Author Topic: Simple way to map enemies to the techs they use?  (Read 13144 times)

sqykly

  • Earthbound (+15)
  • *
  • Posts: 17
    • View Profile
Simple way to map enemies to the techs they use?
« on: April 02, 2015, 08:57:15 pm »
As a just-for-fun project, I did a rather complete disassembly and analysis of the original Chrono Trigger SNES rom's battle mechanics module.  I got the damage equations including upper limits on random damage, I got the exact effects of defense, every detail of hitting and missing, meanings of various bits and subclasses of tech and combo data, and a big fat dump of every tech in the game. 

The PC combo structures have, as their first member, a (reference to a) list of participants, which makes it really easy to figure out which combo/tech data corresponds to which tech in-game, i.e. mapping data to tech.

It has proven less easy to do the same for enemies' techs.  A breakpoint-based approach is far too tedious and slightly error-prone.  I know Chrono Trigger is one of the most hacked games ever made, but no matter where I look, I can't find any simple explanation of the form "here's the offset in the enemy data that identifies what techs they can use".  This is my official cry for help. 

What I'm looking for is some way to identify - at least - what enemy is using each entry in the table that starts at offset $C6FC9.  Entries are 11 bytes long and are in the same format as the PC combo techs, so even though these all specify only a single participant, I refer to the table as the NPC combo table, and the table at $C7AC9 as the NPC tech table, whose records mirror the individual tech components of a PC combo tech in structure.  The only meaningful fields are those that would normally correspond to the first character in a combo's contribution to the tech, and those that apply globally to the tech itself.  In summary:

Offset (hex)MemberType & meaning
0participantListIndexByte.  Always $FF for NPC "combos"
3elementsTop 4 bits are the elements we know & love, bottom 4 are unknown in meaning and appear to be used frequently
5techDataIndex0Byte.  Index of tech record in the NPC tech table.  Multiply by 12 to get offset from start of table.
8modifierIndex0Byte.  Index of the 3 byte modifier record in table that starts $C2A05.  Multiply by 3 to get offset in said table.

If it helps, here's what some entries do:

1. Heal by rnd(9~10)*MAG
2. Fixed 50% chance to inflict lock status, no damage
3. Non-elemental magic attack with base damage (LV+MAG)*4/3, always hits, 50% chance to inflict slow
10. Fire magic attack with base damage (LV+MAG)*2, always hits
17. Fire-elemental physical attack with base damage ATK*4/3, evasion based on HIT/EVA, defense stat is DEF, wall status has no effect

Ringing any bells?!  Is there a nice neat list of enemies with the indices of their techs in it somewhere?  Or do I have to peel through a bunch of "Event Commands" that specify the actions taken by an enemy, and if so, where should I start looking?  I will, in exchange for any useful info, dump everything I have someplace you can read it.  Thanks!

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1774
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Simple way to map enemies to the techs they use?
« Reply #1 on: April 02, 2015, 09:29:54 pm »
I'd love to see your disassembly.

I haven't found anything for enemies that corresponds to the PC Performance Groups, but in AI there's something that can effect it.

Enemies are loaded in a specific slot number, ranging from 3-A (0-2 are party members). An enemy's tech command can load a player target, and one or two enemy slots to perform the tech with.

I'm attaching the current version of Enemy AId, my semi-functional AI editor (at the moment it doesn't save, and only works with US ROMs), and a document I've been working for tech data.

You should also check out Hi-Tech, my mostly functional Tech editor. The most recent version is on the last page.

Edit: I forgot to attach things.

Enemy AId can be added to your Temporal Flux directory and run from the plugins menu.
« Last Edit: April 02, 2015, 09:35:19 pm by Mauron »

sqykly

  • Earthbound (+15)
  • *
  • Posts: 17
    • View Profile
Re: Simple way to map enemies to the techs they use?
« Reply #2 on: April 02, 2015, 10:59:08 pm »
It's more than 22k lines long.  Are you sure you don't just want my symbol table?  I copy-pasted it out of my OpenOffice-based disassembler, so it has tabs for columns & will make a lot more sense if you paste it right back into a spreadsheet of some sort.  Also no guarantees on what my pseudo-code is supposed to look like.  Half of it is "you suck, square" every time they divide by 1, add 0, and branch over 0 instructions.

These performance groups; are you referring to the 3-member lists of PC identifiers beginning at $C249F?  Or are you referring to the more interesting 11 byte structures that describe a whole combo for PCs?  I've got a dump of tons of those for NPCs, but they're all for just 1 participant, i.e. the 2nd and 3rd slots for tech effect and modifier are null, in addition to the meaningless participant list.

I will look over the attachments at length, since I will be without net for a few nights.  Thanks!

Edit: How did you know half of this stuff without disassembling?
« Last Edit: April 02, 2015, 11:44:15 pm by sqykly »

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1774
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Simple way to map enemies to the techs they use?
« Reply #3 on: April 03, 2015, 12:20:28 am »
Whatever you've got would be great.

Performance groups are what I call both the 3-member lists at $C249F, and the bitflag list at... somewhere. I hadn't added that part to my document yet.

The eleven byte structure is what I've been referring to as the control data. I'll have to compare the enemy triple tech indexes in AI to the data in Hi-Tech.

I've done a lot of disassembling, although some I've just been lucky when poking around, back when I first started this.

Redslash

  • Earthbound (+15)
  • *
  • Posts: 21
    • View Profile
    • Twitch.tv/Redslash
Re: Simple way to map enemies to the techs they use?
« Reply #4 on: April 05, 2015, 10:03:53 pm »
This sounds like exciting work. As a CT speedrunner, I would love to learn as much as I can about the battle mechanics, and anything else really. I saw your post the other day and figured it was way beyond me... But then I remembered, couldn't you extract this out of the AI? By picking out the Action 02's... http://datacrystal.romhacking.net/wiki/Chrono_Trigger/Enemy_AI_Documentation
Perhaps there's a more straightforward way, I'm not sure =)

sqykly

  • Earthbound (+15)
  • *
  • Posts: 17
    • View Profile
Re: Simple way to map enemies to the techs they use?
« Reply #5 on: April 06, 2015, 06:45:15 pm »
I looked over your attachments in detail, and they more or less solve my problem.  In particular, HiTech has a list that maps, in most cases, a tech index in the table to the enemy that uses it and other identifying information.  Is there any way I can get this information in a machine-readable format so I can integrate it with my data automatically?  I can just read the contents of the listbox and write the enemy name and tech name in my table manually, but I like to leave anything tedious to a program =D

I did find a few things I've learned from the disassembly that your documents and editor are missing.  In case you end up reading any of my notes, here's how my terminology maps to yours:

My identifierYour term
ComboTechDataControl Header
TechDataEffect Header
ModifierHit Effect
ParticipantListPerformance Group
requiredTargetFlag (field of TechData)Failure condition
neverMiss (flag in TechFlags & ComboFlags)Ignore hit & evade
piercesProtect (flag in TechFlags)Ignore shield
piercesWall (flag in TechFlags)Ignore barrier
damageMultiplier (field in DamageTechData)Tech power
tag (field in TechData)Mode

The trick to understanding some parts of the control header is that it's designed for the re-use of effect headers in double or triple techs.  In the control header's flags, for example, bits $20 and $40 are LSR'd and OR'd with every hit effect flag involved, allowing them to override a hit effect's check for failure conditions or force it to hit when it normally would be evadable.  Further, setting any of the bits 4, 2, or 1 in the same flag simply indicates that all of the hit effects' damage should be added up after they are calculated separately; otherwise, the 2nd & 3rd effects are ignored.

It seems that your hit effects are treated as atomic in the editor, but they are really indexes of unions of structures in a table, just like effect headers.  The offset of said table escapes me at the moment, I'll get it at some point.  Again, the purpose is usually to add damage, status, or elements to a double or triple tech without adding a new effect header.  It looks like a lot of them are also used to add special effects to weapons, and others are necessary for the normal functioning of single techs as well.  The most important one that comes to mind is the two modifier tags that are required for element resistance/weakness to be applied; without that modifier/hit effect, that doesn't happen.

The union is 3 bytes long, and the tag is the first byte.  In the effects descriptions, "damage" refers to the damage done by the effect with the corresponding index in the control header only.  Target flags refers to the same byte tested by required target flags / failure conditions.  Unless otherwise specified, status is the byte with all the common debuffs like slow, poison, etc.  RND is a random number 0-100.

Tag valueTag identifierByte 1Byte 2
What it does
0mulIfCriticalmultiplierunused
If RND < weapon's crit rate, multiply damage by multiplier
1noModifierunusedunused
Does nothing
2mulDivmultiplierdivisor
Multiply damage by multiplier, then divide by divisor.  In HiTech, instances are referred to as X% Physical damage
3multiplyIfTargetBittargetBitsmultiplier
This tests the same flags byte as the required target flags / failure conditions.  If the target has any of the bits in targetBits, multiply damage by multiplier/2.  That's how you get stuff like X% damage against magic monsters.
4mulByDeadFriendliesunusedunused
Multiply damage by (number of dead allies + 1).  This is for one of Magus' weapons I think.
5randomBySecondsunusedunused
Used for one of Lucca's weapons to apply a "random" multiplier to damage.  In fact, it is not random at all.  It picks a multiplier based on the lowest digit of the current play time.  0: 103/1024 (~10%), 1-2: 1/2, 3-4: 1, 5-7: 3/2, 8: 2, 9: 3
6inflictRandomStatusunusedunused
Damage is not effected.  Instead, a random status is selected: 40% lock, 25% stop, 25% sleep, 10% poison.  If the target is not immune to the chosen status, it is inflicted on the target with 100% probability.
7inflictStatusIfTargetFlagtargetFlagsstatus
Damage is not affected.  Instead, check the target's flags for the specified bits; if any are set, there is an 80% chance to inflict the specified status.
8inflictStatusWithProbabilityprobabilitystatus
Damage is not affected.  Instead, if RND < probability, inflict the specified status on the target.
9leaveTargetWith1Hpprobabilityunused
If RND < probability, damage is set to target's current hp - 1.  Otherwise, damage is not affected.  I think this is Nu's thing.
10modifyDamageForElementunusedunused
Multiply damage by 4, then divide by the target's resistance to the attack's element.  Without a modifier with this tag or the next, resistance to elements is ignored.  HiTech refers to modifiers with this tag as Magic Attack.
11mulDivAndElementmultiplierdivisor
The exact effects of tags 2 and 10 are applied.  This is used to both add damage and an element to an effect header / tech when it is part of a combo tech.  HiTech refers to modifiers with this tag as X% Magic Attack.
12setDp1Ato1probabilityunused
If RND < probability, set dp address $1A to 1.  This is used exclusively with techs that steal items, so I imagine the probability corresponds to a success rate.
13maybeFullHealMaybeClearStatusflags: $80 fullHeal, $40 clearStatusunused
If the flags include fullHeal, disregard the previous damage and set it to -targetMaxHp.  Otherwise, damage is not affected.  If flags include clearStatus, the debuff status byte is cleared; in addition, some bits of the same byte that indicates deadness (but not the bit for dead) are cleared.
14halfHpprobabilityunused
If RND < probability, damage is set to target's current hp/2.  Otherwise, damage is not affected.
15removeStatusstatusByteOffsetbitsToClear
Damage is not affected.  The status byte at the specified offset from the target's portrait byte is cleared of the bits in bitsToClear.  This is used by one of Lavos' techs to remove your buffs.  No check is made to ensure that statusByteOffset corresponds to a byte carrying status, or is even within the structure's size, so theoretically this can be used to do fun but pointless things like rounding experience down to a multiple of 32.
16mulByAttackerHpMod10unuseddivisor
Multiply damage by (attacker's hp % 10), then divide by the divisor.
17killAttackerOrTargetunusedwhich
If which = 0, kill the attacker; damage is not affected.  Any other value causes the damage to become the target's current hp.
18killTargetIfBitAndRandomprobabilityunused
The target's flags at offset 19 are checked for bit $80.  If that bit is set and RND < probability, the target is killed.  Otherwise, damage becomes 0, and the bit index corresponding to the target is cleared from $7EAE95 and $7EAE99.  If $7EAE95 becomes 0 as a result, find the highest significance set bit in $7EAE99, clear that bit from $7EAE99, and set that bit in $7EAE95.
19doubleOr9999unusedwhich
If which = 1, damage is set to 9999 regardless of its previous value.  Otherwise, damage is doubled.
20setBitsAtOffsetbyteOffsetbitsToSet
Same deal as the tag 15 removeStatus, but bits are set instead of cleared.  One of my notes says the bits are set on the attacker, not the target, but that seems like a possible typo.  I'll have to look over it again.


I don't totally understand the AI scripts.  How often is a condition evaluated?  How often is an instruction executed?  It seems like there are several actions in sequence, which makes me think it is waiting for its turn between instructions, or maybe I'm misunderstanding something.  Also, what do these "switch states" instructions do?

That markup came out a little wacky... but it's a lot to fix... so let me know if you have trouble understanding.
« Last Edit: April 06, 2015, 06:47:41 pm by sqykly »

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1774
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Simple way to map enemies to the techs they use?
« Reply #6 on: April 07, 2015, 04:46:00 pm »
You mean the tech descriptions? It's not a complete list, but I tried listing at least one enemy that uses a particular tech.

Quote
"00: Weird flash?",
            "01: Cure (Masamune absorbs energy) (Mammon M.)",
            "02: 'X' (Lock) (Mage)",
            "03: Bird / Flying attack (Blue Eaglet)",
            "04: Weird smoke?",
            "05: Nagaette's Slow Spell",
            "06: Slam and attack (Free Lancer)",
            "07: Physical slam (Blue Imp)",
            "08: Weird hypno (Cave Bat)",
            "09: Sand Breath (Blind) (Mohavor)",
            "0A: Fire blast (Fire) (Acid)",
            "0B: Dragon Tank's dash (Grinder)",
            "0C: Missle attack (Dragon Tank)",
            "0D: Bubble attack (Water) (Nereid)",
            "0E: Needlespin attack (Yakra)",
            "0F: Pebble Punt (Mud Imp)",
            "10: \"sing\" attack (Gato)",
            "11: Volcano explosion (Crater)",
            "12: MP suck attack (Rolypoly)",
            "13: Poison status attack (Nizbel II)",
            "14: Laser attack (Bugger)",
            "15: Laser attack (Turret)",
            "16: Missle attack (Bug)",
            "17: Explosion attack / Fusion (Barghest)",
            "18: Explosion attack (Ozzie - 0xA7)",
            "19: Amplifire attack (Guardian)",
            "1A: Delta Attack (Guardian + Bits)",
            "1B: Weird attack (Octoblush)",
            "1C: Dalton's \"BURP\" attack?",
            "1D: Telekinetic attack (Slash)",
            "1E: Ding-a-ling / Chaos (Bellbird)",
            "1F: Earthquake attack (Ogan)",
            "20: Slash's attack",
            "21: X-Strike (Mune)",
            "22: Multiple Counter Attack (Lasher)",
            "23: Wind attack?",
            "24: ??? (Fly Trap)",
            "25: Fire (Rolypoly)",
            "26: Physical attack, weird sound (Unknown)",
            "27: Lightning release attack (Golem)",
            "28: Same as 27, but only hits one party member",
            "29: Rain attack (One party member) (T'Pole)",
            "2A: Ice (Rolypoly)",
            "2B: Lightning (Rolypoly)",
            "2C: Self-damaging attack (Roly Bomber)",
            "2D: Explosion / Blast attack?",
            "2E: Multiple Counter-attack Technique (Outlaw)",
            "2F: Point Flare (Mammon M.)",
            "30: Like Crono's Slash attack (Base)",
            "31: Confusion attack (The Stare) (Flea)",
            "32: Throw target attack (Winged Ape)",
            "33: Wing Blow / Chaos (Lizaractyl)",
            "34: Volcano explosion (Volcano)",
            "35: Same as 34, only enemy attacks itself (Volcano)",
            "36: Chew & spit (HP suck) (Retinite - Bottom - 0xB5)",
            "37: Rust Tyrano's flame breath",
            "38: Rust Tyrano's roar (HP Down status, all)",
            "39: Different type of HP drain (like 12, only affects HP) (Reaper)",
            "3A: Destruction Zone (Scorcerer)",
            "3B: Weird attack (Unknown)",
            "3C: Throws character off screen? (Barghest)",
            "3D: Lifeshaver / HP goes to 1 (Giga Mutant - Bottom)",
            "3E: GaiaMagnade / Fire (Giga Gaia - Right Arm)",
            "3F: Two Part Attack: Pair Blaster (Giga Gaia - Right Arm)",
            "40: Tornado attack (Masa & Mune)",
            "41: Iron orb (HP down by 1/2) (Golem)",
            "42: Shining Bit / Lightning (Looks blue) (Giga Mutant - Top)",
            "43: Laser Beams / Doors of doom open (Lavos - Right Arm)",
            "44: Lavos's Shadow Doom Blaze (Lavos - Second form)",
            "45: Crimson Rain / HP Down (Bantam Imp)",
            "46: Cyclone attack, like Crono (Groupie)",
            "47: Laser Spin (Debuggest)",
            "48: Drop attack (Cave Ape)",
            "49: Explosive attack (Lavos - Second form)",
            "4A: ??? (Lavos Core - Left Bit)",
            "4B: Antipode (Does not need two enemies to use)",
            "4C: Doom, Doom, Doom, Doom... (Zombor)",
            "4D: Drooo (Yakra)",
            "4E: Drooo Counterattack (Yakra)",
            "4F: Character toss (R Series)",
            "50: Cure Beam (Proto 4)",
            "51: Water 2 (Golem)",
            "52: Hexagon Mist (Water)",
            "53: Blue mist attack?",
            "54: Another Fire explosion attack? (Boss Orb)",
            "55: Water Rise (Enemy 0x14)",
            "56: Dreamless (Lavos Core - Center Bit)",
            "57: MP Buster (Target loses all MP) (Sentry)",
            "58: Chaotic Zone / Chaos (Tera Mutant - Top)",
            "59: Blue circle attack?",
            "5A: Blue Circle attack (Retinite - Top)",
            "5B: Blue electricity attack? (Panel)",
            "5C: Steal Steam / HP Down (Giga Mutant - Bottom)",
            "5D: Dalton's \"BURP\" attack (Golem)",
            "5E: Another electricity attack",
            "5F: Non",
            "60: Lock attack (used as \"Lock All\" animation - effect set elsewhere) (Boss Orb)",
            "61: Like Magus's Dark Mist, but only hits one party member",
            "62: Dark Bomb (Lavos - Left Arm)",
            "63: instant death attack (Alien)",
            "64: Poison beam (Flea Plus)",
            "65: Lightning release attack (Hits one)",
            "66: Some type of explosion attack? (Giga Mutant - Top)",
            "67: Unknown Dual Tech (Thrasher)",
            "68: Prism Beam (Blind, all) (Flea Plus)",
            "69: Lavos Core turns on/off defense (Lavos Core - Main Body)",
            "6A: Dark Bomb (Magus)",
            "6B: Dark Matter (Spekkio - Pink Nu)",
            "6C: Geyser (HP Down, used by Magus)",
            "6D: Weird jump?",
            "6E: Unknown Dual Tech (Blue Beast)",
            "6F: Yet ANOTHER earthquake attack",
            "70: Effect from burning an Ogre's hammer",
            "71: Enemy vanishes?",
            "72: Fusion tech (Jinn)",
            "73: Blade toss attack (Goon)",
            "74: slash attack (Dalton Plus)",
            "75: Sand cyclone (Mohavor)",
            "76: Red circle on caster, damages party, enemy dies (Atropos XR)",
            "77: Blizard / Chaos (Man Eater)",
            "78: Enemy turns invisible (non",
            "79: Enemy gets sucked into a void, turns invisible (Dalton Plus)",
            "7A: Life / Life 2 (Glitched)",
            "7B: ???",
            "7C: ???",
            "7D: ???",
            "7E: Cure (Mud Imp)",
            "7F: Self Destruct (Mud Imp)",
            "80: Shoots orbs of fire at target (Mage)",
            "81: Teleportation (By Azala, teleports a rock)",
            "82: Telekinetic slam (Azala)",
            "83: Beam attack (Proto 4)",
            "84: Mutant Gas / Sleep (Giga Mutant - Top)",
            "85: Mutant Gas / Poison (Giga Mutant - Top)",
            "86: Double Part Attack: Dark Plasma (Giga Gaia - Left Arm)",
            "87: Dash? (Possible enemy dual",
            "88: Variation of 80, with explosion at the end (Dalton Plus)",
            "89: Blue flash with circles (Synchrite)",
            "8A: Water cyclone (Heckran)",
            "8B: Telepathy / Sleep (Azala)",
            "8C: Tackle attack?",
            "8D: Jump attack?",
            "8E: Beam blast?",
            "8F: Dark Gear / Shadow (Zeal)",
            "90: Zeal's lightning attack / beam",
            "91: Hexagon Mist (Zeal)",
            "92: Delta Force (Scouter / Red Scout / Blue Scout)",
            "93: Enemy jumps and turns invisible (Part of running away, only enemy does not run)",
            "94: \"Revives Head with Defense Parts\" (Giga Gaia - Left Arm)",
            "95: \"The Drop\" (HP Down by 1/2) (Giga Gaia - Right Arm)",
            "96: Bad Impulse (Flea Plus triple counter)",
            "97: Fire Sword (Super Slash, with Flea Plus)",
            "98: Crying Heavens (Lavos Core - Center Bit)",
            "99: Evil Star (Party's HP down by 1/2) (Lavos Core - Center Bit)",
            "9A: Destruction Rains From the Heavens! (Lavos)",
            "9B: Grand Stone (Lavos Core - Center Bit)",
            "9C: Grudge (Sentry)",
            "9D: Fire 2 (Magus)",
            "9E: Ice 2 (Magus)",
            "9F: Lightning 2 (Magus)",
            "A0: Time Warp (Prehistoric) (Lavos Core - Center Bit)",
            "A1: Time Warp (Leene Square) (Lavos Core - Center Bit)",
            "A2: Time Warp (Lab 16?) (Lavos Core - Center Bit)",
            "A3: Time Warp (Magus's Castle) (Lavos Core - Center Bit)",
            "A4: Time Warp (Mammon Machine)",
            "A5: Time Warp (???) (Lavos - Second form)",
            "A6: Area Bomb (Atropos XR)",
            "A7: Like Robo Tackle, only reduces party's HP by 1/2 (Atropos XR)",
            "A8: Needle attack (Hits all) (Yakra XIII)",
            "A9: Flare (Spekio - Pink Nu)",
            "AA: ???, what the hell does this do?",
            "AB:Earthquake attack that does no damage?",
            "AC: Roulette shuffle? (Son of Sun)",
            "AD: Roulette Shuffle (Son of Sun)",
            "AE: Flame attack (Son of Sun's flame counterattack?)",
            "AF: Sword sound effect?",
            "B0: Flame attack (Gigasaur)",
            "B1: Empty tech? (Panel)",
            "B2: Gato's \"Multipunch\"",
            "B3: Blue Fire attack? (Non",
            "B4: Hallation (Party's Hp down to 1) (Zeal)",
            "B5: Dark Bomb (Lavos Spawn - Head)",
            "B6: Like Azala's rock teleportation, but with smaller rocks, and hits all",
            "B7: Higher power cure attack (Lavos - Left Arm)",
            "B8: Lavos's sing attack (Random status, may freeze game if not used by Lavos?) (Lavos Core - Center Bit)",
            "B9: Multicolored ball attack (Lavos Core - Main Body)",
            "BA: Charge attack (Lavos Core - Left Bit)",
            "BB: Luminaire (Spekkio - Pink Nu)",
            "BC: Tornado spin (Slash / Flea dual)",
            "BD: Nothing?",
            "BE: Nothing?",
            "BF: Nothing?",
            "C0: Weird flash?",
            "C1: Empty Tech? (Giga Gaia - Right Arm)",
            "C2: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "C3: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "C4: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "C5: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "C6: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "C7: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "C8: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "C9: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "CA: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "CB: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "CC: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "CD: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "CE: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "CF: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "D0: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "D1: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "D2: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "D3: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "D4: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "D5: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "D6: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "D7: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "D8: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "D9: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "DA: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "DB: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "DC: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "DD: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "DE: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "DF: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "E0: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "E1: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "E2: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "E3: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "E4: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "E5: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "E6: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "E7: An attack that just has the target (crono) blink white a few times, and damage is taken.",
            "E8: Red tounge snatches party member up, monster chomps them, and spits them out (Krakker)",
            "E9: Shoots balls of fire at characters, flames disperse upon impact (Megasaur)",
            "EA: An unused attack that makes rocks materialize above opponent, and drops with an odd noise",
            "EB: An unused attack that makes rocks materialize above opponent, and drops with an odd noise",
            "EC: An unused attack that makes rocks materialize above opponent, and drops with an odd noise",
            "ED: Red circle under party member, expands outwards (Enemy 0xDE)",
            "EE: Red balls go above enemy, collect and hover above party member, drops and mini red mushroom cloud (Tera Mutant - Top)",
            "EF: Singing attack, causes confusion in party member instead of damage",
            "F0: Lavos Spawn Needle (Lavos Spawn - Body)",
            "F1: Laser shoots out and through party member causing damage (Martello, Panel)",
            "F2: Missiles shoot up and land on party member (Panel)",
            "F3: Enemy jumps up, shoots out black circle at party member, party member laughs (Mega Mutant)",
            "F4: Charge attack with red trail (Lavos Core - Left Bit)",
            "F5: dElectric charge release",
            "F6: Red rocks shoot up, screen turns red, red rocks fall (Terra Mutant - Top)",
            "F7: Star shoots to party member, tornado picks them up, drops them (Goon)",
            "F8: Red Rain (Metal Mute)",
            "F9: The Drop (Goon)",
            "FA: Red spark in center of screen, expands outward in a red circle, and there is... damage...",
            "FB: Water Rise / Water (Lavos Spawn - Head)",
            "FC: Red balls go above enemy, collect and shoot at party member for damage (Zeal)",
            "FD: Telekenisis?",
            "FE: Red balls go above enemy, collect and hover above party member, drops and mini red mushroom cloud (variant?)",
            "FF: Party member flashes white a few times, but no damage is taken (unlike the others like this)"

What did you find that I was missing? I do plan to go over your notes at some point, although my priority lately has been the 8th character patch.

I'm familiar with how the hit effects work - in fact, Hi-Tech reads that data at ROM load to generate its list. I want to make it editable at some point, but I haven't decided where - that same data is also used by weapons and armor.

Switch states is used by the game to determine if its processing conditions or actions. The first section end is the start of the reaction processing. Both of these could probably be made invisible to the user.

I'm not sure how often a condition is evaluated. I do know only one action is taken per enemy turn.

sqykly

  • Earthbound (+15)
  • *
  • Posts: 17
    • View Profile
Re: Simple way to map enemies to the techs they use?
« Reply #7 on: April 08, 2015, 12:47:52 am »
Well if you do know how hit effects work, then the only details I think you'll be interested in are the control header flags $40 and $20, which override each component effect header's flags $20 and $10, respectively.  I'll work my symbol table into something readable shortly, and maybe you'll find something else you can use.

At a minimum, you'll need to be fluent in basic, c, and c++ in order to make sense of my notes in the disassembly.  I kind of go with whatever suits what I'm looking at best, and it's not particularly consistent.  Still, probably more readable than a disassembly.

Thanks for that list, I think that pretty much caps off what I need for what I'm doing.  How would you like to be credited when I publish my faq?

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1774
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Simple way to map enemies to the techs they use?
« Reply #8 on: April 08, 2015, 02:23:14 am »
What byte are those flags on?

I'd like to be credited as Mauron.

What would you like to be credited as for my editor and document?

sqykly

  • Earthbound (+15)
  • *
  • Posts: 17
    • View Profile
Re: Simple way to map enemies to the techs they use?
« Reply #9 on: April 10, 2015, 07:55:58 pm »
Offset is 1, the byte right after the performance group index.

BitsMeaning
$07If none of these bits are set, the 2nd and 3rd effect headers are ignored.  It looks like most double techs have this field set to 1 and triple techs have it set to 2, but I can't seem to find this being decremented or compared to an index at the moment, so I'm not ready to conclude that it's the number of effect headers to use beyond the first.
$18Not known to be used (by me, anyway)
$20If set, overrides bit $10 of all effect headers' flags at offset 7, causing the tech to disregard the effect header's failure conditions.
$40If set, overrides bit $20 of all effect headers' flags at offset 7, bypassing evasion even if the effect header allows it.
$80Not known to be used (by me, anyway)

One more thing I noticed: In HiTech, the enemy physical attack damage formula appears to use the enemy's level instead of its attack attribute.  Not sure if you know this already or not, or if it's relevant for what you're doing, but these are the formulas for the maximum random damage added, since I didn't see it in any of the info you provided:

Mode/tagMaximum Random Damage added
1 : PC melee weaponPWR/3 + 1
2 : PC ranged weaponHIT*77/256 + 1
3 : MagicMAG*77/256 + 1
4 : Enemy physicalATK*205/1024 + 2
5 : Ayla's fistLVL/3 + 1
6 : Desperation / Summons(MAXHP - HP)*103/1024 + 1
7 : Possibly unused attack with someone else's weaponPWR*77/256 + 1
8 : Attack hackers with spaghetti codeHours of time
9 : Possibly unused weapon attackPWR*77/256
10 : Variable attributeATTR*77/256 + 1

Random damage is added after defense is applied, but before status modifications and modifiers / hit effects are applied.

You can credit me as sqykly if you like, but it looks like I've contributed just 2 bits you can use, so don't worry about it.

A few questions about the AI scripts.  You said earlier that the first section (the one that isn't counters) will only run one thing per enemy turn.  Does that apply to techs and attacks (actions that traditionally take up a turn) only, or is there also a wait for other stuff?  In particular, I keep seeing the set wander mode both before and after a tech, and in some cases several set wander modes in a row.  Some of those cases seem to correspond to stunned enemies, e.g. reptites hit with lightning set their custom byte to remember they're stunned, and the script that catches that condition is just a sequence of wanders and/or messages, followed by clearing the custom byte at the end.  If wanders did not have an interval between execution, it seems like the stun would end immediately and not be very useful.  However, if all wander modes consumed a turn, most enemies would only be attacking every 3 turns as their attacks are sandwiched between wander instructions.  Can you clarify what wander modes mean & how they interact with turns?  Or point me at something that can enlighten me?  Thanks.

EDIT:  Just one more question!  I've seen plenty of bestiaries for CT in varying states of completeness, but never one that lists status immunities.  I know I've seen the game checking for them.  Is there a convenient source for this, or should I just dump it out of the rom like most everything else?
« Last Edit: April 10, 2015, 08:25:03 pm by sqykly »

sqykly

  • Earthbound (+15)
  • *
  • Posts: 17
    • View Profile
Re: Simple way to map enemies to the techs they use?
« Reply #10 on: April 10, 2015, 08:16:06 pm »
This sounds like exciting work. As a CT speedrunner, I would love to learn as much as I can about the battle mechanics, and anything else really. I saw your post the other day and figured it was way beyond me... But then I remembered, couldn't you extract this out of the AI? By picking out the Action 02's... http://datacrystal.romhacking.net/wiki/Chrono_Trigger/Enemy_AI_Documentation
Perhaps there's a more straightforward way, I'm not sure =)

I looked at that link, and it's a lot of the same info that Mauron's provided.  And yeah, that was sort of my last ditch non-simple tedious plan.  When my mechanics guide is done, I do hope it will be useful to you, but when I try to put together tactics using what I've learned, it's a lot of the same stuff we've all been doing intuitively forever.  Like using Ayla all the time.  You can tell she's awesome at upper levels even if I haven't yet told you that her base damage grows with her level squared.  If you use Lucca, you're probably feeding her magic tabs even if I haven't yet told you that her chance to inflict sleep with hypnowave is increased by her magic stat.  I know, speed runners don't use Lucca a lot, it's just an example ;).

One fun insight that probably won't improve your time is that Lucca's Wondershot's damage multiplier is based on the seconds digit of your play time, so you could theoretically use a stopwatch or metronome or something to get it to do 3x damage every time.

EDIT: it's 3x damage, not 10x as I originally goofed.
« Last Edit: April 11, 2015, 06:06:37 pm by sqykly »

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1774
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Simple way to map enemies to the techs they use?
« Reply #11 on: April 11, 2015, 02:41:38 am »
Here's a link to the old research thread on AI. Most of what I have is built up from there.

For enemy immunities, you can check out my enemy stats plugin, along with my other plugins, except for Enemy AId and Hi-Tech.

Wander mode definitely takes up a turn. Let's use Gato's action section as an example.

Code: [Select]
Default
    - Attack 1 to random PC - this is where Gato use his single punch attack.
    - Wander mode, related to nearest PC. On his first wander turn, Gato will move up to the upper left corner, then back to the middle.
    - Tech 10, Gato's sing attack.

After that it loops back to his punch.

I'll look back at this tomorrow when I'm less tired.

Redslash

  • Earthbound (+15)
  • *
  • Posts: 21
    • View Profile
    • Twitch.tv/Redslash
Re: Simple way to map enemies to the techs they use?
« Reply #12 on: April 11, 2015, 04:57:47 am »
The bit about Wondershot in your previous post (randomBySeconds tag) I actually did get excited about. Since every move takes a specific number of frames, my idea would be to shoot once and get an initial reading, then branch out a fight script to land the best multiplier.
Always new things to be learned. Even if it ultimately doesn't change the strats, it's very satisfying to know why they work, and that our time investments aren't based so much on speculation =)
Applying anything from the AI would probably be pretty difficult really, some things are best left to trial-and-error. (For example, this Masa fight http://www.twitch.tv/redslash/c/6476595?t=1h01m32s) But, it would be fun to try to explain them!
« Last Edit: April 11, 2015, 05:08:32 am by Redslash »

sqykly

  • Earthbound (+15)
  • *
  • Posts: 17
    • View Profile
Re: Simple way to map enemies to the techs they use?
« Reply #13 on: April 11, 2015, 06:14:16 pm »
Here's a link to the old research thread on AI. Most of what I have is built up from there.

For enemy immunities, you can check out my enemy stats plugin, along with my other plugins, except for Enemy AId and Hi-Tech.

Wander mode definitely takes up a turn. Let's use Gato's action section as an example.

Code: [Select]
Default
    - Attack 1 to random PC - this is where Gato use his single punch attack.
    - Wander mode, related to nearest PC. On his first wander turn, Gato will move up to the upper left corner, then back to the middle.
    - Tech 10, Gato's sing attack.

After that it loops back to his punch.

I'll look back at this tomorrow when I'm less tired.

If there isn't a table of wander modes and what they do somewhere, I might have to bite; my disassembler is hungry, and I hate not knowing stuff.  Any breakpoints I should be aware of?

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1774
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Simple way to map enemies to the techs they use?
« Reply #14 on: April 12, 2015, 02:58:49 pm »
Here's the limited code I have on wander modes.

Code: [Select]
Disassembly: AI Action 00, set 1.
$C1/9810 AE D2 B1 LDX $B1D2  [$7E:B1D2]
$C1/9813 E8 INX
$C1/9814 8E D2 B1 STX $B1D2  [$7E:B1D2]
$C1/9817 20 14 AC JSR $AC14  [$C1:AC14] // Routine for targeting.
$C1/981A AE D2 B1 LDX $B1D2  [$7E:B1D2]
$C1/981D E8 INX
$C1/981E 8E D2 B1 STX $B1D2  [$7E:B1D2]
$C1/9821 BF 00 00 CC LDA $CC0000,x[$CC:0000] // Wander mode value.
$C1/9825 8D E5 AE STA $AEE5  [$7E:AEE5]
$C1/9828 7B TDC
$C1/9829 AD 52 B2 LDA $B252  [$7E:B252] // Enemy index - 3
$C1/982C AA TAX
$C1/982D AD E5 AE LDA $AEE5  [$7E:AEE5]
$C1/9830 9D 0D 5E STA $5E0D,x[$7E:5E0D]
$C1/9833 AD CC AE LDA $AECC  [$7E:AECC]
$C1/9836 9D 15 5E STA $5E15,x[$7E:5E15]
$C1/9839 60 RTS

Disassembly: AI Action 00, set 2.
$C1/99B8 A9 02 LDA #$02
$C1/99BA 8D B8 B3 STA $B3B8  [$7E:B3B8]
$C1/99BD 60 RTS

Let me know what you find.