Quantcast

Jump to content

» «
Photo

[Q:SA] Heatseeking Rocket On a Car; Memory Address Coding Help

5 replies to this topic
bondlover1313
  • bondlover1313

    KITT2000

  • Members
  • Joined: 30 Nov 2008

#1

Posted 09 December 2013 - 06:29 PM

Hello all at GTAforums!

 

Ok, let me explain my overall goal. I want to have rockets shoot out from a car (the LineRunner in particular) when the player presses a certain key (A for example). If the player presses another key before key A (B for example) then the little targetting reticle will come up and begin locking onto a car or something (like a Hydra would) and then with key B still held they press key A and the rocket will "attack" the target. I want what happens when you use missles on a hydra to happen with a car, to put it simplisticly.

 

Ok, now here in lies my problem. I know how to do all the checks for presses of buttons, if and false checks, car checks, etc. But I have zero idea how to mod memory address which is the only way to do this, modding the rocket pool.

	Rockets
The rocket pool contains info on launched rockets (for example, Hydra rockets).
0xC891A8 - Rocket pool start. Each slot has 36 bytes of data. There are 32 elements in the pool.

+0 = [dword] Rocket type:

16 = none
17 = tear gas
19 = normal
20 = heatseeking
39 = remote explosives
58 = flare


+4 = [dword] Pointer to launching entity
+8 = [dword] Pointer to target vehicle (when heatseeking), 0 otherwise
+16 = [byte] Does rocket exist?

0 = exploded/does not exist
1 = travelling


+20 = [float] X-axis position
+24 = [float] Y-axis position
+28 = [float] Z-axis position

I have no idea how to modify anything to do with memory addresses, other then true or false values (ie 1 and 0). I looked up some memory coding tutorials and a general idea of what I might do, I am not sure though. I don't understand if I have to load a rocket model, or actors with weapons, etc before touching those values, or how to tell where the rocket should fire in respect to the car's position (offsets).

 

Here is my general idea in code, I don't have SannyBuilder on this computer, so bear with me as there is a lot missing and probably wrong.

 
:Begin
1@ = 0xC891A8
1@ += 0
0A8D: 2@ = read_memory 1@ size 1 virtual_protect 0

if and
2@ == 20
0AB0:   key_pressed B     // I don't remember the number for it
jf @Begin
0A8C: write_memory 1@ size 4 value 1 virtual_protect 0

1@ += 8
jump @Mid
 
:Mid
1@ = 0xC891A8
1@ += 8
0A8D: 2@ = read_memory 1@ size 1 virtual_protect 0
if
2@ == 1
jf @Begin
0A8C: write_memory 1@ size 4 value 1 virtual_protect 0

1@ += 16
jump @End
 
:End
1@ = 0xC891A8
1@ += 8
0A8D: 2@ = read_memory 1@ size 1 virtual_protect 0
if
2@ == 1
jf @Begin
jump @Begin
 

That is the general code I came up with, but I don't know if I need to load models or how to specify where the rocket should start from in respect to the car. Any help would be deeply appreciated!

 

Thanks, Bests

Bondlover1313 :)

 


DK22Pac
  • DK22Pac

    Playing SA on my lovely PS2. Y'all bums.

  • Feroci
  • Joined: 12 Apr 2009
  • Brazil

#2

Posted 09 December 2013 - 07:08 PM

There's a specal function for creating projectiles. You can also create heat-seek rocket with it (pass the target entity struct as _target_struct param).
http://gtaforums.com...e/?p=1060797395
0x737C80  CProjectileInfo::AddProjectile(CEntity *launcher, eWeaponType WeponType, float src_x, float src_y, float src_z, float force, CVector *dest, CEntity *target)
0AA5: call_function 0x737C80 num_params 8 pop 8 _target_struct 0 _dest_vector 4@ _force 1.0 _src_z 8@ _src_y 7@ _src_x 6@ _weapon_type 19 _launcher_struct 0@

bondlover1313
  • bondlover1313

    KITT2000

  • Members
  • Joined: 30 Nov 2008

#3

Posted 09 December 2013 - 07:48 PM

There's a specal function for creating projectiles. You can also create heat-seek rocket with it (pass the target entity struct as _target_struct param).
http://gtaforums.com...e/?p=1060797395

0x737C80  CProjectileInfo::AddProjectile(CEntity *launcher, eWeaponType WeponType, float src_x, float src_y, float src_z, float force, CVector *dest, CEntity *target)
0AA5: call_function 0x737C80 num_params 8 pop 8 _target_struct 0 _dest_vector 4@ _force 1.0 _src_z 8@ _src_y 7@ _src_x 6@ _weapon_type 19 _launcher_struct 0@

So this is all I have to use to make the car fire heatseeking missles? Wow, that was much simpler then what I had. One question, what parameters do I need to fill in?

 

Thanks, Bests

Bondlover1313 :)


DK22Pac
  • DK22Pac

    Playing SA on my lovely PS2. Y'all bums.

  • Feroci
  • Joined: 12 Apr 2009
  • Brazil

#4

Posted 09 December 2013 - 09:03 PM

_target_struct - struct of target vehicle
_dest_vector - pointer to target entity posn (array of 3 float values, use get_var_offset to get pointer of first var)
_force - speed (1.0 - default)
_src_z, _src_y, _src_x - target coors
_weapon_type - weapon type, 19 for missile
_launcher_struct - player struct (you may also try player vehicle struct).

bondlover1313
  • bondlover1313

    KITT2000

  • Members
  • Joined: 30 Nov 2008

#5

Posted 09 December 2013 - 09:06 PM Edited by bondlover1313, 09 December 2013 - 09:06 PM.

There's a specal function for creating projectiles. You can also create heat-seek rocket with it (pass the target entity struct as _target_struct param).
http://gtaforums.com...e/?p=1060797395

0x737C80  CProjectileInfo::AddProjectile(CEntity *launcher, eWeaponType WeponType, float src_x, float src_y, float src_z, float force, CVector *dest, CEntity *target)
0AA5: call_function 0x737C80 num_params 8 pop 8 _target_struct 0 _dest_vector 4@ _force 1.0 _src_z 8@ _src_y 7@ _src_x 6@ _weapon_type 19 _launcher_struct 0@

 

_target_struct - struct of target vehicle
_dest_vector - pointer to target entity posn (array of 3 float values, use get_var_offset to get pointer of first var)
_force - speed (1.0 - default)
_src_z, _src_y, _src_x - target coors
_weapon_type - weapon type, 19 for missile
_launcher_struct - player struct (you may also try player vehicle struct).

But is that all I need, just the two lines of code you provided me with? Or do I need to go the route I was going but add on what you provided? I am a little confused, thanks.

 

Thanks, Bests

Bondlover1313 :)


DK22Pac
  • DK22Pac

    Playing SA on my lovely PS2. Y'all bums.

  • Feroci
  • Joined: 12 Apr 2009
  • Brazil

#6

Posted 09 December 2013 - 09:19 PM

No, you need just to call this function.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users