[Guide] Adding New Units [WIP]

Discussion in 'Modding' started by Setakat, Oct 4, 2016.

  1. Kasim

    Kasim New Member

    I could ask where I can find the units.objects file, because nowhere in the game files I can't find it?
  2. Ebel

    Ebel Moderator Staff Member

    it's data\scripts\lib\units.script . There is indeed no units.object file. Small error in the first post I guess.
  3. Alatristé

    Alatristé Member

    Good evening. Thanks for the tutorial. I have a problem that blocks me. I am trying to add for the officer18th the recruitment of a new unit.

    I tried several solutions, none works.

    -I tried on this line by adding at the end my unit
    "AddOfficersFormationInfExt (country, ind, 'officer18', 'drummer18', 'pikeman18', ... 'jagerswi', 'musketeer18fra');"
    but it's crashing.

    Same for this line.
    "AddOfficersFormationInfExt (country, ind, 'musketeer18fra', 0);"

    I also have a problem adding upgrades to a unit.

    If you can help me this would be great. If need I could give you my country.Script

    thank you for helping me
  4. Loner

    Loner Well-Known Member

    For some reason, in my experience, you're only allowed to have 17 slots, you must delete one before adding another.;)
  5. Alatristé

    Alatristé Member

    Okay, I understand thank you.

    Can we increase this limit? In the Dmcscript.global, there are several line "Gmaxmembers" have an impact?

    I am looking to give a unique musketeer for France
  6. Loner

    Loner Well-Known Member

    Demoul and Awar have solved this problem in their 'State v Country' Mod, but your guess is as good as mine as how this has been achieved, let me know if you figure it out.:)
  7. Alatristé

    Alatristé Member

    Okay, I'll watch the mod. I'll come back to you if I have results. Cossacks with potential but which we had to be abandoned. Thank you for your help
    Loner likes this.
  8. Loner

    Loner Well-Known Member

    Much appreciated.:cool:
  9. Johny

    Johny Active Member

    This workflow works for me until the game is suppose to produce unit itself. After many attempts I'm still getting error in the editor saying: unknwown unit


    Which is absolutley weird since the unit is visible in game, but somehow it can't find proper files, EVEN IF THEY ARE HERE.

    all files responsible for a model of the unit are on their places:
    azzar.oss, azzar.actor in actors/units
    azzar.prop in objects/units
    azzar.dds in material folder
    azzar.aaf in animation folder (these last two are uninportants since they are not responsible for model itself)

    This unit is a musketeer unit, copied lines are from jannisary.
    Changing .oss and .aaf file to "jannisary" works fine.

    inside of important files is written:
    section.begin {refurl=.\data\actors\ref\refactors.lib; refkey=units}
       LODActorName = azzar
       LODActorFileName = .\data\actors\units\azzar.actor
       'musketeer', 'musketeerpol', 'musketeernet', 'pandur', 'chasseur', 'highlander', 'serdiuk', 'jannisary', 'musketeersco', 'gauduk', 'pandurhun', 'jagerpor', 'jagerswi', 'azzar' : begin
       'azzar' : begin
                      objbase.maxhp := 50;
                      SetObjBaseWeapon(objprop, objbase, weapInd, 24, 250, 400, 850, default, default, default, True);
                      objprop.weapon[weapInd].cost[gc_resource_type_iron] := 6;
                      objprop.weapon[weapInd].cost[gc_resource_type_coal] := 10;
                      SetObjBasePrice(objbase, 110, 0, 0, 26, 10, 0);
                      SetObjBaseSearchBuildVisionScore(objprop, objbase, 850, 512, 1, default);
                      objprop.aiforce := 7;
    mainproperty : section.begin {refurl=.\data\objects\ref\refunit.prop; refkey=mainproperty}
       CustomName = azzar
       BaseName = azzar
    actorproperty : section.begin {refurl=.\data\objects\ref\refunit.prop; refkey=actorproperty}
       LODActorName = azzar
       DefaultMeshName = azzar.mesh
    materialproperty : section.begin {refurl=.\data\objects\ref\refunit.prop; refkey=materialproperty}
       Mesh[0].DefaultMaterialName = azzar
       Mesh[0].UseableMaterials[0] = azzar
    frameanimationproperty : section.begin {refurl=.\data\objects\ref\refunit.prop; refkey=frameanimationproperty}
       FrameAnimationCyclesLibName = azzar
    section.begin {refurl=.\data\actors\ref\refunit.actor}
       ShaderLODList.List[0].ShaderID = 18
       ShaderLODList.List[0].ShaderIDIM = 11
       Animations.LoadFromFile = .\data\animations\aaf\azzar.aaf
       ActorList.Items[0].Name = azzar.mesh
       ActorList.Items[0].LODList.Items[0].MeshObjects.LoadFromFile = .\data\actors\units\azzar.oss
     AddOfficersFormationCavExt(country, ind, 'azzar', 1);
      if (alg) then
          _country_AddMember(country, 'azzar', ind, True, gc_country_editorplace_category_infantry, 29, gc_ai_unit_musk17);
     _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'azzar', 3, 0, ind, csid+'bla', '', '');
     k := k+1; garr_UnitsAll[k] := 'azzar';
    k := k+1; garr_UnitsShooters[k] := 'azzar';
    Can someone tell me what is the last piece I'm missing? Something in global.aix? Thanks.

    EDIT: I will try to duplicate jannisary into algeria and then simply change .oss and .aaf files. I have a feeling that implementing new units from scratch is somehow more complicated than it should.
    Last edited: Feb 27, 2020
  10. Ebel

    Ebel Moderator Staff Member


    This is the ACL reference in the properties file, so ,did you create an azzar.acl and added it to the acl.lib file ? (you didn't mention these in your post above).
    Right now this is the only thing that comes to mind, I'm not seeing proper errors on first glance but then again, it can be very hard without seeing the actual files.

    My gut tells me its coming from unit.script or country.script. Is that the only code you had to add?(the one in the post above?)

    This happens when you place the unit in the editor right?
  11. Johny

    Johny Active Member

    I knew I missed one file!
    I need to add into into acl.lib:

    Name = azzar
    FileName = .\data\animations\acl\azzar.acl

    I'm not saying it's done then, but for sure this one is quite important.
    After getting it complete functional I need to write complete workflow down.
    Since I'm going to travel whole day tomorrow I will re-implement it on saturday. If there will not be some major file issues, I think new unit could be available on monday on steam workshop. (I hope)

    Thanks Ebel, as usual.
  12. Loner

    Loner Well-Known Member

    This is the plan I work from:-

    1. Actors / Units / .actor + .oss (1) then (2)
    Actors / Units / attach / .actor + .oss (1) then (2)
    Actors / actors.lib (2)

    2. Animations / .aaf (1) + acl / acl.lib (2)

    3. Hud / hud.mat (2) + Textures / Ui / iconunits (3)

    4. Locale / en / units(text) (2) + units.lng (4)

    5. Materials / Units / .dds (1) + units.mat (2)

    6. Objects / Units / .prop (1) then (2) + units.objects (2)
    Objects / attach / .prop (1) then (2)

    7. Scripts / Lib / country.script (2)
    Add Member
    Fixed Produce
    Units All

    8. Scripts / Lib / unit.script (2)

    (1) = Copy original file.
    (2) = Open with Notepad ++
    (3) = Open with Paint Program
    (4) = Open with Language Tool

    Attach file is usually only needed for Cavalry Units.
    Hope this is easy enough to follow.;)
    Johny likes this.
  13. Johny

    Johny Active Member


    Here is a link for files of a new unit. (hope it works)
    These files are also on steam Workshop - New Algerian Unit.

    This mod does not work properly due of unexpected errors that occured literary one minute before release.
    Due of the private issues the solution will be found after I'll have enought time to do so.
    For now it's not creating a new unit, but replacing model of jannisary.

    Sorry but I just don't have enough strength to desrcibe all problems that occured. Basicaly the last one was that Steam stopped to upload my files.
    I can't even make a screenshot in-game. Whatever...

    I hope you will still enjoy this unit.
    Ebel, Awar, Foeurdr and 1 other person like this.
  14. Loner

    Loner Well-Known Member

    I've downloaded your unit Johny, I'll let you know how I get on.:)
  15. Loner

    Loner Well-Known Member

    This is Fantastic Johny. Musketeertur.JPG
    Demoul and Awar like this.
  16. Loner

    Loner Well-Known Member

    This is a bit cheeky, but if you can add a melee action to your ( fantastic ) unit, I'll include it in with the Maratha Confederacy, if that's okay with you.;)
    Johny likes this.
  17. Johny

    Johny Active Member

    Well, this should be easy. I just need to set this unit as grenadier and wipe out grenade attack.
    Funny thing, Jannisary itself has an animation for melee attack, but it's not implement in game.

    But first of all, I need to fix its presence as an individual unit in game. Sorry for the fact it's not working again.
    Loner likes this.
  18. Loner

    Loner Well-Known Member

    I know about the Jannisary, it has melee attack in my mod, I don't include units that don't have it.
    What do you mean it's not working.
  19. Loner

    Loner Well-Known Member

    Some more pictures of Johnys impressive work. Musketeertur 2.JPG Musketeertur 3.JPG
    Demoul, Awar, Johny and 1 other person like this.
  20. Loner

    Loner Well-Known Member

    I've made a recording of your unit fighting Johny but don't know what format it needs to be so I can show it here.:confused:
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice