briefing.html|1Kbriefing.sqf+w4Kend.sqf1Kflare.sqsWc3K|fTaskHint.sqfy~pJinit.sqf1K]mission.sqm7KOUPS.sqf8:bJwplayer createDiaryRecord ["Diary", ["Warf Guards", "Intel tells us that these guards are nothing but newly trained recruits. Shouldn't be too hard to suprise and kill them, since they patrol the warf area alone."]]; player createDiaryRecord ["Diary", ["Overview", "Were going to sneak up on to the Russian coast line and take over a warf for future operations. A convoy delivering troops and supplies to the area will pass by, so is one of our targets. Intel tells us of a possible hide out of AA units and to kill them. Afterwards we should move on to the LZ and get picked up, and ready for the next mission... or atleast whats planned. All of this work is being done outside of a Russian Hotspot so atleast we shouldn't worry too much about patrols."]]; tsk4 = player createSimpleTask ["Make it to the LZ"]; tsk4 setSimpleTaskDestination (getMarkerPos "objmrk4"); tsk4 setSimpleTaskDescription ["Once everything is done, haul your asses to the LZ. After all the trouble we have caused, lord knows what might those Russians might send your way...", "Make it to the LZ", "Make it to the LZ"]; tsk3 = player createSimpleTask ["Eliminate enemy AA units"]; tsk3 setSimpleTaskDestination (getMarkerPos "objmrk3"); tsk3 setSimpleTaskDescription ["A wooded area near the location of the enemy base might possible contain AA units. They pose a threat to our helicopters and any other air units. Eliminate them before calling in the OK for the helicopter strike.", "Eliminate enemy AA units", "Eliminate enemy AA units"]; tsk2 = player createSimpleTask ["Ambush incoming convoy"]; tsk2 setSimpleTaskDestination (getMarkerPos "objmrk2"); tsk2 setSimpleTaskDescription ["Ambush the incoming convoy that is carrying suplies to the enemy base. It should pass the warf soon after landing on the beach. Be advised, the trucks are guarded by an APC. The amount is unknown.", "Ambush incoming convoy", "Ambush incoming convoy"]; tsk1 = player createSimpleTask ["Eliminate warf guards"]; tsk1 setSimpleTaskDestination (getMarkerPos "objmrk1"); tsk1 setSimpleTaskDescription ["The warf contains guards. Eliminate them so we might carry further operations from that point.", "Eliminate warf guards", "Eliminate warf guards"];sleep 7; // wait a while, so the player can get a look at things titleText ["To be continued...", "black out"];// fade out sleep 5; // end the mission now endMission "END1"; #Loop flare = "F_40mm_red" createVehicle [getPos aa1 select 0, getPos aa1 select 1, 300]; ~20 + (Random 100) goto "Loop";#define WHITE [1,1,1,1] #define GREY [0.75,0.75,0.75,1] #define GREEN [0.6,0.8,0.4,1] #define RED [1,0.1,0,1] private["_task", "_taskDescription", "_taskStatus", "_taskParams"]; _task = _this select 0; _taskDescription = (taskDescription _task) select 1; _taskStatus = toUpper(taskState _task); _taskParams = switch (_taskStatus) do { case "CREATED": { [format["NEW TASK ASSIGNED: \n%1", _taskDescription], WHITE, "taskNew"] }; case "ASSIGNED": { [format["ASSIGNED TASK: \n%1", _taskDescription], WHITE, "taskCurrent"] }; case "SUCCEEDED": { [format["TASK ACCOMPLISHED: \n%1", _taskDescription], GREEN, "taskDone"] }; case "FAILED": { [format["TASK FAILED: \n%1", _taskDescription], RED, "taskFAILED"] }; case "CANCELED": { [format["TASK CANCELED: \n%1", _taskDescription], GREY, "taskDone"] }; }; taskHint _taskParams;execVM "briefing.sqf"; mk_fTaskHint = compile (preprocessFileLineNumbers "fTaskHint.sqf");version=11; class Mission { addOns[]= { "chernarus", "cacharacters2", "CAWater", "CAWheeled", "CA_Modules_Alice", "ca_modules_animals", "ca_modules_silvie", "CAAir", "ca_missions_battlefieldclearance", "ca_missions_alternativeinjurysimulation", "ca_missions_firstaidsystem", "ace_sys_stick2gether" }; addOnsAuto[]= { "cacharacters2", "CAWater", "CAWheeled", "CA_Modules_Alice", "ca_modules_animals", "ca_modules_silvie", "CAAir", "ca_missions_battlefieldclearance", "ca_missions_alternativeinjurysimulation", "ca_missions_firstaidsystem", "ace_sys_stick2gether", "chernarus" }; randomSeed=10307062; class Intel { briefingName="Operation Silent Night"; briefingDescription="You are part of a 2 fire teams to sabotage the russian coastline defences..."; startWeather=0.57925665; startFog=0.54955518; forecastWeather=0.8171798; forecastFog=0.72079903; year=2005; month=12; day=18; hour=4; minute=0; }; class Groups { items=18; class Item0 { side="EAST"; class Vehicles { items=5; class Item0 { position[]={12880.557,5.9788208,10024.287}; id=0; side="EAST"; vehicle="RU_Soldier_TL"; leader=1; rank="SERGEANT"; skill=0.46666664; init="nul=[this,""RussianTerritory"",""random"",""min:"",8,""max"",16,""showmarker""] execVM ""ups.sqf"""; }; class Item1 { position[]={12889.557,5.9788208,10019.287}; id=4; side="EAST"; vehicle="RU_Soldier"; skill=0.2; }; class Item2 { position[]={12885.557,5.9788208,10019.287}; id=2; side="EAST"; vehicle="RU_Soldier_AT"; rank="CORPORAL"; skill=0.33333331; }; class Item3 { position[]={12887.557,5.9788208,10019.287}; id=3; side="EAST"; vehicle="RU_Soldier_GL"; skill=0.2; }; class Item4 { position[]={12883.557,5.9788208,10019.287}; id=1; side="EAST"; vehicle="RU_Soldier_AR"; rank="CORPORAL"; skill=0.33333331; }; }; }; class Item1 { side="WEST"; class Vehicles { items=4; class Item0 { position[]={13739.539,0.74110961,8191.9561}; id=9; side="WEST"; vehicle="USMC_Soldier_TL"; player="PLAY CDG"; leader=1; rank="SERGEANT"; skill=1; text="ldr1"; init="this moveincargo C2;"; synchronizations[]={50}; }; class Item1 { position[]={13742.539,0.83286321,8186.9561}; id=10; side="WEST"; vehicle="USMC_Soldier_Medic"; player="PLAY CDG"; rank="CORPORAL"; skill=1; init="this moveincargo C2;"; }; class Item2 { position[]={13744.539,0.78632295,8186.9561}; id=11; side="WEST"; vehicle="USMC_Soldier_AT"; player="PLAY CDG"; rank="CORPORAL"; skill=1; init="this moveincargo C2;"; }; class Item3 { position[]={13746.539,0.70659095,8186.9561}; id=12; side="WEST"; vehicle="USMC_Soldier_LAT"; player="PLAY CDG"; skill=1; init="this moveincargo C2;"; }; }; }; class Item2 { side="WEST"; class Vehicles { items=1; class Item0 { position[]={13660.676,0.49830681,8224.6553}; id=14; side="WEST"; vehicle="Zodiac"; leader=1; skill=0.2; text="C2"; }; }; class Waypoints { items=2; class Item0 { position[]={13067.066,4.2975159,8010.6343}; type="TR UNLOAD"; class Effects { }; showWP="NEVER"; }; class Item1 { position[]={14207.268,0.40562001,8231.5898}; class Effects { }; showWP="NEVER"; }; }; }; class Item3 { side="WEST"; class Vehicles { items=1; class Item0 { position[]={13661.466,0.48899853,8251.9375}; id=13; side="WEST"; vehicle="Zodiac"; leader=1; skill=0.2; text="C1"; }; }; class Waypoints { items=2; class Item0 { position[]={13107.314,3.6367993,8413.2393}; type="TR UNLOAD"; class Effects { }; showWP="NEVER"; }; class Item1 { position[]={14192.59,0.93079805,8262.1758}; class Effects { }; showWP="NEVER"; }; }; }; class Item4 { side="EAST"; class Vehicles { items=3; class Item0 { position[]={13171.325,5.9390421,7203.4902}; azimut=345; id=16; side="EAST"; vehicle="UAZ_AGS30_RU"; leader=1; skill=0.2; text="convoycar1"; }; class Item1 { position[]={13174.226,5.8643651,7191.439}; id=17; side="EAST"; vehicle="Ural_INS"; skill=0.2; text="convoycar2"; }; class Item2 { position[]={13182.468,5.8679552,7184.75}; azimut=345; id=47; side="EAST"; vehicle="UAZ_AGS30_RU"; skill=0.2; text="convoycar3"; }; }; class Waypoints { items=2; class Item0 { position[]={13110.639,6.120852,7317.7192}; combatMode="RED"; formation="LINE"; speed="NORMAL"; combat="SAFE"; expCond="if ( triggerActivated trg1 ) then { true };"; class Effects { }; showWP="NEVER"; }; class Item1 { position[]={13015.838,5.6985011,10059.367}; combatMode="RED"; formation="LINE"; speed="NORMAL"; combat="SAFE"; class Effects { }; showWP="NEVER"; }; }; }; class Item5 { side="EAST"; class Vehicles { items=3; class Item0 { position[]={12466.278,24.300314,8669.6162}; id=19; side="EAST"; vehicle="RU_Soldier_AA"; leader=1; rank="SERGEANT"; skill=0.46666664; }; class Item1 { position[]={12469.278,24.160305,8664.6162}; id=20; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; class Item2 { position[]={12471.278,24.066996,8664.6162}; id=21; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; }; class Waypoints { items=1; class Item0 { position[]={12469.664,24.094563,8670.5039}; type="HOLD"; class Effects { }; showWP="NEVER"; }; }; }; class Item6 { side="LOGIC"; class Vehicles { items=3; class Item0 { position[]={14214.861,0.70425618,7773.0308}; id=24; side="LOGIC"; vehicle="AliceManager"; leader=1; skill=0.60000002; }; class Item1 { position[]={14217.318,0.60700047,7905.7163}; id=22; side="LOGIC"; vehicle="BIS_animals_Logic"; skill=0.60000002; }; class Item2 { position[]={14318.061,0.52138543,7832.0015}; id=23; side="LOGIC"; vehicle="SilvieManager"; skill=0.60000002; }; }; }; class Item7 { side="EAST"; class Vehicles { items=3; class Item0 { position[]={11377.664,280.44238,8006.4043}; azimut=90; id=25; side="EAST"; vehicle="RU_Soldier_AA"; leader=1; rank="SERGEANT"; skill=0.46666664; }; class Item1 { position[]={11372.664,279.81696,8003.4043}; azimut=90; id=26; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; class Item2 { position[]={11372.664,279.62723,8001.4053}; azimut=90; id=27; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; }; }; class Item8 { side="EAST"; class Vehicles { items=3; class Item0 { position[]={11392.286,280.58508,7997.876}; azimut=90; id=28; side="EAST"; vehicle="RU_Soldier_AA"; leader=1; rank="SERGEANT"; skill=0.46666664; text="aa1"; }; class Item1 { position[]={11387.286,280.11176,7994.875}; azimut=90; id=29; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; class Item2 { position[]={11387.286,279.87183,7992.876}; azimut=90; id=30; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; }; }; class Item9 { side="EAST"; class Vehicles { items=3; class Item0 { position[]={11373.603,281.07724,8025.0889}; azimut=90; id=31; side="EAST"; vehicle="RU_Soldier_AA"; leader=1; rank="SERGEANT"; skill=0.46666664; }; class Item1 { position[]={11368.603,280.75165,8022.0889}; azimut=90; id=32; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; class Item2 { position[]={11368.603,280.6637,8020.0908}; azimut=90; id=33; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; }; }; class Item10 { side="EAST"; class Vehicles { items=3; class Item0 { position[]={11359.388,279.87711,8014.9346}; azimut=90; id=34; side="EAST"; vehicle="RU_Soldier_AA"; leader=1; rank="SERGEANT"; skill=0.46666664; }; class Item1 { position[]={11354.388,279.31808,8011.9346}; azimut=90; id=35; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; class Item2 { position[]={11354.388,279.1084,8009.9346}; azimut=90; id=36; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; }; }; class Item11 { side="EAST"; class Vehicles { items=3; class Item0 { position[]={11366.698,279.05725,8001.126}; azimut=90; id=37; side="EAST"; vehicle="RU_Soldier_AA"; leader=1; rank="SERGEANT"; skill=0.46666664; }; class Item1 { position[]={11361.698,278.147,7998.126}; azimut=90; id=38; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; class Item2 { position[]={11361.698,277.85373,7996.127}; azimut=90; id=39; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; }; }; class Item12 { side="EAST"; class Vehicles { items=3; class Item0 { position[]={11377.259,279.11932,7993.4072}; azimut=90; id=40; side="EAST"; vehicle="RU_Soldier_AA"; leader=1; rank="SERGEANT"; skill=0.46666664; }; class Item1 { position[]={11372.259,278.10556,7990.4072}; azimut=90; id=41; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; class Item2 { position[]={11372.259,277.76697,7988.4082}; azimut=90; id=42; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; }; }; class Item13 { side="WEST"; class Vehicles { items=1; class Item0 { position[]={12199.951,174.26367,6819.2627}; special="FLY"; id=43; side="WEST"; vehicle="MH60S"; leader=1; skill=0.60000002; text="lift1"; }; }; class Waypoints { items=2; class Item0 { position[]={12116.922,172.78137,6820.3115}; expCond="if( triggerActivated trg4 ) then { true }"; class Effects { }; showWP="NEVER"; }; class Item1 { position[]={11192.708,264.9248,8267.3838}; class Effects { }; showWP="NEVER"; }; }; }; class Item14 { side="EAST"; class Vehicles { items=3; class Item0 { position[]={12462.859,25.861513,8645.6768}; id=44; side="EAST"; vehicle="RU_Soldier_AA"; leader=1; rank="SERGEANT"; skill=0.46666664; }; class Item1 { position[]={12465.859,26.066275,8640.6768}; id=45; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; class Item2 { position[]={12467.859,25.959585,8640.6768}; id=46; side="EAST"; vehicle="RU_Soldier_AA"; rank="CORPORAL"; skill=0.33333331; }; }; class Waypoints { items=1; class Item0 { position[]={12466.245,25.630846,8646.5645}; type="HOLD"; class Effects { }; showWP="NEVER"; }; }; }; class Item15 { side="WEST"; class Vehicles { items=4; class Item0 { position[]={13737.525,0.2298203,8241.6377}; id=5; side="WEST"; vehicle="USMC_Soldier_TL"; player="PLAYER COMMANDER"; leader=1; rank="SERGEANT"; skill=1; text="ldr2"; init="this moveincargo C1;"; synchronizations[]={50}; }; class Item1 { position[]={13740.525,0.65250534,8236.6377}; id=6; side="WEST"; vehicle="USMC_Soldier_Medic"; player="PLAY CDG"; rank="CORPORAL"; skill=1; init="this moveincargo C1;"; }; class Item2 { position[]={13742.525,0.71232301,8236.6377}; id=7; side="WEST"; vehicle="USMC_Soldier_AT"; player="PLAY CDG"; rank="CORPORAL"; skill=1; init="this moveincargo C1;"; }; class Item3 { position[]={13744.525,0.73044312,8236.6377}; id=8; side="WEST"; vehicle="USMC_Soldier_LAT"; player="PLAY CDG"; skill=1; init="this moveincargo C1;"; }; }; }; class Item16 { side="EAST"; class Vehicles { items=1; class Item0 { position[]={13036.054,3.787282,8234.3604}; id=48; side="EAST"; vehicle="RU_Soldier"; leader=1; skill=0.2; init="nul=[this,""SeaBase"",""random"",""min:"",8,""max"",16] execVM ""ups.sqf""; this allowFleeing 0;"; }; }; }; class Item17 { side="LOGIC"; class Vehicles { items=4; class Item0 { position[]={13699.415,0.24642737,8204.7656}; id=50; side="LOGIC"; vehicle="BattleFieldClearance"; leader=1; skill=0.60000002; synchronizations[]={5,9}; }; class Item1 { position[]={13700.09,0.42253014,8227.5723}; id=51; side="LOGIC"; vehicle="AlternativeInjurySimulation"; skill=0.60000002; }; class Item2 { position[]={13698.525,0.22543107,8182.8262}; id=49; side="LOGIC"; vehicle="FirstAidSystem"; skill=0.60000002; }; class Item3 { position[]={13678.884,0.3086805,8204.9219}; id=52; side="LOGIC"; vehicle="ACE_S2G"; skill=0.60000002; }; }; }; }; class Vehicles { items=2; class Item0 { position[]={13094.241,2.0200005,8284.5957}; azimut=270; id=15; side="EMPTY"; vehicle="Ural_INS"; leader=1; skill=0.46666664; }; class Item1 { position[]={13094.241,2.0200005,8280.0732}; azimut=270; id=18; side="EMPTY"; vehicle="Ural_INS"; leader=1; skill=0.46666664; }; }; class Markers { items=7; class Item0 { position[]={12959.282,16.000061,10014.027}; name="RussianTerritory"; text="Under Russian Control"; markerType="RECTANGLE"; type="Empty"; colorName="ColorRed"; a=500; b=500; }; class Item1 { position[]={13056.602,2.0200005,8228.3486}; name="SeaBase"; markerType="RECTANGLE"; type="Empty"; colorName="ColorYellow"; a=60; b=80; }; class Item2 { position[]={13055.041,2.0200005,8240.1982}; name="objmrk1"; text="Eliminate warf guards"; type="mil_objective"; }; class Item3 { position[]={13026.092,5.696516,8149.8862}; name="objmrk2"; text="Ambush incoming convoy"; type="mil_objective"; }; class Item4 { position[]={12470.387,24.108608,8669.0791}; name="objmrk3"; text="Eliminate enemy AA units"; type="mil_objective"; }; class Item5 { position[]={12967.697,5.9977198,10245.807}; name="Russian Area"; text="Russian Area"; type="Faction_RU"; a=2; }; class Item6 { position[]={11176.889,263.34589,8264.6553}; name="objmrk4"; text="LZ"; type="mil_objective"; }; }; class Sensors { items=6; class Item0 { position[]={13674.935,0.63129842,8250.4707}; a=200; b=200; activationBy="WEST"; interruptable=1; age="UNKNOWN"; expActiv="ldr1 setCurrentTask tsk1; ldr2 setCurrentTask tsk1; [tsk1] call mk_fTaskHint; 1 setRadioMsg ""NULL"";"; class Effects { track="Track02_Insertion"; titleType="TEXT"; title="Operation Silent Night : 0400 Hours"; }; }; class Item1 { position[]={12968.467,6.5971341,8193.3896}; a=250; b=250; activationBy="EAST"; activationType="NOT PRESENT"; interruptable=1; age="UNKNOWN"; name="trg1"; expActiv="tsk1 setTaskState ""SUCCEEDED""; [tsk1] call mk_fTaskHint; ldr1 setCurrentTask tsk2; ldr2 setCurrentTask tsk2; [tsk2] call mk_fTaskHint;"; class Effects { }; }; class Item2 { position[]={13023.89,5.8651438,7847.0645}; a=750; b=750; interruptable=1; age="UNKNOWN"; name="trg2"; expCond="if ( ( !canMove convoycar1 ) and ( !canMove convoycar2 ) and ( !canMove convoycar3 ) ) then { true };"; expActiv="tsk2 setTaskState ""SUCCEEDED""; [tsk2] call mk_fTaskHint; ldr1 setCurrentTask tsk3; ldr2 setCurrentTask tsk3; [tsk3] call mk_fTaskHint;"; class Effects { }; }; class Item3 { position[]={11192.197,248.30983,7715.2813}; a=0; b=0; interruptable=1; age="UNKNOWN"; expCond="if( !alive lift1 ) then { true }"; expActiv="_Handle = player execVM ""end.sqf""; waitUntil {scriptDone _Handle};"; class Effects { }; }; class Item4 { position[]={11175.338,263.36063,8267.915}; a=100; b=100; activationBy="WEST"; interruptable=1; age="UNKNOWN"; name="trg4"; expActiv="tsk4 setTaskState ""SUCCEEDED""; [tsk4] call mk_fTaskHint; [] exec ""flare.sqs"";"; class Effects { track="Track01_Dead_Forest"; }; }; class Item5 { position[]={12467.851,23.463337,8678.5098}; a=200; b=200; activationBy="EAST"; activationType="NOT PRESENT"; interruptable=1; age="UNKNOWN"; name="trg3"; expActiv="tsk3 setTaskState ""SUCCEEDED""; [tsk3] call mk_fTaskHint; ldr1 setCurrentTask tsk4; ldr2 setCurrentTask tsk4; [tsk4] call mk_fTaskHint;"; class Effects { }; }; }; }; class Intro { addOns[]= { "chernarus" }; addOnsAuto[]= { "chernarus" }; randomSeed=903070; class Intel { startWeather=0.25; forecastWeather=0.25; year=2008; month=10; day=11; hour=9; minute=20; }; }; class OutroWin { addOns[]= { "chernarus" }; addOnsAuto[]= { "chernarus" }; randomSeed=4181820; class Intel { startWeather=0.25; forecastWeather=0.25; year=2008; month=10; day=11; hour=9; minute=20; }; }; class OutroLoose { addOns[]= { "chernarus" }; addOnsAuto[]= { "chernarus" }; randomSeed=12640663; class Intel { startWeather=0.25; forecastWeather=0.25; year=2008; month=10; day=11; hour=9; minute=20; }; }; // ========================================================================================================= // Urban Patrol Script // Version: 2.0.3 // Author: Kronzky (www.kronzky.info / kronzky@gmail.com) // --------------------------------------------------------------------------------------------------------- // Required parameters: // unit = Unit to patrol area (1st argument) // markername = Name of marker that covers the active area. (2nd argument) // (e.g. nul=[this,"town"] execVM "ups.sqf") // // Optional parameters: // random = Place unit at random start position. // randomdn = Only use random positions on ground level. // randomup = Only use random positions at top building positions. // min:n/max:n = Create a random number (between min and max) of 'clones'. // init:string = Custom init string for created clones. // nomove = Unit will stay at start position until enemy is spotted. // nofollow = Unit will only follow an enemy within the marker area. // delete:n = Delete dead units after 'n' seconds. // nowait = Do not wait at patrol end points. // noslow = Keep default behaviour of unit (don't change to "safe" and "limited"). // noai = Don't use enhanced AI for evasive and flanking maneuvers. // showmarker = Display the area marker. // trigger = Display a message when no more units are left in sector. // empty:n = Consider area empty, even if 'n' units are left. // track = Display a position and destination marker for each unit. // // ========================================================================================================= if (!isServer) exitWith {}; // how far opfors should move away if they're under attack // set this to 200-300, when using the script in open areas (rural surroundings) _safedist=75; // how close unit has to be to target to generate a new one _closeenough=10; // how close units have to be to each other to share information _sharedist=100; // how long AI units should be in alert mode after initially spotting an enemy _alerttime=180; // --------------------------------------------------------------------------------------------------------- // convert argument list to uppercase _UCthis = []; for [{_i=0},{_i=0} do {if (((_bld BuildingPos _bi) select 0)==0) then {_bi=-99} else {_bz=((_bld BuildingPos _bi) select 2); if (((_bz)>4) && ((_bz>_maxZ) || ((_bz==_maxZ) && (random 1>.8)))) then {_maxZ=_bz; _bldpos=_bi}};_bi=_bi+1};_bldpos}; KRON_OnRoad = {private["_p","_w","_i","_lst"];_p=_this select 0; _w=_this select 1; _i=_this select 2; _lst=_p nearObjects ["House",12]; if ((count _lst==0) && (_w || !(surfaceIsWater _p))) then {_i=99}; (_i+1)}; KRON_getDirPos = {private["_a","_b","_from","_to","_return"]; _from = _this select 0; _to = _this select 1; _return = 0; _a = ((_to select 0) - (_from select 0)); _b = ((_to select 1) - (_from select 1)); if (_a != 0 || _b != 0) then {_return = _a atan2 _b}; if ( _return < 0 ) then { _return = _return + 360 }; _return}; KRON_distancePosSqr = {(((_this select 0) select 0)-((_this select 1) select 0))^2 + (((_this select 0) select 1)-((_this select 1) select 1))^2}; KRON_relPos = {private["_p","_d","_a","_x","_y","_xout","_yout"];_p=_this select 0; _x=_p select 0; _y=_p select 1; _d=_this select 1; _a=_this select 2; _xout=_x + sin(_a)*_d; _yout=_y + cos(_a)*_d;[_xout,_yout,0]}; KRON_rotpoint = {private["_cp","_a","_tx","_ty","_cd","_sd","_cx","_cy","_xout","_yout"];_cp=_this select 0; _cx=_cp select 0; _cy=_cp select 1; _a=_this select 1; _cd=cos(_a*-1); _sd=sin(_a*-1); _tx=_this select 2; _ty=_this select 3; _xout=if (_a!=0) then {_cx+ (_cd*_tx - _sd*_ty)} else {_cx+_tx}; _yout=if (_a!=0) then {_cy+ (_sd*_tx + _cd*_ty)} else {_cy+_ty}; [_xout,_yout,0]}; KRON_stayInside = { private["_np","_nx","_ny","_cp","_cx","_cy","_rx","_ry","_d","_tp","_tx","_ty","_fx","_fy"]; _np=_this select 0; _nx=_np select 0; _ny=_np select 1; _cp=_this select 1; _cx=_cp select 0; _cy=_cp select 1; _rx=_this select 2; _ry=_this select 3; _d=_this select 4; _tp = [_cp,_d,(_nx-_cx),(_ny-_cy)] call KRON_rotpoint; _tx = _tp select 0; _fx=_tx; _ty = _tp select 1; _fy=_ty; if (_tx<(_cx-_rx)) then {_fx=_cx-_rx}; if (_tx>(_cx+_rx)) then {_fx=_cx+_rx}; if (_ty<(_cy-_ry)) then {_fy=_cy-_ry}; if (_ty>(_cy+_ry)) then {_fy=_cy+_ry}; if ((_fx!=_tx) || (_fy!=_ty)) then {_np = [_cp,_d*-1,(_fx-_cx),(_fy-_cy)] call KRON_rotpoint}; _np; }; // Misc KRON_UPSgetArg = {private["_cmd","_arg","_list","_a","_v"]; _cmd=_this select 0; _arg=_this select 1; _list=_this select 2; _a=-1; {_a=_a+1; _v=format["%1",_list select _a]; if (_v==_cmd) then {_arg=(_list select _a+1)}} foreach _list; _arg}; KRON_deleteDead = {private["_u","_s"];_u=_this select 0; _s= _this select 1; _u removeAllEventHandlers "killed"; sleep _s; deletevehicle _u}; KRON_AllTroops=[]; KRON_AllWest=[]; KRON_AllEast=[]; KRON_AllRes=[]; KRON_KnownEnemy=[objNull,objNull]; _obj = _this select 0; _pos = [5000,5000]; if (typename _obj=="OBJECT") then {_pos=position _obj}; _trg=createTrigger ["EmptyDetector", _pos]; _trg setTriggerArea [20000,20000,0,false]; _trg setTriggerActivation ["ANY","PRESENT",false]; _trg setTriggerTimeout [1,1,1,false]; sleep 1 + (random 1); _l=list _trg; deleteVehicle _trg; { if (("AllVehicles" countType [_x]>0) && (side _x != civilian)) then { KRON_AllTroops=KRON_AllTroops+[_x]; _s = side _x; switch (_s) do { case west: { KRON_AllWest=KRON_AllWest+[_x]; }; case east: { KRON_AllEast=KRON_AllEast+[_x]; }; case resistance: { KRON_AllRes=KRON_AllRes+[_x]; }; }; }; } forEach _l; _l = nil; if (isNil("KRON_UPS_Debug")) then {KRON_UPS_Debug=0}; //KRON_HQ="Logic" createVehicle [0,0]; createCenter sideLogic; _grpLogic = createGroup sideLogic; KRON_HQ = _grpLogic createUnit ["Logic", [0,0,0], [], 0, "NONE"]; KRON_UPS_Instances=0; KRON_UPS_Total=0; KRON_UPS_Exited=0; KRON_UPS_INIT=1; }; if ((count _this)<2) exitWith { if (format["%1",_this]!="INIT") then {hint "UPS: Unit and marker name have to be defined!"}; }; _exit = false; // --------------------------------------------------------------------------------------------------------- waitUntil {KRON_UPS_INIT==1}; sleep (random 1); KRON_UPS_Instances = KRON_UPS_Instances + 1; // get name of area marker _areamarker = _this select 1; if (isNil ("_areamarker")) exitWith { hint "UPS: Area marker not defined.\n(Typo, or name not enclosed in quotation marks?)"; }; // remember center position of area marker _centerpos = getMarkerPos _areamarker; _centerX = abs(_centerpos select 0); _centerY = abs(_centerpos select 1); // show area marker _showmarker = if ("SHOWMARKER" in _UCthis) then {"SHOWMARKER"} else {"HIDEMARKER"}; if (_showmarker=="HIDEMARKER") then { //_areamarker setMarkerCondition "false"; // VBS2 _areamarker setMarkerPos [-abs(_centerX),-abs(_centerY)]; }; // unit that's moving _obj = _this select 0; _npc = _obj; // is anybody alive in the group? _exit = true; if (typename _obj=="OBJECT") then { if (alive _npc) then {_exit = false;} } else { if (count _obj>0) then { {if (alive _x) then {_npc = _x; _exit = false;}} forEach _obj; }; }; // give this group a unique index _grpidx = format["%1",KRON_UPS_Instances]; _grpname = format["%1_%2",(side _npc),_grpidx]; // remember the original group members, so we can later find a new leader, in case he dies _members = units _npc; KRON_UPS_Total = KRON_UPS_Total + (count _members); // what type of "vehicle" is unit ? _isman = "Man" countType [_npc]>0; _iscar = "LandVehicle" countType [_npc]>0; _isboat = "Ship" countType [_npc]>0; _isplane = "Air" countType [_npc]>0; // check to see whether group is an enemy of the player (for attack and avoidance maneuvers) // since countenemy doesn't count vehicles, and also only counts enemies if they're known, // we just have to brute-force it for now, and declare *everyone* an enemy who isn't a civilian _issoldier = side _npc != civilian; _friends=[]; _enemies=[]; _sharedenemy=0; //TODO: FIND A WAY TO DETERMINE ASSOCIATION OF RESISTANCE UNITS if (_issoldier) then { switch (side _npc) do { case west: { _friends=_friends+KRON_AllWest; _enemies=_enemies+KRON_AllEast+KRON_AllRes; _sharedenemy=0; }; case east: { _friends=_friends+KRON_AllEast; _enemies=_enemies+KRON_AllWest+KRON_AllRes; _sharedenemy=1; }; case resistance: { _enemies=_enemies+KRON_AllEast+KRON_AllWest; _sharedenemy=2; }; }; {_friends=_friends-[_x]} forEach _members; }; sleep .01; // global unit variable to externally influence script _named = false; _npcname = str(side _npc); if ("NAMED" in _UCthis) then { _named = true; _npcname = format["%1",_npc]; _grpidx = _npcname; }; // create global variable for this group call compile format ["KRON_UPS_%1=1",_npcname]; // X/Y range of target area _areasize = getMarkerSize _areamarker; _rangeX = _areasize select 0; _rangeY = _areasize select 1; // marker orientation (needed as negative value!) _areadir = (markerDir _areamarker) * -1; sleep .01; // store some trig calculations _cosdir=cos(_areadir); _sindir=sin(_areadir); // minimum distance of new target position _mindist=(_rangeX^2+_rangeY^2)/4; if (_rangeX==0) exitWith { hint format["UPS: Cannot patrol Sector: %1\nArea Marker doesn't exist",_areamarker]; }; //hint format["%1,%2,%3,%4",_areamarker,isNil ("_areamarker"),_rangeX,_rangeY]; // remember the original mode & speed _orgMode = behaviour _npc; _orgSpeed = speedmode _npc; // set first target to current position (so we'll generate a new one right away) _currPos = getpos _npc; _orgPos = _currPos; _orgWatch=[_currPos,50,getDir _npc] call KRON_relPos; _orgDir = getDir _npc; _avoidPos = [0,0]; _flankPos = [0,0]; _attackPos = [0,0]; _dist = 0; _lastdist = 0; _lastmove1 = 0; _lastmove2 = 0; _maxmove=0; _moved=0; _damm=0; _dammchg=0; _lastdamm = 0; _timeontarget = 0; _fightmode = "walk"; _fm=0; _gothit = false; _hitPos=[0,0,0]; _react = 99; _lastdamage = 0; _lastknown = 0; _opfknowval = 0; _sin90=1; _cos90=0; _sin270=-1; _cos270=0; // set target tolerance high for choppers & planes _closeenough=_closeenough*_closeenough; if (_isplane) then {_closeenough=5000}; sleep .01; // ***************************************** optional arguments ***************************************** // wait at patrol end points _pause = if ("NOWAIT" in _UCthis) then {"NOWAIT"} else {"WAIT"}; // don't move until an enemy is spotted _nomove = if ("NOMOVE" in _UCthis) then {"NOMOVE"} else {"MOVE"}; // don't follow outside of marker area _nofollow = if ("NOFOLLOW" in _UCthis) then {"NOFOLLOW"} else {"FOLLOW"}; // share enemy info _shareinfo = if ("NOSHARE" in _UCthis) then {"NOSHARE"} else {"SHARE"}; // "area cleared" trigger activator _areatrigger = if ("TRIGGER" in _UCthis) then {"TRIGGER"} else {if ("NOTRIGGER" in _UCthis) then {"NOTRIGGER"} else {"SILENTTRIGGER"}}; // suppress fight behaviour if ("NOAI" in _UCthis) then {_issoldier=false}; // adjust cycle delay _cycle = ["CYCLE:",5,_UCthis] call KRON_UPSgetArg; // drop units at random positions _initpos = "ORIGINAL"; if ("RANDOM" in _UCthis) then {_initpos = "RANDOM"}; if ("RANDOMUP" in _UCthis) then {_initpos = "RANDOMUP"}; if ("RANDOMDN" in _UCthis) then {_initpos = "RANDOMDN"}; // don't position groups or vehicles on rooftops if ((_initpos!="ORIGINAL") && ((!_isman) || (count _members)>1)) then {_initpos="RANDOMDN"}; // set behaviour modes (or not) _noslow = if ("NOSLOW" in _UCthis) then {"NOSLOW"} else {"SLOW"}; if (_noslow!="NOSLOW") then { _npc setbehaviour "safe"; _orgMode = "safe"; _npc setspeedmode "limited"; _orgSpeed = "limited"; }; // make start position random if (_initpos!="ORIGINAL") then { // find a random position (try a max of 20 positions) _try=0; _bld=0; _bldpos=0; while {_try<20} do { _currPos=[_centerX,_centerY,_rangeX,_rangeY,_cosdir,_sindir,_areadir] call KRON_randomPos; _posinfo=[_currPos] call KRON_PosInfo; // _posinfo: [0,0]=no house near, [obj,-1]=house near, but no roof positions, [obj,pos]=house near, with roof pos _bld=_posinfo select 0; _bldpos=_posinfo select 1; if (_isplane || _isboat || !(surfaceiswater _currPos)) then { if (((_initpos=="RANDOM") || (_initpos=="RANDOMUP")) && (_bldpos>0)) then {_try=99}; if (((_initpos=="RANDOM") || (_initpos=="RANDOMDN")) && (_bldpos==0)) then {_try=99}; }; _try=_try+1; }; if (_bldpos==0) then { if (_isman) then { {_x setpos _currPos} foreach units _npc; } else { _npc setpos _currPos; }; } else { // put the unit on top of a building _npc setPos (_bld buildingPos _bldpos-1); _currPos = getPos _npc; _exit=true; // don't move if on roof }; }; sleep .01; // track unit _track = if (("TRACK" in _UCthis) || (KRON_UPS_Debug>0)) then {"TRACK"} else {"NOTRACK"}; _trackername = ""; _destname = ""; if (_track=="TRACK") then { _track = "TRACK"; _trackername=format["trk_%1",_grpidx]; _markerobj = createMarker[_trackername,[0,0]]; _markerobj setMarkerShape "ICON"; _markertype = if (isClass(configFile >> "cfgMarkers" >> "WTF_Dot")) then {"WTF_DOT"} else {"DOT"}; _trackername setMarkerType _markertype; _markercolor = switch (side _npc) do { case west: {"ColorGreen"}; case east: {"ColorRed"}; case resistance: {"ColorBlue"}; default {"ColorBlack"}; }; _trackername setMarkerColor _markercolor; _trackername setMarkerText format["%1",_grpidx]; _trackername setmarkerpos _currPos; _destname=format["dest_%1",_grpidx]; _markerobj = createMarker[_destname,[0,0]]; _markerobj setMarkerShape "ICON"; _markertype = if (isClass(configFile >> "cfgMarkers" >> "WTF_Flag")) then {"WTF_FLAG"} else {"FLAG"}; _destname setMarkerType _markertype; _destname setMarkerColor _markercolor; _destname setMarkerText format["%1",_grpidx]; _destname setMarkerSize [.5,.5]; }; sleep .01; // delete dead units _deletedead = ["DELETE:",0,_UCthis] call KRON_UPSgetArg; if (_deletedead>0) then { {_x addEventHandler['killed',format["[_this select 0,%1] spawn KRON_deleteDead",_deletedead]]}forEach _members; }; // how many group clones? // TBD: add to global side arrays? _mincopies = ["MIN:",0,_UCthis] call KRON_UPSgetArg; _maxcopies = ["MAX:",0,_UCthis] call KRON_UPSgetArg; if (_mincopies>_maxcopies) then {_maxcopies=_mincopies}; if (_maxcopies>140) exitWith {hint "Cannot create more than 140 groups!"}; if (_maxcopies>0) then { _copies=_mincopies+random (_maxcopies-_mincopies); // any init strings? _initstr = ["INIT:","",_UCthis] call KRON_UPSgetArg; // create the clones for "_grpcnt" from 1 to _copies do { // copy groups if (isNil ("KRON_grpindex")) then {KRON_grpindex = 0}; KRON_grpindex = KRON_grpindex+1; // copy group leader _unittype=typeof _npc; // make the clones civilians // use random Civilian models for single unit groups if ((_unittype=="Civilian") && (count _members==1)) then {_rnd=1+round(random 20); if (_rnd>1) then {_unittype=format["Civilian%1",_rnd]}}; _grp=createGroup side _npc; _lead = _grp createUnit [_unittype, getpos _npc, [], 0, "form"]; _lead setVehicleVarName format["l%1",KRON_grpindex]; call compile format["l%1=_lead",KRON_grpindex]; _lead setBehaviour _orgMode; _lead setSpeedmode _orgSpeed; _lead setSkill skill _npc; _lead setVehicleInit _initstr; [_lead] join _grp; _grp selectLeader _lead; // copy team members (skip the leader) _c=0; { _c=_c+1; if (_c>1) then { _newunit = _grp createUnit [typeof _x, getpos _x, [],0,"form"]; _newunit setBehaviour _orgMode; _newunit setSpeedMode _orgSpeed; _newunit setSkill skill _x; _newunit setVehicleInit _initstr; [_newunit] join _grp; }; } foreach _members; _nul=[_lead,_areamarker,_pause,_noslow,_nomove,_nofollow,_initpos,_track,_showmarker,_shareinfo,"DELETE:",_deletedead] execVM "ups.sqf"; sleep .05; }; processInitCommands; }; sleep .01; // units that can be left for area to be "cleared" _zoneempty = ["EMPTY:",0,_UCthis] call KRON_UPSgetArg; // create area trigger if (_areatrigger!="NOTRIGGER") then { _trgside = switch (side _npc) do { case west: {"WEST"}; case east: {"EAST"}; case resistance: {"GUER"}; case civilian: {"CIV"};}; _trgname="KRON_Trig_"+_trgside+"_"+_areamarker; _flgname="KRON_Cleared_"+_areamarker; // has the trigger been created already? KRON_TRGFlag=-1; call compile format["%1=false",_flgname]; call compile format["KRON_TRGFlag=%1",_trgname]; if (isNil ("KRON_TRGFlag")) then { // trigger doesn't exist yet, so create one (make it a bit bigger than the marker, to catch path finding 'excursions' and flanking moves) call compile format["%1=createTrigger['EmptyDetector',_centerpos]",_trgname]; call compile format["%1 setTriggerArea[_rangeX*1.5,_rangeY*1.5,markerDir _areamarker,true]",_trgname]; call compile format["%1 setTriggerActivation[_trgside,'PRESENT',true]",_trgname]; call compile format["%1 setEffectCondition 'true'",_trgname]; call compile format["%1 setTriggerTimeout [5,7,10,true]",_trgname]; if (_areatrigger!="SILENTTRIGGER") then { call compile format["%1 setTriggerStatements['count thislist<=%6', 'titletext [''SECTOR <%2> CLEARED'',''PLAIN''];''%2'' setmarkerpos [-%4,-%5];%3=true;', 'titletext [''SECTOR <%2> HAS BEEN RE-OCCUPIED'',''PLAIN''];''%2'' setmarkerpos [%4,%5];%3=false;']", _trgname,_areamarker,_flgname,_centerX,_centerY,_zoneempty]; } else { call compile format["%1 setTriggerStatements['count thislist<=%3', '%2=true;', '%2=false;']", _trgname,_flgname,_zoneempty]; }; }; sleep .01; }; // init done _makenewtarget=true; _newpos=false; _targetPos = _currPos; _swimming = false; _waiting = if (_nomove=="NOMOVE") then {9999} else {0}; // exit if something went wrong during initialization (or if unit is on roof) if (_exit) exitWith { if (KRON_UPS_DEBUG>0) then {hint "Initialization aborted"}; }; // *********************************************************************************************************** // ************************************************ MAIN LOOP ************************************************ _loop=true; _currcycle=_cycle; while {_loop} do { sleep .01; _timeontarget=_timeontarget+_currcycle; _react=_react+_currcycle; //echo format["[K] time on target: %1",_timeontarget]; // did anybody in the group got hit? _newdamage=0; { if((damage _x)>0.2) then { _newdamage=_newdamage+(damage _x); // damage has increased since last round if (_newdamage>_lastdamage) then { _lastdamage=_newdamage; _gothit=true; }; _hitPos=getpos _x; if (!alive _x) then { _members=_members-[_x]; _friends=_friends-[_x]; KRON_AllTroops=KRON_AllTroops-[_x]; }; }; } foreach _members; sleep .01; // nobody left alive, exit routine if (count _members==0) then { _exit=true; } else { // did the leader die? if (!alive _npc) then { _npc = _members select 0; group _npc selectLeader _npc; if (isPlayer _npc) then {_exit=true}; }; }; // current position _currPos = getpos _npc; _currX = _currPos select 0; _currY = _currPos select 1; if (_track=="TRACK") then { _trackername setmarkerpos _currPos; }; // if the AI is a civilian we don't have to bother checking for enemy encounters if ((_issoldier) && ((count _enemies)>0) && !(_exit)) then { // if the leader comes across another unit that's either injured or dead, go into combat mode as well. // If the other person is still alive, share enemy information. if ((_shareinfo=="SHARE") && (behaviour _npc=="SAFE")) then { _others=_friends-_members; { if (!(isNull _x) && (_npc distance _x<_sharedist) && (damage _x>.5)) exitWith { _npc setbehaviour "combat"; _gothit=true; if ((_hitPos select 0)==0) then {_hitPos = getPos _x}; if (_npc knowsabout _x>3) then { if (alive _x) then {_npc reveal (KRON_KnownEnemy select _sharedenemy)}; }; }; } forEach _others; }; sleep .01; // did the group spot an enemy? _lastknown=_opfknowval; _opfknowval=0; _maxknowledge=0; { _knows=_npc knowsabout _x; if (KRON_UPS_Debug>10) then {player sidechat format["%1: %2",_grpidx,_knows]}; if ((alive _x) && (_knows>0.2) && (_knows>_maxknowledge)) then { KRON_KnownEnemy set [_sharedenemy,_x]; _opfknowval=_opfknowval+_knows; _maxknowledge=_knows; if (KRON_UPS_Debug>0) then {player sidechat format["%1: %2",_grpidx,KRON_KnownEnemy]}; }; if (!alive _x) then {_enemies=_enemies-[_x]}; if (_maxknowledge==4) exitWith {}; } forEach _enemies; sleep .01; _pursue=false; _accuracy=100; // opfor spotted an enemy or got shot, so start pursuit if (_opfknowval>_lastknown || _gothit) then { _npc setbehaviour "combat"; _pursue=true; // make the exactness of the target dependent on the knowledge about the shooter _accuracy=21-(_maxknowledge*5); }; if (isNull (KRON_KnownEnemy select _sharedenemy)) then { _pursue=false; }; // don't react to new fatalities if less than 60 seconds have passed since the last one if ((_react<60) && (_fightmode!="walk")) then {_pursue=false}; if (_pursue) then { // get position of spotted unit in player group, and watch that spot _offsx=_accuracy/2-random _accuracy; _offsY=_accuracy/2-random _accuracy; _targetPos = getpos (KRON_KnownEnemy select _sharedenemy); _targetPos = [(_targetPos select 0) + _offsX, (_targetPos select 1) + _offsY]; _targetX = _targetPos select 0; _targetY = _targetPos select 1; {_x dowatch _targetPos} foreach units _npc; sleep .01; // also go into "combat mode" _npc setspeedmode "full"; _speedmode = "full"; _npc setbehaviour "combat"; _pause="NOWAIT"; _waiting=0; // angle from unit to target _dir1 = [_currPos,_targetPos] call KRON_getDirPos; // angle from target to unit (reverse direction) _dir2 = (_dir1+180) mod 360; // angle from fatality to target _dir3 = if (_hitPos select 0!=0) then {[_hitPos,_targetPos] call KRON_getDirPos} else {_dir1}; _dd=(_dir1-_dir3); // unit position offset straight towards target _relUX = sin(_dir1)*_safedist; _relUY = cos(_dir1)*_safedist; // target position offset straight towards unit _relTX = sin(_dir2)*_safedist; _relTY = cos(_dir2)*_safedist; // go either left or right (depending on location of fatality - or randomly if no fatality) _sinU=_sin90; _cosU=_cos90; _sinT=_sin270; _cosT=_cos270; if ((_dd<0) || (_dd==0 && (random 1)>.5)) then {_sinU=_sin270; _cosU=_cos270; _sinT=_sin90; _cosT=_cos90}; // avoidance position (right or left of unit) _avoidX = _currX + _cosU*_relUX - _sinU*_relUY; _avoidY = _currY + _sinU*_relUX + _cosU*_relUY; _avoidPos = [_avoidX,_avoidY]; // flanking position (right or left of target) _flankX = _targetX + _cosT*_relTX - _sinT*_relTY; _flankY = _targetY + _sinT*_relTX + _cosT*_relTY; _flankPos = [_flankX,_flankY]; // final target position _attackPos = _targetPos; // for now we're stepping a bit to the side _targetPos = _avoidPos; if (_nofollow=="NOFOLLOW") then { _avoidPos = [_avoidPos,_centerpos,_rangeX,_rangeY,_areadir] call KRON_stayInside; _flankPos = [_flankPos,_centerpos,_rangeX,_rangeY,_areadir] call KRON_stayInside; _attackPos = [_attackPos,_centerpos,_rangeX,_rangeY,_areadir] call KRON_stayInside; _targetPos = [_targetPos,_centerpos,_rangeX,_rangeY,_areadir] call KRON_stayInside; }; _react=0; _fightmode="fight"; _timeontarget=0; _fm=1; if (KRON_UPS_Debug!=0) then { "dead" setmarkerpos _hitPos; "avoid" setmarkerpos _avoidPos; "flank" setmarkerpos _flankPos; "target" setmarkerpos _attackPos; }; _newpos=true; // speed up the cycle duration after an incident if (_currcycle>=_cycle) then {_currcycle=1}; }; }; sleep .01; if !(_newpos) then { // calculate new distance // if we're waiting at a waypoint, no calculating necessary if (_waiting<=0) then { // distance to target _dist = [_currPos,_targetPos] call KRON_distancePosSqr; if (_lastdist==0) then {_lastdist=_dist}; _moved = abs(_dist-_lastdist); // adjust the target tolerance for fast moving vehicles if (_moved>_maxmove) then {_maxmove=_moved; if ((_maxmove/40) > _closeenough) then {_closeenough=_maxmove/40}}; // how much did we move in the last three cycles? _totmove=_moved+_lastmove1+_lastmove2; _damm = damage _npc; // is our damage changing (increasing)? _dammchg = abs(_damm - _lastdamm); // we're either close enough, seem to be stuck, or are getting damaged, so find a new target if ((!_swimming) && ((_dist<=_closeenough) || (_totmove<.2) || (_dammchg>0.01) || (_timeontarget>_alerttime))) then {_makenewtarget=true;}; // in 'attack (approach) mode', so follow the flanking path (don't make it too predictable though) if ((_fightmode!="walk") && (_dist<=_closeenough)) then { if ((random 1)<.95) then { if (_flankPos select 0!=0) then { _targetPos=_flankPos; _flankPos=[0,0]; _makenewtarget=false; _newpos=true; _fm=1; } else { if (_attackPos select 0!=0) then { _targetPos=_attackPos; _attackPos=[0,0]; _makenewtarget=false; _newpos=true; _fm=2; }; }; }; }; sleep .01; // make new target if (_makenewtarget) then { if ((_nomove=="NOMOVE") && (_timeontarget>_alerttime)) then { if (([_currPos,_orgPos] call KRON_distancePosSqr)<_closeenough) then { _newpos = false; } else { _targetPos=_orgPos; }; } else { // re-read marker position/size _centerpos = getMarkerPos _areamarker; _centerX = abs(_centerpos select 0); _centerY = abs(_centerpos select 1); _areasize = getMarkerSize _areamarker; _rangeX = _areasize select 0; _rangeY = _areasize select 1; _areadir = (markerDir _areamarker) * -1; // find a new target that's not too close to the current position _targetPos=_currPos; _tries=0; while {((([_currPos,_targetPos] call KRON_distancePosSqr) < _mindist)) && (_tries<20)} do { _tries=_tries+1; // generate new target position (on the road) _road=0; while {_road<20} do { _targetPos=[_centerX,_centerY,_rangeX,_rangeY,_cosdir,_sindir,_areadir] call KRON_randomPos; _road=[_targetPos,(_isplane||_isboat),_road] call KRON_OnRoad; sleep .01; }; }; }; _avoidPos = [0,0]; _flankPos = [0,0]; _attackPos = [0,0]; _gothit=false; _hitPos=[0,0,0]; _fm=0; _npc setspeedmode _orgSpeed; _speedmode = _orgSpeed; _newpos=true; // if we're waiting at patrol end points then don't create a new target right away. Keep cycling though to check for enemy encounters if ((_pause!="NOWAIT") && (_waiting<0)) then {_waiting = (15 + random 20)}; }; }; }; sleep .01; // if in water, get right back out of it again if (surfaceIsWater _currPos) then { if (_isman && !_swimming) then { _drydist=999; // look around, to find a dry spot for [{_a=0}, {_a<=270}, {_a=_a+90}] do { _dp=[_currPos,30,_a] call KRON_relPos; if !(surfaceIsWater _dp) then {_targetPos=_dp}; }; _newpos=true; _swimming=true; }; } else { _swimming=false; }; _waiting = _waiting - _currcycle; if ((_waiting<=0) && _newpos) then { // tell unit about new target position //{_x doMove _targetPos}forEach _member; _npc move _targetPos; _npc setSpeedMode _speedmode; if (_fightmode!="walk") then { if (_timeontarget>_alerttime) then { _fightmode="walk"; _npc setBehaviour _orgMode; }; }; if (_track=="TRACK") then { switch (_fm) do { case 1: {_destname setmarkerSize [.4,.4]}; case 2: {_destname setmarkerSize [.6,.6]}; default {_destname setmarkerSize [.5,.5]}; }; _destname setMarkerPos _targetPos; }; _dist=0; _moved=0; _lastmove1=10; _waiting=-1; _newpos=false; _swimming=false; }; // move on _lastdist = _dist; _lastmove2 = _lastmove1; _lastmove1 = _moved; _lastdamm = _damm; // check external loop switch _cont = (call compile format ["KRON_UPS_%1",_npcname]); if (_cont==0) then {_exit=true}; _makenewtarget=false; if ((_exit) || (isNil("_npc"))) then { _loop=false; } else { // slowly increase the cycle duration after an incident if (_currcycle<_cycle) then {_currcycle=_currcycle+.5}; sleep _currcycle; }; }; if !(isNil("_npc")) then { {doStop _x; _x domove getPos _x; _x move getPos _x} forEach _members; }; KRON_UPS_Exited=KRON_UPS_Exited+1; if (_track=="TRACK") then { _trackername setMarkerType "Dot"; _destname setMarkerType "Empty"; }; _friends=nil; _enemies=nil; K3