Jump to content
Sign in to follow this  
Pl4t0

Give AI Weapons

Recommended Posts

I'm fairly new to scripting, and so I was wondering, if I wanted to force infantry units to spawn with different weapons than they normally would spawn with, what would I need to do?

Share this post


Link to post
Share on other sites

Here is an example of dif weps for a USMC (vanilla) Corpsman. The 'code' can be placed in the units 'Initialization' box (through the editor).

removeAllWeapons this;

this addMagazine "30Rnd_556x45_Stanag";
this addWeapon "M16A4";

this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";

this addMagazine "HandGrenade_West";

this addMagazine "7Rnd_45ACP_1911";
this addWeapon "Colt1911";

this addMagazine "7Rnd_45ACP_1911";
this addMagazine "7Rnd_45ACP_1911";
this addMagazine "7Rnd_45ACP_1911";

this addWeapon "NVGoggles";

this addWeapon "ItemGPS";

Notice that a magazine is placed before a weapon. This will allow the unit weapon to spawn loaded.

Review the forum stickies for tons of info on this and other things. Search, too, for instance, on... removeAllWeapons this.

Have a good one! :)

EDIT: Heh. Yeah, what he ^ said. ;)

Share this post


Link to post
Share on other sites
Notice that a magazine is placed before a weapon. This will allow the unit weapon to spawn loaded. ;)

Useful Tip! thanks

Share this post


Link to post
Share on other sites

You can also use forEach to add items (e.g. magazines) as follows:

{this addMagazine "30Rnd_556x45_Stanag"} forEach [1,2,3,4,5]; {this addMagazine "7Rnd_45ACP_1911"} forEach {1,2,3];

Just tidies things up a bit in the init box, is all.

Share this post


Link to post
Share on other sites
You can also use forEach to add items (e.g. magazines) as follows:

{this addMagazine "30Rnd_556x45_Stanag"} forEach [1,2,3,4,5]; {this addMagazine "7Rnd_45ACP_1911"} forEach {1,2,3];

Just tidies things up a bit in the init box, is all.

I know it was just a typo. :) - Change this:

{this addMagazine "30Rnd_556x45_Stanag"} forEach [1,2,3,4,5]; {this addMagazine "7Rnd_45ACP_1911"} forEach {1,2,3];

to this:

{this addMagazine "30Rnd_556x45_Stanag"} forEach [1,2,3,4,5]; {this addMagazine "7Rnd_45ACP_1911"} forEach [color="Red"][[/color]1,2,3];

For the above Corpsman, it would be:

removeAllWeapons this;

{this addMagazine "30Rnd_556x45_Stanag"} forEach [1,2,3,4,5,6,7];
{this addMagazine "15Rnd_9x19_M9"} forEach [1,2,3,4];

this addMagazine "HandGrenade_West";

this addWeapon "M16A4";
this addWeapon "M9";

this addWeapon "NVGoggles";

if you changed the pistol to an M9.

Edited by CyOp

Share this post


Link to post
Share on other sites

Redcoalition: Classnames for all units and weapons are found in this thread. :)

CyOp and SwiftyBoy: Thank you for the information on the "forEach" command. Didn't know about that one. Will certainly clear up some of my initialization lines... Thanks!

Edited by This kid

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  

×