Jump to content
knifeprty

Removing gear from opfor

Recommended Posts

How would I go about removing gear from opfor such as nvgs? Its there a way to edit the missions .sqm so all of opfor has the same gear loadout? Or must I do this individually on each unit? If so what is the script llne for that?

Share this post


Link to post
Share on other sites

RemoveAllItems this ;

removeUniform this;

this addUniform "name";

Removevest this;

this addvest "name";

removeHeadgear this;

this addHeadgear "name";

removeAllWeapons this;

to add weapons, add the magazines first, then weapon:

this addmagazine "name";

this addweapon "name";

To remove NVG:

this unassignItem "NVGoggles";

this removeItem "NVGoggles";

To add goggles/glasses:

this addGoggles "name";

You can also use:

this additem "name";

to add items like medkits.

and:

this addPrimaryWeaponItem "name";

to add stuff to guns. (command is different for primary/secondary, obviously).

Classname info: http://www.armaholic.com/forums.php?m=posts&q=20801

Write the loadouts you want in scripts and execute them from the init line of each unit you want to have said loadout.

Here is the template I always used to make custom weapon setups in OFP/ARMA/ArmA2. To the best of my knowledge, it should still work, but someone else will need to confirm:

_unit = _this Select 0;

RemoveAllWeapons _unit;

_unit AddMagazine "name"; // repeat for as many mags as needed

_unit AddWeapon "name";

_unit SelectWeapon "name(same as above)";

//_unit AddMagazine "name"; //if you want launchers or pistols, do the same as above but minus the selectWeapon

//_unit AddWeapon "name"; // ^^^

//Add gear, goggles, items, weapon attachments, etc here.

Exit;

Save it as a script and execute it in the init line of the desired unit.

Edited by GRS

Share this post


Link to post
Share on other sites

use the command "removeAllAssignedItems unitName" (see this: http://community.bistudio.com/wiki/removeAllAssignedItems ) in the Init field of the units.

If you only want to remove a single item, use "removeItem" ( http://community.bistudio.com/wiki/removeItem ). You will need to find the classname of the object you want to remove. You might need to unassigne it before removing it. I didn't test it so I don't know. Unassigning it might be enough to prevent them from using it too. You will have to do some tests.

EDIT: looks like someone was quicker than me!

Share this post


Link to post
Share on other sites

Any time.

Also, not sure since I've never tried but you could try using a large trigger to execute the script for each unit inside it.

Probably something like

condition: opfor present

on act: {nul = [_x] execVM "scriptname.sqf"} foreach thislist;

I do not know if that is how it would be done, but that's the basic idea, for ArmA2 anyways. I'm still making the switch editor wise. So far it has been very smooth. I personally prefer to just add the exec to each unit's init to allow various loadouts.

Share this post


Link to post
Share on other sites

To remove NVGs from every OPFOR unit:

{
       if (side _x == east) then {
               _x unassignItem "NVGoggles";
               _x removeItem "NVGoggles";
       };

} foreach allunits;

Share this post


Link to post
Share on other sites

@2nd Ranger: Excuse the simple question,

from where would you run that bit of code to ensure all opfor gear was changed?

Thanks,

Dom.

[Edit: never mind, I tried running it in a unit's init and it worked fine, thanks for code]

Edited by BirdFilm

Share this post


Link to post
Share on other sites

was there something that changed at release in regards to removing NVGs? I can't seem to get them to remove. this's exactly what I'm using in the AI's Init file (per unit as I want some with NVG's):

this unassignitem "NVGoggles"; this removeweapon "NVGoggles";

Share this post


Link to post
Share on other sites

is there a similar script to make them all have flashlights?

instead of manually inserting into every unit kinda thing?

Share this post


Link to post
Share on other sites
_unit addPrimaryWeaponItem "acc_flashlight";

More in-depth and ensuring the weapon doesn't have a IR Laser on it:

//If using editor placed units, place the following in your init.sqf

if (side _x = EAST) then { 

{
_x removePrimaryWeaponItem "acc_pointer_IR";   
_x addPrimaryWeaponItem "acc_flashlight";   
_x enableGunLights "forceon";//<<Turns on the light as well.
} foreach allUnits; 

}; 

Edited by JShock

Share this post


Link to post
Share on other sites

Fixed* ;)

{
if (side _x = EAST) then { 
_x removePrimaryWeaponItem "acc_pointer_IR";   
_x addPrimaryWeaponItem "acc_flashlight";   
_x enableGunLights "forceon";//<<Turns on the light as well.
}; 
} foreach allUnits; 

Share this post


Link to post
Share on other sites
Fixed* ;)

{
if (side _x = EAST) then { 
_x removePrimaryWeaponItem "acc_pointer_IR";   
_x addPrimaryWeaponItem "acc_flashlight";   
_x enableGunLights "forceon";//<<Turns on the light as well.
}; 
} foreach allUnits; 

Hehe, lol, yea...brain feels a bit off today :p.

Share this post


Link to post
Share on other sites

{
if (side _x == EAST) then { 
_x removePrimaryWeaponItem "acc_pointer_IR";   
_x addPrimaryWeaponItem "acc_flashlight";   
_x enableGunLights "forceon";//<<Turns on the light as well.
}; 
} foreach allUnits; 

Extra fix? (Double equals)

Share this post


Link to post
Share on other sites

Yes that would make even more sense now wouldn't it, at this point it would probably just be better to go with Beerkan's plan....lol :p

Share this post


Link to post
Share on other sites
{
if (side _x == EAST) then { 
_x removePrimaryWeaponItem "acc_pointer_IR";   
_x addPrimaryWeaponItem "acc_flashlight";   
_x enableGunLights "forceon";//<<Turns on the light as well.
}; 
} foreach allUnits; 

Extra fix? (Double equals)

Good catch. Hadn't spotted that.

Share this post


Link to post
Share on other sites

Is there any way to do this same thing, but with units placed by a script? I use a script to create small groups, and I'd want to use it in a night infiltration style mission, and this code only works with editor-placed units.

I also have my BluFor without nvgs, and I don't want them stealing NVGs from dead enemies. apart, of course, of using nvg would be a huge advantage to IAs.

This is the script I use to spawn units:

if (!isServer) exitWith {};   
waituntil {!isnil "bis_fnc_init"};




//create AI Group 1
AM1 = createGroup east; sleep 0.5;

"O_soldier_TL_F" createUnit [getMarkerPos "AM1", AM1,"AM1_1 = this", 0.6, "sergeant"]; sleep 0.2;
"O_soldier_AR_F" createUnit [getMarkerPos "AM1", AM1,"AM1_2= this", 0.5, "corporal"]; sleep 0.2;
"O_soldier_GL_F" createUnit [getMarkerPos "AM1", AM1,"AM1_3 = this", 0.5, "corporal"]; sleep 0.2;
"O_soldier_F" createUnit [getMarkerPos "AM1", AM1,"AM1_4 = this", 0.5, ""]; sleep 0.2;
"O_soldier_F" createUnit [getMarkerPos "AM1", AM1,"AM1_5 = this", 0.5, ""]; sleep 0.2;

[AM1, getMarkerPos "MARKER", 600 ] call bis_fnc_taskAttack;
[AM1, 1] setWaypointSpeed "FULL";
[AM1, 1] setWaypointCombatMode "RED";
[AM1, 1] setWaypointBehaviour "AWARE";
sleep 0.2;

Share this post


Link to post
Share on other sites

Change the "forEach allUnits" to "forEach units group AM1"

Share this post


Link to post
Share on other sites
Change the "forEach allUnits" to "forEach units group AM1"

tried this and didn't work. bear in mind they don't spawn until a trigger is executed. that is my problem, that those units are not present at the beginning of the mission

Share this post


Link to post
Share on other sites

Then put this in the code that creates those units, or execute an sqf file with this in it after those units have been created.

Share this post


Link to post
Share on other sites

I thought I had replied. I came up with that same idea (executing a new sqf with some delay) the next morning (I hadn't checked the forums). I forgot to came here to tell my solution:

sleep 7;

{  if (side _x == east) then {  _x unassignItem "NVGoggles_OPFOR";  
_x removeItem "NVGoggles_OPFOR";  
_x removePrimaryWeaponItem "acc_pointer_IR";  
_x addPrimaryWeaponItem "acc_flashlight";  
_x enableGunLights "forceon"; }  } ForEach allUnits;

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

×