Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (85,239 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

Jack

[REL|SA|WIP|VC&III] Tank Fire

Recommended Posts

Jack

Hi! Since I like to modify wanted level system in III era because it's a significant part of the game I decided to make another mod. As you can see this mod is a 6th WL star related (the second military mod made by me) and it makes the tanks attack you with cannons. With this mod GTA will slightly remind you to some war game:

 

04.06.17 Tank Fire 1.4
- fixed game crash from the previous version,
- removed tank aiming when the soldier exits the tank.

 

20.02.17 Tank Fire 1.3
- fixed player's tank "frozen aiming",
- removed aiming ability for destroyed NPC tanks,
- SWAT Tank water cannon replaced with cannoballs
- mod changes available through Tank Fire.ini:

ENABLE_ONMISSION = 0                  ; [boolean]    seting this value to 1 will disable tank fire while the player is on the mission    - PLAYER_TANK_FIRE_RATE = 250    ; [4 bytes]     time in milisecinds:  250 ms = 1/4 seconds (0 means the fastest fire rate)               - NPC_TANK_FIRE_RATE = 1000           ; [4 bytes]     time in milisecinds: 1000 ms = 1 second (0 means the fastest fire rate)                                                                         - CANNONBALL_SPEED = 220.0          ; [float]                       - CANNONBALL_SMOKE_R = 1.0        ; [float]          Cannonball some colour Red [values from 0.0 to 1.0]                      - CANNONBALL_SMOKE_G = 1.0        ; [float]        Cannonball some colour Green [values from 0.0 to 1.0]              - CANNONBALL_SMOKE_B = 1.0        ; [float]        Cannonball some colour Blue [values from 0.0 to 1.0]

***********************
TANK FIRE VERSION 1.21
***********************
- there's no need to use $INCLUDE directive any more so remove everything from the previous version and just use this single $CLEO code,
- drasticly increased the distance shot of the tank fire (200.0) so now you can hit every vehicle (even Hydra),
- decreased interval between shots,
- tank pushing power has been removed,
- tank "doom" aiming is completely controlable by mouse movement - there's no delay in moving,
- it's possible to destroy other tanks so it looks like a tank battle game,
- the players tank has a rapid fire and it can be activated by "press and hold" the right mouse button,
- at STAR7 the players tank can be destroyed by other tanks (not tested),
- the code shoud work for multiple game versions (not tested).

 

 



Mod features:
- other tanks are now vulnurable to explosions of any type so you can easily destroy them in combat (handling.cfg file was not modified),
- tanks are pretty precise when they hit a standing or slow motion targets,
- vertical direction of a cannon projectile trajectory is also defined so the tanks are able to hit you while you're flying a helicopter at low heights for exmpl,
- if you drive really fast the cannon projectiles will most likely miss you,
- appart from m4 assault riffles soldiers from tanks will carry thermal googles and bombs (they'll not actually use those extra gear but they'll drop it after death).
- if you're on foot you can surrender yourself by clicking LCTRL and S at the same time.

Credits:

- DK22Pac [special thanks]
- Silent
- Wesser


I didn't actually have the honor to work together on this mod with any of these guys (except Wesser for VC&III) but I used some of their methods to buid up this code:

- to take handle of multiple vehicles and peds I used DK22Pac's $INCLUDE method:
http://gtaforums.com/topic/503390-useful-using-of-include/

- for calculation of a directional angle between 2 points I used method from here:
http://gtaforums.com/topic/413458-ive-questions-about-cleo/page-3

- for calculating a vertical trajectory of a cannon projectile I used Tayler series for arcus sinus approximation:


vertical_vector.jpg



Tayler1
Tayler2

Source code v1.1

DOWNLOAD v1.0&v1.1
How to install:
You need CLEO and DK22Pac's files

After you install CLEO (if not already installed) extract DK22Pac's files and my files into the CLEO folder of GTA SA directory.

Also it's always a good thing to have some sort of error recoverer - you can download Link2012's SCRLog.

The Tank Fire code has been tested and it appears it works fine.
However if you do experience problems with this mod send me the SCRLog crash report.

 

EDIT:

********************************
TANK FIRE VERSION 1.1
********************************

Code update:
- inputed safety conditional checks in order to prevent the rare game crash,

- removed the player's tank vulnerability to explosions [NPC tanks can still be destroyed by any type of explosion],

- added the ability to faster rotate the player's tank gun [like in V],
- decreased the push power of the players tank while fireing a cannon projectile,
- drasticly increased cannon projectile speed for NPC tanks (I'm still not sure which speed I should set- future code versions will be diferent),

- tested for 1.0 game version.

Future plans [WIP]:

SA:

- Adding the city alarm siren for danger to make things even more dramatic,

- I'm thinking to put all this into the star 7 (6-7 replace).

 

Download link is updated.

Edited by Jack

Share this post


Link to post
Share on other sites
goodidea82

Cool stuff with the Taylor approximation. In my golf mod I also had to compute the angle from a vector and used a quadratic function as an approximation and it was suprisingly accurate. Later I found out that the angle can be easily computed with:

0604: get_Z_angle_for_point [email protected] [email protected] store_to $tempvar_Angle

Share this post


Link to post
Share on other sites
Wesser

Preferring approximation over precision is an acceptable choise whenever achieving full speed is crucial or when the working environment doesn't supply any function to perform a task the easiest (but still accurate) way. Luckily, since VC you can optimize and simplify your code further using the available scripting commands (untested approach, it is just a concept):

  • Get the 2D magnitude between the tank cannon and the target with GET_DISTANCE_BETWEEN_COORDS_2D (1289);
  • Get the Z distance between the 2 entities (tank cannon and target) through an obvious subtraction of their Z coordinates (the Z offset, so to speak);
  • Compute the managed inverse tangent by passing the 2 values (relative to the origin) you obtained using GET_HEADING_FROM_VECTOR_2D (1540). Alternatively, you can configure GET_ANGLE_BETWEEN_2D_VECTORS (1444) as explained here to avoid messing around with hardcoding (it is the only command featured in VC, though);
  • If necessary, subtract the resulting angle by the tank pitch (subtracting additional 180 degrees may be needed) retrievable with GET_CAR_PITCH (1917). Alternatively, you can transform the Y axis [0, 1, 0] by the matrix of the tank entity with GET_OFFSET_FROM_CAR_IN_WORLD_COORDS (1031) and repeat the first 3 steps (substitute the tank cannon with the tank entity and the target position with the aforesaid coordinates).
Finally, make sure you apply yaw (Z angle) and then pitch (X angle). Edited by Wesser

Share this post


Link to post
Share on other sites
Jack

Sorry I'm late. I thought I used the most simpliest way to make this mod. About the GET_HEADING_FROM_VECTOR_2D: This only calculates Z_angle (the angle in horizontal flat) of a line whose edges are 0.0 0.0 (coord start) and some 2D point in the same system.

Same thing about GET_ANGLE_BETWEEN_2D_VECTORS - it calculates the angle whose top is coord start (0.0 0.0) - the only diference is here we have 3 points and 2 vectors.

Anyway the point is - why would I use those 2 commands inside vertical triangle build up by positions of a cannon and a player.
Also about the horizontal angle calculations - why not just use that scm function that you , ZAZ and Silent showed in that topic:

0AB1: call_scm_func @getAngleBetweenPoints 4 from_XY [email protected] [email protected] and_XY [email protected] [email protected] store_to [email protected]:getAngleBetweenPoints0063: [email protected] -= [email protected]: [email protected] -= [email protected]: get_Z_angle_for_point [email protected] [email protected] store_to [email protected]: ret 1 [email protected]

It seems like a fastest way and also the most precise???

Maybe I misunderstood what you're saying.

Share this post


Link to post
Share on other sites
lolleroz

Dude, huge fan of your mods, they always filled that niche thing that no other mods filled after years of evolved modding, thanks for this it's great - does it work fully with your wanted level enhacement? (forgot what its called)

Share this post


Link to post
Share on other sites
Wesser

@Jack, I pointed you a way to not overcomplicate things when possible (in III you cannot do anything simple, for example) and benefit from the intrinsic means the scripting engine does offer as regards the Taylor approximation for computing the cannon pitch. GET_HEADING_FROM_VECTOR_2D simply returns the absolute arctangent given a 2D vector (the offset between source and target coordinates), thus we can transpose any directional vector as if it is lying on a horizontal plane. Let the 2D distance between the source and the target be the Y direction and let the Z offset be the X direction, you are ready to calculate the in-between pitch (X angle) just like yaw (Z angle) using an atan2 function.

Edited by Wesser

Share this post


Link to post
Share on other sites
Jack

 

WHILE TRUE    wait 0    00AA: store_car [email protected] position_to [email protected] [email protected] [email protected]    00A0: store_actor $PLAYER_ACTOR position_to [email protected] [email protected] [email protected]    0509: [email protected] = distance_between_XY [email protected] [email protected] and_XY [email protected] [email protected] // Y    0063: [email protected] -= [email protected]    0097: make [email protected] absolute_float // X    0604: get_Z_angle_for_point [email protected] [email protected] store_to [email protected] // GET_HEADING_FROM_VECTOR_2D    0007: [email protected] = 360.0    0063: [email protected] -= [email protected] // vertical angleEND

I wish I knew this before. This saves a lot of work. Thanks a lot Wesser.

Does anybody know the memory offset for a tank aiming angle in gta3? I was pretty sure it's CVehicle + 0x580(fnc called tank controll) but I was wrong. Btw it's 0x5B0 for VC so I assumed it must be close. Also I don't think there's a vertical offset in VC or III like in SA(0x950).

 

Share this post


Link to post
Share on other sites
Jack

Dude, huge fan of your mods, they always filled that niche thing that no other mods filled after years of evolved modding, thanks for this it's great - does it work fully with your wanted level enhacement? (forgot what its called)

If you mean "Does it work with the rest of my wanted level modifications?" Well it should work but it's never been tested.

 

EDIT: Double post was a stupid mistake...

Edited by Jack

Share this post


Link to post
Share on other sites
Patrik2000_CZ

Nice man, I was waiting for this.

Share this post


Link to post
Share on other sites
Jack

***********************
TANK FIRE VERSION 1.1
***********************

Code update:
- inputed safety conditional checks in order to prevent the rare game crash:

 

{$I CLEO\forallpeds}    wait 0    IF        056D:   actor ped defined    THEN    ...    END{$I CLEO\for_end}{$I CLEO\forallcars}    wait 0    IF        056E:   car veh defined    THEN    ...    END{$I CLEO\for_end}

 


- removed the player's tank vulnerability to explosions [NPC tanks can still be destroyed by any type of explosion],
- added the ability to faster rotate the player's tank gun,
- decreased the push power of the players tank while fireing a cannon,
- drasticly increased cannon speed for NPC tanks (I'm still not sure which speed I should make - future code versions will be diferent),

- tested only for the 1.0 game version

Future plans [WIP]:

SA:

- Adding the city alarm siren for danger to make things even more dramatic,

- I'm thinking to put all this into the star 7 (6-7 replace).
VC^III: Project not yet started... "take all handle" needed plus the III tank aiming offsets...

 

Download link updated in the first post.

Edited by Jack

Share this post


Link to post
Share on other sites
ThirteenAG

VC^III: Project not yet started... "take all handle" needed plus the III tank aiming offsets...

But you got the right offset, the code is very similar to VC. So, what's the problem? And what is "take all handle"?

Share this post


Link to post
Share on other sites
Jack

I have the offset for VC (0x5B0) but not for III. And by "take all handle" I mean vehicle and actor "pool addresses" - the ones that DK22Pac used inside the $INCLUDE files for SA. In other words I need to take handle of all vehicles and actors (for III and VC) - I tried this for VC:

 

WHILE TRUEFOR [email protected] = 0 to 35584 step 256    wait 0    0085: [email protected] = [email protected]    FOR [email protected] = 0 to 127        IF AND           056D:   actor [email protected] defined           803C:   not $PLAYER_ACTOR == [email protected]          THEN            IF                0449:   actor [email protected] in_a_car            THEN            03C0: [email protected] = actor [email protected] car            020B: explode_car [email protected]            01C2: remove_references_to_actor [email protected]    BREAK            END       END       000A: [email protected] += 1   ENDENDwait 0END



But the code speed is not satisfying enough.

Share this post


Link to post
Share on other sites
ThirteenAG

Well, it's a CLEO3 friendly way, you can use this:

 

if    0AE1: [email protected] = random_actor_near_point 0.0 0.0 0.0 in_radius 20.0 find_next 0 pass_deads 1 //IF and SETthen    repeat        if                    then                   end    until 8AE1: not [email protected] = random_actor_near_point 0.0 0.0 0.0 in_radius 20.0 find_next 1 pass_deads 1 //IF and SETend
And where VC uses 0x5B0 offset, GTA3 uses 0x580 as you mentioned before, that why I'm asking what's the problem.

Share this post


Link to post
Share on other sites
Jack

"random_actor_near_point & random_vehicle_near_point" were my first choice when I started to build the SA code but they appeared not to work so well.
They were just too slow to force 3 or more tanks to aim at the player simultaneously. That's why I chose the $INCLUDE method - because it takes all at once and it's fast.

So I would prefer not to use the "random_actor/vehicle_near point" in VC&III. I need to learn DK22Pac's way or something similar that could take handle of all tanks at once.
And about gta3 0x580 offset - you're probably right. I'll recheck my testing code again.

Share this post


Link to post
Share on other sites
MW_29

Preferring approximation over precision is an acceptable choise whenever achieving full speed is crucial or when the working environment doesn't supply any function to perform a task the easiest (but still accurate) way. Luckily, since VC you can optimize and simplify your code further using the available scripting commands (untested approach, it is just a concept):

  • Get the 2D magnitude between the tank cannon and the target with GET_DISTANCE_BETWEEN_COORDS_2D (1289);
  • Get the Z distance between the 2 entities (tank cannon and target) through an obvious subtraction of their Z coordinates (the Z offset, so to speak);
  • Compute the managed inverse tangent by passing the 2 values (relative to the origin) you obtained using GET_HEADING_FROM_VECTOR_2D (1540). Alternatively, you can configure GET_ANGLE_BETWEEN_2D_VECTORS (1444) as explained here to avoid messing around with hardcoding (it is the only command featured in VC, though);
  • If necessary, subtract the resulting angle by the tank pitch (subtracting additional 180 degrees may be needed) retrievable with GET_CAR_PITCH (1917). Alternatively, you can transform the Y axis [0, 1, 0] by the matrix of the tank entity with GET_OFFSET_FROM_CAR_IN_WORLD_COORDS (1031) and repeat the first 3 steps (substitute the tank cannon with the tank entity and the target position with the aforesaid coordinates).
Finally, make sure you apply yaw (Z angle) and then pitch (X angle).

 

Hey Wesser, could You help. I am trying to make a script that would make an object to rotate towards the player, but with no luck so far. What am i doing wrong here? (not talking about simple-not high level code structure ofc)

{$CLEO .cs}//-------------MAIN---------------0000: NOP Model.Load(540):NONAME_1wait 0if and   Player.Defined($PLAYER_CHAR)   not Actor.Dead($PLAYER_ACTOR) jf @NONAME_1wait [email protected] = Object.Create(540, 290.0, -1300.0, 15.0 )wait 3000:NONAME_2wait 10001BB: store_object [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-Ya01BB: store_object [email protected] position_to [email protected] [email protected] 0.0 02F7: 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)01BB: store_object [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 Angle//0453: object [email protected] set_rotation 0.0 0.0 [email protected] 0177: set_object [email protected] z_angle_to [email protected] @NONAME_2

Result of above code is just a object rotating a bit and after that dissapearing. I remade this code snippet from linked topic where You helped Jack and i thought it may be a good opportunity to ask someone with more experience about my issue. Any constructive reply appreciated :) PS. Sorry for question in release topic Jack.

Edited by MW_29

Share this post


Link to post
Share on other sites
Wesser

You are mixing up variable references with immediate values for getting the entity's position, doing so the command behaviour is undefined (it may crash your game in the worst case).

 

By the way, GET_ANGLE_BETWEEN_2D_VECTORS (1444) returns the inverse of the cosine deriving from the dot product of 2 vectors, a relative angle within the range 0 and 180 degrees. Contrary to an atan2 function, it does have no information about the sign of the sine value (since we can calculate sine from cosine but get the sign lost). In its absence, we can make use of the cross product which gives us a normal, a perpendicular vector indicating the direction of the product itself. Forasmuch as we plotted vectors on a 2D space, their Z coordinate is meaningless and the normal XY components are always 0, thus we can just work with its Z component to find out the correct side (if positive, we are on the right side):

 

CVector2D vecOffset, vecYAxis;float fYaw;vecOffset = vecTarget - vecSource;vecYAxis = CVector2D(0.0f, 1.0f);// Start of GET_ANGLE_BETWEEN_2D_VECTORS.fYaw = RAD2DEG(acosf(DotProduct(vecOffset, vecYAxis) / sqrtf(DotProduct(vecOffset, vecOffset) * DotProduct(vecYAxis, vecYAxis))));// End of GET_ANGLE_BETWEEN_2D_VECTORS.if(CrossProduct(vecOffset, vecYAxis) > 0.0f)    fYaw = 360.0f - fYaw;
Demonstration script:

 

 

{$CLEO}0000: NOPconst    MINIGUN_BASE = 2985endconst    OBJECT_COORD_X = 2488.562    OBJECT_COORD_Y = -1666.865    OBJECT_COORD_Z = 12.3457endconst    SOUND_MINITANK_FIRE = 1157endconst    PAD1 = 0endconst    LEFTSHOULDER1 = 4 // Secondary Fireendconst    TIMERA = [email protected]    TIMERB = [email protected]: request_model MINIGUN_BASEwhile 8248:   not has_model MINIGUN_BASE loaded    wait 0end029B: [email protected] = create_object MINIGUN_BASE at OBJECT_COORD_X OBJECT_COORD_Y OBJECT_COORD_Z no_offset0177: set_object [email protected] heading 90.00249: mark_model MINIGUN_BASE as_no_longer_neededwhile 80E1:   not is_pad PAD1 button_pressed LEFTSHOULDER1    wait 0endTIMERA = 0while true    wait 0    00A0: get_char $PLAYER_ACTOR coordinates [email protected] [email protected] [email protected]    01BB: get_object [email protected] coordinates [email protected] [email protected] [email protected]    0063: [email protected] -= [email protected]    0063: [email protected] -= [email protected]    05A4: get_angle_between_2d_vectors [email protected] [email protected] 0.0 1.0 store_to [email protected]    if        [email protected] > 0.0    then        [email protected] *= -1.0        [email protected] += 360.0    end    //0604: get_heading_from_vector_2d [email protected] [email protected] store_to [email protected]    [email protected] += 90.0    0177: set_object [email protected] heading [email protected]    if and        TIMERA > 100 // Inverse firing rate.    00E1:   is_pad PAD1 button_pressed LEFTSHOULDER1    then        0400: get_world_coords [email protected] [email protected] [email protected] from_object [email protected] offset 0.92 0.017 1.125        0400: get_world_coords [email protected] [email protected] [email protected] from_object [email protected] offset 50.92 0.017 1.125        06BC: fire_single_bullet_from [email protected] [email protected] [email protected] to [email protected] [email protected] [email protected] damage 20        058A: add_big_gun_flash_from [email protected] [email protected] [email protected] to [email protected] [email protected] [email protected]        097B: report_at_object [email protected] mission_audio_event SOUND_MINITANK_FIRE        TIMERA = 0    endend

 

Edited by Wesser

Share this post


Link to post
Share on other sites
Jack

Wesser your method seems logical but it doesn't work for me [the bellow code has some of the ThirteenAGs CLEO 2.0 opcodes] :

{$CLEO}0000: TESTVCREPEAT    wait 250UNTIL 0256:   player $PLAYER_CHAR definedwait 70000247: request_model #RHINO038B: load_requested_models04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 0.0 5.0 0.000A5: [email protected] = create_car #RHINO at [email protected] [email protected] [email protected] TRUE    wait 0    0054: store_player $PLAYER_CHAR position_to [email protected] [email protected] [email protected]    00AA: store_tank [email protected] position_to [email protected] [email protected] [email protected]      0063: [email protected] -= [email protected]    0063: [email protected] -= [email protected]    05A4: get_angle_between_2d_vectors [email protected] [email protected] 0.0 1.0 store_to [email protected] // returns extremely low angle values from 0.0 to 4.0  ???        // on screen testing    0088: $WQY = [email protected] // (float)    03C4: set_status_text $WQY type 0 GXT 'Z_Angle'   //  0x821298 (float)        IF        0021:   [email protected] > 0.0    THEN    0013: [email protected] *= -1.0    000B: [email protected] += 360.0    END    000B: [email protected] += 90.0        0174: [email protected] = tank [email protected] Z_angle    0063: [email protected] -= [email protected]       0017: [email protected] /= 57.295779513082320876798154814105  // deg to rad    0A97: [email protected] = tank [email protected] struct    000A: [email protected] += 0x5B0 // 0x5B0 - HA    0A8C: write_memory [email protected] size 4 value [email protected] virtual_protect 0 // set Tank aiming to [email protected]
And where VC uses 0x5B0 offset, GTA3 uses 0x580 as you mentioned before, that why I'm asking what's the problem.

 

This:

{$CLEO}0000: TESTLCWHILE 8256:   not player $PLAYER_CHAR defined    wait 250ENDREPEAT    wait 1000UNTIL 00E1:   player 0 pressed_key 17 // fire0247: request_model #RHINO038B: load_requested_models0054: store_player $PLAYER_CHAR position_to [email protected] [email protected] [email protected]: [email protected] += 3.000A5: [email protected] = create_car #RHINO at [email protected] [email protected] [email protected] TRUE    wait 0    05E7: [email protected] = car [email protected] struct    000A: [email protected] += 0x580 // HA         0172: [email protected] = actor $PLAYER_ACTOR z_angle    0017: [email protected] /= 57.295779513082320876798154814105  // rad    05DF: write_memory [email protected] size 4 value [email protected] virtual_protect 0END

It does nothing.

 

DOWN:

It appears that this gta3 tank offset 0x580 works only when the player is inside the tank.

Edited by Jack

Share this post


Link to post
Share on other sites
MW_29

Me also ;/ I tried sample script that Wesser gave but it seems that in VC this opcode (05A4: get_angle_between_2d_vectors...) doesn't work as we would like to. Only visible result i got is the same as i was trying with my previous script, an object turns a little, maybe a few degrees and stops turning :(

Share this post


Link to post
Share on other sites
Jack

MW_29 you could use some rookie ways to achieve your goal:
- attach some actor to your object [04F4]

- make him invisible [0337],
- force him to look at the players XY and your objects Z [01BE],
- then just read his angle[0172]
- and put all that in a loop.

Unfortunately for me I can't use that method because my code is too complex and not to mention gta3 where we don't have "turret opcodes".

Edited by Jack

Share this post


Link to post
Share on other sites
MW_29

MW_29 you could use some rookie ways to achieve your goal:

- attach some actor to your object [04F4]

- make him invisible [0337],

- force him to look at the players XY and your objects Z [01BE],

- then just read his angle[0172]

- and put all that in a loop.

 

Unfortunately for me I can't use that method because my code is too complex and not to mention gta3 where we don't have "turret opcodes".

You're probably right, not exactly what i want, but i'll give it a try. But my final goal is also more complicated, i was asking about know how to properly use this vector-thing opcode in XY dimensions. If i would reach that then i would handle the Z dimension also with use of 05A4. And the idea is to have working SAM, i already got working script but it relays on a completely different method - player distances to object and comparing them, then adjusting +/- the object angle, but it is a bit to "mechanical", i mean either i have smooth turning but with slow speed or not smooth turning with fast speed ;/ ...so it would be nice to have 05A4 working in Vice anyway ;)

Edited by MW_29

Share this post


Link to post
Share on other sites
Wesser

The VC's counterpart of that command is indeed ambiguous. It computes the arctangent given the sine calculated from the cosine (obtained as explained earlier) beyond this one. The result is then normalized to range within the interval -pi/2 and pi/2, therefore a radian angle is returned. A manual adaptation is needed:

 

CVector2D vecOffset, vecYAxis;float fCos, fSin, fYaw;vecOffset = vecTarget - vecSource;vecYAxis = CVector2D(0.0f, 1.0f);// Start of GET_ANGLE_BETWEEN_2D_VECTORS.fCos = DotProduct(vecOffset, vecYAxis) / sqrtf(DotProduct(vecOffset, vecOffset) * DotProduct(vecYAxis, vecYAxis));fSin = sqrtf(1.0f - fCos * fCos);fYaw = (float)M_PI_2 - atan2f(fSin, fCos);// End of GET_ANGLE_BETWEEN_2D_VECTORS.if(CrossProduct(vecVectorA, vecVectorB) <= 0.0f)    fYaw = (float)M_PI_2 - fYaw;else    fYaw = (float)M_3PI_2 + fYaw;fYaw = RAD2DEG(fYaw);
Below is how the whole thing should look like script-wise (untested):

 

 

const    M_PI_2  = 1.57079637050628662109375 // pi/2    M_3PI_2 = 4.7123889923095703125     // 3pi/2    RAD2DEG = 57.2957763671875          // 180/piend00A0: get_char $PLAYER_ACTOR coordinates [email protected] [email protected] [email protected]: get_object [email protected] coordinates [email protected] [email protected] [email protected]: [email protected] -= [email protected]: [email protected] -= [email protected]: get_angle_between_2d_vectors [email protected] [email protected] 0.0 1.0 store_to [email protected]    [email protected] <= 0.0then    [email protected] *= -1.0    [email protected] += M_PI_2else    [email protected] += [email protected] *= RAD2DEG

 

Edited by Wesser

Share this post


Link to post
Share on other sites
Jack

Tested and it worked:

WHILE TRUE    wait 0    0054: store_player $PLAYER_CHAR position_to [email protected] [email protected] [email protected]    00AA: store_tank [email protected] position_to  [email protected] [email protected] [email protected]    0063: [email protected] -= [email protected]    0063: [email protected] -= [email protected]    05A4: get_angle_between_2d_vectors [email protected] [email protected] 0.0 1.0 store_to [email protected]    [email protected] *= 57.2957763671875    IF        [email protected] <= 0.0    THEN    [email protected] *= 1.0    ELSE    [email protected] *= -1.0    END    0174: [email protected] = tank [email protected] Z_angle    0063: [email protected] -= [email protected]       0017: [email protected] /= 57.295779513082320876798154814105      0A97: [email protected] = tank [email protected] struct    000A: [email protected] += 0x5B0    0A8C: write_memory [email protected] size 4 value [email protected] virtual_protect 0 // set Tank aiming to [email protected]

Thanks again Wesser. Have some cakes :cookie::cookie::cookie:

 

EDIT: SA way (thanks to ThirteenAG's CLEO 2.0 opcodes):

WHILE TRUE    wait 0    0054: store_player $PLAYER_CHAR position_to [email protected] [email protected] [email protected]    00AA: store_tank [email protected] position_to  [email protected] [email protected] [email protected]    0AB1: call_scm_func @getAngleBetweenPoints 4 from_XY [email protected] [email protected] and_XY [email protected] [email protected] store_to [email protected]    [email protected] *= 57.295779513082320876798154814105    0174: [email protected] = tank [email protected] Z_angle    0063: [email protected] -= [email protected]       0017: [email protected] /= 57.295779513082320876798154814105      0A97: [email protected] = tank [email protected] struct    000A: [email protected] += 0x5B0    0A8C: write_memory [email protected] size 4 value [email protected] virtual_protect 0END:getAngleBetweenPoints0063: [email protected] -= [email protected]: [email protected] -= [email protected]: get_angle_between_2d_vectors [email protected] [email protected] 0.0 1.0 store_to [email protected]    IF        [email protected] <= 0.0    THEN    [email protected] *= 1.0    ELSE    [email protected] *= -1.0    END0AB2: ret 1 [email protected]

EDIT:

Btw gta3 tank offset 0x580 [doom aiming] works only when a player is inside the tank.

Edited by Jack

Share this post


Link to post
Share on other sites
Ryhan'ZFX

hey man, great mod! but can you please decrease the firing rate,like 2 rounds per 8 seconds, that would be great!

Share this post


Link to post
Share on other sites
Ryhan'ZFX

Little suggestion,yesterday i play gta sa on pc,i use your mod and police improvement mod (because star 7 somehow doesn't work for me) when 6 stars are gained,it was so fricking awesome!it was just like war game! like battlefield for example

Share this post


Link to post
Share on other sites
Jack

hey man, great mod! but can you please decrease the firing rate,like 2 rounds per 8 seconds, that would be great!

Thanks. Do you mean for all tanks or just the player's tank?

Try this code I made a month ago (you can change some values by yourself at the begining of the code):

http://pastebin.com/sLRJXhNw

 

 

... star 7 somehow doesn't work for me...

Doesn't work how?

Have you tried to input the cheat code (star7)?

Game version???

Share this post


Link to post
Share on other sites
Ryhan'ZFX

Hey man thanks for the link,i really enjoyed now playing sa but still the tanks firing rate (NPC) are still like machine guns,by the way where to put the txt file?

Edited by Ryhan'ZFX

Share this post


Link to post
Share on other sites
Ryhan'ZFX

 

hey man, great mod! but can you please decrease the firing rate,like 2 rounds per 8 seconds, that would be great!

Thanks. Do you mean for all tanks or just the player's tank?

Try this code I made a month ago (you can change some values by yourself at the begining of the code):

http://pastebin.com/sLRJXhNw

 

 

... star 7 somehow doesn't work for me...

Doesn't work how?

Have you tried to input the cheat code (star7)?

Game version???

I tried but still not working, i'm using modloader

Share this post


Link to post
Share on other sites
Jack

Install this:
Sanny Builder v3.2.2
CLEO v4.3.21

 

Put CLEO mods (.cs or .cm files) into the CLEO folder of GTA SA directory and the TankFire v1.22.txt inside the CLEO folder. Open the txt with the Sanny Builder, make changes, select GTA SA at the bottom right corner of the program, go tools - options, choose GTA SA directory and INI path:

Example:

GTA SA Directory
C:\Program Files\Rockstar Games\GTA San Andreas

INI Path
C:\Program Files\Sanny Builder 3\data\sa\SASCM.ini

 

Press OK then press F6 to compile the TankFire code, press OK and F8 to start the game.

That's all.

Edited by Jack

Share this post


Link to post
Share on other sites
Ryhan'ZFX

Install this:

Sanny Builder v3.2.2

CLEO v4.3.21

 

Put CLEO mods (.cs or .cm files) into the CLEO folder of GTA SA directory and the TankFire v1.22.txt inside the CLEO folder. Open the txt with the Sanny Builder, make changes, select GTA SA at the bottom right corner of the program, go tools - options, choose GTA SA directory and INI path:

 

Example:

 

GTA SA Directory

C:\Program Files\Rockstar Games\GTA San Andreas

 

INI Path

C:\Program Files\Sanny Builder 3\data\sa\SASCM.ini

 

Press OK then press F6 to compile the TankFire code, press OK and F8 to start the game.

That's all.

Thanks man,you answer really fast,can i post your mod in another forum? Of course i will give you the credits

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

×

Important Information

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