Jump to content
ante185

need help with a weapon spawing script

Recommended Posts

So i found this script for a wasteland mission for arma 2 and i want to reuse it, i've tested it and it does not appear to work, i think it might have some outdated elements, but i kind of got my head up my arse when it comes to these scripts

//////////////////////////////////BUILDING LOOT//////////////////////////////////////



_weapons = ["hgun_Pistol_heavy_02_F", "arifle_MX_GL_F", "arifle_mx_f", "LMG_Mk200_MRCO_F", "arifle_Katiba_F", "arifle_Katiba_GL_F", "arifle_MXC_F", "arifle_Katiba_C_F",  "srifle_DMR_01_F",
"arifle_MXM_F", "arifle_SDAR_F", "LMG_Mk200_F","arifle_TRG20_F", "arifle_TRG21_F", "LMG_Zafir_F", "SMG_02_F", 
"arifle_TRG21_GL_F", "hgun_PDW2000_snds_F", "launch_RPG32_F", "arifle_Mk20C_plain_F","arifle_Mk20_F", "arifle_TRG21_GL_F", "hgun_P07_F", 
"hgun_Rook40_snds_F", "srifle_EBR_DMS_pointer_snds_F", "srifle_LRR_F", "srifle_GM6_F", "hgun_ACPC2_F", "hgun_Pistol_heavy_01_snds_F", ];



_items = ["ItemWatch", "ItemCompass", "ItemGPS", "ItemRadio", "ItemMap", "MineDetector", "Binocular", "Rangefinder", 
"NVGoggles", "FirstAidKit", "Medikit", "ToolKit", "Laserdesignator", "muzzle_snds_H", "muzzle_snds_L", "muzzle_snds_M", 
"muzzle_snds_B", "muzzle_snds_H_MG", "optic_Arco", "optic_ACO_grn", "optic_ACO_grn_sm", "optic_SOS", "acc_flashlight", 
"muzzle_snds_acp", "optic_DMS", "optic_tws", "FirstAidKit"];



_magazines = ["DemoCharge_Remote_Mag", "ATMine_Range_Mag", "APERSMine_Range_Mag", "HandGrenade",
"SmokeShell", "Chemlight_green", "20Rnd_762x51_Mag", "16Rnd_9x21_Mag", "16Rnd_9x21_Mag", "30Rnd_9x21_Mag",
"16Rnd_9x21_Mag", "30Rnd_9x21_Mag", "16Rnd_9x21_Mag", "1Rnd_Smoke_Grenade_shell",
"30Rnd_65x39_caseless_green", "RPG32_HE_F", "RPG32_F", "30Rnd_65x39_caseless_green_mag_Tracer",
"1Rnd_HE_Grenade_shell", "30Rnd_65x39_caseless_green_mag_Tracer", "30Rnd_65x39_caseless_mag",
"UGL_FlareRed_F", "30Rnd_65x39_caseless_mag_Tracer", "30Rnd_65x39_caseless_mag_Tracer",
"20Rnd_556x45_UW_mag", "30Rnd_556x45_Stanag", "30Rnd_556x45_Stanag", "30Rnd_556x45_Stanag_Tracer_Red",
"30Rnd_556x45_Stanag_Tracer_Green", "30Rnd_556x45_Stanag_Tracer_Yellow", "150Rnd_762x51_Box_Tracer",
"7Rnd_408_Mag", "9Rnd_45ACP_Mag", "5Rnd_127x108_APDS_Mag", "9Rnd_45ACP_Mag", "6Rnd_45ACP_Cylinder",
"DemoCharge_Remote_Mag", "ATMine_Range_Mag", "APERSMine_Range_Mag", "HandGrenade", "SmokeShell",
"Chemlight_green"];





_buildings = nearestobjects [getmarkerPos "weapons", ["house"], 10000];

_markernum = 0;

{

_building = _x;

hint "placing loot.";

// search more positions

_positions = 0;

_i = 0;

_loop = 1;

while {_loop == 1} do

{

_next = _building buildingPos _i;

if (((_next select 0) == 0) && ((_next select 1) == 0) && ((_next select 2) == 0)) then

{

_loop = 0;

} else {

_positions = _positions + 1;

_i = _i + 1;

};

};

_posnumber = floor (random _positions);

_position = _building buildingpos _posnumber;

hint "placing loot..2";

if (random 100 > 75) then {

_weapon = _weapons call BIS_fnc_SelectRandom;

_mag=(getArray (configFile/"Cfgweapons"/_weapon/"magazines")) select 0;

        _weap = "groundWeaponHolder" createVehicle [0,0];

        _weap addMagazineCargo [_mag,(round (random 3))];

        _weap addWeaponCargo [_weapon,1];

        _weap setPos [(_position select 0),(_position select 1),((_position select 2)-.14)];

};



_posnumber = floor (random _positions);

_position = _building buildingpos _posnumber;





hint "placing loot...3";

if (random 100 > 60) then {

_weapon = _items call BIS_fnc_SelectRandom;

        _weap = "groundWeaponHolder" createVehicle [0,0];

        _weap addMagazineCargo [_mag,(round (random 2))];

        _weap addWeaponCargo [_weapon,1];

        _weap setPos [(_position select 0),(_position select 1),((_position select 2)-.14)];;

};



_posnumber = floor (random _positions);

_position = _building buildingpos _posnumber;





hint "placing loot..4";

if (random 100 > 40) then {

_weapon = _items call BIS_fnc_SelectRandom;

        _weap = "groundWeaponHolder" createVehicle [0,0];

        _weap addMagazineCargo [_mag,(round (random 2))];

        _weap addWeaponCargo [_weapon,1];

        _weap setPos [(_position select 0),(_position select 1),((_position select 2)-.14)];;

};



_posnumber = floor (random _positions);

_position = _building buildingpos _posnumber;



hint "placing loot..5";

if (random 100 > 30) then {

_weapon = _items call BIS_fnc_SelectRandom;

        _weap = "groundWeaponHolder" createVehicle [0,0];

        _weap addMagazineCargo [_mag,(round (random 2))];

        _weap addWeaponCargo [_weapon,1];

        _weap setPos [(_position select 0),(_position select 1),((_position select 2)-.14)];;

};



_posnumber = floor (random _positions);

_position = _building buildingpos _posnumber;



hint "placing loot....";

} foreach _buildings; hint "Finished! Unless it didn't work...";

Share this post


Link to post
Share on other sites

the one named "weapons"? yes, nothing happens, i can see that there's several hints in there but none of them shows up, either it's the script or the way i am starting the script (null = execVM "weapons_in_houses.sqf";)

Share this post


Link to post
Share on other sites

i see 2 ";" in the last "if"

_weap setPos [(_position select 0),(_position select 1),((_position select 2)-.14)];;

don't know if it can be this, did you enabled showScriptErrors ?

Share this post


Link to post
Share on other sites

weapons = ["hgun_Pistol_heavy_02_F", "arifle_MX_GL_F", "arifle_mx_f", "LMG_Mk200_MRCO_F", "arifle_Katiba_F", "arifle_Katiba_GL_F", "arifle_MXC_F", "arifle_Katiba_C_F",  "srifle_DMR_01_F",
 "arifle_MXM_F", "arifle_SDAR_F", "LMG_Mk200_F","arifle_TRG20_F", "arifle_TRG21_F", "LMG_Zafir_F", "SMG_02_F", 
 "arifle_TRG21_GL_F", "hgun_PDW2000_snds_F", "launch_RPG32_F", "arifle_Mk20C_plain_F","arifle_Mk20_F", "arifle_TRG21_GL_F", "hgun_P07_F", 
 "hgun_Rook40_snds_F", "srifle_EBR_DMS_pointer_snds_F", "srifle_LRR_F", "srifle_GM6_F", "hgun_ACPC2_F", "hgun_Pistol_heavy_01_snds_F", ];

Notice a "," just after the last weapon in the weapons array. maybe that ??

Share this post


Link to post
Share on other sites

Holy hell! after i removed those semicolons and that rouge comma it fucking worked! Thank you Tay and Zigo!

---------- Post added at 19:20 ---------- Previous post was at 18:49 ----------

Just one thing, if i want to have it like in Ryd's pilgrimage mission where his script spawns in weapons that mods add too, how'd i do that?

Share this post


Link to post
Share on other sites
Holy hell! after i removed those semicolons and that rouge comma it fucking worked! Thank you Tay and Zigo!

That extra coma should have come up on your screen or in .rpt as error. You can save yourself some hair pulling by simply enabling error reporting.

-showScriptErrors

Edited by Killzone_Kid

Share this post


Link to post
Share on other sites
Holy hell! after i removed those semicolons and that rouge comma it fucking worked! Thank you Tay and Zigo!

Welcome to programming. A nefarious comma will get ya every time. :p

Share this post


Link to post
Share on other sites

I'm new to the forums and I can't make my own topic post yet so I figured I'd ask in a place with similar questions about Wasteland; I'm currently installing Nato SF and Russian Spetsnaz weapons and Wander Panzer WAP to my Altis Wasteland server but I don't know how to implement them in the shop. (I also have IdentiZee but I don't think I need to edit the server mission to use that?) Anyone think they could explain some mission editing to me? (I have the tools to extract the Wasteland pbo and view/edit its contents, I just don't know how.)

Also, is there any way to add items from these mods to the random loot system of Wasteland?

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

×