Advertisement
Guest User

Untitled

a guest
Jun 15th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 6.84 KB | None | 0 0
  1. //by tankbuster
  2.  #include "..\includes.sqf"
  3. _myscript = "doprimary.sqf";
  4. __tky_starts;
  5. private ["_npt","_handle","_handle1","_flagpos","_t","_mytruck","_radarpos","_radartype","_hqtype","_hqpos","_testradius"];
  6. vehiclecleanup= []; mancleanup = []; roadblockreturndata = nil; roadblockscleared = false;pt_tripmines = [];
  7. sleep 10;
  8. __tky_debug
  9. if !(testmode) then {sleep 40;};
  10. civvecsmustbekilledflag = false; // have all the composition civ units (empty opfor vecs) been killed?
  11. if (primarytargetcounter > 1) then
  12.     {
  13.     // 2nd, 3rd , 4th targets, etc
  14.     handle_cnp_finished = false;
  15.     _npt = [cpt_position] execVM "server\choosenextprimary.sqf";// creates global variable nextpt which is a logic
  16.     waitUntil {handle_cnp_finished};
  17.     sleep 0.1;
  18.     civvecsmustbekilledflag = true; // this isn't pt1, so no composition objs to be killed
  19.     primarytarget = nextpt;// <-- dont forget nextpt is a logic
  20.     _handle = [primarytarget] execVM "server\PT_ai\ai_spawnroadblocks.sqf";// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<todo
  21.     waitUntil {sleep 0.2;(!(isnil "roadblockreturndata"))};
  22.     }else
  23.     {
  24.     roadblockscleared = true;// this is the first target, no roadblocks so set it to true so it's ignored
  25.     //[] spawn tky_fnc_ptcivvecscheck;
  26.     };
  27. __tky_debug
  28. //Reset goodguy scores.
  29. reinforcementcounter = 0;
  30. heartandmindscore = 0;
  31. civkillcount = 0;
  32. reinforcementcounter = 0;
  33. captivekillcounter = 0;
  34. deadgatecount = 0;
  35. cpt_position = getpos nextpt;
  36. cpt_radius = (nextpt getVariable "targetradius");
  37. cpt_type = (nextpt getVariable "targettype");
  38. cpt_name = (nextpt getVariable "targetname");
  39. cpt_island = (nextpt getVariable "targetlandmassid");
  40. primarytarget = nextpt;
  41. publicVariable "primarytarget";
  42. __tky_debug
  43. // Spawn Enemy Horde.
  44. handle_spt_finished = false;
  45. _handle1 = [primarytarget] execVM "server\spawnprimarytargetunits.sqf";//<< must send a target logic, ie on with variables stored on it
  46. __tky_debug
  47. waitUntil {handle_spt_finished};
  48. __tky_debug
  49. // Spawn Enemy CQB
  50. handle_ai_pcqb_finished = false;
  51. _handle1 = [position primarytarget, cpt_radius] execVM "server\PT_ai\ai_populateCQBBuildings2.sqf";//
  52. __tky_debug
  53. waitUntil {handle_ai_pcqb_finished};
  54. __tky_debug
  55. _flagpos = [cpt_position,0,20,0,0,20,0] call bis_fnc_findSafePos;
  56. cpt_flag = "Flag_Red_F" createVehicleLocal _flagpos;
  57. // create a marker
  58. cpt_marker = createMarker [("cpt_marker_" + str primarytargetcounter), cpt_position];
  59. cpt_marker setMarkerShape "ELLIPSE";
  60. cpt_marker setMarkerType "Flag";
  61. cpt_marker setMarkerSize [cpt_radius,cpt_radius];
  62. cpt_marker setMarkerColor "ColorRed";
  63. __tky_debug
  64.  
  65. // make trigger that senses when town is empty of enemies
  66. trg2 = createTrigger ["EmptyDetector", cpt_position];
  67. trg2 setTriggerArea [(cpt_radius),(cpt_radius),0,false];
  68. trg2 setTriggerActivation  ["EAST", "NOT PRESENT", false];
  69. trg2 setTriggerStatements ["this", "", ""];
  70.  
  71. trg3 = createTrigger ["EmptyDetector", cpt_position];
  72. trg3 setTriggerArea [(cpt_radius + 200),(cpt_radius + 200),0,false];
  73. trg3 setTriggerActivation  ["EAST", "NOT PRESENT", false];
  74. trg3 setTriggerStatements [" (triggerActivated trg2) and  {(not (alive pt_radar) ) and (not (alive pt_hq)) and (roadblockscleared) and (civvecsmustbekilledflag)}", "execVM 'server\assaultphasefinished.sqf'", ""];
  75. [] spawn
  76. {
  77.     while {primarytargetcounter isEqualTo 1} do
  78.     {
  79.         sleep 5;
  80.         if ( (vehicles inAreaArray trg3 select {(typeof _x) in civvecsmustbekilled and {alive _x}}) isEqualTo []) then
  81.             {civvecsmustbekilledflag = true;};
  82.     };
  83. };
  84. // task stuff
  85. __tky_debug
  86. taskname = "task" + str primarytargetcounter;
  87. [west, [taskname], ["Clear the target of all enemy forces", "Clear target of enemy forces",(format ["cpt_marker_%1", primarytargetcounter])], cpt_position,1,2,true ] call bis_fnc_taskCreate;
  88. if (
  89.         (primarytargetcounter isEqualTo 1) or
  90.         (cpt_type != 1) or
  91.         (cpt_radius < 150)
  92.     ) then {roadblockscleared = true};
  93. __tky_debug
  94. if (primarytargetcounter > 1) then
  95.     {
  96.     if ((roadblockreturndata # 4) > 0) then // if this isnt the first target and it has roadblocks spawned
  97.         {
  98.         0 spawn {
  99.             while {!roadblockscleared} do
  100.                 {
  101.                 sleep 10;
  102.                 deadgatecount = 0;
  103.                     {
  104.                     if ((_x animationPhase "Door_1_rot" isEqualTo 0) or (!alive _x) or ((damage _x) > 0.8)) then {deadgatecount = deadgatecount +1};
  105.                     } foreach roadblockgates;
  106.                 if (deadgatecount >= (count roadblockgates)) then
  107.                     {
  108.                     roadblockscleared = true;
  109.                         {
  110.                         _mytruck = _x;
  111.                         {_mytruck deleteVehicleCrew _x}foreach (crew _mytruck);
  112.                         deleteVehicle _mytruck; roadblockgates = [];
  113.                         } foreach roadreinforcementvehicles;
  114.                     roadreinforcementvehicles = [];
  115.                     }
  116.                 };
  117.             };
  118.         }
  119.         else
  120.         {
  121.         roadblockscleared = true;// if, for whatever reason, there are no rb's (towns with 1 or 0 access roads), set this to true;
  122.         };
  123.         if (cpt_type isEqualTo 1) then {0 = execVM "server\PT_ai\ai_roadreinforcementmanager.sqf";};
  124.     };
  125.     __tky_debug
  126. // air radar controls the opfor reinforcements that are bought in by helicopter
  127. _radarpos = [] call tky_fnc_findhighground;
  128. _radartype = selectRandom opforradartypes;
  129. pt_radar = createVehicle [_radartype, _radarpos,[],0,"NONE"];
  130. pt_radar addeventhandler ["HandleDamage", {if (((_this # 4) isKindOf "MissileCore") or ((_this # 4 ) isKindOf "ShellCore")) then { 1; } else { _this # 2; }; }];
  131. pt_radar_alive = true;
  132. pt_radar addEventHandler ["killed", {[_this # 0] execVM "server\pt_radarkilled.sqf"}];
  133. pt_radar setVectorUp [0,0,1];
  134. __tky_debug
  135. // hq vehicle controls opfor air support
  136. _hqtype = selectRandom opforhqtypes;
  137. __tky_debug
  138. _hqpos = [0,0,0];
  139. _testradius = 50;
  140. while {_hqpos in [[0,0,0], islandcentre] } do
  141.     {
  142.     _hqpos = [cpt_position, 10, _testradius, 23, 0, 0.3, 0] call BIS_fnc_findSafePos;
  143.     _testradius = _testradius * 2;
  144.     };
  145. pt_hq = createVehicle [_hqtype, _hqpos, [],0, "NONE"];
  146. pt_hq_alive = true;
  147. _higherhqpos = [_hqpos # 0, _hqpos # 1, 10 ];
  148. __tky_debug
  149. hqnet = createVehicle ["Land_IRMaskingCover_01_F", _higherhqpos, [] ,0, "CAN_COLLIDE" ];
  150. hqnet allowdamage false;
  151. pt_hq addeventhandler ["HandleDamage", {if (((_this # 4) isKindOf "MissileCore") or ((_this # 4 ) isKindOf "ShellCore")) then { 1; } else { _this # 2; }; }];
  152. pt_hq addEventHandler ["Killed", {[_this # 0] execVM "server\pt_hqkilled.sqf"}];
  153. if (_hqtype isKindOf "Car") then
  154.     {
  155.         hqnet setdir 90;
  156.     };
  157. if (_hqtype isKindOf "Building") then
  158.     {
  159.         hqnet setdir 180;
  160.     };
  161. [hqnet, 0] call BIS_fnc_setHeight;
  162. hqnet allowdamage true;
  163. __tky_debug
  164. 0 = execVM "server\PT_ai\ai_reinforcementChoppermanager.sqf";
  165. 0 = execVM "server\PT_ai\ai_airsupportmanager.sqf";
  166. 0 = execVM "server\killlastfewai.sqf";
  167. {
  168.     if ((cpt_position distance2d _x) > (cpt_radius + 100)) then
  169.         {
  170.             diag_log format ["%1 too far outside the target (%2m), so destroying it now", _x, (_x distance cpt_position)];
  171.             _x setdamage 1;
  172.         };
  173. } foreach [pt_radar, pt_hq];
  174. //stuff that needs to be check constantly runs here
  175. __tky_ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement