Jump to content
Sign in to follow this  
ALPHIVE

How make random spawn loot with height ?

Recommended Posts

Hi guys 😉

 

On my server im actually placing random loot spawns, for this, im using this command in INIT of empty helipad :

 

 

gun = [

 

"rhs_weap_pb_6p9",
 "rhs_weap_pya",
 "rhs_weap_makarov_pm",
 "rhs_weap_makarov_pmm",
 "rhs_weap_pp2000_folded"

 

] call BIS_fnc_selectRandom;
Waffe1 = "groundweaponholder" createVehicle getpos this;
Waffe1 addWeaponCargo [gun,1];
Waffe1 setPos [getPos this select 0,getPos this select 1,0.00];

 

 

It works pretty well,

but my problem is the height of the spawn : sometime when i place it in buildings, the script make spawn weapon automaticly to the ground, and not to the house surface

 

-> So i want use this script to make spawn my stuff at 2nd floor of a building, it will not work because it will spawn on the ground, under the building

 

 

My question is : how can i set the height ? in using this scrip

 

Thank you guys !

 

Share this post


Link to post
Share on other sites

I dont understand how it works really, sorry im not verry good at scripting 😕

Share this post


Link to post
Share on other sites
gun = selectRandom [
	"rhs_weap_pb_6p9",
	"rhs_weap_pya",
	"rhs_weap_makarov_pm",
	"rhs_weap_makarov_pmm",
	"rhs_weap_pp2000_folded"
];
Waffe1 = "groundweaponholder" createVehicle getpos this;
Waffe1 addWeaponCargo [gun,1];
Waffe1 setPosATL getPosATL this;

Not tested

  • Like 1

Share this post


Link to post
Share on other sites

I found 😉

 

here is the solution for people who want (in yellow, the number is the height to set)

 

 

gun = [

 

"rhs_weap_pb_6p9",
 "rhs_weap_pya",
 "rhs_weap_makarov_pm",
 "rhs_weap_makarov_pmm",
 "rhs_weap_pp2000_folded"

 

] call BIS_fnc_selectRandom;
Waffe1 = "groundweaponholder" createVehicle getpos this;
Waffe1 addWeaponCargo [gun,1];
Waffe1 setPos [getPos this select 0,getPos this select 1,
2.00];

Share this post


Link to post
Share on other sites
3 hours ago, ALPHIVE said:

I don't understand how it works really, sorry im not verry good at scripting 😕


The command  , I recommended using, is extracting building position automatically.  Positions that are spread inside , including second / third / whatever floors. Will work with other structures. You don't need to hardcode Z values as you did. 

i.e - place trigger called lootMarker , init the code:


weaponArray = [
"arifle_MXC_F",
"hgun_P07_F"
];


houseArray = (getMarkerPos "lootMarker") nearObjects ["house",300];

{
buildingPositions =[_x] call BIS_fnc_buildingPositions;
{
weapon = weaponArray select (floor (random (count weaponArray)));
itemBox = "WeaponHolderSimulated" createVehicle [0,0,0];
itemBox setPos _x;
itemBox addWeaponCargoGlobal [weapon,1];
} forEach buildingPositions;
} forEach houseArray;

This will spawn random weapons  from weaponArray on all positions in all houses in radius of 300 meters from trigger. If you want to you can make some to spawn and some not, as not forEach buildingPosition.   The point is , I recommend using "automated" positions of the buildings models and not hardcoded per attached object like helipad.

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  

×