Results 1 to 4 of 4

Thread: (Almost) Complete Guide to Adding a Unit

  1. #1

    Default (Almost) Complete Guide to Adding a Unit

    First off, I know there are already tutorials on this subject.
    Anyway,
    I spend a lot of time doing this so I thought I should share this with y'all.

    First, decide what the units is going to be. Don't go in blindly hoping to get something good (or if you do, dont expect professional results.) Plan what it is good at, what it is named and maybe even write a short description ahead of time to use in the export_units.txt.

    Next, when it is planned out, open the export_descr_units,txt file, located in the data folder. Find a template unit. For example, I'm adding an infantry unit called "Los Quesos" just cause. Their template will be the Scottish "Highland Nobles." You want a unit with similar mechanics to what you are planning. Los Quesos will be two-handed swordsmen, so hence my choice. Now copy and paste this unit's entire entry from "type...Unit" down to ";unit_info X X X" at the bottom of the file (or top) for easy access. You can put something like "Modded Units" separating it from the other units, just remember to put ;Modded Units so that the game ignores it or else you will crash.
    Now change the type to your unit's name. It doesnt have to be the real one, just something you can remember is this unit. Use spaces, not underscores. Now replace the dictionary entry with something else, same as before except with underscores. The entry near that with the semicolon is ignored by the game, so you can do whatever you want to it.
    So here is mine so far:

    type Los Quesos
    dictionary Los_Quesos ; Mucho queso

    Now move down. The next stuff shouldn't really be changed if you picked a good template, but I'll go through it anyway.
    Category: Infantry, cavalry etc.
    Class: Heavy, light, missile, etc.
    Voice_type: I don't know, but it seems pretty self explanatory. Heavy(says stuff like HEAVY INFANTRY), light, etc.
    Banner faction: Type of flag they use. Main_infantry, main_missile, etc.
    Banner holy: crusade, jihad.

    Next comes what I call the "fun stuff."
    This is where you can customize the soldier a bit. The first entry is "soldier"
    First comes the soldier itself. Highland_Nobles is the model name. If you made a unit model, put the file name here. Next is the number of men per unit. Multiply it by 2.5 to get the unit size in "Huge" mode. 100=250 etc. Next is the number of engines. Ballistas, cannons, elephants etc. After that is the unit's mass. Only works for infantry, but the higher the number, the more they weigh. That means they can knock enemies flying if it's big enough. Best to only change by tenths unless you want supermen.
    Now comes the attributes. I like this part. Here is a list of attributes by Mythic Commodore:


    • sea_faring - This unit can board ships and cross the water. It does not affect the unit's ability to take advantage of landbridges. Also given to ships.
    • hide_forest\hide_improved_forest - Allows the unit to hide in forests. Whether or not you include improved determines how good the unit is at hiding. This also has effects on the campaign map.
    • hide_anywhere - The unit can hide anywhere on the battlefield, like Hashashim or Battlefield Assassins. This does not seem to affect the ability to hide on the campaign map.
    • frighten_foot - The unit frightens foot soldiers.
    • frighten_mounted - The unit frightens mounted soldiers.
    • can_run_amok - The unit can "go crazy" like Elephants. It only works with mounted units.
    • general_unit - The unit can be used as a general's bodyguard.
    • general_unit_upgrade - Used in the Late General's Bodyguards. Of course, they never show up, so this seems to be useless.
    • cantabrian_circle - The unit has the "Circle and Shoot" special ability. Note that a unit may only have one special ability.
    • no_custom - The unit cannot be selected in custom battles, like Mounted Longbowmen.
    • command - The unit provides a morale bonus to nearby units. I am unsure whether it works properly.
    • mercenary_unit - This has two effects - the unit will only use the "merc" version of its model. This means that if I were to allow the French to train Swiss Pikemen, since they have this attribute, they would not wear the French blue and white unless I removed the attribute (or the grayish colouring that they usually have). The second effect is that the unit can now be hired as a mercenary - which is referenced in the descr_mercenaries.txt file.
    • is_peasant - This unit only counts as half for public order purposes. This means that if I had a unit of 150 Swiss Pikemen but they had this trait, then they would only count as a garrison of 75 for the purpose of counting public order in the settlement.
    • druid - The unit has the ability to chant. This raises your morale and lowers the enemy's morale.
    • power_charge - Seems to improve the charging ability of a unit.
    • free_upkeep_unit - The unit can be supported for free in a city, like militia.
    • can_withdraw - The unit can withdraw from battles.
    • hardy\very_hardy - The unit has more stamina than normal.
    • can_formed_charge - The unit can form up and charge, like Mailed Knights.
    • knight - The unit is a knight. This means that they get bonuses from the Jousting Lists and Tourney Field.
    • gunpowder_unit - The unit uses a gunpowder weapon.
    • start_not_skirmishing - Only for missile units. The unit has skirmish mode off by default instead of on.
    • stakes - The unit can lay stakes before battle, like Longbowmen.
    • fire_by_rank - They fire and rotate like Musketeers.
    • cannot_skirmish - I think that this is Kingdoms-only. Disables skirmish for a missile unit.
    • There are also various AI labels. These tell the computer how to use these units and are optional. The AI labels are - guncavalry, crossbow, gunmen, peasant, pike, incendiary (used on Naffatun), artillery, cannon, rocket, mortar, explode, standard (like Great Cross) and wagon_fort (which seems to be unused)


    Basic ones would be sea-faring, hardy, can_hide_forest, can_withdraw.

    Next is the numbers. I'll just run through and explain quickly each one.

    Formation. Straightforward, first two numbers are distance from each other front and back and side to side, second two are same except in loose formation. Last number is normal number of rows in basic formation. Then comes the formations they can be in. Horde (circle) Square, phalanx ( Pike Wall) and wedge are basic ones.

    Stat_health. First number is the amount of health a unit has (1 is normal), second is health of their mount.

    Stat_pri, stat_pri_ex, stat_pri_attr. Stat pri is the basic attack stats of their primary weapons. Attack is first, then charge bonus, then ammo type (if it applies) then range of missile, ammo amount, type of combat (melee, thrown etc.) then missile type (missile_mechanical or missile_gunpowder etc.), then damage type, animation, speed (unused) and priority. Ignore stat_pri_ex, the game does.
    Stat_pri_attr is the attributes of the weapon. Ap for armor piercing, bp for going through multiple people like a catapult.

    Stat_sec etc. is the same except with the secondary weapon.

    Stat_pri_armour is the armour levels. First number is armor level, second is defense ability and third is shield level.

    Ignore the next two, they are useless.

    Stat_heat is how much the unit i affected by heat. The higher the number above 0, the better they do. The lower it is below 0, the worse they do in deserts and so on.

    stat_ground is the different ground types. First is scrub, then sand, then forest and finally snow.

    stat_mental is their mental and physical health. First is their base morale level, then their discipline level (low, normal, disciplined, impetuous), Last is the training level. trained, highly_trained etc. You can add the words lock_morale after that to make the unit never rout.

    stat_charge_distance is the distance in meters at which they begin to charge.

    stat_fire_delay is how long between volleys a unit takes.

    stat_food is not used.

    stat_cost is how much a unit costs to recruit, pay yearly and upgrade. Ignore the "1." The first number is the cost to recruit during the campaign. The second is the upkeep. Third and fourth are cost to upgrade attack and defense. Fifth is cost to recruit in a custom battle. The last two i dont know about.

    armour_ug_levels tells what levels your smithies have to be in order to upgrade to this level

    armour_ug_models tells what models to use for the armor upgrades

    ownership- lists factions that this unit belongs to, relates directly to the battlemodels.modeldb file. If you forget to edit that one, they will show up without a texture as just plain white.


    Now we are done with this part. To recap, copy a template, edit it however you want, remember the two dictionary and type names you gave it, like Los Quesos and Los_Quesos.

    Now onto the export_units.txt:

    Go into your text folder and find the file called export_units.strings.bin or .txt if you have converted it. Now either open it in the editor or convert it if you haven't and find any unit. Here is an example of an entry:

    {Highland_Nobles}Highland Nobles
    {Highland_Nobles_descr}These are the clan leaders and their kinsfolk from the highlands and isles of Scotland. Although their mail armour and helmets are better than the common folk can aspire to, their equipment is scarcely comparable to that of the nobility from more prosperous lands further south. Nevertheless, their fighting spirit and vicious two handed swords mean that they command respect on the battlefield.
    {Highland_Nobles_descr_short}Scottish shock troops wielding a large two-handed sword and armoured in chain.

    The top is the in-game name (this is what the unit will appear as), the middle is the long description (when you right-click on a unit card) and the bottom is the short description they use when you hover over the unit card in a custom battle selection screen.

    Now copy and paste this entire entry and change it as follows:

    {Los_Quesos}Highland Nobles
    {Los_Quesos_descr}These are the clan leaders and their kinsfolk from the highlands and isles of Scotland. Although their mail armour and helmets are better than the common folk can aspire to, their equipment is scarcely comparable to that of the nobility from more prosperous lands further south. Nevertheless, their fighting spirit and vicious two handed swords mean that they command respect on the battlefield.
    {Los_Quesos_descr_short}Scottish shock troops wielding a large two-handed sword and armoured in chain.


    Use the dictionary entry (the one with underscores) and leave the _descr and _descr_short at the end. Now write what you want here:

    {Los_Quesos}Los Quesos
    {Los_Quesos_descr}Queso mucho queso queso
    {Los_Quesos_descr_short}El queso

    Now you are done with that part.

    If you chose to give the unit an ownership in the EDU that the template didn't have, you will have to deal with that. It's a whole different tutorial but it's easy once you get the hang of it. I recommend using the formatted modeldb.

    Now you have the models part. I'm unlearnt in the art of modelling so I can't help you here. Search a tutorial. Find someone else. I'm not that smart, OK?

    So now, assuming you have gotten this far, the unit should work in custom battles. But it won't have a unit card. Go ahead and go into data/ui/units/the faction it belongs to (or one of them) and copy one of the pics there. Edit it and make it how you want your new unit card to be and rename it #unit_name_with_underscores (with the hashtag)

    To add it to the campaign, go ahead into the Export_descr_buildings.

    find a barracks-type building like a mustering hall or a town watch then read the upgrade levels up to the royal armoury and stuff. Under each level you will find a list of units it can recruit.

    building castle_barracks
    {
    convert_to barracks
    levels mustering_hall garrison_quarters drill_square barracks armoury
    {
    mustering_hall castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, }
    {
    capability
    {
    recruit_pool "Peasants" 1 0.5 4 0 requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, }
    recruit_pool "Highland Rabble" 1 0.5 4 0 requires factions { scotland, }
    recruit_pool "Southern Peasants" 1 0.5 4 0 requires factions { sicily, byzantium, }
    recruit_pool "EE Peasants" 1 0.5 4 0 requires factions { poland, russia, hungary, }
    recruit_pool "ME Peasants" 1 0.5 4 0 requires factions { moors, egypt, turks, mongols, timurids, }
    recruit_pool "Los Quesos" 1 0.5 4 0 requires factions { spain, }

    }
    material wooden
    construction 1
    cost 600
    settlement_min village
    upgrades



    To add the ability to recruit your unit at this building, just copy one of the unit lines and change the name to your unit (the one without underscores) like Los Quesos. The bold print is what I added. Make sure you put the correct faction in the brackets. The numbers after it are the initial number of units you can recruit here, the rate at which you can recruit the units (0.5 per turn, so one every two turns.), the maximum number you can recruit and I don't know the fourth one. It seems to always be 0.

    Here you go! Done! Let me know if you have any questions, hope I could help.

    EmperorGurkiman
    Last edited by EmperorGurkiman; October 11, 2013 at 08:48 PM. Reason: Additions

  2. #2
    Otterbear's Avatar Tiro
    Join Date
    Mar 2011
    Location
    Michigan, USA
    Posts
    229

    Default Re: (Almost) Complete Guide to Adding a Unit

    In this example:

    Code:
    armour_ug_levels 5
    armour_ug_models khazad_guard
    ownership        moors
    Would this code mean that if you created this unit [Khazad_Guard], before reaching level 5 smiths, that it wouldn't have a skin?

    Follow up question. Can you re-use the same skin for several armour upgrades?

    IE:

    Code:
    armour_ug_levels 0, 1, 2, 3, 4, 5
    armour_ug_models khazad_guard, khazad_guard, khazad_guard, khazad_guard, khazad_guard, khazad_guard
    EDIT:The armor upgrade using the same skin does work.
    Last edited by Otterbear; December 22, 2013 at 01:15 PM.

  3. #3
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: (Almost) Complete Guide to Adding a Unit

    1. The model will use the entry from the soldier line first, so the answer is 'NO'. (you can have totally different models for soldier and upgrade lines, eg peasant and dismounted_knight - as long as they are of the same class)
    2. As you discovered 'YES' is the answer here.










  4. #4

    Default Re: (Almost) Complete Guide to Adding a Unit

    Quote Originally Posted by EmperorGurkiman View Post
    This is where you can customize the soldier a bit. The first entry is "soldier"
    ...Next is the number of men per unit. Multiply it by 2.5 to get the unit size in "Huge" mode. 100=250 etc.
    EmperorGurkiman
    Where does "mode" come in? I changed the settings for my Irish units (and will eventually reset the settings for all units [Based on a formula I established]) and the numbers appear to have been multiplied by 1.25 across the board.

    So, I guess I'll have to readjust my figures (once I have the spreadsheet set up for all units).

    It's just that I had no idea that I was operating in a "mode".

    SK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •