• Topic Archived
You're browsing the GameFAQs Message Boards as a guest. Sign Up for free (or Log In if you already have an account) to be able to post messages, change how messages are displayed, and view media in posts.
  1. Boards
  2. Romance of the Three Kingdoms II
  3. Hex-editing the registry of generals

User Info: ServantOfMagnus

6 years ago#1
Newly registered user, veteran of ROTK2

Sorry if this has been posted anywhere else, but it seems to be unknown as of as recently as a week ago.

And thanks to DragonAtma and Marsil79 for all of their work that made this possible.

How to edit the general registry, or, what the values from 17D76 to 19BB5 do:

As you know, each general has 22 consecutive columns, starting with Cao Cao from 17D76 to 17D8B.

1. If the general is not active at the beginning of every scenario he is in, this is the year he will be available in. Unlike birth years, does not need to be altered by 1.

2. Haven't looked at this one yet. DragonAtma says it's a family or autojoin code. I suspect the latter, based on what everything else here does. (Are we sure Fei Wei and Guo Youzhi never autojoin Liu Bei? Maybe we're usually at the max count of 256 generals when they become available, and by the time room is cleared Liu Bei is dead???)

3. The province the general is active or hidden in, or will become available in in a later year, in the first scenario. FF means he will never be available when playing the first scenario.

4. Same as 3, but for scenario 2.

5. Same as 3, but for scenario 3.

6. Same as 3, but for scenario 4.

7. Same as 3, but for scenario 5.

8. Same as 3, but for scenario 6.

9 & 10. The general's officer number. Very important. Two bytes; 9 is the 1's byte, 10 is the 256's byte (just like for province data). So column 10 is always either 00 or 01.

11 & 12. Tells the game how to populate the provinces with generals at the start of the first scenario. Full explanation below.

13 & 14. Same as 11 & 12, but for scenario 2.

15 & 16. Same as 11 & 12, but for scenario 3.

17 & 18. Same as 11 & 12, but for scenario 4.

19 & 20. Same as 11 & 12, but for scenario 5.

21 & 22. Same as 11 & 12, but for scenario 6.

Now, a walkthrough for what the game does with the code in columns 11 - 22. I will use the first scenario for my explanation. It's easier if you have a spreadsheet with all of the code in 11 - 22 by general.

Province 1 is totally empty at the start of the first scenario. No active generals, no hidden generals (Gongsun Yuan isn't available until much later.) Same with province 2.

Province 3 is the first province with a general, and he is Gongsun Zan. Gongsun Zan's code for scenario 1 is 13 94. The 13 tells the game that Gongsun Yue comes next (his officer # is 13 00). The second byte contains multiple values, which break down as follows:

1 If the next general has a 01 for his second byte, the 1 will appear here.

4 is a command to start the set. The first general in a province always has this. So does the first hidden general in a province, at the start of the scenario.

8 is a command to end the set. The last general in a province always has this. So does the last hidden general in the province, at the start of the scenario.

10 makes the general a governor.

20 makes the general hidden and searchable at the start of the scenario.

40 makes the general an advisor.

80 makes the general a ruler.

2 is only used once per scenario. It tells the game that the initial population of generals is done, and the game is ready to start.

So that explains the 94 for Gongsun Zan (4 + 10 + 80).

Gongsun Yue's code is 01 08. The 8 tells the game this is the last (active) general in this province. The 01 tells it the next general is 01 00, Liu Bei, who is the first general in province 4. If there were any hidden generals in province 3 at the start of the scenario, they would come next, instead of Liu Bei. But there aren't (Zhao Yun isn't available until the year 190).

And it seems I will have to continue in the next post.

User Info: DragonAtma

6 years ago#2
Aha! I took a look at it, but I couldn't figure out how to change officers without causing chaos (such as replacing multiple leaders with a 126/8/109 Liu Biao and a gamecrash in the first month). Now, maybe I can change things properly!

As for column 2, yes, that's definitely who they'll autojoin. Thing is, Fei Wei and Guo Youzhi join in 210 and 216 (respectively) , while you can fill up all 256 slots as early as 202. So unless you decide to be Captain Buzzsaw and behead all the Xiahou Maos and Cai Hes of the world, it can be a long time before those two show up.

On a side note, it almost certainly means that officers can only autojoin officers 0-254. Of course, if you want to have more than 254 officers with someone autojoining them, it'd likely be a very strange mod!

EDIT: The earliest for hitting the maximum of 256 generals is only year 202 in scenario 1. In scenario 2 it's 203, in scenario 3 it's 210, in scenario 4 it's 230, and in scenarios 5 & 6 there aren't enough generals to hit the max, These numbers assume, however, that nobody dies -- even though some officers (such as Sun Jian) are fated to die young, and others may reach 67 well before the max occurs...
Nagas on a plane! ^_^

User Info: ServantOfMagnus

6 years ago#3
Continuing the explanation of the code in columns 11 - 22:

Liu Bei's code is 28 94. The 94 is the same as it was for Gongsun Zan, and the 28 means Guan Yu is next. Guan Yu's code is 29 00. 29 00 means Zhang Fei is next, and there are no other instructions for Guan Yu. Zhang Fei's code is 39 08. The 08 means he is the last (active) general in the province. The 39 indicates Han Sui, # 39 00, is next.

There are no generals hidden in province 4 at the start of the scenario, and there are no active generals in province 5 at the start of the scenario. But, Han Sui is hidden in province 5 at the very beginning of the scenario, so he comes next. His code is 03 2C. 2C breaks down as 4 + 8 + 20. Han Sui is the first general in this set (generals hidden in province 5 at the start of the scenario), hence the 4, and he is also the last general in this set, thus he also needs the 8. The 20 means he is hidden (at the start of the scenario). If he didn't have the 20 here, he would be active instead of hidden. But, the C is 4 + 8, meaning he would be the only general in the province. If he is the only general in the province, he needs to be the governor. So his code would be 1C. However, it would also be necessary to code which ruler controls province 5 (a different section of the code, as you know.)

The 03 in Han Sui's code tells us Yuan Shao is next. Province 6 proceeds much as before, so I will jump to the last general in the active province 6 set, Feng Ji. His code is 55 08. The 08 signifies the end of this set, and the 55 brings up Zhang Nan. Zhang Nan is also in province 6, but he is a hidden general. It is important to note that the active generals and the hidden generals in each province are in separate sets (I'm not sure I've been using 'set' in a correct, technical, sense, but I hope my meaning is clear.) So the last active general in a province needs an 8, and the first hidden general needs a 4, even if they are in the same province.

Zhang Nan's code is 70 24. The 20 means he is hidden, the 4 means he comes first, and the lack of an 8 in the second byte means there are more hidden generals in this province (at the start of the scenario). 70 is Xu You, whose code is 74 20. That the second byte is 20 instead of 28 tells us that there will be another hidden general. He is Jiang Yiqu, officer # 74 00. Jiang Yiqu's code is 0B 28. 28 means on to the next province, and 0B calls for Hain Fu.

When you get through all of the provinces, you find that the last general in the first scenario is Gao Ding, who is hidden in the unruled province 36 at the beginning of the scenario. His code is 00 2E. Normally, a 00 would mean Cao Cao, # 00 00, or Ma Zhong, # 00 01, is next, but the second byte is 2E. That is 2C + 2. The 2C is the same as it was for Han Sui - hidden general, only general in the province, but the 2 tells the game that it is done populating the provinces with generals. Gao Ding is also the "last" general in scenarios 2 thru 4. In scenario 5, it is Lu Ji, whose code is 00 0A. 0A is 8 + 2, meaning he is an active general (no 20), the last general (08), in a province with more than one active generals (otherwise it would be C + 2 instead of 8 + 2), and the 2 tells the game it is finished. In scenario 6, the last general is Zhang Wen, with the same 00 0A code.

Now for the generals who are not available at the beginning of the scenario, but will become so later. These are easier because there is only one element in the second byte code; it is either 00 or 01 depending on the officer # of the general who comes next. There is no longer a need for the 4 or 8, nor the 20, because none of these generals are either active or hidden at the start of the scenario. There can be no 10, 40, or 80, either. There is also no 2; more on this with regard to Sun Liang later.

I find it easiest to think of the code for these generals, who are not available at the beginning of the scenario but will become so later, as a queue.

It appears I need a third post : - )

User Info: ServantOfMagnus

6 years ago#4
Continuing the explanation of the code for generals who are neither active nor hidden at the start of the scenario:

These generals are chained in the queue by the year they become available in. Up until a few minutes ago : - ) I thought I knew exactly how it worked, but, now that I see my error, I should mark this explanation as tenative, pending further review and / or experimentation.

I had thought that the chain started with the lowest-numbered province, as it did with the generals who are available at the beginning of the scenario. So I had thought that the first general was Zhao Yun, as, of the generals who become available in the year 190, he locates in the lowest-numbered province of the group (province 3). I had thought this because at the time I had just figured out how the code works for the active and initially hidden generals, so I didn't look at the later generals more closely when at first glance it seemed to work the same way. Zhao Yun (province 3, year 190) brings up Chunyu Qiong (province 6, year 190), who brings up Bao Xin (province 9, year 190). So I thought I had it. But, upon closer inspection of my data, the province doesn't seem to matter. The chain actually starts with Gan Ning (province 21, year 190). However, it does go through all of the year 190 generals before moving on to the year 191 generals. I don't really want to follow the chain all the way through to the end right now to verify, but I do want to finish this post, so I'm going to say 'good enough' for now.

The important thing is that the code for each general is just the officer # of the next general in the queue - none of the other stuff in the second byte. No code for changing provinces, and no code for changing years. The second byte of the code contains only the second byte of the next general's officer #, which is either 00 or 01. (Before, it always contained that, too, but it had all of the other stuff in addition. Which is why the second byte there might be 00 or 01, 08 or 09, 14 or 15, 20 or 21, 24 or 25, 28 or 29, 40 or 41, 94 or 95, 1C or 1D, and 2C or 2D. It just depends on whether the next general's officer # has a 00 or a 01 in its second byte.)

So this queue is pretty easy, at least until you get to the end, when a bit of a conundrum surfaces. Eventually, in every scenario, the chain in time brings you to the last general, Sun Liang. All roads lead to Sun Liang. His first byte code is FF, but this is unlikely to refer to an officer #, just as the first byte code for the last general in the scenario start chains (Gao Ding in 1-4, Lu Ji in 5, Zhang Wen in 6) is 00, but it doesn't have anything to do with Cao Cao or Ma Zhong. In any case, we know there are no more generals.

Sun Liang's second byte code is also FF. This is more problematic, because we don't know how to tell the game that the queue of later-year generals is finished. While the FF seems to do the job, it also seems to come at the expense of Sun Liang NEVER showing up. I had hypothesized that replacing the FF with a 02 *might* do it, as with the earlier chain. (At least, that would be the only guess I would have.) But that would have to be tested by playing the game until Sun Liang is supposed to be available. You can move that date up, of course, but you have to move up several other generals, too, or else you mess up the queue. Of course, if it's just Sun Liang you're after, you can place him earlier in the queue, by changing his code and that of the general before him, but that doesn't answer the question we're really after, which is whether the 352nd general, whoever he (or she) may be, can ever appear in the game. Anyway, I haven't run any experiments on this.

However, what I did do was bring all of the later generals (those who aren't available until after 220) into the game by placing them in the chain of active/hidden generals for scenario 6.

More on this in a fourth post.

User Info: ServantOfMagnus

6 years ago#5
Continuing towards the answer to the question, "Can you ever get all 352 generals in the game?":

Right now, I think the answer is, sort of.

There are ten generals who don't appear until after 220: Jiang Wei, Liu Chan, Sun Deng, Sima Shi, Zhuge Dan, Sima Zhao, Zhong Hui, Cao Shuang, Sun He, and Sun Liang. I went ahead and put all of them in the active / hidden general chain for scenario 6. I didn't change their provinces, but I'm sure I could have. I also didn't make any of them hidden, but again, that shouldn't be a problem. I did make Jiang Wei start as the governor of province 29, and I did the same for Zhuge Dan in province 8. [Just to show how easy it is to miss something when you're making a lot of changes, when I first did this, I had coded Cheng Wu correctly (the last general in province 7), AA 08 changed to 5A 08, and Zhuge Dan (governor and first general in province 8) correctly, 5B 01 changed to AA 14, but I forgot to change Chen Jiao (the original governor of province 8) from 9D 14 to 9D 00. So because Chen Jiao was still governor Zhuge Dan didn't show up. Then I fixed that, but since I didn't bother to change the starting loyalties from FF for these ten generals (in one of the other sections of the code), they all started with 255 loyalty. Which was not good for Zhuge Dan, who promptly pulled a Gongsun Yuan : - ) But everything seemed to work fine with the changes I did make.

So, since I don't know how to end the "future general" queue, the only way I can get the 352nd general in the game is to have him available (active or hidden) at the start of the scenario. Which means I've effectively eliminated the "future general" queue for that scenario (note that in scenario 6, that queue contains only those ten generals, which is why I chose that scenario to edit).

Therefore, with what I know now, if I create my own scenario, I have to choose between having the 352nd general never appear, or having no "future general" queue. I would choose to live without officer # 5F 01 (general no. 352) in the first five scenarios, and to omit the "future general" queue in the sixth scenario. That way, if I do all six scenarios, I can get each of the 352 generals in at least one scenario. (Of course, no "future generals" could come after 220 in any scenario, because the general's active year number is the same for all scenarios, and all generals would have to be active by 220 for scenario 6.)

With what is now known, I can more or less fully create my own scenarios. I can:

Edit the number of playable rulers per scenario, and who the ruler of each clan is (0F96C - 0F9DD)

Edit the order for province colors (0FE3A - 0FEB1)

Edit the province data, including what clan, if any, rules it (0FF70 - 11775)

Edit the generals' starting loyalties (11E38 - 12677)

Edit the generals' birth year, portrait, and other properties (12678 - 132D7)

Edit the generals' intelligence, war, and charm stats (132D8 - 136F7)

Edit the generals' names (14A44 - 16042)

Edit who appears when and where in what scenario (17D76 - 19BB5)

I have not seen the province colors posted here, but I may have missed it. I will post in the next message just in case.

User Info: DragonAtma

6 years ago#6
Actually, I think Sun Liang may autojoin in..... 255 AD. IIRC he'd autojoin in 256 and 257 as well. Historically he was born in 243, became emperor in 252, was deposed in 258, and died in 260.

...Hmm. If you enter the cheat codes 7EE006xx and 7EE007yy you can change the year; in scenario 6, Sun Liang, Sun Deng, and Sun He will autojoin Sun Quanin years 255, 256, 257, 258, 259, 260, 261, 266, 276, and 306... despite their ages. Only Sun Deng and Sun He autojoin, however, if you set it to 254. For the curious, xx = 1s and yy = 256s.

Now, if you choose scenario 1 (but still shark the year), Sun Quan would be too old in 254 and doesn't autojoin.... so neither do his sons. But many people are alive at first, and boom, 256 officer limit. However, when january rolls around (reset back to 254 by the cheat code), massive swarms of people die (for me, Sun Jian and six of his other eight officers died, as did eight of the other eleven rulers). For some reason, even after six months of trying, Lu Meng, Zhu Zhi, and Zhou Tai (the three officers available) were unable to search out ANY of the three Sun Quan sons. I handed the game over to the CPU. So this needs a deeper look...

Still, thank you for your work; this is likely the breakthrough that lets us make modding attempts a reality!
Nagas on a plane! ^_^

User Info: ServantOfMagnus

6 years ago#7
Just in case this is not known, here is how to edit the province colors:

The data is located at 0FE36 to 0FEB1 (it starts with BC 00 0B 0F). There are twenty columns for each scenario. As I write this, it is occurring to me that what I don't know could be important.... but I will post what I have.

1. I'm looking at these and the code is always one year before the start of the scenario (scenario 1 is BC, scenario 2 is C1, scenario 3 is C8, scenario 4 is CF, scenario 5 is D6, and scenario 6 is DB). Could changing these change the scenario start year? Will have to check into this...could be awesome : - )

2. Always 00

3. Always 0B

4. Seems to be the total number of rulers who start the scenario. (scenarios 1 & 2 are 0F, scenario 3 is 08, scenario 4 is 0A, scenarios 5 & 6 are 04)

5. The color of the first clan in the order; the order is set out in a different section of code (0F96C - 0F9DD)

6. The color of the second clan in the order.

And so forth, concluding with

20. The color of the last clan in the order, by default always the new ruler color (07).

The color codes are:

00 Dong Zhuo / Lu Bu color

01 Yuan Shao / Meng Huo yellow

02 Zhang Lu / Tao Quian color

03 Wei purple

04 Yuan Shu / Gongsun Yuan : - ) pink

05 Ma Teng purple

06 Shu green

07 New Ruler blue

08 Liu Biao blue

09 Zhao Fan / Wang Lang blue

0A Wu red

0B Liu Yan / Zhang orange

0C Han Xuan / Kong Rong gold

0D Liu Yong color

0E Li Jue / Hain Fu green

0F Gongsun Zan color

The only experiment I've done with these is to change all of the colors of the rulers in the first scenario. It worked exactly as I expected, except that I had put color 04 in the last position, but when I created a new ruler, he still had color 07, which I had given to Cao Cao. So both Cao Cao and the new ruler had color 07, and color 04 did not appear at all (at least, not at the start of the game.) Having two rulers share the same color didn't seem to cause any problems, though. I know almost nothing about the code for all the New Ruler stuff (only how to use their portraits for other generals), so maybe that matters. Alternatively, I suppose I could try changing the 0F in column 4 to a 10, but that may cause other problems, at least from my experience with changing some of the ruler / clan code in 0F96C - 0F9DD.

Note that all 16 colors are ordered for each scenario, regardless of the number of clans / rulers that start the scenario. My understanding is that this comes into play when a governor rebels (in the lingo we've used since SNES days, when he "starts his own clan" : - ) I believe the color for the newly created ruler / clan is always the first available one in the queue. And I have seen a rebel get the new ruler color when the other 15 were already currently in use. But I'm not 100% sure about that queue, because the color order is almost identical for scenarios 1, 2, 5 and 6. (There's only one swap between two consecutive colors from scenario 1 to 2.) Only scenarios 3 and 4 are much different, especially 4, in which Kong Rong gold gets elevated to a playable color. (Can I get the paint store to mix me up some 'Kong Rong gold' for my walls? : - )

Will have to do more experiments here, but this is a start.

User Info: DragonAtma

6 years ago#8
IIRC, the first & third byte are actually a month before the starting month. So when you choose a force in scenario 1, for example, it's december 188. After you choose a force, it advances a month...

Table for force color orders:

Cao Cao..........1......1......1........1.........1.......1
Liu Bei..............2......2......2........2.........2.......2
Sun Jian...........3......3......3........3........3.......3
Yuan Shao.......4......4......4.......(11).....4.......4
Yuan Shu..........5......5....(9).....(12)....(5)....(5)
Ma Teng............6......6......6........4.......(6)....(6)
Liu Yan..............7......7......5........5.......(7)....(7)
Liu Biao............8......8......8......(13)....(8)....(8)
Dong Zhuo.......9......9....(10)...(14)....(9)....(9)
Gongsun Zan.10....10...(11)...(15)...(10)..(10)
Tao Quian........11....12.....7.......10....(11)..(11)
Hain Fu............12....11...(12).....6.....(12)..(12)
Kong Rong......13....13...(13).....7.....(13)..(13)
Wang Lang......14....14...(14).....8.....(14)..(14)
Liu Yong...........15....15...(15).....9.....(15)..(15)
New Ruler......(16)..(16)..(16)..(16)..(16)..(16)

So if a virulent strain of Lu Buism breaks out in scenario 6, the first rebel (likely Gongsun Yuan) is Yuan Shu's color, the second is Ma Teng's color, the third is Liu Yan's color, etc.

And yeah, forces in the game always have priority because their order is lower. If Cao Cao is wiped out, for example, the next rebellion WILL use his color because it's always first in the order. Many of you know this, but the game can only handle sixteen forces at once; if all sixteen are in play, even Lu Bu will stay loyal as governor..... up until poor lonely Wang Lang gets wanglanged, at which time Lu Bu will promptly rebel. >_>

For those with palette interest, the palette order for the map is:
Darker ocean blue
Lighter ocean blue
Light green (plains)
Light green (mountains)
Middle green
Darker green
Wang Lang blue
Sun Jian red
Yuan Shu pink
Liu Bei green
Kong Rong orange
Yuan Shao yellow
Cao Cao purple
New Ruler lightblue
Nagas on a plane! ^_^

User Info: ServantOfMagnus

6 years ago#9
A couple more things:

I have not been able to determine whether it matters what a ruler's initial loyalty (in code 11E38 - 12677) is set to. In the code, it is always either 00 or 64, but there doesn't seem to be a pattern explaining why it should be one or the other. In scenarios 3 & 6, all rulers are coded as 64. In scenarios 4 & 5, all rulers are coded as 00. In scenarios 1 & 2, it varies, with no discernible reason. I tried changing some of them; it didn't seem to affect anything, at least not at the outset. This was true whether I chose 00, 64 or something else (I tried 32).

It may be that this value is irrelevant because it is overriden by the general being a ruler. Still, why would they not use the same value for all rulers? As of right now, I'm assuming that the value doesn't really matter for a ruler, but if someone discovers otherwise, that would be a good thing to post.

Also, DragonAtma pointed out that there are four different color palettes for the generals' portraits, and there was a very handy .png file with all of the unique general portraits (excepting the new ruler and marriage daughter portraits, the latter awesomely useful for adding female generals to a mod.) It was noted that some of them were not in the correct palette. Sometimes, this was very cool - the orange Chen Qun, Li Yi without the bold red helmet, a more colorful Sun Yi, Xiahou Ba in Shu green, etc. And it would be very cool to have more portrait flexibility in a mod.

So, does anyone know if you can change the color palette used for a general's portrait in the game?

I hope to start more work on the generic portraits. Some of the pieces they didn't use in the game are pretty cool (I'm thinking turban/bandana on the old guy). It seems like they just gave us dozens of variations on Zhu Zhi and Xiahou Mao : - ) I've only got the main eight types of face, and four subtypes for each, cataloged so far. If anyone has already done a lot of work here, that would make a really good post, too.

Again, thanks to everyone who started all the work on hex-editing ROTK2. It's a lot easier to build on the work of others than start from scratch!

User Info: DragonAtma

6 years ago#10
Oh, many of them definitely look good in other palettes; it's almost a necessity, seeing as all four get applied to the stock officers.

I've looked for palette data before, but I don't think I've found it yet. it's gotta be somewhere, though. The 12678 block contains the facetype, but not the palette...

http://www.gamefaqs.com/boards/588628-romance-of-the-three-kingdoms-ii/66195426 has a list of which unique is in each palette, including all new rulers but not the daughters.

All palettes have the follower general format (with hues ABCD changing by palette):
Dark grey
B, dark
B, mid
B, light
C, dark
C, light
Skin, very light
Skin, light
Skin, medium
*Skin, dark
D, dark
D, medium
D, light

Sun Jian's ABCD: purple, blue, green, red->yellow
Yuan Shao's ABCD: greenish, red->yellow, blue, off-yellow
Zhuge Dan's ABCD: blue, pink, off-gray, skin->yellow
Wang Can's ABCD: blue, green, red->orange, purple.

In addition, Wang Can palette's darkest skintone gets a definite purple hue, so it matches the purple betetr than the other skintones. It's not THAt far off, thoguh, so it';s still used for skintone shading/outline.

There are three main problems with off-palette graphics:
(1) They like to use the local red for lips instead of skintone. Therefore, many people have blue or green lips in another palette XD
(2) Sometimes they use a different-but-similar colorgroup for shading. Zhang Fei's hat, for example, is red with skintone shading... and winds up as blue with skintone shading in other palettes, which doesn't l;ook good.
(3) Even the oldest people have some shading in their beards. Therefore, Huang Zhong, yan yan, etc. have issues with some palettes. Grey (Zhuge Dan) and blue (Yuan Shao) look fine; red (Wang Can) and green (Sun Jian) not so much.

The first is easily fixable, the second is doable, while the third would have to be redrawn for every old guy (sorry).

On a side note, Sun Deng and Sun He look like edits of each other (compare Sun Deng's left collar to Sun he's right collar!), while I get the feeling some officers (Zhang Hong, Shen Pei, Zhuge Jin, etc.) are either variants of one face or used to be a generic facetype.
Nagas on a plane! ^_^
  1. Boards
  2. Romance of the Three Kingdoms II
  3. Hex-editing the registry of generals
  • Topic Archived