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

sqykly

  • Earthbound (+15)
  • *
  • Posts: 17
    • View Profile
Re: Simple way to map enemies to the techs they use?
« Reply #15 on: April 12, 2015, 04:35:17 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.

Alright, I'll start with a read breakpoint on $7E5E0D.  M and X flags are set and clear in that code, respectively, in case I need to disassemble $C1AC14?  Any chance the screen or world coordinates of the enemies are at some known offset?

EDIT: Better make that $5E10; didn't realize $B252 was the index among all battle participants & not just enemies.
« Last Edit: April 12, 2015, 06:05:57 pm by sqykly »

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1776
  • Nu-chan
    • View Profile
    • Hi trig!
Re: Simple way to map enemies to the techs they use?
« Reply #16 on: April 12, 2015, 06:00:02 pm »
Alright, I'll start with a read breakpoint on $7E5E0D.  M and X flags are set and clear in that code, respectively, in case I need to disassemble $C1AC14?

Correct.

Quote
Any chance the screen or world coordinates of the enemies are at some known offset?

It should be somewhere in here. Gato is object 08 is his event.

Code: [Select]
7E1801 ??? FF Location Object X Coord 2007.08.15
7E1881 ??? FF Location Object Y Coord 2007.08.15

Djibriel

  • Iokan (+1)
  • *
  • Posts: 4
    • View Profile
    • Collapse of Heaven and Earth
Re: Simple way to map enemies to the techs they use?
« Reply #17 on: June 04, 2015, 07:55:33 am »
Though I'm no programmer, I have been tinkering with enemy AI lately. I've found that there is a lot of info 'missing' about CT. What's the damage formula for enemy Techs? What's the hit% of Lucca's Hypno Wave or the Slow-setting ability of the Blue Eaglet's Scream? These things, I would like to know.

What makes CT AI much more difficult than, say, FFVI's AI is that movement and some sprite choices are made in the AI string. 01 is the Attack command, always followed with three bytes; AA BB CC. AA is which attack is to be used (00 = basic physical, 01 = special physical), BB is targeting, CC seems to be a condition byte. 00 AA BB CC is a movement command where CC is the sprite set that is used at the end (does Gato raise his arms up and down or does he march in place. Well, you probably know all this.

Anyway, the Blue Eaglet's Scream / Slow is Non-elemental magic attack with base damage (LV+MAG)*4/3, always hits, 50% chance to inflict slow? That's good to know.

I feel the CT community would really benefit from a document detailing mechanics, attacks and/or enemy behavior. I've been writing something that's shaping up to become a detailed walkthrough for CT lately, but I've become frustrated with the lack of good info I could find. Triple Tech damage formulae, damage calculations, enemy immunities and all that are hard or impossible to come by, it seems. Editors would be helpful, but for me personally, a Mac user, no answer.

So anyway, I have little to contribute to this topic except for lots and lots of questions, but I wanted to indicate how helpful your work is / could be. Looking forward to your mechanics guide sqykly.




Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1776
  • Nu-chan
    • View Profile
    • Hi trig!
Re: Simple way to map enemies to the techs they use?
« Reply #18 on: June 05, 2015, 12:11:32 am »
Enemy physical techs should use (Level + Magic) * 12 * Tech Power / 15 for the damage formula. Enemy magical techs should use Level * 2 * Tech Power / 18 for the formula.

Lucca's Hypno Wave has a base chance of 60%, plus (magic / 10)%. Blue Eaglet's scream has a tech power of 2, and a straight 50% chance of slow.

I may make a dump of AI in text format, if I get around to it.  Unfortunately Temporal Flux doesn't run under Mono last I checked, and I don't plan on making a stand alone version of Enemy AId, since I couldn't take advantage of Temporal Flux's memory management.

Fortranm

  • Architect of Kajar
  • Earthbound (+15)
  • *
  • Posts: 32
    • View Profile
Re: Simple way to map enemies to the techs they use?
« Reply #19 on: June 17, 2015, 05:36:55 am »
Has anyone gotten the formula for Frog Squash and Dino Tail?
I wonder if there are any differences between their damage formulas.

Djibriel

  • Iokan (+1)
  • *
  • Posts: 4
    • View Profile
    • Collapse of Heaven and Earth
Re: Simple way to map enemies to the techs they use?
« Reply #20 on: June 18, 2015, 09:22:58 am »
Phoenix 1911 lists them as:

Frog Squash:
Damage = ((maximum HP) - (current HP)) * (Stamina / 140) * 10 * (1 - Physical Defense / 255) + Random Value

Dino Tail
Damage = ((maximum HP) - (current HP)) * (Stamina / 140) * 9 * (1 - Physical Defense / 255) + Random Value

I've been decoding monster AI scripts by hand, almost done. Mapping last few monsers / bosses in sidequests prior to Black Omen. Discovered a few weird things. Chrono Compendium is wrong/incomplete on a few occassions.

The condition routine that starts with the value 17 picks any random number for a 'random chance' of something happening. Is the value in the second byte the value is measures? In other words, when the condition is 17 20 00 00 does that mean that there is a 32% chance of something happening?

Is there text documentation of monster Tech Power values?

« Last Edit: June 18, 2015, 09:28:24 am by Djibriel »

Fortranm

  • Architect of Kajar
  • Earthbound (+15)
  • *
  • Posts: 32
    • View Profile
Re: Simple way to map enemies to the techs they use?
« Reply #21 on: June 18, 2015, 02:48:13 pm »
Thanks for the information!
It's surprising that they actually don't have anything to do with the value of power.

Redslash

  • Earthbound (+15)
  • *
  • Posts: 21
    • View Profile
    • Twitch.tv/Redslash
Re: Simple way to map enemies to the techs they use?
« Reply #22 on: June 26, 2015, 04:35:53 am »
Yo, I love this thread. I started trying to make a readable AI doc too, and I've been able to fill in a few gaps so far. Missing lots of details, but it's cool seeing the big picture at least (http://goo.gl/xfBNaZ)
Random numbers are weird, the condition probably uses the frame (or maybe second?) that the enemy's ATB fills, to lookup a value from the random number table (just like how acid/alkaline formation is determined)... haven't found a simpler explanation anyway. I did finally test the Wondershot cycles for myself, and it turns out it's based on seconds, not frames.

Djibriel

  • Iokan (+1)
  • *
  • Posts: 4
    • View Profile
    • Collapse of Heaven and Earth
Re: Simple way to map enemies to the techs they use?
« Reply #23 on: June 29, 2015, 07:19:26 am »
Sweet! I decoded all AI scripts except all the Lavos by hand as well. Looks like we share some questions:

What is the Magus enemy with ID #FB? My theory is that a different Magus was set to appear when you fight him mano a mano with Frog, since it has specific Masamune react script. But he never shows as far as I can tell.

What's with the 02 01 01 02 condition used by Bug, Mad Bat and the 02 00 01 02 condition used by Flea? I can't really see any good reason for an insect to use Missile anyway. Also, Flea seems to do very little when one or more characters have Berserkers equipped, and I don't see why.



Razig

  • Enlightened One (+200)
  • *
  • Posts: 232
    • View Profile
Re: Simple way to map enemies to the techs they use?
« Reply #24 on: June 29, 2015, 04:05:59 pm »
What is the Magus enemy with ID #FB? My theory is that a different Magus was set to appear when you fight him mano a mano with Frog, since it has specific Masamune react script. But he never shows as far as I can tell.

Big props to those with the skill to understand all this debugging and memory address stuff. It's way over my head so I could easily be wrong, but perhaps this version of Magus might be the one Lavos mimics during the battle with its shell?

Redslash

  • Earthbound (+15)
  • *
  • Posts: 21
    • View Profile
    • Twitch.tv/Redslash
Re: Simple way to map enemies to the techs they use?
« Reply #25 on: June 29, 2015, 06:59:37 pm »
Lavos shell Magus is accounted for, good thinking though. Those did take some sorting through since they're all named "Lavos", ha ha. But, this Magus is clearly incomplete, with a random move set that's empty. I agree it could've been for a different 1v1 fight with Frog (isn't fight pretty tough?) Or maybe you could've fought him sometime after recruiting him, that'd be sick.

Flea's behavior versus Berserk Frog is attributed to an ATB glitch... Flea's AI doesn't get to advance at all because Frog's speed exactly matches up and overrides Flea's attack. Might be more to it than that, I'm not sure. If Frog's HP is lower than P3's HP, then he'll also override Flea's counterattack, otherwise he won't. Pretty weird. Perhaps Condition 02 could be a check on player's HP, but I would guess it's unrelated.

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1776
  • Nu-chan
    • View Profile
    • Hi trig!
Re: Simple way to map enemies to the techs they use?
« Reply #26 on: June 29, 2015, 09:38:57 pm »
Sweet! I decoded all AI scripts except all the Lavos by hand as well. Looks like we share some questions:

What is the Magus enemy with ID #FB? My theory is that a different Magus was set to appear when you fight him mano a mano with Frog, since it has specific Masamune react script. But he never shows as far as I can tell.

Everything I have lists ID #FA (North Cape Magus) as the last entry in the enemy table. I'm not sure what would follow.

Quote
What's with the 02 01 01 02 condition used by Bug, Mad Bat and the 02 00 01 02 condition used by Flea? I can't really see any good reason for an insect to use Missile anyway. Also, Flea seems to do very little when one or more characters have Berserkers equipped, and I don't see why.

Condition 02 is as follows. 02 TT OO BB.
TT - Target, 00 for PCs, 01 for enemies.
OO - Offset from battle data 0x1D (start of status flags).
BB - Bits to check.

So 02 00 01 02 would be If any PC is asleep.

Redslash

  • Earthbound (+15)
  • *
  • Posts: 21
    • View Profile
    • Twitch.tv/Redslash
Re: Simple way to map enemies to the techs they use?
« Reply #27 on: July 01, 2015, 04:02:44 am »
Cool! It does appear the Bugs check for sleeping enemies. But they don't use missile unless a PC is also sleeping. That's interesting. I don't really understand targetting at all, so I won't be taking my doc any further at this point X)
Thank you for all your insights Mauron, I defer to you completely on this topic =)

Djibriel

  • Iokan (+1)
  • *
  • Posts: 4
    • View Profile
    • Collapse of Heaven and Earth
Re: Simple way to map enemies to the techs they use?
« Reply #28 on: July 07, 2015, 10:34:55 am »
Here you can see #FB's AI script:

http://datacrystal.romhacking.net/wiki/Chrono_Trigger/Enemy_AI_Documentation

The name Magus may be misapplied (dunno who attached the names), but the script is definately Magus-like since it spams the big 3 and has specific Masamune react-scripts, but not against Masamune II. It only uses physical attacks on its turn, and counters with full-screen elemental mayhem.

I noticed how enemy HP-draining attacks seem to scale with character's level. Are they percentage-based?
« Last Edit: July 07, 2015, 10:36:29 am by Djibriel »

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1776
  • Nu-chan
    • View Profile
    • Hi trig!
Re: Simple way to map enemies to the techs they use?
« Reply #29 on: July 07, 2015, 04:20:03 pm »
Looking at it more, there's definitely AI, stat, sprite, and reward data for enemies up to 0xFF. The only thing missing is name data - after the entry for Magus 0xFA, there's some other data present.

In the case of enemy 0xFB, the data was mostly filled in too. It loads Magus's graphics, has 3333 HP, and no status immunities other than 1/2 HP and instant death. The remaining stats are identical to Magus 0xFA.

Enemies 0xFC-0xFF are mostly incomplete, but space was reserved for them. Since the sprite data was left at 0, it loads Crono's graphics.