View previous topic :: View next topic |
Author |
Message |
SirCabby Newbie cheater Reputation: 0
Joined: 31 Aug 2020 Posts: 15
|
Posted: Mon Jun 14, 2021 8:34 pm Post subject: Can this be done? |
|
|
I'm working on updating a CE table for FF IV to include some nicer tooling to update inventory in the game. The inventory is very predictable, every 4 bytes is an item and the bytes include the item code (2 bytes) a quantity (1 byte) and a 00 separator. Instead of doing a lot of copy / pasta to allow a user to modify each individual item, I'd like to make something that allows the user to select an inventory slot, and then a few codes to alter a slot.
Cheats would be:
1 value that stores the original pointer location (defined via script enable)
1 value that stores an index of the item to modify (zero-based, user sets)
1 value that shows "current item type" (user can update)
1 value that shows "current item quantity" (user can update)
2 questions:
1) I'm trying to store the pointer as a label and registered symbol so that I can reference it in the cheat addresses. I can't seem to get it to update. item1Address remains at 00000000 when referenced via a cheat address as (item1Address). This is what I have:
Code: |
[ENABLE]
globalalloc(mycode,1024)
label(item1Address itemNum)
registersymbol(item1Address)
registersymbol(itemNum)
mycode:
ret
item1Address:
dq (dword) 00e70240
itemNum:
dd (int)0
[DISABLE]
unregistersymbol(item1Address)
unregistersymbol(itemNum)
|
The second question I have is if it's possible to do math within defining these cheats? If I have the user updating the "Item Number" or the item index, I'll need to multiply that by a number of bytes to land the address correctly. I could think of something hacky like running another thread that watches the user value and updates another value for me to use, but is there something easier? The math would be something simple like "(itemNum)*4 + 3"
Any feedback is appreciated.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Mon Jun 14, 2021 10:28 pm Post subject: |
|
|
1) Don't put parenthesis around symbolnames, use alloc and dealloc instead of globalalloc if you're going to register/unregister symbols yourself anyway, dq is for quadwords, dword isn't a valid value type specifier, and all this is pointless indirection you could remove by simply putting 00e70240 for the address in the memory record (preferably the modulename instead- e.g. game.exe+70240)
2) Using threads to do that is ridiculous and you're making this far more complicated than it needs to be. Simply putting the symbol itemNum in the address / offset fields should work.
Use this script to get some memory:
Code: | [ENABLE]
alloc(itemIndex,4)
registersymbol(itemIndex)
itemIndex:
dd 0
[DISABLE]
unregistersymbol(itemIndex)
dealloc(itemIndex) |
Add a memory record to the cheat table w/ address itemIndex. The user changes this to whatever they feel like.
Add memory records for the properties of items, each with addresses using itemIndex. e.g. if the item array is in static memory, use game.exe+1234+itemIndex*4+4
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
SirCabby Newbie cheater Reputation: 0
Joined: 31 Aug 2020 Posts: 15
|
Posted: Tue Jun 15, 2021 10:28 am Post subject: |
|
|
Thanks for the feedback.
So I had tried playing with doing what you suggested before, but got different results.
For example, when I do something like "00e70240+itemIndex", it seems to be using the itemIndex memory address instead of the value. The same thing happens when trying to use it as an offiset for a pointer though I don't need that for this example.
So for example, this works:
FF4.exe+230240+1*4
But this doesn't:
FF4.exe+230240+itemIndex*4
I seem to get it to resolve if I do something like [itemIndex] but I don't think the lua interpretation is doing what I intend either.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Tue Jun 15, 2021 12:34 pm Post subject: |
|
|
Oh, right, my bad. You need to put the symbol name in square brackets to read the value at that address: i.e. [itemIndex]
I don't know what you mean by "Lua interpretation"
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
SirCabby Newbie cheater Reputation: 0
Joined: 31 Aug 2020 Posts: 15
|
Posted: Tue Jun 15, 2021 12:49 pm Post subject: |
|
|
Oh interesting, I thought the square brackets didn't work at first but it appears they work only if I re-edit the other saved addresses and then save them. Is there a way for them to dynamically update?
* edit - I'm just too impatient, they updated after a few seconds.
Regarding the square brackets being lua interpreted, that's what I read from this page: cheatengine dot org/help/Addresslist htm
Thanks again for the help
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Tue Jun 15, 2021 2:41 pm Post subject: |
|
|
https://cheatengine.org/help/Addresslist.htm
Quote: | Another special notation that the change value field supports is enclosing the new value by square brackets [ ]
The value between the backets will be calculated by lua as if it would do a "return <valuebetweenbrackets>"
For example [10+12] would return 22, but you can also do more advanced scripting like [readInteger(12345678)*2] | This is wrong.
Looking at CE's source code, the function TMemrecOffset.setOffsetText tries 4 different ways of parsing the text you enter as an offset:
1) Try to interpret it as a hexadecimal number
2) Shallow symbol lookup (doesn't dig deeper or invoke callbacks)
3) Try to parse it as Lua code
4) Regular symbol lookup
As far as I can tell from reading TSymhandler.getAddressFromName, it should resolve on shallow symbol lookup.
The memory records should dynamically update on their own unless you have "only update the offset when the memory record gets reinterpreted" checked.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
SirCabby Newbie cheater Reputation: 0
Joined: 31 Aug 2020 Posts: 15
|
Posted: Tue Jun 15, 2021 2:48 pm Post subject: |
|
|
Makes sense. I was able to get a working table update over here:
fearlessrevolution dot com/viewtopic.php?f=4&t=2536&p=197021#p197021
Turned out to be pretty simple once I understood the syntax and such, thanks again.
|
|
Back to top |
|
|
|