-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Hello! I have the following script that calculates the address for a pointer based on a regional indicator. This seems to work in most cases, but when I do a direct comparison to the previous value vs. the current value at the target address, I'm running into an issue with how sub/add source and remember/recall conditions are ordered.
class Utilities {
function GetRegionalAddress(base, offset, accessor) {
return accessor(offset + base)
}
function MaskPointer(value) {
return value & 0x1fffffff
}
}
utilities = Utilities()
class Region {
Code = 0x3183
EUBit = bit4(Code)
JPBit = bit3(Code)
function GetRegionalOffset(euOffset, jpOffset) {
return (this.EUBit * euOffset) + (this.JPBit * jpOffset)
}
function GetPlayerObjectPointerOffset() {
euOffset = 0x7a0
jpOffset = -0x520
return this.GetRegionalOffset(euOffset, jpOffset)
}
}
region = Region()
class PlayerOffsets {
Score = 0x190
}
class PlayerObject {
RegionalOffset = region.GetPlayerObjectPointerOffset()
Pointer = utilities.GetRegionalAddress(0x353128, RegionalOffset, dword_be)
Base = utilities.MaskPointer(Pointer)
Offsets = PlayerOffsets()
function GetData() {
object = PlayerData()
scoreAddress = this.Base + this.Offsets.Score
object.Score = dword_be(scoreAddress)
return object
}
}
playerObject = PlayerObject()
class AchievementHelpers {
function GainedPointAmount(value) {
playerData = playerObject.GetData()
return playerData.Score == prev(playerData.Score) + value
}
}
helpers = AchievementHelpers()
class AchievementTriggers {
function Gained2Million() {
return helpers.GainedPointAmount(2000000)
}
}
triggers = AchievementTriggers()
achievement("Test", "Test", points = 5, trigger = triggers.Gained2Million())
Here's what is being produced by RATools. This results in the 2000000 being added to the regional offset for the pointer address:
And here is the desired result. Ideally the 2000000 would come after the remember so it's not being added to the regional offset:
Thanks for any and all help, and please don't hesitate to let me know if you need any additional information!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels