diff options
author | Idain <luiscarlosholguinperez@outlook.com> | 2021-11-22 00:16:39 -0400 |
---|---|---|
committer | Idain <luiscarlosholguinperez@outlook.com> | 2021-11-22 00:16:39 -0400 |
commit | 5f63ea8838d10e30700736d04048faaa4b0b2a4d (patch) | |
tree | 19fe322cc6a82daf72c21a031d82a6b31ec29929 | |
parent | db1e773b1887edbb8de5e514a7836ef2736d0639 (diff) |
Fix format, optimize code and fix check after `friendship_endure_checks`
-rw-r--r-- | SWSH-Friendship-Endure.md | 131 |
1 files changed, 68 insertions, 63 deletions
diff --git a/SWSH-Friendship-Endure.md b/SWSH-Friendship-Endure.md index 89a1ea3..b79c3d2 100644 --- a/SWSH-Friendship-Endure.md +++ b/SWSH-Friendship-Endure.md @@ -2,10 +2,13 @@ Pokémon Sword and Shield merged friendship and affection, and as a result, merg This tutorial implements the chance to endure an attack that would otherwise cause the Pokémon to faint. This effect does not occur for enemy trainers or during link battles. ## Contents + 1. [Add the Friendship Endure text](#1-add-the-friendship-endure-text) 2. [Update the ApplyDamage battle command](#2-update-the-applydamage-battle-command) + ## 1. Add the Friendship Endure text + In [data/text/battle.asm](../blob/master/data/text/battle.asm), we add in a new text string for when an attack is endured through friendship. ```diff EnduredText: @@ -19,83 +22,85 @@ EnduredText: + prompt ``` + ## 2. Update the ApplyDamage battle command -Next, in [engine/battle/effect_commands.asm](../blob/master/engine/battle/effect_commands.asm), we need to find `BattleCommand_ApplyDamage` label. -there are several changes to be made in this section + +Next, in [engine/battle/effect_commands.asm](../blob/master/engine/battle/effect_commands.asm), we need to find `BattleCommand_ApplyDamage` and make several changes here: + ```diff -BattleCommand_ApplyDamage: - ld a, BATTLE_VARS_SUBSTATUS1_OPP - call GetBattleVar - bit SUBSTATUS_ENDURE, a -- jr z, .focus_band -+ jr z, .friendship_endure + BattleCommand_ApplyDamage: + ; applydamage + + ld a, BATTLE_VARS_SUBSTATUS1_OPP + call GetBattleVar + bit SUBSTATUS_ENDURE, a +- jr z, .focus_band ++ jr z, .friendship_endure - call BattleCommand_FalseSwipe - ld b, 0 - jr nc, .damage - ld b, 1 - jr .damage + call BattleCommand_FalseSwipe + ld b, 0 + jr nc, .damage + ld b, 1 + jr .damage +.friendship_endure -+ ld a, [wLinkMode] -+ cp LINK_COLOSSEUM -+ jr z, .focus_band ++ ld a, [wLinkMode] ++ and a ++ jr nz, .focus_band ++ ++ ldh a, [hBattleTurn] ++ and a ++ jr z, .focus_band + -+ ld hl, wBattleMonHappiness -+ ldh a, [hBattleTurn] -+ and a -+ jr z, .focus_band ++ ld hl, wBattleMonHappiness ++ ld a, [hl] ++ ld b, 25 percent + 1 ++ cp 255 ++ jr z, .friendship_endure_checks + -+ ld a, [hl] -+ cp 255 -+ jr z, .endure_high -+ cp 220 -+ jr nc, .endure_mid -+ cp 180 -+ jr c, .focus_band -+; fallthrough -+ ld b, 12 percent -+ jp .friendship_endure_checks -+.endure_mid -+ ld b, 18 percent -+ jr .friendship_endure_checks -+.endure_high -+ ld b, 25 percent ++ ld b, 18 percent + 1 ++ cp 220 ++ jr nc, .friendship_endure_checks + ++ ld b, 12 percent + 1 ++ cp 180 ++ jr c, .focus_band ++ ; fallthrough +.friendship_endure_checks -+ call BattleRandom -+ cp b -+ jr c, .focus_band ++ call BattleRandom ++ cp b ++ jr nc, .focus_band + -+ call BattleCommand_FalseSwipe -+ ld b, 0 -+ jr nc, .damage -+ ld b, 3 -+ jr .damage ++ call BattleCommand_FalseSwipe ++ ld b, 0 ++ jr nc, .damage ++ ld b, 3 ++ jr .damage + -.focus_band - ... + .focus_band + ... -.done_damage - pop bc - ld a, b - and a - ret z + .done_damage + pop bc + ld a, b + and a + ret z -- dec a -- jr nz, .focus_band_text -- ld hl, EnduredText -+ dec a -+ jr z,.endured_text -+ dec a -+ jr z, .focus_band_text -+ ld hl, EnduredFriendshipText -+ jp StdBattleTextbox + dec a +- jr nz, .focus_band_text +- ld hl, EnduredText ++ jr z, .endured_text ++ dec a ++ jr z, .focus_band_text ++ ld hl, EnduredFriendshipText ++ jp StdBattleTextbox + +.endured_text -+ ld hl, EnduredText - jp StdBattleTextbox ++ ld hl, EnduredText + jp StdBattleTextbox .focus_band_text - ... -```
\ No newline at end of file + ... +``` + +And that's it! Now our Pokémon can be anime protagonists and have a chance to endure hits thanks to the power of friendship!
\ No newline at end of file |