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-31 17:13        
     
This is the code fragment I'm using, incorporated with part
of Mando's Heliroute script.

This is in .sqf format!

    _Eendpos = getpos ETgt;
    _Einipos = getpos ERTTBase;
    _Edist   = (ERTTBase distance ETgt);
    _Eang    = ((_Eendpos select 0) - (_Einipos select 0)) atan2 ((_Eendpos select 1) - (_Einipos select 1));

    _Epos2   = [(_Einipos select 0) + sin(_Eang)*400,(_Einipos select 1) + cos(_Eang)*400];	      
   
    EElev setpos _Epos2;
   
    _EEleUPos= getpos EElev;
    _EEleux=_EEleUPos Select 0;
    _EEleuy=_EEleUPos Select 1;
    _EEleuz=_EEleUPos Select 2;

Question

Can anyone give me a detailed explaination of what these
two lines of code are doing, and how I can convert _Epos2
to an x,y,z format that I can work with?

    _Eang    = ((_Eendpos select 0) - (_Einipos select 0)) atan2 ((_Eendpos select 1) - (_Einipos select 1));
    _Epos2   = [(_Einipos select 0) + sin(_Eang)*400,(_Einipos select 1) + cos(_Eang)*400];	      

What I'm trying to do OVERALL

(1) Using addaction, I want to click up, and move EElev up one degree.
(2) ...or down, using the same method.
(3) Regarding LEFT, and RIGHT, I want to move ETgt, not EElev.
(4) After ETgt has been moved, I want to update _Eang and _Epos2
(5) Use the updated position of _Epos2 to reallign EElev
(6) I want to keep the updated x,y positions, but I want to keep the previous Z position intact.

Step (6) is another problem I've encountered, being able to use Mando's code
_Eang and _Epos2 calculations, while keeping the previous altitude
adjustments.

(7) The player is free to press LEFT, RIGHT, UP, or DOWN as often as desired.
(8) ...but EElev must not move outside the 400m radius of the D30.
(9) Moving EElev too far away will cause the gunner not to DoWatch.

Explaination of code

(1) ETgt is a bottle of class name "AAMI100" found in Editor-Objects.
(2) _Eendpos is local variable assigned the address of ETgt.
(3) ETgt is placed anywhere on the map through onmapsingleclick.
    _Eendpos = getpos ETgt;

(1) ERTTBase is a helipad of class name "HeliHEmpty".
(2) This is the only location where a D30 artillery unit may be created in game.
(3) I am assigning the address of ERTTBase to local variable _Einipos.
    _Einipos = getpos ERTTBase;

(1) Using onmapsingleclick, ETgt will be placed where I want a strike.
(2) _Edist stores the range between the D30 and the area I wish to strike.
    _Edist   = (ERTTBase distance ETgt);

(1) Analyzes _Einipos and _Eendpos
(2) Generates a position 400m from the D30 at an angle facing ETgt
(3) _Epos2 is a position of unknown format, not x,y,z.
(4) Somewhere an unwanted height is being incorporated here.
    _Eang    = ((_Eendpos select 0) - (_Einipos select 0)) atan2 ((_Eendpos select 1) - (_Einipos select 1));
    _Epos2   = [(_Einipos select 0) + sin(_Eang)*400,(_Einipos select 1) + cos(_Eang)*400];	      

(1) EElev is another bottle of class name "AAMI100".
(2) This object is placed 400m away from the D30, at position _Epos2.
(3) Using addactions, I can move this object UP,DOWN,LEFT, or RIGHT.
(4) At desired elevation I can use DoWatch to have D30 watch this object.
(5) When ready, I can also use DoFire, to force D30 to fire at object.
(6) If the elevation is correct, the projectile, will hit over 4500m at ETgt.
    EElev setpos _Epos2;

(1) After EElev has been placed at the calculated position _Epos2
(2) I retrieve the x,y,z, coordinates of EElev.
(3) I can't use _Epos2 as I would like, because I can't figure it's format.
    _EEleUPos= getpos EElev;
    _EEleux=_EEleUPos Select 0;
    _EEleuy=_EEleUPos Select 1;
    _EEleuz=_EEleUPos Select 2;

(1) After step (2) above, I use a statement such as below...
(2) Previously defined are a few publicvariables used here...

EElevVar, EElevXVar, EArtyInc, EArtyIncX

(3) By Default all of the above public's are set to a value of zero.
(4) Place EElev at the current pos, but add in the multipliers.
(5) These multipliers are used so I don't have to press UP, etc, 100 times.
    EElev setpos [_EEleux+(EElevXVar*EArtyIncX),_EEleuy,_EEleuz+(EElevVar*EArtyInc)];

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.