Pl4t0 10 Posted January 31, 2010 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
W0lle 1052 Posted February 1, 2010 This has been asked countless times since OFP has been released in 2001. addWeapon addMagazine Share this post Link to post Share on other sites
cyop 10 Posted February 1, 2010 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
caprera 0 Posted February 1, 2010 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
SwiftyBoy 0 Posted February 1, 2010 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
cyop 10 Posted February 1, 2010 (edited) 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 February 1, 2010 by CyOp Share this post Link to post Share on other sites
Redcoalition 0 Posted February 1, 2010 Sry for the noob question but, where can i see the list of equipment names that is used in the editor? Share this post Link to post Share on other sites
This kid 1 Posted February 2, 2010 (edited) 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 February 2, 2010 by This kid Share this post Link to post Share on other sites