Quantcast

Jump to content

» «
Photo

Directional angle between 2 points (For Vice City)

5 replies to this topic
Jack
  • Jack

    Firearms and Adrenaline

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#1

Posted 30 November 2013 - 02:14 PM

I'll let this picture to tell what exactly I need:
pkdnnyp1009adawfg.jpg
So I need the angle between the north line and AB line. As most of you already know there're no opcode for the invert function of tangens in Vice City.
I've only found this one:
It doesn't calculate arctg but arccos instead.
 
Why do I need this directional angle:
I want to force any moving helicopter to look directly at players car all the time no matter which coordinates it has. I've tried a simple method:
-----------------------------------------------------------------------------
04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 0.0 200.0 30.0 
00A5: create_car #HUNTER at [email protected] [email protected] [email protected] store_to [email protected]
009A: create_char 4 model #ARMY at 0.0 0.0 0.0 store_to [email protected]
0464: put_actor [email protected] into_turret_on_car [email protected] at_car_offset 0.0 0.0 0.0 position 0 angle 360.0 with_weapon 0
0337: set_actor [email protected] visibility 0 
-------------------------------------------------------------------------------------------------------
WHILE TRUE
    wait 0
    04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 0.0 -25.0 30.0 
    04A2: heli [email protected] fly_to [email protected] [email protected] [email protected] speed 100
    020F: actor [email protected] look_at_player $PLAYER_CHAR 
    0172: [email protected] = actor [email protected] z_angle 
    04D0: set_heli_orientation [email protected] to [email protected]
END
Well this do trick but only aproximately - I need a precise direction. 
I'm starting to think that heli speed or maybe a mass has something to do with this problem. 
Any suggestions? Thanks :)

DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]
    Helpfulness Award [Mods]

#2

Posted 30 November 2013 - 04:27 PM Edited by _DK, 30 November 2013 - 04:28 PM.

http://en.wikipedia.org/wiki/Atan2

//...

05F7: [email protected] = label @atan2 offset
05E1: call [email protected] num_params 2 pop 2 _x [email protected] _y [email protected]
05F2: [email protected] = pop_float // pop result to [email protected]

//...

// float atan2(float y, float x)
:atan2
hex
    D9 44 24 04 // fld [esp+4]
    D9 44 24 08 // fld [esp+8]
    D9 F3       // fpatan
    C3          // retn
end
  • ThirteenAG likes this

NTAuthority
  • NTAuthority

    hell, no, tunnel, no

  • Feroci
  • Joined: 09 Sep 2008
  • European-Union
  • Best Script or Plugin 2016 [SkyGfx] [Contribution]
    Best Conversion 2014 [ViIV for GTANY]
    Most Knowledgeable [Tech] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Contribution Award [Mods]

#3

Posted 30 November 2013 - 04:41 PM

oh yeah, let's use non-standard commands provided by a runtime with disputed stability and mix code with data


DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]
    Helpfulness Award [Mods]

#4

Posted 30 November 2013 - 06:58 PM

And let's play un-modded GTA games also.

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown
  • Contribution Award [Mods]

#5

Posted 30 November 2013 - 08:42 PM

If you want to deal with GET_ANGLE_BETWEEN_2D_VECTORS (05A4) command, you should be capable to distinguish a vector by a point. A vector simply describes the direction pointing to a point. The mentioned command needs 2 points rotating around a third point to behave like SA's GET_HEADING_FROM_VECTOR_2D (0604) command:
const
    POINT_A_X = 0.0
    POINT_A_Y = 0.0
    POINT_B_X = -1.0
    POINT_B_Y = 0.0
end
var
    [email protected]: Float
    [email protected]: Float
    [email protected]: Float
    [email protected]: Float
    [email protected]: Float
end
[email protected] = POINT_A_X
[email protected] = POINT_A_Y
[email protected] = POINT_B_X
[email protected] = POINT_B_Y
[email protected] -= [email protected]
[email protected] -= [email protected]
05A4: get_angle_between_2d_vectors [email protected] [email protected] and_origin_to 0.0 -1.0 store_to [email protected]
if
    [email protected] < 0.0
then
    [email protected] += -360.0
    [email protected] *= -1.0
end
  • Jack likes this

Jack
  • Jack

    Firearms and Adrenaline

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#6

Posted 01 December 2013 - 12:12 PM Edited by Jack..., 01 December 2013 - 12:24 PM.

@_DK I'm not really into that hardcoded things right now so I'll take Wessers method. But thanks for the help. I'll look into it latter.
@Wesser:
WHILE TRUE
wait 0
00AA: store_car [email protected] position_to [email protected] [email protected] 0.0                // A
0054: store_player $PLAYER_CHAR position_to [email protected] [email protected] 0.0 // B
 
// vector 1
0063: [email protected] -= [email protected] // Xb-Xa
0063: [email protected] -= [email protected] // Yb-Ya
00AA: store_car [email protected] position_to [email protected] [email protected] 0.0
02F7: cos [email protected] store_to [email protected]   // x
02F6: sin [email protected] store_to [email protected]   // y
0013: [email protected] *= 120.0   // Xn (X-north)
0013: [email protected] *= 120.0   // Yn (Y-north)
00AA: store_car [email protected] position_to [email protected] [email protected] 0.0
 
// vector 2
0063: [email protected] -= [email protected] // Xn-Xa
0063: [email protected] -= [email protected] // Yn-Ya
05A4: get_angle_between_2d_vectors [email protected] [email protected] and_origin_to [email protected] [email protected] store_to [email protected]   // Directional Angle
04D0: set_heli_orientation [email protected] to [email protected]
END
That did it. Thanks man :happy:.

 

The complexity simplifier, the efficiency optimizer.

Indeed :santa:.

  • Wesser likes this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users