Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Ice_Rhino

Random Location of units

Recommended Posts

I am creating a Hostage Rescue mission using the setcaptive commands. Is there a way that I can make it so that the hostages could appear in any one of a number of predefined buildings each time you play? I wanted them to be in any of 4 buildings at random.

Thanks

IR

Edited by Ice_Rhino
Corrected very bad english

Share this post


Link to post
Share on other sites

Place markers next to possible buildings you'd want to use. Place the unit next to another possible building you'd wanna use. Group the unit to all the markers. Then use something like this old script from Tophe to place the unit in a random spot:

init field of unit:

0 = [this] execVM "bp.sqf";

bp.sqf:

_unit = _this select 0;
_house = nearestbuilding (_this select 0);
_p = 0;
while { format ["%1", _house buildingPos _p] != "[0,0,0]" } do {_p = _p + 1};
_p = _p - 1;
_unit setPos (_house buildingpos (random _p)); 

The unit will spawn either wherever you place them or at one of the grouped markers then teleport into one of the building positions of the nearby building.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×