Forum Jump :

Author Message


Posts: 26
Rank:


Level: Member

Country: us
Location: Dallas, Tx
Occupation:
Age: 46
In-game name:

 
#1 Posted at 2012-03-28 20:06        
     

The below problem has been solved using a few lines of
code I found in Mando's Heliroute script.


CREDITS
Thanks Mando, you may not have been aware but even code
that you use for your projects may be used elsewhere
to fix other's problems, such as mine, who are not as
elite in scripting. Thanks again for the fix.

RESOLUTION
#StepAgain
? ((_Heli distance _Obj1)<3000): goto "Restart1";

_endpos = getpos _Obj1;
_inipos = getpos _Heli;
_dist   = (_Heli distance _Obj1);
_ang    = ((_endpos select 0) - (_inipos select 0)) atan2 ((_endpos select 1) - (_inipos select 1));

_pos    = [(_inipos select 0) + sin(_ang)*2000,(_inipos select 1) + cos(_ang)*2000];

~1

deleteMarkerLocal "Wpt";
createMarkerLocal ["Wpt",_pos]; 
"Wpt" setMarkerShapeLocal "ICON"; 
"Wpt" setMarkerColorLocal "ColorGreen";
"Wpt" setMarkerTypeLocal "DOT";
"Wpt" setMarkerSizeLocal[0.5,0.5];
"Wpt" setMarkerTextLocal "Wpt";

_StepFlg = 0;
#StepLoop
  ? (_StepFlg==0): _Heli domove _pos;
  _StepFlg = 1;
  
  ? ((!(_Pilot in _Heli))||(!(alive _Heli))||(!(alive _Pilot))||(!(canmove _Heli))): goto "Cont";
  Hint Format["Dist > %1 ETA WPT %2",_CDist,(_Heli distance _pos)];
  ? ((_Heli distance _pos) < 600): goto "StepAgain";
goto "StepLoop";

#Restart1
deleteMarkerLocal "Wpt";

This is the code I used from Mando to fix my
script, so I credit Mandoble for this fix.


_endpos = getpos _Obj1;
_inipos = getpos _Heli;
_dist   = (_Heli distance _Obj1);
_ang    = ((_endpos select 0) - (_inipos select 0)) atan2 ((_endpos select 1) - (_inipos select 1));

_pos    = [(_inipos select 0) + sin(_ang)*2000,(_inipos select 1) + cos(_ang)*2000];

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


This post was edited by harold5187 (2012-03-31 17:39, ago)

As many of us do, I as well, come from a Flashpoint, Resistance and Arma background. I was a member of the original DSF clan for about two months, back when Hatcher was in charge, along with Deaddog, Joker, Thatcher, two german dudes, and my callsign was, and still is FullMetal.

Author Message


Posts: 134
Rank:


Level: Member

Country: us
Location: Censored by Chuck Norris
Occupation: Why do you want to know? Stalker.....
Age: 115
In-game name: FuNKo1

 
#2 Posted at 2012-03-29 15:02        
     
so you do not know how to define the position? I'm a little confused, but you could place a gamelogic on the place where you want _pos to be, then define _pos using _pos = getpos NAME OF GAMELOGIC

I Can't Think of a Creative Signature Right Now...

Advertisement


Author Message


Posts: 26
Rank:


Level: Member

Country: us
Location: Dallas, Tx
Occupation:
Age: 46
In-game name:

 
#3 Posted at 2012-03-29 16:18        
     
Thankyou for taking the time to reply... I know how to define _pos, but I do not know
the math behind what I'm trying to do...

If my helicopter is 2000m away from "respawn_east", I can say
 _Heli domove getpos _Obj1;

...but if my helicopter is 5,325m away from "respawn_east", then I need to
break (_Heli distance _Obj1) / 3000... ...break the journey up into
increments that the _Pilot will not freak out over.

I know how to create a marker, but I don't know how to place it say, 2,500m in front
of _Heli, in the direction I wish to fly, which is towards my helipad named _Obj1;

Anyway, that's the problem I'm having, Mando used the math in his Mando_Heliroute
script, but it's confusing for me to understand because his script allows for
multiple routes or waypoints, while my script will never exceed one waypoint.

Thanks again for the reply...

As many of us do, I as well, come from a Flashpoint, Resistance and Arma background. I was a member of the original DSF clan for about two months, back when Hatcher was in charge, along with Deaddog, Joker, Thatcher, two german dudes, and my callsign was, and still is FullMetal.