Quantcast

Jump to content

» «
Photo

[SA] memory scripting 'INTMAN'

10 replies to this topic
frankandbeans
  • frankandbeans

    Crackhead

  • Members
  • Joined: 27 Jul 2015
  • United-States

#1

Posted 12 January 2018 - 11:33 AM Edited by frankandbeans, 12 January 2018 - 09:21 PM.

I'm trying to alter the 2-star-wanted-level behavior at police departments when the player is armed, but I can't seem to get it working. Here's what I'm trying to use:

{$cleo}
0000:

while true
    wait 0
    0AAA: [email protected] = thread 'INTMAN' pointer
    if [email protected] <> 0
    jf continue
       
    [email protected] += 16   //base ip   
    0A8D: [email protected] = read_memory [email protected] size 4 vp 0
    
    [email protected] += 3094 //offset
    
    if gosub @HasNotBeenModified
    jf continue
    
    0A8C: write_memory [email protected] size 1 value 0 vp 1      
end

:HasNotBeenModified
0085: [email protected] = [email protected]
0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0
if not [email protected] == 0
return

Basically I'm trying to change the value '2' to '0' in 'Player.SetMinWantedLevel($PLAYER_CHAR, 2)' shown from the main.scm:

:INTMAN_3052
if 
  $1260 == 1 
else_jump @INTMAN_3095 
if 
82D8:   not actor $PLAYER_ACTOR current_weapon == 56 
else_jump @INTMAN_3095 
Player.SetMinWantedLevel($PLAYER_CHAR, 2)

The '[email protected] += 16' makes my game crash, but if I don't use it, no changes occur.

 

note: this is just an example, so don't tell me to use other methods please.

 

Tried this too:

{$cleo}
0000:

while true
    wait 0
    0AAA: [email protected] = thread 'MAIN' pointer
    if [email protected] <> 0
    jf continue 
       
    [email protected] += 16   //base ip   
    0A8D: [email protected] = read_memory [email protected] size 4 vp 0
    
    [email protected] += 101988 //offset
    
    if gosub @HasNotBeenModified
    jf continue
    
    0A8C: write_memory [email protected] size 1 value 0 vp 1      
end

:HasNotBeenModified
0085: [email protected] = [email protected]
0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0
if not [email protected] == 0
return


Jack
  • Jack

    MODEL_SWAT

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#2

Posted 14 January 2018 - 12:04 PM

There's no need to make an extra code since this specific change won't effect the save game.
Just replace 2 with 0 and compile. That's it.

It can be done as cleo like this:

const
    globalVarsPointer = 0x44CA44
    PrecinctLevel = 0
end

0A8D: [email protected] = read_memory globalVarsPointer size 4 virtual_protect 0
0A8E: [email protected] = [email protected] + 0x2690C
0A8C: write_memory [email protected] size 1 value PrecinctLevel virtual_protect 0
0A93: end_custom_thread
  • frankandbeans likes this

frankandbeans
  • frankandbeans

    Crackhead

  • Members
  • Joined: 27 Jul 2015
  • United-States

#3

Posted 4 weeks ago Edited by frankandbeans, 4 weeks ago.

 

There's no need to make an extra code since this specific change won't effect the save game.
Just replace 2 with 0 and compile. That's it.

It can be done as cleo like this:
 

const
    globalVarsPointer = 0x44CA44
    PrecinctLevel = 0
end

0A8D: [email protected] = read_memory globalVarsPointer size 4 virtual_protect 0
0A8E: [email protected] = [email protected] + 0x2690C
0A8C: write_memory [email protected] size 1 value PrecinctLevel virtual_protect 0
0A93: end_custom_thread

 

 

Junior_Djjr helped me out and actually I wanted to do it like this because I wanted to add a police outfit check. Your script looks interesting though, so I'll study it. I had a hard time locating the exact offset.


DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]
    Helpfulness Award [Mods]

#4

Posted 4 weeks ago

So maybe you should ask Junior_Djjr directly?

Also: another idea is to intercept SetMinWantedLevel command call in 'INTMAN' thread (something similar to this). With such implementation It'll work even if your main.scm was changed/recompiled.

frankandbeans
  • frankandbeans

    Crackhead

  • Members
  • Joined: 27 Jul 2015
  • United-States

#5

Posted 4 weeks ago Edited by frankandbeans, 4 weeks ago.

So maybe you should ask Junior_Djjr directly?

Also: another idea is to intercept SetMinWantedLevel command call in 'INTMAN' thread (something similar to this). With such implementation It'll work even if your main.scm was changed/recompiled.

I've already stated that Junior_Djjr helped me out (by asking him directly).
 
Isn't that what my script was basically trying to do? Finding the 'INTMAN' thread and writing '0' over '2' in SetMinWantedLevel. Yours doesn't look like a cleo script. Is it asi/dll?
 

There's no need to make an extra code since this specific change won't effect the save game.
Just replace 2 with 0 and compile. That's it.

It can be done as cleo like this:
 

const
    globalVarsPointer = 0x44CA44
    PrecinctLevel = 0
end

0A8D: [email protected] = read_memory globalVarsPointer size 4 virtual_protect 0
0A8E: [email protected] = [email protected] + 0x2690C
0A8C: write_memory [email protected] size 1 value PrecinctLevel virtual_protect 0
0A93: end_custom_thread


How did you get the global vars pointer? Through IDA? Cheat engine?

DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]
    Helpfulness Award [Mods]

#6

Posted 4 weeks ago

Yours doesn't look like a cleo script. Is it asi/dll?

That's a C++ code, meant to be compiled and used as dll/asi library/plugin.

Jack
  • Jack

    MODEL_SWAT

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#7

Posted 4 weeks ago Edited by Jack, 4 weeks ago.

How did you get the global vars pointer? Through IDA? Cheat engine?

Both. And GTA database too.

 

So maybe you should ask Junior_Djjr directly?

Also: another idea is to intercept SetMinWantedLevel command call in 'INTMAN' thread (something similar to this). With such implementation It'll work even if your main.scm was changed/recompiled.

I noticed that there're many opcodes (mostly CLEO4) which are not present in the database (like 010E {ALTER_WANTED_LEVEL_NO_DROP}).

How are they implemented?
For example 010E calls CWanted::SetWantedLevelNoDrop. So I searched for "call    _ZN7CWanted20SetWantedLevelNoDropEi" and I got 0 results from CRunningScript::ProcessCommands. ???

So how to call those opcodes (in SDK) and where are they? Is there a documentation similar as in database? Or maybe I'm missing something?


DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]
    Helpfulness Award [Mods]

#8

Posted 4 weeks ago Edited by DK22Pac, 4 weeks ago.

I noticed that there're many opcodes (mostly CLEO4) which are not present in the database (like 010E {ALTER_WANTED_LEVEL_NO_DROP}).
How are they implemented?

1) 010E is not a CLEO4 opcode.
2) CLEO4 opcodes are not presented in gta_sa executable, they're part of CLEO.asi plugin.
 

For example 010E calls CWanted::SetWantedLevelNoDrop. So I searched for "call    _ZN7CWanted20SetWantedLevelNoDropEi" and I got 0 results from CRunningScript::ProcessCommands. ???

So how to call those opcodes (in SDK) and where are they? Is there a documentation similar as in database? Or maybe I'm missing something?

All original opcodes are divided among 27 ProcessCommands functions (100 opcode IDs per each function).
So, with given 010E ID, we have this:
1) Opcode ID 010Eh (hexademical) is 270d in decimal.
2) This opcode is implemented in CRunningScript::ProcessCommands200to299 function (270 is placed between 200 and 299).
3) Decompile this function and find a desired branch in switch construction (case 0x10E/270):

CLyMoDg.png

For opcode use in plugin, check ScriptCommands example (III/VC/SA)
  • Jack and frankandbeans like this

Jack
  • Jack

    MODEL_SWAT

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#9

Posted 4 weeks ago

...

Great. Thanks.


frankandbeans
  • frankandbeans

    Crackhead

  • Members
  • Joined: 27 Jul 2015
  • United-States

#10

Posted 3 weeks ago Edited by frankandbeans, 3 weeks ago.

edit: deleted post


frankandbeans
  • frankandbeans

    Crackhead

  • Members
  • Joined: 27 Jul 2015
  • United-States

#11

Posted 3 weeks ago Edited by frankandbeans, 3 weeks ago.

edit: deleted post





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users