Advertisement
Guest User

Untitled

a guest
Aug 29th, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.61 KB | None | 0 0
  1. ALiVE_fnc_combatSupportAdd = {
  2. private ["_support", "_array","_sides"];
  3. _support = _this select 0;
  4. _array = _this select 1;
  5.  
  6. _sides = [WEST,EAST,RESISTANCE,CIVILIAN];
  7. switch (_support) do
  8. {
  9. case "TRANSPORT" :
  10. {
  11. private ["_pos", "_dir", "_type", "_callsign", "_code","_tasks","_side"];
  12. _pos = _array select 0; _pos set [2, 0];
  13. _dir = _array select 1;
  14. _type = _array select 2;
  15. _callsign = toUpper (_array select 3);
  16. _code = _array select 4;
  17. _height = parsenumber(_array select 5);
  18.  
  19. _tasks = ["Pickup", "Land", "land (Eng off)", "Move", "Circle","Insertion"];
  20.  
  21. _transportfsm = "\x\alive\addons\sup_combatSupport\scripts\NEO_radio\fsms\transport.fsm";
  22. _faction = gettext(configfile >> "CfgVehicles" >> _type >> "faction");
  23. _side = getNumber(configfile >> "CfgVehicles" >> _type >> "side");
  24.  
  25. switch (_side) do {
  26. case 0 : {_side = EAST};
  27. case 1 : {_side = WEST};
  28. case 2 : {_side = RESISTANCE};
  29. default {_side = EAST};
  30. };
  31.  
  32.  
  33. private ["_veh"];
  34. _veh = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
  35. _veh setDir _dir;
  36. _veh setPosATL _pos;
  37.  
  38. If(_height > 0) then {_veh setposasl [getposASL _veh select 0, getposASL _veh select 1, _height]; _veh setVelocity [0,0,-1]} else {_veh setPosATL _pos};
  39.  
  40. private ["_grp"];
  41. _grp = createGroup _side;
  42. [_veh, _grp] call BIS_fnc_spawnCrew;
  43.  
  44. _ffvTurrets = [_type,true,true,false,true] call ALIVE_fnc_configGetVehicleTurretPositions;
  45. _gunnerTurrets = [_type,false,true,true,true] call ALIVE_fnc_configGetVehicleTurretPositions;
  46. _ffvTurrets = _ffvTurrets - _gunnerTurrets;
  47.  
  48.  
  49.  
  50. if(count _ffvTurrets > 0) then
  51. {
  52. for "_i" from 0 to (count _ffvTurrets)-1 do
  53. {
  54. _turretPath = _ffvTurrets call BIS_fnc_arrayPop;
  55. [_veh turretUnit _turretPath] join grpNull;
  56. deleteVehicle (_veh turretUnit _turretPath);
  57. };
  58. };
  59.  
  60. _veh lockDriver true;
  61. [_grp,0] setWaypointPosition [(getPos _veh),0];
  62.  
  63. _codeArray = [_code, ";"] Call CBA_fnc_split;
  64. {
  65. If(_x != "") then {
  66. [_veh, _x] spawn {
  67. private ["_veh", "_spawn"];
  68. _veh = _this select 0;
  69. _spawn = compile(_this select 1);
  70. [_veh] spawn _spawn;
  71. };
  72. };
  73. } forEach _codeArray;
  74.  
  75.  
  76. //Set Group ID
  77. [[(units _grp select 0),_callsign], "fnc_setGroupID", false, false] spawn BIS_fnc_MP;
  78.  
  79. // set ownership flag for other modules
  80. _veh setVariable ["ALIVE_CombatSupport", true];
  81. _veh setVariable ["NEO_transportAvailableTasks", _tasks, true];
  82.  
  83. [_veh, _grp, _callsign, _pos, _dir, _height, _type, CS_RESPAWN,_code] execFSM _transportfsm;
  84.  
  85.  
  86. private ["_transportArray"];
  87. _transportArray = NEO_radioLogic getVariable format ["NEO_radioTrasportArray_%1", _side];
  88. _transportArray set [count _transportArray, [_veh, _grp, _callsign]];
  89. NEO_radioLogic setVariable [format ["NEO_radioTrasportArray_%1", _side], _transportArray, true];
  90. };
  91.  
  92. case "CAS" :
  93. {
  94. private ["_pos", "_dir", "_type", "_callsign", "_code","_height","_aiport","_side"];
  95. _pos = _array select 0;
  96. _airport = [_pos] call ALiVE_fnc_getNearestAirportID;
  97. _pos set [2, 0];
  98. _dir = _array select 1;
  99. _type = _array select 2;
  100. _callsign = toUpper (_array select 3);
  101. _code = _array select 4;
  102. _height = parsenumber(_array select 5);
  103.  
  104. _casfsm = "\x\alive\addons\sup_combatSupport\scripts\NEO_radio\fsms\cas.fsm";
  105.  
  106. _faction = gettext(configfile >> "CfgVehicles" >> _type >> "faction");
  107. _side = getNumber(configfile >> "CfgVehicles" >> _type >> "side");
  108.  
  109. switch (_side) do {
  110. case 0 : {_side = EAST};
  111. case 1 : {_side = WEST};
  112. case 2 : {_side = RESISTANCE};
  113. default {_side = EAST};
  114. };
  115.  
  116.  
  117. private ["_veh"];
  118. _veh = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
  119. _veh setDir _dir;
  120. _veh setPosATL _pos;
  121.  
  122. If(_height > 0) then {_veh setposasl [getposASL _veh select 0, getposASL _veh select 1, _height]; _veh setVelocity [0,0,-1]} else {_veh setPosATL _pos};
  123.  
  124. private ["_grp"];
  125. _grp = createGroup _side;
  126. If (getNumber(configFile >> "CfgVehicles" >> _type >> "isUav") == 1) then {
  127. createVehicleCrew _veh;
  128. } else {
  129. [_veh, _grp] call BIS_fnc_spawnCrew;
  130. };
  131.  
  132. _ffvTurrets = [_type,true,true,false,true] call ALIVE_fnc_configGetVehicleTurretPositions;
  133. _gunnerTurrets = [_type,false,true,true,true] call ALIVE_fnc_configGetVehicleTurretPositions;
  134. _ffvTurrets = _ffvTurrets - _gunnerTurrets;
  135.  
  136.  
  137.  
  138. if(count _ffvTurrets > 0) then
  139. {
  140. for "_i" from 0 to (count _ffvTurrets)-1 do
  141. {
  142. _turretPath = _ffvTurrets call BIS_fnc_arrayPop;
  143. [_veh turretUnit _turretPath] join grpNull;
  144. deleteVehicle (_veh turretUnit _turretPath);
  145. };
  146. };
  147.  
  148. _veh lockDriver true;
  149. [_grp,0] setWaypointPosition [(getPos _veh),0];
  150.  
  151. _codeArray = [_code, ";"] Call CBA_fnc_split;
  152. {
  153. If(_x != "") then {
  154. [_veh, _x] spawn {
  155. private ["_veh", "_spawn"];
  156. _veh = _this select 0;
  157. _spawn = compile(_this select 1);
  158. [_veh] spawn _spawn;
  159. };
  160. };
  161. } forEach _codeArray;
  162.  
  163.  
  164. // Set Group ID
  165. [[(units _grp select 0),_callsign], "fnc_setGroupID", false, false] spawn BIS_fnc_MP;
  166.  
  167. // set ownership flag for other modules
  168. _veh setVariable ["ALIVE_CombatSupport", true];
  169.  
  170. //FSM
  171. [_veh, _grp, _callsign, _pos, _airport, _dir, _height, _type, CS_RESPAWN, _code] execFSM _casfsm;
  172.  
  173. private ["_casArray"];
  174. _casArray = NEO_radioLogic getVariable format ["NEO_radioCasArray_%1", _side];
  175. _casArray set [count _casArray, [_veh, _grp, _callsign]];
  176. NEO_radioLogic setVariable [format ["NEO_radioCasArray_%1", _side], _casArray, true];
  177. diag_log format ["Support with callsign not found in Transport units"];
  178. };
  179. /*
  180. case "ARTY" :
  181. {
  182. private ["_pos", "_class", "_callsign", "_unitCount", "_rounds", "_code", "_roundsUnit", "_roundsAvailable", "_canMove", "_units", "_grp", "_vehDir"];
  183. _pos = _array select 0; _pos set [2, 0];
  184. _class = _array select 1;
  185. _callsign = toUpper (_array select 2);
  186. _unitCount = round (_array select 3); if (_unitCount > 4) then { _unitCount = 4 }; if (_unitCount < 1) then { _unitCount = 1 };
  187. _rounds = _array select 4;
  188. _code = _array select 5;
  189. _roundsUnit = _class call NEO_fnc_artyUnitAvailableRounds;
  190. _roundsAvailable = [];
  191. _canMove = if (_class in ["MLRS", "GRAD_CDF", "GRAD_INS", "GRAD_RU"]) then { true } else { false };
  192. _units = [];
  193. _grp = createGroup _side;
  194. _vehDir = 0;
  195.  
  196. for "_i" from 0 to (_unitCount - 1) do
  197. {
  198. private ["_vehPos", "_veh"];
  199. _vehPos = [_pos, 15, _vehDir] call BIS_fnc_relPos; _vehPos set [2, 0];
  200. _veh = createVehicle [_class, _vehPos, [], 0, "CAN_COLLIDE"];
  201. [nil, nil, rCALLVAR, [_veh], BIS_ARTY_F_initVehicle] call RE;
  202. _veh setDir _vehDir;
  203. _veh setPosATL _vehPos;
  204. [_veh, _grp] call BIS_fnc_spawnCrew;
  205. _veh lock true;
  206. _vehDir = _vehDir + 90;
  207. _units set [count _units, _veh];
  208. };
  209.  
  210. private ["_battery"];
  211. _battery = (createGroup _side) createUnit ["BIS_ARTY_Logic", _pos, [], 0, "NONE"];
  212. waitUntil { !isNil { BIS_ARTY_LOADED } };
  213.  
  214. _battery synchronizeObjectsAdd [_units select 0];
  215. waitUntil { (_units select 0) in (synchronizedObjects _battery) };
  216. [nil, nil, "per", rSPAWN, [_grp, _callsign], { (_this select 0) setGroupId [(_this select 1)] }] call RE;
  217.  
  218. //Validate rounds
  219. {
  220. if ((_x select 0) in _roundsUnit) then
  221. {
  222. _roundsAvailable set [count _roundsAvailable, _x];
  223. };
  224. } forEach _rounds;
  225. _battery setVariable ["NEO_radioArtyBatteryRounds", _roundsAvailable, true];
  226.  
  227. //Code to spawn
  228. [_battery, _grp, _units, units _grp] spawn _code;
  229.  
  230. //FSM
  231. [_units, _grp, _callsign, _pos, _roundsAvailable, _canMove, _class, _battery] execFSM "scripts\NEO_radio\fsms\arty.fsm";
  232.  
  233. private ["_artyArray"];
  234. _artyArray = NEO_radioLogic getVariable format ["NEO_radioArtyArray_%1", _side];
  235. _artyArray set [count _artyArray, [_battery, _grp, _callsign, _units, _roundsAvailable]];
  236. NEO_radioLogic setVariable [format ["NEO_radioArtyArray_%1", _side], _artyArray, true];
  237. };
  238. */
  239. };
  240. };
  241.  
  242. ALiVE_fnc_combatSupportRemove = {
  243. private ["_side", "_support", "_callsign"];
  244. _side = _this select 0;
  245. _support = _this select 1;
  246. _callsign = _this select 2;
  247.  
  248. switch (_support) do
  249. {
  250. case "TRANSPORT" :
  251. {
  252. private ["_array", "_index"];
  253. _array = NEO_radioLogic getVariable format ["NEO_radioTrasportArray_%1", _side];
  254. _index = 99;
  255.  
  256. {
  257. if ((_x select 2) == _callsign) then
  258. {
  259. _index = _forEachIndex;
  260. };
  261. } forEach _array;
  262.  
  263. if (_index != 99) then
  264. {
  265. {
  266. switch (_forEachIndex) do
  267. {
  268. case 0 : { { if (!isPlayer _x) then { deletevehicle _x } } forEach crew _x; deleteVehicle _x };
  269. case 1 : { deleteGroup _x };
  270. };
  271. } forEach (_array select _index);
  272.  
  273. _array set [_index, "DELETEPLEASE"];
  274. _array = _array - ["DELETEPLEASE"];
  275. NEO_radioLogic setVariable [format ["NEO_radioTrasportArray_%1", _side], _array, true];
  276. }
  277. else
  278. {
  279. diag_log format ["Support with callsign %1 not found in Transport units", _callsign];
  280. };
  281. };
  282.  
  283. case "CAS" :
  284. {
  285. private ["_array", "_index"];
  286. _array = NEO_radioLogic getVariable format ["NEO_radioCasArray_%1", _side];
  287. _index = 99;
  288.  
  289. {
  290. if ((_x select 2) == _callsign) then
  291. {
  292. _index = _forEachIndex;
  293. };
  294. } forEach _array;
  295.  
  296. if (_index != 99) then
  297. {
  298. {
  299. switch (_forEachIndex) do
  300. {
  301. case 0 : { { deletevehicle _x } forEach crew _x; deleteVehicle _x };
  302. case 1 : { deleteGroup _x };
  303. };
  304. } forEach (_array select _index);
  305.  
  306. _array set [_index, "DELETEPLEASE"];
  307. _array = _array - ["DELETEPLEASE"];
  308. NEO_radioLogic setVariable [format ["NEO_radioCasArray_%1", _side], _array, true];
  309. }
  310. else
  311. {
  312. diag_log format ["Support with callsign %1 not found in Cas units", _callsign];
  313. };
  314. };
  315.  
  316. /*case "ARTY" :
  317. {
  318. private ["_array", "_index"];
  319. _array = NEO_radioLogic getVariable format ["NEO_radioArtyArray_%1", _side];
  320. _index = 99;
  321.  
  322. {
  323. if ((_x select 2) == _callsign) then
  324. {
  325. _index = _forEachIndex;
  326. };
  327. } forEach _array;
  328.  
  329. if (_index != 99) then
  330. {
  331. {
  332. switch (_forEachIndex) do
  333. {
  334. case 0 : { deleteVehicle _x };
  335. case 1 : { { deletevehicle _x } forEach units _x; deleteGroup _x };
  336. case 3 : { { deleteVehicle _x } forEach _x };
  337. };
  338. } forEach (_array select _index);
  339.  
  340. _array set [_index, "DELETEPLEASE"];
  341. _array = _array - ["DELETEPLEASE"];
  342. NEO_radioLogic setVariable [format ["NEO_radioArtyArray_%1", _side], _array, true];
  343. }
  344. else
  345. {
  346. diag_log format ["Support with callsign %1 not found in Arty units", _callsign];
  347. };
  348. };*/
  349. };
  350. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement