[Guide] Suikoden II Hex Editor

If you are stuck in the Dunan Unification Wars; or wish for more details on the gameplay systems, this is the place.
User avatar
Pyriel
Webmaster
Posts: 1227
Joined: Wed Aug 18, 2004 1:20 pm

Re: [Guide] Suikoden II Hex Editor

Post by Pyriel »

Whatever gets you there. If something doesn't need to be done repeatedly, or I'm just doing it for myself, I'll do what you did and find a long enough search string from the file so that searching the ISO gives me one or however many hits I expect. This change is one I'd just instinctively want to do as a cheat code. I might want to play around with the value, and not having to keep searching or modifying the ROM would be handy in that case. Furthermore, thanks to the game loading and unloading modules constantly, I probably wouldn't even need a reset code to turn it off. That's why I just stuck with the location it gets loaded to in the PSX's memory.

If you're thinking of doing a larger patch, you might want to look into the bug-fixes thread. The scripts in my GitHub are pretty good for ripping the disc apart and reassembling a patched copy. I partner it with the armips assembler and a custom version of the PPF format, but you can just as easily do binary find-and-replace in a script if you don't want to go that route.

As to spell damage multipliers, yeah, they're in there somewhere. It's been a long time since I looked at that, though. Given that there were no bugs to do with those modifiers, I didn't go into it too deeply, and I remember next to nothing about it. I don't think I documented any part of it, except maybe a passing comment in a disassembly. As to the spells themselves, they're in MAGI.BIN, and somewhere on the forum I described the structs for spells and runes.

Here's some old code. I think the threads have other information, like the purpose of some of the unknowns.

Code: Select all

#define NAMESIZE 21
#define DESCSIZE 32

/*
byte after description appears to be spell damage type:
0x22 - Enemy
0x23 - Heal
0x42 - Status

Next byte maybe spell delay? Actually, I think target indicator.

Byte 2 after SDT seems to be the spell element
0x01 - Fire
0x02 - Water
0x03 - Wind

byte 3 after element possibly indicates enemy affect?*/

typedef struct s2magic {
unsigned char name[NAMESIZE];
unsigned char desc[DESCSIZE];
unsigned char unk1;
unsigned char unk2;
unsigned char element;
unsigned char unk4;
unsigned char unk5;
unsigned char unk6;
unsigned char unk7;
signed int damage;
} T_S2MAGIC;

typedef struct s2rune {
unsigned char name[NAMESIZE];
unsigned char desc[DESCSIZE];
unsigned char slotmask;
unsigned char unk1;
unsigned char unk2;
unsigned char spells[4];
unsigned short cost;
} T_S2RUNE;

static const wchar_t *ElementName[10] = {
L"Non-Elemental"
, L"Fire"
, L"Water"
, L"Wind"
, L"Earth"
, L"Lightning"
, L"Holy"
, L"Darkness"
, L"Bright Shield"
, L"Unknown 1"
//, L"Unknown 2"
};
psychedelist
Posts: 68
Joined: Sat Oct 27, 2018 1:45 pm

Re: [Guide] Suikoden II Hex Editor

Post by psychedelist »

Thank you very much once again, i managed to find what seems to be fire, lightning, resurrection, blue gate, bright shield and dark sword spell damage data. There's one (hopefully last) thing that i really want to find, is there a basic price table for all items? And is there any way to replace Rare Find items in a shop, specifically rune shops in Muse and Gregminster? One thread mentions files MONSYOY as related to rune shops, but i couldn't find a single "57 20" (Fury rune) in them. Maybe those files are related to shop interface/logic rather than contents.
User avatar
Pyriel
Webmaster
Posts: 1227
Joined: Wed Aug 18, 2004 1:20 pm

Re: [Guide] Suikoden II Hex Editor

Post by Pyriel »

Sometimes they don't use the full item ID in lists that only contain one specific type of item. I don't remember offhand if that's the case with town shops, but in the castle shop (HMONSYOY.BIN) the various inventories had 02 as the type for crystals, just to keep things confusing. I don't know which files contain the town shop inventories, or how they're stored. I think I looked at rare finds when I was figuring out why Gregminster's one shop had a different inventory depending on where you were standing when you talked to the shopkeeper. I'll look through that later and see if I made any notes.

There's a table for the items, yeah. It occurs something like 60-80 times in various modules, and I know at least three of them are used for various purposes, so I can't really point you to a "master" list for it. It's pretty easy to find, if you just search for something like "Mega Medicine" by name. It'll be scattered everywhere. The prices are in there, or at least I'm pretty sure they are, just stored as 1/10 the actual value. So they store 50 (0x32) for Mega Medicine instead of the actual cost of 500.
KakCAT2
Posts: 12
Joined: Wed Jul 11, 2018 5:12 am

Re: [Guide] Suikoden II Hex Editor

Post by KakCAT2 »

Pyriel wrote: Thu Nov 01, 2018 5:16 pm Well, like I said earlier, the stat growth guide is out of date, and it was only ever based on a load of experimentation by the authors. They did the best they could, but with the random factors involved they were never going to get everything perfect. Looking at your tool, you get what I got from extracting the data, so I would imagine yours is right, even if it disagrees a bit with the main site's guide.

As I recall, the growth rates were in several files throughout the disc. How many places is your editor changing it? Or have you tested your edits to make sure they're working consistently? The usual pattern with this game is that data copied 20 times is used 99% of the time in one place, 18 of the remainder will just be cruft, and the one that's left is used in a special circumstance that doesn't even seem to require a privileged copy.
Sorry, I missed the answer in the previous post (I usually connect to suikosorce very late at night and... zZz)

Right now the editor is just 'read only' and using the data presented in this thread. Doing a quick search in the ISO it seems that the data from player stats is present 5 times, as long as the format is the same there should be no problem in overwriting that data 5 times instead of one. I'll try to have a go when I have some time, but of course thoroughly checks will be long to do.
User avatar
Pyriel
Webmaster
Posts: 1227
Joined: Wed Aug 18, 2004 1:20 pm

Re: [Guide] Suikoden II Hex Editor

Post by Pyriel »

Regarding rare finds, there's a block of data in the area module that defines what they are for the shop, and probably the chances that one will appear, how many can be stocked, etc.

http://herrvillain.net/suikoden/gs2/rarefinds.txt

I don't know all the ins and outs of it, but I was able to get the shop to stock Black Sword runes by editing this just now. And it does use 0x02 instead of 0x20 for the type.
psychedelist
Posts: 68
Joined: Sat Oct 27, 2018 1:45 pm

Re: [Guide] Suikoden II Hex Editor

Post by psychedelist »

Amazing, thanks. Would this affect both "inventories depending on direction" that are specific to gregminster? For Muse's Fury, i think 030_ARC\VC21.BIN might have it: 2nd, 3rd and 4th appearance of "02 57" look a lot like the sequence in your finding (just wonder why there're 3 of them, maybe separate entry for each possible appearance, so max quantity of 3). Will have to test it later (don't have a save there right now).

With your tremendous help, i found almost all i was looking for. Blacksmith upgrade prices would be still nice to have but not a must. I tried to search for them as a sequence (divided by 10 or 100), it didn't seem to be anywhere. Do you happen to have an idea how they might be stored?

Edit: for first post in this thread,
Others - 111FCDFC
This is for jowy's weapon (the "dummy" entries at the end use same data as him).
User avatar
Pyriel
Webmaster
Posts: 1227
Joined: Wed Aug 18, 2004 1:20 pm

Re: [Guide] Suikoden II Hex Editor

Post by Pyriel »

Blacksmith costs:
270_BOOT\EVENTDA1.BIN
270_BOOT\EVENTDA2.BIN
270_BOOT\EVENTDA3.BIN
270_BOOT\EVENTDA4.BIN
270_BOOT\EVENTDA5.BIN
270_BOOT\EVENTDAT.BIN
280_GAME\TABLE.BIN

All stored as 4-byte integers like one might expect (00011170 int32 or 70110100 byte-array for the top-end). I don't know if one is the canon copy and the others are unnecessary, or if different files are used in different places.

I'm pretty sure that finds list affects both inventories, yeah. The "two inventories" thing is a fairly high-level description, I think. The bug is that the scripts check different last-accessed times depending on how you talk to the Rune Master, timer 0xD from in front of the desk and timer 0 from anywhere else. I'm 90% sure it doesn't pull from a different pool of items; it's just that one last-accessed might be beyond the reset time, while the other isn't, giving you two chances to get the rare finds to open up. If both are in a state where a reset can occur, he'll have the same inventory from any location.
psychedelist
Posts: 68
Joined: Sat Oct 27, 2018 1:45 pm

Re: [Guide] Suikoden II Hex Editor

Post by psychedelist »

Thanks a lot, so they were stored as a sequence after all, i must have reversed the bytes incorrectly when tried to search for them. And the "no heal/support speed buff" suggestion worked for me too, it's wonderful.

I think the bestiary currently lists str as the stat used to determine counter str. It seems that enemies use a separate stat for attack str. It's often same as the one for counter, but not always. They also use a separate value to calculate the chance to hit you, and it's not what's listed as tech in the bestiary. Here's my current enemy structure map.

Code: Select all

3D25244C111212192400000000000000	NAME: CutRabbit
1400 STR (counter)
0600 MAG
0800 PROT
0600 MDEF
1400 TECH
1D00 SPD
0600 LUCK
2800 HP
0300 LEVEL
0000 ?
013C ?
0000 ?
1400 STR (attack)
1900 hit chance (tech?)
001E ?
1000 ?
2101 ?
0000
0000
0000
0000
0000
0228
0000
1900
0A00
0000
1000
4001
0000
0000
0000
9C21
1680
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000 fire (2nd byte)
0000 water and wind
0000 earth and lightning
0000 resurrection and dark
0000 bright shield and silence
0000 knockdown and sleep
0000 poison and death
0000 ?
3200 Potch per
5F20 Drop 1, Technique Rune
D768 Drop 2, Cream Stew x 2
0000 Drop 3, Nada
0502 Probably probabilities possibly.
00 ibid
20
2000
3000
If the last bytes are really the probabilities, has it been figured out how to decipher them? Just curious because they're listed in the bestiary.

I know that the contents of IKKI and WAR folders are related to duels and war battles, but once again i don't know anything about their data structures, such as hp/str/def of your duel opponent or an enemy war unit. Pyriel, would you happen to know anything about it?
User avatar
Pyriel
Webmaster
Posts: 1227
Joined: Wed Aug 18, 2004 1:20 pm

Re: [Guide] Suikoden II Hex Editor

Post by Pyriel »

It's just chances out of 255 for the drops. The sum of all the drops needs to be 255 or less, because the game will do a running sum from first to last, so it rolls once, and then roll < first chance gets the first drop, otherwise roll < (first chance + second chance) gets the second, and finally roll < (sum of all chances) gets the third.

I know some, but not a lot about the war battles. About 75% of them are scripted, and there are no bugs with them apart from the missing music which was caused by a much broader issue with how the NA disc was mastered. Not something I felt a lot of need to look at. There are lists of GameShark codes that may give you a better idea what to look for than I could. I'm 90% certain all the variables the codes hit are just space pre-allocated in one of the war modules. The codes will at least indicate the order of things like attack and def for particular units.

On the duels, I'd lay money that stats aren't stored in those modules. All the duel opponents are named characters with portraits and space in the global character array. Their stats are most likely there, and with the exception of maybe Jowy and Flik, they're probably initialized when a new game is launched or when the game is booted, and basically left that way forever, or at least until the duel. So BOOT.BIN or something of the sort. Wherever the startup data is for a new game (I forget).
psychedelist
Posts: 68
Joined: Sat Oct 27, 2018 1:45 pm

Re: [Guide] Suikoden II Hex Editor

Post by psychedelist »

Thanks for the explanation. I saw there's an array of all character names, but i doubt i'll be able to figure out the data associated with them (if there's any), but that's fine.

Now I'm trying to change pre-located items on a stage. For example, Kobold Village (080_arh\vh03.bin), Exertion rune (67 20). There's one instance of 67 20 and one instance of 20 67, which stand out (don't look like part of opcodes/whatever). Modifying one of them results in the item appearing as an empty string/garbage data. Modifying both of them makes the item look like... Exertion rune just like before - until you save and load your game. If the item was changed to another rune (e.g. Kindness) and you try to embed it before save/load, it'll appear properly as Kindness once installed, but go back to Exertion once uninstalled. It's like my changes make the item different on the inside, but it remains old on the outside. I tested all of this with Friendship in South Window, Kindness in Lakewest and Double-Strike (located in a chest) in Tinto Mines, it's same story everywhere.

I tried to look for more instance that could be related - 02 67, 67 02, 20 00 67, 67 00 20, 02 00 67, 67 00 02. But none of them worked so far (will take a long time to test all). Is there any hope for me to modify a pre-located item properly?
User avatar
Pyriel
Webmaster
Posts: 1227
Joined: Wed Aug 18, 2004 1:20 pm

Re: [Guide] Suikoden II Hex Editor

Post by Pyriel »

The game should have a copy of the base item object with all its stats and the like stored in the file. If you need to add one, good luck, it'll be a massive pain. If you're replacing one, you'd probably just have to overwrite it with the appropriate item.

As a general rule, the game tries to only cache details for items it needs. It'll behave badly or even crash if you write in an item it doesn't have details for (e.g. with a code), and they embed details for chest items in the modules to prevent that when items are found in chests and the like. There is a code, which possibly makes the game update the primary cache constantly (not sure), that you can find at CodeTwink. I'm not sure that'll help much, though. The items you get from chests are embedded in scripts, and there's no reason to think the game would scan them when looking for things to cache. It might be the best it can do is eliminate the need for a save and reload.

Looking at the disc, VH02 has a copy of Kindness, but no Exertion, and VH03 has Exertion but no Kindness. As it happens, I already had a disassembly of VH03 for some reason. I only see one relevant script (it does go item ID, type, with the type being set in the upper nibble instead of the lower). I'll post it below. Using the other ordering, I found some random data, one pointer to unrelated text, and as 20 67 happens to be "p!" a lot of talk about "sheep!" and other assorted dialogue.

RAM:80111730 unk_80111730: .byte 0x17 # DATA XREF: RAM:80112C50o
RAM:80111730 # Popup text
RAM:80111731 .byte 8 # array 8, entry 4: "{Delay=0} Large mortar{Pause=6}!!"
RAM:80111732 .byte 4
RAM:80111733 .byte 0x65 # e # Play sound 4-7
RAM:80111734 .byte 4
RAM:80111735 .byte 7
RAM:80111736 .byte 0x65 # e # Again
RAM:80111737 .byte 4
RAM:80111738 .byte 7
RAM:80111739 .byte 0x1E # Add Exertion rune
RAM:8011173A .byte 3
RAM:8011173B .byte 4
RAM:8011173C .byte 0
RAM:8011173D .byte 0x67 # g
RAM:8011173E .byte 0x20
RAM:8011173F .byte 0
RAM:80111740 .byte 0x29 # ) # Make decision.
RAM:80111741 .byte 2 # 2 options.
RAM:80111742 .byte 2 # 2/3
RAM:80111743 .byte 3
RAM:80111744 .byte 0xFF
RAM:80111745 .byte 2 # Option 2: Set bitflag 0x32, bit 2.
RAM:80111746 .byte 9
RAM:80111747 .byte 0x32 # 2
RAM:80111748 .byte 4
RAM:80111749 .byte 0xFF
RAM:8011174A .byte 0xFE # ¦
RAM:8011174B .byte 0xFF
RAM:8011174C .byte 3 # Option 3: Exit
RAM:8011174D .byte 0xFF
RAM:8011174E .byte 0xFE # ¦
RAM:8011174F .byte 0xFF
RAM:80111750 .byte 0xFE # ¦
RAM:80111751 .byte 0
RAM:80111752 .byte 0
RAM:80111753 .byte 0
User avatar
Pyriel
Webmaster
Posts: 1227
Joined: Wed Aug 18, 2004 1:20 pm

Re: [Guide] Suikoden II Hex Editor

Post by Pyriel »

Oh, here's the data for the Exertion Rune, just in case.

RAM:8011AD7C unk_8011AD7C: .byte 0xA8 # ¿ # DATA XREF: RAM:8011ADF8o
RAM:8011AD7C # * Exertion
RAM:8011AD7D .byte 0x10
RAM:8011AD7E .byte 0x3F # ?
RAM:8011AD7F .byte 0x28 # (
RAM:8011AD80 .byte 0x15
RAM:8011AD81 .byte 0x22 # "
RAM:8011AD82 .byte 0x24 # $
RAM:8011AD83 .byte 0x19
RAM:8011AD84 .byte 0x1F
RAM:8011AD85 .byte 0x1E
RAM:8011AD86 .byte 0
RAM:8011AD87 .byte 0
RAM:8011AD88 .byte 0
RAM:8011AD89 .byte 0
RAM:8011AD8A .byte 0
RAM:8011AD8B .byte 0
RAM:8011AD8C .byte 0
RAM:8011AD8D .byte 0
RAM:8011AD8E .byte 0
RAM:8011AD8F .byte 0
RAM:8011AD90 .byte 0
RAM:8011AD91 .byte 0x3B # ; # ATT increases each turn, WPN
RAM:8011AD92 .byte 0x4E # N
RAM:8011AD93 .byte 0x4E # N
RAM:8011AD94 .byte 0x10
RAM:8011AD95 .byte 0x19
RAM:8011AD96 .byte 0x1E
RAM:8011AD97 .byte 0x13
RAM:8011AD98 .byte 0x22 # "
RAM:8011AD99 .byte 0x15
RAM:8011AD9A .byte 0x11
RAM:8011AD9B .byte 0x23 # #
RAM:8011AD9C .byte 0x15
RAM:8011AD9D .byte 0x23 # #
RAM:8011AD9E .byte 0x10
RAM:8011AD9F .byte 0x15
RAM:8011ADA0 .byte 0x11
RAM:8011ADA1 .byte 0x13
RAM:8011ADA2 .byte 0x18
RAM:8011ADA3 .byte 0x10
RAM:8011ADA4 .byte 0x24 # $
RAM:8011ADA5 .byte 0x25 # %
RAM:8011ADA6 .byte 0x22 # "
RAM:8011ADA7 .byte 0x1E
RAM:8011ADA8 .byte 0x65 # e
RAM:8011ADA9 .byte 0x10
RAM:8011ADAA .byte 0x51 # Q
RAM:8011ADAB .byte 0x4A # J
RAM:8011ADAC .byte 0x48 # H
RAM:8011ADAD .byte 0
RAM:8011ADAE .byte 0
RAM:8011ADAF .byte 0
RAM:8011ADB0 .byte 0
RAM:8011ADB1 .byte 0
RAM:8011ADB2 .byte 7
RAM:8011ADB3 .byte 0
RAM:8011ADB4 .byte 0
RAM:8011ADB5 .byte 0
RAM:8011ADB6 .byte 0
RAM:8011ADB7 .byte 0
RAM:8011ADB8 .byte 0x8C # î
RAM:8011ADB9 .byte 0xA
RAM:8011ADBA .byte 0
RAM:8011ADBB .byte 0
psychedelist
Posts: 68
Joined: Sat Oct 27, 2018 1:45 pm

Re: [Guide] Suikoden II Hex Editor

Post by psychedelist »

It worked, thank you million times once again. Can't believe i didn't try to search for the item names in those files. It seems you do need to modify the outstanding instance of "20 67" though (surrounded by 00s). The item was still appearing as an empty string/garbage without this change.
User avatar
Pyriel
Webmaster
Posts: 1227
Joined: Wed Aug 18, 2004 1:20 pm

Re: [Guide] Suikoden II Hex Editor

Post by Pyriel »

I assume that was this block, which I missed last night.

RAM:8011ADF4 byte_8011ADF4: .byte 0x20 # DATA XREF: sub_8010EB8C+4r
RAM:8011ADF4 # sub_8010EB8C+18o
RAM:8011ADF5 .byte 0x67 # g
RAM:8011ADF6 .byte 0
RAM:8011ADF7 .byte 0
RAM:8011ADF8 .word unk_8011AD7C # * Exertion
RAM:8011ADFC .byte 0x50 # P
RAM:8011ADFD .byte 0x37 # 7
RAM:8011ADFE .byte 0
RAM:8011ADFF .byte 0
RAM:8011AE00 .word unk_8011ADBC # Recipe #13
RAM:8011AE04 .byte 0xFF
RAM:8011AE05 .byte 0xFF
RAM:8011AE06 .byte 0
RAM:8011AE07 .byte 0
RAM:8011AE08 .byte 0
RAM:8011AE09 .byte 0
RAM:8011AE0A .byte 0
RAM:8011AE0B .byte 0

I'd been kind of wondering how they actually ran down the items, since they don't use the full array of descriptions, and they don't use relative positions for the items in the module within the scripts. It appears this is how they resolve it, by searching for IDs, and they have to embed functions in every module that needs to perform this task, which jibes with my notes on command 0x1E that say it calls custom area functions, but is mysteriously used for treasure. Which seems like something so commonplace it'd have its own set of commands or reusable systems in place.
psychedelist
Posts: 68
Joined: Sat Oct 27, 2018 1:45 pm

Re: [Guide] Suikoden II Hex Editor

Post by psychedelist »

Yeah, it was that block.

There was already a lot of research on the Kindness bug done by you, so I hope it won't be too much to ask, would you happen to know the file where Kindness rating calculation is done, and maybe share a disassembly of the place where the 128 max value bound is enforced? I'm hoping to be able to change that max value.
Post Reply