Hi,
This is study about unit models code and advice how to manage your code for modding. I will explain how the unit models and unit animations are built in that skript file and how you can edit unit textures thare. I include some rules how this must be edited to get your animation and new skins to work for your (new)units.
If you open battle_models.MODELDB with notepad you will have really mess on screen:
Example:
22 serialization::archive 3 0 0 0 0 701 0 0 10 mount_pony 1.12 0 0 3 0 0 52 unit_models/Mounts/Medium_Horse/mount_pony_lod0.mesh 121 52 unit_models/Mounts/Medium_Horse/mount_pony_lod1.mesh 1225 52 unit_models/Mounts/Medium_Horse/mount_pony_lod2.mesh 10000 0 0 24 0 0 7 england 69 unit_models/Mounts/Medium_Horse/textures/medium_horse_england.texture 68 unit_models/Mounts/Medium_Horse/textures/medium_horse_normal.texture 42 unit_sprites/england_Mount_Pony_sprite.spr 8 scotland 70 unit_models/Mounts/Medium_Horse/textures/medium_horse_scotland.texture 68 unit_models/Mounts/Medium_Horse/textures/medium_horse_normal.texture 43 unit_sprites/scotland_Mount_Pony_sprite.spr 6 france 68 unit_models/Mounts/Medium_Horse/textures/medium_horse_france.texture 68 unit_models/Mounts/Medium_Horse/textures/medium_horse_normal.texture 41 unit_sprites/france_Mount_Pony_sprite.spr 3 hre 65 unit_models/Mounts/Medium_Horse/textures/medium_horse_hre.texture 68 unit_models/Mounts/Medium_Horse/textures/medium_horse_normal.texture 38 unit_sprites/hre_Mount_Pony_sprite.spr 7 denmark 69 unit_models/Mounts/Medium_Horse/textures/medium_horse_denmark.texture 68 unit_models/Mounts/Medium_Horse/textures/medium_horse_normal.texture 42 unit_sprites/denmark_Mount_Pony_sprite.spr 5 spain 67 unit_models/Mounts/Medium_Horse/textures/medium_horse_spain.texture 68 unit_models/Mounts/Medium_Horse/textures/medium_horse_normal.texture 40 unit_sprites/spain_Mount_Pony_sprite.spr 8 portugal 70 unit_models/Mounts/Medium_Horse/textures/medium_horse_portugal.texture
Readable? I think not. Well i study the code and results are next:
Read more about adding units to another factions
Thread is http://www.twcenter.net/forums/showt...t=74945&page=2
I will ldescribe how the unit skin skript is build up in the battle_models.MODELDB as i understand it.
Description of most widely used unit Mercenary Crossbowmen
RULES:
1. String lenght number AND String must be on same line, Enter key not allowed, you will have CTD if launching Medieval2.exe.
2. To test it out, if thare are mistakes just launch medieval. If something is wrong you will have CTD. Most problem is that the number and string lenght do not mach.
3. If you have MS Word edit it thare and keep track changes nad make spaces and othet forms visible but you have to copy it back to notepad to save the info. You can't save it in word.
So i tested it out with next code in my battle_models.MODELDB
This is original copy-paste from my file.
You can read it and medieval 2 also. Have nice modding.![]()
16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
21 mercenary_crossbowmen
1 4
68 unit_models/_Units/EN_Peasant_Padded/mercenary_crossbowmen_lod0.mesh 121
68 unit_models/_Units/EN_Peasant_Padded/mercenary_crossbowmen_lod1.mesh 900
68 unit_models/_Units/EN_Peasant_Padded/mercenary_crossbowmen_lod2.mesh 2500
68 unit_models/_Units/EN_Peasant_Padded/mercenary_crossbowmen_lod3.mesh 6400
1
4 merc
77 unit_models/_Units/EN_Peasant_Padded/textures/EN_Peasant_Padded_mercs.texture
78 unit_models/_Units/EN_Peasant_Padded/textures/EN_Peasant_Padded_normal.texture
50 unit_sprites/merc_Mercenary_Crossbowmen_sprite.spr
1
4 merc
66 unit_models/AttachmentSets/Final European CB Gun_merc_diff.texture
66 unit_models/AttachmentSets/Final European CB Gun_merc_norm.texture 0 <- ends with double space
1
4 None
18 MTW2_Fast_Crossbow
20 MTW2_Non_Shield_Fast
1
21 MTW2_Crossbow_Primary
1
18 MTW2_Sword_Primary
Description about file above.
Animation section:
16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002 (<- positsion or something, pony has all 0-s entry )
21 (string lenght of ->) mercenary_crossbowmen (< it ends with space and it is the model name. It must be same as "soldiers" in EDU, to use this animation for that unit, same rule for armor upgrades)
1 (<- don't know what that number means, do not change it.. :hmmm: )
4 (number of *.mesh strings or files to come. These are hardcoded unit animation files. You can't change weapons.)
68 (string lenght of ->) unit_models/_Units/EN_Peasant_Padded/mercenary_crossbowmen_lod0.mesh 121 (<- distance when it is used)
68 (string lenght of ->) unit_models/_Units/EN_Peasant_Padded/mercenary_crossbowmen_lod1.mesh 900 (<- distance when it is used)
68 (string lenght of ->) unit_models/_Units/EN_Peasant_Padded/mercenary_crossbowmen_lod2.mesh 2500 (<- distance when it is used)
68 (string lenght of ->) unit_models/_Units/EN_Peasant_Padded/mercenary_crossbowmen_lod3.mesh 6400 (<- distance when it is used)
Texture section
1 (number of factions can use the texture)
4 (string lenght of ->) merc (<- faction whos case the unit texture is used. Merc means Mercenary_unit, so all factions can use this!)
77 (string lenght of ->) unit_models/_Units/EN_Peasant_Padded/textures/EN_Peasant_Padded_mercs.texture (<- unit skin texture file to be used, variety of diferent textures for same unit)
78 (string lenght of ->) unit_models/_Units/EN_Peasant_Padded/textures/EN_Peasant_Padded_normal.texture (<- texture file to be used for shading, lighting and other effects, seems more alpha texture)
50 (string lenght of ->) unit_sprites/merc_Mercenary_Crossbowmen_sprite.spr (<- sprite file to be used fo long range view to make game run faster)
1 (number of factions can use the weapon texture)
4 (string lenght of ->) merc (<- the faction whos case next animations will be used in battle: It has diferent shield pictures and weapons)
66 (string lenght of ->) unit_models/AttachmentSets/Final European CB Gun_merc_diff.texture (<- texture file to be used for different weapons)
66 (string lenght of ->) unit_models/AttachmentSets/Final European CB Gun_merc_norm.texture 0 (<- texture file to be used for different weapons shading and lighting effects, includes alpha and brightness)
Weapons section
1 (<-number of strings lines to come about mount)
4 (string lenght of ->) None (<- mount type, if none then the unit is on foot)
Next two files are animations, unit has crossbow and no shield
18 (string lenght of ->) MTW2_Fast_Crossbow
20 (string lenght of ->) MTW2_Non_Shield_Fast
1 (<-number of strings lines to come, norse archer has two entrys and number two)
21 (string lenght of ->) MTW2_Crossbow_Primary (<- the animation if crossbow is primary weapon)
1 (<-number of strings lines to come, norse archer has two entrys and number two)
18 (string lenght of ->) MTW2_Sword_Primary (<- the animation if sword is primary weapon)
Unfortunately you can't turn one animation off to use secondary animation instead. I have not find out how to do this. Lanced units use lance instead of swordseems very funni to me.
Now it is more readable! You can use "Enter" to separate lines, it will not disturb your code! But keep in mind that the number and stringline must be on same line!! The reason is because the game can't parse the code if it don't know the lenght to read. Keep in mind that all spaces must stay as thare are. Every line in that example ends vit one space And some 0 has double space.
Usually it is weapon effect skin what ends with zero and double space.
Example is "66 unit_models/AttachmentSets/Final European CB Gun_merc_norm.texture 0 <- this 0 ends with double space.
Anothed units (Norse Archer, it has shield) full code:
16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
13 norse_archers
1
4
60 unit_models/_Units/EN_Peasant_Padded/norse_archers_lod0.mesh 121
60 unit_models/_Units/EN_Peasant_Padded/norse_archers_lod1.mesh 900
60 unit_models/_Units/EN_Peasant_Padded/norse_archers_lod2.mesh 2500
60 unit_models/_Units/EN_Peasant_Padded/norse_archers_lod3.mesh 6400
1
7 denmark
79 unit_models/_Units/EN_Peasant_Padded/textures/EN_Peasant_Padded_denmark.texture
78 unit_models/_Units/EN_Peasant_Padded/textures/EN_Peasant_Padded_normal.texture
52 unit_sprites/denmark_Dummy_EN_Archers_ug1_sprite.spr
1
7 denmark
60 unit_models/AttachmentSets/Final Danish_denmark_diff.texture
60 unit_models/AttachmentSets/Final Danish_denmark_norm.texture 0
1
4 None
11 MTW2_Bowman
14 MTW2_Swordsman
2
19 MTW2_Bowman_Primary
14 fs_test_shield
2
18 MTW2_Sword_Primary
14 fs_test_shield




Reply With Quote








