aboutsummaryrefslogtreecommitdiffstats
path: root/engine/battle/move_effects/recoil.asm
diff options
context:
space:
mode:
authorRangi <35663410+Rangi42@users.noreply.github.com>2020-07-03 09:38:52 -0400
committerGitHub <noreply@github.com>2020-07-03 09:38:52 -0400
commitc85050497c1bd062e9cd40bf5b32fa3beca366cc (patch)
tree9593ddd3ab820223ab580d5fc0ae133b485b8315 /engine/battle/move_effects/recoil.asm
parentActually run .travis/webhook.sh (diff)
parentAdd engine/movie/oak_speech/ subdirectory (diff)
downloadpokeyellow-c85050497c1bd062e9cd40bf5b32fa3beca366cc.tar.gz
pokeyellow-c85050497c1bd062e9cd40bf5b32fa3beca366cc.tar.xz
pokeyellow-c85050497c1bd062e9cd40bf5b32fa3beca366cc.zip
Merge pull request #256 from Rangi42/master
Add subdirectories to engine/ similar to pokecrystal
Diffstat (limited to 'engine/battle/move_effects/recoil.asm')
-rw-r--r--engine/battle/move_effects/recoil.asm70
1 files changed, 70 insertions, 0 deletions
diff --git a/engine/battle/move_effects/recoil.asm b/engine/battle/move_effects/recoil.asm
new file mode 100644
index 00000000..0f2f087b
--- /dev/null
+++ b/engine/battle/move_effects/recoil.asm
@@ -0,0 +1,70 @@
+RecoilEffect_:
+ ld a, [H_WHOSETURN]
+ and a
+ ld a, [wPlayerMoveNum]
+ ld hl, wBattleMonMaxHP
+ jr z, .recoilEffect
+ ld a, [wEnemyMoveNum]
+ ld hl, wEnemyMonMaxHP
+.recoilEffect
+ ld d, a
+ ld a, [wDamage]
+ ld b, a
+ ld a, [wDamage + 1]
+ ld c, a
+ srl b
+ rr c
+ ld a, d
+ cp STRUGGLE ; struggle deals 50% recoil damage
+ jr z, .gotRecoilDamage
+ srl b
+ rr c
+.gotRecoilDamage
+ ld a, b
+ or c
+ jr nz, .updateHP
+ inc c ; minimum recoil damage is 1
+.updateHP
+; subtract HP from user due to the recoil damage
+ ld a, [hli]
+ ld [wHPBarMaxHP+1], a
+ ld a, [hl]
+ ld [wHPBarMaxHP], a
+ push bc
+ ld bc, wBattleMonHP - wBattleMonMaxHP
+ add hl, bc
+ pop bc
+ ld a, [hl]
+ ld [wHPBarOldHP], a
+ sub c
+ ld [hld], a
+ ld [wHPBarNewHP], a
+ ld a, [hl]
+ ld [wHPBarOldHP+1], a
+ sbc b
+ ld [hl], a
+ ld [wHPBarNewHP+1], a
+ jr nc, .getHPBarCoords
+; if recoil damage is higher than the Pokemon's HP, set its HP to 0
+ xor a
+ ld [hli], a
+ ld [hl], a
+ ld hl, wHPBarNewHP
+ ld [hli], a
+ ld [hl], a
+.getHPBarCoords
+ coord hl, 10, 9
+ ld a, [H_WHOSETURN]
+ and a
+ ld a, $1
+ jr z, .updateHPBar
+ coord hl, 2, 2
+ xor a
+.updateHPBar
+ ld [wHPBarType], a
+ predef UpdateHPBar2
+ ld hl, HitWithRecoilText
+ jp PrintText
+HitWithRecoilText:
+ TX_FAR _HitWithRecoilText
+ db "@"