Quantcast

Jump to content

» «
Photo

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

SA Released VC WIP
43 replies to this topic
Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#1

Posted 17 November 2015 - 03:12 PM Edited by Jack, 04 June 2017 - 10:31 AM.

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...ing-of-include/

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

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

Spoiler


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.

  • Fireman, xNCx, ThirteenAG and 15 others like this

goodidea82
  • goodidea82

    SA Modder

  • Members
  • Joined: 13 Jun 2013
  • Germany

#2

Posted 17 November 2015 - 08:51 PM

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 5@ 6@ store_to $tempvar_Angle


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

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

#3

Posted 18 November 2015 - 12:31 AM Edited by Wesser, 18 November 2015 - 12:15 PM.

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

Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#4

Posted 18 November 2015 - 12:21 PM

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 5@ 6@ and_XY 8@ 9@ store_to 6@
:getAngleBetweenPoints
0063: 0@ -= 2@
0063: 1@ -= 3@
0604: get_Z_angle_for_point 0@ 1@ store_to 6@
0AB2: ret 1 6@

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

Maybe I misunderstood what you're saying.

lolleroz
  • lolleroz

    They might kill me, but they won't scare me.

  • Members
  • Joined: 29 Jul 2010
  • None

#5

Posted 18 November 2015 - 01:04 PM

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)

  • Jack likes this

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

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

#6

Posted 18 November 2015 - 01:26 PM Edited by Wesser, 18 November 2015 - 01:29 PM.

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.
  • Jack likes this

Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#7

Posted 18 November 2015 - 06:00 PM

WHILE TRUE
    wait 0
    00AA: store_car 0@ position_to 1@ 2@ 3@
    00A0: store_actor $PLAYER_ACTOR position_to 4@ 5@ 6@
    0509: 7@ = distance_between_XY 1@ 2@ and_XY 4@ 5@ // Y
    0063: 3@ -= 6@
    0097: make 3@ absolute_float // X
    0604: get_Z_angle_for_point 3@ 7@ store_to 8@ // GET_HEADING_FROM_VECTOR_2D
    0007: 9@ = 360.0
    0063: 9@ -= 8@ // vertical angle
END

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

Spoiler

Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#8

Posted 18 November 2015 - 06:06 PM Edited by Jack, 23 November 2015 - 12:18 PM.

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...


Patrik2000_CZ
  • Patrik2000_CZ

    aha sana sihhiye yardım cantasi....

  • Members
  • Joined: 26 Aug 2013
  • Czech-Republic

#9

Posted 23 November 2015 - 04:05 PM

Nice man, I was waiting for this.


Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#10

Posted 24 November 2015 - 07:28 PM Edited by Jack, 24 November 2015 - 07:42 PM.

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

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

Spoiler

- 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.


ThirteenAG
  • ThirteenAG

    Gangsta

  • Feroci
  • Joined: 29 Dec 2008
  • None
  • Contribution Award [Mods]

#11

Posted 24 November 2015 - 07:48 PM

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"?


Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#12

Posted 24 November 2015 - 08:13 PM

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:

Spoiler


But the code speed is not satisfying enough.

ThirteenAG
  • ThirteenAG

    Gangsta

  • Feroci
  • Joined: 29 Dec 2008
  • None
  • Contribution Award [Mods]

#13

Posted 24 November 2015 - 09:02 PM

Well, it's a CLEO3 friendly way, you can use this:
if
    0AE1: 0@ = random_actor_near_point 0.0 0.0 0.0 in_radius 20.0 find_next 0 pass_deads 1 //IF and SET
then
    repeat
        if
            
        then
           
        end
    until 8AE1: not 0@ = random_actor_near_point 0.0 0.0 0.0 in_radius 20.0 find_next 1 pass_deads 1 //IF and SET
end
And where VC uses 0x5B0 offset, GTA3 uses 0x580 as you mentioned before, that why I'm asking what's the problem.

Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#14

Posted 24 November 2015 - 09:17 PM

"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.


MW_29
  • MW_29

    i came to play

  • Members
  • Joined: 19 Jan 2008
  • None

#15

Posted 24 November 2015 - 11:25 PM Edited by MW_29, 24 November 2015 - 11:30 PM.

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_1
wait 0
if and
   Player.Defined($PLAYER_CHAR)
   not Actor.Dead($PLAYER_ACTOR) 
jf @NONAME_1
wait 5000
0@ = Object.Create(540, 290.0, -1300.0, 15.0 )
wait 3000


:NONAME_2
wait 100
01BB: store_object 0@ position_to 5@ 6@ 0.0                // A


0054: store_player $PLAYER_CHAR position_to 13@ 14@ 0.0 // B
 
// vector 1
0063: 13@ -= 5@ // Xb-Xa
0063: 14@ -= 6@ // Yb-Ya
01BB: store_object 0@ position_to 5@ 6@ 0.0 
02F7: cos 5@ store_to 7@   // x
02F6: sin 6@ store_to 8@   // y
0013: 7@ *= 120.0   // Xn (X-north)
0013: 8@ *= 120.0   // Yn (Y-north)
01BB: store_object 0@ position_to 5@ 6@ 0.0 
 
// vector 2
0063: 7@ -= 5@ // Xn-Xa
0063: 8@ -= 6@ // Yn-Ya
05A4: get_angle_between_2d_vectors 13@ 14@ and_origin_to 7@ 8@ store_to 2@   // Directional Angle
//0453: object 0@ set_rotation 0.0 0.0 2@ 
0177: set_object 0@ z_angle_to 2@

jump @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.


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

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

#16

Posted 27 November 2015 - 06:15 PM Edited by Wesser, 28 November 2015 - 10:27 PM.

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:
Spoiler
  • dkluin likes this

Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#17

Posted 28 November 2015 - 08:30 AM Edited by Jack, 30 November 2015 - 10:48 AM.

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: TESTVC

REPEAT
    wait 250
UNTIL 0256:   player $PLAYER_CHAR defined

wait 7000
0247: request_model #RHINO
038B: load_requested_models

04C4: create_coordinate 1@ 2@ 3@ from_actor $PLAYER_ACTOR offset 0.0 5.0 0.0
00A5: 0@ = create_car #RHINO at 1@ 2@ 3@

WHILE TRUE
    wait 0
    0054: store_player $PLAYER_CHAR position_to 1@ 2@ 3@
    00AA: store_tank 0@ position_to 4@ 5@ 6@  
    0063: 1@ -= 4@
    0063: 2@ -= 5@
    05A4: get_angle_between_2d_vectors 1@ 2@ 0.0 1.0 store_to 6@ // returns extremely low angle values from 0.0 to 4.0  ???
    
    // on screen testing
    0088: $WQY = 6@ // (float)
    03C4: set_status_text $WQY type 0 GXT 'Z_Angle'   //  0x821298 (float)
    
    IF
        0021:   1@ > 0.0
    THEN
    0013: 6@ *= -1.0
    000B: 6@ += 360.0
    END
    000B: 6@ += 90.0
    
    0174: 7@ = tank 0@ Z_angle
    0063: 6@ -= 7@   
    0017: 6@ /= 57.295779513082320876798154814105  // deg to rad
    0A97: 8@ = tank 0@ struct
    000A: 8@ += 0x5B0 // 0x5B0 - HA
    0A8C: write_memory 8@ size 4 value 6@ virtual_protect 0 // set Tank aiming to 6@
END
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: TESTLC

WHILE 8256:   not player $PLAYER_CHAR defined
    wait 250
END

REPEAT
    wait 1000
UNTIL 00E1:   player 0 pressed_key 17 // fire
0247: request_model #RHINO
038B: load_requested_models

0054: store_player $PLAYER_CHAR position_to 0@ 1@ 2@
000B: 1@ += 3.0
00A5: 3@ = create_car #RHINO at 0@ 1@ 2@

WHILE TRUE
    wait 0
    05E7: 4@ = car 3@ struct
    000A: 4@ += 0x580 // HA     
    0172: 6@ = actor $PLAYER_ACTOR z_angle
    0017: 6@ /= 57.295779513082320876798154814105  // rad
    05DF: write_memory 4@ size 4 value 6@ virtual_protect 0
END

It does nothing.

 

DOWN:

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


ThirteenAG
  • ThirteenAG

    Gangsta

  • Feroci
  • Joined: 29 Dec 2008
  • None
  • Contribution Award [Mods]

#18

Posted 28 November 2015 - 08:53 AM

000A: 4@ += 580 != 000A: 4@ += 0x580

MW_29
  • MW_29

    i came to play

  • Members
  • Joined: 19 Jan 2008
  • None

#19

Posted 28 November 2015 - 12:40 PM

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 :(


Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#20

Posted 28 November 2015 - 03:22 PM Edited by Jack, 28 November 2015 - 03:25 PM.

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".

  • MW_29 likes this

MW_29
  • MW_29

    i came to play

  • Members
  • Joined: 19 Jan 2008
  • None

#21

Posted 28 November 2015 - 06:18 PM Edited by MW_29, 28 November 2015 - 06:19 PM.

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 ;)


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

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

#22

Posted 29 November 2015 - 12:17 AM Edited by Wesser, 29 November 2015 - 10:55 AM.

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):
Spoiler
  • Jack likes this

Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#23

Posted 29 November 2015 - 11:23 AM Edited by Jack, 30 November 2015 - 10:50 AM.

Tested and it worked:

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

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 1@ 2@ 3@
    00AA: store_tank 0@ position_to  4@ 5@ 6@
    0AB1: call_scm_func @getAngleBetweenPoints 4 from_XY 1@ 2@ and_XY 4@ 5@ store_to 6@
    6@ *= 57.295779513082320876798154814105
    0174: 7@ = tank 0@ Z_angle
    0063: 6@ -= 7@   
    0017: 6@ /= 57.295779513082320876798154814105  
    0A97: 8@ = tank 0@ struct
    000A: 8@ += 0x5B0
    0A8C: write_memory 8@ size 4 value 6@ virtual_protect 0
END

:getAngleBetweenPoints
0063: 0@ -= 2@
0063: 1@ -= 3@
05A4: get_angle_between_2d_vectors 0@ 1@ 0.0 1.0 store_to 6@
    IF
        0@ <= 0.0
    THEN
    6@ *= 1.0
    ELSE
    6@ *= -1.0
    END
0AB2: ret 1 6@

EDIT:

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


Ryhan'ZFX
  • Ryhan'ZFX

    Crackhead

  • Members
  • Joined: 18 Jan 2017
  • Indonesia

#24

Posted 28 January 2017 - 01:07 PM

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

Ryhan'ZFX
  • Ryhan'ZFX

    Crackhead

  • Members
  • Joined: 18 Jan 2017
  • Indonesia

#25

Posted 30 January 2017 - 01:53 PM

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

Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#26

Posted 30 January 2017 - 06:28 PM

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???


Ryhan'ZFX
  • Ryhan'ZFX

    Crackhead

  • Members
  • Joined: 18 Jan 2017
  • Indonesia

#27

Posted 10 February 2017 - 11:54 AM Edited by Ryhan'ZFX, 10 February 2017 - 11:57 AM.

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?

Ryhan'ZFX
  • Ryhan'ZFX

    Crackhead

  • Members
  • Joined: 18 Jan 2017
  • Indonesia

#28

Posted 10 February 2017 - 11:59 AM

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

Jack
  • Jack

    Wanted Level Chaos

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#29

Posted 10 February 2017 - 01:07 PM Edited by Jack, 10 February 2017 - 01:12 PM.

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.


Ryhan'ZFX
  • Ryhan'ZFX

    Crackhead

  • Members
  • Joined: 18 Jan 2017
  • Indonesia

#30

Posted 10 February 2017 - 02:11 PM

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




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users