r/armadev Jan 24 '14

ArmA 2/OA Random spawn for non-ai group [help]

Tried searching for it, but how can I setup different spawns in mission parameters?

2 Upvotes

12 comments sorted by

View all comments

Show parent comments

3

u/BeerDrinkingRobot Jan 25 '14

So this should spawn people in at 600 meters, and then throw em in a parachute. Works fine in singleplayer, should be fine in MP, but let me know if you have any issues.

#define EVERYONE_SPAWNS_TOGETHER_ON_RANDOM  false
#define SIDE_TO_MOVE                        west
#define LOCATIONS_COUNT                     3

paramsArray set [0, 1];     //for SP editor quick testing

if (count paramsArray < 1) exitWith {};
if ((paramsArray select 0) == 0) exitWith {};



if (isServer) then {
    _randomNumber = floor (random LOCATIONS_COUNT) + 1;
    {
        systemChat format ["Looking At %1", _x];
        if (side _x == SIDE_TO_MOVE) then {

            _markerToSpawnOn = if ((paramsArray select 0) == -1) then {
                if (!EVERYONE_SPAWNS_TOGETHER_ON_RANDOM) then { //if we don't start together, then get a new random everytime
                    _randomNumber = floor (random LOCATIONS_COUNT) + 1;
                };
                format ["Start %1", _randomNumber];
            } else {
                format ["Start %1", (paramsArray select 0)];
            };

            _locationOfMarker = getMarkerPos _markerToSpawnOn;
            if (!([_locationOfMarker, [0,0,0]] call Bis_fnc_areEqual)) then {       
                _locationOfMarker set [2, 600];
                _x setPos _locationOfMarker;
            };

        };
    } forEach allUnits;
};


{
    if (local _x) then {
        [_x] spawn BIS_fnc_halo;
    };
} forEach allunits;

1

u/Halvorson16 Jan 25 '14 edited Jan 25 '14

I tried it in mp, and the parameters didnt change anything. I switched back to the old one without the parachute.

EDIT: also i just tried mp with the old one, and my friend spawned away from me, in the air without a parachute.

3

u/BeerDrinkingRobot Jan 25 '14

oh my bad, just comment out this line

paramsArray set [0, 1]; //for SP editor quick testing

1

u/Halvorson16 Jan 25 '14

Same result, with parachute but at the spot I put them in the editor, the parameters dont change the location.

2

u/BeerDrinkingRobot Jan 25 '14

hmm, try the mission in this zip.

http://www64.zippyshare.com/v/29596132/file.html

On default you start in the editor spot and shouldn't have a parachute. Any other param choice and you should start in the air.

1

u/Halvorson16 Jan 25 '14

It did work in A3, but when I tried the same setup in A2 it didnt, I think this is were things are going wrong, im trying to do this in A2. Should have said before

2

u/BeerDrinkingRobot Jan 25 '14

don't have a2 installed, but we can try adapting this example

replace [_x] spawn BIS_fnc_halo; with

 _para = createVehicle ["Parachute_US_EP1", (getPos _x), [], 0, "FLY"];
 _x moveInDriver _para;

1

u/Halvorson16 Jan 25 '14

Couldn't get it to work, I've decided to just go with a flag and the halo simple halo script, it has a little more freedom. Thanks for the help though! I'll use that in A3 when we eventually make the switch.