# [Guide] Adding New Units [WIP]

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

Tags:
1. ### KasimNew Member

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

2. ### EbelModeratorStaff 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é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.

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

thank you for helping me

4. ### LonerWell-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é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. ### LonerWell-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é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. ### LonerWell-Known Member

Much appreciated.

9. ### JohnyMember

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:
Code:
//actors.lib
section.begin {refurl=.\data\actors\ref\refactors.lib; refkey=units}
LODActorName = azzar
LODActorFileName = .\data\actors\units\azzar.actor

//unit.script
'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;
end;

//units.object
ObjectItems[*].PropertiesFileName=.\data\objects\units\azzar.prop

//azzar.prop
{refurl=.\data\objects\ref\refunit.prop}

mainproperty : section.begin {refurl=.\data\objects\ref\refunit.prop; refkey=mainproperty}
CustomName = azzar
BaseName = azzar
section.end

actorproperty : section.begin {refurl=.\data\objects\ref\refunit.prop; refkey=actorproperty}
LODActorName = azzar
DefaultMeshName = azzar.mesh
section.end

materialproperty : section.begin {refurl=.\data\objects\ref\refunit.prop; refkey=materialproperty}
Mesh[0].DefaultMaterialName = azzar
Mesh[0].UseableMaterials[0] = azzar
section.end

frameanimationproperty : section.begin {refurl=.\data\objects\ref\refunit.prop; refkey=frameanimationproperty}
FrameAnimationCyclesLibName = azzar
section.end

//azzar.actor
section.begin {refurl=.\data\actors\ref\refunit.actor}
ActorList.Items[0].Name = azzar.mesh
section.end

//country.script

if (alg) then
begin
_country_AddMember(country, 'azzar', ind, True, gc_country_editorplace_category_infantry, 29, gc_ai_unit_musk17);
end;

_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. ### EbelModeratorStaff Member

hi,

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. ### JohnyMember

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

section.begin
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. ### LonerWell-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)
Formation
Fixed Produce
Units All
Shooters
Bayonet

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

(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. ### JohnyMember

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.

15. ### LonerWell-Known Member

This is Fantastic Johny.

Demoul and Awar like this.
16. ### LonerWell-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. ### JohnyMember

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. ### LonerWell-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. ### LonerWell-Known Member

Some more pictures of Johnys impressive work.

Demoul, Awar, Johny and 1 other person like this.
20. ### LonerWell-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.