Created
November 16, 2016 12:42
-
-
Save SamJUK/b56360977dcfbf6b91cc51c57f2195da to your computer and use it in GitHub Desktop.
ArmA 3 Mass Vehicle Spawn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Spawn Vehicle Script | |
PARAMETERS: | |
Vehicle(s): Classname | Single Array | Multi Dimentional Array | |
Total: Int | |
Row: Int | |
Return: None | |
["A3L_Towtruck",50,10]call sam_fnc_MassSpawn; | Spawn 5 rows of 10 tow trucks facing north totaling to 50 trucks | |
*/ | |
sam_fnc_MassSpawn = { | |
private ["_vehicles","_total","_row","_gap","_vehwidth","_startingCord","_vehtospawn","_classname","_pos"]; | |
//Parameters | |
_vehicles = _this select 0; | |
_total = _this select 1; | |
_row = _this select 2; | |
//Defines | |
//Local | |
_gap = 5; | |
_vehwidth = 5; | |
_startingCord = []; | |
_vehtospawn = []; | |
//Global | |
i = 0; | |
t = 0; | |
vs = 0; | |
//Check if anything to do | |
if (_total == 0)exitWith{hint "Atleast give me something to do :<"}; | |
if (_row == 0)exitWith{systemChat "How am i meant to spawn nothing in a row?";}; | |
//Vehicle to spawn | |
if (isArray _vehicles)then { | |
if (isArray(_vehicles select 0))then{ | |
//Multi Dia Array | |
{ | |
_a = _vehicles select _x; | |
if (!count _a == 1) then {_vehtospawn pushback (_a select 0)}; | |
if (count _a == 2) then { | |
while {ap < (_a select 1)} do { | |
_vehtospawn pushback (_a select 0); | |
ap = ap + 1; | |
}; | |
}; | |
} forEach _vehicles; | |
}else{ | |
//Single Array | |
_vehtospawn = _vehicles; | |
}; | |
}else{ | |
//Single Classname | |
_vehtospawn pushBack _vehicles; | |
}; | |
//Even in row | |
if (_row % 2 == 0) then { | |
_offsetCount = _row/2; | |
_offsetCord = (_gap + (_vehwidth/2)) * _offsetCount; | |
_startingCord = [(getPos player select 0) - _offsetCord, (getPos player select 1) - 5, getPos player select 2]; | |
}; | |
//Odd in row | |
if !(_row % 2 == 0) then { | |
_offsetCount = (_row - 1)/2; | |
_offsetCord = (_gap + (_vehwidth/2)) * _offsetCount; | |
_startingCord = [(getPos player select 0) - _offsetCord, (getPos player select 1) - 5, getPos player select 2]; | |
}; | |
//Spawn Loop | |
while {t < _total} do { | |
if (i < _row)then { | |
//Current Row | |
_classname = ""; | |
_pos = [0,0,0]; | |
if (i == 0)then {_pos = _startingCord;}else{_pos = [(_pos select 0) + _gap + (_vehwidth / 2), _pos select 1, _pos select 2];}; | |
//Get classname to spawn | |
if (count _vehtospawn == 1)then {_classname = _vehtospawn select 0}; | |
if (count _vehtospawn != 1)then {if (isNil _vehtospawn select vs) then {vs = 0;};_classname = _vehtospawn select vs}; | |
//Spawn | |
_veh = createVehicle [_classname, _pos, [], 0, "CAN_COLLIDE"]; | |
//Increase Increments | |
t = t + 1; | |
i = i + 1; | |
vs = vs + 1; | |
}else{ | |
//New Row | |
_startingCord = [_startingCord select 0, (_startingCord select 1) - 10, _startingCord select 2]; | |
i = 0; | |
}; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment