Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This is a sample script for Metroid Prime.
- -- It's simpler and less structured than the other game scripts
- -- (F-Zero GX, Super Mario Galaxy, etc.).
- -- It's meant to be easier to follow (or at least to imitate) for anyone new
- -- to these Lua scripts.
- -- Imports.
- -- package.loaded.<module> ensures that the module gets de-cached as needed.
- -- That way, if we change the code in those modules and then re-run the script,
- -- we won't need to restart Cheat Engine to see the code changes take effect.
- package.loaded.utils = nil
- local utils = require 'utils'
- local subclass = utils.subclass
- package.loaded.dolphin = nil
- local dolphin = require 'dolphin'
- package.loaded.valuetypes = nil
- local valuetypes = require "valuetypes"
- local V = valuetypes.V
- local MV = valuetypes.MV
- local MemoryValue = valuetypes.MemoryValue
- local FloatType = valuetypes.FloatTypeBE
- local Vector3Value = valuetypes.Vector3Value
- local SH = subclass(dolphin.DolphinGame)
- SH.supportedGameVersions = {
- na = 'G9SE8P',
- us = 'G9SE8P',
- }
- -- Layouts specific to this game module can be found in metroidprime_layouts.lua.
- SH.layoutModuleNames = {'sonicheroes_layouts'}
- -- This game runs at 60 frames per second. A few layouts and functions need
- -- to know the framerate for their calculations.
- SH.framerate = 60
- function SH:init(options)
- dolphin.DolphinGame.init(self, options)
- self.addrs = {}
- self.startAddress = self:getGameStartAddress()
- end
- -- If there are any addresses that can change during the game, calculate
- -- them in this function, which will be called on every frame.
- function SH:updateAddresses()
- -- We don't have any dynamic addresses for this game yet,
- -- so we'll just do nothing here.
- end
- -- Values at static addresses (from the beginning of the game memory).
- SH.StaticValue = subclass(MemoryValue)
- function SH.StaticValue:getAddress()
- return self.startAddress + self.offset
- end
- -- getActiveChar: checks the active character
- function SH:getActiveChar()
- return self.startAddress + utils.readIntBE(self.startAddress + 0x9D986A) - 0x80000000
- end
- local pointer = 0xAD090 + SH:getActiveChar() * 4
- -- Position.
- SH.blockValues.posX = MV("Pos X", pointer + 0x18, SH.StaticValue, FloatType)
- SH.blockValues.posY = MV("Pos Y", pointer + 0x1C, SH.StaticValue, FloatType)
- SH.blockValues.posZ = MV("Pos Z", pointer + 0x20, SH.StaticValue, FloatType)
- local pointer1 = 0x2AD0D0 + getActiveChar() * 4
- local pointer2 = 0x2AD0B0 + getActiveChar() * 4
- local pointer3 = 0x2AD0D0 + getActiveChar() * 4
- -- Velocity.
- SH.blockValues.velF = MV("Forward Vel", pointer1 + 0x60, SH.StaticValue, FloatType)
- SH.blockValues.velVt = MV("Vertical Vel", pointer1 + 0x64, SH.StaticValue, FloatType)
- SH.blockValues.velSd = MV("Sideways Vel", pointer1 + 0x68, SH.StaticValue, FloatType)
- SH.blockValues.velX = MV("Vel X", pointer2 + 0x0, SH.StaticValue, FloatType)
- SH.blockValues.velY = MV("Vel Y", pointer2 + 0x4, SH.StaticValue, FloatType)
- SH.blockValues.velZ = MV("Vel Z", pointer2 + 0x8, SH.StaticValue, FloatType)
- -- We can also use a Vector3Value to group a set of coordinates together.
- SH.blockValues.pos = V(
- subclass(Vector3Value),
- SH.blockValues.posX,
- SH.blockValues.posY,
- SH.blockValues.posZ
- )
- SH.blockValues.pos.label = "Position"
- return SH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement