Jump to content
Sign in to follow this  
braveblades

Custom soldier template

Recommended Posts

Hello, at first i'd like to apologize for my 'maybe-newbie' question, but i'm quite new in ARMA world scripting.

I'm currently working on several missions (in future i will link them into campaign), where I would like to use "soldier template". This is very important to me, because i want to define in detail every "asset" in mission (don't want to use auto-generate). What i mean as "soldier template"? In one place it defines elements such as: custom loadout & appearance and AI skill (for now i use ASR & TPW). for example:

Name= "Regular_Recruit", "loadout & appearance", AiSkill = " " ...

Name= "Regular_Elite", "loadout & appearance", AiSkill = " " ...

Name= "SpecOps", "loadout & appearance", AiSkill = " " ...

...

Than, I'd like to place soldier in editor and in initialization refer to this "template", I'd like to assign "SpecOps" parameter to this soldier and all parameters (like loadout, appearance, aiskill) are already pre-defined.

I search forum and find a lot of code but i've a problem connecting them together to work as i want :(

braveblades

Share this post


Link to post
Share on other sites

I've been working on something quite similar, even though I'm working on groups and not individual soldiers, so I'm not using the same parameters.

Anyway, one solution to that would be to create your templates as an array. As to where to store that array, it's your choice, I myself use a gamelogic so that I'm sure it doesn't mess with anything else.

So you'd create (probably easier to just place it in the editor) a gamelogic called YourTag_templates_logic. (can add YourTag_templatesInit_done = false; to its init line)

Then, in a script (or directly in the init line of the gamelogic, but I don't recommend that as it's not very easy to work with):

YourTag_templates_logic setVariable ["Regular_Recruit", ["uniform", "weapon", "magazines", AIskill (number between 0 and 1), etc...]];
YourTag_templates_logic setVariable ["Regular_Elite", ["uniform", "weapon", ["magazines", magazines number], AIskill (number between 0 and 1), etc...]];
etc.

YourTag_templatesInit_done = true;

etc.

You can obviously set whatever you want in that array. For example you could decide to set every different AI skill individually (aimingAccuracy, aimingShake...). You could also define classname for that particular template, so that you could spawn them directly from a script.

Then, you have in the init line of every unit:

[this, "TemplateName"] spawn YourTag_fnc_setTemplate;

then the function itself, YourTag_fnc_setTemplate

waitUntil {YourTag_templatesInit_done};
_unit = _this select 0;
_tempName = _this select 1;
_temp = YourTag_templates_logic getVariable "Regular_Recruit";

_unit addUniform _temp select 0;
_unit addWeapon _this select 1;
_unit addMagazines [(_this select 2) select 0, (_this select 2) select 1];
_unit setSkill _temp select 3;
etc.

That function would be best defined from the description.ext, as to avoid any loading order issues.

Of course, all that is very rough around the edges, but I have no idea as to how much you master scripting. In any case, you get the idea, or if you don't, just ask for clarifications!

Share this post


Link to post
Share on other sites

Thank you so much BlackMamb!

This is very detailed instruction. Unfortunately i'm not very good in scripting, so I got your idea but have few question.

I forgot to write the important thing - for now I want create only SP mission. The solution is probably the same, but maybe this is important information :)

As I good understand your approach, in steps:

1. must define every detail of asset in external script - for example parameters.sqf

2. place gamelogic in editor and place "YourTag_templatesInit_done = false;" in init line

3. place solider in editor and in init line put "[this, "parameters.sqf"] spawn YourTag_fnc_setTemplate;" - i not sure that i correctly call script

4. in description.ext i defined function "YourTag_fnc_setTemplate"

and... there i'm little confused :) because i don't understand what is the role of this function..

I think that when I define in script every detail, i just simply call by init field of soldier :(

Share this post


Link to post
Share on other sites

Aww sorry, I wentt a bit fast here, I think.

Just to be clear, that function I wrote is totally incomplete. It was just an example as to what could be done.

So, I'll detail the idea a bit.

First, you need to decide on what exactly will your templates contain.

My example went with a uniform, a weapon, some mags and a general AI skill. Now, that's probably not what you want, so I'll let you do that.

For every single parameter that you want to adjust with your template, you need to find how that's done (e.g adding a uniform will be done with addUniform, and you need the config name of that uniform, AI skill will be adjusted with setSkill, and you need a number between 0 and 1). Check the wiki for all that.

When you've decided on a list of parameters you need for a template, you write an array, containing every single one of the parameters needed:

["config name of your weapon", ["config name of your magazine", number of magazines], number between 0 and 1 for the skill, ...]

(Note that addMagazines requires a magazine classname and a number of magazines to add. So I created another array inside the first array, the first value being the name of the mag, the second the number. That's not a mandatory way of doing things, I just find it less confusing)

You write that same array, with different parameters, for every template you might want to use.

Now, you need to store those arrays somewhere, and I chose the gamelogic, so you use the setvariable thing from my previous post.

Then you write the function that's gonna translate that array into actual parameters for your unit:

//retrieve the arguments passed to the function: this (your unit) and "templateName" (whatever you wrote in the init line)

_unit = _this select 0;								// Contains the unit you're gonna apply the template to
_tempName = _this select 1; 						// Contains a template Name, that you've defined before hand
_temp = YourTag_templates_logic getVariable _tempName		//based on the name you passed, goes fetch the corresponding array of parameters

// Then you retrieve all the values from the array

_uniform = _temp select 0;
_weap = _temp select 1;
_mags = _temp select 2;
_skill = _temp select 3;
...

// Finally you apply those parameters

_unit addUniform _uniform;
_unit addWeapon _weap;
_unit addMagazines _mags;
_unit setSkill _skill

//  and this goes on until the unit looks exactly like what you want

finally, when creating your mission, you just paste this into the init lines of your units:

 [this, "TemplateName"] spawn YourTag_fnc_setTemplate;

(where TemplateName is actually one of the templates you've created earlier, e.g "Regular_Recruit").

(note here that I decided to register that function into the function library. If you're not confortable with that, you could for example write your function in a separate sqf file, say setTemplate.sqf. In which case this is what you'd put in the init line:

 [this, "TemplateName"] execVM "setTemplate.sqf";

I'm sorry I sometimes have trouble explaining all that stuff. But if you want, just paste here a complete list of the attributes you want your templates to define (like for example define precisely what you mean by "loadout & appearance") and I'll write something more adapted to what you need.

Edited by BlackMamb

Share this post


Link to post
Share on other sites

OMG!:omg: BlackMamb - you are a MAN! :) thanks!!.. give me a moment for "read & understand" your explanation!

Share this post


Link to post
Share on other sites

I've got a script that I use for SF, Medic, Demo and Machingunner that I use for BackPacks.

I can post them up here if you want them. I got them made for me from AndersMolin over at Armaholic Forums.

He was nice enough to post them up.

Let me know if that helps.

Share this post


Link to post
Share on other sites

Ok..I think that i'd like to define in my template almost the same things as you.

For now i understand much more :) but of course if have time and want to help me more I will be much obliged and.. very, very happy :)

Generally i'd like to customize as much as i can, because I pay attention to detail, so as i think about this template i want to define:

- classification (class) name (regular, elite, specop, etc.)

- uniform (optionally appearance like NV or headset, etc)

- weapons (primary and secondary)

- magazines (for primary and secondary)

- accessories (Rangefinder, Maps, compass, etc.)

- skill of unit (in details) - I've a problem because i don't know is this any correlation between setting up manually skill of unit and used external mode like ASR, Zeus & TPW mods)

Ok, so next in editor, I imagine that, when I place single solider (name: sol1) on map I can "call" from this template one of class - like "specop", and this sol1 will have specific parameters defined earlier in my template. I imagine that, this approach would not only help me to build the mission, but also to manage a large number of individuals units on map (with different parameters). I will also ensure that every soldier with "class regular" has the same equipment and skills.

Second thing what i want is to setup name and soundname for this soldier -but i know how to do this :)

I think about this template as a "unified tool" to manage a large number of custom units (without place in init line for every unit specific parameters)

---------- Post added at 17:34 ---------- Previous post was at 17:33 ----------

Kommiekat - great! if i may try/use your scripts (and LEARN) it will be great! thanks!

Share this post


Link to post
Share on other sites

Firstly, all credit goes to AndersMolin over at Armaholic.

http://www.armaholic.com/forums.php?m=posts&q=24407&n=last#bottom

Here goes:

Basic SF pack ("sfpack.sqf")

Unit init box:

0 = this execVM "sfpack.sqf";

// Call this script from any unit you wish to equip by putting the following string in their Init field: 
// 0 = this execVM "sfpack.sqf"; (don't forget the semicolon!)

removebackpack _this; //gets rid of the current backpack
_this addBackpack "B_carryall_base"; //Replace classname with your choice of backpack, obviously, if you wish
_backpack = unitBackpack _this; //creates a local variable for use in the rest of this script

_backpack addWeaponCargo ["Rangefinder",1];
_backpack addItemCargo ["H_HelmetSpecB_blk",1];

_backpack addmagazinecargo ["SmokeShellGreen", 4];
_backpack addmagazinecargo ["SmokeShellRed", 4];
_backpack addmagazinecargo ["SmokeShell", 2];
_backpack addMagazineCargo ["Chemlight_yellow", 10];
_backpack addMagazineCargo ["ClaymoreDirectionalMine_Remote_Mag", 1];
_backpack addMagazinecargo ["30Rnd_65x39_Caseless_mag", 10];

SF Medic pack ("sfMedicpack.sqf")

Unit init box:

0 = this execVM "sfMedicpack.sqf";

// Call this script from any unit you wish to equip by putting the following string in their Init field: 
// 0 = this execVM "sfMedicpack.sqf"; (don't forget the semicolon!)

removebackpack _this; //gets rid of the current backpack
_this addBackpack "B_carryall_base"; //Replace classname with your choice of backpack, obviously, if you wish
_backpack = unitBackpack _this; //creates a local variable for use in the rest of this script

_backpack addItemCargo ["H_HelmetSpecB_blk",1];
_backpack addItemCargo ["Medikit",1];
_backpack addItemCargo ["FirstAidKit",15];

_backpack addmagazinecargo ["SmokeShellGreen", 4];
_backpack addmagazinecargo ["SmokeShellYellow", 4];
_backpack addMagazineCargo ["Chemlight_yellow", 10];
_backpack addMagazineCargo ["ClaymoreDirectionalMine_Remote_Mag", 1];
_backpack addMagazinecargo ["30Rnd_65x39_Caseless_mag", 10];

SF Autorifleman pack ("sfARpack.sqf")

Unit init box:

0 = this execVM "sfARpack.sqf";

// Call this script from any unit you wish to equip by putting the following string in their Init field: 
// 0 = this execVM "sfARpack.sqf"; (don't forget the semicolon!)

removebackpack _this; //gets rid of the current backpack
_this addBackpack "B_carryall_base"; //Replace classname with your choice of backpack, obviously, if you wish
_backpack = unitBackpack _this; //creates a local variable for use in the rest of this script

_backpack addItemCargo ["H_HelmetSpecB_blk",1];
_backpack addmagazinecargo ["SmokeShell", 2];
_backpack addmagazinecargo ["HandGrenade", 12];
_backpack addmagazinecargo ["100Rnd_65x39_caseless_mag",6];

SF Explosives pack ("sfDemopack.sqf")

Unit init box:

0 = this execVM "sfDemopack.sqf";

// Call this script from any unit you wish to equip by putting the following string in their Init field: 
// 0 = this execVM "sfDemopack.sqf"; (don't forget the semicolon!)

removebackpack _this; //gets rid of the current backpack
_this addBackpack "B_carryall_base"; //Replace classname with your choice of backpack, obviously, if you wish
_backpack = unitBackpack _this; //creates a local variable for use in the rest of this script

_backpack addItemCargo ["H_HelmetSpecB_blk",1];
_backpack addItemCargo ["ToolKit",1];
_backpack addItemCargo ["MineDetector",1];

_backpack addMagazinecargo ["30Rnd_65x39_Caseless_mag", 10];
_backpack addMagazineCargo ["ClaymoreDirectionalMine_Remote_Mag", 2];
_backpack addMagazineCargo ["SLAMDirectionalMine_Wire_Mag", 2];
_backpack addMagazineCargo ["DemoCharge_Remote_Mag", 2];
_backpack addMagazineCargo ["SatchelCharge_Remote_Mag", 2];

OK, hope this helps you for backpack load outs. Should save you lots of time in the editor!

Cheers

Share this post


Link to post
Share on other sites

Thanks man! :) imho BlackMamba approach is more complex and more adress what i imagine, BUT this scripts are cool and for sure its help me customize my units. Excellent.

Share this post


Link to post
Share on other sites

hi Kommiekat, i've another question about your approach - is this possible to insert in this scripts code about detailed skill set? i'd like to define it for every "class". anyway - thanks again man! :)

Share this post


Link to post
Share on other sites

Not sure how you can do that but...........

{
 if (side _x == east) then {
   _x setskill ["aimingAccuracy",0.4];
   _x setskill ["spotDistance",0.6];
   _x setskill ["spotTime",0.75];
   _x setskill ["courage",0.6]; 
   _x setskill ["commanding",0.6]; 
   _x setskill ["aimingShake",0.15];
   _x setskill ["aimingSpeed",0.6];
 };
} foreach allunits;

Share this post


Link to post
Share on other sites

ok, i will try - thanks! after research i build script based on this scripts what you show. i try to put it here tommorow.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×