Question
I know how to create a local marker, at a
given _pos. But I do not know how to define
_pos. This is what I need...
.sqs format only.
(1) check if (_Heli distance _Obj1) > 3000
(2) if true, create a local marker 2,500m from the current pos of _Heli towards _Obj1
(3) _pos = getmarkerpos (local marker)
(4) #SrtLoop _Heli domove _pos; (_Heli distance (local marker) < 200)
(5) if true, delete local marker and perform steps (1) through (4)
To create a localmarker here is the code...
deleteMarkerLocal "Wpt";
createMarkerLocal ["Wpt",_pos];
"Wpt" setMarkerShapeLocal "ICON";
"Wpt" setMarkerColorLocal "ColorGreen";
"Wpt" setMarkerTypeLocal "DOT";
"Wpt" setMarkerSizeLocal[0.5,0.5];
"Wpt" setMarkerTextLocal "Wpt";
Program execution will not exit #StepLoop until _Heli distance _Obj1 < 3000
Code fragment of E1EvacRTB.sqs
;Execute StepLoop until distance to _Obj1 < 3000
#StepLoop
;Need code here to cause _Heli to fly towards _Obj1
;until condition is met, at which time the rest of
;the script will take charge to ensure _Heli lands
;at base.
;Error checking routine has already been added along
;with exit-loop conditions.
? ((!(_Pilot in _Heli))||(!(alive _Heli))||(!(alive _Pilot))||(!(canmove _Heli))): goto "Cont";
Hint Format["Dist > %1 ETA %2",_CDist,(_Heli distance _Obj1)];
? ((_Heli distance _Obj1) < 3000): goto "Restart1";
goto "StepLoop";
E1EvacRTB.sqs
Private ["_Unit","_Heli","_Pilot","_Mkr1","_Mkr2","_Obj1","_Obj2","_CFlyIn","_CSpeed","_CDist"];
_Unit = _this select 1;
_Heli = _this select 0;
_Pilot= driver _Heli;
;"E1LZMkr"
_Mkr1 = (_this select 3) select 0;
;"E1EvacRTB"
_Mkr2 = (_this select 3) select 1;
;E1LZ
_Obj1 = (_this select 3) select 2;
;E1AirLnd
_Obj2 = (_this select 3) select 3;
_CFlyIn = 150;
_CSpeed = "NORMAL";
_CDist = 2000;
_CDistFlg = 0;
titleText[">>> Order confirmed! Chopper RTB! <<<", "PLAIN DOWN"];
#RestartErr2
_Mkr1 setmarkerpos getmarkerpos _Mkr2;
_Obj1 setdir getdir _Obj2;
_Obj1 setpos getmarkerpos _Mkr1;
~2
;Skip StepLoop if destination between _Heli and _Obj1 < 3000 initially
? ((_Heli distance _Obj1)<3000): goto "Restart1";
;Execute StepLoop until distance to _Obj1 < 3000
#StepLoop
;Need code here to cause _Heli to fly towards _Obj1
;until condition is met, at which time the rest of
;the script will take charge to ensure _Heli lands
;at base.
;Error checking routine has already been added along
;with exit-loop conditions.
? ((!(_Pilot in _Heli))||(!(alive _Heli))||(!(alive _Pilot))||(!(canmove _Heli))): goto "Cont";
Hint Format["Dist > %1 ETA %2",_CDist,(_Heli distance _Obj1)];
? ((_Heli distance _Obj1) < 3000): goto "Restart1";
goto "StepLoop";
#Restart1
_Heli flyinheight _CFlyIn;
_Pilot setspeedmode _CSpeed;
? (_CDistFlg == 0): _Heli doMove (position _Obj1);
? (_CDistFlg == 1): _Heli Land "Get Out";
? (_CDistFlg == 2): _Heli Land "LAND";
? ((!(_Pilot in _Heli))||(!(alive _Heli))||(!(alive _Pilot))||(!(canmove _Heli))): goto "Cont";
Hint Format["Dist > %1 ETA %2",_CDist,(_Heli distance _Obj1)];
? ((_Heli distance _Obj1) > _CDist): goto "Restart1";
? (_CDist == 2000): goto "CDistRtn1";
? (_CDist == 1000): goto "CDistRtn2";
? (_CDist == 600): goto "CDistRtn3";
? (_CDist == 300): goto "CDistRtn4";
? (_CDist == 150): goto "CDistRtn5";
? (_CDist == 25): goto "CDistRtn6";
_Pilot action ["EngineOff",(vehicle _Pilot)];
Hint "Landed!";
goto "ContEnd";
#Cont
? ((!(alive _Heli))||(!(alive _Pilot))): goto "ContErr1";
? (((alive _Pilot)&&(_Pilot in _Heli))&&(!(canmove _Heli))): goto "ContErr2";
? ((!(alive _Pilot))&&(canmove _Heli)||(!(canmove _Heli))): goto "ContErr3";
? (!(_Pilot in _Heli)): goto "ContErr4";
goto "ContEnd";
#ContErr1
Hint "RTB Failure: Chopper and crew destroyed!";
goto "ContEnd";
#ContErr2
_Heli setdammage 0;
_Heli setfuel 1;
Hint "RTB Warning: Making repairs and attempting to continue mission!";
goto "RestartErr2";
#ContErr3
Hint "RTB Failure: Pilot Killed! Destroying chopper (10 Secs)!";
~10
_Heli Setdammage 1;
goto "ContEnd";
#ContErr4
Hint "MAYDAY!!! MAYDAY!!! Going Down! I'm bailing and need rescue!";
goto "ContEnd";
#CDistRtn1
_CDist = 2000;
_CFlyIn = 150;
_CSpeed = "NORMAL";
goto "Restart1";
#CDistRtn2
_CDist = 1000;
_CFlyIn = 105;
_CSpeed = "LIMITED";
goto "Restart1";
#CDistRtn3
_CDist = 600;
_CFlyIn = 90;
_CSpeed = "LIMITED";
goto "Restart1";
#CDistRtn4
_CDist = 300;
_CFlyIn = 70;
_CSpeed = "LIMITED";
goto "Restart1";
#CDistRtn5
_CDist = 150;
;_CFlyIn = 25;
_CSpeed = "LIMITED";
_CDistFlg = 1;
goto "Restart1";
#CDistRtn6
_CDist = 25;
_CFlyIn = 15;
_CSpeed = "LIMITED";
_CDistFlg = 0;
goto "Restart1";
#CDistRtn7
_CDist = 15;
;_CFlyIn = 15;
_CSpeed = "LIMITED";
_CDistFlg = 2;
goto "Restart1";
#ContEnd
exit