Home › Forums › Destiny of an Emperor › Destiny of an Emperor RH Guide ( MOVED! to http://doaerhguide.wikidot.com )
Tagged: Battles, Destiny of an Editor, Destiny of an Emperor, Destiny of an Emperor hacking, Destiny of an Emperor Mods, Destiny of an Emperor Rom, DoaE rom, DoaE Rom hacking, FCEUX, Feidian, Graphics, hacking DoaE, Map, NES ROM hacking, nes8 template, Portraits, ROM Hacking, ROM hacking information
- This topic has 985 replies, 17 voices, and was last updated 2 years, 9 months ago by
MiDKnighT.
-
AuthorPosts
-
November 7, 2011 at 7:34 pm #39775
MiDKnighT
ModeratorQuote:Midknight, remember that we just so happen to have an expansion for extra portraits…. and anything else that needs free space.Yes there is space on the extra pages but the problem is page switching. With the very limited space on the existing pages there's barely even enough room to switch pages. Another problem is that if we switch pages, there's still data we need from the page we switched from. I think in the future we might have to put some page switching function at 0x3bff# and just store it all somewhere else. Best idea might be to switch pages, load what we need in memory, then come back. The tricky part with that is the DoaE uses that same memory for other stuff so we have to be careful not to crash stuff :)
I think our biggest challenge so far is that the DoaE developers used just about every drop of space in the ROM for DoaE goodness. Which makes it tough for us to do anything. Very little wiggle room.
We'll have to come up with a good page switching method using very little space on the existing pages.
Atma, were you interested in having BOTH the extra chapters *and* damage formula changes? If so I can start looking into the page switching stuff.
November 7, 2011 at 8:34 pm #39776DragonAtma
ModeratorDamage formula isn't as high a priority; extra chapters would be more sensible, though, especially for longer chapters. After all, there's a pretty big difference between Zhang Liao (13,027 soldiers) and Yu Jin (30,767 soldiers). No reason for them to show up together.
That, and IIRC nothing in the code prevents all four of the jingzhou rulers from showing up allied in the same battle even though DoaE supposedly has them at each others' throats! XD
November 7, 2011 at 8:36 pm #39777MiDKnighT
ModeratorQuote:That, and IIRC nothing in the code prevents all four of the jingzhou rulers from showing up allied in the same battle even though DoaE supposedly has them at each others' throats! XDMaybe they hate each other but hate you even more :twisted:
November 7, 2011 at 9:30 pm #39778ludmeister
ParticipantTo set a fixed lower limit that Strategists must reach in order to be eligible to be tactician, here's what you gotta do:
0x3b7c5: "dd9c61b003" -> "c996b004ea" (Open an eligible officer to gain their tactic list)
0x38348: "dd9c619043" -> "c9969044ea" (Allow an eligible officer to become tactician)
In both cases, you are replacing
DD 9C61- CMP $619C,X@$619C+ (Compare Int with Str)
with
C9 96- CMP #$96 (Compare Int with 150)
You could change the $96 to whatever, to set the bar as high or as low as needed. To remove all restrictions (except the restrictions set on the tactics themselves), set the code snippets to "EAEAEAEAEA"… NOP them out.
When all else fails... manipulate the source code.
November 7, 2011 at 9:37 pm #39779sonic.penguin
ModeratorWish list:
Find out what makes bows hit twice and if we can make weapons multi-hit <– might make Bo Ye and Wan Sheng useful?
November 7, 2011 at 10:03 pm #39780ludmeister
ParticipantSonic.Penguin,
Thanks for reminding me… I've been wanting to get into this part of the algorithm.
Here's what I've found. Here's the check:
0x3a1e1 – 0E:A1D1:BD 00 61 LDA $6100,X @ $6112 = #$D2 (Load in an item from attacking officer's pack)
0x3a1e4 – 0E:A1D4:C9 C7 CMP #$C7 (Compare it with C7… will explain below)
0x3a1e6 – 0E:A1D6:F0 04 BEQ $A1DC (If equal, then do second attack)
0x3a1e8 – 0E:A1D8:C9 CB CMP #$CB (Compare it with CB)
0x3a1ea – 0E:A1DA:D0 06 BNE $A1E2 (If not equal, then keep looking through pack)
0x3a1ec – 0E:A1DC:20 8D AB JSR $AB8D (Subroutine: Set up second attack?)
0x3a1ef – 0E:A1DF:4C 5A A1 JMP $A15A (Do second attack)
Why does it compare the item with C7 and CB, when the Bow's ID is 47, and the Crossbow's ID is 4B? When an officer equips an item, its ID is "OR"ed with 0x80. There are no items with IDs > 7F, so this is perfectly fine. The 0x80 bit is the "item equipped" bit. So what the algorithm above is asking is… is this item a bow or crossbow that's equipped? Of course, if so, no other weapon is equipped. If it doesn't find one of these two items equipped… then no second attack is performed.
Possibilities, now armed with this knowledge:
1. Now you can edit "C7" and "CB" to "CD" (Equipped Wan Sheng) and "CE" (Equipped Bo Ye). Though, you may want to edit the name of the Bow and Crossbow to something that might not strike twice.
2. With a little intrepidity, you could create a "strike-twice-passive-effect" item… and check for that item (sans being orr'ed by 0x80). That might have ridiculous fun written all over it… place it Wu Cave or one of the two caves between Ru Nan and Chin castle.
3. For more powerful effect, you might place several items that you want to strike twice together in the Item list (hint: rename some weapons), and trap for that certain range (if you wanted to re-write a little 6502 code… you'd need to rethink the comparisons and branch types).
4. Or… maybe I'll figure out a way of making Agility count for potential double-hits… for allies and enemies! I'm starting to get excited about that potentiality.
When all else fails... manipulate the source code.
November 7, 2011 at 10:56 pm #39781sonic.penguin
ModeratorGot it working :) Heres the kicker though… why does it attack twice when a player uses that check, but not the enemy? IE; equpping enemy w/ a bow they only attack once. That agility thing may be worth looking into.
EDIT: found a way that enemies can attack all players. Question, where is the priority found of each tactic used by an enemy? Ie; Use Huo Shen more often than Bei Ji? Or Wan Fu more often than Jie Ce?
November 7, 2011 at 11:20 pm #39782MiDKnighT
ModeratorBetter? :)

0x385E3: 23C513A0A0A0FFFF0000AAAAAAAA0F0F00000A0A0A0A <– PPU color switch
0x3EA75: FE <– Tactic Table
0x3EA8C: 03 <– Equip Box
0x3861E: 0A <– Space in front of AC
0x38623: 10 <– "A"
0x38628: 12 <– "C"
Just cut and paste these 5 lines starting at 3EA40:
FBF8F2D4FEFAFC140AFB0A2223210AF8
7785FB0A181D230AF87785FB0A101618
0AF87785FB0A101F0A0AF87785FBF80D
86F87785FEFE010C6D0C0C2310122318
120C0C6E0C6EFAF80EB7FBFF03F90E6D
Lud is it time for us to declare victory on the "8 tactic" project? *high five* :cheers:
Was great working with you on this and am very glad to have another DoaE assembly guy around. (not that I'm much of an assembly guy, I'm still mostly a noob)
November 8, 2011 at 12:00 am #39783MiDKnighT
ModeratorQuote:Question, where is the priority found of each tactic used by an enemy? Ie; Use Huo Shen more often than Bei Ji? Or Wan Fu more often than Jie Ce?I discovered this when working on getting enemies to use 8 tactics. I may be wrong but it looks to me like the odds in the original DoaE are:
Fire/Water tactic: Around 25%
Heal tactic: Around 25% but probability is low when HP is high, high when HP is low.
Slot 03 tactic: Around 25% (Ji Rou, Huo Jian, Shui Jian, Ce Mian, Ji Mian)
Slot 04 tactic: Around 12.5%
Slot 05 tactic: Around 12.5%
With the 8 tactic change it's like this:
Fire/Water tactic: Around 25%
Slot 02 (heal): Around 12.5% but probability is low when HP is high, high when HP is low.
Slot 03 (secondary heal?): Around 12.5% but probability is low when HP is high, high when HP is low.
Slot 04 tactic: Around 12.5%
Slot 05 tactic: Around 12.5%
Slot 06 tactic: Around 12.5%
Slot 07 tactic: Around 12.5%
My post yesterday had some of the nuts and bolts of how the original DoaE worked:
First it's looking up one of 4 values here:
A897: 00 02 03 04
Then figuring out what to do with the value and storing in $00F4.
00:A8F6:BD 97 A8 LDA $A897,X @ $A899 = #$03 <– Going to use tactic in slot 03
00:A8F9:85 F4 STA $00F4 = #$03
00:A8FB:D0 07 BNE $A904
00:A8FD:AE 20 62 LDX $6220 = #$00
00:A900:F0 02 BEQ $A904
00:A902:E6 F4 INC $00F4 = #$03
00:A904:C9 04 CMP #$04 <– If it is 04 it decides if it wants to increment to 05
00:A906:D0 0C BNE $A914
00:A908:A5 AD LDA $00AD = #$30
00:A90A:65 AE ADC $00AE = #$0C
00:A90C:E5 AC SBC $00AC = #$34
00:A90E:29 01 AND #$01
00:A910:F0 02 BEQ $A914
00:A912:E6 F4 INC $00F4 = #$03 <– Can increment $00F4 if it is 0 or 4
00:A914:20 0C DF JSR $DF0C
Then it cycles through the enemy guy's tactics until it hits the slot for $00F4 and uses that one.
So when it reads 00 (1 in 4 chance) it's going to use a fire or water tactic. It pulls the value for 02 or 03 directly so those are 1 in 4 but we know that it uses the heal tactic little when HP is high and more when HP is low. When it reads tactic 04 there is a 50% chance it will end up with 04 and 50% chance it reads 05 so it essentially cuts the probability of slots 04 and 05 in half (ie…12.5%).
November 8, 2011 at 12:56 am #39784MiDKnighT
ModeratorQuote:Found a bug in the guan yu/zhang fei leave in party code… here is what happensThe game unequips them upon the "leaving party" script, BUT if you look in the menu, Guan yu/Zhang Fei have 255 AC with nothing equipped. This changes once you equip them but who would want to? muahahaha!
Checking the "leaving" code:
00:AFA3:A9 00 LDA #$00
00:AFA5:8D 9C 60 STA $609C = #$80 <— clearing alive status
00:AFA8:8D 9D 60 STA $609D = #$80 <— clearing alive status
00:AFAB:8D A8 60 STA $60A8 = #$A9 <— removing from your party
00:AFAE:8D A9 60 STA $60A9 = #$AA <— removing from your party
00:AFB1:8D C0 60 STA $60C0 = #$0A
00:AFB4:8D C1 60 STA $60C1 = #$0A
00:AFB7:8D B4 60 STA $60B4 = #$8C
00:AFBA:8D B5 60 STA $60B5 = #$8C
00:AFBD:85 F1 STA $00F1 = #$00
00:AFBF:AA TAX
00:AFC0:20 FF 9D JSR $9DFF <– subroutine that removes general
00:AFC3:A9 01 LDA #$01
00:AFC5:85 F1 STA $00F1 = #$00
00:AFC7:A2 00 LDX #$00
00:AFC9:20 FF 9D JSR $9DFF <– subroutine that removes general
I think the AC problem is because my fix was loading FF into the accumulator. I have a better fix now, which just zeros out some stuff that was kicking them out:
0x36FB4: 00000000000000000000000000
0x36FD0: 000000
0x36FD9: 000000
They are still getting their weapons unequipped though. Either I can dig deeper to prevent that or you can write it into the story. They needed the blood cleaned off their weapons or something… :D
November 8, 2011 at 1:00 am #39785sonic.penguin
Moderatorunequipped weapons is fine, can work with that
November 8, 2011 at 1:18 am #39786ludmeister
ParticipantQuote:Lud is it time for us to declare victory on the "8 tactic" project?IMHO, that status screen rocks. Truly great work. Will work at re-editing my ROM to allow for 8 tactics tonight. I think we may have kicked it, man. FLEXX I would never have attempted to do this on my own.
I may also look into the preliminaries for AGI-based double strikes tonight, if time permits. I have a few officers in my mod which are marginal fighters, but are fast… they may have an additional purpose if I get this working. I'll need to change code blocks for sure.
Quote:why does it attack twice when a player uses that check, but not the enemy?I'm not sure as of yet… however, there's no sense in looking through an AI officer's pack (officer #8 – 12). My guess is that it checks the attacker's #, and if one of the first 7, it starts rummaging through their backpack for an equipped bow. If not, well… their turn's simply over. I'm definitely not through digging into the code here.
EDIT: I was wrong… the game checks the AI officer's backpack! However, there are only zeroes there, so they never attack twice! This definitely makes an agility based double attack more feasible…
When all else fails... manipulate the source code.
November 8, 2011 at 3:31 am #39787ludmeister
ParticipantMiDKnighT… question for you, if you get time.
When you page switch in ROM, how do you get the RAM from $2000 to $7fff to stay in memory? My page switching works… but it totally wipes out the memory I'm trying to work with. Any suggestions?
When all else fails... manipulate the source code.
November 8, 2011 at 3:41 am #39788MiDKnighT
ModeratorThere may be other ways, but when I switch pages I just use:
00:B520:A9 0D LDA #$0D <— Load page # into accumulator
00:B522:20 82 C4 JSR $C482 <— subroutine to switch pages
If you're on a non-fixed page it will plop you into the same spot on the new page. Example:
00:B520:A9 0D LDA #$0D
00:B522:20 82 C4 JSR $C482
…function to switch page to 0D…
00:B525:C0 64 CPY #$64 <— Now it is on B525 on the new page.
I haven't watched the memory when switching pages but it seems to work fine. Ie…I don't lose my party or anything (I would if I lost the $6000 stuff…)
I also noticed that the game uses $0600 to $06FF for temporarily storing stuff like we would when switching between pages. The problem for us is that we don't want to step on that if the game is already using it.
November 8, 2011 at 3:51 am #39789ludmeister
ParticipantThe problem is I'm switching to page 1C… I don't think that the variables were defined for more than through pages 0F. I may be wrong, but when it switches to a page greater than 0F… loses the memory. Gains it back when it goes back to normal code. Grrr. I may have to do a double hop for my Agility code :huohu:
When all else fails... manipulate the source code.
-
AuthorPosts
- You must be logged in to reply to this topic.

