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

Random yet specific span location?

Recommended Posts

So right now I am trying to make a mission where my men have to locate a bomb and disarm it. I want it to spawn in a "random" location, which is really one of 6 possible locations.

Normally I would just group the item with 6 "empty" markers and call it good. But I am placing it inside of buildings, so I need a way to randomly have it be "spawned" or "setpos" at the start of the missions. I need to be able to set it up to a specific elevation and location basically.

Anyone able to help me out with this? The hard part is making it randomly choose one.

Share this post


Link to post
Share on other sites

create a alpha radio trigger repeated.

in on act: randomLoc = randomLoc + [(getPos player)];

create a bravo radio trigger.

in on act: copyToClipboard format["%1",randomLoc];

place yourself in a unit, place this in unit initline:

randomLoc = [];

Now run around the building, find the spot you want the object at and activate the alpha trigger, repeat this for all the positions you need, when done activate bravo trigger and alt tab to your script and ctrl v (paste) all the positions.

Edit: for alpha trigger you can maybe also use in on act:

randomLoc = randomLoc + [(getPos cursorTarget)];

this may give you an exact pos of on top of tables etc, or it will back fire and just give pos of house.

You can test your locations by adding this to the alpha trigger?

cone setPos (getPos cursorTarget)

and create a cone or small object and name it cone then it will be placed to the pos when you activate alpha trigger.

Edited by Demonized

Share this post


Link to post
Share on other sites

I guess I didn't explain it well enough...

I already KNOW the exact coordinates that I want it to spawn at, the question is, how do I make a script that randomly chooses one of the locations and puts the bomb there?

Share this post


Link to post
Share on other sites

place all the locations in an array:

_allLocations = [ [0,1,2], [0,1,2], [0,1,2], [0,1,2], [0,1,2], [0,1,2] ];

// select one random one:

_randomLoc = _allLocations select (floor(random(count _allLocations)));

_object setPos _randomLoc;

Share this post


Link to post
Share on other sites

if (!isServer) exitWith {};

private ["_pos1","_pos2","_pos3","_pos4","_pos5","_pos6","_posarray","_random_bomb_pos"];

_pos1 = [coords, go, here];
_pos2 = [coords, go, here];
_pos3 = [coords, go, here];
_pos4 = [coords, go, here];
_pos5 = [coords, go, here];
_pos6 = [coords, go, here];

_posarray = [_pos1,_pos2,_pos3,_pos4,_pos5,_pos6];

_random_bomb_pos = (_posarray select (floor(random(count _posarray))));

/// You now have a random bomb postion just use the variable: _random_bomb_pos

You beat me to it Demonized, lol. Nice multi dimensional array,btw. I started to make one but was not sure if he would understand it.

Edited by Riouken
Beaten to the punch

Share this post


Link to post
Share on other sites

@Riouken

I already KNOW the exact coordinates
well he seemed either really cocky or he knew what he was talking about.

I asumed in good faith it was the latter :)

Share this post


Link to post
Share on other sites
@Riouken

well he seemed either really cocky or he knew what he was talking about.

I asumed in good faith it was the latter :)

:)

Thanks for all the help Demonized, glad to have you in the community.

Share this post


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

×