Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (85,999 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

Sign in to follow this  
Jack

Directional angle between 2 points (For Vice City)

Recommended Posts

Jack
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 :).

Share this post


Link to post
Share on other sites
DK22Pac

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

 

 

//...05F7: [email protected] = label @atan2 offset05E1: call [email protected] num_params 2 pop 2 _x [email protected] _y [email protected]: [email protected] = pop_float // pop result to [email protected]//...// float atan2(float y, float x):atan2hex    D9 44 24 04 // fld [esp+4]    D9 44 24 08 // fld [esp+8]    D9 F3       // fpatan    C3          // retnend
Edited by _DK

Share this post


Link to post
Share on other sites
NTAuthority

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

Share this post


Link to post
Share on other sites
DK22Pac

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

Share this post


Link to post
Share on other sites
Wesser

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.0endvar    [email protected]: Float    [email protected]: Float    [email protected]: Float    [email protected]: Float    [email protected]: [email protected] = [email protected] = [email protected] = [email protected] = [email protected] -= [email protected]@ -= [email protected]: get_angle_between_2d_vectors [email protected] [email protected] and_origin_to 0.0 -1.0 store_to [email protected]    [email protected] < 0.0then    [email protected] += -360.0    [email protected] *= -1.0end

Share this post


Link to post
Share on other sites
Jack
@_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 TRUEwait 000AA: store_car [email protected] position_to [email protected] [email protected] 0.0                // A0054: store_player $PLAYER_CHAR position_to [email protected] [email protected] 0.0 // B // vector 10063: [email protected] -= [email protected] // Xb-Xa0063: [email protected] -= [email protected] // Yb-Ya00AA: store_car [email protected] position_to [email protected] [email protected] 0.002F7: cos [email protected] store_to [email protected]   // x02F6: sin [email protected] store_to [email protected]   // y0013: [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 20063: [email protected] -= [email protected] // Xn-Xa0063: [email protected] -= [email protected] // Yn-Ya05A4: get_angle_between_2d_vectors [email protected] [email protected] and_origin_to [email protected] [email protected] store_to [email protected]   // Directional Angle04D0: set_heli_orientation [email protected] to [email protected]
That did it. Thanks man :happy:.

 

The complexity simplifier, the efficiency optimizer.

Indeed :santa:.

Edited by Jack...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.