Destiny of an Emperor Rom Hacking Guide

Some assembly required…

This post should be a "living document" to hold all of the most important DoaE ROM hacking information. We can edit and add any important new information as it is discovered.

The primary technical contributors to this information are MiDKnighT (me), ludmeister, Niahak, Meteorstrike, James, sonic penguin, Xhinaeria, and several regulars on the LYS message board. Big thanks to everybody that contributed to taking apart Destiny of an Emperor and his highness Lord Yuan Shu and James for giving us a place for a great DoaE community (one of the best games ever made).

RECOMMENDED SOFTWARE:

  • Destiny of an Editor (DoaE tool)
  • A hex editor that supports loading tables (I'm using Hexecute and the editor in FCE Ultra).
  • An emulator that has good debugging features. FCE Ultra works great for me.

For Portraits and Graphics:

DOAE ROM HACKING BEST PRACTICES:

  • Back up your ROM often! Perhaps under a different name with the date in the name each time so that you have a history to fall back to.
  • If it was tough to figure something out, document it. Or better yet, post it on this message board so that others can use your findings and perhaps even improve on it.
  • Make a good ROM! Yes it may take weeks, months, or even years to make a great mod. If you're going to share a finished product don't just change Liu Bei's character and call it a day. A fantastic mod would be one that uses most if not all of the techniques in this guide well and gives the player a brand new and unique gameplay experience.

Places to Find ROMs and Talk about DoaE Modding:
Lord Yuan Shu Forums: http://www.lordyuanshu.com/forums/forum/destiny-of-an-emperor
Scholars of Shen Zhou: http://the-scholars.com/viewforum.php?f=3
Facebook: http://www.facebook.com/pages/Destiny-of-an-Emperor-Mods and http://www.facebook.com/game.walkthroughs

For Contributors:

  • To contribute, go to the bottom of the page, join the page, and enter the password.
  • It is probably easiest to edit sections individually with +Options —> "Edit Sections" at the bottom of the page.

Table of Contents

Page 2 Contains:

  • Portraits & Sprites
  • Towns
  • Level Ups
  • Events
  • Miscellaneous
  • Additional Reading
  • Advanced ROM Debugging

Destiny of an Editor

Credit: Niahak, MiDKnighT, and others who assisted (see bottom of README)

Anything that can be edited by "Destiny of an Editor" by Niahak, should be. This tool makes it easier to edit some of the most important aspects of the game like officers, portraits, text, battles, tactics, items, etc…

That said, download Destiny of an Editor HERE

Generals

0wu62YL.png

After opening your ROM with DoaEditor, you can use this page to edit all the key attributes of every general in the game.

Text

gL7w8nU.png

This tab makes it possible to change the text in the game. It can be sorted in ROM order or Alphabetical order. After changing a line of text make sure to hit the "Check my line" button to check the length of the text, etc…

Map

Xsy1t1k.png

This interface allows you to easily drag and drop tiles from the right side to the map area in the middle. There is also a "Region Selector" to help find the region you are looking for. Activate this by clicking on the "Select from map" button at the bottom.

There are certain regions that should not be edited. These are:

  • Any region where an event in the game triggers a map change. For example this happens at Qing Zhou castle, directly below Gui Yang castle, the bridge above Nan Yang, the "canal" area of Wu, and the Luo Yang area and just south of it.
  • Do not edit any region that is outside of the playable area. The general rule is, if you can't walk there in the original game, you probably can't walk there in a modified game.
  • Do not edit any region that is used in more than one place. For example this would be a region that contains all water, all mountains, etc…

There are also special considerations when creating a castle, house, gate, or village. See the LOCATIONS, WARPS, and BATTLES sections below for more info.

Battles

tBc5k2f.png

Edit the battle lineup here. The battles are in the order displayed at: http://kongming.net/doae/rom_hacking/battles/

You can also change the before and after battle taunts and the location of the battle based on the coordinates (see the "Locations" section for more on the coordinates).

Tactics

KSjQbbA.png

Edit attributes of each tactic here. This view is with IPS 1.3 and above. More info about what you are editing here is in the "Tactics" section of this guide.

Profiles

xMhjexy.png

This page is for IPS 1.3 and above only. You can edit officer profiles. Profiles include what tactics the officer can learn when leveling up, what weapons they can use, and what they might be inclined to do as an enemy. On the "Generals" tab you can then assign different officers to different profiles.

Items

S7eYIlA.png

On this page you can edit item names, prices, icons, and various other attributes specific to each item.

Places

JXK760N.png

Edit villagers in each town, inns, weapon stores, merchant stores, provisions, and more here.

Readme

DoaEditor was created by Niahak (www.niahak.org). Check there for the latest version. The current version is 0.98f.

Directions:
1) Load a valid DoaE ROM.
2) Click on an officer's name.
3) Change that officer's stats and name as desired.
4) Click "Save" to save changes to that officer.
5) Repeat 2-4 for each officer. There is no error accounting for using *too much* space - generally I would say it would lead to Very Bad Things. However, it does tell you how much space is left.
6) When you're ready to save the new ROM, click file->Export to ROM. I recommend saving it in a new file and testing, just in case it still isn't all working.

Oh, and some additional info:

Agility is never shown in the game, but it affects order during a round.

Region determines where the officer is found in random encounters, but [i]does not[/i] affect when you can recruit them. If you have them in your party, you won't find them in random encounters.

Sprites are mostly listed by their most memorable (or recognizable) character - most of these were given their names by James.

Sprite color is a value that also affects A.P. when you fight them as an enemy officer, so there are numbers by each color set. For allies, it doesn't matter.

There are multiple leveling schemes in the Soldier drop-downs. These are used for the 5 Tigers, Zhuge Liang, and Jiang Wei. Any character can be made to level. Additional schemes seem to exist in the ROM but are unpredictable.

Highest Tactic determines the highest possible tactic an enemy officer can use. It is also bounded by INT, though - for example, you could give Cheng Yuanzhi access to all tactics, but he can't use any because he's not smart enough.

Portrait values are, yes, raw hex. It's not recommended to mess with these at random, but you can keep track of them to build portraits (like I did with Cao Cao's below).

Portrait Background is usually white for the "special" characters (Liu Bei, Zhao Yun etc). You can give them other colors, but they affect the palette.

Generally: Many values are listed as "Unknown" with a hex value, particularly in portrait backgrounds. Usually these correspond to known values, but are listed separately because they may have unknown side effects.

I cannot guarantee DoaEditor will be completely bug-free. It has been tested multiple times, and seems to be working properly. If you do run into an error, please let me know so I can look into fixing it!

Text-editing has been recently added to this edition, as well as preliminary map-editing.

ROM Expansion explanation:
This feature expands the ROM and allows access to multiple portrait banks, allowing more than 300 portraits to be added to the game (and/or 120 or so new sprites).
Portraits and sprites can be added following a procedure written by MiDKnighT, found here:
http://www.lordyuanshu.com/forums/topic/destiny-of-an-emperor-rom-hacking-guide-1#post-25204

The ROM automatically loads portraits from the file itself, so new portraits can be viewed and used in the editor. Sprite loading is not yet complete.

Thanks go out to:

  • James (www.kongming.net) for a huge amount of help in building tables of AP, AC, and sprites, in addition to ripping the sprites and testing the program.
  • Lord Yuan Shu (www.lordyuanshu.com) for encouragement, testing, and for declaring himself emperor too early.
  • Taishi Ci (2.0) for his Destiny of an Emperor parody, which partially inspired DoaEditor.
  • MeteorStrike of the DoaE GameFAQs board, for much aid in figuring out where things are.
  • MiDKnighT of Scholars of Shen Zhou and LYS.com for helping discover how maps work and ripping their graphics, as well as some awesome work on ROM expansion.
  • sonic.penguin of Scholars of Shen Zhou and LYS.com for keeping the flame lit despite how dark things may seem in the DOAE-hacking world.

DoaE IPS Patch

We've added several of our DoaE "enhancements" into 1 DoaE IPS patch bundle. This patch is geared towards modders who want to quickly add enhancements to their game but it can be used against the original DoaE as well. If you've played DoaE before and have some time, please try it out and give feedback.

Enhancements/fixes added in IPS patch version 1.1:

- Iron Ore / Treasure Chest Bug Fix
- Portrait Expansion Code
- Sprite Expansion Code
- Pre-loaded sprite bank(s)
- 8 tactics
- Agility on status page
- Critical hit formula changes (subtle increase in number of critical hits)
- Agility Based Multi-attacks
- Modified soldier bars to support more troops
- 25 soldier gain level up patterns
- Modified TP gains at level-up
- Change food usage (subtle decrease in amount of food used)
- DoaE2 like damage
- 8 New Chapters
- "Life" and "Raise" tactics
- Smoke pot lasts twice as long

Added in version 1.2:

- Everything in IPS Patch 1.1 and…
- DOAE Artificial Intelligence Enhancements
- "Duel" Tactic (replaces Shui Jian)
- "Charge" Tactic (replaces Cheng Nei)
- "Protect" Tactic (combines Wuo Jian, Shui Jian, and Cheng Nei)
- Enhanced "An Sha" tactic
- Level/soldier based damage for tactics
- Guard tactic only defends against physical attacks
- Defend now halves damage from physical and tactic attacks + gains TP
- Enemy Profiles (Which tactics they are likely to use)
- Equip Menu Enhancement (less steps to equip new items)
- Weapon, Armor, and Tactic icons

Added in version 1.3:

- Everything in IPS Patch 1.2 and…
- Base AC Enhancement
- Expanded number of items, weapons, armor, helmets
- Default icons for items, weapons, armor, helmets, and tactics
- Item, weapon, armor, helmet, and tactic names expanded to 9 characters (including icon) each
- Tactic name list expanded to 255 names (for future expansion)
- New Attributes (LDR, VIT, POL)
- Party leader's LDR affects duel outcome and more to come for LDR.
- VIT is used for Base AC enhancement and more to come for VIT.
- POL is used for item drops and more to come for POL.
- Spoils of war enhancement (item drops)
- Guo Si bug fix
- Tactic Expansion Framework and Tactics Using New Attributes
- Tactic Level Up Profiles
- Many new tactics

This patch will not overwrite your generals, portraits, or custom text. It is only designed to add the new enhancements to your ROM that are in the above list.

Instructions:

  1. Expand your ROM with DoaEditor if you haven't done so already. Note that this will destroy existing save states.
  2. Once the ROM expansion is done, DoaEditor will prompt you to ask if you want to apply a DoaE IPS Patch. Click yes to apply. It is also available as a menu item if you decide to patch later or update your patching with the latest changes.

If using IPS patch 1.2 or greater, there are 2 patches:

Patch 1 – Formats the new code areas on the ROM (apply once)
Patch 2 – Adds all the other enhancements. Note that patch 2 will not overwrite custom lists but patch 1 will.

Usually things that the modder will customize (like palettes, lists, and such) will be changed in patch 1 but patch 2 won't touch those items. DoaEditor will automatically apply patch 1 if it hasn't been applied yet and always apply patch 2 if you choose to apply or update your IPS patch.

Next, just play the game… (Note that FCE Ultra is the most tested emulator with DoaE expanded ROMs – any other emulator must support mapper 245). Obvious changes are the general status page, agility based multi-hits, tactic list if you are using a save state and enter battle, and more.

Let us know how it's working! Please give any feedback on the enhancements or report any bugs.

*** Note that if you are already using the latest features, back up these lists before patching for the first time if you were already using IPS patch 1.2 or above:

0×4450-0x446F = mismatch list – winner
0×4470-0x448F = mismatch list – loser
0×4490-0x44CF = no kill list
0x44D0-0x44EF = rare duel list (for rulers mainly)
0x44F0-0x450F = bigger no an sha list

0x7A400-0x7A4FF = where you assign a profile to an officer

Patch 1.3 and above only:

Weapon Power- Status display: 0×78640 (none), 0×78641 to 0x7865f (ID #40 – #5e)
0×79010-791FF – Enemy tactic profiles (what are they going to do)
0x7AA00-0x7AAFF = LDR settings for officers
0x7AB00-0x7ABFF = VIT settings for officers
0x7AC00–0x7ACFF = POL settings for officers
0x7E710-0x7E777 – Weapon/Item Expansion Details
0xE8400-0xE96FF – Tactic Attributes and Profiles
Page 3E (0xF8010-0xFC00F) = expanded weapon and tactic names
0xFE710-0xFE777 – Weapon/Item Expansion Details

Patch 1.1 and 1.2 only:

0×5710-0x572F = tactic no fail list
0×5730-0x573F: STR bonus list (put tactic ID in this list for STR bonus)
0×5740-0x574F: AGI bonus list (put tactic ID in this list for AGI bonus)
0×5750-0x575F: INT bonus list (put tactic ID in this list for INT bonus)
0x7A510-0x7A6DF = tactic profiles

Locations

Credit: MiDKnighT and Meteorstrike

Everywhere you step in the game, you are stepping on a unique address. Think of it as the "mailing address" of that spot. This address is stored in memory from $0060 to $0063. An example address is: 0C 05 07 12

In this example, OC is the vertical position in your "zone". 05 is the vertical zone that you are in. 07 is the horizontal position in your "zone". 12 is the horizontal "zone" that you are in. The game uses these addresses to place items, location of castles, location of battles, etc…

How do you know your current address? You have to look at the memory while the game is running. For example, in FCE Ultra you open the Hex editor and look at 60-63 in memory (found this from the Meteorstrike post on Gamefaqs).

Here's a pic from the Yuan Shao mod:

MAP1.jpg

So where am I standing? I'm standing in zone 7-10 (7 vertical, 10 horizontal) and I'm standing at 01-0F within that zone. So I'm standing on the last block of the top row in that zone.

Knowing how these location addresses work are critical for being able to place warps, battles, and items.

Item Placement

Credit: Meteorstrike and James

For reference, here's the item list:

  • 00 ~*006038 coins [glitch]
  • 01 ~96 coins
  • 02 ~237 coins
  • 03 ~592 coins
  • 04 ~1013 coins
  • 05 ~1533 coins
  • 06 ~4028 coins
  • 07 ~29 food
  • 08 ~125 food
  • 09 ~821 food
  • 0A ~2011 food
  • 0B ~5902 food
  • 0C ~10151 food
  • 0D ~2098390 food
  • 0E ~2148799 food
  • 0F ~*86607 food [glitch]
  • 10 [blank] ->
  • 16 [blank]
  • 17 Silver Key ->
  • 18 Silver Key
  • 19 Gemsword
  • 1A Ma Letter [???]
  • 1B Gun Powder
  • 1C Intro Letr
  • 1D Iron Ore
  • 1E Dead Wood
  • 1F Saltpeter
  • 20 [glitch]
  • 21 Chi Tu Ma [Red Hare]
  • 22 Zhou Letr [Zhang Ltr]
  • 23 Gold Key
  • 24 Gullwing ->
  • 28 Gullwing
  • 29 [blank] ->
  • 2A [blank]
  • 2B Smoke Pot
  • 2C Steed
  • 2D Resurrect -> (Glitched, use 30)
  • 30 Resurrect
  • 31 Elixir A
  • 32 Elixir B
  • 33 Elixir C
  • 34 Elixir D
  • 35 Power Pill -> (Glitched, use 38)
  • 38 Power Pill
  • 39 Dagger ->
  • 40 Dagger
  • 41 Flail
  • 42 Ax
  • 43 Club
  • 44 Spear
  • 45 Sabre
  • 46 Trident
  • 47 Bow
  • 48 Sword
  • 49 Battleax
  • 4A Scimitar
  • 4B Crossbow
  • 4C Lance
  • 4D Wan Sheng
  • 4E Bo Ye
  • 4F Qing Guang
  • 50 Nu Long
  • 51 Qing Long
  • 52 Halberd
  • 53 Robe ->
  • 59 Robe
  • 5A Leather ->
  • 5B Leather
  • 5C Padded ->
  • 5D Padded
  • 5E Ring M ->
  • 5F Ring M
  • 60 Chain M ->
  • 61 Chain M
  • 62 Splint M ->
  • 63 Splint M
  • 64 Plate M ->
  • 65 Plate M
  • 66 Bandana ->
  • 68 Bandana
  • 69 Cap
  • 6A Hood
  • 6B Wood H
  • 6C Copper H
  • 6D Bronze H
  • 6E Iron H
  • 6F Steel H
  • 6F [glitch] ->
  • 7F [glitch]
  • 80 "I found a small keyhole." ->
  • FF "I found a small keyhole."

Ref: http://the-scholars.com/viewtopic.php?f=3&t=19872&st=0&sk=t&sd=a&start=20

Meteorstrike's missing item FAQ has a list of items and their locations:

HIDDEN = 20

$668E => Chapter 1 – Mt. Da Xing – (001.048.013.001) => 42 = Ax
$6680 => Chapter 2 – World Map – (013.010.012.017) => 21 = Chi Tu Ma
$668F => Chapter 2 – Hu Lao Guan – (001.048.012.003) => 42 = Ax
$6682 => Chapter 2 – Luo Yang – (002.026.012.004) => FF = (~)
$6691 => Chapter 2 – Yang Zhou – (001.047.010.008) => 43 = Club
$6693 => Chapter 3 – Nan Yang – (006.022.005.027) => 46 = Trident
$6684 => Chapter 4 – Guang Zong – (002.007.008.024) => 45 = Sabre
$6685 => Chapter 4 – Ji Zhou – (006.012.007.026) => 47 = Bow
$6688 => Chapter 5 – Wu Ling – (004.031.008.027) => 47 = Bow
$6686 => Chapter 5 – Chang Sha – (004.028.012.026) => 48 = Sword
$6687 => Chapter 5 – Gui Yang – (004.030.012.030) => 48 = Sword
$6692 => Chapter 5 – Ling Ling – (002.047.006.010) => 48 = Sword
$6689 => Chapter 6 – Luo – (006.029.000.024) => 49 = Battleax
$668A => Chapter 6 – Cheng Du – (008.025.008.020) => 4A = Scimitar
$6683 => Chapter 7 – Jian An – (003.028.004.020) => 1E = Dead Wood
$668B => Chapter 7 – Jian An – (001.028.004.020) => 4A = Scimitar
$6690 => Chapter 7 – Hui Ji – (001.048.012.005) => 4A = Scimitar
$668C => Chapter 7 – Wu – (007.026.013.018) => 4B = Crossbow
$668D => Chapter 7 – Wu – (012.026.013.018) => 63 = Splint M
$6681 => Chapter 8 – Guang Ling – (009.026.013.015) => 4E = Bo Ye

For items in this list, the addresses are stored in separate arrays.

$8A00,X = 0x30A10,X = Map address value 1
$8A40,X = 0x30A50,X = Map address value 2
$8A80,X = 0x30A90,X = Map address value 3
$8AC0,X = 0x30AD0,X = Map address value 4
$8B00,X = 0x30B10,X = Item

For dead wood X = 03 (6683 – 6680 = 03). So if you wanted to change the location of dead wood here are the addresses to change:

0x30A13 = Map address value 1
0x30A53 = Map address value 2
0x30A93 = Map address value 3
0x30AD3 = Map address value 4
0x30B13 = Item

CHESTS = 43

$667A : bit 7 => Chapter 1 – Tie Men Xia – (001.029.003.006) => 42 = Ax
$6604 : bit 7 => Chapter 1 – Cave – (003.003.002.004) => 42 = Ax
$6676 : bit 7 => Chapter 2 – Fan Shui Guan – (001.029.003.006) => 42 = Ax
$662A : bit 7 => Chapter 2 – Cave 1 – (002.035.007.029) => 23 = Gold Key
$662A : bit 6 => Chapter 2 – Cave 1 – (003.034.007.026) => 04 = coins
$6629 : bit 2 => Chapter 2 – Cave 2 – (002.041.009.007) => 43 = Club
$664D : bit 7 => Chapter 3 – Chen Cang – (001.029.003.006) => 44 = Spear
$662B : bit 7 => Chapter 3 – Cave – (002.038.005.023) => 69 = Cap
$662B : bit 6 => Chapter 3 – Cave – (002.038.003.023) => 44 = Spear
$662B : bit 5 => Chapter 3 – Cave – (011.039.007.015) => 69 = Cap
$662B : bit 4 => Chapter 3 – Cave – (005.039.013.016) => 59 = Robe
$662B : bit 3 => Chapter 3 – Cave – (002.039.001.017) => 59 = Robe
$662B : bit 2 => Chapter 3 – Cave – (011.040.003.015) => 44 = Spear
$662B : bit 1 => Chapter 3 – Cave – (011.040.007.016) => 44 = Spear
$662B : bit 0 => Chapter 3 – Cave – (011.040.013.017) => 05 = coins
$662C : bit 7 => Chapter 3 – Cave – (007.036.004.023) => 69 = Cap
$662C : bit 6 => Chapter 3 – Cave – (011.036.007.023) => 04 = coins
$662C : bit 5 => Chapter 3 – Cave – (007.036.011.023) => 38 = Power Pill
$662C : bit 4 => Chapter 3 – Cave – (002.036.009.023) => 59 = Robe
$6629 : bit 4 => Chapter 6 – Cave – (002.035.002.009) => 05 = coins
$6629 : bit 3 => Chapter 6 – Cave – (010.033.010.012) => 1D = Iron Ore
$664C : bit 7 => Chapter 6 – Mian Zhu Guan – (001.029.003.006) => 49 = Battleax
$6630 : bit 7 => Chapter 7 – Cave 1 – (011.045.002.001) => 1F = Saltpeter
$6629 : bit 7 => Chapter 7 – Cave 2 – (011.039.000.008) => 34 = Elixir D
$6629 : bit 6 => Chapter 7 – Cave 2 – (010.037.003.015) => 50 = Nu Long
$6629 : bit 5 => Chapter 7 – Cave 2 – (002.036.002.012) => 6F = Steel H
$662F : bit 7 => Chapter 8 – Cave 1 – (009.044.013.024) => 38 = Power Pill
$662F : bit 6 => Chapter 8 – Cave 1 – (006.043.009.024) => 6D = Bronze H
$662F : bit 5 => Chapter 8 – Cave 1 – (012.043.015.018) => 2B = Smoke Pot
$662F : bit 4 => Chapter 8 – Cave 1 – (007.044.013.022) => 4D = Wan Sheng
$662F : bit 3 => Chapter 8 – Cave 1 – (005.044.013.022) => 65 = Plate M
$662F : bit 2 => Chapter 8 – Cave 1 – (003.044.013.022) => 6D = Bronze H
$662D : bit 7 => Chapter 8 – Cave 2 – (005.043.011.015) => 65 = Plate M
$662D : bit 6 => Chapter 8 – Cave 2 – (005.043.013.015) => 28 = Gullwing
$662D : bit 5 => Chapter 8 – Cave 2 – (007.043.011.015) => 34 = Elixir D
$662D : bit 4 => Chapter 8 – Cave 2 – (007.043.013.015) => 63 = Splint M
$662D : bit 3 => Chapter 8 – Cave 2 – (009.043.011.015) => 6E = Iron H
$662D : bit 2 => Chapter 8 – Cave 2 – (009.043.013.015) => 6F = Steel H
$662D : bit 1 => Chapter 8 – Cave 2 – (003.042.003.015) => 52 = Halberd
$662E : bit 7 => Chapter 8 – Cave 2 – (010.041.009.011) => 38 = Power Pill
$662E : bit 6 => Chapter 8 – Cave 2 – (000.042.015.011) => 4F = Qing Guang
$662E : bit 5 => Chapter 8 – Cave 2 – (010.042.011.012) => 28 = Gullwing
$662E : bit 4 => Chapter 8 – Cave 2 – (006.041.013.012) => 34 = Elixir D

Ref: http://faqs.ign.com/articles/974/974431p1.html#VIII.A

Placing items from this list is easy. Just put the world map address then the item ID in the ROM. For example, if I stand on the treasure chest in Fan Shui Guan I am at 01 1D 03 06. The contents of the treasure chest is an Ax (42). So in the ROM I see: "01 1D 03 06 42" at 0x309DD. If I change the 42 to 52 I get a halberd instead of an Ax :D Or to move the item you'd just give it a new map address.

Expanded Treasure Feature

Credit: MiDKnighT

The way DOAE normally works for treasure chests is that it looks up the location ID for where you are standing. It uses the location ID to find the starting treasure chest point using the tables at 0x30820 and 0x30890. It will then scan 8 chests of 5 bytes each looking for the chest that's either on your screen or that you are standing on. What does that mean for us modders?

  • We can't move chests outside of that range of 8 chests. We have seen this problem when we move a treasure chest in DoaEditor but then the game can't see the contents because it is outside of it's location ID spread of 8 chests.
  • You are limited to 8 chests per location ID.

So what this enhancement does is…

  • Makes chests movable to any location ID. Ie…every time we search for the chest on the screen we will search through ALL chests not just the 8 for our location ID. So you should be able to move chests to different caves, etc… without issue.
  • Expands the number of treasure chests from 44 to 102
  • You won't be able to see the new chests in DoaEditor until the DoaEditor Version 59 or above.
  • New chests are placed in first Guan Ping cave screen at 06.41 (first one is 01 29 01 06 02)
  • As a bonus, because I freed up some space on the OE page with this feature I threw in the change where you can see AGI with bonus in billeting (Billeting was not showing adjusted AGI before, just base AGI).
  • If you already have a working ROM chest Open / Close may be wonky depending on what you have in your save state. If you zero out $6600-$667F in memory all assigned chests should be closed and full of loot.
  • There are some caveats regarding the tent chests. The rules for these will be this:

Don't move the tent chests in location IDs 7A, 76, 4C, and 4D. In the original ROM these are:

Chapter 1 – Tie Men Xia – (001.029.003.006) => 42 = Ax
Chapter 2 – Fan Shui Guan – (001.029.003.006) => 42 = Ax
Chapter 3 – Chen Cang – (001.029.003.006) => 44 = Spear
Chapter 6 – Mian Zhu Guan – (001.029.003.006) => 49 = Battleax

In the ROM they are at 0x309D3:

011D030642 011D030642 011D030644 011D030649

Changes:

0x38150:
60200DD121006020A9D420E4C4209EC4
4C5B066868A9EA48A95448A2078E3164
20A5BBA90920C8E360EAEAEAEAEAEAEA
EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEA
EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEA
EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEA
EAEAEAEAEAEAEA20008720D5C0207ACE

0x306D0:
A90185F3A98885F4A447C07AD009E6F4
A9D285F3A23060C076D009E6F4A9CD85
F3A23160C04CD009E6F4A9C385F3A232
60C04DD008E6F4A9C885F3A233600000
A20020C086EAEAEAEAEAA000A98085F1
BD006685F2A000B1F3C8C560D017B1F3
C8C561D011B1F3C8C562D00BB1F3C8C5
63D005F00EC8C8C8C806F246F1C028D0
D6F01806F2B040B1F3856EEAEABD0066
05F19D0066A5F18D000160E8E028D003
4CCE87A5F3C9F79014A90085F3A5F418
6901C98A90016085F4E84C0A87A5F318
692885F34C0A8768A99C486000000000
A20020C086EAEAEAEAEAA000BD006685
F2B1F3C8C51CD017B1F3C8C51DD011B1
F3C8C51ED00BB1F3C8C51FD005F038C8
C8C8C806F2C028D0D8E8E028D00568A9
674860A5F3C9F79014A90085F3A5F418
6901C98A90016085F4E84C9A87A5F318
692885F34C9A8768A9A5486000000000

Note that this section starting at 0x30810 is NOT in IPS 1.3 patch 2 so as to not overwrite chest locations. This section is the NEW chests that will be placed on Guan Ping's cave first page. If you have an existing mod and are just adding this enhancement you should copy this part in manually:

0x30810:
00012901060202290106020329010602
04290106020529010602062901060207
29010602082901060209290106020A29
0106020B290106020C290106020D2901
06020E29010602012902060202290206
02032902060204290206020529020602
06290206020729020602082902060209
290206020A290206020B290206020C29
0206020D290206020E29020602012903
06020229030602032903060204290306
02052903060206290306020729030602
082903060209290306020A290306020B
290306020C290306020D290306020E29
03060201290406020229040602032904
06020429040602052904060206290406
02072904060208290406020929040602
0x39390:
8DAF61ACAF60A9092053814C52EA205D

0x7D970:
C901D04BA90C2082C4209087EAEAEAEA
EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEA
EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEA
EAEAEAEAEAEAEAEAEAEAEAEAEAEA06F2

0xFD970:
C901D04BA90C2082C4209087EAEAEAEA
EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEA
EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEA
EAEAEAEAEAEAEAEAEAEAEAEAEAEA06F2

Changing the Chapter for the Region

Credit: MiDKnighT and Meteorstrike

Each region has a single digit to specify what chapter that region belongs to. This code will control what enemies you face and how much gold and experience you gain after battle. The chapter control digits start at 0x37df5:

000000000000044444000000
000000000000004444111100
000000000044444441111100
000000044444444411111100
000000443332222211111100
000000443332222221111100
000000044333322222111100
000000044333388888888888
000006665533338888888888
000066665553338888888888
000066665555555888888888
000066655555555778888888
000066655555555778778888
000006666655555777778888
000066666665555777778888
000066666677777777770000
000066666677777777770000
000066666677777777770000
000000000077777777770000
000000000077777777770000

Each number represents a chapter number (0-8). The chapter numbers are:

0=No Random Encounters
1=Yellow Turbans
2=Dong Zhuo
3=Yuan Shu
4=Yuan Shao
5=Jingzhou
6=Shu
7=Wu
8=Wei

Here is a picture showing these layed out on the map:

World_Chapters.jpg

Each number corresponds to a 'region' on the map. Want to change the Chapter 1 Xu Zhou area to be Chapter 8 (Wei)? Simply change all 1's to 8's in the above section. Knowledge of how the zones are layed out will allow us to *customize* enemy areas. Maybe the snow area will no longer be just chapter 4. Maybe it will be chapter 2 on the west side and chapter 3 on the east side. Or maybe you can break Wei up into separate chapters…

Special Map Regions:

The chapters for some regions are uneditable by DOAEditor and thus must be edited directly in the hex. Those special addresses are listed below.

QingZhou 37E16
Jian An 37EBA
Wu Cave 37EC9
Chen ?????

8 New Chapters

Credit: MiDKnighT

Basically I'm having 8 new chapters *share* rebel forces, etc… from previous chapters. The mapping is:

1 2 3 4 5 6 7 8
9 A B C D E F 0

Which means that chapter 9 will share chapter 1's rebel forces, chapter A will share chapter 2's rebel forces, etc… So you could split each chapter in 2 if you wanted to. So in chapter 9 you would see chapter 9's generals and chapter 1's rebel forces. In chapter 0 you would see chapter 0's generals and chapter 8's rebel forces. Here's the hex changes to make this happen:

0x399D2-0x399D4: AE3670
0x39AB7-0x39AB9: AD3670
0x3A49E-0x3A4A0: AE3670
0x3B311: 20E0BF
0x3B3CB: AD3670
0x3B3DD: AD3670
0x3BFF0: AD2660C9099002E908C901B002A9088D367060

Original ROM size:

0x3DFD3: 20E0BF
0x3E01D: AE2660
0x3E043: AE3670
0x3E092: AD36700A6D3670

1MB ROM:

0x7DFD3: 20E0BF
0x7E01D: AE2660
0x7E043: AE3670
0x7E092: AD36700A6D3670
0xFDFD3: 20E0BF
0xFE01D: AE2660
0xFE043: AE3670
0xFE092: AD36700A6D3670

Then put your new chapters on the map using the "Changing the Chapter for the Region" instructions and to put your general(s) in the new chapter you would change his "Region" value to the new chapter.

So…the logical chapter order would be:

1 9 – 2 A – 3 B – 4 C – 5 D – 6 E – 7 F – 8 0

Where "-" represents a switch to a stronger rebel force. So if you were to split the Yellow Scarves area you would use chapters 1 and 9. If you were to split Wei you would use chapters 8 and 0.

  • Note that chapters 1-5 and 9-D will have bandit forces, brigand, pirate, etc…

*** Note that this battle damage formula changes the same area of the ROM as the "Expanded Chapters" enhancement. If you want this enhancement *and* ludmeister's DoaE2-like damage enhancement do the following:

1. Add the Agility based extra attacks enhancement.

2. Add the DoaE2-like Damage enhancement.

3. Edit the following:

0×39826: "4cc7a1"

Original ROM size:

0x3a1d7: "4603 6604 88C0 00D0 F7A5 0418 6500 8515 4C17 98"

1MB ROM:

0x7a1d7: "4603 6604 88C0 00D0 F7A5 0418 6500 8515 4C17 98"
0xfa1d7: "4603 6604 88C0 00D0 F7A5 0418 6500 8515 4C17 98"

4. Add the 8 Chapters enhancement.

How the Map is Built

Credit: MiDKnighT (although Meteorstrike has figured a lot of this out before but it wasn't documented)

1. Location ID is stored in memory at $6013 and $47.

It all starts with the warp (see the warp section below). This is where it gets the location ID. Here it is getting the location ID for Xu Zhou:

A:00 X:01 Y:00 S:2E P:nvUbdIzc                  $06D0:A0 08     LDY #$08
A:00 X:01 Y:08 S:2E P:nvUbdIzc                  $06D2:B1 1A     LDA ($1A),Y @ $8383 = #$7E

Note that every time it uses a warp, it stores the what "hierarchy" it came from in $6012. That's how it knows to warp back to the world map when leaving Xu Zhou because it's going from hierarchy 01 to hierarchy 00.

Not every region on the map has it warp in it. But as Liu Bei is walking around the map, it doesn't matter. The PPU graphics, palette, etc… only change when it steps through a warp. Until that happens, it just keeps the same PPU graphics, palette, etc… that you had before.

Note that this presents a problem for loading map regions into DoaEditor that is documented here:
http://www.lordyuanshu.com/forums/topic/town-and-cave-editing/page/2/#post-53352

2. Look up which group of tiles are loaded into PPU memory.

How does it know which set of graphics to load?

A:00 X:0F Y:02 S:2A P:nvUbdIZC $BF38:A5 47 LDA $0047 = #$7E
A:7E X:0F Y:02 S:2A P:nvUbdIzC $BF3A:4A LSR
A:3F X:0F Y:02 S:2A P:nvUbdIzc $BF3B:A8 TAY
A:3F X:0F Y:3F S:2A P:nvUbdIzc $BF3C:B9 86 BF LDA $BF86,Y @ $BFC5 = #$55
A:55 X:0F Y:3F S:2A P:nvUbdIzc $BF3F:B0 04 BCS $BF45
A:55 X:0F Y:3F S:2A P:nvUbdIzc $BF41:4A LSR
A:2A X:0F Y:3F S:2A P:nvUbdIzC $BF42:4A LSR
A:15 X:0F Y:3F S:2A P:nvUbdIzc $BF43:4A LSR
A:0A X:0F Y:3F S:2A P:nvUbdIzC $BF44:4A LSR
A:05 X:0F Y:3F S:2A P:nvUbdIzc $BF45:29 0F AND #$0F
A:05 X:0F Y:3F S:2A P:nvUbdIzc $BF47:85 49 STA $0049 = #$00

What this is doing, loading the location ID (Xu Zhou / 7E), then LSR’ing it, transferring it to Y, and looking up from a table at $BF86-$BFC5 on page 0E (0x3bf95-0x3bfd5). Then it stores the value in $49 and uses it here to find where to look up tiles:

A:00 X:BA Y:00 S:28 P:nvUbdIZc $DEF5:A5 49 LDA $0049 = #$05
A:05 X:BA Y:00 S:28 P:nvUbdIzc $DEF7:0A ASL
A:0A X:BA Y:00 S:28 P:nvUbdIzc $DEF8:0A ASL
A:14 X:BA Y:00 S:28 P:nvUbdIzc $DEF9:0A ASL
A:28 X:BA Y:00 S:28 P:nvUbdIzc $DEFA:69 80 ADC #$80
A:A8 X:BA Y:00 S:28 P:NvUbdIzc $DEFC:85 01 STA $0001 = #$60
A:A8 X:BA Y:00 S:28 P:NvUbdIzc $DEFE:A9 00 LDA #$00
A:00 X:BA Y:00 S:28 P:nvUbdIZc $DF00:85 00 STA $0000 = #$78

So here it's going to use $A800 for the next lookup on the graphics page. $A800 = Town graphics:

World map graphics: 0x10010-0x1080f
Inside an Inn/House: 0x10810-0x1100f
Cave graphics: 0x11010-0x1180f
Inside castle graphics: 0x11810-0x1200f
Fortress graphics: 0x12010-0x1280f
Town graphics: 0x12810-0x1300f
Burnt Luo Yang: 0x13010-0x1380f

Now to put this info to use, let’s change Xu Zhou’s PPU tiles…

If I give Xu Zhou the "Burnt Luo Yang" graphics and palette I get some interesting results:

AWCicbP.png

Someone burnt down Xu Zhou!

3. Find the Map Region

First, the address in the warp when you walk into Xu Zhou is “0E 08 0F 01″ which is in the format Y1 Y2 X1 X2. With the Y2/X2 values being the region and the Y1/X1 values being the location on the region.

Now it will find the lookup table location for the region:

Load $1F which is the X2 value for the region (01), ASL (left shift) it, then store in $F3 (02).

Load $1D (Y2 value) which is 09 then multiply it by 40 which gives us 240. It then takes the “40″ and adds $F3 to it giving us 42. It then loads the “2″ from 240 and adds A7 to it giving us A9. This gives us the address to look up our region info which is $A942 which is used next.

Page 09 contains a table which includes a page number and a modifier. For example when I walk into Xu Zhou it loads the modifier at $A942 and $A943 which is 07 D5:

$D8D2:B1 10 LDA ($10),Y @ $A942 = #$D5 A:00 X:24 Y:00 S:22 P:nvUbdIZc
$D8D4:AA TAX A:D5 X:24 Y:00 S:22 P:NvUbdIzc
$D8D5:C8 INY A:D5 X:D5 Y:00 S:22 P:NvUbdIzc
$D8D6:B1 10 LDA ($10),Y @ $A943 = #$07 A:D5 X:D5 Y:01 S:22 P:nvUbdIzc

The ROM location for this table is at 0×26710-0x2770F so $A942 is at 0x26952.

Testing this… Let’s mess with the modifier and see what happens. I’ll replace D5 with DB and look what happens, it replaces an entire region in Xu Zhou:

bXgdHx8.png

4. Load the Map Tiles

So once it goes to page 07, it load D5 into memory then multiplies it by 8 which gives 0x06a8 and stores these values in $F4 (06) and $F3 (A8). Then it takes our 06a8 number and multiplies it by 8 again giving us 0x3540. Then it takes the “40″ and adds $F3 to it giving us E8 and it takes the “35″ number and adds $F4 to it giving us 0x3b then it takes that number and adds 0x80 to it giving us our region location which is $BBE8 on page 07 in this case. It uses $BBE8, applies a Y value, and looks up the tile here:

$D91E:B1 12 LDA ($12),Y @ $BC03 = #$8A A:1B X:06 Y:1B S:22 P:nvUbdIzc

Using this, I tracked down one of Xu Zhou’s regions stored at $BDE0 on page 07 which is 0x1FDF0. If I zero out that line look what happens:

GNBFIlt.png

5. Build the Map Tiles

Tracing how this tile is built:

DskcuSa.png

First it loads “C0″ (the tile ID) into memory via $D91E. Remember that in the world map there are 2 versions of “C0″. We have to figure out which one by loading the control code. More about that in Niahak’s old post here:

http://www.lordyuanshu.com/forums/topic/how-to-move-castles-change-graphics-etc-in-doae1#post-38133

So here it is loading the control code:

A:45 X:03 Y:45 S:22 P:nvUbdIzc $D931:B1 12 LDA ($12),Y @ $91FD = #$7F

7F = 01111111

This tile is in the middle of that row so it gets the high value “1″. Which means it’s tile # 2_192.

Blowing up the picture and looking at the PPU viewer you can see exactly how the small tiles make it up (4×4):

tbdll2o.png

To load the actual (small) tiles first it takes the tile ID. In this case "C0" and multiplies it by 4 (0x300) and stores it in $14 (00) and $15 (03). Then if the control code was "1" it adds 4 to $15 which gives us #07 (if control code was 0 it would stay at 03) then it loads the value from the table at D9B6. Testing this further I found that when it loads this value at $D944 the value for X is:

0 = World Map
1 = Inn/House, Caves, & Inside Castles
2 = Fortress, Town, & Burnt Luo Yang

So that table is at 0x3d9c6 (normal ROM) and 0x7d9c6/0xfd9c6 (expanded ROM): "80 8D 9A"

A:F0 X:FF Y:45 S:22 P:NvUbdIzC                              $D939:A5 15     LDA $0015 = #$03
A:03 X:FF Y:45 S:22 P:nvUbdIzC                              $D93B:69 03     ADC #$03
A:07 X:FF Y:45 S:22 P:nvUbdIzc                              $D93D:85 15     STA $0015 = #$03
A:07 X:FF Y:45 S:22 P:nvUbdIzc                              $D93F:A6 48     LDX $0048 = #$00
A:07 X:00 Y:45 S:22 P:nvUbdIZc                              $D941:A5 15     LDA $0015 = #$07
A:07 X:00 Y:45 S:22 P:nvUbdIzc                              $D943:18        CLC
A:07 X:00 Y:45 S:22 P:nvUbdIzc                              $D944:7D B6 D9  ADC $D9B6,X @ $D9B6 = #$80
A:87 X:00 Y:45 S:22 P:NvUbdIzc                              $D947:85 15     STA $0015 = #$07

This look up value (8700) will be used soon.

The value for Y in the next section depends on $1C which is derived from the Y1 value and $1E which is derived from the X1 value. I think the Y value used at $F657 and $F56D comes from which direction the character is walking so 00 should be ok. These values are stored at:

0x3F667 and 0x3F57D (normal ROM)
0x7F667, 0xFF667 and 0x7F57D and 0xFF57D (expanded ROM)

A:FF X:6E Y:00 S:22 P:NvUbdIzc                              $D80F:A6 61     LDX $0061 = #$08 <-- Y2
A:FF X:08 Y:00 S:22 P:nvUbdIzc                              $D811:86 1D     STX $001D = #$07
A:FF X:08 Y:00 S:22 P:nvUbdIzc                              $D813:A6 60     LDX $0060 = #$01 <-- Y1
A:FF X:01 Y:00 S:22 P:nvUbdIzc                              $D815:86 1C     STX $001C = #$09

$1C getting set basically translates to Y1.

A:F7 X:01 Y:00 S:22 P:NvUbdIzC                              $D82F:A6 63     LDX $0063 = #$01  <-- X2
A:F7 X:01 Y:00 S:22 P:nvUbdIzC                              $D831:86 1F     STX $001F = #$01
A:F7 X:01 Y:00 S:22 P:nvUbdIzC                              $D833:A6 62     LDX $0062 = #$0C  <-- X1
A:F7 X:0C Y:00 S:22 P:nvUbdIzC                              $D835:86 1E     STX $001E = #$0C

$1E getting set basically translates to X1.

Here is how it uses those values to generate a Y value which could be anywhere from 00 to 03:

A:00 X:02 Y:42 S:22 P:nvUbdIZc                              $D94E:A0 00     LDY #$00
A:00 X:02 Y:00 S:22 P:nvUbdIZc                              $D950:A5 1C     LDA $001C = #$05
A:05 X:02 Y:00 S:22 P:nvUbdIzc                              $D952:4A        LSR  <-- Right shift
A:02 X:02 Y:00 S:22 P:nvUbdIzC                              $D953:90 02     BCC $D957
A:02 X:02 Y:00 S:22 P:nvUbdIzC                              $D955:C8        INY
A:02 X:02 Y:01 S:22 P:nvUbdIzC                              $D956:C8        INY
A:02 X:02 Y:02 S:22 P:nvUbdIzC                              $D957:A5 1E     LDA $001E = #$0A
A:0A X:02 Y:02 S:22 P:nvUbdIzC                              $D959:4A        LSR  <-- Right shift
A:05 X:02 Y:02 S:22 P:nvUbdIzc                              $D95A:90 01     BCC $D95D
A:05 X:02 Y:02 S:22 P:nvUbdIzc                              $D95D:B1 14     LDA ($14),Y @ $9C2A = #$3A

It right shifts each one ($1C and $1E) and the original bit 0 is shifted into the carry.

Y starts as 0, then:
If X1 LSR (right shift) forces a binary “1″ into carry, then increase Y by 2
If Y1 LSR (right shift) forces a binary “1″ into carry, then increase Y by 1.

So any number that has a “1″ in the right most binary value will set the carry flag:

0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7
1000 = 8
1001 = 9
1010 = 10
1011 = 11
1100 = 12
1101 = 13
1110 = 14
1111 = 15

So for example if X1 is 6 then it will not cause Y to increase. If X1 is 7 then Y will increase by 2. Same with Y1. If the carry flag is set for X1 it will increase Y by 2, if it’s set for Y1 then Y will increase by 1.

Then we grab that lookup value (8700 in this case from page 09), add the Y value, and pull the value then store it in Y:

A:03 X:00 Y:02 S:22 P:nvUbdIzc                              $D95D:B1 14     LDA ($14),Y @ $8702 = #$0E
...
A:0E X:00 Y:02 S:22 P:nvUbdIzC                              $D9B0:A8        TAY

Then it uses the Y value to re-populate $14 and $15 with:

A:00 X:00 Y:0E S:24 P:nvUbdIZc                            $F57D:A9 00     LDA #$00
A:00 X:00 Y:0E S:24 P:nvUbdIZc                            $F57F:85 14     STA $0014 = #$00
A:00 X:00 Y:0E S:24 P:nvUbdIZc                            $F581:A6 48     LDX $0048 = #$00
A:00 X:00 Y:0E S:24 P:nvUbdIZc                            $F583:BD BA F6  LDA $F6BA,X @ $F6BA = #$88
A:88 X:00 Y:0E S:24 P:NvUbdIzc                            $F586:85 15     STA $0015 = #$87

As for the table at $F6BA, I think it follows the same rules for the X value as before:

0 = World Map
1 = Inn/House, Caves, & Inside Castles
2 = Fortress, Town, & Burnt Luo Yang

This table lives at:

Normal Rom:

0x3f6ca: 88 95 A2

Expanded ROM:

0x7f6ca: 88 95 A2
0xff6ca: 88 95 A2

So now the lookup value is $8800 which it adds Y to next. It then loads the (small) tiles 4 at a time and it actually looks like it looks up the tile IDs on page 9:

A:10 X:10 Y:0E S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $880E = #$C0
A:11 X:11 Y:0E S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $890E = #$C1
A:34 X:34 Y:0E S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8A0E = #$D0
A:35 X:35 Y:0E S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8B0E = #$D1

A:12 X:12 Y:0F S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $880F = #$C2
A:13 X:13 Y:0F S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $890F = #$C3
A:36 X:36 Y:0F S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8A0F = #$D2
A:37 X:37 Y:0F S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8B0F = #$D3

A:10 X:10 Y:0C S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $880C = #$B0
A:11 X:11 Y:0C S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $890C = #$A1
A:34 X:34 Y:0C S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8A0C = #$B0
A:35 X:35 Y:0C S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8B0C = #$B1

A:12 X:12 Y:0D S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $880D = #$A2
A:13 X:13 Y:0D S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $890D = #$A3
A:36 X:36 Y:0D S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8A0D = #$B2
A:37 X:37 Y:0D S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8B0D = #$B3

These are locations are coming from:

$880E = 0x2481E = C0
$890E = 0x2491E = C1
$8A0E = 0x24A1E = D0
$8B0E = 0x24B1E = D1

When it loads the actual tile ID (C0,C1,D0,D1, etc…), it’s giving the location in PPU memory starting with tile $80. That means for the world map, tile $80 is at 0x10010 and so on.

6. Load the Graphics Into PPU Memory

Next it actually loads the actual graphics into PPU memory. The graphics are located in these locations:

World map graphics: 0x10010-0x1080f
Inside an Inn/House: 0x10810-0x1100f
Cave graphics: 0x11010-0x1180f
Inside castle graphics: 0x11810-0x1200f
Fortress graphics: 0x12010-0x1280f
Town graphics: 0x12810-0x1300f
Burnt Luo Yang: 0x13010-0x1380f

And it loads them exactly how you see them in the FCEUX PPU Viewer. This is the first one loaded for Xu Zhou:

 1F:C3BD:B1 00     LDA ($00),Y @ $A800 = #$01
 1F:C3BF:8D 07 20  STA $2007 = #$95

Here's what it looks like in the PPU viewer (tiles $80-$FF):

NLMDJga.png

7. Load the Palettes

Here we see it starting to load the palette starting at $C655 in this case ($A3 is populated from $49 from step 2):

A:10 X:10 Y:38 S:27 P:nvUBdIzC                         $C5A8:A6 A3     LDX $00A3 = #$05
A:10 X:05 Y:38 S:27 P:nvUBdIzC                         $C5AA:BD B2 C6  LDA $C6B2,X @ $C6B7 = #$55
A:55 X:05 Y:38 S:27 P:nvUBdIzC                         $C5AD:85 F3     STA $00F3 = #$07
A:55 X:05 Y:38 S:27 P:nvUBdIzC                         $C5AF:BD C2 C6  LDA $C6C2,X @ $C6C7 = #$C6
A:C6 X:05 Y:38 S:27 P:NvUBdIzC                         $C5B2:85 F4     STA $00F4 = #$24
A:C6 X:05 Y:38 S:27 P:NvUBdIzC                         $C5B4:A0 00     LDY #$00
A:C6 X:05 Y:00 S:27 P:nvUBdIZC                         $C5B6:B1 F3     LDA ($F3),Y @ $C655 = #$01

The location look up value tables are at:

Normal ROM:

0x3C6C2-0x3C6D1: EF 11 22 33 44 55 66 77 77 88 99 B2 B2 B2 B2 B2
0x3C6D2-0x3C6E1: C5 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6

Expanded ROM:

0x7C6C2-0x7C6D1 & 0xFC6C2-0xFC6D1: EF 11 22 33 44 55 66 77 77 88 99 B2 B2 B2 B2 B2
0x7C6D2-0x7C6E1 & 0xFC6D2-0xFC6E1: C5 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6 C6

Palettes are stored in these locations.

Normal ROM:

0x3C5FF (World Map): 00 0F 27 29 1A 0F 00 30 29 0F 17 37 29 0F 20 31 11
0x3C621 (Inn/House): 01 27 16 00 0F 30 21 00 0F 38 27 00 0F 20 31 11
0x3C632 (Cave): 01 39 28 18 0F 37 27 17 0F 30 2B 1B 0F 20 2C 1C
0x3C643 (Inside Castle): 01 37 27 16 0F 30 25 37 0F 30 2B 27 0F 20 2C 27
0x3C654 (Fortress): 01 17 38 15 0F 17 29 19 0F 17 38 27 0F 20 38 17
0x3C665(Town): 01 27 37 15 0F 19 29 27 0F 20 10 27 0F 20 31 11
0x3C676 (Burnt Luo Yang): 01 27 37 15 0F 27 37 1A 0F 27 37 17 0F 20 10 11

Expanded ROM:

0x7C5FF & 0xFC5FF (World Map): 00 0F 27 29 1A 0F 00 30 29 0F 17 37 29 0F 20 31 11
0x7C621 & 0xFC621 (Inn/House): 01 27 16 00 0F 30 21 00 0F 38 27 00 0F 20 31 11
0x7C632 & 0xFC632 (Cave): 01 39 28 18 0F 37 27 17 0F 30 2B 1B 0F 20 2C 1C
0x7C643 & 0xFC643 (Inside Castle): 01 37 27 16 0F 30 25 37 0F 30 2B 27 0F 20 2C 27
0x7C654 & 0xFC654 (Fortress): 01 17 38 15 0F 17 29 19 0F 17 38 27 0F 20 38 17
0x7C665 & 0xFC665 (Town): 01 27 37 15 0F 19 29 27 0F 20 10 27 0F 20 31 11
0x7C676 & 0xFC676 (Burnt Luo Yang): 01 27 37 15 0F 27 37 1A 0F 27 37 17 0F 20 10 11

NES palettes:

pallettes.jpg

The remaining locations after these are other palettes (officer status screen, text etc…)

Warps

Credit: Meteorstrike and MiDKnighT

Warps happen whenever you step into a town or village, or even if you walk into a castle , store, or house while you are in town. You essentially teleport from one address to another address. Most of these warps are stored in the 0x1C### area of the ROM. There is the address of the place on the world map followed by the address of the entrance of a place. So if for example, you want to move a castle, here's what you would do…

Either use the latest DoaEditor and right click / move the warps. Or if you want the gory details:

1. With FCE Ultra or some emulator where you can view memory in real-time, watch $0060-$0063 when you walk around. Walk into your castle then walk out and don't move. That's where your "world map" warp is. Record this address…

2. Now use DoaEditor to remove the castle graphics on the map and put them somewhere else. Save your ROM.

3. Now go back into your emulator, walk to the spot where your castle entrance is, and record the address again.

4. Now find the old address in the ROM with a hex editor and change it to the new address.

However you're not done yet. If there was a castle battle at that address you will have to move that too. To do that see the BATTLES section below.

Thankfully, the battle address area of the ROM gives us the mailing address to most castles and gates. I have compiled a list here of castle world map entrances and town/inside addresses.

Place – World Map – Entrance – Location Code
LuoSang – 09070613 – 0C180618 – 7F
XuZhou – 0B070712 – 0E080F01 – 7E
QingZhou – 05060712 – 0E0B0002 – 7D
DaXing – 0A070211 – 0E0E0801 – 7C
TieMenXia – 0C090412 – 0E020C0A – 7B
HuLaoGuan – 080A0410 – 0E010D18 – 75
LuoYang1 – 0D09050E – 0E1A0707 – 21
LuoYang2 – C31A0707 – 0D0E001D – 71
YangZhou – 10A010D – 0907001D – 70
ChangAn – 09080A0A – 0E0B0F1D – 6F
Yuan – 030B060C – 0C13 081B – 6E
HuaiNan – 090C010B – 0E07071B – 6D
ChenCang – 030B010B – 0E1A041E – 6C
NanYang – 0B080209 – 0E170F1A – 6A
BoHai – 0507010B – 0E0F071A – 69
Chang – 0D070D0C – 0E010713 – 68
GuangZong – C3200708 – 05060017 – 67
JiZhou – 0D050D10 – 0A0C0F19 – 66
ChangSha – 0710010E – 0E1C0B1A – 65
GuiYang – 0912030E – 0E1E071E – 64
LingLing – 07100D09 – 0C1A081B – 63
WuLing – 890E0F0A – 0C1F0F1B – 62
LuoFengPo – 07140D04 – 0E100801 – 61
FuShui – 0D100907 – 0E1B0918 – 60
Luo – 030E0906 – 0E1E0318 – 5F
MianZhuGuan – 050D0605 – 0E120401 – 5E
ChengDu – 0B0C0107 – 0E1A0714 – 5D
JianAn – 0B14050B – 0E1C0514 – 5C
HuiJi – 0516090B – 0E140801 – 5B
Wu – 0D14010F – 0E1A0812 – 5A
PoYang – 080F070F – 0E010416 – 59
JinDu – 0D120F10 – 0E1F0912 – 58
JianYe – 09100D13 – 0E1F0F14 – 57
GuangLing – 0B0E0F15 – 0E1B070F – 56
HeFei – 0C0B0915 – 0E01040D – 55
RuNan – 0B0D0113 – 201E0910 – 54
ChenLiu – 060D0C0E – 0E01040F – 53
Chen – 0B0B090E – ? – 52
LuoYang – 0D09050E – ? – 51

And don't forget…there are…

Special considerations for warps:

  • There are also addresses for gullwings. These are generally 1 below the castle address. So Xu Zhou's gullwing address is 0C070712 and is stored at 0x38E04. After this the other "gullwing" castle addresses are stored. So after Xu Zhou's address is one tile south of Yang Zhou's address.
  • LuoSang village has 2 locations stored (09070613 and 09070713). 09070613 is the first warp and is at 0x1c370 while the other address is listed at 0×35564 and 0×36001.
  • There are at least 3 locations that I can think of that have 2 warps. Fan Shui Guan (Hua Xiong), Luo Yang (first Dong Zhou fight), and Guang Zong (Zhao Yun). These warp from the world map to another screen then to the castle. So for example Luo Yang's warps are:

0D09050E 0E1A0707 21 (warp to the field where you talk to Yuan)
C31A0707 0D0E001D 71 (warp to the entrance of the castle)

Battles

Changing the Battle Lineup

Credit: Meteorstrike, James, and Niahak (for DoaEditor changes)

Destiny of an Editor now supports battle editing!

For manual editing see: http://kongming.net/doae/rom_hacking/battles/

HEX OFFICER
03 Bandit Force
C8 Bao Long
02 Brigand Force
63 Bu Xi
18 Cai Yong
74 Cao Ang
70 Cao Cao
75 Cao Chun
73 Cao Hong
71 Cao Pi
72 Cao Ren
76 Cao Xiu
96 Cao Zhang
77 Cao Zhen
95 Cao Zhi
3B Chen Deng
1F Chen Ji
94 Chen Jiao
23 Chen Lan
34 Chen Lin
6A Chen Pu
90 Chen Qun
62 Chen Wu
44 Chen Ying
89 Cheng Yu
10 Cheng Yuan Zhi
79 Dian Wei
CB Ding Feng
BD Dong Min
BB Dong Zhuo
52 Fa Zheng
5F Fan Zhang
15 Fen Chou
CF Gan Ning
C2 Gao Lan
C9 Gao Pei
3F Gong Zhi
CE Gu Yong
AF Guan Ping
A4 Guan Suo
AC Guan Xing
A9 Guan Yu
12 Guo Ji
97 Guo Jia
33 Guo Tu
64 Han Dang
24 Han Xian
40 Han Xuan
38 Han Zhong
82 Hou Cheng
16 Hu Zhen
14 Hua Xiong
5E Huang Gai
53 Huang Quan
41 Huang Zhong
B8 Huo Hu
61 Jang Qin
1D Ji Ling
1A Jia Xu
8F Jiang Gan
D4 Jiang Wei
3E Jin Xuan
30 Ju Shou
6C Kan Ze
7C Le Xin
1E Lei Bo
4E Lei Tong
C6 Leng Bao
7D Li Dian
21 Li Feng
13 Li Jue
17 Li Ru
11 Li Su
37 Li Yan
22 Liang Gang
20 Liang Ji
60 Ling Tong
50 Liu Ba
A8 Liu Bei
AB Liu Chan
92 Liu Dai
35 Liu Du
AE Liu Feng
46 Liu Kui
4A Liu Xun
7F Liu Ye
47 Liu Zheng
BC Lu Bu (Dong Zhuo)
C4 Lu Bu (Ji Zhou)
C0 Lu Bu (Nan Yang)
B7 Lu Bu (Shu)
BF Lu Fan
C1 Lu Guang
6F Lu Ji
CC Lu Meng
65 Lu Su
69 Lu Sun
D1 Lu Wen
C3 Lu Xiang
B0 Ma Chao
B1 Ma Dai
9F Ma Liang
A0 Ma Su
2A Ma Yan
0F Ma Yuan Yi
8B Mao Jie
48 Meng Da
3D Mi Zhe
80 Niu Jin
B2 Pang De
9D Pang Tong
B4 Pirate
01 Pirate Force
04 Rebel Force
2E Shen Pei
8E Si Ma Shi
88 Si Ma Yi
8D Si Ma Zhao
0A Song Ren
8C Song Xian
0B Song Yong
56 Sun Ce [E]
9E Sun Gan
59 Sun Huan
57 Sun Quan
5A Sun Yi
58 Sun Yu
5D Tai Si Ci
D8 Tao Qian
31 Tian Feng
8A Wang Can
09 Wang Gui
93 Wang Lang
54 Wang Lei
87 Wang Shuang
81 Wei Xu
42 Wei Yan
2D Wen Hun
6D Wu Fan
4D Wu Lan
4C Wu Yi
85 Xia Hou De
7A Xia Hou Dun
84 Xia Hou Mao
86 Xia Hou Shang
7B Xia Hou Yuan
C5 Xing Dao Rong
D0 Xu Huang
BE Xu Rong
CA Xu Sheng
32 Xu Shou
D6 Xu Zhe
78 Xu Zhu
6B Xue Zong
D2 Xun Huo
D3 Xun You
2C Yan Liang
6E Yan Xun
4F Yan Yan
4B Yang Huai
B9 Yang Jin
43 Yang Ling
91 Yang Xiu
A5 Yi Ji [E]
7E Yu Jin
27 Yuan Shang
26 Yuan Shao
1B Yuan Shu
28 Yuan Tan
29 Yuan Xi
25 Yuan Yin
AD Zhang Bao
AA Zhang Fei
2F Zhang He
68 Zhang Hong
0C Zhang Jao
19 Zhang Ji
0E Zhang Liang
83 Zhang Liao
49 Zhang Ren
51 Zhang Song
1C Zhang Xun
2B Zhang Yi
67 Zhang Zhao
C7 Zhao Fan
D7 Zhao Yun
BA Zheng Mao
99 Zhou Cang
08 Zhou Chao
5C Zhou Tai
66 Zhou Yu
CD Zhu Ge Jin
D5 Zhu Ge Liang
5B Zhu Zhi
01 Pirate Force
02 Brigand Force
03 Bandit Force
04 Rebel Force
08 Zhou Chao
09 Wang Gui
10 Cheng Yuan Zhi
11 Li Su
12 Guo Ji
13 Li Jue
14 Hua Xiong
15 Fen Chou
16 Hu Zhen
17 Li Ru
18 Cai Yong
19 Zhang Ji
20 Liang Ji
21 Li Feng
22 Liang Gang
23 Chen Lan
24 Han Xian
25 Yuan Yin
26 Yuan Shao
27 Yuan Shang
28 Yuan Tan
29 Yuan Xi
30 Ju Shou
31 Tian Feng
32 Xu Shou
33 Guo Tu
34 Chen Lin
35 Liu Du
7F Liu Ye
37 Li Yan
38 Han Zhong
40 Han Xuan
41 Huang Zhong
42 Wei Yan
43 Yang Ling
44 Chen Ying
46 Liu Kui
47 Liu Zheng
48 Meng Da
49 Zhang Ren
50 Liu Ba
51 Zhang Song
52 Fa Zheng
53 Huang Quan
54 Wang Lei
56 Sun Ce
57 Sun Quan
58 Sun Yu
59 Sun Huan
60 Ling Tong
61 Jang Qin
62 Chen Wu
63 Bu Xi
64 Han Dang
65 Lu Su
66 Zhou Yu
67 Zhang Zhao
68 Zhang Hong
69 Lu Sun
70 Cao Cao
71 Cao Pi
72 Cao Ren
73 Cao Hong
74 Cao Ang
75 Cao Chun
76 Cao Xiu
77 Cao Zhen
78 Xu Zhu
79 Dian Wei
80 Niu Jin
81 Wei Xu
82 Hou Cheng
83 Zhang Liao
84 Xia Hou Mao
85 Xia Hou De
86 Xia Hou Shang
87 Wang Shuang
88 Si Ma Yi
89 Cheng Yu
90 Chen Qun
91 Yang Xiu
92 Liu Dai
93 Wang Lang
94 Chen Jiao
95 Cao Zhi
96 Cao Zhang
97 Guo Jia [F]
99 Zhou Cang
0A Song Ren
0B Song Yong
0C Zhang Jao
AD Zhang Bao
0E Zhang Liang
0F Ma Yuan Yi
1A Jia Xu
1B Yuan Shu
1C Zhang Xun
1D Ji Ling
1E Lei Bo
1F Chen Ji
2A Ma Yan
2B Zhang Yi
2C Yan Liang
2D Wen Hun
2E Shen Pei
2F Zhang He
3B Chen Deng
3D Mi Zhe
3E Jin Xuan
3F Gong Zhi
4A Liu Xun
4B Yang Huai
4C Wu Yi
4D Wu Lan
4E Lei Tong
4F Yan Yan
5A Sun Yi
5B Zhu Zhi
5C Zhou Tai
5D Tai Si Ci
5E Huang Gai
5F Fan Zhang
6A Chen Pu
6B Xue Zong
6C Kan Ze
6D Wu Fan
6E Yan Xun
6F Lu Ji
7A Xia Hou Dun
7B Xia Hou Yuan
7C Le Xin
7D Li Dian
7E Yu Jin
8A Wang Can
8B Mao Jie
8C Song Xian
8D Si Ma Zhao
8E Si Ma Shi
8F Jiang Gan
9D Pang Tong
9E Sun Gan
9F Ma Liang
A0 Ma Su
A4 Guan Suo
A5 Yi Ji [E]
A8 Liu Bei
A9 Guan Yu
AA Zhang Fei
AB Liu Chan
AC Guan Xing
AE Liu Feng
AF Guan Ping
B0 Ma Chao
B1 Ma Dai
B2 Pang De
B4 Pirate
B7 Lu Bu (Shu)
B8 Huo Hu
B9 Yang Jin
BA Zheng Mao
BB Dong Zhuo
BC Lu Bu (Dong Zhuo)
BD Dong Min
BE Xu Rong
BF Lu Fan
C0 Lu Bu (Nan Yang)
C1 Lu Guang
C2 Gao Lan
C3 Lu Xiang
C4 Lu Bu (Ji Zhou)
C5 Xing Dao Rong
C6 Leng Bao
C7 Zhao Fan
C8 Bao Long
C9 Gao Pei
CA Xu Sheng
CB Ding Feng
CC Lu Meng
CD Zhu Ge Jin
CE Gu Yong
CF Gan Ning
D0 Xu Huang
D1 Lu Wen
D2 Xun Huo
D3 Xun You
D4 Jiang Wei
D5 Zhu Ge Liang
D6 Xu Zhe
D7 Zhao Yun
D8 Tao Qian

The battles are listed in order starting at 0x30D70 and each contains 5 slots. One for each general ID. You can see the general IDs in DoaEditor on the Generals page.

Changing the Battle Location

Credit: Meteorstrike and MiDKnighT

Want to move a battle somewhere else? Sure… These are stored in our "world map" addresses. All the original battles are stored at:

BattleID Location Vert VertZone Horiz HorizZone
0 – Qing Zhou – 05 06 07 12
1 – Mt. Da Xing – 0A 07 02 11
2 – Tie Man Xia – 0C 09 04 12
3 – Qing Zhou (Cave) – 00 00 00 00
4 – Ma Yuan Yi – 00 00 00 00
5 – Qing Zhou (Front) – 05 06 07 12
6 – Si Shui Gate – 07 18 07 07
7 – Hu Lao Gate – 08 0A 04 10
8 – Luo Yang (Gate 1) *1* – 07 0A 08 0E
9 – Luo Yang (Gate 2) *2* – 03 0A 06 0E
A – Luo Yang – 03 1A 07 07
B – Yang Zhou – 01 0A 01 0D
C – Chang An (Gate 1) – 0B 08 00 0B
D – Chang An – 09 08 0A 0A
E – Yuan – 03 0B 06 0C
F – Huai Nan – 09 0C 01 0B
10 – Chen Cang Fortress – 03 0B 01 0B
11 – Nan Yang (Gate 1) – 05 09 02 09
12 – Nan Yang (Gate 2) – 01 09 00 09
13 – Nan Yang – 0B 08 02 09
14 – Bo Hai – 05 07 01 0B
15 – Xu Shou’s Fortress – 0D 07 0D 0C
16 – Guan Zhong – 03 20 07 08
17 – Yuan Shang (Town) – 00 00 00 00
18 – Ji Zhou (Gate 1) – 09 05 0D 10
19 – Ji Zhou (Gate 2) – 0B 05 0D 10
1A – Ji Zhou – 0D 05 0D 10
1B – Gui Yang – 00 00 00 00
1C – Ling Ling – 07 10 0D 09
1D – Ling Ling (Gate 1) – 03 10 0B 09
1E – Wu Ling – 09 0E 0F 0A
1F – Chang Sha – 07 10 01 0E
20 – Liu Kui’s Fortress – 07 14 0D 04
21 – Fu Shui – 0D 10 09 07
22 – Fu Shui (Gate 1) – 00 11 09 07
23 – Luo (Gate 1) – 01 0E 09 06
24 – Luo Castle – 03 0E 09 06
25 – Mian Zhu Guan Fortress – 05 0D 06 05
26 – Cheng Du (Gate 1) – 0D 0C 01 07
27 – Cheng Du – 0B 0C 01 07
28 – Ling Ling (Wu) – 07 10 0D 09
29 – Wu Ling (Wu) – 09 0E 0F 0A
2A – Jian An – 0B 14 05 0B
2B – Hui Ji Fortress – 05 16 09 0B
2C – Yan Xun *3* – 00 00 00 00
2D – Wu – 0D 14 01 0F
2E – Po Yang – 08 0F 07 0F
2F – Po Yang (Gate 1) – 0B 0F 07 0F
30 – Jin Du – 0D 12 0F 10
31 – Jin Du (Gate 1) – 0A 12 0F 10
32 – Lu Meng (Town) – 00 00 00 00
33 – Jian Ye (Gate 1) – 04 11 09 13
34 – Jian Ye (Gate 2) – 01 11 0A 13
35 – Jian Ye (Gate 3) – 0D 10 0A 13
36 – Jian Ye – 09 10 0D 13
37 – Guang Ling – 0B 0E 0F 15
38 – Guang Ling (Gate 1) – 0E 0E 0E 15
39 – He Nei Fortress – 0C 0B 09 15
3A – He Nei Fortress (Gate 1) – 05 0C 08 15
3B – Ru Nan (Gate 1) – 05 0D 02 13
3C – Ru Nan (Gate 2) – 08 0D 01 13
3D – Ru Nan – 0B 0D 01 13
3E – Chen Liu Fortress – 06 0D 0C 0E
3F – Chen Liu Fortress (Gate 1) – 08 0D 0C 0E
40 – Chen Jiao *4* – 00 00 00 00
41 – Xu Huang *5* – 00 00 00 00
42 – Chin – 0B 0B 09 0E
43 – Luo Yang (Gate 1) – 0B 0A 08 0E
44 – Luo Yang (Gate 2) – 07 0A 08 0E
45 – Luo Yang (Gate 3) – 03 0A 06 0E
46 – Luo Yang (Sima Zhao and Shi) – 0D 09 05 0E
47 – Luo Yang (Sima Yi) – 0D 09 05 0E
48 – Yuan Shao (Ambush) – 08 08 02 09
49 – Zhou Cang *6* – 00 00 00 00
4A – Huang Zhong and Wei Yan *7* – 00 00 00 00
4B – Pang Tong (Ambush) – 00 00 00 00
4C – Pirate Inn – 00 00 00 00
4D – Jian Ye (Taishi Ci) – 09 10 0D 13
4E – Ru Nan (Sima Yi) – 0B 0D 01 13
4F – Lu Bu (Shu Ambush) – 00 00 00 00

The battles with 0 0 0 0 address are triggered by an event (ie…talking to someone) or in Lu Bu and Pang Tong's case it comes as a random battle. For explanations on the *'s see: http://kongming.net/doae/rom_hacking/battles/

To change the battle location, the 4 address values are stored in:

0x30C10 = List of coordinate 1 positions for all boss battles.
0x30C68 = List of coordinate 2 positions for all boss battles.
0x30CC0 = List of coordinate 3 positions for all boss battles.
0x30D18 = List of coordinate 4 positions for all boss battles.

Ref: http://www.gamefaqs.com/boards/563402-destiny-of-an-emperor/47999342?page=4

Simply change all 4 values for the battle you are editing and the battle should be moved.

Enemy Soldier Counts

Are stored in 0x33EE0-0x33FDF. Each value is swapped. So "A2 01" = 100 and "85 00" = 418.

Battle Taunts

Credit: MiDKnighT

The opening line pointers for all battles are stored at 0x3AF21:

A6B7 AE00 0000 2324 8187 2628 8507 8081
8385 8387 8486 8200 8187 6D00 8084 8500
8084 8285 0086 8180 8582 8780 8683 8186
8180 0084 8182 FF86 82B9 8085 84BE D882
8386 DE84 8081 E7ED 5E00 0006 0060 D000

So A6 is the Qing Zhou battle, B7 is the Mt. Da Xing battle, AE is the Tie Man Xia battle, etc… The order of the battles can be found above. Which text bank it will use is at 0x3AF79:

0000 00FF FFFF 0101 0202 0101 0201 0202
0202 0202 0202 02FF 0202 02FF 0202 0203
0202 0202 0202 0202 0202 0202 0202 0202
0202 FF02 0202 FF02 0202 0202 0202 0202
0202 0202 0202 0202 0100 0003 FF02 02FF

Closing comments (like "Retreat they are too strong", etc…) are stored at 0x3B0A3:

CACA CA00 00D6 FF25 0000 27FF 0008 0000
0000 0058 0000 0000 0000 CF00 1000 0001
0000 0000 0100 0017 1B1A 0000 0000 0000
0000 0000 0000 6200 00BA 0000 0000 D900
0000 DF00 0000 ECEE 5F00 0007 0061 D3FA

Text banks for those are at 0x3B0FB:

0000 00FF FF80 FF01 FFFF 01FF FF81 FFFF
FFFF FF01 FFFF FFFF FFFF 81FF 83FF FF03
FFFF FFFF 02FF FF83 0303 FFFF FFFF FFFF
FFFF FFFF FFFF 02FF FF02 FFFF FFFF 02FF
FFFF 02FF FFFF 0202 01FF FF03 FF02 0202

Choose Battle Taunt Portraits

Credit: MiDKnighT

This enhancement will allow you to swap the opening or closing taunt portrait of any battle with whatever officer you want. The Taishi Ci battle at Jian Ye is the only battle in the game where someone else (Sun Quan) does the opening and closing taunt. This enhancement catches that spot at each place and diverts it to a lookup table on page 3D to replace the taunting officer's portrait. Here's the intercept points:

Opening Taunt:

A:1E X:BC Y:01 S:2C P:nvUbdIZc $AE5E:A6 75 LDX $0075 = #$0B <— Battle ID (Lu Bu gemsword battle)
A:1E X:0B Y:01 S:2C P:nvUbdIzc $AE60:E0 4D CPX #$4D <— Special Taishi Ci battle?
A:1E X:0B Y:01 S:2C P:NvUbdIzc $AE62:F0 F2 BEQ $AE56 <— Take a different code path

Then if it goes that direction, it loads Sun Quan's officer ID directly:

0E:AE56:A9 57 LDA #$57 <—- Sun Quan
0E:AE58:20 A9 CF JSR $CFA9

Using a debugger I swapped the value at $0075 and had Sun Quan talk instead of Lu Bu.

Closing Taunt:

0E:AFCC:A6 75 LDX $0075 = #$03 <— Load battle ID
>0E:AFCE:E0 4D CPX #$4D <— Special Taishi Ci battle?
0E:AFD0:F0 EF BEQ $AFC1 <— take a different code path

>0E:AFC1:20 B3 AB JSR $ABB3
0E:AFC4:A9 57 LDA #$57 <— Sun Quan
0E:AFC6:20 A9 CF JSR $CFA9

Hex Changes to use this enhancement (we have to add Sun Quan into the tables to keep the existing game Taishi Ci battle behavior):

0x3ae60:
38E901D0F660EA9820A9CF4C7DAEA93D
2082C4EABD69AFC9FFD00CA575C904D0

0x3afd0:
FF20B3ABA50020A9CF4CE7AFA93D2082
C4EABDEBB0C9FFD0034C5FB00A0820B3

0xf6e60:
00A90E2082C400000000000000000000
000000A675BDF0AEC900D005A007B9A8
60A84C51AE0000000000000000000000

0xf6fc0:
000000000000000000000000A90E2082
C4000000000000000000000000000000
00A675BDF0B0C900D005A007B9A86085
004CBCAF000000000000000000000000

0xf704d —> 57 (Sun Quan talks instead of Taishi Ci)
0xf714d —> 57 (Sun Quan talks instead of Taishi Ci)

Tables for storing which officer ID taunts for each battle:

Opening taunt officer table:
0xF70## where ## = battle ID

Closing taunt officer table:
0xF71## where ## = battle ID

Each value represents an officer ID. If it is "00" then the default behavior happens and the top enemy officer taunts.

Ambush Battles

Credit: Meteorstrike

The default ambush battles are:

Quote:
#$48 = 072 = (Nan Yang Outside) Yuan Shao
#$39 = 057 = (He Fei) Cao Pi
#$3D = 061 = (Ru Nan) Cao Pi
#$4E = 078 = (Ru Nan) Si Ma Yi
If, on the other hand, you want to change the 4 possible ambush battles to be different ones, OR get rid of them altogether, you can do this very easily:

0x39CEB = First boss battle that will be an ambush. (Should be 0×48 by default)
0x39CEF = Second boss battle that will be an ambush. (Should be 0×39 by default)
0x39CF3 = Third boss battle that will be an ambush. (Should be 0x3D by default)
0x39CF7 = Fourth boss battle that will be an ambush. (Should be 0x4E by default)

By changing the values at the above addresses, you will change the hard-coded opcodes that will test for the ambush-able boss battles… the values to use here are the boss battle IDs. A list of all the boss battle IDs can be found in the Damage Calculator.

If you want to get rid of ambush-able battles, simply use FF for the boss battle ID, since there is no boss battle with ID of FF.

Ref: http://www.gamefaqs.com/boards/563402-destiny-of-an-emperor/47999342?page=3

Random Enemies

Credit: Meteorstrike, James, sonic penguin, and ludmeister

Random enemy info is documented very well in this post:

Editing Guide for Rebels, Bandits, Brigands and Pirates
Below you can find all the information you need to edit strength, intelligence, agility, attack power, defense power, and soldiers for the Rebels, Bandits, Brigands and Pirates through the game. Thanks go out to MeteorStrike! If not for his research this would not be possible.

Random Enemies' Strength/Intelligence/Agility
Strength, Intelligence and Agility values for Bandits, Brigands, Pirates and Rebels are stored in two tables, one for Bandits, Brigands and Pirates, and another dedicated to Rebels, with eight entries—one for each chapter—and three hexadecimal values for each entry. Each entry’s hexadecimal values correspond to Strength, Intelligence and Agility. Strength and Agility are modified by a variance factor (see STR/INT Variance Factor below) but Agility is assigned as a raw value. Please note that if Strength or Intelligence are increased above 255 by the variance factor they will reset to 0 and start counting up from there. Values below 213 for Strength and Intelligence are probably safe unless a higher variance has been entered.

random_str_int_agi.png

Original ROM Size:

0x3E45B = Pirate/Brigand/Bandit Force

1MB ROM:

0x7E45B = Pirate/Brigand/Bandit Force
0xFE45B = Pirate/Brigand/Bandit Force

Code:
Ch.1 20 17 04 = 32 23 04
Ch.2 24 1A 0C = 36 26 12
Ch.3 2A 1E 14 = 42 30 20
Ch.4 30 22 1C = 48 34 28
Ch.5 37 27 28 = 55 39 40
Ch.6 3F 2D 38 = 63 45 56 * Rebel Force only in Shu
Ch.7 49 34 48 = 73 52 72 * Rebel Force only in Wu
Ch.8 54 3C 58 = 84 60 88 * Rebel Force only in Wei
0x3E473 = Rebel Force (0x7E473 and 0xFE473 for 1MB ROM)

Code:

Ch.1  2A 1E 08 = 42 30 08
Ch.2  30 23 18 = 48 35 24
Ch.3  38 28 28 = 56 40 40
Ch.4  40 2E 38 = 64 46 56
Ch.5  49 34 50 = 73 52 80
Ch.6  54 3C 70 = 84 60 112
Ch.7  61 45 90 = 97 69 144
Ch.8  6F 50 B0 = 111 80 176

0x3E48B = STR/INT Variance Factor (0x7E48B and 0xFE48B for 1MB ROM)

Strength, Intelligence and Agility values for Bandits, Brigands, Pirates and Rebels are randomized based on one of sixteen hexadecimal values stored at 0x3E48B, which are, by default, 00 = 0, 19 = 25, 26 = 38, or 33 = 51. There are many duplicate entries. To determine the variance this value is applied to the equation 1+($value/256). Please see below for formulas for the game’s default values. And also note that if your multipliers create numbers larger than 255 they will cycle down to 0 an start counting up again.

random_str_int_agi_variance.png

Code:

00 = 1 + ( 0 / 256 ) = 1.00
19 = 1 + ( 25 / 256 ) =~ 1.10
26 = 1 + ( 38 / 256 ) =~ 1.15
33 = 1 + ( 51 / 256 ) =~ 1.20

Random Enemies' Attack

Attack values are stored with one hexadecimal entry per chapter per unit of Pirate, Brigand, Bandit and Rebel Force. Pirates, Brigands and Bandits share attack values, but Rebels have their own table. To change defense values enter the desired value from the Weapon Selection Table below. Please note that the hexadecimal values entered correspond to a weapon in the game, not to a raw value (e.g. 09 would give the unit the same attack power as the Sword, which is 120 assuming you haven’t changed it elsewhere in the ROM).

random_attack.png

0x3E49B = Pirate/Brigand/Bandit Force (0x7E49B and 0xFE49B for 1MB ROM)

Code:

Ch.1  03 = 20 (Ax)
Ch.2  04 = 30 (Club)
Ch.3  04 = 30 (Club)
Ch.4  05 = 50 (Spear)
Ch.5  05 = 50 (Spear)
Ch.6  06 = 70 (Sabre)      * Rebel Force only in Shu
Ch.7  07 = 100 (Trident)   * Rebel Force only in Wu
Ch.8  08 = 80 (Bow)        * Rebel Force only in Wei

0x3E4A3 = Rebel Force (0x7E4A3 and 0xFE4A3 for 1MB ROM)

Code:

Ch.1  02 = 15 (Flail)
Ch.2  03 = 20 (Ax)
Ch.3  03 = 20 (Ax)
Ch.4  04 = 30 (Club)
Ch.5  04 = 30 (Club)
Ch.6  05 = 50 (Spear)
Ch.7  05 = 50 (Spear)
Ch.8  06 = 70 (Sabre)

Weapon Selection Table

Code:

00 =   0  (N/A)
 01 =  10  (Dagger)
 02 =  15  (Flail)
 03 =  20  (Ax)
 04 =  30  (Club)
 05 =  50  (Spear)
 06 =  70  (Sabre)
 07 = 100  (Trident)
 08 =  80  (Bow)
 09 = 120  (Sword)
 0A = 140  (Battleax)
 0B = 150  (Scimitar)
 0C = 130  (Crossbow)
 0D = 170  (Lance)
 0E = 190  (Wan Sheng)
 0F = 190  (Bo Ye)
 10 = 240  (Qing Guang)
 11 = 240  (Nu Long)
 12 = 240  (Qing Long)
 13 = 250  (Halberd)

Random Enemies' Defense

Attack values are stored with one hexadecimal entry per chapter per unit of Pirate, Brigand, Bandit and Rebel Force. Pirates and Brigands share defense values, but Bandits and Rebels have their own tables. To change defense values enter the desired value from the Defense Selection Table below.

random_defense.png

0x3E4BB = Pirate/Brigand Force (0x7E4BB and 0xFE4BB for 1MB ROM)

Code:

 Ch.1  00 = 10
 Ch.2  00 = 10
 Ch.3  01 = 20
 Ch.4  02 = 25
 Ch.5  03 = 35
 Ch.6  04 = 40   * Rebel Force only in Shu
 Ch.7  05 = 45   * Rebel Force only in Wu
 Ch.8  06 = 48   * Rebel Force only in Wei

0x3E4C3 = Bandit Force (0x7E4C3 and 0xFE4C3 for 1MB ROM)

Code:

Ch.1  00 = 10
 Ch.2  00 = 10
 Ch.3  01 = 20
 Ch.4  01 = 20
 Ch.5  02 = 25
 Ch.6  03 = 35   * Rebel Force only in Shu
 Ch.7  04 = 40   * Rebel Force only in Wu
 Ch.8  05 = 45   * Rebel Force only in Wei

0x3E4B3 = Rebel Force (0x7E4B3 and 0xFE4B3 for 1MB ROM)

Code:

Ch.1  00 = 10
 Ch.2  01 = 20
 Ch.3  02 = 25
 Ch.4  03 = 35
 Ch.5  04 = 40
 Ch.6  05 = 45
 Ch.7  06 = 48
 Ch.8  07 = 50

Defense Selection Table

Code:

 00 = 10
 01 = 20
 02 = 25
 03 = 35
 04 = 40
 05 = 45
 06 = 48
 07 = 50
 08 = 60
 09 = 70
 15 = 80
 0B = 85
 16 = 90
 28 = 95
 0D = 100
 0A = 110
 43 = 130
 0C = 160
 0E = 170
 0F = 180
 48 = 185
 59 = 200
 C3 = 215
 C8 = 230
 51 = 244
 1F = 255

Random Enemies' Soldiers

There are four possible soldier values for Bandit, Brigand, Pirate and Rebel Forces in each chapter. Whenever a unit is generated it is assigned one of the values below. Values are stored in two pairs. To convert to decimal reverse each hex value, treat as a single value, and convert to decimal (e.g. 0E 01 = 10E = 270). Do this in reverse to make a proper two-party hexadecimal entry into the ROM.

random_soldiers.png

Chapter 1 0x3E41B (0x7E41B and 0xFE41B for 1MB ROM)

Code:

 64 00 = 100
 64 00 = 100
 78 00 = 120
 8C 00 = 140

Chapter 2 0x3E423 (0x7E423 and 0xFE423 for 1MB ROM)

Code:

 78 00 = 120
 78 00 = 120
 96 00 = 150
 B4 00 = 180

Chapter 3 0x3E42B (0x7E42B and 0xFE42B for 1MB ROM)

Code:

 C8 00 = 200
 DC 00 = 220
 E6 00 = 230
 FA 00 = 250

Chapter 4 0x3E433 (0x7E433 and 0xFE433 for 1MB ROM)

Code:

 E6 00 = 230
 FA 00 = 250
 0E 01 = 270
 2C 01 = 300

Chapter 5 0x3E43B (0x7E43B and 0xFE43B for 1MB ROM)

Code:

 2C 01 = 300
 40 01 = 320
 5E 01 = 350
 7C 01 = 380

Chapter 6 0x3E443 (0x7E443 and 0xFE443 for 1MB ROM)

Code:

 BC 02 = 700
 52 03 = 850
 84 03 = 900
 E8 03 = 1000

Chapter 7 0x3E44B (0x7E44B and 0xFE44B for 1MB ROM)

Code:

 E8 03 = 1000
 4C 04 = 1100
 B0 04 = 1200
 14 05 = 1300

Chapter 8 0x3E453 (0x7E453 and 0xFE453 for 1MB ROM)

Code:

 DC 05 = 1500
 72 06 = 1650
 08 07 = 1800
 6C 07 = 1900

Many thanks to MeteorStrike for making this possible!
Ref: http://the-scholars.com/viewtopic.php?f=3&t=19872&st=0&sk=t&sd=a&start=10#p487840

To change the portrait of pirate force, brigand force, bandit force, rebel force, or even the Wu pirates, you need to first change the background from black 00 to some other color such as white 09. Once that is done, simply replace the 6 slices/strips for each force found below. – Keep in mind that these values can CHANGE as the rom is edited. These are *relatively accurate* values but not necessarily precise.

Sprites:
32803 Pirate Sprite
32824 Brigand Sprite
32846 Bandit Sprite
32867 Rebel Sprite

Pirate Force Portrait Color 32810
Pirate Force Portrait Strips 3280A-3280F

Brigand Force Portrait Color 32831
Brigand Force Portrait Strips 3282B-32830

Bandit Force Portrait Color 32853
Bandit Force Portrait Strips 3284D-32852

Rebel Force Portrait Color 32874
Rebel Force Portrait Strips 3286E-32873

Pirate (in Wu House) Portrait Color 33A35
Pirate Portrait Strips 33A2F-33A34

For example, if I change
32810 to 09
3280A to 00
3280B to 01
3280C to 02
3280D to 03
3280E to 04
3280F to 05

Then we will get Liu Bei's portrait to appear every time we encounter a Pirate Force. Pretty scary huh?

Note: The 6th Hex value BEFORE the first portrait slice controls the AP/Color of the Force. The 7th Hex value BEFORE the first portrait slice will allow you to change the sprite. These have address but I haven't typed them out yet.

Manually Editing Officer Stats

Credit: Niahak w/notes by sonic penguin

Here is a more accurate breakdown of how officer data is displayed in the hex:
Officer structure notes (from various sources, as well as DoaEd code).
Raw Hex Values: for example FF=255
ID # – this is not a raw hex number, it is a pointer to another table where the data is stored. This data can be easily referenced to in the ‘tables’ folder of DOAEditor.

STR – (Raw Hex Value)
INT (Raw Hex Value)
Region (chapter in which they are encountered) (Raw Hex Value)
Sprite (Graphic) (ID # from doae table)
Sprite Color (ID # from doae table)
DP as Enemy (ID # from doae table)
Soldiers (Enemy) (ID # from doae table)
Soldiers (Ally) (ID # from doae table)
Tactics (ID # from doae table)
AGI (Raw Hex Value)
Portrait Slice 1
Portrait Slice 2
Portrait Slice 3
Portrait Slice 4
Portrait Slice 5
Portrait Slice 6
Portrait BG (single-color BG only)
Page the portrait slices are found in (F0-FF)
unknown
Name Spacing
Officer Name

ludmeister: The game only allows Rebel Forces to attack you in Shu/Wu/Wei. If the game determines that the battle that is taking place is in one of these regions, normal encounters will be with Rebel Forces. I wanted to change this behavior, and allow the other "forces" to attack me. Here's how you do this:

Code:
0x3b315: "06" -> "09"
Also, if you want a different force to default to attack you when officers attack, here's where you'd change that:

Code:
0x3b319: "04" ->
"01" for Pirate Force
"02" for Brigand Force
"03" for Bandit Force

Soldier Bars

Credit: ludmeister and sonic penguin

In 0x3adfe-0x3ae13, we find data pertaining to how long the soldier line visualization is in battle, and the soldier count thresholds for when those lengths change (along with the color). I have not figured out where the color info is.

The length/color used is determined by the allied general who has the most soldiers when at maximum.

0x3adfe-0x3ae09: # of soldiers per pixel length
0a28 64c8 2c90 (Byte 1)
0000 0000 0101 (Byte 2)

000a (10), 0028 (40), 0064 (100), 00c8 (200), 012c (300), 0190 (400)

0x3ae0a-0x3ae13: Threshold value.
0107 1327 3a (Byte 2)
f4d1 8911 99 (Byte 1)

01f4 (500), 7d1 (2001), 1389 (5001), 2711 (10001), 3a99 (15001)

Changing these to more well-spaced-out values makes it possible to see the variations in late Wei soldier totals, as stock DoaE green soldier bars top out when an officer is currently leading around 25000 men.

Example change:

"0a1e 50c8 fae8
0000 0000 0103
0105 0f27 61
f4dd a111 a9"

Thresholds: 500, 1501, 4001, 10001, 25001
Soldiers/pixel: 10, 30, 80, 200, 500, 1000

Soldier Bar Color

The soldier bar color can be changed by modifying the values between 3ADF8-3ADFD. If I changed 3ADF8 to 19, then my pink bars turn green! Each of the 6 values controls the color of the bar for each of the colors in game. The stock colors are pink, orange, pale yellow, sky blue, and light green. You will need to refer to the color palette for color choices.

pallettes.jpg

Gold Awarded for Winning Battles and Item Sales

Credit: ludmeister

0x39ad7-0x39ae6: Gold awarded per chapter multipliers
0014 0028 003d 007a 00cc 0199 02cc 0400

For some reason, these are not stored like other values are, and are meant to be read as I divided them. So those multipliers are:

20 (Yellow Scarves campaign)
40 (Dong Zhou)
61 (Yuan Shu)
122 (Yuan Shao)
204 (Jing Zhou)
409 (Shu)
716 (Wu)
1024 (Wei)

One more little tidbit that controls the cash flow of the game, especially as your army begins swapping out expensive weapons/armor for more expensive ones… the sell rate that item shops observe. The multiplier is 75%, and this is found in the code here:

Code:
0E:8F17:A9 C0 LDA #$C0 <– Rate of selling, out of 255.
Therefore, to change this rate of exchange, edit this byte:

Code:
0x38f28: "c0"
"40" would be 25%, "80" would be 50%, and so on.

Spoils of War – POL version (uses POL to determine drop rate)

Credit: ludmeister (with some minor additions by MiDKnighT)

It requires at least a 512K ROM, and uses page 1E for its work.

0x3a547:

Code:
"A900 8573 20D79A A202 1E0005 38 7E0005 CA 10F6" -> "a91e 2082c4 200d82 2095d4 ea a900 8573 20d79a"
0x7a530:

Code:

 A200A9009D05629DAF60E8E006D0F560
 00000000000000A90E2082C44C50A5EA
 2082C400000000000000000000000000
 2020A52050A6A2021E0005387E0005CA
 10F6A92EC500F00FA5AD65604A65AF65
 10297FC56E3005A90E4C40A565AE4A65
 61651165AD290F856EAD3670AACA8A29
 070A0A0A0A656E856EEAEAEAA5AE6552
 651165626563297FC9153010A56EA8B9
 D0A5856EA900856F4C37A5EAA56EA8B9
 50A6856EA900856F4C37A5EA00000000
 31313131313131313132303030282B2C
 313131313131323232303030282B2C38
 323232323232323330303028282B2C38
 323232333333303028282B2B2C2C3838
 32333333333330302828282B2C2C3838
 33333333333334303028282B2C2C3838
 34343434343434303028282B2C2C3838
 343434343434302128282B2B2C2C3838
 AD9060AABD2064C900D005A908856E60
 4A4A4A4A856E60000000000000000000

0x7a560: This contains the algorithm guts. It decides whether something was found, and if so, whether it was a rare drop or not. Then, it picks a random item from 0 to 15, and gets that item from the correct chapter. Extra chapters are treated as the normal chapter of the same rank (Extended Wu would be treated as Wu).

0x7a5e0 – 0x7a65f: These are the random common drops. 8 regions, 16 items per region. This item table just has ordinary items (Elixirs, Gullwings, Steeds, Power Pills, Revives, and Smoke Pots), except for one Red Hare in Wei's region.

EDIT: Alternately, this table weaves in some gold and ration drops:

Code:

01010731313131313132303030282B2C
 010208313131323232303030282B2C38
 020309093232323233303028282B2C38
 03040A3232333333303028282B2C2C38
 04040A33333333303028282B2C2C3838
 04050A0B3333333334303028282B2C38
 05060B0C34343434343028282B2C2C38
 060C0C34343434213028282B2C2C3838

0x7a660 – 0x7a6df: These are the random rare drops. 8 regions, 16 items per region. You will probably want to make these more helpful drops, such as equipment, as they can be offered rarely and thus can be made to not totally break the game. The format for this table is exactly the same as the common drop table.

Party leader's POL attribute affects how often items are dropped. If your party leader has higher POL you will get more item drops.

You can change the ratio of rare to common drops. The value to change is in this instruction:

Code:

1E:A59C:C9 15     CMP #$15

This is the chance, out of 128, that this current drop is rare, as when execution reaches this instruction, we know we are receiving a drop. Change 0x7a5ad, making the value smaller to make rare drops more rare, and larger to make them more common. If you change this value to greater than 0×40, you would be making "rare" drops more common than "common" drops– silly you :geek: . Default chance for this drop to be rare is 20/128, or 5 out of 32.

3. Obviously, you can change the items that drop. It does seem that you can make more gold coins or food rations drop. I don't recommend that you allow reception of items that you cannot sell or discard :wink:

Spoils of War Original (does not use POL to determine drop)

Credit: ludmeister

First, here are the Hex changes to the ROM. It requires at least a 512K ROM, and uses page 1E for its work.

0x3a547:
Code:
“A900 8573 20D79A A202 1E0005 38 7E0005 CA 10F6″ -> “a91e 2082c4 200d82 2095d4 ea a900 8573 20d79a”

0x7a547:
Code:
a90e 2082c4 4c50a5 ea 2082c4

0x7a560: This contains the algorithm guts. It decides whether something was found, and if so, whether it was a rare drop or not. Then, it picks a random item from 0 to 15, and gets that item from the correct chapter. Extra chapters are treated as the normal chapter of the same rank (Extended Wu would be treated as Wu).

Code:

a202 1e0005 38 7e0005 ca 10f6 a5ad 6560
4a 65af 6510 297f c908 3005 a90e 4c40a5
65ae 4a 6561 6511 65ad 290f 856e ad3670
aa ca 8a 2907 0a 0a 0a 0a 656e 856e eaeaea
a5ae 6552 6511 6562 6563 297f c915 3010
a56e a8 b9d0a5 856e a900 856f 4c37a5 ea
a56e a8 b950a6 856e a900 856f 4c37a5 ea

0x7a5e0 – 0x7a65f: These are the random common drops. 8 regions, 16 items per region. This item table just has ordinary items (Elixirs, Gullwings, Steeds, Power Pills, Revives, and Smoke Pots), except for one Red Hare in Wei’s region.
Code:

31313131313131313132303030282B2C
313131313131323232303030282B2C38
323232323232323330303028282B2C38
323232333333303028282B2B2C2C3838
32333333333330302828282B2C2C3838
33333333333334303028282B2C2C3838
34343434343434303028282B2C2C3838
343434343434302128282B2B2C2C3838

EDIT: Alternately, this table weaves in some gold and ration drops:

Code:

01010731313131313132303030282B2C
010208313131323232303030282B2C38
020309093232323233303028282B2C38
03040A3232333333303028282B2C2C38
04040A33333333303028282B2C2C3838
04050A0B3333333334303028282B2C38
05060B0C34343434343028282B2C2C38
060C0C34343434213028282B2C2C3838

0x7a660 – 0x7a6df: These are the random rare drops. 8 regions, 16 items per region. You will probably want to make these more helpful drops, such as equipment, as they can be offered rarely and thus can be made to not totally break the game. The format for this table is exactly the same as the common drop table.

Helpful tips to make Battle Spoils work for you

1. You can make all drops more or less common. The value to change is in this instruction:

Code:
1E:A567:C9 08 CMP #$08

This determines the chance, out of 128, to gain an item. Change 0x7a578, making it larger to make drops more common, and of course make it smaller to make drops more rare. Default drop chance is 8/128, or 1 in 16.

2. You can change the ratio of rare to common drops. The value to change is in this instruction:

Code:
1E:A59C:C9 15 CMP #$15

This is the chance, out of 128, that this current drop is rare, as when execution reaches this instruction, we know we are receiving a drop. Change 0x7a5ad, making the value smaller to make rare drops more rare, and larger to make them more common. If you change this value to greater than 0×40, you would be making “rare” drops more common than “common” drops– silly you :geek: . Default chance for this drop to be rare is 20/128, or 5 out of 32.

3. Obviously, you can change the items that drop. It does seem that you can make more gold coins or food rations drop. I don’t recommend that you allow reception of items that you cannot sell or discard :wink:

I have tested this algorithm, and it will not bork the game if you don’t have any space to put the item; it will just scream at you with the default message saying that you don’t have any more room.

Here is a list of item ID’s you can use:
00 ~*006038 coins [glitch]
01 ~96 coins
02 ~237 coins
03 ~592 coins
04 ~1013 coins
05 ~1533 coins
06 ~4028 coins
07 ~29 food
08 ~125 food
09 ~821 food
0A ~2011 food
0B ~5902 food
0C ~10151 food
0D ~2098390 food
0E ~2148799 food
0F ~*86607 food [glitch]
10 [blank] ->
16 [blank]
17 Silver Key ->
18 Silver Key
19 Gemsword
1A Ma Letter [???]
1B Gun Powder
1C Intro Letr
1D Iron Ore
1E Dead Wood
1F Saltpeter
20 [glitch]
21 Chi Tu Ma [Red Hare]
22 Zhou Letr [Zhang Ltr]
23 Gold Key
24 Gullwing ->
28 Gullwing
29 [blank] ->
2A [blank]
2B Smoke Pot
2C Steed
2D Resurrect -> (glitched, use 30)
30 Resurrect
31 Elixir A
32 Elixir B
33 Elixir C
34 Elixir D
35 Power Pill -> (glitched, use 38)
38 Power Pill
39 Dagger ->
40 Dagger
41 Flail [Club]
42 Ax [Ax]
43 Club [Mace]
44 Spear [Flail]
45 Sabre [Spear]
46 Trident
47 Bow
48 Sword
49 Battleax [Great Ax]
4A Scimitar
4B Crossbow
4C Lance [Dadao]
4D Wan Sheng [Wansheng]
4E Bo Ye [Boye]
4F Qing Guang [Qingguang]
50 Nu Long [Nulong]
51 Qing Long [Qinglong]
52 Halberd
53 Robe ->
59 Robe
5A Leather ->
5B Leather
5C Padded ->
5D Padded
5E Ring M ->
5F Ring M
60 Chain M ->
61 Chain M
62 Splint M ->
63 Splint M
64 Plate M ->
65 Plate M
66 Bandana ->
68 Bandana
69 Cap
6A Hood
6B Wood H
6C Copper H
6D Bronze H
6E Iron H
6F Steel H
6F [glitch] ->
7F [glitch]
80 “I found a small keyhole.” ->
FF “I found a small keyhole.”

Officer Recruitibility

Credit: ludmeister and Meteorstrike

First of all, all officers have their status byte stored in memory in $6300-$63ff. They're stored in General ID order (to figure out a specific General's ID #, check him out in Destiny of an Editor).

If you check there, you'll see a number of repeating values… mostly 80, 90, 98, and C0.

80- You can never meet this officer in random battles.
90- You can meet this officer in random battles, and you can recruit him after the battle.
98- You can meet this officer in random battles, but you cannot recruit him after the battle.
C0- I don't know what this value means. Possibly linked to special cases… see below.

How officers are (normally) set to be recruitable

Furthermore, most castle battles will seek out a table of bits in the DoaE ROM, stored @ 0x3b153-0x3b172, and based on whether the a participant General's bit in this table is 1 or 0, will set the officer's status byte to "90" or not. In other words, if you meet Yang Huai in a castle battle, after the battle, it will check bit #0x4b in this table… bit #4 of 0x3b15c… and seeing that that bit is set (is = 1) will set Yang Huai as recruitable.

This is how the table @ 0x3b153-0x3b172 looks:

00 00 7f cf f8 3e f1 81 18 ff b8 1f ff ff 00 4d
a1 39 f9 00 00 10 20 03 72 f7 e0 80 00 00 00 00

Let's look @ 0x3b155 specifically now:

7f = 0111 1111

0 – 1 – 1 – 1 – 1 – 1 – 1 – 1 (bit-by-bit representation of 0x7f)
10- 11- 12- 13- 14- 15- 16- 17 (General ID)

So, if we met any of the officers with IDs between 11 and 17 in a (normal) castle battle, after the battle we could recruit them. If we met General ID 10 in battle, he'd stay resolute against our allies' cause and would not be recruitable… in fact their status would not change. If 80 (cannot be met), that would not change. If 98 (can meet him), that also would not change.

Officer's initial statuses

Initial statuses for generals are based upon a separate bit table, found at 0×35722-0×35741:

00 00 ff ef fc ff f7 83 f8 ff b8 ff ff ff 3f ff
ff 79 ff 00 00 00 00 23 76 f7 e0 80 00 00 00 00

If the bit is set, the initial status is 0×98 (you can encounter him in random battle but cannot recruit him). If not set, the initial status is 0×80 (you cannot meet him in random battle).

Special cases

I have not ferreted out special cases, but it is clear that there are exceptions to these rules… like when you beat the Zhang brothers in the cave behind Qing Zhou, and therefore don't engage Zheng Mao and Chengyuan Zhi, but they are still recruitable after that battle.

To make all officers recruitable… always

A change so powerful it might almost be considered cheating… to make any officer recruitable from a random battle… always, try this:

0x3a45d: "98" -> "99"

What this does is it changes this statement:

0e:a44c:C9 98 cmp #$98

to a statement that is never true, since no officer has a status of 0×99. Therefore, any and all officers you could engage in a random battle would be recruitable.

Officer Battle Recruit Event

Credit: MiDKnighT, sonic.penguin

Officer joins your party for free 3A48B
Default Value is 06

Decreasing this value will lower the likelihood an officer will join your party free of charge. Increasing the value will make it more likely they will join your party free of charge.

Officer joins your party for money or a steed 3A497
Default Value is 0C

Decreasing this value will lower the likelihood an officer will ask for money and increase the likelihood an officer will ask for a steed, for example 02. Increasing this value will increase the likelihood an officer will ask for money and decrease the likelihood an officer will ask for a steed for example 0E.

This can all be found here courtesy of MiDKnighT:

0E:A466:A5 AC LDA $00AC = #$0F <– Get random number
0E:A468:65 AE ADC $00AE = #$9A <– Get random number
0E:A46A:85 AC STA $00AC = #$0F <– Get random number
0E:A46C:29 0F AND #$0F
0E:A46E:C9 03 CMP #$03 <– If the value is < 03 he only serves his master.
0E:A470:B0 08 BCS $A47A <– He may join
0E:A472:20 0D D1 JSR $D10D <– I serve only my master!
0E:A475:6C 00
0E:A477:4C 1F A5 JMP $A51F
0E:A47A:C9 06 CMP #$06 <– If less < 06, auto join
0E:A47C:B0 08 BCS $A486
0E:A47E:20 0D D1 JSR $D10D
0E:A481:A0 02
0E:A483:4C D0 A4 JMP $A4D0
0E:A486:C9 0C CMP #$0C
0E:A488:B0 5F BCS $A4E9 <– Money or steed (if under 0C money, if over 0C horse)

So with this info we can control recruiting behavior. You could make it so that they always ask for a horse, always ask for money, or change the percentages…

Retreat Using LDR and AGI Attributes

Credit: MiDKnighT

I've made LDR and AGI important for retreating. Want to get away from most battles? Have someone with high LDR and AGI leading your party. Changes:

0x39FB0:
A5751013E8EAEAEAEAEAEAEAEAEAEAEA
EAEAEAEAEAEAEAA91E2082C4EAEAEAEA
EAEA200DD12F00A21420BCC0A209A900

0x79FB0:
000A3264060A0C0E000A326401020406
00000000000000A90E2082C48E3064AE
9060BD00644A8D3264BDB4614A6D3264
A207BD00644A8D3364EA4CE29FA90E20
82C4BDB4614A6D3364AE3064AD326438
ED33649011A003D9A09FB0038810F8B9
A49F85F3101438E90149FFA003D9A89F
B0038810F8B9AC9F85F34C30A0000000
00000000000000A90E2082C44C27A000
A5AD65AE290FC5F390034CB79F4CDD9F

How the regular retreat code works:

0E:9FA5:AD AF 60 LDA $60AF = #$04 <– Enemy leader general ID
0E:9FA8:C9 02 CMP #$02 <– Is it higher than pirate or brigand?
0E:9FAA:90 0B BCC $9FB7
0E:9FAC:E8 INX <– If so increment X making it harder to escape
0E:9FAD:C9 04 CMP #$04 <– Is it higher than bandit force?
0E:9FAF:90 06 BCC $9FB7
0E:9FB1:E8 INX <– If so increment X making it harder to escape
0E:9FB2:C9 08 CMP #$08 <– Is it higher than rebel force?
0E:9FB4:90 01 BCC $9FB7
0E:9FB6:E8 INX <– If so increment X making it harder to escape
0E:9FB7:A5 AD LDA $00AD = #$7B <– Random number check
0E:9FB9:65 AF ADC $00AF = #$6A <– Random number check
0E:9FBB:29 1F AND #$1F <– Random number check
0E:9FBD:DD 83 A6 CMP $A683,X @ $A781 = #$AC <– Check to see if it's less than this number, if so they got away. The numbers it checks against are 1E 1B 18 14. The higher X is, the harder it is to escape
0E:9FC0:90 20 BCC $9FE2 <– Got away
0E:9FC2:20 0D D1 JSR $D10D <– Didn't get away

So here are my changes:

I've re-worked the retreat code to make it more like a tactic succeed/fail. Now it is purely based on LDR+AGI of own leader vs enemy leader + randomness. The type of force (bandit, rebel, etc…) no longer matters. Only LDR+AGI matters.

1E:9FBC:8E 30 64 STX $6430 = #$04 <– Store current X value
1E:9FBF:AE 90 60 LDX $6090 = #$02 <– What general is leading our army?
1E:9FC2:BD 00 64 LDA $6400,X @ $6404 = #$73 <– Get LDR for leader
1E:9FC5:4A LSR
1E:9FC6:8D 32 64 STA $6432 = #$4F <– Get AGI for leader
1E:9FC9:BD B4 61 LDA $61B4,X @ $61B8 = #$36
1E:9FCC:4A LSR
1E:9FCD:6D 32 64 ADC $6432 = #$4F <– Combine LDR + AGI
1E:9FD0:A2 07 LDX #$07 <– Get enemy leader
1E:9FD2:BD 00 64 LDA $6400,X @ $6404 = #$73 <– Get enemy leader's LDR
1E:9FD5:4A LSR
1E:9FD6:8D 33 64 STA $6433 = #$29
1E:9FD9:EA NOP
1E:9FDA:4C E2 9F JMP $9FE2 <– Gotta skip ahead to leave space for a jump point
1E:9FDD:A9 0E LDA #$0E
1E:9FDF:20 82 C4 JSR $C482
1E:9FE2:BD B4 61 LDA $61B4,X @ $61B8 = #$36 <– Get enemy leader's AGI
1E:9FE5:4A LSR
1E:9FE6:6D 33 64 ADC $6433 = #$29 <– Combine enemy leader's LDR+AGI
1E:9FE9:AE 30 64 LDX $6430 = #$04 <– Get X back
1E:9FEC:AD 32 64 LDA $6432 = #$4F <– Get allied leader's LDR+AGI

Similar to tactic succeed/fail:

1E:9FEF:38 SEC
1E:9FF0:ED 33 64 SBC $6433 = #$0C <– Subtract enemy LDR+AGI from party leader's LDR+AGI
1E:9FF3:90 11 BCC $A006

We have higher LDR+AGI

1E:9FF5:A0 03 LDY #$03
1E:9FF7:D9 A0 9F CMP $9FA0,Y @ $9FA0 = #$00
1E:9FFA:B0 03 BCS $9FFF
1E:9FFC:88 DEY
1E:9FFD:10 F8 BPL $9FF7
1E:9FFF:B9 A4 9F LDA $9FA4,Y @ $9FA4 = #$06
1E:A002:85 F3 STA $00F3 = #$D4
1E:A004:10 14 BPL $A01A

Enemy has higher LDR+AGI:

1E:A006:38 SEC
1E:A007:E9 01 SBC #$01
1E:A009:49 FF EOR #$FF
1E:A00B:A0 03 LDY #$03
1E:A00D:D9 A8 9F CMP $9FA8,Y @ $9FA8 = #$00
1E:A010:B0 03 BCS $A015
1E:A012:88 DEY
1E:A013:10 F8 BPL $A00D
1E:A015:B9 AC 9F LDA $9FAC,Y @ $9FAC = #$01
1E:A018:85 F3 STA $00F3 = #$D4
1E:A01A:4C 30 A0 JMP $A030

Check to see if we made it:

1E:A030:A5 AD LDA $00AD = #$A0
1E:A032:65 AE ADC $00AE = #$2B
1E:A034:29 0F AND #$0F
1E:A036:C5 F3 CMP $00F3 = #$D4
1E:A038:90 03 BCC $A03D
1E:A03A:4C B7 9F JMP $9FB7 <– Didn't make it
1E:A03D:4C DD 9F JMP $9FDD <– Successful retreat

Preferred Weapons

Credit: MiDKnighT

*Note that this enhancement requires the enemy profiles enhancement*

With this change officers can only use the weapon types that are in their profile. This is based on the icon at the front of the weapon name so obviously this requires the use of icons to work.

DoaE_IPS_13_Patch2-11_zpsfca1cb1f.png

Changes:

0x388F0: E8C6F3D0EFA6F2201ABC

0x393F0: 9C60A93E2082C4

0x3BC20:
0A3264010204069D0061A93E2082C468
60020202040602080A01020401010801

0×78910:
0000A90E2082C4

0x7BCA0:
00000000000000004848BD0061684C02
89000000000000000000000000000000

0xEBC40:
0000000000000000000000000000A93E
2082C48C2278A54AA8B9A860A8A9F085
00A9998501B9F08ED0034C6EBCA8A500
1869109002E601850088C000D0F2A00B
B100CD2278D009BD0061EAEA684C32BC
C8C010D0EBA00FB9A0BC99507E8810F7
20507EA91E2082C40000000000000000
20B0C9200DD10F00A93A2082C4600000

0xEBCF0:
0000000000000000000000A93E2082C4
A9F08500A9998501BDF08ED0034C11BD
A8A5001869109002E601850088C000D0
F2A00BB100991878C8C010D0F6A000B9
B09B992878C8C005D0F54CEBBC000000

0xF93F0:
0000A90E2082C4A9C09D00632010BC4C
EBBC2009BC980A0A0AA8A200B90061C9
8010034C34948C2F78E980A8B900B085
00B970B08501A002B100A000D92378D0
034C4094C8C00BD0F3AC2F78B90061E9
80990061C8E8E009D0C2EAEAEAEAEAEA
2009BC980A0A0AA8A200B90061C9C0D0
07C9DFF0034C7094E8C8E009D0EC2009
BCA90099C060EAEAEAEAEAEAEAEAEAEA
2009BC4CE293

0xFBC10:
000000000000000000AE2078AC217860
8E20788C217860000000A90E2082C420
10BC68C9E9F00300000048BD0061A8B9
00B08500B970B08501A002B100A8A93A
2082C42009BC4C1ABC00000000000000

0xFBCF0:
0000000000000000000000A93A2082C4
4CF293

Damage

Critical Hits

Credit: MiDKnighT and Meteorstrike

Without going into too much detail, the amount of damage you will do will mainly depend on your STR and A.P. However, there is some randomization that occurs when you hit. See this post:

Now pick a random number between 0 and 255, and if the number is greater than or equal to 240 (F0), this is an excellent blow, so damage potential is 51. Otherwise, pick a random number between 0 and 15, and use this number to extract the damage potential from an array. The end resulting damage potential will be one of the following:

51 = 1 in 16 chance, excellent blow. Otherwise, damage potential is one of the following 3 values:
20 = 2 in 16 chance
23 = 6 in 16 chance
25 = 8 in 16 chance

These values live at 0×39948:

14 17 17 17 19 19 19 19 19 19 19 19 17 17 17 14

If you change these values you are changing the randomization of how random your normal attacks are (yours and the enemies). For example if you changed one of those 19's to a 1 and a normal attack will sometimes barely touch the opponent. Or change to an FF and occasionally a normal attack will result in brutal damage. But that's not what we would want to do…we would rather change the critical hits. With that said…

To change critical hit chances and damage there are 3 checks in the code to see if our random value is above F0 which means we got a critical hit. They are at:

00:AC19:A6 7C LDX $007C = #$4F
00:AC1B:A9 00 LDA #$00
00:AC1D:A4 7A LDY $007A = #$01
00:AC1F:F0 02 BEQ $AC23
00:AC21:A9 02 LDA #$02
00:AC23:E0 F0 CPX #$F0

Check whether to make "critical hit" sound

00:9847:A5 7C LDA $007C = #$62
00:9849:C9 F0 CMP #$F0

Check whether to do "critical hit" damage

00:9920:A5 7C LDA $007C = #$B4
00:9922:C9 F0 CMP #$F0

Check to see if "critical hit" text is used

In the ROM:

0x3AC33: E0 F0 <– for the sound
0x39859: C9 F0 <– for the damage
0x39932: C9 F0 <– for the text

And we have the "how bad will a critical hit hurt value":

00:984D:A9 33 LDA #$33

Default is 33 (51). This value is stored in:

0x3984D: A9 33

So if we were to make a critical hit twice as likely and make it hurt twice as bad we would make the following changes:

0x3AC33: E0 E1
0x39859: C9 E1
0x39932: C9 E1
0x3985D: A9 66

Note that lowering the first 3 values from F0 to E1 increases the critical hit chances.

Just for testing purposes if you set the first 3 to 00 and the last one to FF then every hit will be a brutal critical hit.

Weapon Damage

Credit: Meteorstrike and James

12 = ( NONE )
25 = Dagger
38 = Flail
56 = Ax
84 = Club
128 = Spear
192 = Sabre
435 = Trident
289 = Bow
655 = Sword
1024 = Battleax
1280 = Scimitar
768 = Crossbow
1536 = Lance
1792 = Wan Sheng
1792 = Bo Ye
2048 = Qing Guang
2048 = Nu Long
2048 = Qing Long
4096 = Halberd

Ref: http://www.gamefaqs.com/boards/563402-destiny-of-an-emperor/44112071

The low byte values for these are stored starting at 0x3E710 and the high byte values are stored starting at 0x3E724.

(7E710-7E737 and FE710-FE737 in 1MB Expanded Rom, low then high value order remains)

Changing the A.P. strength of weapons displayed in a general's profile:

0x38609 -> 00 0A 0F 14 1E 32 46

Dagger
Flail
Ax
Club
Spear
Sabre

0x38610 -> 64 50 78 8C 96 82 AA BE BE F0 F0 F0 FA

Trident
Bow
Sword
Battleax
Scimitar
Crossbow
Lance
Bo Ye
Wan Sheng
Qing Guang
Nu Long
Qing Long
Halberd

Change that FA at the end to FF and the Halberd displays an attack power of 255.

Change the BE BE to F0 F0 and all the magical swords have a displayed attack power of 240.

Ref: http://www.lordyuanshu.com/forums/topic/destiny-of-an-emperor-hacking-notes

DoaE2 Attack Algorithm

Credit: ludmeister

Since you all were wondering (maybe), here is the code for implementing a more DoaE2-like damage function, and then I'll discuss what it changes:

@ 0x397f2… to 0x3982d (0x3b bytes)

Old:

B9D0 6085 03B9 D160 8504 B9D2 6085 0520
88D6 A000 B904 01D0 07C8 C008 D0F6 F01B
84F2 A907 38E5 F285 F2A8 A900 8515 A5F2
1865 1585 1588 D0F6 205B C1

New:

B9D0 6085 04B9 D160 8503 A8C0 00F0 1F30
08C0 0830 12C0 2030 07A2 27A0 0A4C 1498
A20F A008 4C14 98A2 07A0 074C 1498 A201
A005 8600 4CE0 BFEA 205B C1

@ 0x3bff0… to 0x3c003 (0×14 bytes)

Old:

0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

New:

4603 6604 88C0 00D0 F7A5 0418 6500 8515 4C17 9800

To illustrate what the calculation does, here's a before and after.

Before:
*

Army size (soldiers) Strength multiplier (x = army size)
1 to 9 –> 1
10 to 99 –> 4
100 to 999 –> 9
1000 to 9999 –> 16
10000+ –> 25

Meteorstrike's discussion of the damage function helped me in this as he provided clues as to what to look for, so I would know that damage was being calculated.

Quite literally, the game calculated the number of digits in your current soldier total (like it might calculate the length of a string), and then squared that result. That number was multiplied by your strength, your weapon damage rating (not what you see in the status screen), and finally a number from the random table.

After
*

With my edits to the damage algorithm, your current soldiers modify the damage in this way:

Army size (soldiers) Strength multiplier (x = army size)
1 to 255 –> (x / 32) + 1
256 to 2047 –> (x / 128) + 7
2048 to 8191 –> (x / 256) + 15
8192+ –> (x / 1024) + 37

Hence, until you reach 256, you gain +1 to your strength multiplier every 32 soldiers. Then, from 384 to 2048, you gain +1 every 128 soldiers. At 2304 and every 256 soliders until 8192, you gain +1. Once you hit 8192 soldiers, you need another 1024 soldiers to gain a +1. Let's compare damage ratings with real figures.

Soldiers – Previous – Modified
10 soldiers – 4x – 1x
75 soldiers – 4x – 3x
550 soliders – 9x – 11x
1896 soldiers – 16x – 21x
5000 soldiers – 16x – 34x
40000 soldiers – 25x – 76x

Don't mess with overwhelming forces… or get overwhelmed! Mwa-hahaha

//Note that this battle damage formula changes the same area of the ROM as the "Expanded Chapters" enhancement. If you want this enhancement *and* ludmeister's DoaE2-like damage enhancement do the following:

1. Add the Agility based extra attacks enhancement.
2. Add the DoaE2-like Damage enhancement.
3. Edit the following:

0×39826: "4cc7a1"
0x3a1d7: "4603 6604 88C0 00D0 F7A5 0418 6500 8515 4C17 98"

4. Add the 8 Chapters enhancement.//

Agility Based Multi-attacks

Credit: ludmeister

Edits:

@ 0x3a1d2-0x3a1f9:

—- a91e 2082 c400 0000 0000 0000 0000
0000 0000 0000 0000 0000 d006 208d ab4c
5aa1 0000 0000 0000 a678 …..

@ 0x7a1d0-0x7a1f9:

0000 0000 0000 004c fbb1 0000 0000 0000
0000 0000 00a9 0e20 82c4 0000 0000 0000
0000 00a9 0e20 82c4 0000

@ 0x7b200-0x7b20f:

0000 0000 0000 0000 0000 00a9 0b20 82c4

@ 0x7b300-0x7b30f:

0000 0000 004c e3a1 0000 0000 004c d5a1

@ 0x2f210-0x2f30f (0×100, or 256 bytes)

bdd0 61d0 2aa9 409d d061 980a 0a0a a8b9
0061 c9c7 f010 eaea eaea eaea eaea eaea
eaea c9cb d003 4c9d b2c8 9829 07d0 e0a4
4ab9 b461 8510 a900 8511 bdd0 61a8 c040
f017 8884 12a9 00a0 3cc6 1088 c510 f02d
c000 d0f5 a412 4c3e b2a9 0085 12a5 ad65
ae65 10ea 85ad 290f a8b9 e0b2 8515 205b
c138 a44b b9b4 614c 8ab2 eaea ea4c d7b2
a44a fed0 61a9 004c f8b2 a8a9 00c6 1188
c511 f0e9 c000 d0f5 4c80 b200 00a5 ad65
ae65 1085 ad4c f8b2 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 00ea eaa9 00a4 4a4c f0b2
1926 3340 4c59 6673 8099 a6b3 c0cc e6ff
a91e 2082 c400 0000 a91e 2082 c400 0000

What it does:

1. Keeps the Bow/Crossbow bonus hit… applies this first. This is only valid for allies, as only allies have item packs.

2. After that, Agility is modified by a random percentage from a table @ 0x2f2f0. This is achieved by multiplying by a chosen value, then dividing by 256.

1926 3340 4c59 6673 8099 a6b3 c0cc e6ff

These values correspond to these percentages:
10%, 15%, 20%, 25%, 30%, 35%, 40%, 45%, 50%, 60%, 65%, 70%, 75%, 80%, 90%, 100-%

3. Then, that modified value is compared with the defender's agility.

4. If the defender's Agility is greater, then the turn ends. If not, a new attack is performed…. and the check is done again.

5. Each successive hit renders a cumulative 60 Agility penalty to all checks against the enemy's agility. Therefore, the chance to make another attack becomes nil very quickly… only the very fastest officers ever get a legitimate chance for three hits… and only on slow generals.

6. The Agility-based check is valid for allies as well as enemies hitting you… if you plan on using this modification, Agility will be a very important stat and thought will need to be spent on how you balance out officer's Agility throughout the game.

7. One interesting thing about this implementation… bonus attacks are not always awarded. A 255 Agility officer could hit a 160 Agility officer up to three times (255 – 120 penalty = 135… which would automatically fail that check against 160 Agility. However, because of the random table, it is *much* more likely that they would strike once, or twice.

Possible customization to the algorithm:

1. There are twelve "EA" NOPs in 0x2f226-0x2f231. These are intentionally left in, because that space is perfect for placing up to 3 extra item checks. This is what an item check looks like:

0x2f222 – 0B:B212:

C9 C7– CMP #$C7

(Is it an equipped Bow?)
0x2f224 – 0B:B214:

F0 10– BEQ $B226

*$B226 = $B214 + $#0010 (from statement) + $#0002 (trust me). To create a valid branch, you'll need to take whatever address to which you want to branch (always $B226 here), subtract the address of your branch statement (in this case, that's $B214), and subtract also the length of your branch statement (in 6502 assembly, I believe this value is always 2). That's how I arrived at the "10" at 0x2f225.

2. Obviously, the table for percentages (0x2f2f0-0x2f2ff) is editable. Note that in later IPS patches change 0x2f2## to 0x55## as this code was moved.

3. To remove the Random Agility check, and use this edit simply for expanded item checking:
Change 0x2f23f-0x2f241 to "4cd7b2"

0x2f23f – 0B:B22F: (0x553F in later IPS patches)

4C D7 B2– JMP $B2D7

(what that statement says)

4. To cap the number of extra hits from Agility at one, do this:
Change 0x2f252-0x2f254 to "4cd7b2"

0x2f252 – 0B:B242:

4C D7 B2– JMP $B2D7

5. To edit the cumulative Agility penalty on successive hits, edit this:
Change 0x2f258 to whatever you want.

0x2f257 – 0B:B247:

A0 3C– LDY $#3c

(Default penalty is 60)

Let's review.

1. Any bonus attack for equipment/item possession is applied first. There is a maximum of one item-based attack bonus. After that's out of the way…

2. Attacker Agility is first penalized based on the number of attacks made.

3. Then, it is multiplied by a random value from the table.

4. Then, the result is divided by 256.

5. Finally, this value is compared against the defender's agility.

6. If, after all that, the defender's agility is lower, a new attack is made… and after that attack is completed (and there's still an enemy standing), we'll do this check all over again.

7. With my default setup, it's rarer than it sounds to make extra attacks… unless the defender's Agility is abysmal.

Happy serendipities

In stock DoaE, if you get two attacks (for example, via equipped Crossbow), and manage a critical hit on strike #1, strike #2 is an automatic critical. This has been corrected, at least within successive hits based on Agility. I believe the auto-critical is also corrected if you make a critical on strike #1 with an equipped bow, though this has not been explicitly tested.

Errata

I noticed that after I had used a successful Negate tactic, Pang Tong got a second hit. That was not expected, but not bad. I wonder if this modification will suffer from the same difficulty that the Ambush tactic does… if an officer successfully uses Ambush and uses a Healing tactic the next round, often times he will strike his ally. More testing may be necessary to track this and fix it. However, I have used healing tactics successfully without extra attacks being applied to allies, so I don't think this is too much of a worry.

Also… Jiang Wei just hit that absolute maximum number of non-bow attacks… struck a group of chapter 2 Brigands <i>5 additional times.</i> (He was repelled once). Of course, he has 255 Agility, and the poor Brigands only had an Agility of 12… poor poor Brigands.

UPDATE: To have Qi Shou influence agility based attacks:

I believe I've had success updating the Agility-based multi-strike algorithm. Here's what's changed:

@ 0x3a1d2-0x3a1f9:

—- a91e 2082 c400 0000 0000 0000 0000
0000 0000 0000 0000 0000 d006 208d ab4c
5aa1 0000 0000 0000 a678 …..

@ 0x7a1d0-0x7a1f9:

0000 0000 0000 004c fb94 0000 0000 0000
0000 0000 00a9 0e20 82c4 0000 0000 0000
0000 00a9 0e20 82c4 0000

@ 0×79500-0x7950f:

0000 0000 0000 0000 0000 00a9 0120 82c4

@ 0×79600-0x7960f:

0000 0000 004c e3a1 0000 0000 004c d5a1

@ 0×5510-0×5686 (0×177, or 375 bytes)

BDD061D02AA9409DD061980A0A0AA8B9
00618412A000D9D095F010C8C007D0F6
A412C8982907D0E74C2F954C9D95EA4C
0096EAEAEAEAA9008511BDD061A8C040
F017888412A900A03CC61088C510F02D
C000D0F5A4124C3E95A9008512A5AD65
AE6510EA85AD290FA8B9E0958515205B
C1384C4096EAEA4C8A95EAEAEA4CD795
A44AFED061A9004CF895A8A900C61188
C511F0E9C000D0F54C80950000A5AD65
AE651085AD4CF8950000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
C7CBFFFFFFFFFFEAEAA900A44A4CF095
192633404C5966738099A6B3C0CCE6FF
A91E2082C4000000A91E2082C4000000
A44AB9B4618510A54BC907B007A8AD2D
624C1A96E907A8AD2C62C000F005884A
4C1A962901C901F0034C369546104C36
95000000000000000000000000000000
A44BB9B4618512A54AC907B007A8AD2D
624C5A96E907A8AD2C62C000F005884A
4C5A962901C901F0034C6E964612A512
A00084124C8A95

Data Tables

0x55e0-0x55e6 — Bonus Attack Item ID table. These items grant a guaranteed bonus strike.
0x55f0-0x55ff — Random % of attacker's AGI

Adding this code in place of the original guts of my Agility-based multi-strikes code will upgrade it so that you have the following functionality:

1. An Item ID table is read from when determining which items will grant one extra attack. The default IDs are "c7 cb ff ff ff ff ff". You do not need to modify the algorithm to add additional items to this. Remember, any item that is 80 to ff is considered equipped.

2. When an officer (enemy or ally) attacks a defender who has Qi Shou active, the attacker's AGI is halved for the purposes of executing multiple strikes.

3. When an officer (enemy or ally) has Qi Shou active and attacks, the defender's AGI is halved for the purposes of negating multiple strikes.

Therefore, if both attacker and defender have Qi Shou active, the attacker will pit half of their AGI against half of the defender's AGI.

Why the algorithm was implemented like this

When determining how to apply Qi Shou bonuses, I had to be mindful of the 8-bit nature of the NES. It would not do to multiply AGI by 2, because that would result in 8-bit overflows. Instead, I needed to use division, and therefore we have the resulting algorithm.

Base AC and Item Expansion

Credit: ludmeister

I've actually got an IPS patch together that does the Base AC and Item Expansion edits– just click on the link below to download it. You can only apply it (safely) to a 1MB ROM. If you're using Firefox… right clicky -> Save as.

Download Base AC and Item Expansion patch Note that IPS 1.3 and above also include this.

Patch details
***

Here's the nitty gritty of the stuff that has it's location changed:
Weapon Power- Status display: 0×78640 (none), 0×78641 to 0x7865f (ID #40 – #5e)
Weapon Damage- least significant byte: 0xfe710 to 0xfe72f (0×20 bytes), also 0x7e710 to 0x7e72f
Weapon Damage- most significant byte: 0xfe730 to 0xfe74f (0×20 bytes), also 0x7e730 to 0x7e74f
Armor Defense: 0xfe750 to 0xfe758 – Displayed AC in status screen (0×09 bytes), also 0x7e750 to 0x7e758
Helm Defense: 0xfe759 to 0xfe760 – Displayed AC in status screen (0×28 bytes), also 0x7e759 to 0x7e760
Defense values for opposing generals: 0xfe750 to 0xfe777 (0×28 bytes), also 0x7e750 to 0x7e777
Item Name Pointers: 0xfb010 to 0xfb0ef (0xe0 bytes)
Item Names: 0xfb110 to 0xfb80f (0×700 bytes)

That may look like a lot, but most of the stuff above is encapsulated in the 0xfe710 to 0xfe777 and 0x7e710 to 0x7e777 ranges.

So, Item IDs #40-#5e are used for weapons, #5f-#67 are for Armor, and #68-6f are for Helmets.

The patch creates the dummy names for the expansion items, and makes sure that all items are still in the same place (whether given at the start, sold in stores, or found in chests on hidden on the ground). Armor defense is not re-aligned for use with Base AC enhancement; it uses stock DoaE defense values.

The Base AC enhancement works as advertised (at least, as far as my meager testing as gone). The equation used is:

let x = STR/2 + INT/4 + AGI/4
Base AC = x * 3 * level / 256, capped at 100

In IPS patch 1.3 the formula is:

let x = VIT/2 + STR/4 + AGI/4
Base AC = x * 2 * level / 256, capped at 100

Tactics

Changing Tactic Names

Credit: MiDKnighT (for expanded tactic names)

Tactic names can be changed by:

1. Open the ROM in your hex editor.

2. Load the doaetable.tbl from DoaEditor.

3. Find the tactic names at 0x2FE4F

4. Change the tactic name as needed. Be careful about spacing! The other tactic names have pointers to them and we don't want to move them.

tactics.jpg

Expanded Tactic Names (1MB ROM):

DoaE_IPS_13_Patch2-0_zps079b782c.png

Tactic Name Pointers: 0xf8010 to 0xf820f

Tactic Names: 0xf8220-0xf920f (one per line)

0x7D590 & 0xFD590:
3C20A9D3A9684CA9D360A44DA93E2082
C4B9008085F3B9008185F4A00020D1D5

0xF8010:
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
00102030405060708090A0B0C0D0E0F0
82828282828282828282828282828282
83838383838383838383838383838383
84848484848484848484848484848484
85858585858585858585858585858585
86868686868686868686868686868686
87878787878787878787878787878787
88888888888888888888888888888888
89898989898989898989898989898989
8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A
8B8B8B8B8B8B8B8B8B8B8B8B8B8B8B8B
8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C
8D8D8D8D8D8D8D8D8D8D8D8D8D8D8D8D
8E8E8E8E8E8E8E8E8E8E8E8E8E8E8E8E
8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F
90909090909090909090909090909090
91919191919191919191919191919191
00000000000000000000000000000000
5A1B38303D0A17643EFF000000000000
5A28340A17643EFF0000000000000000
5A28303D0A2134FF0000000000000000
5A13300A2134FF000000000000000000
5A17643E0A2237343DFF000000000000
5B223764380A2364FF00000000000000
5B2237643827383D36FF000000000000
5B223764380A1B3438FF000000000000
5B173E3D3622376438FF000000000000
5B223764381B3E3D36FF000000000000
5E1237380A27383DFF00000000000000
5E233E3D362738303DFF000000000000
5E28383D0A2738303DFF000000000000
5E19383D0A2738303DFF000000000000
5E26303D0A1564FF0000000000000000
581664302D33FF000000000000000000
581F2D3E2F34322FFF00000000000000
411364343BFF00000000000000000000
7312340A1C38303DFF00000000000000
7219380A1C38303DFF00000000000000
511237302D3634FF0000000000000000
7428380A27383DFF0000000000000000
751B380A1938303DFF00000000000000
7420380A22373E64FF00000000000000
7F1938340A1234FF0000000000000000
76103D0A223730FF0000000000000000
0F1134380A1938FF0000000000000000
7215640A11383D36FF00000000000000
5F1B383534FF00000000000000000000
5F2130382E34FF000000000000000000

Tactic Atributes

Credit: Meteorstrike, ludmeister, and MiDKnighT

There are thirty tactics in DoaE, and are represented in the ROM in this order:

01 Lian Huo, Ye Huo, Yan Re, Da Re, Huo Shen
06 Shui Tu, Shui Xing, Shui Lei, Hong Shui, Shui Long
0b Chi Xin, Tong Xian, Yin Xian, Jin Xian, Wan Fu
10 Ji Rou, Huo Jian, Shui Jian, Ce Mian, Ji Mian
15 Cheng Nei, Yi Xin, Li Jian, Qi Shou, Jie Ce
1a An Sha, Bei Ji, Fu Bing, Tui Lu, Gui Huan

Tactic damage relies on the INT of the attacker, the INT of the opponent, and other factors. However, each tactic has a "damage potential" associated with it:

Note that these tables do not apply to IPS patch 1.3 and above (expanded tactics):italic text

Check the arrays at $BB8B,Y and $BBAA,Y. Here is the info in them for reference:
Tactic ID = Tactic Name = Type of Tactic = Damage Potential.

01 = Lian Huo = Damage = 003C = 60
02 = Ye Huo = Damage = 008C = 140
03 = Yan Re = Damage = 00AA = 170
04 = Da Re = Damage = 0514 = 1300
05 = Huo Shen = Damage = 07D0 = 2000
06 = Shui Tu = Damage = 0064 = 100
07 = Shui Xing = Damage = 00A0 = 160
08 = Shui Lei = Damage = 00C8 = 200
09 = Hong Shui = Damage = 05DC = 1500
10 = Shui Long = Damage = 09C4 = 2500

Ref: http://www.gamefaqs.com/boards/563402-destiny-of-an-emperor/47999342?page=2

You can find the first array at 0x3BB9C and the 2nd array at 0x3BBBB.

The low byte values are stored in the first array then the high byte values in the following array. For example the values for Da Re are at 0x3BB9F and 0x3BBBE.

As for healing tactics, the two arrays start at 0x3BC27

Tactic ID = Tactic Name = Type of Tactic = Healing Potential.

11 = Chi Xin = Recovery = 0064 = 100
12 = Tong Xian = Recovery = 01F4 = 500
13 = Yin Xian = Recovery = 03E8 = 1000
14 = Jin Xian = Recovery = 1194 = 4500
15 = Wan Fu = Recovery = FFFF = 65535

Array 1 starts at 0x3BC27, array 2 starts at 0x3BC2C.

The tactic cost table in the same neighborhood at 0x3BBDA:

02 04 06 08 0C 03 06 08 0C 0F 03 05 0A 04 0A 05 04 03 11 07 05 05 06 04 05 0A 0A 06 05 06

Tactic – Cost

01 = Lian Huo = Cost = 0002 = 2
02 = Ye Huo = Cost = 0004 = 4
03 = Yan Re = Cost = 0006 = 6
04 = Da Re = Cost = 0008 = 8
05 = Huo Shen = Cost = 000C = 12
06 = Shui Tu = Cost = 0003 = 3
07 = Shui Xing = Cost = 0006 = 6
08 = Shui Lei = Cost = 0008 = 8
09 = Hong Shui = Cost = 000C = 12
10 = Shui Long = Cost = 000F = 15
etc…

0x3b880-0x3b8b2- Tactic ID learned at level up (1st ID for level 1… last is level 50!)

00 01 11 06 0b 15 18 02 12 07 19 1c 0c 03 08 0d
10 1b 16 17 09 04 0f 14 1d 1e 1a 0e 0a 05 13 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00

Hence, ID #01 (Lian Huo) is learned at level 2, ID #11 (Huo Jian) is learned at level 3, ID #0f (Wan Fu) is learned at level 23… you get the picture.

0x3b8b2-0x3b8cf- Tactic appears in this "slot"

00 00 00 00 00 01 01 01 01 01 02 02 02 02 02
03 03 03 03 03 04 04 05 05 04 05 05 05 04 04

Since the ROM's tactic list is faithful to group Fire, Water, Healing, and Defense tactics, this is straight-forward. It gets interesting in the last two groups.

0x3b8d1-0x3b8ee- Priority level for tactic

01 02 03 04 05 01 02 03 04 05 01 02 03 05 04
03 01 02 05 04 01 03 03 01 02 04 05 02 04 05

Put simply, given your tactician can learn two tactics that are placed in a given "slot", the higher priority tactic is the one is given. Note that An Sha's priority is 04, and Bei Ji's is 05… thus the Pang Tongs and Zhu Ge Liangs of the world don't learn An Sha, even though An Sha is learned later in the game.

0x3b8f0-0x3b90d- Intellect needed for Tactic eligibility

3c 5a 78 b4 dc 46 64 82 a0 dc 46 a0 c8 fc dc
c8 50 6e f0 c8 78 b4 8c 8c a0 b4 f0 dc 8c 96

In 0x3bb3f-0x3bc30, a good share of data is stored describing the effects of all the tactics.

0x3bb3f-0x3bb5c- How to target the tactic

80 80 00 80 00 80 80 80 00 00 01 01 00 00 01
00 00 00 00 00 00 80 80 01 00 80 01 80 00 00

00 means that no targeting is needed. 80 means an enemy officer is targeted. 01 means that an allied general is targeted.

0x3bb5e-0x3bb7b- Targets all or not

00 00 80 00 80 00 00 00 80 80 00 00 01 01 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00 means to use the targeting info gleaned from input (see above). 80 means target all enemy officers, 01 means target all allied officers. Defense tactics, as well as special tactics such as Gui Huan and Tui Lu are special cases, and are simply target-less.

To make Shui Xing hit all enemy generals, therefore, we'd change 0x3bb45 from "80" -> "00", and 0x3bb64 from "00" -> "80". This means that Shui Xing needs no targeting from the player, and that it hits all enemy officers.

0x3bb7d-0x3bb9a- Elemental damage type (01- Fire, 02- Water)

01 01 01 01 01 02 02 02 02 02 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

To 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)

0×38348: "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.

8 Tactics

Credit: MiDKnighT and ludmeister

Want 8 tactics in your game? Do this:

0x3A8A9: 0406
0x3A914: C900F00C
0x3A928: 08
0x3B799: "0a85f3 0a65f3" -> "0a0a0a eaeaea"
0x3B7A3: "06" -> "08"
0x3B823: "07" -> "09"
0x3B827: "06" -> "08"
0x3B72A: 0A0A0AEAEAEA

Original Size ROM:

0x3FFF0: FF020AFAF82292FAF83E92FF
0x3EDD0: E0
0x3EE00: FF
0x3EBB8: FAF80EB7F80EB7FF
0x3E0DD: "ca65" -> "d865"
0x3DF36: 0A0AEAEAEA
0x3E0D1: "0a85f3 0a65f3" -> "0a0a0a eaeaea"
0x3E0D9: "06" -> "08"

1MB ROM:

0x7FFF0: FF020AFAF82292FAF83E92FF
0x7EDD0: E0
0x7EE00: FF
0x7EBB8: FAF80EB7F80EB7FF
0x7E0DD: "ca65" -> "d865"
0x7DF36: 0A0AEAEAEA
0x7E0D1: "0a85f3 0a65f3" -> "0a0a0a eaeaea"
0x7E0D9: "06" -> "08"
0xFFFF0: FF020AFAF82292FAF83E92FF
0xFEDD0: E0
0xFEE00: FF
0xFEBB8: FAF80EB7F80EB7FF
0xFE0DD: "ca65" -> "d865"
0xFDF36: 0A0AEAEAEA
0xFE0D1: "0a85f3 0a65f3" -> "0a0a0a eaeaea"
0xFE0D9: "06" -> "08"

To change the general status page:

8tactics_2.jpg
0x385E3: 23C513A0A0A0FFFF0000AAAAAAAA0F0F00000A0A0A0A <– PPU color switch
0x3861E: 0A <– Space in front of AC
0×38623: 10 <– "A"
0×38628: 12 <– "C"
0x3B74B: "05" -> "07"
0x385cb: 15 <– how much a "||" character is worth for STR/INT/AGI bar
0x385d9: 0a <– how much a "| " character is worth for STR/INT/AGI bar

Original Size ROM:

0x3EA75: FE <– Tactic Table
0x3EA8C: 03 <– Equip Box
0x3ea47: 16 <– How long a Stat bar entry is allowed to be in the status screen

1MB ROM:

0x7EA75: FE <– Tactic Table
0x7EA8C: 03 <– Equip Box
0x7ea47: 16 <– How long a Stat bar entry is allowed to be in the status screen
0xFEA75: FE <– Tactic Table
0xFEA8C: 03 <– Equip Box
0xFea47: 16 <– How long a Stat bar entry is allowed to be in the status screen

Just cut and paste these 5 lines starting at 3EA40 (7EA40 and FEA40 in 1MB ROM):

FBF8F2D4FEFAFC140AFB0A2223210AF8
7785FB0A181D230AF87785FB0A101618
0AF87785FB0A101F0A0AF87785FBF80D
86F87785FEFE010C6D0C0C2310122318
120C0C6E0C6EFAF80EB7FBFF03F90E6D

Adding agility stuff:

0x38601: B4F9B46161618560
0x38598: 03
0x385A3: 05
0x3937A: A9008DBB608DC76020C8E38DA361ACAF60A90120C8E38DAF61ACAF60A90920C8E38DBB

Once you have done all that you can assign tactics to slot "06" and "07" in 0x3b8b2-0x3b8cf using the tactic guide above. Recommended slot usage (unless using the enemy profiles enhancement):

Slot – Type of tactic
00 – Fire tactic
01 – Water tactic
02 – Heal tactic
03 – Secondary heal tactic, life, raise, or defensive tactic
04 – Any
05 – Any
06 – Any
07 – Any

This is mainly for the enemies. Without the enemy profiles enhancement, enemies will use fire and water tactics the same amount as they ever did and besides that will spread between tactics 04-07 evenly. When their HP is low they will use one of the tactics in slots 02 or 03 which is why we want to put a secondary healing tactic, life, raise, or a defensive tactic in slot 03.

"Life" and "Raise" Tactics (replaces Tui Lu/Escape and Gui Huan/Return)

Credit: MiDKnighT

To Enable "Life" and "Raise" for the Good Guys:

Life1.jpgLife2.jpg

Ally and Tactic Changes:

0x2FF37: 1B383534FFFFFF2130382E34FFFF <– tactic names
0x38D1D: 1DB0
0x3B98E: 4CCABA0000
0x3BACA: 206F8CA00CC91ED002A00F844D4C83B9B99C60A8A91E2082C4AAA91E2082C48A184CF3A7<– tactic code
0x3BBF6: 0A14 (10 and 20) <– tactic cost
0x3B90C: B4E6 (180 and 230) <– INT needed
0x3A805: "F0" –> "B0"

Success/Fail code:

0x7B98E: A90E2082C4
0x7B9DB: A90E2082C4
0x7B9E8: A90E2082C4
0x7BAC0: 98A44DC01D900AC98090034CCBB94CD8
B9C980B0034CCBB94C7EB900000000000000004CB0BA2082C44C5083<– main success/fail code

To Enable "Life" and "Raise" for the Bad Guys:

Life3.jpgLife4.jpg

First make all the ally and tactic changes then:

0x3B804: 0C
0x3A7FA: 4CD3BA0000E678A678
0x78360: A90C2082C4A90E4CD6BA
0x783BF: 4CDFA6
0x7A6EF: A90E2082C4
0x30360:
A91E2082C4188AA6789DE46184BEBC00
62C01DB00CAAE678A4BEA90085BE4C50
83A8ADFA01690585BFC8C00AD002A005
B9AA60C900F0F2B99E60C900F005C6BF
4C9983989DE461C6BFA5BFC900D0DABD
E461A8B99E60C900F005A91E2082C4A9
0085BEE6784C5083 <– Enemy target selection code (the hard part)

Recommendations:

- Use the tactic slot table to put "Life" and "Raise" in slot 03 if using 8 tactics or slot 02 if using 6 tactics. By doing this the enemy will only use "Life" or "Raise" if they are low on HP instead of any time.

0x3b8b2-0x3b8cf- Tactic appears in this "slot"

00 00 00 00 00 01 01 01 01 01 02 02 02 02 02
03 03 03 03 03 04 04 05 05 06 05 05 07 03 03

- Life should probably be introduced in mid-game (chapter 4-5?). So adjust level learned accordingly…

- Raise is an end game tactic that could be used by the nastiest smart bad guys. Should probably be introduced around chapter 6 or 7… So adjust level learned accordingly…

- Not a good idea to put too many enemies in one battle that have Revive and Raise or you may be in for a never-ending battle… :wink:

The main guts of the changes:

Succeed or Fail – Basically Success if ally is dead, fail if they are alive when using "Life" or "Raise":

00:BAD3:98 TYA
00:BAD4:A4 4D LDY $004D = #$1D
00:BAD6:C0 1D CPY #$1D <– Is this life or raise?
00:BAD8:90 0A BCC $BAE4
00:BADA:C9 80 CMP #$80 <– Is the ally alive or dead?
00:BADC:90 03 BCC $BAE1
00:BADE:4C CB B9 JMP $B9CB <– Tactic fails
00:BAE1:4C D8 B9 JMP $B9D8 <– Tactic succeeds
00:BAE4:C9 80 CMP #$80 <– Is the target alive or dead?
00:BAE6:B0 03 BCS $BAEB
00:BAE8:4C CB B9 JMP $B9CB
00:BAEB:4C 7E B9 JMP $B97E <– Test tactic for success/fail

Tactic Code:

00:BABA:20 6F 8C JSR $8C6F <– Call Resurrect Code
00:BABD:A0 0C LDY #$0C <– Call Salve for "Life"
00:BABF:C9 1E CMP #$1E
00:BAC1:D0 02 BNE $BAC5
00:BAC3:A0 0F LDY #$0F <– Call Revive for "Raise"
00:BAC5:84 4D STY $004D = #$1D <– Switch tactic
00:BAC7:4C 83 B9 JMP $B983 <– Go run heal tactic

Enemy Target Choice – Enemy randomly chooses a dead ally to bring back to life:

00:8355:18 CLC
00:8356:8A TXA
00:8357:A6 78 LDX $0078 = #$05 <– General who's turn it is
00:8359:9D E4 61 STA $61E4,X @ $61E9 = #$02 <– Store target
00:835C:84 BE STY $00BE = #$00
00:835E:BC 00 62 LDY $6200,X @ $6205 = #$1E <– What tactic are they using?
00:8361:C0 1D CPY #$1D <– Is it life or raise?
00:8363:B0 0C BCS $8371
00:8365:AA TAX
00:8366:E6 78 INC $0078 = #$05 <– Go to next ally.
00:8368:A4 BE LDY $00BE = #$00
00:836A:A9 00 LDA #$00
00:836C:85 BE STA $00BE = #$00
00:836E:4C 50 83 JMP $8350
00:8371:A8 TAY
00:8372:AD FA 01 LDA $01FA = #$06 <– Random number
00:8375:69 05 ADC #$05 <– Cycle through at least 5 times to look for dead allies
00:8377:85 BF STA $00BF = #$00
00:8379:C8 INY
00:837A:C0 0A CPY #$0A <– If we've hit the last ally, start at top again
00:837C:D0 02 BNE $8380
00:837E:A0 05 LDY #$05
00:8380:B9 AA 60 LDA $60AA,Y @ $60AF = #$54 <– Load general ID of target
00:8383:C9 00 CMP #$00 <– Is there a general in this slot?
00:8385:F0 F2 BEQ $8379
00:8387:B9 9E 60 LDA $609E,Y @ $60A3 = #$80 <– Is the target alive or dead?
00:838A:C9 00 CMP #$00 <– Ignore and choose a different target if they are alive
00:838C:F0 05 BEQ $8393
00:838E:C6 BF DEC $00BF = #$00
00:8390:4C 99 83 JMP $8399
00:8393:98 TYA
00:8394:9D E4 61 STA $61E4,X @ $61E9 = #$02 <– Store target to bring back
00:8397:C6 BF DEC $00BF = #$00
00:8399:A5 BF LDA $00BF = #$00
00:839B:C9 00 CMP #$00
00:839D:D0 DA BNE $8379
00:839F:BD E4 61 LDA $61E4,X @ $61E9 = #$02 <– Load target
00:83A2:A8 TAY
00:83A3:B9 9E 60 LDA $609E,Y @ $60A5 = #$80 <– Is the target alive or dead?
00:83A6:C9 00 CMP #$00
00:83A8:F0 05 BEQ $83AF <– If target is alive, choose something else to do.
00:83AA:A9 1E LDA #$1E
00:83AC:20 82 C4 JSR $C482
00:83AF:A9 00 LDA #$00
00:83B1:85 BE STA $00BE = #$1E
00:83B3:E6 78 INC $0078 = #$07
00:83B5:4C 50 83 JMP $8350

Officers Using Their Own Tactics

Credit: ludmeister and MiDKnighT

The function to choose tactic list is found in 0f:df0c (0x3df1c or in a 1MB ROM: 0x7df1c and 0xfdf1c). There, it checks to see whether this is a friend or foe. A foe chooses his own tactics. Otherwise, it goes to a little loop to see which general in your lineup has a "C0" in their "present" byte (80 means the general is present in your army, the added '40' bit means they are the strategist). Then it calculates where in memory to find the tactic list from this info.

To make each officer use their own tactic list, do this for the original size ROM:

0x3df26: "a44a4c24df"
0x3df26: A4 4A: LDY $004A (Memory location $004a is where the current attacking officer is stored)
0x3df28: 4C 24 DF: JMP $DF24 (Calculates position in memory to find this tactic list)

1MB ROM:

0x7df26: "a44a4c24df"
0x7df26: A4 4A: LDY $004A (Memory location $004a is where the current attacking officer is stored)
0x7df28: 4C 24 DF: JMP $DF24 (Calculates position in memory to find this tactic list)
0xfdf26: "a44a4c24df"
0xfdf26: A4 4A: LDY $004A (Memory location $004a is where the current attacking officer is stored)
0xfdf28: 4C 24 DF: JMP $DF24 (Calculates position in memory to find this tactic list)

That's all there is to it! If the officer has no tactic list, they are given the generic rebuttal "The tactician has not yet prepared any strategies." (This only used to be given for level one armies).

The strategist is still the one powering the group's TP store. So they still have a purpose. Unless you want to completely remove picking a tactician:

*To remove the need to have a tactician fueling your party TP

*Have the current TP = Max TP (after an inn)

*"STRAT" removed from the menu since it is unnecessary.

0x3B850:
EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAADF861

0x38375:
EAEAEAEAEA

0x39741:
0A0A0A0A0A0A

Original ROM size:

0x3EA0B: FFFFFFFFFFFF

1MB ROM:

0x7EA0B: FFFFFFFFFFFF
0xFEA0B: FFFFFFFFFFFF

DOAE Artificial Intelligence + New Charge Tactic

Credit: MiDKnighT

*** Note that this enhancement works best with the "8 tactics" enhancement. The Ce Mian/Negate piece will not fully work with 6 tactics.

The following enhancement makes these changes:

  • Enemies with INT > 180 should be complete bastards now as they should not re-use tactics that are already active… Difficulty should be higher against smart enemies.
  • If Ce Mian/Thwart is already active, they won't run it again (unless negated or expired).
  • If the good guys used Ce Mian, smart enemies (180+) with negate will only attack or attempt to Jie Ce/Negate.
  • If Ji Mian/Evade is already active, they won't run it again (unless negated or expired).
  • If Ji Rou/Guard is already active, they won't run it again (unless negated).
  • If Wuo Jian/Douse is already active, they won't run it again (unless negated or canceled by Ce Mian/Thwart, Ji Mian/Evade, or Ji Rou/Guard).
  • If Shui Jian/Levee is already active, they won't run it again (unless negated or canceled by Ce Mian/Thwart, Ji Mian/Evade, or Ji Rou/Guard).
  • If Yi Xin/Doubt is already active vs one of your allies, they shouldn't try to doubt the same person.
  • If Li Jian/Mislead is already active vs one of your allies, they shouldn't try to mislead the same person.
  • If Qi Shou/Haste is already active for one of the bad guys, they won't run it again (unless negated).
  • If Bei Ji/Zeal/Rally is already active, they won't run it again (unless negated).
  • If Ce Mian/Thwart is used by an ally or enemy, it cancels Ji Mian/Evade, Ji Rou/Guard, Wuo Jian/Douse, Shui Jian/Levee, and Cheng Nei/Castle/Barrier
  • If Ji Mian is used by an ally or enemy, it cancels Ce Mian/Thwart, Ji Rou/Guard, Wuo Jian/Douse, Shui Jian/Levee, and Cheng Nei/Castle/Barrier
  • If Ji Rou/Guard is used by an ally or enemy, it cancels Ce Mian/Thwart, Ji Mian/Evade, Wuo Jian/Douse, Shui Jian/Levee, and Cheng Nei/Castle/Barrier
  • Cheng Nei/Castle/Barrier effects added to Wuo Jian/Douse
  • Cheng Nei/Castle/Barrier effects added to Shui Jian/Levee
  • New tactic called "Charge" (power pill effects) to replace Cheng Nei

…Uses Cheng Nei's tactic slot.
…If "Charge" is used, the Cheng Nei status is *not* added.
…Still using Cheng Nei's success/fail code so INT does play a factor.
…Calls power pill code for a guaranteed critical hit then may hit again with a normal hit due to agility based attacks.

Hex Changes (IPS patch may have additional bug fixes):

0x043B8: E6ADA91E2082C4
0x04D44: A900A6789DD061A90E2082C4
0x2FEF9: 1237302D3634FFFFFF
0x3A7C9: A91E2082C4
0x3A952: A91E2082C4
0x3BA52: EAEAEAEAA91E2082C4
0x3BB53: 80
0x78010: A9012082C44C42A9
0x780D0: A9012082C44CB9A7
0x78210: A9012082C44C46BA
0x783BF: 4CDFA6
0x7A6EF: A90E2082C4
0x7A7C9: A90E2082C44CC080
0x7A952: A90E2082C44C0080
0x7BA56: A90E2082C44C0082
0x04010:
A91E2082C4A9019DD061A678BDAA61C9
B4B0034C0080BD0062AC2562C000D003
4C50808AE9050A0A0AAAA008BDD865E8
88C919D008A6789D00624C0080C000D0
EBA678BD00624C008000000000000000
C910B0034C0080C913D00AAC2462C000
F0034CA883C914D00AAC2662C000F003
4CA883C910D00EA8AD22622901C900F0
034CA88398C911D00EA8AD22622902C9
00F0034CA88398C912D00EA8AD226229
04C900F0034CA883984C008000000000
00000000000000000000000000000000
A91E2082C4A5F39DE461BDAA61C9B4B0
034CC080BD0062C916D00FA8AD28623D
3081C900F0034CA88398C917D00FA8AD
2A623D3081C900F0034CA88398C918D0
0FA8AD2C623D3081C900F0034CA88398
C91BD00FA8AD2E623D3081C900F0034C
A883984CC08000000000000000000000
01020408100102040810
0x041E0:
E858A80001031B61020202040602080A
01020401010801010102040810010204
08100000000000000000000000000000
A91E2082C4C015D0074C348D00000000
BD206219D0819D2062C010D011A9019D
2062A900E8E89D2062E8E89D2062C013
D00EA900CACA9D2062E8E8E8E89D2062
C014D00EA900CACACACA9D2062E8E89D
2062C011D00DA015BD206219D0819D20
62A011C012D00DA015BD206219D0819D
2062A0124C0082

To control INT for A.I… Ie… above what INT has additional A.I.?

0x04020: "B4" (180) – controls A.I. for Ce Mian, Ji Mian, Ji Rou, Wuo Jian, Shui Jian
0x040DE: "B4" (180) – controls A.I. for Yi Xin, Li Jian, Qi Shou, Bei Ji

A.I Enhancement Details:

00:8005:A9 01 LDA #$01
00:8007:9D D0 61 STA $61D0,X @ $61D8 = #$00
00:800A:A6 78 LDX $0078 = #$08 <– load general who's turn it is
00:800C:BD AA 61 LDA $61AA,X @ $61B2 = #$E6 <– find their INT
00:800F:C9 B4 CMP #$B4 <– greater than 180?
00:8011:B0 03 BCS $8016
00:8013:4C 00 80 JMP $8000 <– less than 180 goes back
00:8016:BD 00 62 LDA $6200,X @ $6208 = #$07 <– Load tactic being used
00:8019:AC 25 62 LDY $6225 = #$00 <– Check Ce Mian status
00:801C:C0 00 CPY #$00
00:801E:D0 03 BNE $8023
00:8020:4C 50 80 JMP $8050 <– If no Ce Mian, skip ahead
00:8023:8A TXA
00:8024:E9 05 SBC #$05
00:8026:0A ASL
00:8027:0A ASL
00:8028:0A ASL
00:8029:AA TAX
00:802A:A0 08 LDY #$08
00:802C:BD D8 65 LDA $65D8,X @ $65DF = #$00 <– Loop to look through tactics
00:802F:E8 INX
00:8030:88 DEY
00:8031:C9 19 CMP #$19 <– Does the enemy have negate?
00:8033:D0 08 BNE $803D
00:8035:A6 78 LDX $0078 = #$07
00:8037:9D 00 62 STA $6200,X @ $6207 = #$16 <– Use negate!
00:803A:4C 00 80 JMP $8000
00:803D:C0 00 CPY #$00
00:803F:D0 EB BNE $802C <– End Loop to look through tactics
00:8041:A6 78 LDX $0078 = #$07
00:8043:BD 00 62 LDA $6200,X @ $6207 = #$16
00:8046:4C 00 80 JMP $8000
00:8050:C9 10 CMP #$10 <– Ji Rou or greater?
00:8052:B0 03 BCS $8047
00:8054:4C 00 80 JMP $8000 <– If tactic number < Ji Rou (10) then finish
00:8057:C9 13 CMP #$13 <– Is tactic Ce Mian?
00:8059:D0 0A BNE $8055 <– If not Ce Mian skip ahead
00:805B:AC 24 62 LDY $6224 = #$00
00:805E:C0 00 CPY #$00 <– Is Ce Mian enabled?
00:8060:F0 03 BEQ $8055
00:8062:4C A8 83 JMP $83A8 <– Pick something else if Ce Mian enabled
00:8065:C9 14 CMP #$14 <– Is tactic Ji Mian?
00:8067:D0 0A BNE $8063 <– If not Ji Mian skip ahead
00:8069:AC 26 62 LDY $6226 = #$00
00:806C:C0 00 CPY #$00 <– Is Ji Mian enabled?
00:806E:F0 03 BEQ $8063
00:8070:4C A8 83 JMP $83A8 <– Pick something else if Ji Mian enabled
00:8073:C9 10 CMP #$10 <– Is tactic Ji Rou?
00:8075:D0 0E BNE $8075 <– If not Ji Rou skip ahead
00:8077:A8 TAY
00:8078:AD 22 62 LDA $6222 = #$00 <– Get Cheng Nei, Ji Rou/Guard, Wuo Jian, or Shui Jian Status
00:807B:29 01 AND #$01 <– Only look at Ji Rou
00:807D:C9 00 CMP #$00
00:807F:F0 03 BEQ $8074
00:8081:4C A8 83 JMP $83A8 <– Pick something else if Ji Rou enabled
00:8084:98 TYA
00:8085:C9 11 CMP #$11 <– Is tactic Wuo Jian?
00:8087:D0 0E BNE $8087 <– If not Wuo Jian skip ahead
00:8089:A8 TAY
00:808A:AD 22 62 LDA $6222 = #$00 <– Get Cheng Nei, Ji Rou/Guard, Wuo Jian, or Shui Jian Status
00:808D:29 02 AND #$02
00:808F:C9 00 CMP #$00
00:8091:F0 03 BEQ $8086
00:8093:4C A8 83 JMP $83A8 <– Pick something else if Wuo Jian enabled
00:8096:98 TYA
00:8097:C9 12 CMP #$12 <– Is tactic Shui Jian?
00:8099:D0 0E BNE $8099 <– If not Shui Jian skip ahead
00:809B:A8 TAY
00:809C:AD 22 62 LDA $6222 = #$00 <– Get Cheng Nei, Ji Rou/Guard, Wuo Jian, or Shui Jian Status
00:809F:29 04 AND #$04
00:80A1:C9 00 CMP #$00
00:80A3:F0 03 BEQ $8098
00:80A5:4C A8 83 JMP $83A8 <– Pick something else if Shui Jian enabled
00:80A8:98 TYA
00:80A9:4C 00 80 JMP $8000 <– All done

Targeted tactics:

00:80C5:A5 F3 LDA $00F3 = #$04
00:80C7:9D E4 61 STA $61E4,X @ $61EB = #$02
00:80CA:BD AA 61 LDA $61AA,X @ $61B1 = #$F1 <– find general's INT
00:80CD:C9 B4 CMP #$B4 <– greater than 180?
00:80CF:B0 03 BCS $80D4
00:80D1:4C C0 80 JMP $80C0 <– less than 180 goes back
00:80D4:BD 00 62 LDA $6200,X @ $6207 = #$14 <– what tactic?
00:80D7:C9 16 CMP #$16 <– is Tactic Yi Xin?
00:80D9:D0 0F BNE $80EA <– If not, skip ahead
00:80DB:A8 TAY
00:80DC:AD 28 62 LDA $6228 = #$00 <– check Yi Xin status
00:80DF:3D 30 81 AND $8130,X @ $8137 = #$04
00:80E2:C9 00 CMP #$00
00:80E4:F0 03 BEQ $80E9
00:80E6:4C A8 83 JMP $83A8 <– Pick something else
00:80E9:98 TYA
00:80EA:C9 17 CMP #$17 <– is Tactic Li Jian?
00:80EC:D0 0F BNE $80FD <– If not, skip ahead
00:80EE:A8 TAY
00:80EF:AD 2A 62 LDA $622A = #$00 <– check Li Jian status
00:80F2:3D 30 81 AND $8130,X @ $8137 = #$04
00:80F5:C9 00 CMP #$00
00:80F7:F0 03 BEQ $80FC
00:80F9:4C A8 83 JMP $83A8 <– Pick something else
00:80FC:98 TYA
00:80FD:C9 18 CMP #$18 <– is Tactic Qi Shou?
00:80FF:D0 0F BNE $8110 <– If not, skip ahead
00:8101:A8 TAY
00:8102:AD 2C 62 LDA $622C = #$04 <– check Qi Shou status
00:8105:3D 30 81 AND $8130,X @ $8137 = #$04
00:8108:C9 00 CMP #$00
00:810A:F0 03 BEQ $810F
00:810C:4C A8 83 JMP $83A8 <– Pick something else
00:810F:98 TYA
00:8110:C9 1B CMP #$1B <– is Tactic Bei Ji?
00:8112:D0 0F BNE $8123 <– If not, skip ahead
00:8114:A8 TAY
00:8115:AD 2E 62 LDA $622E = #$04 <– check Bei Ji status
00:8118:3D 30 81 AND $8130,X @ $8137 = #$04
00:811B:C9 00 CMP #$00
00:811D:F0 03 BEQ $8122
00:811F:4C A8 83 JMP $83A8 <– Pick something else
00:8122:98 TYA
00:8123:4C C0 80 JMP $80C0 <– All done

Making Ce Mian, Ji Mian, and Ji Rou mutually exclusive:

00:8210:BD 20 62 LDA $6220,X @ $6223 = #$00
00:8213:19 D0 81 ORA $81D0,Y @ $81E1 = #$02
00:8216:9D 20 62 STA $6220,X @ $6223 = #$00 <– store tactic status
00:8219:C0 10 CPY #$10 <– Is tactic Ji Rou?
00:821B:D0 11 BNE $822E
00:821D:A9 01 LDA #$01
00:821F:9D 20 62 STA $6220,X @ $6223 = #$00 <– clear Wuo Jian, Shui Jian, Cheng Nei status
00:8222:A9 00 LDA #$00
00:8224:E8 INX
00:8225:E8 INX
00:8226:9D 20 62 STA $6220,X @ $6223 = #$00 <– clear Ce Mian status
00:8229:E8 INX
00:822A:E8 INX
00:822B:9D 20 62 STA $6220,X @ $6223 = #$00 <– clear Ji Mian status
00:822E:C0 13 CPY #$13 <– Is tactic Ce Mian?
00:8230:D0 0E BNE $8240 <– if not, skip ahead
00:8232:A9 00 LDA #$00
00:8234:CA DEX
00:8235:CA DEX
00:8236:9D 20 62 STA $6220,X @ $6223 = #$00 <– Clear Ji Rou, Wuo Jian, Shui Jian, Cheng Nei status
00:8239:E8 INX
00:823A:E8 INX
00:823B:E8 INX
00:823C:E8 INX
00:823D:9D 20 62 STA $6220,X @ $6223 = #$00 <– Clear Ji Mian status
00:8240:C0 14 CPY #$14 <– Is tactic Ji Mian?
00:8242:D0 0E BNE $8252 <– if not, skip ahead
00:8244:A9 00 LDA #$00
00:8246:CA DEX
00:8247:CA DEX
00:8248:CA DEX
00:8249:CA DEX
00:824A:9D 20 62 STA $6220,X @ $6223 = #$00 <– Clear Ji Rou, Wuo Jian, Shui Jian, Cheng Nei status
00:824D:E8 INX
00:824E:E8 INX
00:824F:9D 20 62 STA $6220,X @ $6223 = #$00 <– Clear Ji Mian status

Adding Cheng Nei to Wuo Jian and Shui Jian:

00:8252:C0 11 CPY #$11 <– Is tactic Wuo Jian?
00:8254:D0 0D BNE $8263 <– if not, skip ahead
00:8256:A0 15 LDY #$15
00:8258:BD 20 62 LDA $6220,X @ $6223 = #$00
00:825B:19 D0 81 ORA $81D0,Y @ $81E1 = #$02
00:825E:9D 20 62 STA $6220,X @ $6223 = #$00 <– Add Cheng Nei status
00:8261:A0 11 LDY #$11
00:8263:C0 12 CPY #$12 <– Is tactic Shui Jian?
00:8265:D0 0D BNE $8274 <– if not, skip ahead
00:8267:A0 15 LDY #$15
00:8269:BD 20 62 LDA $6220,X @ $6223 = #$00
00:826C:19 D0 81 ORA $81D0,Y @ $81E1 = #$02
00:826F:9D 20 62 STA $6220,X @ $6223 = #$00 <– Add Cheng Nei status
00:8272:A0 12 LDY #$12
00:8274:4C 00 82 JMP $8200 <– All done

Charge Tactic:

00:8205:C0 15 CPY #$15 <– Is tactic in Cheng Nei slot?
00:8207:D0 07 BNE $8210 <– if not, skip ahead
00:8209:4C 34 8D JMP $8D34
00:8D34:A9 00 LDA #$00
00:8D36:A6 78 LDX $0078 = #$00 <– get slot id
00:8D38:9D D0 61 STA $61D0,X @ $61D3 = #$02 <– trick it to think we're using a power pill
00:8D3B:A9 0E LDA #$0E
00:8D3D:20 82 C4 JSR $C482 <– jump off to power pill code

Protect, Enhanced An Sha, and Duel Tactics

Credit: MiDKnighT

Protect:

  • Protect combines Wuo Jian, Shui Jian, and Cheng Nei into 1 tactic.
  • Enemies will not use it if Ji Mian, Ce Mian, or Ji Rou (Guard) are active.
  • The tactic will fail if you use it with Ji Mian, Ce Mian, or Ji Rou (Guard) active as those 3 tactics are more powerful.
  • If Ce Mian is used by an ally or enemy, it cancels Ji Mian, Ji Rou, Wuo Jian, Shui Jian, and Cheng Nei
  • If Ji Mian is used by an ally or enemy, it cancels Ce Mian, Ji Rou, Wuo Jian, Shui Jian, and Cheng Nei
  • If Ji Rou (Guard) is used by an ally or enemy, it cancels Ce Mian, Ji Mian, Wuo Jian, Shui Jian, and Cheng Nei

More info on the Enhanced An Sha:

  • The attacker's INT will be compared to the defender's INT. If the defender has 20+ more INT than the attacker then An Sha will fail.
  • If the defender is smarter than the attacker (by less than 20) then it's possible for the tactic to succeed but it will be pretty rare.
  • If the attacker is smarter than the defender, the more he is smarter the better the chance An Sha will succeed.
  • But if an officer has INT > 160, it will be twice as hard to An Sha them vs an officer with INT < 160.
  • There is an additional "No An Sha" list where you can add up to 32 officers (in addition to the original 7). This is stored at 0x44F0-0x450F. Simply put general IDs there if you don't want them An Sha'd.
  • There is a "secret sauce" formula to generate a "random number" that won't change much in battle unless major changes happen in the battle. That will make save state hacking a lot tougher if not impossible. If you save state and re-cast An Sha over and over, you'll almost definitely get the same result every time.
  • As for An Sha A.I., an enemy won't attempt An Sha on someone who is 15+ INT smarter than them.

More info on "Duel":

How it works:

1. Caster initiates "duel" with custom text:

duel4_1.png

2. Target decides to accept or reject without user input. Higher INT generals will weigh the odds of winning and intelligently decide whether to accept or reject. Lower INT generals are more likely to blindly accept. Higher STR generals are also more likely to accept. Lower INT generals may receive some kind of penalty for rejecting (Yi Xin and loss of Bei Ji/Qi Shou status). A very high INT general or general on the "rare duel list" (meant for rulers) might send a stronger general to duel in their place. Ie…if you cast duel on Zhuge Liang, he sends Zhao Yun out to duel. The "Rare Duel" list is at 0x44D0-0x44EF. Just put general IDs there (for rulers mainly…like Cao Cao, Sun Quan, Liu Bei, Dong Zhuo, Yuan Shu, etc…)

Example of someone accepting a duel and taunting back:

duel3_5.png

3. If the duel is accepted, the two duel participants step forward and clash:

duel_hit.png

There are many possible outcomes for a duel:

Close Match:

  • Draw (2/3rd chance) – Neither participant gets any status change
  • Both participants An Sha'd (1/3rd chance)

Clear Winner:

  • One person is An Sha'd (2/3rd chance)
  • Winner but both parties unharmed (1/3rd chance)
  • The winner will either receive an agility boost (2/3rd chance) or a Bei Ji boost (1/3rd chance) after victory.

Mismatch (Think: Lu Bu vs Song Yong) -

  • One person is An Sha'd (1/3rd chance)
  • Loser flees and is his own men are disgusted (1/3rd chance). The fleeing general will lose Qi Shou and Bei Ji status and get Yi Xin status.
  • Loser gets KILLED (An Sha'd and removed from the game) (1/3rd chance but this will also have stat protections (nobody over 220 STR, AGI, or INT will be killed unless on the mismatch list) and a no kill list. If the officer is protected it will just be An Sha).

Important lists:

4450-446F (mismatch list – winner)
4470-448F (mismatch list – loser)
4490-44CF = no kill list
44D0-44EF = rare duel list (for rulers mainly)
44F0-450F = bigger no an sha list

The "mismatch list" overrides any protections (no kill list or stat protections). If 2 generals on the mismatch list meet in a duel the mismatch loser will likely die. How it works… You put the winner in the first 2 rows and the loser in the last 2 rows. However, they must line up exactly. For example if I wanted Guan Yu to automatically kill Yan Liang in a duel I could put Guan Yu's general ID at 0×4458 and put Yan Liang's general ID at 0×4478 (exactly 2 rows under). Now if Yan Liang sees Guan Yu in battle he better run…

When it comes to duel there are 3 INT levels:

Below 180 = Only look at their own STR to decide whether or not to duel.
181-219 = Compare their STR vs their opponent and make a somewhat wise choice.
220+ = Rarely duel, see if they can send someone else in their place.

The "180" cutoff is at 0×4537.

The way it works now the only general that will never reject a duel is Lu Bu. With INT < 180 he is only looking at his own STR and he has max STR.

The formula for winning a duel is:

Own STR: 50%
Own AGI: 16.5%
Party Leader's LDR: 16.5% (Party leader's STR if you are on < IPS patch 1.3)
Secret Sauce Random Number: 16.5%

The final number from the above is compared to the opponent's final number of the above (but they have a different secret sauce random number). If they either only has a +10 or less advantage (0A) there is a draw, otherwise the one who wins by 10+ is the victor.

That said dueling against Lu Bu where Lu Bu is leading the enemy party would be very, very tough to beat but not impossible.

After Duel, there are 4 tactic replacements after this phase:

- Cheng Nei (Tactic ID: 10)
- Wuo Jian (Tactic ID: 11)
- Shui Jian (Tactic ID: 12)
- Original An Sha (Tactic ID: 1A)

With:

- Charge (Power Pill Affects – Tactic ID: 10)
- Protect (Wuo Jian + Shui Jian + Cheng Nei – Tactic ID: 11)
- Duel (Tactic ID: 12)
- Enhanced An Sha (Tactic ID: 1A)

For hex changes and addition code details see this thread:

http://www.lordyuanshu.com/forums/topic/duel-tactic-details#post-29868

Tactic Damage Level, Soldier, and Optionally STR, AGI, and INT based.

Credit: MiDKnighT

  • Tactic damage is level, soldier, and optionally STR, AGI, and INT based.
  • To calculate damage, use this spreadsheet and fill in the yellow boxes. The final estimated damage potential is in the gray box for each level. –> https://www.box.com/s/c550a40e0c0d8adf5cd7 (note that the latest version of DoaEditor has this too.
  • There are 3 lists to control whether a tactic gets a STR, AGI, or INT damage bonus. Simply put the tactic ID on the list (ie…01 for Lian Huo)
  • There is a list to control whether a damage/healing tactic always succeeds. For Lian Huo you would put "01" at 0×5710, Ye Huo at 0×5711, etc… Note that this list doesn't work for "Charge", "An Sha", or "Duel".

Lists are:

0×5710-0x572F: Tactic always succeed list. 01=always work (only for tactics 01-0F)
0×5730-0x573F: STR bonus list (put tactic ID in this list for STR bonus)
0×5740-0x574F: AGI bonus list (put tactic ID in this list for AGI bonus)
0×5750-0x575F: INT bonus list (put tactic ID in this list for INT bonus)

Hex Changes:

0x39790: 8511A9012082C4EA
0x3BA30: 11A91E2082C4EA
0x79860:
0000000000000000000000A9012082C4
4C21BA00000000000000000000000000
0x7BA30: 00A90E2082C44C5B98
0x4170:
C015D0034CB182C01AD0034CB182C012
D0034CB1A44DB90F97C901F0034CB182
4C908300000000000000000000000000
0x42B0:
A91E2082C4A44DC015D0034C348D4C60
81C01AD0034CB083A5AD65AE290FC5F3
0x5760:
AAA511C9FFF006A511690185118A6000
A678E005B00AAD73604A85B120B09760
BDB6604A4A4A85B120B0976000000000
0000A90E2082C4A90085128515206097
20E097202098EAEAEAEAEAEAEAEAEAEA
EAEAEAEA20F0874C8297000000000000
A54A0A0AAABD61614A4A4A85B2A67820
00884A4A4A4A85B6A6782020884A4A4A
4A85B7A6782040884A4A4A4A85B86000
A90085B385B485B5A00FB92097C54DD0
06A5B365B685B38810F0A00FB93097C5
4DD006A5B465B785B48810F0A00FB940
97C54DD006A5B565B885B58810F06000
A4B1A5101865B190032050971865B290
032050971865B390032050971865B490
032050971865B590032050978810D585
1060000000000000000000A91E2082C4
A9008512851520609720E097202098EA
20F0874C5B9800000000000000000000

Guard and Defend Enhancement

Credit: MiDKnighT (with a couple of bug fixes by ludmeister)

  • "Guard" will halve physical damage only
  • "Guard" and "Protect" are mutually exclusive, casting one over-writes the other. (if you have the A.I. and protect enhancements)
  • "Guard" will fail if Ji Main or Ce Mian are active (if you have the A.I. and protect enhancements)
  • Enemy will not cast "Guard" if Ji Mian or Ce Mian are active. (if you have the A.I. and protect enhancements)
  • Defend will now actually serve a purpose. It will do what Guard used to do (halve physical and tactic damage)
  • Defend will also gain TP automatically depending on INT.

Hex Changes:

0x40A0: 0190
0x4220:
C010D00F205083C000D0034C9583A901
9D2062C013D015A900CACA9D2062E8E8
E8E89D2062CACA69009D2062C014D015
A900CACACACA9D2062E8E89D2062E8E8
69009D2062C011D044205083C000D003
4C9583A90E9D2062EAEAEAEAEAEAEAEA
EAEAA90E9D2062EAEAEAEAEAEAEAEAEA
0x4360:
E8E8BD2062C900F002A000E8E8BD2062
C900F002A000CACACACA600000000000
0x58C0:
18C9F09002A9008D0070600000000000
4A4A4A4A4A4A60000000A90E2082C4A4
79B9D061C902D006461266116610B900
62C900D00CBD22624A90064612661166
104CCA98000000000000000000000000
A91E2082C4A5751007A90010034C0099
A678BDD061C902D0F4204088C996B002
A90020C09885B720CB8620C0981865B7
85B7A678204088AAA5B7E0DCB0014A20
B098186DFB61CDF861900AADF86138ED
FB6120B098ADFB61186D00708DFB61AD
FE6138ED007018EAC9F09002A9008DFE
612069D60070A90085B7A678A9809DD0
614C0099000000000000000000000000
0x398D0:
1006461266116610A67AA9012082C4EA
EAEAEAEAEAEAA478A57A4901AABD2E62

You'll also need to change the "[T-VALUE]is defending" text to say something like:

[T-VALUE]is
defending and
planning new[>]
strategies, [VALUE] [LVL-SLDR-AMT] TP
gained.[>][END]

Enemy Profiles (Which tactics they are likely to use)

Credit: MiDKnighT

Features:

  • Water tactic restriction is removed, you and the enemy can and will use water tactics anywhere.
  • Choice between attack vs tactics is the same as before but once we decide to use a tactic we randomly pick between the 8 slots then the A.I. is applied. That is…unless an officer has a "profile".
  • Enemy will not use heal unless they are at < 50% HP.
  • You can assign "profiles" to different officers. There are up to 29 profiles available. To assign a profile:

0x7A400-0x7A4FF is where you assign a profile to an officer (this is 0xE8F00-0xE8FFF in IPS 1.3). If Guan Yu's general ID is A9 you would assign his profile at 0x7A4A9 or 0xE8FA9 (last 2 numbers = general ID). If Lu Bu's general ID is C0 you would assign his profile at 0x7A4C0 or 0xE8FC0 (last 2 numbers = general ID). The profiles are:

00 = default (normal/random DOAE behavior)
01-1D = Custom profile

You set the attack/tactics for each profile at:

Profile Number – Location
01 – 0x7A510-0x7A51F
02 – 0x7A520-0x7A52F
03 – 0x7A530-0x7A53F
04 – 0x7A540-0x7A54F
05 – 0x7A550-0x7A55F
06 – 0x7A560-0x7A56F
07 – 0x7A570-0x7A57F
etc…

IPS 1.3 locations:

Profile Number – Location
01 – 0x79010-0x7901F
02 – 0x79020-0x7902F
03 – 0x79030-0x7903F
04 – 0x79040-0x7904F
05 – 0x79050-0x7905F
06 – 0x79060-0x7906F
07 – 0x79070-0x7907F
etc…

A profile would look like this:

FF FF FF FF 00 00 00 01 01 01 02 03 04 05 06 07

FF = attack and all the other numbers = tactic slot number.

With a profile like this, this officer will attack 1/4th of the time (4/16), he will use the tactic in slot 00 or 01 18.5% of the time (3/16) or will use a tactic in slot 02, 03, 04, 05, 06, or 07 6% of the time each (1/16).

As you can see with this system different officers can have unique personalities. You might have an officer that favors duel, favors attack, favors attack tactics, favors healing, etc… There are tons of possibilities for different personality types.

Changes:

0x4020: 96 (150 INT)
0x40DE: 96 (150 INT)
0x4030: 4C9081
0x4050: EBA678BD00624C9A81
0x4060: C910B0034CF091
0x41A0:
AC2362C00EEAEA4CB081A678A9009DD0
614C0080000000000000000000000000
AC2362C001F0034CC0814CC091000000
AC2762C001F0034C50804CC091000000
0x51D0:
20E691A900A008BDD865E888C900D005
4C008010F4A678BDD061C900D0034CA8
434C00800000A6788AE9050A0A0AAA60
0x5200:
C90AB0034C0080A67820D0888A0A0AAA
BD6161C900D0034C20924A85B3BDD160
C5B3B0034C00804CA883000000000000
BD60614A85B3BDD0604C109200000000
0x59A0:
A678BDAA60AAA91E2082C420F099A91E
2082C420F099A91E2082C40000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
A678203BDFA206600000000000000000
0x39EC6: 01->FF
0x3A6FA: A91E2082C4
0x3A7C0:
F4C6F410F0A678C6F3A5F39DE461E005
0x3A7FF: 2002A9EA
0x3A8F0:
AD290F85F3A5B6C901F021A678BDAA60
65AE65AF65ADE5AC4A4A4A4A4A85F4EA
EAEAEAEAEAEAEAEAEAEAEAEAA90085B6
85B785B8200CDFA90885F3BEA065BDA1
0x3A90F: 4C0CA9A91E2082C460
0x3A944: 12->FF
0x783BF:
A5AD0A0A18A678E0099004A20986784CDFA6
0x79990:
0000000000000000000000A9012082C4
000000000000A9012082C44CFAA6A901
2082C44CEAA600000000004C40A70000
0x799B0:
2082C44CEAA60000000000BA86BFE010
B0034C96A8E07090034C96A84C40A700
0x7A6E0:
000000000000000000000000000000A9
0E2082C4000000000000A90E2082C44C
8B990000000000000000BDF0A3C900D0
034C9699180A0A0A0A85B7A9A59002A9
A685B8A5B7E90F85B7A8A90185B6A5AD
65AE65AF4A4A4A4AA8B1B7C9079007A9
0085F34C9E9985F44C9E990000000000
A90E2082C40000000000000000000000
0x7A8A6: A90E2082C4
0x7A910:
0000A90E2082C4A578C90AB002E678A6
784C02A9000000000000000000000000

Tactic Expansion Framework (1MB ROM Only)

Credit: MiDKnighT

The framework for tactic expansion is complete!

There is now room for 255 tactics in the game. To do this I had to move and replace all of the tactic tables. The lists are at:

  • 0xE8400–0xE84FF – Attributes associated with tactic
  • 0xE8500–0xE85FF – Stat level needed to learn tactic
  • 0xE8600–0xE86FF – Slot of tactic
  • 0xE8700–0xE87FF – Priority level of tactic
  • 0xE8800–0xE88FF – Tactic cost table
  • 0xE8900–0xE89FF – How to target the tactic
  • 0xE8A00–0xE8AFF – Targets all or not
  • 0xE8B00–0xE8BFF – Elemental damage type
  • 0xE8C00–0xE8CFF – Damage Potential 1
  • 0xE8D00–0xE8DFF – Damage Potential 2
  • 0xE8E00–0xE8EFF – Offensive/Defensive Tactic
  • 0xE9000–0xE903F – Tactic ID level learned

Tactic Names are on Page 3E starting at 0xF8220.

So to use a new tactic, set up the above lists for that tactic and for your officer to learn it, add it to the tactic ID level learned table at 0xE9000. Note that the order you put in there is important. Ie.. a later tactic in slot 0 will replace an earlier one. The first list at "0xE8400–0xE84FF – Attributes associated with tactic" is very important. This defines what attributes are associated with a tactic and if the tactic auto-succeeds or not. The attributes control:

  • Whether a tactic is learned or not (if there are 2 attributes the officer's stat must be high enough in both attributes to learn the tactic.
  • Whether the tactic succeeds or fails. It uses the attributes for the tactic and compares them to the enemy's same attributes. If there is more than one attribute we choose the weakest to determine if the tactic succeeds. For example if Zhuge Liang uses a tactic that has STR and INT then STR would be used to see if the tactic succeeds.
  • How much damage the tactic does. The more attributes associated with a tactic, the higher the damage potential, but the more attributes the harder it is for the tactic to succeed.

Currently the tactics available are:

01 Lian Huo = 10 (00010000 – INT based)
02 Ye Huo = 10 (00010000 – INT based)
03 Yan Re = 10 (00010000 – INT based)
04 Da Re = 10 (00010000 – INT based)
05 Huo Shen = 10 (00010000 – INT based)
06 Shui Tu = 10 (00010000 – INT based)
07 Shui Xing = 10 (00010000 – INT based)
08 Shui Lei = 10 (00010000 – INT based)
09 Hong Shui = 10 (00010000 – INT based)
0A Shui Long = 10 (00010000 – INT based)
0B Chi Xin = 94 (10010100 – auto succeed, INT+VIT based)
0C Tong Xian = 94 (10010100 – auto succeed, INT+VIT based)
0D Yin Xian = 94 (10010100 – auto succeed, INT+VIT based)
0E Jin Xian = 94 (10010100 – auto succeed, INT+VIT based)
0F Wan Fu = 94 (10010100 – auto succeed, INT+VIT based)
10 Ji Rou = C4 (11000100 – auto succeed, LDR+VIT based)
11 Protect = 94 (10010100 – auto succeed, INT+VIT based)
12 Duel = 20 (00100000 – STR based) *
13 Ce Mian = 90 (10010000 – auto succeed, INT based)
14 Ji Mian = C0 (11000000 auto succeed, LDR based)
15 Charge = E0 (11100000 – auto succeed, LDR+STR based) *

16 Yi Xin = 02 (00000010 POL based)
17 Li Jian = 12 (00010010 INT+POL based)
18 Qi Shou = C8 (11001000 – auto succeed, LDR+AGI based)
19 Jie Ce = 50 (01010000 LDR+INT based)
1A An Sha = 12 (00010010 INT+POL based) ***
1B Bei Ji = C0 (11000000 auto succeed, LDR based)
1C Fu Bing = 48 (01001000 LDR+AGI based)
1D Life = 94 (10010100 – auto succeed, INT+VIT based)
1E Raise = 94 (10010100 – auto succeed, INT+VIT based)
1F New Damage tactic 1
20 New Damage tactic 2
21 New Damage tactic 3
22 New Damage tactic 4
23 New Damage tactic 5
24 New Damage tactic 6
25 New Damage tactic 7
26 New Damage tactic 8
27 New Damage tactic 9
28 New Damage tactic 10
29 New Damage tactic 11
2A New Damage tactic 12
2B New Damage tactic 13
2C New Damage tactic 14
2D New Damage tactic 15
2E New Damage tactic 16
2F New Damage tactic 17
30 New Damage tactic 18
31 New Damage tactic 19
32 New Damage tactic 20
33 New Damage tactic 21
34 New Damage tactic 22
35 New Damage tactic 23
36 New Damage tactic 24
37 New Damage tactic 25
38 New Damage tactic 26
39 New Damage tactic 27
3A New Damage tactic 28
3B New Damage tactic 29
3C New Damage tactic 30
3D New Heal tactic 1
3E New Heal tactic 2
3F New Heal tactic 3
40 New Heal tactic 4
41 New Heal tactic 5
42 New Heal tactic 6
43 New Heal tactic 7
44 New Heal tactic 8
45 New Heal tactic 9
46 New Heal tactic 10
47 Yi Xin2
48 Li Jian2
49 Qi Shou2
4A An Sha2
4B Bei Ji2
4C Fu Bing2
And more coming soon…

Hex Changes:

0×4130:
A883984C4084

0×4160:
10F8C900F0034CA883A0194CD7800000
C015D0034CB1824C7A81EAEAEAEAC012
D0034CB182A93A2082C4C01AD0034CB0
83C04AD0034CB0834C6E810000000000

0x42C0:
81EAEAEAEAEAEAEA

0×4450 (A.I. code for new tactics):
C947D00FA8AD28623D3081C900F0034C
A88398C948D00FA8AD2A623D3081C900
F0034CA88398C949D00FA8AD2C623D30
81C900F0034CA88398C94BD00FA8AD2E
623D3081C900F0034CA8839868C92BF0
04484CC080484C008000000000000000

0×39780:
F3A678BC0062844DEAEAEAEAEAEAEAEA
EAEAA93A2082C4EA2029AE8514205FC1
A5AC65AF290FA8B9A0998514B9B09985
15205FC1A67AA44DBD22622902F00720
CCB8D010F014BD22622904F00D20F4B8

0x397B0:
15205FC1A67AA44DBD22622902F00720
CCB8D010F014BD22622904F00D20F4B8

0x39EC0:
62A820F4B8C9FFF004C0FFD008AD2062
D0034C819E20E0B8CD1062F002B0A79D
136220B8B84C3A9E2052AA201BAE4C76

0x3A1F0:
5AA1000000000000A678BC0062F04D20
B8B8D04820C2B8F043BDE4618579A678

0x3A7D0: 902DBC006220B8B8

0x3A920:
85B785B8200CDFA90885F3BEA06520EA
B8C5F4F007C8C6F3D0F1F01BA678B9A0

0x3B5C0: C007D0C8AE736020D6B8

0x3B7D0 (jump off point):
857FA93A2082C44C12B8000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
0000A90985F3A90885F4A511A8AACAE8

0x3B880 (functions to get tactic data):
C010B0034C8BA1C04790034C35BAC01F
90034C8BA14C35BA0000000000000000
00000000000000000000000000000000
000000000000000000008D3364AE3164
AC3264AD33646000A93A2082C48A20AA
B860A93A2082C48A20AAB860A93A2082
C48A20AAB860A93A2082C49820AAB860
A93A2082C48A20AAB860A93A2082C48A
20AAB860A93A2082C48A20AAB860A678
BC0062F03720B8B8D032AD3262D02D20
C2B8F0083006E005B00A9004E0059004
A900F002A90585792036DFB99C603004
E67910F4844B8AA6789DE461A478B900
62854DA820CCB8207AE3200DD17C0020
39AAA44DA67AD00FAE3262D00AA93A20
82C4EAEAEAEAEAA67AC019F00FBD2462
F00AA678A9009D00624C8EA1A44BB99C
60104DA44D202EBB10034C10BAA44BB9

0x3BA10:
D5C4200DD1D201A44D4C70B8EAEAEAEA
20F4B8C902D01EEAEAEAEAEAEAEAEAEA
EAA93A2082C4EA2029AE8514205FC120

0x3BAC0:
9D06054C4EBA4C40BBEA

0x3BB30:
61A8BD28621931BC9D28624C4BBAA93A
2082C48A20AAB8600000000000000000
C01DD0034CBABAC01ED0034CBABAC01D
B0034CEABAC049B00A9838E931854DA8
4C13BBC049D00A9838E931854DA84CF2
BAC04AD00A9838E930854DA84C8DBAC0
4BD00A9838E930854DA84CF2BAC04CD0
0A9838E930854DA84CEABA0000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000A326406080C0F00

0x7A950 (A.I. Bug Fix):
0000A90E2082C468684C0080

0xE8400 (default tactic attributes):
00101010101010101010109494949494
C4942090C0E00212C85012C048949410
10101010101010101010101010101010
10101010101010101010101010949494
949494949494940212C812C048000000

0xE8500 (default stat requirement to learn tactic):
003C5A78B4DC466482A0DC46A0C8FCDC
C8506EF0C878B48C8CA0B4F0DC8C9600

0xE8600 (default slot for each tactic):
00000000000001010101010202020202
03030303030404050504050505040400
00000000000000000000000000000101
01010101010101010101010101020202
02020202020202040505050505000000

0xE8700 (default priority level of tactics):
00010203040501020304050102030504
03010205040103030102040502040503
03030303030303030303030303030303
03030303030303030303030303030303
03030303030303040402040502000000

0xE8800 (default tactic cost):
00020406080C0306080C0F03050A040A
050403110705050604050A0A06050600

0xE8900 (default tactic targeting):
00808000800080808000000101000001
00000000000080800100800180000080
80808080808080000000000000008080
80808080808000000000000000010101
01010000000000000000000000000000

0xE8A00 (default targets all or not):
00000080008000000080800000010100
00000000000000000000000000000000
00000000000000808080808080800000
00000000000080808080808080000000
00000101010101808001800180000000

0xE8B00 (default elemental type):
00010101010102020202020000000000
00000000000000000000000000000000

0xE8C00 (default damage/heal potential 1):
003C8CAA14D064A0C8DCC464F4E894FF

0xE8D00 (default damage/heal potential 2):
000000000507000000050900010311FF

0xE8E00 (default offensive/defensive tactic):
00000000000000000000008080808080
80808080800000008000008000000000
00000000000000000000000000000000
00000000000000000000000000808080
80808080808080000080008000000000

0xE9000 (default tactic level learned table – order is important later will replace earlier):
000111060B1518021207191C0C03080D
101B161709040F141D1E1A0E0A051300

0xE9790 (damage lookup):
0000A9012082C4B9F08B8510B9F08C85
114C8297000000000000000000000000

0xEB7D0 (guts of tactic learning code):
0000A90E2082C4A90185F4A4F4BEEF8F
2020B8BDF084C510F002B034BDF08685
F3BDF085186511A8BEA065BDF085F004
C5F3B01CA6F4BDEF8FA65DE00C9008A6
73F004C91DB009C54D99A065D002E612
E6F4A5F4C57FF0B390B14CC2B7000000
8C3764A9FF8510BDF0832940C940D00C
20B0B8B90064C510B0028510BDF08329
20C920D00C20B0B8B99C61C510B00285
10BDF0832910C910D00C20B0B8B9A861
C510B0028510BDF0832908C908D00C20
B0B8B9B461C510B0028510BDF0832904
C904D00C20B0B8B91064C510B0028510
BDF0832902C902D00C20B0B8B92064C5
10B0028510AC37646000000000000000
A5114A4A4AA86000A90E2082C44C2BB9
0000A90E2082C44C35B90000A90E2082
C44C21B9000000A90E2082C44C17B900
A90E2082C44C0DB90000A90E2082C44C
03B90000A90E2082C42040B9B9F085AA
4CF4B82040B9BDF085AA4CEAB82040B9
B9F087AA4CE0B82040B9BDEF8FAA4CD7
B82040B9B9F08AAA4CDCB82040B9B9F0
88AA4CB8B82040B9B9F089AA4CC2B800
8E31648C326460000000000000000000
00000000000000000000000000A90E20
82C4ADFE611879F0878DFE614C5DB900

0xEBA30:
00A91E2082C4B9F08B8510B9F08C8511
4C21BA00000000000000000000000000

0xEBB30:
0000000000000000000000000000A90E
2082C42040B9B9F08DAA4C2EBB000000

For default tactic names, see: http://www.lordyuanshu.com/forums/topic/tactic-expansion-ideas

Tactic Level Up Profiles (1MB ROM Only)

Credit: MiDKnighT

DoaE_IPS_13_Patch2-7_zps0c746c55.png

There are 27 different officer types now available. In other words there are 27 different level up profiles. Officer 1 might be assigned to level up profile 0 and learn Lian Huo on level 1 but officer 2 might be assigned to level up profile 2 and learn Arrows on level 1. You can control which officers learn which tactics. Now officers can be specialized.

Some other noticeable changes:

  • Max TP will go up every level regardless of if there is a tactic learned.
  • Even if multiple people learn a tactic there will not be a comma after their name.

Important lists:

0xE8F00-0xE8FFF – This assigns an officer to a level up profile. If the officer id is Song Yong (0B), you would set his officer profile # at 0xE8F0B where the last 2 numbers are the officer ID. Level up profile 00 is the default profile. If you do not set a profile ID for an officer the default level up profile will be used. Make sure you use the hex number for the level up profile #. Ie…level up profile 21 = 15 in hex.

The next lists are the level up profiles. You would put tactic IDs in this list. For example level up profile 00 starts at 0xE9000 so at 0xE9001 you would put the tactic ID you want them to learn at level 1.

0xE9000-0xE903F = Level up profile 00
0xE9040-0xE907F = Level up profile 01
0xE9080-0xE90BF = Level up profile 02
0xE90C0-0xE90FF = Level up profile 03
0xE9100-0xE913F = Level up profile 04
0xE9140-0xE917F = Level up profile 05
0xE9180-0xE91BF = Level up profile 06
0xE91C0-0xE91FF = Level up profile 07
0xE9200-0xE923F = Level up profile 08
0xE9240-0xE927F = Level up profile 09
0xE9280-0xE92BF = Level up profile 0A
0xE92C0-0xE92FF = Level up profile 0B
0xE9300-0xE933F = Level up profile 0C
0xE9340-0xE937F = Level up profile 0D
0xE9380-0xE93BF = Level up profile 0E
0xE93C0-0xE93FF = Level up profile 0F
0xE9400-0xE943F = Level up profile 10
0xE9440-0xE947F = Level up profile 11
0xE9480-0xE94BF = Level up profile 12
0xE94C0-0xE94FF = Level up profile 13
0xE9500-0xE953F = Level up profile 14
0xE9540-0xE957F = Level up profile 15
0xE9580-0xE95BF = Level up profile 16
0xE95C0-0xE95FF = Level up profile 17
0xE9600-0xE963F = Level up profile 18
0xE9640-0xE967F = Level up profile 19
0xE9680-0xE96BF = Level up profile 1A
0xE96C0-0xE96FF = Level up profile 1B
0xE9A00-0xE9BBF = Profile names and weapons

It is one profile per line with weapon icon list on the same line like so:

profiles_zps10b62041.png

Code changes:

0x384BC: 4CFE84 –> 4CFEBB

0×38560:
818558A20920B8C9A900856EA22D2091
7EC658A9008570209FC0A20B20B8C9A2

0×38680: C472866020A0BBEAEAEAEAEA60

0x3B5C0:
C007D0C8AE736020D0B7D0034C53B620
BFBB4C2DB6EAEAA9FF8512BE9060304D
20B2BBA5123046864AE66E20A9D48A48
9848A900859FA46FC89848A9FF8512BE
906030094CFBB5A5123002E69F68A8A5
9FD005C8C007D0E168A868AAA59FF008
200DD12C004C1DB6200DD12C00E66FA4
6FC007D0A2A56EF02A60EAEAEAEAA900

0x3B7E0:
2095B82088B8209CB8A9008D3164209C
B820D6B8AC3164991078EE3164AC3164
C007D0EAA007A206B91078DD1078D005
A9FF991078CAD0F020B9BB88D0EA209C
B860

0x3B890:
90034C8BA14C35BAA007A9FF88991078
C000D0F8608E34648C326460AE3464AC
326460000000000000008D3364AE3464
AC3264AD33646000A93A2082C48A20AA
B860A93A2082C48A20AAB860A93A2082
C48A20AAB860A93A2082C48A20AAB860

0x3BBB0:
A2068E31642068E78E3164CE3164CA10
F4608E3164207CB7609838E902AA6020
95B8A0FFC8B91078C007900160C9FFF0
F3C900F0EF854D8C3D64209CB8A00084
6E846F20C7B5A56EC900D006AC3D644C
C4BB200DD12D00AC3D644CC4BB600000

0x3BC00:
C4BB200DD12D00AC3D644CC4BB60A920
2082C400000000000A326406080C0F00

0x7AD10: 8D30648E31

0x7ADC0:
68C9DDD00948AE3164A90E4C5EEAC9C5
9004484C3084C9AAD00848AE31648A4C
C7E0C997D00748AC32644C8993C923D0
0248604CB5AD00000000000000000000

0x7BC20:
000000000000000000000000A9202082
C42000AD4C1CBC000000000000000000

0x7EDE5 & 0xFEDE5: 88–>80

0x7EE15 & 0xFEE15: ED–>7E

0x800F0:
FDF90E0AFB221E1B1318142122F81F86
FE20B8C920A07E20809920E2C9600000
A017A90A9948038810FAA573D006A901
8585D00510034CE2C0A93A2082C46000

0x80500: 000000000000000000A90E2082C40000

0x83C10:
000000AD407EC900D00BA07FB9608099
007E8810F7AD0064C900D005A91E2082
C4AD807EC900D00BA07FB9E08099807E
8810F74CF98400000000000000000000

0xE9880:
8E38648C3964A9EF8500A98F8501AE31
64BDA860AABDF08ED0034CA798C92390
05A9004CA798A8A5001869409002E601
850088C000D0F2AC386468C9CFD003AC
396448B1008D3A64AE386468C9CFD003
AE3A64AC396448AD3A64600000000000

0xE9990 (Main status page code):
A9ED8DC07EA9FC8DC17EA90D8DC27EA9
F08500A9998501A44AB9A860A8B9F08E
D0034CB699A8A5001869109002E60185
0088C000D0F2A00FB10099C37E8810F8
A9D28500A97E8501A005A90A9100C600
B9CD7E910088C000D0F0A9FF8DD77E8D
D87E8DCD7EA9C08516A97E8517600000

0xE9A00 (default names and weapons):
1E35353832342D0A0A0AFF4142430A0A
1F2D3E35383B3400010AFF400A0A0A0A
1F2D3E35383B3400020AFF410A0A0A0A
1F2D3E35383B3400030AFF420A0A0A0A
1F2D3E35383B3400040AFF430A0A0A0A
1F2D3E35383B3400050AFF440A0A0A0A
1F2D3E35383B3400060AFF450A0A0A0A
1F2D3E35383B3400070AFF460A0A0A0A
1F2D3E35383B3400080AFF470A0A0A0A
1F2D3E35383B3400090AFF480A0A0A0A
1F2D3E35383B3400100AFF490A0A0A0A
1F2D3E35383B3400110AFF4A0A0A0A0A
1F2D3E35383B3400120AFF410A0A0A0A
1F2D3E35383B3400130AFF410A0A0A0A
1F2D3E35383B3400140AFF410A0A0A0A
1F2D3E35383B3400150AFF410A0A0A0A
1F2D3E35383B3401000AFF410A0A0A0A
1F2D3E35383B3401010AFF410A0A0A0A
1F2D3E35383B3401020AFF410A0A0A0A
1F2D3E35383B3401030AFF410A0A0A0A
1F2D3E35383B3401040AFF410A0A0A0A
1F2D3E35383B3401050AFF410A0A0A0A
1F2D3E35383B3401060AFF410A0A0A0A
1F2D3E35383B3401070AFF410A0A0A0A
1F2D3E35383B3401080AFF410A0A0A0A
1F2D3E35383B3401090AFF410A0A0A0A
1F2D3E35383B3401100AFF410A0A0A0A
1F2D3E35383B3401110AFF410A0A0A0A

0xEB7C0:
A5F4C57FF00160E61260000000000000
0000A90E2082C4A90185F4A4F4207098
2020B8BDF084C510F002B035BDF08685
F3BDF085186511A8BEA065BDF085F004
C5F3B01DA6F4207098A65DE00C9008A6
73F004C91DB009C54D99A065D00320B0
B7E6F4A5F4C57FF0B290B04CC2B70000

0xEB8E0:
C44C21B90000A90E2082C4EA4C17B900
A90E2082C44C0DB90000A90E2082C44C
03B90000A90E2082C42040B9B9F085AA
4CF4B82040B9BDF085AA4CEAB82040B9
B9F087AA4CE0B82040B9207098AA4CD6
B82040B9B9F08AAA4CDCB82040B9B9F0
88AA4CB8B82040B9B9F089AA4CC2B800
8E34648C326460000000000000000000

6 Pack of Old and New Tactics (1MB ROM Only)

Credit: MiDKnighT

6 pack of old and new tactics added!

DoaE_IPS_13_Patch2-15_zps902f438a.png DoaE_IPS_13_Patch2-16_zps2f267207.png
  • Wuo Jian: Back from the dead. For use in early levels.
  • Shui Jian: Back from the dead. For use in early levels.
  • Cheng Nei: Back from the dead. For use in early levels (ya it sux but you can give it to weak guys. Plus with the A.I. they would only use it once.)
  • Gui Huan: Back from the dead. It was a major pain bringing it back but it's working now.
  • Gullwing: Like Gui Huan but it pulls up the Gullwing menu giving you an option of where to go.
  • Scout: The coolest one… An INT/agility based tactic where if it is successful, all tactics (other than Duel, An Sha, or POL based tactics like Mislead) will be successful for the rest of the turn. If your guy that's using scout goes last this tactic doesn't help you at all. If he goes first then all your non-Duel, non-An Sha, non-POL tactics will succeed. The tactic will write a message like "We know the enemy's position". The "scout" status will be cleared at the end of a turn. Meaning it only works for 1 turn. I'll also try to have the person using scout run across the screen to check out the enemy (like charge) with no attack.

Note that there is new text for this. If you have a previous IPS patch applied just change "blah" after the Duel text to something for Scout like "We know the enemy's position!".

Hex changes:

0x4130: A88398A93C2082C4

0x4190: 83C04AD0034CB0834C3092

0x4260:
69009D2062C011D016205083C000D003
4C9583A90E9D2062A011A9004CB086EA
EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEA
EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEA
EAEAEAEAEAEAEAEAEAEAEAEAEA4CD082

0x3BBA0:
079838E930854DA8A93B2082C44CEABA

0x3AE4B: 09–>0F

0xE8190:
034C8B83C01AD0034CAB83EAEA4CF082

0xE8300:
ADA062A64AE007B0022901E007900229
02C900F0034C1083A44DB9F0834C9081
A64DBDF0832902C902D0034C08834C8B
83

Default attributes:

0xE844D: 101010252518

0xEB8B0: 10B00285104C70B900

0xEB980:
BDF0832901C901D00BAC3164C0079004
A9008510AC3764600000000000000000

0xED250:
000000000000000000000000004C9DBB

0xEE190:
000000000000000000008A2024D14C4F
BA000000000000000000000000000000

0xEF9D0:
0000000000000000000000A90E2082C4

0xEFB80 (new tactic code):
E8E8BD2262C900F002A000E8E8BD2262
C900F002A000CACACACABD2262C90EC9
0ED002A000600000A90E2082C4C04DD0
26A200A54AC907B001E8BD226209029D
22622070BBC000D0034CCBB9A9238514
A90385154C8AA1C04ED026A200A54AC9
07B001E8BD226209049D22622070BBC0
00D0034CCBB9A9258514A90385154C8A
A1C04FD02CA200A54AC907B001E8BD22
6209089D22622070BBC000D0034CCBB9
A92AE001F002A92B8514A90385154C8A
A1C050D043A02EB939BC99507D8810F7
A200A01E844D4C507DA90E2082C42054
BC20E4C420A2C420BA9F20A6C42024F1
A90185872064E520FBC4DDBA2037A520
1FCFA2309A4C3BF1C051D060A051B97A
BC99507D8810F74C507DA90E2082C4A9
00857CA22320B8C920B3CDA67CA65B86
F1A200BDE78DA8E8B900672902F0F4C6
F110F0CA8A48A0052022C520DFCDA000
680A0AAABDF48D996000E8C8C004D0F4
2037A5201FCFA2309A4C3BF100000000

0xF0010: A91E2082C4

0xF0130:
0000000000000000BD0062C947D00FA8
AD28623D3081C900F0034CA88398C948
D00FA8AD2A623D3081C900F0034CA883
98C949D00FA8AD2C623D3081C900F003
4CA88398C94BD00FA8AD2E623D3081C9
00F0034CA88398C94DD00EA8AD226229
02C900F0034CA88398C94ED00EA8AD22
622904C900F0034CA88398C94FD00EA8
AD22622908C900F0034CA883984C9082

0xF02A0: 68C92BF004484CC080484C0080

0xF03B0:
0000000000000000E6ADA91E2082C400

0xF86D0 (tactic names):
5826643E0A1938303DFF000000000000
58223764380A1938303DFF0000000000
581237343D360A1D3438FF0000000000
521664380A1764303DFF000000000000
5216643B3B66383D36FF000000000000
5122323E642FFF000000000000000000

Officer Attributes

Adding agility to character page (replacing T.P.)

Credit: ludmeister and MiDKnighT

AGI.jpg

Changes to make:

0x38601: B4F9B46161618560
0x38598: 03
0x385A3: 05
0x3861E: 10
0x38628: 12
0x3937A: A9008DBB608DC76020C8E38DA361ACAF60A90120C8E38DAF61ACAF60A90920C8E38DBB

Original ROM Size:

0x3EA5C: 101618
0x3EA65: 10631F

1MB ROM Size:

0x7EA5C: 101618
0x7EA65: 10631F
0xFEA5C: 101618
0xFEA65: 10631F

From ludmeister:

Some interesting things about Agility that placing Agility in the status screen has gleaned:
Chi Tu Ma/Red Hare increases Agility by an additional 50%. If the resulting value is greater than 255, it will award that officer 255 Agility.

There are a handful of "special" generals that actually gain Agility increases as the game's Chapter increases. This is as shown below (this is found through gameplay, and not code inspection):

Chapter 1- Game beginning until Liu Bei accepts lordship of Xu Zhou
Chapter 2- The following story up until Liu Bei arrives at Chang An
Chapter 3- I believe that the game determines you are in Chapter 3 until Yuan Shao ambushes you
Chapter 4/5- Until you fight your first Shu based battle
Chapter 6- For game purposes, you are in Chapter 6 until Liu Bei gives his long speech about not usurping the throne, but ordering an attack against Wu and Wei
Chapter 7- Presumably, you are in Chapter 7 until you fight your first battle in Wei's province

{EDIT} The generals that I have found that gain Agility are:

Guan Yu
Zhang Fei
Zhao Yun
Huang Zhong
Pang Tong
Zhu Ge Liang
Ma Chao
Guan Xing
Zhang Bao

For the sake of illustration, each of these generals begin at "X" Agility.

Chapter 1: Agility = X
Chapter 2: Agility = X * 5 / 4
Chapter 3: Agility = X * 3 / 2
Chapter 4/5: Agility = X * 7 / 4
Chapter 6: Agility = X * 17 / 8 (approximate… but is greater than 200%!)
Chapter 7/8: Agility = X * 2

I thought this was extremely interesting, as it shows the Shu army's expertise in fighting in their home land.

MiDKnighT's additoinal notes:

When you read from billeting it's reading directly from the ROM.

When you read from the menu it's reading from the ROM then adding a multiplier depending on what "rank" you are —> $6010.

Here's the main code that's coming up with the in party agility.

1F:E7A0:AC 10 60 LDY $6010 = #$06  - Party Rank
1F:E7A3:B9 EB E7 LDA $E7EB,Y @ $E7F1 = #$19  - Use party rank to find multiplier 1
1F:E7A6:85 14 STA $0014 = #$19 - Store multiplier 1 in $14
1F:E7A8:B9 F3 E7 LDA $E7F3,Y @ $E7F9 = #$02 - Use party rank to find multiplier 2
1F:E7AB:85 15 STA $0015 = #$02 -- Store multiplier 2 in $15
1F:E7AD:20 5F C1 JSR $C15F - Do some crazy voodoo magic using officer agility + multipliers. It does a lot of bit shifting so not only does base agility matter, it matters what bits are set in the base agility.
1F:E7B0:A5 10 LDA $0010 = #$F3 - The result of the previous function is loaded.
1F:E7B2:9D B4 61 STA $61B4,X @ $61B6 = #$01 - Store new agility

<End MiDKnighT's additional notes>

However… the catch with this multiplication is that if the value exceeds 255… it wraps back around to 0. Stinky. So when modifying these 9 generals, do not give them an Agility any higher than 120… maybe even 116 to be safe.

Officer stats are stored in memory in groups of twelve… the first 7 are Liu Bei's Army, and the final 5 are your enemy's. The final 5 slots are obviously invalid outside of battle. This will become important later.

@ 0x3ea4a (in a 1MB ROM: 0x7ea4a and 0xfea4a) – Status screen stat output strings
222321 0a0a f87785fb (STR…)
181d23 0a0a f87785fb (INT
…)
10631f 0a0a f87785fb (A.P…)
106312 0a0a f87785fb (A.C
…)
0d86 f87785fe (T.P__…) <- Trust me. This was friggin' annoying to ferret out.

The "860d" bit is actually a pointer to the function to display stuff. Go figure. So we'll have to dig for the actual "T.P" string.

According to my notes, to change T.P to AGI:

The pointers to the memory locations which display the various values on the status screen are located in the ROM @ 0x385ff-0×38608. They read:

9ca8f9b4fb 6161856061

The first group are the first bytes, the second group reference the second bytes of the pointers. So…

STR pointer= 619c
INT pointer= 61a8
A.P pointer= 85f9
A.C pointer= 60b4
"T.P" pointer= 61fb

T.P is not stored in memory as a part of an officer's data, and is custom calculated for the status screen. This can be gleaned from the following code:

0e:8579    (0×38589)    B9 EF 85    LDA $85EF,Y @ $85EF = $9C    (1st pointer byte)
0e:857c    (0x3858c)    85 18     STA $0018
0e:857e    (0x3858e)    B9 F4 85    LDA $85F4,Y @ $85F4 = $61    (2nd pointer byte)
0e:8581    (0×38591)    85 19     STA $0019
0e:8583    (0×38593)    A4 4A     LDY $004A     (# of general in list, 00 is 1st, 06 is player's last, 07-0b are enemies)
0e:8585    (0×38595)    A5 54     LDA $0054     (Status screen value… 00 = STR, 01 = INT, etc.)
0e:8587    (0×38597)    C9 02     CMP #$02     (Is it A.P?)
0e:8589    (0×38599)    D0 07     BNE $8592
0e:858b    (0x3859b)    B9 C0 60    LDA $60C0,Y @ $60C0 …     (Get general's Weapon ID)
0e:858e    (0x3859e)    A8     TAY
0e:858f    (0x3859f)    4C 9F 85    JMP $859F
0e:8592    (0x385a2)    C9 04     CMP #$04     (Is it T.P?)
0e:8594    (0x385a4)    D0 09     BNE $859F     (if not, don't bother getting general ID)
0e:8596    (0x385a6)    A0 00     LDY #$00
0e:8598    (0x385a8)    A5 4A     LDA $004A (# of general in list)
0e:859a    (0x385aa)    C9 07     CMP #$07     (Compare # with 1st foe in list)
0e:859c    (0x385ac)    90 01     BCC $859F
0e:859e    (0x385ae)    C8     INY
0e:859f    (0x385af)    E6 6E     …     Determines value based on the gleaned info

Part 2: Billeting output

The above edits did not matter when inspecting a billeted officer!

When we look at a billeted general, his stats actually get placed in the 8th general's place (1st enemy!) Before we get here, Y already has the General ID we are looking up. Here's the code:

0e:936a (0x3937a)    A9 00     LDA #$00
0e:936c (0x3937c)    20 C8 E3    JSR $E3C8    Get Strength
0e:936f (0x3937f)    8D A3 61    STA $61A3
0e:9372 (0×39382)    AC AF 60    LDY $60AF     Y = General ID
0e:9375 (0×39385)    A9 01 LDA #$01
0e:9377 (0×39387)    20 C8 E3    JSR $E3C8    Get Intellect
0e:937a (0x3938a)    8D AF 61    STA $61AF
0e:937d (0x3938d)    A9 00     LDA #$00
0e:937f (0x3938f)    8D C7 60    STA $60C7
0e:9382 (0×39392)    8D BB 60    STA $60BB
0e:9385 (0×39395)    8D FB 61    STA $61FB    These are not important to zero out… they contain TP info which we will not show
0e:9388 (0×39398)    8D FC 61    STA $61FC
0e:938b (0x3939b)    8D FD 61    STA $61FD
…

So we can rewrite this little script, like so:

0e:936a (0x3937a)    A9 00     LDA #$00
0e:936c (0x3937c)    8D BB 60    STA $60BB Important to zero out
0e:936f (0x3937f)    8D C7 60    STA $60C7 Ditto
0e:9372 (0×39382)    20 C8 E3    JSR $E3C8    Get Strength
0e:9375 (0×39385)    8D A3 61    STA $61A3
0e:9378 (0×39388)    AC AF 60    LDY $60AF     Y = General ID
0e:937b (0x3938b)    A9 01     LDA #$01
0e:937d (0x3938d)    20 C8 E3    JSR $E3C8    Get Intellect
0e:9380 (0×39390)    8D AF 61    STA $61AF
0e:9383 (0×39393)    AC AF 60    LDY $60AF Y = General ID again
0e:9386 (0×39396)    A9 09     LDA #$09
0e:9388 (0×39398)    20 C8 E3    JSR $E3C8    Get Agility
0e:938b (0x3939b)    8D BB 61    STA $61BB
…

In other words, we change 0x3937a-0x3939c from
"A90020C8E38DA361ACAF60A90120C8E38DAF61A9008DC7608DBB608DFB618DFC618DFD"
to
"A9008DBB608DC76020C8E38DA361ACAF60A90120C8E38DAF61ACAF60A90920C8E38DBB"

A few extra notes about AGI:

The function $E3C8 is pulling the agility directly from the ROM. It's the function JSR $E768 that is adding to AGI based on what "rank" we are. The above code does not add the agility bonues. Ie…when you look at an officer in billeting the AGI may be less than it is when they are in your party.

You can manipulate the AGI bonuses for each "rank" with:

Rank:               1  2  3  4  5  6  7  8
                   -- -- -- -- -- -- -- --
0x7E7FC & 0xFE7FC: 00 40 80 C0 E6 19 00 00   
0x7E804 & 0xFE804: 01 01 01 01 01 02 02 02

As you can see rank 6 has the highest bonus. Most modders might want it to be rank 8.

LDR, VIT, and POL Attributes (1MB ROM Only)

Credit: MiDKnighT

Definition of Attributes:

Leadership (LDR) - How strong of a leader they are. You would want to put someone with high LDR at the front of your party.

Strength (STR) - Officer attacking strength. Used for physical damage and dueling.

Intelligence (INT) – Officer tactic strength (for INT based tactics). Also used for enemy officer artificial intelligence and intelligent officers are smarter about accepting duels.

Agility (AGI) – Affects order of turns in battle and agility based attacks.

Vitality (VIT) – Helps with physical and tactic defense. In your own mod you could rename this attribute to RES (resistance), CON (constitution), or maybe even TRN (training).

Political (POL) – kind of a combination of POL and CHA from ROTK games. Would affect some tactics (like Mislead and Doubt) but also affect recruitment and gold/items gained after battle. In your own mod you could rename this attribute to CHA (charm or charisma) or LOY (loyalty).

Attack Power (AP) – weapon strength

AC – armor + helmet strength + VIT

Status Screen With New Attributes:

DoaE_IPS_13_Patch2-3_zpsac1455ed.png

LDR, VIT, and POL are now taking user given values or deriving them if they are not set. The attributes don't do anything new yet but they will. What modders need to know:

  • To set the LDR for an officer, put the value at 0x7AA## where ## = officer ID
  • To set the VIT for an officer, put the value at 0x7AB## where ## = officer ID
  • To set the POL for an officer, put the value at 0x7AC## where ## = officer ID

If you leave it at 0 for an officer, the number will be derived like so:

  • LDR = Roughly 50% INT + 25% STR + 25% AGI = 100% LDR
  • VIT = Roughly 50% STR + 25% INT + 25% AGI = 100% VIT
  • POL = Roughly 75% INT + 25% AGI = 100% POL

For coders:

  • LDR is stored in $6400-$6406 for allies and $6407-$640B for enemies
  • VIT is stored in $6410-$6416 for allies and $6417-$641B for enemies
  • POL is stored in $6420-$6426 for allies and $6427-$642B for enemies

Allied party and enemy values for LDR, VIT, and POL are refreshed every time:

  • An officer joins or leaves the party
  • A battle is started
  • Billeting stats are checked

Changes:

0x38530 (Status page code changes):
D620D2CE2091CF2064DD6075209FC0A9
A18558C6AAA64ABD9C6030082064DDEA
85209FC0E6AAA91085A9A20820B8C9A9
818558A20920B8C9A900856EA22D20B8
C9C658A9008570209FC0A20B20B8C9A2
0A20B8C94C9FD4A46EB935EA8518B940
EA8519A44AA554C906D007B9C060A84C
9F85C908D009A000A54AC9079001C8E6
6EA91E2082C4EA850485052088D6A902
2019CCE8EAB118483868E91C900A48A9
F49D1803E838B0F1690E9006A9F39D18
03E86023C002FFFF23DA02AAAA23E202
AAAA23EA04AAAA0000FF21A1010EFF9C

0x7AD10 (the meat of setting LDR, VIT, and POL):
8D30648E31648C3264A000B9A860AABD
F0A9F0069900644C3FADB99C614A4A8D
0D64B9A8614A8D0E64B9B4614A4A8D0F
64A9006D0D646D0E646D0F64990064BD
F0AAF0069910644C6FADB99C614A8D1D
64B9A8614A4A8D1E64B9B4614A4A8D1F
64A9006D1D646D1E646D1F64991064BD
F0ABF0069920644C9FADB9A8614A8D2D
64B9A8614A4A8D2E64B9B4614A4A8D2F
64A9006D2D646D2E646D2F64992064C8
C00C90034CB0AD4C0BAD000000000000
68C9DDD00948AE3164A90E4C5EEAC9C5
9004484C3084C9AAD00848AE31648A4C
C7E0C997D00748AC32644C89934CB5AD

0x7C600 & 0xFC600 (pallette changes):
0F27291A0F0030290F1737290F203111
0F3036150F3027030F2B37060F293714
FF012716000F3021000F3827000F2031
11FF013928180F3727170F302B1B0F20
1C0CFF013727160F3025370F302B270F
202C27FF011738150F1729190F173827
0F203817FF012737150F1929270F2010
270F203111FF012737150F27371A0F27
37170F201011FF012031210F2021310F
170F320F372621FF012627040F203111
0F2031110F372620FF012820370F2838

0x7EA40 & 0xFEA40:
FBF8F2D4FE009CA8B41020F9B4000000
6461616164648560000000A900856E4C
77858DBB61AAA91E2082C44C00AD2082
C44CDDE7FEFE010E6D0C0C2310122318
12220C0C0C6EFAF80EB7FBFFFA010E6D
0C0C0C142024181F0C0C0C0C6EFAF834

0x80010 (loading stuff into memory at $7500, mostly status page stuff)
A03FB9208099907F8810F7A07FB96080
9900758810F7A90E4CB7C40000000000
85EDC91F9006A902484CA07FA90048EA
A5ED0AC93F9002E94048A9068D008068
8D018018690148A9078D0080688D0180
A9008D0080688D018060000000000000
0DF8150AFB0A1B13210AF84BEAFB0A22
23210AF87785FB0A181D230AF87785FB
0A1016180AF87785FB0A2518230AF877
85FB0A1F1E1B0AF87785FB0A101F0A0A
F87785FB0A10120A0AF87785FE000000
00000000000000000000000000000000
23C002FFFF23DA03AAAA2223E203AAAA
2223EA03AAAA2223F203AAAA22FF0000

Misc Jumps and Such:

0x39390: 8DAF61ACAF60A90920C8E34C52EA205D
0x78440: A90E2082C4
0x79390: 000000000000000000A90E2082C4
0x7E0D0: & FE0D0: 8A0A0A0A4C55EA
0x7E7E0 & 0xFE7E0: 619002A9FF9DB4614C56EAEAEA207CB7
0x7EDC1 & 0xFEDC1: 00
0x7EDF1 & 0xFEDF1: 75
0x7F0D0: 2FB42074864C55EAA9072080C44C4391

Completed Attribute Uses:

LDR:

  • LDR of the party leader affects duel outcome
  • Higher LDR+AGI makes it easier to retreat. Party leader's LDR+AGI vs 1st enemy's LDR+AGI
  • Negate success, LDR+INT (1st party member) vs 1st enemy's LDR+INT (if negate is defined with LDR/INT)

VIT:

  • VIT affects base AC
  • If target has high VIT it can cut tactic damage against them a bit.

POL:

  • Higher POL for the party leader makes item drops more likely
  • Doubt / Mislead success (if defined)

Using New Attributes for Tactic Success/Fail and Tactic Damage

Credit: MiDKnighT

Note that this enhancement is built on top of the "Tactic Damage Level, Soldier, and Optionally STR, AGI, and INT based." Enhancement. Ie…the changes here will overwrite those.

In the list at 0xE8400–0xE84FF you can define a tactic as LDR based, STR based, INT based, AGI based, VIT based, or POL based. Then the success/fail will be measured by the tactic attribute of the attacker vs the tactic attribute of the defender (with randomness thrown in).

You can define the attributes for each tactic at 0xE84## where ## = tactic ID. To define each tactic you need to switch your calculator to binary mode (1's and 0's). Here's how we use each value:

Auto-Succeed – LDR – STR – INT – AGI – VIT – POL – (not used)

So if a tactic is INT based it would be:

Auto-Succeed – LDR – STR – INT – AGI – VIT – POL – (not used)

0 0 0 1 0 0 0 0

See the list of tactic defaults in the expanded tactics section.

The list from 0xE8400–0xE84FF replaces these lists:

0x5710-0x572F: Tactic always succeed list. 01=always work (only for tactics 01-0F)
0x5730-0x573F: STR bonus list (put tactic ID in this list for STR bonus)
0x5740-0x574F: AGI bonus list (put tactic ID in this list for AGI bonus)
0x5750-0x575F: INT bonus list (put tactic ID in this list for INT bonus)

If a tactic is associated with 2 attributes, then we use the weakest attribute to check for success. For example, since Jie Ce (negate) is LDR and INT based, let's say my leader has 200 more INT than the enemy leader but only 10 higher LDR than the enemy leader. The code would use LDR to decide whether the tactic succeeds or fails since that is the weak link.

Code changes:

0×4180 (jump off point for tactic succeed/fail):
D0034CB182A93A2082C4000000000000
00000000000000000000000000000000

0x56B0 (checking new attributes for tactic damage):
E0059005E8E84C8D96BD9760AABD1064
60000000000000000000000000000000
E0059005E8E84C8D96BD9760AABD2064
60000000000000000000000000000000
A6782040884A4A4A4A85B8A678208096
4A4A4A4A85BCA67820A0964A4A4A4A85
BDA67820C0964A4A4A4A85BE60000000

0×5750 (used for subtracting VIT from tactic damage):
AAA511C900F006A511E90185118A6000

0x57A0 (adding up tactic damage):
20E09720F097EAEAEAEAEAEAEAEAEAEA
EAEAEAEA20F0874C8297000000000000
A54A0A0AAABD61614A4A4A85B2A67820
00884A4A4A4A85B6A6782020884A4A4A
4A85B720E09660000000000000000000
A93A2082C46000000000000000000000
A4B1A5101865B190032050971865B290
032050971865B390032050971865B490
032050971865B590032050971865B990
032050971865BA90032050971865BB90
0320509738ED3064B0032040978810B4
85106000000000000000000000000000
0000000000000000000000A91E2082C4
A9008512851520609720E09720F097EA

0xE8180 (main guts of success/fail):
00000000000000000000A44DB9F08310
034C8B83C01AD0034CAB83A44DB9F083
2940C940F008A9FF8D30644CB081A44B
B9006485F3A44AB9006420B0828D3064
A44DB9F0832920C920F008A9FF8D3164
4CD581A44BB99C6185F3A44AB99C6120
B0828D3164A44DB9F0832910C910F008
A9FF8D32644CFA81A44BB9A86185F3A4
4AB9A86120B0828D3264A44DB9F08329
08C908F008A9FF8D33644C1F82A44BB9
B46185F3A44AB9B46120B0828D3364A4
4DB9F0832904C904F008A9FF8D34644C
4482A44BB9106485F3A44AB9106420B0
828D3464A44DB9F0832902C902F008A9
FF8D35644C6982A44BB9206485F3A44A
B9206420B0828D3564AD306485F3AD31
64C5F3B00285F3AD3264C5F3B00285F3
AD3364C5F3B00285F3AD3464C5F3B002
85F3AD3564C5F3B00285F3A5AD65AE29
0FC5F390034C90834C8B830000000000
38E5F39011A003D9E082B0038810F8B9
E48285F3101438E90149FFA003D9E882
B0038810F8B9EC8285F3600000000000
000A326406080C0F000A326401020406

0xE8390 (jump off points):
0000000000000000000000A9012082C4
A9012082C40000000000000000000000
0000000000000000000000A9012082C4

0xE8400 (default tactic attributes):
00101010101010101010109494949494
C4942090C0E00212C85012C048949400

0xE97F0 (Checking Attributes for Tactic Damage):
A9012082C4A90085B385B485B585B985
BA85BBA44DB9F0832940C940D006A5B9
65BC85B9A44DB9F0832920C920D006A5
B365B685B3A44DB9F0832910C910D006
A5B465B785B4A44DB9F0832908C908D0
06A5B565B885B5A44DB9F0832904C904
D006A5BA65BD85BAA44DB9F0832902C9
02D006A5BB65BE85BBA44BB910644A4A
4A4A4A8D30644CE09700000000000000
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License