Jump to content
Sign in to follow this  
Homefry

Random Loadouts

Recommended Posts

After some inspiration, and a load of help from PsyWarrior, I've completed my first script that is useful!

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Random Loadouts.... Originally by PsyWarrior

;Edited by Homefry

;To Use: [unitname] exec "randomweapons.sqs"

_man = _this select 0

;Weapons are removed:

removeAllWeapons _man

;Determine what side the unit is on

?side _man == west : goto "westweapons"

?side _man == east : goto "eastweapons"

?side _man == resistance : goto "resistanceweapons"

?side _man == civilian : goto "civilianweapons"

#westweapons

_primaryArray = ["m16", "M60", "M4", "G36A", "FAL", "Steyr", "HKG3"]

_BulletArray = ["m16", "M60", "M4", "G36AMag", "FALMag", "SteyrMag", "HKG3Mag"]

goto "randomize"

#eastweapons

_primaryArray = ["AK47", "AK74", "AK74SU", "PK"]

_BulletArray = ["AK47", "AK74", "AK74", "PK"]

goto "randomize"

#resistanceweapons

_primaryArray = ["AK47", "AK47CZ", "HuntingRifle", "PK", "FAL"]

_BulletArray = ["AK47", "AK47", "HuntingRifleMag", "PK", "FALMag"]

goto "randomize"

#civilianweapons

_primaryArray = ["Beretta", "CZ75", "Glock", "Ingram", "Revolver", "Skorpion", "Tokarev"]

_BulletArray = ["BerettaMag", "CZ75Mag", "GlockMag", "IngramMag", "RevolverMag", "SkorpionMag", "TokarevMag"]

goto "randomize"

;Generate random number based on number of elements in array.

#randomize

_n = 0

_n = count _primaryArray

_random1 = random _n + 1

goto "loopstart"

#loopstart

_ammo = _BulletArray select _random1

_man addmagazine _ammo

_man addmagazine _ammo

_man addmagazine _ammo

_man addmagazine _ammo

_primaryWeap = _primaryArray select _random1

_man addWeapon _primaryWeap

exit

Test mission: Here

What I need is suggestions and/or requests to make this thing better.

P.S. Is the "+1" at the end of "_random1 = random _n + 1" neccesary?

Share this post


Link to post
Share on other sites

Yea, nice script mate! Thanks for sharing...

/Christer (a.k.a KeyCat)

Share this post


Link to post
Share on other sites

Your welcome, thanks for testing and using it. If you encounter any problems, please let me know so I can correct it.

Share this post


Link to post
Share on other sites

I had some time today to update this, it's much better now. I haven't had any problem's whatsoever.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Random Loadouts.... Originally by PsyWarrior

;Edited by Homefry

;To Use: [unitname, "modname"] exec "randomweapons.sqs"

;use [unitname, "Default"] exec "randomweapons.sqs" to use BIS Weapons only

_man = _this select 0

_mod = _this select 1

;Weapons are removed:

removeAllWeapons _man

;Determine what side the unit is on

?side _man == west : goto "westweapons"

?side _man == east : goto "eastweapons"

?side _man == resistance : goto "resistanceweapons"

?side _man == civilian : goto "civilianweapons"

;Add West Weapons:

#westweapons

;Format for Adding in Addon Weapons:

;?_mod == "MODNAME" : _primaryArray = ["GUN_CLASS_NAME_ONE", "GUN_CLASS_NAME_TWO", "ETC..."]

;?_mod == "MODNAME" : _BulletArray = ["MAG_CLASS_NAME_ONE", "GUN_CLASS_NAME_TOW", "ETC..."]

?_mod == "BAS" : _primaryArray = ["BAS_JM4ACOG", "BAS_JM4ACOGS", "BAS_JM4MKACOG", "BAS_JM4REFLEX", "BAS_JM4REFLEXS", "BAS_JM4ReflexM203", "BAS_JM4ReflexSM203", "BAS_JM4MKReflex", "BAS_JM4EOTech", "BAS_JM4EOTechS", "BAS_JM4EOTechM203", "BAS_JM4EOTechSM203", "BAS_JM4Aimpoint", "BAS_JM4AimpointS", "BAS_JM4AimpointM203", "BAS_JM4AimpointSM203", "BAS_JM14AIMPOINT", "BAS_JM14DMR", "BAS_JM24SWS", "BAS_JSR25", "BAS_JSR25S", "BAS_JMP5SDAimpoint", "BAS_JM249", "BAS_JM249SPW", "BAS_JM249SPWSD", "BAS_JM240B"]

?_mod == "BAS" : _BulletArray = ["JAM_W556_30mag", "JAM_W556_30SDmag", "JAM_W556_30mag", "JAM_W556_30mag", "JAM_W556_30SDmag", "JAM_W556_30mag", "JAM_W556_30mag", "JAM_W556_30mag", "JAM_W556_30mag", "JAM_W556_30SDmag", "JAM_W556_30mag", "JAM_W556_30mag", "JAM_W556_30mag", "JAM_W556_30SDmag", "JAM_W556_30mag", "JAM_W556_30SDmag", "JAM_W762_20mag", "JAM_W762_20mag", "JAM_W762_5mag", "JAM_W762Sniper_20Mag", "JAM_W762Sniper_20SDMag", "JAM_MP5SBASDmag", "JAM_W556M_200mag", "JAM_W556M_200mag", "JAM_W556M_200SDmag", "JAM_W762M_100mag"]

?_mod == "BAS" : goto "randomize"

?_mod == "MARPAT" : _primaryArray = ["C8XM16acog", "C8XM16cco", "C8XM16reflex", "C8XM16M203", "C8XM16M203acog", "C8XM16M203reflex", "C8XM16M203cco", "C8XM249", "C8XM249m145", "C8XM249PARA", "C8XM249PARAcco", "C8XM4", "C8XM4acog", "C8XM4reflex", "C8XM4cco", "C8XM4M203", "C8XM4M203cco", "C8XM4M203acog", "C8XM4M203reflex", "C8XM4_sd", "C8XM4acog_sd", "C8XM4reflex_sd", "C8XM4cco_sd", "C8XM4M203_sd", "C8XM4M203cco_sd", "C8XM4M203acog_sd", "C8XM4reflex_sd", "C8XM1014", "C8XM1014cco"]

?_mod == "MARPAT" : _BulletArray = ["c8xm16mag", "c8xm16mag", "c8xm16mag", "c8xm16mag", "c8xm16mag", "c8xm16mag", "c8xm16mag", "c8xm16mag", "c8xm249mag", "c8xm249mag", "c8xm249mag", "c8xm249mag", "c8xm4mag", "c8xm4mag", "c8xm4mag", "c8xm4mag", "c8xm4mag", "c8xm4mag", "c8xm4mag", "c8xm4mag", "c8xm4sdmag", "c8xm4sdmag","c8xm4sdmag","c8xm4sdmag","c8xm4sdmag","c8xm4sdmag","c8xm4sdmag","c8xm4sdmag", "c8xm1014mag", "c8xm1014mag"]

?_mod == "MARPAT" : goto "randomize"

_primaryArray = ["m16", "M60", "M4", "G36A", "FAL", "Steyr", "HKG3"]

_BulletArray = ["m16", "M60", "M4", "G36AMag", "FALMag", "SteyrMag", "HKG3Mag"]

goto "randomize"

#eastweapons

?_mod == "MARPAT" : _primaryArray = ["C8XAK74M", "C8XAK74Mcobra", "C8XAK74M1p29", "C8XAK74MGP25", "C8XAK74MGP25cobra", "C8XAK74MGP251p29", "C8XAK74M_SD", "C8XAK74Mcobra_SD", "C8XAK74M1p29_SD", "C8XAK74MGP25_SD", "C8XAK74MGP25cobra_SD", "C8XAK74MGP251p29_SD", "C8XRPK74M", "C8XRPK74M1p29", "C8XAKS74U", "C8XAKS74Ucobra", "C8XAKS74U_sd", "C8XAKS74Ucobra_sd", "C8XAKS74UBS1", "C8XAKS74UBS1cobra"]

?_mod == "MARPAT" : _BulletArray = ["c8xak74mag", "c8xak74mag", "c8xak74mag", "c8xak74mag", "c8xak74mag", "c8xak74mag", "c8xak74sdmag", "c8xak74sdmag", "c8xak74sdmag", "c8xak74sdmag", "c8xak74sdmag", "c8xak74sdmag", "c8xrpk74mag", "c8xrpk74mag", "c8xaks74umag", "c8xaks74umag", "c8xaks74usdmag", "c8xaks74usdmag", "c8xaks74usdmag", "c8xaks74usdmag"]

?_mod == "MARPAT" : goto "randomize"

_primaryArray = ["AK47", "AK74", "AK74SU", "PK"]

_BulletArray = ["AK47", "AK74", "AK74", "PK"]

goto "randomize"

#resistanceweapons

_primaryArray = ["AK47", "AK47CZ", "HuntingRifle", "PK", "FAL"]

_BulletArray = ["AK47", "AK47", "HuntingRifleMag", "PK", "FALMag"]

goto "randomize"

#civilianweapons

_primaryArray = ["Beretta", "CZ75", "Glock", "Ingram", "Revolver", "Skorpion", "Tokarev"]

_BulletArray = ["BerettaMag", "CZ75Mag", "GlockMag", "IngramMag", "RevolverMag", "SkorpionMag", "TokarevMag"]

goto "randomize"

;Generate random number based on number of elements in array.

#randomize

_random1 = 0

_n = 0

_n = count _primaryArray

_random1 = random _n

_random1 = _random1 - 1

?_random1 == 0 : goto "randomize"

?_random1 > _n : goto "randomize"

?_random1 < 0 : goto "randomize"

_ammo = _BulletArray select _random1

_primaryWeap = _primaryArray select _random1

_a = 0

goto "specialweapons"

;Weapons with speconday weapons go here:

;In this case, weapon's with M203's or similar were given two rounds

#specialweapons

?_a == 2: goto "loopstart"

?_mod == "BAS" && _primaryWeap == "BAS_JM4ReflexM203" : _man addMagazine "JAM_M433grenade"

?_mod == "BAS" && _primaryWeap == "BAS_JM4ReflexSM203" : _man addMagazine "JAM_M433grenade"

?_mod == "BAS" && _primaryWeap == "BAS_JM4EOTechM203" : _man addMagazine "JAM_M433grenade"

?_mod == "BAS" && _primaryWeap == "BAS_JM4EOTechSM203" : _man addMagazine "JAM_M433grenade"

?_mod == "BAS" && _primaryWeap == "BAS_JM4AimpointM203" : _man addMagazine "JAM_M433grenade"

?_mod == "BAS" && _primaryWeap == "BAS_JM4AimpointSM203" : _man addMagazine "JAM_M433grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM16M203" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM16M203acog" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM4M203reflex" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM4M203_sd" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM4M203acog_sd" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM4M203reflex_sd" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM4M203cco_sd" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM16M203reflex" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM16M203cco" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM4M203" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM4M203cco" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XM4M203acog" : _man addMagazine "c8xm203grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XAK74MGP25" : _man addMagazine "c8xgp25grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XAK74MGP25cobra" : _man addMagazine "c8xgp25grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XAK74MGP251p29" : _man addMagazine "c8xgp25grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XAK74MGP25_SD" : _man addMagazine "c8xgp25grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XAK74MGP25cobra_SD" : _man addMagazine "c8xgp25grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XAK74MGP251p29_SD" : _man addMagazine "c8xgp25grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XAKS74UBS1" : _man addmagazine "C8XBS1grenade"

?_mod == "MARPAT" && _primaryWeap == "C8XAKS74UBScobra" : _man addmagazine "C8XBS1grenade"

_a = _a + 1

goto "specialweapons"

#loopstart

;Give the unit his weapon and ammo

_man addmagazine _ammo

_man addmagazine _ammo

_man addmagazine _ammo

_man addmagazine _ammo

_man addWeapon _primaryWeap

~3

_b = _man hasWeapon _primaryWeap

?_b = 0 : goto "randomize"

exit

Script here

<a href="http://www.ofpec.com/yabbse/attachments/RandomWea

pons1-5.Noe.pbo" target="_blank">Test Mission</a>

I've also included all the rifles from the BAS Ranger/Delta Pack(v1.55) and the Marine Assault Pack. To use the BAS weapons: [unitname, "BAS"] exec "randomweapons.sqs"

To use the MAP weapons: [unitname, "MARPAT"] exec "randomweapons.sqs"

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  

×