Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.45 KB | None | 0 0
  1.  
  2. private ["_basepos","_loopVar","_dir","_PTdir","_pos","_barrier","_unitsArray","_flatPos","_accepted","_position","_enemiesArray","_targetList","_fuzzyPos","_x","_briefing","_enemiesArray","_unitsArray","_flatPos1","_flatPos2","_flatPos3","_doTargets","_targetSelect","_targetListEnemy"];
  3.  
  4. //-------------------- 1. FIND POSITION FOR OBJECTIVE
  5.  
  6. _basepos = getMarkerPos "respawn_west";
  7. _flatPos = [0,0,0];
  8. _accepted = false;
  9. while {!_accepted} do {
  10. _position = [[[_basepos,2000]],["water","out"]] call BIS_fnc_randomPos;
  11. _flatPos = _position isFlatEmpty [5, 0, 0.2, 5, 0, false];
  12.  
  13. while {(count _flatPos) < 2} do {
  14. _position = [[[_basepos,6000]],["water","out"]] call BIS_fnc_randomPos;
  15. _flatPos = _position isFlatEmpty [5, 0, 0.2, 5, 0, false];
  16. };
  17.  
  18. if ((_flatPos distance _basepos) > 2000) then {
  19. if ((_flatPos distance _basepos) < 3750) then {
  20. if ((_flatPos distance (getMarkerPos currentAO)) > 500) then {
  21. _accepted = true;
  22. };
  23. };
  24. };
  25. };
  26.  
  27. _flatPos1 = [(_flatPos select 0) - 2, (_flatPos select 1) - 2, (_flatPos select 2)];
  28. _flatPos2 = [(_flatPos select 0) + 2, (_flatPos select 1) + 2, (_flatPos select 2)];
  29. _flatPos3 = [(_flatPos select 0) + 20, (_flatPos select 1) + random 20, (_flatPos select 2)];
  30.  
  31. //-------------------- 2. SPAWN OBJECTIVES
  32.  
  33. _PTdir = random 360;
  34.  
  35. sleep 1;
  36.  
  37. priorityObj1 = "O_APC_Tracked_02_AA_F" createVehicle _flatPos1;
  38. waitUntil {!isNull priorityObj1};
  39. priorityObj1 setDir _PTdir;
  40.  
  41. sleep 1;
  42.  
  43. priorityObj2 = "O_APC_Tracked_02_AA_F" createVehicle _flatPos2;
  44. waitUntil {!isNull priorityObj2};
  45. priorityObj2 setDir _PTdir;
  46.  
  47. sleep 1;
  48.  
  49. //----- SPAWN AMMO TRUCK (for ambiance and plausibiliy of unlimited ammo)
  50.  
  51. ammoTruck = "O_Truck_03_ammo_F" createVehicle _flatPos3;
  52. waitUntil {!isNull ammoTruck};
  53. ammoTruck setDir random 360;
  54.  
  55. {_x lock 3;_x allowCrewInImmobile true;} forEach [priorityObj1,priorityObj2,ammoTruck];
  56.  
  57. //-------------------- 3. SPAWN CREW
  58.  
  59. _unitsArray = [objNull]; // for crew and h-barriers
  60.  
  61. _priorityGroup = createGroup east;
  62.  
  63. "O_officer_F" createUnit [_flatPos, _priorityGroup];
  64. "O_officer_F" createUnit [_flatPos, _priorityGroup];
  65. "O_engineer_F" createUnit [_flatPos, _priorityGroup];
  66. "O_engineer_F" createUnit [_flatPos, _priorityGroup];
  67.  
  68. ((units _priorityGroup) select 0) assignAsCommander priorityObj1;
  69. ((units _priorityGroup) select 0) moveInCommander priorityObj1;
  70. ((units _priorityGroup) select 1) assignAsCommander priorityObj2;
  71. ((units _priorityGroup) select 1) moveInCommander priorityObj2;
  72. ((units _priorityGroup) select 2) assignAsGunner priorityObj1;
  73. ((units _priorityGroup) select 2) moveInGunner priorityObj1;
  74. ((units _priorityGroup) select 3) assignAsGunner priorityObj2;
  75. ((units _priorityGroup) select 3) moveInGunner priorityObj2;
  76.  
  77. _unitsArray = _unitsArray + [_priorityGroup];
  78.  
  79. {
  80. _x addCuratorEditableObjects [[priorityObj1, priorityObj2, ammoTruck] + (units _priorityGroup), false];
  81. } foreach adminCurators;
  82.  
  83.  
  84. //---------- Engines on baby
  85.  
  86. sleep 0.1;
  87. priorityObj1 engineOn true;
  88. sleep 0.1;
  89. priorityObj2 engineOn true;
  90. priorityObj1 doWatch _basepos;
  91. priorityObj2 doWatch _basepos;
  92.  
  93.  
  94. //-------------------- 4. SPAWN H-BARRIER RING
  95.  
  96. sleep 1;
  97.  
  98. _distance = 16;
  99. _dir = 0;
  100. for "_c" from 0 to 7 do
  101. {
  102. _pos = [_flatPos, _distance, _dir] call BIS_fnc_relPos;
  103. _barrier = "Land_HBarrierBig_F" createVehicle _pos;
  104. waitUntil {alive _barrier};
  105. _barrier setDir _dir;
  106. _dir = _dir + 45;
  107. _barrier allowDamage false;
  108. _barrier enableSimulation false;
  109.  
  110. _unitsArray = _unitsArray + [_barrier];
  111. };
  112.  
  113. //-------------------- 5. SPAWN FORCE PROTECTION
  114.  
  115. _enemiesArray = [priorityObj1] call QS_fnc_PTenemyEAST;
  116.  
  117. //-------------------- 6. THAT GIRL IS SO DANGEROUS!
  118.  
  119. [(units _priorityGroup)] call QS_fnc_setSkill4;
  120. _priorityGroup setBehaviour "COMBAT";
  121. _priorityGroup setCombatMode "RED";
  122. _priorityGroup allowFleeing 0;
  123.  
  124. //----- 6a. UNLIMITED AMMO
  125.  
  126. priorityObj1 addEventHandler ["Fired",{ priorityObj1 setVehicleAmmo 1 }];
  127. priorityObj2 addEventHandler ["Fired",{ priorityObj2 setVehicleAmmo 1 }];
  128.  
  129. //-------------------- 6b. ABIT OF EXTRA HEALTH
  130.  
  131. //---------- OBJ 1
  132.  
  133. priorityObj1 setVariable ["selections", []];
  134. priorityObj1 setVariable ["gethit", []];
  135. priorityObj1 addEventHandler
  136. [
  137. "HandleDamage",
  138. {
  139. _unit = _this select 0;
  140. _selections = _unit getVariable ["selections", []];
  141. _gethit = _unit getVariable ["gethit", []];
  142. _selection = _this select 1;
  143. if !(_selection in _selections) then
  144. {
  145. _selections set [count _selections, _selection];
  146. _gethit set [count _gethit, 0];
  147. };
  148. _i = _selections find _selection;
  149. _olddamage = _gethit select _i;
  150. _damage = _olddamage + ((_this select 2) - _olddamage) * 0.25;
  151. _gethit set [_i, _damage];
  152. _damage;
  153. }
  154. ];
  155.  
  156. //---------- OBJ 2
  157.  
  158. priorityObj2 setVariable ["selections", []];
  159. priorityObj2 setVariable ["gethit", []];
  160. priorityObj2 addEventHandler
  161. [
  162. "HandleDamage",
  163. {
  164. _unit = _this select 0;
  165. _selections = _unit getVariable ["selections", []];
  166. _gethit = _unit getVariable ["gethit", []];
  167. _selection = _this select 1;
  168. if !(_selection in _selections) then
  169. {
  170. _selections set [count _selections, _selection];
  171. _gethit set [count _gethit, 0];
  172. };
  173. _i = _selections find _selection;
  174. _olddamage = _gethit select _i;
  175. _damage = _olddamage + ((_this select 2) - _olddamage) * 0.25;
  176. _gethit set [_i, _damage];
  177. _damage;
  178. }
  179. ];
  180.  
  181. //----- 6c. CAN SEE ALL PLAYERS OR NEARBY TARGETS (TARGET PILOTS?) SMALL RADAR DOME NEARBY?
  182.  
  183. /* WIP: See below loop */
  184.  
  185. //-------------------- 7. BRIEFING
  186.  
  187. _fuzzyPos = [((_flatPos select 0) - 300) + (random 600),((_flatPos select 1) - 300) + (random 600),0];
  188. { _x setMarkerPos _fuzzyPos; } forEach ["priorityMarker", "priorityCircle"];
  189. priorityTargetText = "Anti-Air Battery"; publicVariable "priorityTargetText";
  190. "priorityMarker" setMarkerText "Priority Target: Anti-Air Battery"; publicVariable "priorityMarker";
  191. _briefing = "<t align='center' size='2.2'>Priority Target</t><br/><t size='1.5' color='#b60000'>Anti-Air Battery</t><br/>____________________<br/>OPFOR forces are setting up an anti-air battery to hit you guys damned hard! We've picked up their positions with thermal imaging scans and have marked it on your map.<br/><br/>This is a priority target, boys!";
  192. GlobalHint = _briefing; hint parseText _briefing; publicVariable "GlobalHint";
  193. showNotification = ["NewPriorityTarget", "Destroy Anti-Air"]; publicVariable "showNotification";
  194.  
  195. //-------------------- 8. CORE LOOP
  196.  
  197. _loopVar = TRUE;
  198. _doTargets = [];
  199. _targetSelect = objNull;
  200. while {_loopVar} do {
  201.  
  202. //========== Small targeting system routine
  203.  
  204. _doTargets = [];
  205. _targetSelect = objNull;
  206. _targetList = _flatPos nearEntities [["Air"],7500];
  207. if ((count _targetList) > 0) then {
  208. {_priorityGroup reveal [_x,4];} forEach _targetList;
  209. _targetListEnemy = [];
  210. {
  211. if ((side _x) == west) then {
  212. 0 = _targetListEnemy pushBack _x;
  213. };
  214. } count _targetList;
  215.  
  216. if ((count _targetListEnemy) > 0) then {
  217. {
  218. if ((getPos _x select 2) > 25) then {
  219. 0 = _doTargets pushBack _x;
  220. };
  221. } count _targetListEnemy;
  222.  
  223. if ((count _doTargets) > 0) then {
  224. _targetSelect = _doTargets select (floor (random (count _doTargets)));
  225. if (canFire priorityObj1) then {
  226. priorityObj1 doWatch [(getPos _targetSelect select 0),(getPos _targetSelect select 1),2000];
  227. priorityObj1 doTarget _targetSelect;
  228. sleep 2;
  229. priorityObj1 fireAtTarget [_targetSelect,"missiles_titan"];
  230. sleep 2;
  231. if (canFire priorityObj2) then {
  232. _targetSelect = _doTargets select (floor (random (count _doTargets)));
  233. priorityObj2 doWatch [(getPos _targetSelect select 0),(getPos _targetSelect select 1),2000];
  234. priorityObj2 doTarget _targetSelect;
  235. sleep 2;
  236. priorityObj2 fireAtTarget [_targetSelect,"missiles_titan"];
  237. sleep 2;
  238. };
  239. } else {
  240. if (canFire priorityObj2) then {
  241. priorityObj2 doTarget _targetSelect;
  242. sleep 2;
  243. priorityObj2 doFire _targetSelect;
  244. sleep 2;
  245. };
  246. };
  247. };
  248. };
  249. };
  250.  
  251. //============================== Exit strategy
  252.  
  253. if (!alive priorityObj1) then {
  254. if (!alive priorityObj2) then {
  255.  
  256. _loopVar = FALSE;
  257.  
  258. //-------------------- 9. DE-BRIEF
  259.  
  260. _completeText = "<t align='center' size='2.2'>Priority Target</t><br/><t size='1.5' color='#08b000'>NEUTRALISED</t><br/>____________________<br/>Incredible job, boys! Make sure you jump on those priority targets quickly; they can really cause havoc if they're left to their own devices.<br/><br/>Keep on with the main objective; we'll tell you if anything comes up.";
  261. GlobalHint = _completeText; hint parseText _completeText; publicVariable "GlobalHint";
  262. showNotification = ["CompletedPriorityTarget", "Anti-Air Battery Neutralised"]; publicVariable "showNotification";
  263. {_x setMarkerPos [-10000,-10000,-10000];} forEach ["priorityMarker","priorityCircle"]; publicVariable "priorityMarker";
  264.  
  265. //-------------------- 10. DELETE
  266.  
  267. sleep 120;
  268. {_x removeEventHandler ["Fired", 0];} forEach [priorityObj1,priorityObj2];
  269. {_x removeEventHandler ["HandleDamage",1];} forEach [priorityObj1,priorityObj2];
  270. {[_x] spawn QS_fnc_SMdelete;} forEach [_enemiesArray,_unitsArray];
  271. {deleteVehicle _x;} forEach [priorityObj1,priorityObj2,ammoTruck];
  272. };
  273. };
  274. sleep 5;
  275. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement