Author Topic: [Solved] OXCE + Cheat Engine: soldier values pointers?  (Read 3534 times)

Offline timmyr0x0r

  • Squaddie
  • *
  • Posts: 2
    • View Profile
[Solved] OXCE + Cheat Engine: soldier values pointers?
« on: June 16, 2021, 09:00:16 pm »
Hi all.
I'm trying to experiment on memory editing OXCE and I'm currently using Cheat Engine.
I easily found out addresses to soldier values in battlescape but it turns out they are not static: I tried to find the pointer to those addresses but no dice, they don't seem to be static either :/

So this is a question to OX/OXCE devs and/or data tinkerers out there: what am I doing wrong? Did I miss something on how OXCE reads values or something?
« Last Edit: February 12, 2023, 11:30:34 am by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9009
    • View Profile
Re: OXCE + Cheat Engine: soldier values pointers?
« Reply #1 on: June 17, 2021, 09:47:26 am »
My guess would be that you are accessing the BattleUnit values, not the Soldier values.

Geoscape Soldier objects are used to construct Battlescape BattleUnit objects, which only exist temporarily during the Battlescape and are deleted when you return to the Geoscape.

Offline timmyr0x0r

  • Squaddie
  • *
  • Posts: 2
    • View Profile
Re: OXCE + Cheat Engine: soldier values pointers?
« Reply #2 on: June 17, 2021, 11:56:03 am »
Thanks for this tidbit: I thought the Geoscape Soldier data was the same as the Battlescape data, but yeah in hindsight I can see why it's handled like this instead.

I'm still surprised I can't seem to get an static pointer on the currently selected soldier/BattleUnit: I would have guessed this specific part of game UI logic to be static in memory and read data to be simply swapped.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9009
    • View Profile
Re: OXCE + Cheat Engine: soldier values pointers?
« Reply #3 on: June 17, 2021, 02:19:59 pm »
Geoscape Soldier data has a static pointer; and the Battlescape BattleUnit has a pointer to this Geoscape Soldier too (of course only if the given BattleUnit corresponds to a soldier).

Check the OpenXcom source code to see the structure details.

There is also a pointer to the currently selected unit (can be a soldier, a HWP, an alien, or even null)... again check the source code... it's easier to search for it when you know where to look and what to expect.

Offline krautbernd

  • Commander
  • *****
  • Posts: 1108
    • View Profile
Re: OXCE + Cheat Engine: soldier values pointers?
« Reply #4 on: June 17, 2021, 04:51:17 pm »
I am curious, what exactely are you trying to achieve by using a memory editor?

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: OXCE + Cheat Engine: soldier values pointers?
« Reply #5 on: June 17, 2021, 09:09:27 pm »
I am curious, what exactely are you trying to achieve by using a memory editor?

I'm also curious; the save files are all plain text, so editing soldier values mid-battle just requires a save, open file in notepad, edit, and load.