summaryrefslogtreecommitdiff
path: root/engine/battle/moveEffects
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/moveEffects')
-rw-r--r--engine/battle/moveEffects/focus_energy_effect.asm24
-rw-r--r--engine/battle/moveEffects/leech_seed_effect.asm39
-rw-r--r--engine/battle/moveEffects/substitute_effect.asm77
3 files changed, 140 insertions, 0 deletions
diff --git a/engine/battle/moveEffects/focus_energy_effect.asm b/engine/battle/moveEffects/focus_energy_effect.asm
new file mode 100644
index 00000000..f01e61cc
--- /dev/null
+++ b/engine/battle/moveEffects/focus_energy_effect.asm
@@ -0,0 +1,24 @@
+FocusEnergyEffect_: ; 27f86 (9:7f86)
+ ld hl, W_PLAYERBATTSTATUS2
+ ld a, [H_WHOSETURN]
+ and a
+ jr z, .notEnemy
+ ld hl, W_ENEMYBATTSTATUS2
+.notEnemy
+ bit GettingPumped, [hl] ; is mon already using focus energy?
+ jr nz, .alreadyUsing
+ set GettingPumped, [hl] ; mon is now using focus energy
+ callab PlayCurrentMoveAnimation
+ ld hl, GettingPumpedText
+ jp PrintText
+.alreadyUsing
+ ld c, $32
+ call DelayFrames
+ ld hl, PrintButItFailedText_
+ ld b, BANK(PrintButItFailedText_)
+ jp Bankswitch
+
+GettingPumpedText: ; 27fb3 (9:7fb3)
+ db $0a
+ TX_FAR _GettingPumpedText
+ db "@"
diff --git a/engine/battle/moveEffects/leech_seed_effect.asm b/engine/battle/moveEffects/leech_seed_effect.asm
new file mode 100644
index 00000000..a257d143
--- /dev/null
+++ b/engine/battle/moveEffects/leech_seed_effect.asm
@@ -0,0 +1,39 @@
+LeechSeedEffect_: ; 2bea9 (a:7ea9)
+ callab MoveHitTest
+ ld a, [W_MOVEMISSED] ; W_MOVEMISSED
+ and a
+ jr nz, .asm_2bee7
+ ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2
+ ld de, wEnemyMonType1 ; wcfea (aliases: wEnemyMonType)
+ ld a, [H_WHOSETURN] ; $fff3
+ and a
+ jr z, .asm_2bec8
+ ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2
+ ld de, wBattleMonType1 ; wd019 (aliases: wBattleMonType)
+.asm_2bec8
+ ld a, [de]
+ cp GRASS
+ jr z, .asm_2bee7
+ inc de
+ ld a, [de]
+ cp GRASS
+ jr z, .asm_2bee7
+ bit Seeded, [hl]
+ jr nz, .asm_2bee7
+ set Seeded, [hl]
+ callab PlayCurrentMoveAnimation
+ ld hl, WasSeededText ; $7ef2
+ jp PrintText
+.asm_2bee7
+ ld c, $32
+ call DelayFrames
+ ld hl, EvadedAttackText ; $7ef7
+ jp PrintText
+
+WasSeededText: ; 2bef2 (a:7ef2)
+ TX_FAR _WasSeededText
+ db "@"
+
+EvadedAttackText: ; 2bef7 (a:7ef7)
+ TX_FAR _EvadedAttackText
+ db "@"
diff --git a/engine/battle/moveEffects/substitute_effect.asm b/engine/battle/moveEffects/substitute_effect.asm
new file mode 100644
index 00000000..e88def4a
--- /dev/null
+++ b/engine/battle/moveEffects/substitute_effect.asm
@@ -0,0 +1,77 @@
+SubstituteEffect_: ; 17dad (5:7dad)
+ ld c, 50
+ call DelayFrames
+ ld hl, wBattleMonMaxHP
+ ld de, wPlayerSubstituteHP
+ ld bc, W_PLAYERBATTSTATUS2
+ ld a, [H_WHOSETURN]
+ and a
+ jr z, .notEnemy
+ ld hl, wEnemyMonMaxHP
+ ld de, wEnemySubstituteHP
+ ld bc, W_ENEMYBATTSTATUS2
+.notEnemy
+ ld a, [bc] ;load flags
+ bit HasSubstituteUp, a ;user already has substitute?
+ jr nz, .alreadyHasSubstitute ;skip this code if so
+ ;user doesn't have a substitute [yet]
+ push bc
+ ld a, [hli] ;load max hp
+ ld b, [hl]
+ srl a ;max hp / 4, [quarter health to remove from user]
+ rr b
+ srl a
+ rr b
+ push de
+ ld de, wBattleMonHP - wBattleMonMaxHP
+ add hl, de ; point hl to current HP
+ pop de
+ ld a, b
+ ld [de], a ;save copy of HP to subtract in ccd7/ccd8 [how much HP substitute has]
+ ld a, [hld] ;load current hp
+ sub b ;subtract [max hp / 4]
+ ld d, a ;save low byte result in D
+ ld a, [hl]
+ sbc a, 0 ;borrow from high byte if needed
+ pop bc
+ jr c, .notEnoughHP ;underflow means user would be left with negative health
+ ;bug: note since it only brances on carry, it will possibly leave user with 0HP
+.userHasZeroOrMoreHP
+ ldi [hl], a ;store high byte HP
+ ld [hl], d ;store low byte HP
+ ld h, b
+ ld l, c
+ set HasSubstituteUp, [hl] ;set bit 4 of flags, user now has substitute
+ ld a, [W_OPTIONS] ;load options
+ bit 7, a ;battle animation is enabled?
+ ld hl, PlayCurrentMoveAnimation ;animation enabled: 0F:7BA8
+ ld b, BANK(PlayCurrentMoveAnimation)
+ jr z, .animationEnabled
+ ld hl, AnimationSubstitute ;animation disabled: 1E:56E0
+ ld b, BANK(AnimationSubstitute)
+.animationEnabled
+ call Bankswitch ;jump to routine depending on animation setting
+ ld hl, SubstituteText
+ call PrintText
+ ld hl, DrawHUDsAndHPBars
+ ld b, BANK(DrawHUDsAndHPBars)
+ jp Bankswitch
+.alreadyHasSubstitute
+ ld hl, HasSubstituteText
+ jr .printText
+.notEnoughHP
+ ld hl, TooWeakSubstituteText
+.printText
+ jp PrintText
+
+SubstituteText: ; 17e1d (5:7e1d)
+ TX_FAR _SubstituteText
+ db "@"
+
+HasSubstituteText: ; 17e22 (5:7e22)
+ TX_FAR _HasSubstituteText
+ db "@"
+
+TooWeakSubstituteText: ; 17e27 (5:7e27)
+ TX_FAR _TooWeakSubstituteText
+ db "@"