Messing around with Cheat Engine

A forum for people who have played the game concerning the Sun Rune War to answer gameplay questions.
literally
Posts: 2
Joined: Sun Jan 27, 2013 10:07 pm

Messing around with Cheat Engine

Postby literally » Mon Jan 28, 2013 12:47 am

I'm playing through the game on a Windows emulator with Cheat Engine running. I was surprised to find that when I searched, there was no info anywhere about using Cheat Engine with Suikoden V. So, the purpose of this thread is just to post what I've learned in the hopes that someone else will find it useful. I'm still playing through the game, so I'll continue to post new info as I learn it. My present goal is figuring out how affinities are determined (I'll elaborate on the problem later).

NOTE: This is a warning and a disclaimer. From the forum rules page: "Illegal Topics: Do not discuss anything that is illegal. This includes, but is not limited to, illegal drugs, solicitation, ROMs or other copyrighted products." I legally own both a Playstation 2 and the NA version of the PS2 game Suikoden 5. What I'm saying here is DON'T ASK ABOUT ILLEGALLY ACQUIRING THIS GAME (or any others)!

With that out of the way, I'll get on with it. I'm using Cheat Engine 6.2 and the emulator PCSX2 r5350.

Suikoden 5 is much more difficult to figure out than the first 4 main series titles. In those games, stats, MP, items, affinities, all of it is determined by a very simple memory location + value.

In this game things are more complex -- much more complex, it seems, but I also know next to nothing about programming so I can't really judge.

I've mostly figured out the equipment system. There are a total of 7 equipment categories, each with a unique value system:
1: All 3 rune slots share the same value system
2: Head slot
3: Body slot
4: Hands slot
5: Feet slot
6: All 4 aux slots share the same value system
7: Both skill slots share the same value system

Runes, head items, body items, hand items, feet items, and skills

The first 5 things I listed plus the 7th -- Runes, head, body, hands, feet, and skills -- are all pretty similar. All of them are 1-byte memory locations with a similar range of values. They all start with 0 (which is an empty slot), and each whole number value thereafter corresponds to a unique item in each type of slot. Here are some examples to make sure I'm being clear:

-A value of 0 is an empty slot.
-A value of 1 is a Dawn Rune in a rune slot, a Bandana in the head slot, a Robe in the body slot, a Bandage in the hands slot, a Mules in the feet slot, and the skill Stamina in a skill slot.
-A value of 16 is a Beast rune, a Forehead Guard, a Fantasy Half Coat, Leather Gloves, Long Boots, and Triple Harmony skill.

Despite being similar, each category has a different total amount of values:

Rune slot values: 0-97. There are a total of 93 runes. (Note: 20, 38, 57, and 58 are all blank)

Head slot values: 0-32. There are a total of 32 head items.

Body slot values: 0-71. There are a total of 71 body items.

Hand slot values: 0-37. There are a total of 37 hand items.

Feet slot values: 0-30. There are a total of 30 feet items.

Skill slot values: 0-48. There are a total of 47 skills. (Note: 27 is blank)


The aux slots are different, and I haven't quite figured them out. Aux slots appear to be 8-byte memory locations, though I have never seen more than the first 4 bytes used at a time. To me it seems like only 2 bytes should be necessary for this -- using the extra byte to measure consumable quantity values -- but again, I know nothing about programming so I really have no idea.

Aux items

The values assigned to aux items appears to be random (though there's probably a not-very-complicated logic to it that would be obvious/not hard to find if I knew anything about programming), so here's some examples:

261 = Cape
2313 = Sacrificial Jizo
3333 = White Rose Brooch
4357 = Scarf
10501 = Lightning Ring
11781 = Eyeball Ring
11525 = Defense Ring
83951881 = Medicine1
84214025 = Medicine5
50398986 = Breath of Ice S1
50530058 = Breath of Ice S3


I've also found the memory locations of potch, party SP, character SP, character EXP, character weapon level, character skill levels, character stats, and character affinities. All of those but the last 2 (character stats and character affinities) are very simple.

Potch, party SP, character SP, character EXP, character weapon level, character skill levels

Potch: there are two 4-byte memory locations for potch. One is the actual amount, the other is the counter displayed on the bottom-left after you win a battle

Party SP: similar to potch; there are two 2-byte memory locations for party SP. One is the actual amount, the other is the counter display

character EXP: similar to the above; there are two 2-byte memory locations for character EXP. One is the actual amount, the other is the EXP counter displayed under the character's name, hp, etc on the right of the screen after you win a battle

character SP: same as above; two 2-byte memory locations for character SP. one is the actual amount, the other is the SP counter under the character after you win a battle

character weapon level
: a 1-byte memory location just before the string of three 1-byte character rune slot locations. a value of 0 is weapon level 1, 2 is weapon level 3, 9 is weapon level 10, etc.

character skill level: a string of many 1-byte memory locations, each corresponding to a different skill
0 = no skill
1 = E
2 = D
3 = C
4 = B
5 = A
6 = S
7 = SS


Character stats and character affinities are more complicated

Character stats, character affinity (note: i'm leaving HP and MP aside for now)

Character stats are 2-byte memory locations, one each for: ATK, MAG, PDF, MDF, TEC, ACC, EVA, SPD, and LUK (in that order)

Character affinities are 1-byte memory locations, one each for: Su, Fi, Li, Wi, Wa, Ea, St, So, Ho, Da, Sl, Th, Pu, and Sh
Values:
1: E
2: D
3: C
4: B
5: A
6: S
(note: 0 is not a valid value)
(note: 6, or S, is the highest value, meaning there is no SS rank for affinity)


My current problem is that I can't figure out how to change stats or affinity. If I change the values, they are automatically reset when I open the menu (pressing square) and also when I confirm ending my turn in battle.

From what I can tell, this is a fairly common problem programming-illiterate people have when using Cheat Engine and similar programs. My current guess is that there is some algorithm that determines both stats and affinities, then writes the answer it comes up with to the character stat and character affinity addresses I've found. Hopefully someone who knows what they're doing will see this and let everyone know what's going on.

If not, I'll probably figure it out eventually. I can already sort-of get around it by telling the Cheat Engine debugger to find what writes to those addresses, then adding the code to the code list, and right-clicking it and replacing it with "code that does nothing". Leaving aside the major problem that this tends to cause the game to crash, this works fine with affinities, because the game doesn't need to recalculate affinities when characters level up. But for stats -- let's take the magic stat as an example -- it's different. So, I could disable the code and set Cornelio's magic to 500. But then, the magic stat for him and all other characters will stay the same even if they level up until I re-enable the code, at which point it will reset back to what it should be for whatever level they are.

I'm really interested in figuring out a way to reliably change affinities without causing a freeze/crash, because it would be a tremendous help in figuring out exactly how affinity factors into casting speed.

Anyway, if anyone wants my .CT (not sure if it's worth anything cause i have no idea how to use pointer scans) and/or my (incomplete) spreadsheet of equipment values, I'd be happy to post them once I figure out where to do it.

edit: fixing typos, etc

User avatar
Pyriel
Webmaster
Posts: 926
Joined: Wed Aug 18, 2004 1:20 pm

Re: Messing around with Cheat Engine

Postby Pyriel » Mon Jan 28, 2013 10:10 am

You realize most of this covered in the existing codes for PS2 cheat devices, right? The items carry over the type system from other games, but they expand it to bytes instead of bits. I forget how the system works for this game, but there are lists around, and a lot of people complaining about how hard the item codes are to use because they can't just plug in 050E and get Mega Medicine. They have to do something like 5009050E to account for the item type, quantity, and the item index. That's just a for instance. I'm sure those aren't real values.

When you say you're letting Cheat Engine find code that writes to a given address in the game, and further that you're NOPing (no operation or "code that does nothing"), are you aware of the fact that you're dealing with an emulated system, so what you're tracing is the emulator's code that simulates a PS2 environment, and not the actual game? If you're not, then chances are that what you're NOPing is PCSX2's implementation of the PS2's store operations. It's a miracle the game isn't crashing constantly, so I'm thinking you might be aware of that, or there's some plug-in for Cheat Engine that lets it handle the abstraction layers inherent to the emulator. Also, "code that does nothing" means something different to a Windows machine than it does to the PS2. If you're NOPing a PS2 instruction, you need 4 bytes of zeroes to create the NOP (it's actually "SLL zero, zero, 0" if memory serves). If you're NOPing something in x86 or x64 binaries, that's a series of 90 (NOP) instructions, for whatever the size of that particular operation is. So again, unless there's a plugin handling all this stuff, using Cheat Engine to analyze the programming, and letting it make automated changes to it is bad, bad, bad, bad.

And yeah, Suikoden V does refresh a number of things constantly. If I remember right, it does it when you open menus, when you transition areas, when you enter battle, etc., etc. I don't usually mess with affinities, and I'm surprised it constantly updates those. They're usually set at the beginning of the game, and there's no reason to change them ever. Either the programmers were overzealous, or the affinities do change from time to time.

User avatar
Pyriel
Webmaster
Posts: 926
Joined: Wed Aug 18, 2004 1:20 pm

Re: Messing around with Cheat Engine

Postby Pyriel » Tue Jan 29, 2013 10:57 am

http://forums.codetwink.com/showthread. ... Mod-Cheats

I found some information on the item data that might help you out. Going by this, what you should see in memory for each item would be:

Byte Offset 00: Item Index
Byte Offset 01: Item Type (Head, Body, etc.)
Byte Offset 02: Quantity Remaining
Byte Offset 03: Quantity Maximum

I guess they keep the maximum quantity with it, so they can stack items? I don't recall seeing this, but if they don't periodically consolidate your "Medicines X 2" into "Medicines X 4", they've completely wasted a byte of memory for every item. The "slot activator" code is really badly named. It's a count of items currently in the inventory array.

I think PCSX2 always maps the PS2's main RAM to 0x20000000, so it should be fairly easy to convert these codes to addresses you can watch in Cheat Engine. Just add 0x20000000 to the addresses.

literally
Posts: 2
Joined: Sun Jan 27, 2013 10:07 pm

Re: Messing around with Cheat Engine

Postby literally » Wed Jan 30, 2013 10:05 am

Sorry for the sluggish reply! I'm still playing through the game for the first time; things are getting very interesting with my castle upgrading to level 2.

In reply to your first post, no, I had pretty much no idea what I was doing with the NOP codes. Not only that, but messing around with them turns out to be completely pointless. The addresses I found were just for display on the character stats screen. Originally, I found 2 separate addresses for character stats and affinities, so I assumed that one of them was for display while the other was the real value. Turns out there's also a third address for both affinities and stats -- this last one I found is the base character stat/affinity value. So, one of the other values is for display on the stats screen, and I think the last one is an aggregate of the base stat/affinity value + stat/affinity increases from items (Holy amulet, Speed Ring, etc).

I'm pretty sure the code I was NOPing were accessing the character and item stat/affinity addresses, adding the values up and writing to the display addresses. I don't know enough to tell if this should be surprising, but it seemed to only cause crashes if I used the NOP function, loaded a savestate without using the "restore code to original state" function, then 1) entered a battle, changed areas, or opened the menu while in-game, or 2) tried to use the "restore code" after loading a savestate. In conclusion, yeah I don't know what I'm doing. That's the cool thing about emulators and save states though: no matter how badly my ignorant fumbling around screws things up I can go right back to where I started.

Anyways, one interesting thing I learned is that the Pale Gate Rune's 4th level spell, Empty World, uses the Holy affinity. The Suikoden V data on the Pale Gate Rune here on Suikosource says that it's non-elemental, and googling around for forum posts, most people seem to think it's Dark affinity (if any). I'm absolutely sure that Empty World is a Holy Affinity spell; I tested it with a character who had all affinities set to E and went down the list increasing one affinity at a time to A and casting the spell. The spell will do 0 damage if Holy affinity is E; D or above the damage is calculated normally, seeming to match the formula I found in some other thread here. Maybe the damage done isn't holy/is non-elemental, but the spell itself is Holy.

I haven't done any real testing of casting speed yet, I've been messing around with silly stuff like giving my party all Mage stats + armor, but infinite level 1 and 2 mana + chain magic. I'll probably get around to it eventually. I also want to figure out consecutive attack, continuous attack, counter rate, and crits, but there's a lot stuff covering that elsewhere in this forum that I haven't yet read.

And thanks for that link in your second post! I should be able to figure out how to edit my inventory from there.

User avatar
Pyriel
Webmaster
Posts: 926
Joined: Wed Aug 18, 2004 1:20 pm

Re: Messing around with Cheat Engine

Postby Pyriel » Wed Jan 30, 2013 1:08 pm

Now that I think on it, what you might be modifying is recompiled code that the emulator generated. That could explain why the game doesn't immediately crash. In any case, you're either modifying the emulator or its data, or through some stroke of luck you're modifying the program in the emulated PS2 RAM, and are making changes that will cause errors.

You can use the stat codes (CodeBreaker) on CodeTwink the same way as the item codes. That would at least confirm the addresses for you.

On the Pale Gate Rune, yeah, that's not surprising. It's always a mix of elements. I did the same thing for 2, but in reverse. I tweaked the enemies weaknesses/strengths and made them impervious or deathly weak to elements in turn. Somewhere on the disc should be a set of magic data can definitively answer the question, but as I recall, the files on Suikoden V disc are scrambled or compressed in some way. Although, you could probably find the array in memory, for a quick and dirty confirmation.

EasymodeX
Posts: 13
Joined: Mon Feb 25, 2013 10:08 pm

Re: Messing around with Cheat Engine

Postby EasymodeX » Tue Mar 26, 2013 10:55 pm

literally wrote:Turns out there's also a third address for both affinities and stats -- this last one I found is the base character stat/affinity value.


Based on your post it sounds like you found the 'source' affinity area, but to clarify:

The stat area has 3 copies of the affinities for no apparent reason, not 2. For some reason the cheat engine search is only showing two of those 3 for some reason. Kinda weird DX.

Also, observing with random equip/unequipping of a Lightning Ring, all 3 copies of the 'stat area' affinity data are updated. Maybe there's 3 copies for some other reason, but it doesn't seem to be gear. Strange.

Jowwy
Posts: 1
Joined: Sat Dec 03, 2016 12:03 pm

Re: Messing around with Cheat Engine

Postby Jowwy » Sat Dec 03, 2016 12:04 pm

Please share your CT files :D


Return to “Suikoden V”

Who is online

Users browsing this forum: No registered users and 4 guests