You are not logged in.
Pages: 1
Hi,
I've been working on a few custom scripts for GTA SA, and I was wondering how mission hooks work. I've seen the OTB hook example, but my coding skills are very limited so I'm kind of clueless.
Basically, I wanted to hook the Vigilante sub-mission and change the 2nd parameter of 02A9 (all lines) to make the criminals vulnerable to npc actors and peds, assuming it is possible at all.
I've tried a different approach by making a custom script using intercepting opcodes, but to no avail.
Any help would be appreciated.
-Krailer
Offline
You can't hook opcodes executed by another thread. Otherwise you can manipulate its variables. In your case, you can hook the local variables containing the criminals' handles to take control of these peds.
{$CLEO} // Hooks the Vigilante mission, making all criminals vulnerable to nonplayer peds 0000: while true wait 250 0AAA: 0@ = thread 'COPCAR' pointer if 0@ > 0 // true if mission Vigilante is running then // get the address where all mission local variables are stored if 0AA9: is_game_version_original then 3@ = 0x00A48960 // Mission Locals address v1 else 3@ = 0x00A4AFE0 // Mission Locals address v1.1 end // call an SCM function for specific local variables that contain the criminals handles 0AB1: call_scm_func @SetNPCVuln 1 37 // 37@ 0AB1: call_scm_func @SetNPCVuln 1 38 // 38@ 0AB1: call_scm_func @SetNPCVuln 1 39 // 39@ 0AB1: call_scm_func @SetNPCVuln 1 41 // 41@ 0AB1: call_scm_func @SetNPCVuln 1 42 // 42@ 0AB1: call_scm_func @SetNPCVuln 1 43 // 43@ 0AB1: call_scm_func @SetNPCVuln 1 44 // 44@ 0AB1: call_scm_func @SetNPCVuln 1 46 // 46@ 0AB1: call_scm_func @SetNPCVuln 1 47 // 47@ 0AB1: call_scm_func @SetNPCVuln 1 48 // 48@ 0AB1: call_scm_func @SetNPCVuln 1 49 // 49@ end end :SetNPCVuln // read the value of specific mission variable (37@, 38@, etc) 0@ *= 4 005A: 0@ += 3@ // (int) 0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 // check if it's the correct ped handle if 056D: actor 0@ defined then // make it vulnarable 02A9: set_actor 0@ immune_to_nonplayer 0 end 0AB2: ret 0
Offline
Hi,
Thanks for the fast reply. I've tried it but it doesn't seem to have effect.
By the way, the different approach I mentioned earlier was something along these lines:
{$CLEO} 0A95: enable_thread_saving :VGLNTE 0001: wait 300 ms 0AAA: 0@ = thread 'COPCAR' pointer 00D6: if 0019: 0@ > 0 004D: jump_if_false @VGLNTE_4 :VGLNTE_1 0247: load_model #BRASSKNUCKLE :VGLNTE_2 0001: wait 300 ms 00D6: if and 0256: player $PLAYER_CHAR defined 0248: model #BRASSKNUCKLE available 004D: jump_if_false @VGLNTE_2 00A0: store_actor $PLAYER_ACTOR position_to 1@ 2@ 3@ 08E5: get_actor_in_sphere 1@ 2@ 3@ radius 50.0 handle_as 4@ //tried with versionB as well 00D6: if 056D: actor 4@ defined 004D: jump_if_false @VGLNTE_4 089F: get_actor 4@ pedtype_to 5@ 0470: 6@ = actor 4@ current_weapon 00D6: if and 0039: 5@ == 24 8491: not actor 4@ has_weapon 1 8118: not actor 4@ dead 004D: jump_if_false @VGLNTE_3 02A9: set_actor 4@ immune_to_nonplayer 0 081A: set_actor 4@ weapon_skill_to 2 01B2: give_actor 4@ weapon 1 ammo 9999 0249: release_model #BRASSKNUCKLE 00D6: if 82D8: not actor 4@ current_weapon == 6@ 004D: jump_if_false @VGLNTE_3 01B9: set_actor 4@ armed_weapon_to 6@ :VGLNTE_3 0001: wait 0 ms 01C2: remove_references_to_actor 4@ :VGLNTE_4 0002: jump @VGLNTE
In theory, I thought it should work. But not only it didn't work, as it caused some weird glitches in surrounding traffic.
Offline
Pages: 1