Fix berserked targeting after using Hermes#1
Open
cassidoxa wants to merge 2 commits intoHungryTenor:mainfrom
Open
Fix berserked targeting after using Hermes#1cassidoxa wants to merge 2 commits intoHungryTenor:mainfrom
cassidoxa wants to merge 2 commits intoHungryTenor:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a bug where berserked party members can target swooned enemies if they use the Hermes item before being berserked. We hook into the battle command execution routine at $03AE81, where the current actor's subcommand is loaded and compared to $BA, which is used for both the Hermes item and a "Life All" enemy spell. If the value is $BA, a "can hit swooned" flag is set (also used for things like Life potions.) Our code checks if the actor command is $C2, a monster white magic action. If the command is $C2, we load the subcommand, exit, and proceed with the comparison. If not $C2, we transfer Y (which will always hold $FFFF from a previous loop in this path) to A.
This works because the Life All command is only used during the Zeromus cutscene (when Palom and Porom revive the party.) So the subcommand can never be $BA except in this cutscene and therefore other enemy healing actions won't improperly target swooned characters. When a character is berserked, their command will never be $C2, the monster white magic command. Y = $FFFF is another invariant we can depend on, there are no branches between the decrement that sets it and our code.
Another avenue worth investigating is hooking into the vanilla "select berserk target" routine around $03ACA3 which is called during a "queue auto actions routine" that only loops through the five player characters. The former routine initializes some character data including setting the "main" command to zero. It may be possible to safely zero out the subcommand here as well (perhaps if the character is also not charmed.) But I am unsure if this may have other side effects. Could also look into zeroing out the subcommand when berserked.