Page 1 of 1

Modifying values of pointers

Posted: Sat Jun 22, 2019 8:16 am
by HailoSir
1) I have a multilevel pointer which gives the value for money with a multiplier applied to the value shown in the game. However, I don't want to open my calculator every time to apply the multiplier to the amount I want... Is it possible to change the value to the amount I want with a script that applies the multiplier automatically?

2) Also, this money pointer is at all times 8 bytes away from another useful address pointing toward an honor value. How would I go about writing a script to calculate the honor address based off the money pointer?

Re: Modifying values of pointers

Posted: Sat Jun 22, 2019 1:25 pm
by TimFun13
1.) You can add a custom type and set the pointer value type to that.
Here is a script for an integer (4 byte) divided by 100, you'll need to add this to the table Lua script:

Code: Select all


local TypeName = 'Int / 100'
local ByteCount = 4
local IsFloat = false

local function bytesToValue( ... )
	local bytes = { ... }
	return (byteTableToDword({ bytes[1], bytes[2], bytes[3], bytes[4] }) / 100)
end
local function valueToBytes(value)
	local bytes = dwordToByteTable(value * 100)
	return bytes[1], bytes[2], bytes[3], bytes[4]
end

registerCustomTypeLua(TypeName, ByteCount, bytesToValue, valueToBytes, IsFloat)

2.) Just add to the final offset. Copy & paste the pointer, then add to the final offset (the one at the top in the CE address/pointer window).

Re: Modifying values of pointers

Posted: Sat Jun 22, 2019 2:25 pm
by SunBeam
Yeah, sure he'll know wtf you mean with Lua code ;)

Re: Modifying values of pointers

Posted: Sat Jun 22, 2019 6:23 pm
by HailoSir
Thanks, ShyTwig16! Everything is working :D