Animorphs GBC Battle Mechanics ------------------------------ a writeup by stump (twitch.tv/stumpdotio) == Who goes first? == If you're not morphed, you go first, but you're forced to use that turn to morph. The battle continues with an AI turn. If you're already morphed, the higher speed stat goes first. You win ties. Each side gets one action in strict alternation. You get to attack, run, or morph; the AI always chooses to use one of its attacks, (nominally) uniformly at random each time. You are given the menu at the beginning of each of your turns. == Morphing == You can unmorph. You are forced to immediately morph again. The AI does not get a turn in between. After you remorph, the battle continues with an AI turn. Defense is kept across morphs; the low-health debuff is (correctly) reset. == Running == If your speed stat, plus an RNG byte, minus the enemy's speed stat, is greater than or equal to 128, running succeeds. Otherwise, it fails. (This is done with 16-bit addition, and negative and over-255 results are correctly handled.) Runs are guaranteed to fail if your max HP is less than 1/4 of your current HP. (That is not a typo - this is actually in the code!) Since this can never be true, it doesn't matter, but given the debuff that occurs whenever you drop to 1/4 health, this was probably intended to prevent you from running when weakened. == Attacking == Just before you are given the main menu, if you don't have the low-health debuff already you are given it if you are at or below 1/4 health. No message is displayed yet if this happens. After you select a move, if you just got the low-health debuff, you are told "Your attacks are less effective!" before the " tries .." text. === Move success === The move success check is then performed. If the attacker's speed, plus an RNG byte, plus the attack's modifier to hit, plus 16 is greater than or equal to 1.5 times the defender's speed (rounded down), the attack succeeds. Otherwise, it fails with the message "But it fails." and there is no effect. (This is checked for all moves, even defensive ones.) Damage is then computed. === Damage and defense === If the move has a defense boost, this quantity is added to the attacker's defense. (All moves with defense boosts have zero base damage.) If the defense value goes over 255, it wraps, losing 256 defense points. (Defense starts at zero in each battle and is carried across morphs.) If the defender's defense is less than or equal to the move's defense drop (which is only nonzero for specific defensive moves), the defender's defense becomes zero, and the damage is set to the base damage. Skip to "Boosts and drops." Otherwise, the move's base damage and defense drop (at least one of which is zero for every move) are added together. If the sum is less than or equal to the defender's defense, the defender loses that much defense, and the damage is set to zero. Otherwise the damage is set to that sum minus the defender's defense, and the defender's defense is set to zero. Boosts and drops never apply to mechanics involving defense, only to whatever damage gets past this stage. TL;DR: There are three types of moves: 1. Attacking moves: Reduce defender's defense by move's base damage, with any excess base damage moving forward in the damage calculation. (Bite, Claw, Scream, Venom, Throw, Gnaw, Punch, Kick, Tailwhip) 2. Pure defending moves: Attacker's defense increases by move's defense boost. (Burrow, Camo, Dodge, Feign) 3. Defending moves with defense drops: Attacker's defense increases by move's defense boost and defender's defense decreases by move's defense drop, but excess defense drop does not become damage. (Swim, Climb, Fly) === Boosts and drops === Damage is halved (rounded down) for your attacks when the low-health debuff is in effect. There is no such debuff for the AI. Damage is then halved (rounded down) if the move used matches the defender's resistance. Damage is then doubled if the move used matches the defender's weakness. "Successful defense!" is shown for successful defensive moves. "But it is avoided" is shown for otherwise-successful attacking moves that do no damage. "Super effective!" is shown if double damage occurred due to weakness, except if (for attacks in either direction!) the low-health debuff is in effect, even though double damage still applies. "Success!" is shown in other cases. == Animal and move list == Enemies are defined in a large table for each level that includes all of their attributes (though the same type of enemy is *usually* consistent over its appearances in the table). The table includes other entries; I think it may be all of the level's objects and sprites. You should be able to tell by whether the stats and moves are nonsense. It's dumped in animorphs-table-dump in this directory. /afs/stump.io/speedruns/notes/animorphs-table-dump http://notes.stump.io/animorphs-table-dump Note carefully: The same-named move will not necessarily have the same numeric attributes in all of its appearances. Make sure you're using the right numbers when calculating probabilities!