Fisheries terrain mod

Post Reply
dejvid2
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 103
Joined: Sat Nov 04, 2017 2:50 pm

Fisheries terrain mod

Post by dejvid2 » Fri Oct 26, 2018 3:11 pm

I am posting this with two aims. First because I need help and second because it might be helpful to other modders to see the steps I have taken.
Hence it is probably a little longer than it really needs to be for those who understand modding sufficiently to answer my question. So apologies to them in advance.
The problem.
The Peloponnese is mainly hills and so my scenario is currently very short of food. I want to increase food production in limited areas.
Farms in the sea?
The vanilla mod provides (under <terrainAttributes> ) <terrainExtensions> which increase food ie fields (aka TerrainExtension.AgriculturalLand) and farms. Why not farms for the sea like the Holland mod has (though the Holland mod uses basin and nets for fish not food of course)
But then I will have to get into the tech tree etc. And I want the food boost to be fixed. I don’t want players (human or AI) so filling the seas with terrain extensions that there is quickly a glut of food.
Creating a new <terrainProperties>
There are ten fundamental terrain types from grass thru water 4 to swamp (10). So I copied the water TerrainPropertiesMemento and stuck it in my changing the name from water to name="Terrains.FISHERY", replacing the ProductMemento <ProductMemento id="5" perTurns="1" value="3.6" /> (before it had value="0.6" ) and the id from 4 to 11.

And it worked - sort of. The cities with fishery tiles next to them did start using them and so had a greatly enhanced supply of food. But boats couldn’t go into them.
So I looked at the definition of boats which is defined as <UnitModelMemento id="57" parentModelId="0" scripting="Boat" name="Units.Boat" etc.
Each unit definition has this section:
<terrains inheritsFromParent="false">
<terrainBehaviors>
<TerrainBehaviorMemento
and there are 10 TerrainBehaviorMemento all have movementConsume="-1" except the 4th down (and water is id 4 of course) which has movementConsume="1".
“Ah-ha, all I have to do is add and 11th with movementConsume="1" and boats (and galleys aka Units.NavalTransport and Triremes) will know they can go onto the tile.

But when Aggressors tried to load my mod it crashed.

So my question is what is the cause.
It could be a silly error in my xml code but my xml editor says the file is “well formed”. Also when I have made an error in the xml the crash is instant. Now Aggressors hangs for a minute or two and then crashes.
It could be there is yet something else I need to define, but what?
It could be that Aggressors is only set up to have terrain types and in that case I must look at farms in the sea or maybe replacing a terrain type instead of adding one.


Any pointers?

Cablenexus
Sr. Colonel - Battleship
Sr. Colonel - Battleship
Posts: 1680
Joined: Mon Jan 04, 2016 7:09 pm

Re: Fisheries terrain mod

Post by Cablenexus » Sun Oct 28, 2018 1:23 am

Hi,

My first suggestion is never make something more difficult then it is. Many times some minor changes at first sight, will influence other area's you are not aware of. I would say, stay away from altering functionallity that is not 100% necessary or you know 100% what you are doing.
That said:

- You can simply increase the food production for hills. You can select where you want to place hills. This is just a single value in terrainID.

- Watertiles already provides an amount of food automatically. So you can simply increase the food production for existing water tiles (the same you want to achieve with the 11th terrain).

About the terrain you added. I understand what you want to achieve. In your scenario you want to place this 11th watertiles only on places accesable for the faction that you want to yield them.
What you did by adding a 11th terrain to your mod looks good to me, if I do the same my mod.ag file looks like this:

Look at the screenshot. Make sure this is how your MOD ag looks like. (I think your mod crashes because you miss those elements/attributes) If any questions feel free to ask. I just helped you now with the technical part. I did not judge the outcome of the values and if I think it's a good idea to do it this way, but I encourage you to try.

Change the bitmapIndex to 13 and remove the coastmap index. Otherwise your new terrain will not show up in the editor.

<TerrainPropertiesMemento id="11" name="Terrains.FISHERY" color="-16747623" isRotationAllowed="false" roadSuitability="0" roadAllowed="false" altitudes="3" staticGeometrySurroundingsScale="1.0" defaultUnitOffset="-0.1" isOwnerable="false" isFlat="true" isDefaultNewMapTerrain="true" bitmapIndex="13"
fishery2.jpg
fishery2.jpg (485.01 KiB) Viewed 1185 times
fishery.jpg
fishery.jpg (199.04 KiB) Viewed 1185 times
Last edited by Cablenexus on Sun Oct 28, 2018 2:21 am, edited 1 time in total.

Cablenexus
Sr. Colonel - Battleship
Sr. Colonel - Battleship
Posts: 1680
Joined: Mon Jan 04, 2016 7:09 pm

Re: Fisheries terrain mod

Post by Cablenexus » Sun Oct 28, 2018 2:10 am

In addition to my previous post, do not use ID 11, it's better use something like 111 or 21 or so. 11 might be used by the devs in the future.
This is a general (unwritten) rule for all the parts you eventually add (units, behaviors etc)

Now for the boat:
fishery3.jpg
fishery3.jpg (547.57 KiB) Viewed 1180 times

Cablenexus
Sr. Colonel - Battleship
Sr. Colonel - Battleship
Posts: 1680
Joined: Mon Jan 04, 2016 7:09 pm

Re: Fisheries terrain mod

Post by Cablenexus » Sun Oct 28, 2018 2:18 am

Some notes:

- Adding new terrain is pretty advanced and it affects a lot. There is also not enough space in the terrain bitmap file to add many new terrain types. Your new terrain also needs an image, and I suggest you use bitmapindex 13 for it:

<TerrainPropertiesMemento id="11" name="Terrains.FISHERY" color="-16747623" isRotationAllowed="false" roadSuitability="0" roadAllowed="false" altitudes="3" staticGeometrySurroundingsScale="1.0" defaultUnitOffset="-0.1" isOwnerable="false" isFlat="true" isDefaultNewMapTerrain="true" bitmapIndex="13"

And remove the coastmapindex at all for terrain 11.

But you will also need to change the image in the bitmapfile.

H:\SteamLibrary\steamapps\common\Aggressors Ancient Rome\Bin\Mods\ancient_rome\Graphics\Textures\High and Low

Must be saved as DDS. file
fishery4.jpg
fishery4.jpg (86.01 KiB) Viewed 1179 times
The result is you can use boat 57 on terrain 11 in your own mod on a new terrain tile:
fishery5.jpg
fishery5.jpg (541.18 KiB) Viewed 1179 times

Cablenexus
Sr. Colonel - Battleship
Sr. Colonel - Battleship
Posts: 1680
Joined: Mon Jan 04, 2016 7:09 pm

Re: Fisheries terrain mod

Post by Cablenexus » Sun Oct 28, 2018 2:27 am

Last ;-)

To have a nice description and name for terrain (instead of terrain.FISHERY) you need the Resourcetextfile.

you have to add:

<data name="Terrains.FISHERY" xml:space="preserve">
<value>Super Fertile Sea Tile</value>
</data>

Remember that if you make your own resourcetext file for your mod you will need at least this:

</root>

At the end of it.

And at the start you need at least EVERYTHING between this:

<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema

And this:

<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
fishery6.jpg
fishery6.jpg (255.85 KiB) Viewed 1177 times

pavelk
Kubat Software
Kubat Software
Posts: 2445
Joined: Mon May 16, 2016 4:27 pm

Re: Fisheries terrain mod

Post by pavelk » Sun Oct 28, 2018 9:22 am

Cablenexus is absolutely correct and thank you for such a detailed instruction how to do it. Adding new terrain is not an easy operation (especially because of you need to define all the TerrainBehaviors for unit models which will be allowed to pass through. Once you define that, you will be pretty much done. You just need to define the terrainProperty itself.
Good luck and let us know how did it go

dejvid2
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 103
Joined: Sat Nov 04, 2017 2:50 pm

Re: Fisheries terrain mod

Post by dejvid2 » Sun Oct 28, 2018 2:29 pm

Thank you Cablenexus for a very complete reply

My error was to assume that
<TerrainBehaviorMemento movementConsume="1" attackBonus="0" defenseBonus="0" silentMovementConsume="-1" terrain="121" railMovementConsume="-1" roadMovementConsume="-1" movementConsumePercentage="0" attackBonusPercentage="0" defenseBonusPercentage="0" silentMovementConsumePercentage="0" railMovementConsumePercentage="0" roadMovementConsumePercentage="0" priority="0" viewRangeChange="0" attackRangeChange="0" defenseRangeChange="0" terrainOffset="0" />
got its id from its position so I had two terrain="4" so of course it crashed.
Curious foible: if I only have my fisheries TerrainBehaviorMemento the game won't allow the loading of land units when the boat is on water tiles. Adding the old TerrainBehaviorMemento with terrain="4" in front of my new fisheries one with terrain ="121" one soves this.

I have now got it to a level that's playable but I will need to go carefully thru your posts to get it playable.
EDIT:
I have now got it to a level that's playable but I will need to go carefully thru your posts to get it PUBLISHABLE.
Last edited by dejvid2 on Sun Oct 28, 2018 5:43 pm, edited 1 time in total.

Cablenexus
Sr. Colonel - Battleship
Sr. Colonel - Battleship
Posts: 1680
Joined: Mon Jan 04, 2016 7:09 pm

Re: Fisheries terrain mod

Post by Cablenexus » Sun Oct 28, 2018 3:34 pm

dejvid2 wrote:
Sun Oct 28, 2018 2:29 pm
Thank you Cablenexus for a very complete reply

My error was to assume that
<TerrainBehaviorMemento movementConsume="1" attackBonus="0" defenseBonus="0" silentMovementConsume="-1" terrain="121" railMovementConsume="-1" roadMovementConsume="-1" movementConsumePercentage="0" attackBonusPercentage="0" defenseBonusPercentage="0" silentMovementConsumePercentage="0" railMovementConsumePercentage="0" roadMovementConsumePercentage="0" priority="0" viewRangeChange="0" attackRangeChange="0" defenseRangeChange="0" terrainOffset="0" />
got its id from its position so I had two terrain="4" so of course it crashed.
Curious foible: if I only have my fisheries TerrainBehaviorMemento the game won't allow the loading of land units when the boat is on water tiles. Adding the old TerrainBehaviorMemento with terrain="4" in front of my new fisheries one with terrain ="121" one soves this.

I have now got it to a level that's playable but I will need to go carefully thru your posts to get it playable.
Feel free to ask any question, the level you are operating on without asking any help is already a very good start.
Good luck.

Post Reply

Return to “Aggressors Modding”