Quantcast

Jump to content

» «
Photo

[SA] Island wanted level

7 replies to this topic
aStiffSausage
  • aStiffSausage

    Formerly Oksu

  • Members
  • Joined: 30 Sep 2010
  • Finland

#1

Posted 20 November 2013 - 04:17 PM

I've been doing a bit of "investigation" in main.scm of San Andreas, and I found out that the game uses integer stat 181 (Cities unlocked) to determine if player is given wanted level in San Fierro or Las Venturas. Though, how does the game actually give the player the wanted level? Is it hard-coded into the game, to check if current town number is larger than "cities unlocked"-stat? And is it possible to get rid of said feature, without changing the stat?


Silent
  • Silent

    Chief Vision™ Alterer

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [Modding] 2016
    Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012

#2

Posted 20 November 2013 - 04:34 PM

Is it hard-coded into the game


It is.

And is it possible to get rid of said feature, without changing the stat?


Should be as easy as writing 0xC3 (byte) to 0x441770.

aStiffSausage
  • aStiffSausage

    Formerly Oksu

  • Members
  • Joined: 30 Sep 2010
  • Finland

#3

Posted 20 November 2013 - 08:11 PM

Thank you, works just as it should! :)


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer

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

#4

Posted 22 November 2013 - 07:12 PM Edited by Wesser, 22 November 2013 - 07:12 PM.

Should be as easy as writing 0xC3 (byte) to 0x441770.

What will happen if someone wants to re-use the function you disabled? :p Noping the call instruction may be bothering when there are a lot of references, but you should take into account the safety and even the optimization first of all. The code below does the same but appropriate thing (untested):
// nop word ptr [eax+eax*1+00h]
0A8C: write_memory 0x00442AE4 size 4 value 0x441F0F66 vp 1
0A8C: write_memory 0x00442AE8 size 2 value 0x0000 vp 1
// add esp, 4
0A8C: write_memory 0x00442AF1 size 1 value 0x04 vp 1
// nop word ptr [eax+eax*1+00000000h]
// nop
0A8C: write_memory 0x00562E38 size 4 value 0x841F0F66 vp 1
0A8C: write_memory 0x00562E3C size 4 value 0x00000000 vp 1
0A8C: write_memory 0x00562E40 size 2 value 0x9000 vp 1

aStiffSausage
  • aStiffSausage

    Formerly Oksu

  • Members
  • Joined: 30 Sep 2010
  • Finland

#5

Posted 22 November 2013 - 11:33 PM

@Wesser

Thanks, I was kinda expecting to see you post something, well, let's say more "advanced". :p

 

But exactly how would your way be better than the one SilentPL showed? Other than someone "re-using" said function, and in which case someone might do so?


Deji
  • Deji

    Coding like a Rockstar!

  • Feroci
  • Joined: 24 Dec 2007
  • None
  • Contribution Award [Mods]

#6

Posted 23 November 2013 - 04:15 AM

He's got a point... but then again someone could also want to lazily redirect any of those calls by just overwriting the offset (or have already done so and you're cutting off the call) and we'd still have a problem. Never easy to avoid disaster when there's several different scripts hacking away at the same thing. You could be extra precarious and validate all memory before you change it. Kinda adds some weight to such a basic operation, though.


DK22Pac
  • DK22Pac

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

#7

Posted 30 November 2013 - 07:14 PM Edited by _DK, 30 November 2013 - 07:19 PM.

What will happen if someone wants to re-use the function you disabled?

That will mean these 2 mods are incompatible.
Just think about it - you use mod which disables wanted level, and at this time - another mod which do something with wanted level.

The solution for this problem lies in other place.
You need to share sources of your mod or at least notice somewhere (in text file for example) memory addresses you've touched.

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer

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

#8

Posted 01 December 2013 - 11:35 AM

Ofcourse, my opinion was meant to be effective in the general case. What about those routines used by the game only one-way or those returning a value? You cannot monopolize the modding scene with your modifications. Plus, you should attempt to maintain the executable integrity when feasible. RET-a-function is the worst and unsafe hack ever because you may reduce forcibly the mods compatibility, although the words hack and safety reject themselves yet.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users