Jump to content
Sign in to follow this  
kOepi

to let certain AI classes spawn with new equipment/loadout

Recommended Posts

Hey guys,

I am a noob, so be nice please :P.

I want to give every spetznas unit a new uniform, because that is bugged in the RHS mod, so my problem is to adress an AI unit correctly ( if the unit is a player I can make it happen ).

if (typeof vehicle=="CUP_O_RUS_Soldier_Marksman") then {

private "_RSF1";

if (_RSF1 iskindof "Man") then {

removeuniform _RSF1;

removebackpack _RSF1;

hint "You are spetznaz!";};

};

Script error: invalid number in expression in line 1.

would appreciate any help or linking, dont even know wether the definition "vehicle" is appropiate for an infantry unit.

2nd question. I would guess that this script will check on every unit in the mission wether it is the certain class, I assume that is negative for the performance.

Should I try to execute this script only when this kind of AI group is being spawned ( there are others ), does it not matter and if, how do I do it?

greetz

kOepi

Edited by kOepi

Share this post


Link to post
Share on other sites

I guess at the start of the mission you could try it for all units and then again when spawning.

in the init.sqf

{
if (typeof  _x == "CUP_O_RUS_Soldier_Marksman") then {
removeuniform _x;
removebackpack _x;
if (isplayer _x) then {hint "You are spetznaz!"};
};
} foreach allunits;

then later in a script save as "uniform.sqf" and call using null=unit execvm "uniform.sqf";

unit would be the name of the object being spawned.

if (typeof  _this == "CUP_O_RUS_Soldier_Marksman") then {
removeuniform _this;
removebackpack _this;
if (isplayer _this) then {hint "You are spetznaz!"};

You can't use if (typeof vehicle as vehicle is a command that's why you get an error, there was also no need to check if it was a kindof man as that was sort of done when you checked the type of unit.

I have no idea if this would work in MP.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

thank you. that worked so far. As I figured while making a new loadout list, it would be better to start single .sqf files with each classname.

so I linked it like this:

if (typeof _x == "CUP_O_RUS_Soldier_Marksman") then [

execVM "scripts\loadouts\0-4.sqf";

];

and my 0-4.sqf starts like this:

private ["_unit"];

_unit = _this select 0;

obviously I could have seen that error coming, but I dont know how to set the variable correctly.

error: unknown variable this.

any clue?

Share this post


Link to post
Share on other sites

so I linked it like this:

if (typeof _x == "CUP_O_RUS_Soldier_Marksman") then [

execVM "scripts\loadouts\0-4.sqf";

];

and my 0-4.sqf starts like this:

private ["_unit"];

_unit = _this select 0;

obviously I could have seen that error coming, but I dont know how to set the variable correctly.

error: unknown variable this.

any clue?

if (typeof _x == "CUP_O_RUS_Soldier_Marksman") then [color="#B22222"]{[_x][/color] execVM "scripts\loadouts\0-4.sqf"[color="#B22222"]}[/color];

Share this post


Link to post
Share on other sites

thanks for answering.

the linking worked without _x, the error is found in the linked script. when I put _x in the calling script it gives me error "undefined variable _x

and my 0-4.sqf starts like this:

private ["_unit"];
_unit = _this select 0;

error: unknown variable this.

I thing I need to make the global variable _x in that specific case a local one in this script.

Edited by kOepi

Share this post


Link to post
Share on other sites

You should post the script your modifying in full as it's getting a little confusing.

[_x] can be passed withou the need to be global.

Share this post


Link to post
Share on other sites

alright. this is the script that is working and linking the actual file that I think and arma thinks is the problem.

called script in the init.sqf:

nul = [] execVM "scripts\RSFspawn.sqf";

in the RSFspawn.sqf:

if (typeof  _x == "CUP_O_RUS_Soldier_Marksman") then [
execVM "scripts\loadouts\MM.sqf";
];

in the MM.sqf:

//	Marksman

private ["_unit"];
_unit = _this select 0;
IF(!local _unit) exitwith {};

comment "Exported from Arsenal by kOepi";

comment "Remove existing items";
removeAllWeapons _unit;
removeAllItems _unit;
removeAllAssignedItems _unit;
removeUniform _unit;
removeVest _unit;
removeBackpack _unit;
removeHeadgear _unit;
removeGoggles _unit;

comment "Add containers";
_unit forceAddUniform "rhs_uniform_mflora_patchless";
for "_i" from 1 to 6 do {_unit addItemToUniform "AGM_Bandage";};
for "_i" from 1 to 3 do {_unit addItemToUniform "AGM_Morphine";};
for "_i" from 1 to 2 do {_unit addItemToUniform "AGM_Epipen";};
_unit addItemToUniform "AGM_EarBuds";
for "_i" from 1 to 2 do {_unit addItemToUniform "rhs_mag_9x18_12_57N181S";};
_unit addVest "rhs_6b23_6sh92";
for "_i" from 1 to 6 do {_unit addItemToVest "CUP_20Rnd_9x39_SP5_VSS_M";};
for "_i" from 1 to 2 do {_unit addItemToVest "rhs_mag_rgd5";};
for "_i" from 1 to 2 do {_unit addItemToVest "rhs_mag_rdg2_white";};
_unit addBackpack "CUP_B_ACRScout_m95";
for "_i" from 1 to 2 do {_unit addItemToBackpack "rhs_mag_nspn_green";};
for "_i" from 1 to 2 do {_unit addItemToBackpack "rhs_mag_rgd5";};
_unit addItemToBackpack "APERSTripMine_Wire_Mag";
_unit addHeadgear "rhs_beanie_green";
_unit addGoggles "G_Bandanna_tan";

comment "Add weapons";
_unit addWeapon "CUP_srifle_VSSVintorez";
_unit addPrimaryWeaponItem "CUP_optic_PSO_1";
_unit addWeapon "rhs_weap_makarov_pmm";
_unit addWeapon "Binocular";

comment "Add items";
_unit linkItem "ItemMap";
_unit linkItem "ItemCompass";
_unit linkItem "Itemwatch";

basically every AI unit spawning in that class should have that loadout.

and it gives me an error in the MM.sqf : "unknown variable this"

Share this post


Link to post
Share on other sites

try this.

{
if (typeof  _x == "CUP_O_RUS_Soldier_Marksman") then { [_x] execVM "scripts\loadouts\MM.sqf"};
} foreach  allunits;

Share this post


Link to post
Share on other sites

[/color]it fucking works. another one against me. note to myself: "dont trust the rest of a script when there is one corrupted line in it !"

thank you very much ! ! !

2015-03-01_00010.jpg

Share this post


Link to post
Share on other sites

there was just more stuff, for the other characters in the RSFspawn.sqf, that still were wrong, even though the first was fine, arma didnt execute it.

Share this post


Link to post
Share on other sites

mhm. works fine with units that are created in the editor. even on a dedicated.

But units spawning with ALIVE or in my actual missions spawn without the equipment.

Where should I look?

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  

×