Jump to content
HaggisRoll

Help with a Simple Random Spawn Script

Recommended Posts

HI all.

 

Wonder if anyone would be as kind enough to help me out with a script for random spawn of ai.

 

 

I would like to place 10 markers down on the map. and then when trigger is activated. an ai will spawn and then move to 1 of 10 random waypoints(markers)

 

I know i need to make another array with the marker positions in it.  But not sure on how to put it all together.

 

At the moment i have it working using the following, however i want to add random start points.

 

_mygroup = [getmarkerpos "HVT", EAST, ["O_officer_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;  // HVT is an empty marker called HVT

_wp1 = _mygroup addWaypoint [getmarkerpos "wp1", 0];  // wp1 is an empty marker called wp1

_wp2 = _mygroup addWaypoint [getmarkerpos "wp2", 0];  // wp1 is an empty marker called wp1

 

I'll use it in a trigger and call it there.

 

 

Any help would be greta.

 

Thanks

A

Share this post


Link to post
Share on other sites
_spawnposarray = ["spawnpos1","spawnpos2","spawnpos3"]; //array with three marker names
_spawnpos = selectRandom _spawnposarray; //select a random spawnposition

_mygroup = [getmarkerpos _spawnpos, EAST, ["O_officer_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup; //spawn the unit on the random position.

Here's an example.

  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, L3TUC3 said:

_spawnposarray = ["spawnpos1","spawnpos2","spawnpos3"]; //array with three marker names
_spawnpos = selectRandom _spawnposarray; //select a random spawnposition

_mygroup = [getmarkerpos _spawnpos, EAST, ["O_officer_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup; //spawn the unit on the random position.

Here's an example.

 

selectRandom works but a lot of times with me I had issues with it. you can use instead BIS_fnc_selectRandom

Share this post


Link to post
Share on other sites

I don't specify the array and I've never had a problem with selectRandom  when I use it like this:-

 

_spawnpos = selectRandom ["spawnpos1","spawnpos2","spawnpos3"]; //select a random spawnposition from 3 marker names

_mygroup = [getmarkerpos _spawnpos, EAST, ["O_officer_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup; //spawn the unit on the random position.

Share this post


Link to post
Share on other sites
1 hour ago, Beerkan said:

I don't specify the array and I've never had a problem with selectRandom  when I use it like this:-

 

 


_spawnpos = selectRandom ["spawnpos1","spawnpos2","spawnpos3"]; //select a random spawnposition from 3 marker names

_mygroup = [getmarkerpos _spawnpos, EAST, ["O_officer_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup; //spawn the unit on the random position.

 

Yeah, that works as well, less typing xD. Simpler form tbh.

Share this post


Link to post
Share on other sites

Guys. You make it look so simple.  Thanks a million.

 

Been trying for days before i decied to ask..:dontgetit:

 

Would love to learn more about arma coding, but find it hard to wrap my head around sometimes.

 

 

Share this post


Link to post
Share on other sites

?  Can i do this with Waypoints also based on markers.   Say once the unit spawns in, send him to a random marker based on an array also.

Share this post


Link to post
Share on other sites

I've done it...  :don11:

 

Here it is.   You guys helped with the first part.  Thanks again.

 

Basicly i can spawn a HVT at any of set locations.   Once the HVT spawns, he'll move to 1 of the 3 waypoints.

 

_spawnposition = selectRandom ["wp1","wp2","wp3","wp4","wp5","wp6","wp7","wp8","wp9","wp10"];             //select a random spawnposition from 10 marker names

_HVT = [getmarkerpos _spawnposition, EAST, ["O_officer_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;     //spawn the unit on the random position.

 

_wppostistion = selectRandom ["wp_1","wp_2","wp_3"];                         //    selects a random spawnposition from 3 empty markers named wp_1, wp_2 & wp_3

_waypoint  = _HVT  addWaypoint [getmarkerpos _wppostistion,0];        //  Tells the spawned HVT to add a waypoint at one of the postitions from the _wppostistion array

 

Can i equip this unit with specific gear and clothing?... i.e laser designator.

Share this post


Link to post
Share on other sites

Due to the way you have spawned the "O_officer_F " you have set  _HVT as the name of the Group " O_officer_F " is in, therefore instead of doing say this

_HVT linkItem "Laserdesignator";

you might have to do this to add a laser Designator to him.

leader group _HVT linkItem "Laserdesignator";

Share this post


Link to post
Share on other sites
1 hour ago, Beerkan said:

Due to the way you have spawned the "O_officer_F " you have set  _HVT as the name of the Group " O_officer_F " is in, therefore instead of doing say this


_HVT linkItem "Laserdesignator";

you might have to do this to add a laser Designator to him.


leader group _HVT linkItem "Laserdesignator";

 

 

Nice..   Will have a mess with it and see what i can come up with.

 

 

 

 

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

×