The first steps
This is a STEP BY STEP guide to show you how to create a WORKING custom settlement using IWTE. It does not replace the King Kong's Tutorial, just guides you in a more friendly and didactic way.
1 – Download Milkshape 3d
2 - Download IWTE
3 - Download King Kong's tutorial
4 – Do this.
5 - Create a new text file in C:\Program Files (x86)\SEGA\Medieval II Total War and rename the file extension to .bat. Open this file and place the following code on it:
Save it and close it. Then create a copy of your medieval2.preference.cfg, rename it to mod.cfg. Then create a shortcut to your newly-created .bat file, you will use that shortcut to acess the game and see your custom settlement.Code:medieval2.exe @mod.cfg
6 - Open IWTE.
7 - If you want to edit your terrain, you can do it by the following 3 ways, if not go for step 11.
- In milkshape 3d. (Only use this if you want to make very small changes or flat ramps)
- In IWTE. (Only for very small and simple modifications)
- In photoshop. (This is where you will make 90% of the edit, the rest can be made using the 2 other ways. Its the only way to get smooth natural surfaces).
8 - In IWTE, go for Terrain 1 tab. Click create terrain TGA´s, find your .terrain file in C:\Program Files (x86)\SEGA\Medieval II Total War\data\settlements\select the one you want to edit (north_european, south_european etc.)\settlements\select the one you want to edit (city, large_city etc). Select it. Keep the settings as they are in the boxes, dont change it. Click OK. Go in the folder and find the file you created (there will be 3 TGAs, open the "terrainbase" one. Edit it in photoshop (the lighter a zone is the higher it is, the darker it is the deeper it is). Save your file in photoshop.
9 - In IWTE in Terrain 1 tab, click "replace with terrain base TGA", select your recently modified TGA file and your .terrain file, they are in the folder you previously choosed. Click ok (again, dont change the values on the boxes). Go to settlement's folder in windows explorer, you will find your new .terrain file created, delete the original one (keep a backup on your junkbox), and then rename the new one with exactly the same name from the original one.
You can now go in the game and check your modifications (enter the game using the shortcut your created on step 4!
Detailed explanations about editing the terrain are here
10 - In IWTE, go for the Terrain1 tab and then click create terrain .ms3d, select the .worldterrain file in the folder you are working on, now go to this folder , and you will find your terrain in a 3d file.
10 - Open the 3d terrain file you just created. In milkshape 3d, go to Vertex and then Mirror Left < -- > Right. Save and keep that file separated, it will be the basis for you to place the buildings on your settlement. You can now fit the terrain with your objects (walls, houses etc). So your game editor is actually Milkshape 3d, its your pick and place tool.
11 - In your terrain file, inside milkshape 3d, merge already done models (file -> merge) or create your own in milkshape 3d, then place it where you want, this represents exactly what you will see in the game. Delete the terrain GROUP in milkshape 3d (Groups tab on the right), get back to model tab, click comment, delete all text in it. Now you have only your object (a house for example), and it is ready to be inserted on your custom settlement.
With this procedure, you can place as many objects you want inside your settlement. You cant work in too much objects at the same time since milkshape 3d has a vertex limit, so maybe you will need to create various 3d files containing your buildings for the settlement.
12 - In IWTE, click Read 3 Binary Files
13 - Go to the folder of the settlement you choose before.
14 – It will show up a .world file, select it, then it will show a .worldcollision file, select it, then it will show up a .animinstances file, select it. These are the three main files of you settlement. Now the settlement is loaded in IWTE.
15 - Click on the Structure tab. In the structures window (right side of IWTE) select anyone (I recomend to select the last one, then your new one will be the new last one, easier to find on the list) and then click Add structure. Find the .ms3d files you created before and select it. Select the texture you want to apply on your model. Click ok and then your model will be added on the settlement.
Check King Kong's tutorial for adding new textures.
16 - Click on the Worldfiles tab, click save 3 binary files, go to the folder of the settlement in windows explorer, you see now there is 3 new files created, with number added to its name. Keep these 3 new ones, delete the original 3 ones (but keep them on your junkbox as a backup!). Change the name of the new ones so they will look axactly as the old ones, replacing them. Your settlement is now changed, go inside the game (using the shortcut you created before!) and check your changings.
This is the most basic steps to start messing up with IWTE but is the most difficult part to someone who is starting to deal with it. After that, you can now go changing your terrain and adding your own structures. The rest is just about small procedures and tricks you must learn by yourself and use your imagination.
Remember to check the tutorial by King Kong.
Here you find a very extense thread with lots of doubts already solved, look for your answers there.
DO SEARCHES BEFORE POSTING ANY DOUBT, DONT WASTE THESE GUYS TIME AS THEY ALREADY GAVE TOO MUCH CONTRIBUTIONS AND DESERVE A REST.
Planning your settlement's layout
The first thing you must plan for your settlement is the layout. It includes the plaza position, the position of walls/gates and the paths that the AI/Player can use to move inside/arround it.
Do not conceive bizarre layouts! It will not work, you must follow the engine laws!
I recommend you to firstly make a sketch of it with paper and pen.
1 - Edit the pathfinding:
Combined with the plaza position ,this is the most impportant, it defines if your settlement will work or not, for the attacking AI. Actually, you should first of all edit your pathfinding the way you want your settlement, even without inserting buildings etc. Then place the walls/gates (if there are), and then test it. This way you can test your settlement very early and save lots of future work.
Do not insert your buildings before beeing sure your layout totally works!
Basically, the AI in med 2 is made to handle the vanilla layouts. If you just mimic a vanilla pathfinding for your layout, there is big chances things will work then.
However, we have seen custom settlemets with unique layouts working well. You can dare making something different, but no guarantees it will work.
The AI need space for reaching the plaza by flanking, layouts with only a direct way to the plaza does not work well, so leave latteral entrances for yourt plaza!
Block the pathfinding where there are walls/gates but also in any region you want the terrain to be unpassable.
While testing your layout, you should flat your's settlement terrain, so there will be no heigh blockages for the units. And now you start editing your pathfinding.
This is an example of a working layout I did by editing pathfinding in photoshop:
Place the plaza where you want.
Notice that after each gate, there must be a working layout. If you look in a vanilla city layout, wich has 4 entrances (gates), there is a different layout after each one. They all work well for the AI. If you plan a layout with more than 1 entrance, you must test them all, just rotate the settlement so the attacking army will be spawn in front of another gate.
If your settlement has 2 or 3 wall/gate lines, the layouts between lines needs no worry, they can be anything, as far as there is a next wall/gate line, the AI will cross this layout and find this next line. But that must be tested of course, some times the AI get stuck, some times not... The last layout, wich is after the last gate, and contains the plaza, must be made carefully. I suggest copying this one from vanilla.
BEWARE! Even the smallest pathfinding changing can cause the AI to change his behavior! I got some experiences with AI change the way they move after I added some blocked pathfinding arroung a pillar. So keep in mind that after every change in pathfinding you need to test the AI behavior and see if they act the way you want.
2 - Testing your layout:
ATTENTION, CHECK THE "TRICKS AND TIPS" SECTION FOR SOME VITAL INFO ABOUT SETTLEMENT FUNCTIONALITY IN STRAPMAP.
Now you must test your settlement. Load a battle on the custom battle menu.
You will need to test it with some setups.
Ai will properly defend any layout, you dont need to test the AI defense.
The attacking AI behavior:
The AI will break the walls/gates, join the settlement, organize, and then try to reach the paza. They will likely divide in groups, some groups will try to circle the plaza using latteral roads, another groups will just go ahead to the plaza. They will put all their units in the plaza, if they are not running for the plaza will all men, that means your layout is not working well. The more units left without fighting, lost anywere in the city, the more your layout is wrong. A layout where only 1 or 2 enemy attackers are stuck doing nothing can be considered good, as it is very difficult to make it perfect and vanilla med2 never worked perfectly anyway.
If they flee, they will ocasionally back to fight or get stuck and doing nothing. Sometimes it happens that they flee and just stay some meters from the palza, doing nothing. No problem, it is like that in vanilla med2. THIS IS HOW AI SHOULD ACT WHEN ATTACKING.
Pay attention in what they are doing. Sometimes they get confused and keep moving in a small area, going on and going back, shouting "foward!" or "move!".
This is caused by pathfinding.
2.1 - Testing:
ATTENTION: DURING ALL THE TESTS DESCRIBED AHEAD, YOU MUST SET THE AI ARMY AS A FULL STACK, AND YOURS (DEFENDER) AS JUST 3 OR 4 OF THE BEST POSSIBLE UNITS WITH ALL UPGRADES, PLACE YOUR UNITS IN THE PLAZA AND STAY THERE, WATCH THE AI ACTING THEN. ITS THE BEST WAY I FOUND TO TEST IT.
You should test your settlement for diferent AI attacking army setups. Give them rams, then give them siege towers, try them with only infantary, then try with a combination of archers, cavalary etc... try ginving them no siege engines but just siege weapons (catapults etc), try everything!
The most known AI issues are:
- They get in the settlement but stuck right after the walls.
- They try to circle the settlement from outside and get loss in the corners of the battlemap.
- They attack the plaza with some units but other ones gets lost in the settlement or outiside it.
All that issues are fixed by editing the pathfinding and relocating the plaza!
Set the speed to 6x and give them some time. Sometimes they keep organizing the army and only then they attack properly, so give them some time.
So if it shows any of these issues, your settlement is not working well. Time to remodel it.
After each line of walls/gate, there must be a handable pathfinding layout in order to get the AI attacking it properly.
Notice that each gate must have a handable layout behind it, that means if you want a settlements with 4 gates in the first line of walls, you will need to edit the pathfinding and test with attacking AI comming from all 4 directions... I recommend you to use vanilla layout and walls/gates, and just edit the buildings... otherwise... prepare to suffer...
Settlements without any line of gates/walls will likely work well but this is not granted, even a settlement without gates/walls can have bad functionality for attacking AI. Notice that they will try to circle the settlement and find alternative routes for the plaza even if there is not such route! Sometimes terrain blockage is not enough, thats means that if there is only one entrance for your settlement and the plaza is on the top of a hill, yet the AI will try to circle and get near the plaza. So you must edit the pathfinding arround the plaza, blocking it.
BE CAREFUL ABOUT THE TERRAIN HEIGHTS AND WATER! It seems like water under the terrain where the units will move can totally bug the AI movement. If you make terrain too lower (unpassable) even in places where the units should not be able to walk (like blocked by blue pathfinding), that can totally affect the pathfinding for AI and completly change their behavior! It seems the AI gets confused when trying to calculate that pathfinding on such terrain.
Cavalary seems to have problems with too tight pathfinding passages. Do not make any passage too tight, otherwise cavalary will get confused without knowing what to do and that will compromise the behavior of all their army. I got that problem once, enlarging pathfinding passages was the fix for it. So you must use cavalary while etsting it, not only infantary or archers. In the other hand, infantary seems to have problems with too large paths. So you must find the ballance.
The AI is capable of handling very complex settlements when you have 2 or 3 lines of walls/gates. They lead the ram/ladders in very difficult paths to reach the consecutive lines.
Catapults and ballistas can pass under gatehouses, that means if your settlement has no walls, they can break the gate and enter the settlement with these siege weapons. If your settlement has 2 or 3 line sof walls, the AI is also very smart in leading the catapults/ballistas to the consecutive walls, they can handle complex layouts with this siege equipment.
Trebuchets cannot pass under gatehouses. For they beeing able to, there must be walls. Trebuchets can break and then pass through broken walls, getting near the next line. The trebuchets will break line after line until their army can reach the plaza. If the lines are at a short distance, they can fire and break them all even without entering the settlement! In that case they just fire from outise it.
Do not put any big blockage that could avoid the trebuchets hitting the walls. Like buildings or mounts.
Trebuchets seems not capable to handle complex routes, if your settlement will have 2 or more lines of walls/gates then they should be parallel. The trebuchet is not good at rotes with curves. However, I've managed to make the trebuchets to handle Minas Tirith path until a second gate on the 6th level, so you can try it and "fool" the AI.
I really recomend you repeating the tests with different AI attacker army setups, give them more, then give them less units. Use infantary or just cavalary or both. The more tests you do, the more you will know if your layut is ok.
Here is a video of the AI acting in my esgaroth custom settlement:
Another one showing the AI behavior for my new version of Minas Tirith. (the video dont shows it but all the attacking units reaches the plaza!)
Sally Forth testing:
For testing it, load a custom battle where you attack with a single unit and give the AI defender a full stack. When the battle starts, they will notice the advantage and sally forth. Now observe if they act normal when salling forth. If not, the solutions would be the same presented before.
If your settlement has a gate/walls line, sally forth will work with no difficulties.
If not, I really recommend you to copy and use a vanilla pathfinding layout, I did Fangorn like that, used a village layout.
Remember that the 3d wall model you will use must match the settlement type. So if you use a huge wall model, then the settlement must be a huge city (wich is the only settlement type that uses huge walls). Otherwise the engine will produce wrong siege equipment while in siege (ladder and siege towers sizes) and would result in fail.
PS: If you use huge walls in your settlement, and set his type as something that uses large walls (like large_castle), the engine will produce smaller siege equipment than what is really necessary for matching the size of the wall. However, th siege ewuipment will work fine, even the animations works fine, the heigh difference between the ladders/towers and the wall is not that much, so it does not look that bad! I can only say that for the example I told. I have no experienced different sizes than that.
PS: If you are planning to make a settlement with a gate but no walls , consider not having towers on it. Because in a settlement like that the only siege engine usable will be the ram; with too powerful defences (the towers) the defenders would likely fire the ram very quickly, winning the battle by destroying all attacking capacity from the attacker.
NOTE: If your layout has more than 1 line of walls/gates, I recomend you to place the second one a little bit more high than the first one (and then the 3rd one higher than the second). This is how they are in vanilla medieval 2 and it seems to avoid catapults and trebuchets wasting all ammo by missing the walls when firing.
They work well and does not affect pathfinding badly, if you place them in the right position. Barad dur is there to prove it.
BEWARE: Do not put wall/gate breaches near bridge paths. If there is a bridge and then a gate, like in Barad Dur, there must be a space between them, otherwise the AI will act strange when attacking with rams, that will also mess the player.
Also, it seems like the AI does not like bridges between gates. Means that if you are planning to make a settlement with 2 or more lines of gates, it is better to not include bridges between such lines in your plan.
Integrating your settlement with the strat map.
Once you are in battlemap, of your custom settlement, right at the end of your settlement terrain, the engine fits with terrain generated based in the strat map.
That engine generated surrounding is based on the strat map terrain where your settlement is.
If there is a mountain in the strat map, in any of the 8 tiles that surrounds your settlement (see image), then that mountain will show up in the surrounding of your battlemap custom settlement, exactly in the same position. The same for rivers, sea and any heigh variation. And also textures.
After implementing your settlement, you might have to edit the borders of your settlement terrain so it matches the surroundings (wich are generated by the engine). Otherwise it would look like strange edges at the end of your terrain, not integrating well with the rest. Thats boring and you must test it lots of times ingame.
Keep in mind that the strat map arround your settlement will show up axactly the same in the loaded battlemap of your settlement. The same goes to armies involved in a battle on that settlement. When the battle is loaded, they will show up exactly where they were on the strat map.
For example, Dunharrow is placed in the strat map in a way that if the attacker comes from gondor (south) they will show up behind the settlement, where I edited the terrain of the settlement to be the tight corridor between the mountains. While if the attacker comes from Rohan (north), they will show up in front of the zigzag ramp path of the settlement.
That could lead to armies spawn on mountains or rivers wich would lead to his death or game crash.
You can avoid that by editing your settlement terrain in a way that there would be no water/mountains in the positions where armies are supposed to deploy. Or even editing pathfinding and terrain on the strat map so no army can approach the settlement from that direction.
While testing sally forth or your attacking armies comming from multiple tiles, remember that your armies will be spawn in two possible distances from the settleent. If they have sige engines, they will show up right near the gate settlement (or in a certain distance from the defender deployment zone, in case there is no gate.). Now, if they have no siege engines, they will come from the border of the map, more distant. You must test both to be certain about the functionality of the attacking armies.
The position of the settlement strat map model is customized by you and does have no relation with the vector your settlement is in battle map. So you might have to rotate your entire settlement (IWTE can do it easly), in order to have it showing up the way you want when loaded. (See image).
The image shows two examples of the explained (wich concers to the settlement loaded in battlemap and not the strat map model, something tottally different and has no influence here).
ATTENTION: ROTATING YOUR SETTLEMENT CAN (VERY LIKELY) MESS YOUR GATE/WALLS BREACHES AND BRIDGE PATHS, GIVING A STRANGE BUG WHERE UNITS PASS IN A BOTTLENECK. DELETE THESE BREACHES AND GIVE NEW ONES AFTER ROTATION.
Integrating your settlement with water from strat map.
As explained, you can edit your terrain in a way that it will integrate with water surfaces generated by the engine, not only surrounding your terrain but also invading it. All you need to do is edit the terrain heighs. The water plane from sea and lakes extends itself "infinitely", if you can see water near your settlement, that means this water plane is in all the terrain, under it, hidden. Edit the terrain by lowering it and the water will show up in the battle map automatically. This is the way esgaroth was made. I did not added any water surface in IWTE (wich is possible). The water you see there is actually the water from lake esgaroth, generated by the engine on my battlemap.
Here you find a very extense thread with lots of doubts already solved, look for your answers there.
DO SEARCHES BEFORE POSTING ANY DOUBT, DONT WASTE THESE GUYS TIME AS THEY ALREADY GAVE TOO MUCH CONTRIBUTIONS AND DESERVE A REST.
Tricks and tips.INVISIBLE GATE - If there is only 1 gate on your settlement (in the first line of walls/gates), then the attackers will always be spawn in front of this gate, no matter where they come from in the strat map. So if you want to keep only one gate but make attackers be spawn in another front when the battle is loaded, you can simply add a new gate on that front, with an invisible texture. Place some building above it, like a rock aor anything else, block the pathfindings on it and leave the pathfinding free for the AI pass arround the gate. then, armies comming from that direction in strat map will show up in front of this new gate when the battle is loaded. Thats how I did with the black gate, units comming from mordor now show up in back of the gate, with no obstacles between them and the plaza!
CLEAN GATE AIM- Do not hide your gate too much inside the gatehouse! Otherwise the projectiles from catapults etc will miss all the shots, hiting the gatehouse, and compromising the attacker, also, remember to not put any obstacle in front of the gate. In barad dur, for example, there is some obstacles that could prevent projectiles hitting the gate, but they have no collision so projectiles simply pass through it and then hit the gate.
ENGINE MYSTERIES. - The map climates are different in therms of AI behavior, means the same settlement can work well in a climate and not in another one. This is all about testing. The settlement height, controled by IWTE by vector change, is also responsible for making the AI working well, you also need to test different height for the settlement and for the terrain. Info about this can be found here. That means a settlement can work well in some custom battle locations and not in other ones, or even work well in custom battles but not in the campaign map.
In settlements with 3 lines of gates (3 perimeters), if you make a unit leave a perimeter and left no other unit inside it, the gate will not close after you pass through it.Known Medieval II engine bugs.