summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2013-09-09 21:51:41 -0400
committeryenatch <yenatch@gmail.com>2013-09-09 21:51:41 -0400
commit40010e2514bffb35e9895f5cb1185296f9020c02 (patch)
tree34839c56c6152f37d4354fba57d0b0df1da32065
parentaaf77957bf6e2a149827461a3126fea0a85102c9 (diff)
split protect and endure effects into battle/effects/
-rw-r--r--battle/effect_commands.asm99
-rw-r--r--battle/effects/endure.asm16
-rw-r--r--battle/effects/protect.asm81
3 files changed, 99 insertions, 97 deletions
diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm
index 1ae8976ae..996634376 100644
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -9544,104 +9544,9 @@ BattleCommand53: ; 37563
INCLUDE "battle/effects/curse.asm"
+INCLUDE "battle/effects/protect.asm"
-BattleCommand55: ; 37618
-; protect
- call ProtectChance
- ret c
-
- ld a, BATTLE_VARS_SUBSTATUS1
- call GetBattleVarPair
- set SUBSTATUS_PROTECT, [hl]
-
- call Function0x37e01
-
- ld hl, ProtectedItselfText
- jp StdBattleTextBox
-; 3762c
-
-
-ProtectChance: ; 3762c
-
- ld de, PlayerProtectCount
- ld a, [hBattleTurn]
- and a
- jr z, .asm_37637
- ld de, EnemyProtectCount
-.asm_37637
-
- call Function0x36abf
- jr nz, .failed
-
-; Can't have a substitute.
-
- ld a, BATTLE_VARS_SUBSTATUS4
- call CleanGetBattleVarPair
- bit SUBSTATUS_SUBSTITUTE, a
- jr nz, .failed
-
-; Halve the chance of a successful Protect for each consecutive use.
-
- ld b, $ff
- ld a, [de]
- ld c, a
-.loop
- ld a, c
- and a
- jr z, .done
- dec c
-
- srl b
- ld a, b
- and a
- jr nz, .loop
- jr .failed
-.done
-
-.rand
- call BattleRandom
- and a
- jr z, .rand
-
- dec a
- cp b
- jr nc, .failed
-
-; Another consecutive Protect use.
-
- ld a, [de]
- inc a
- ld [de], a
-
- and a
- ret
-
-
-.failed
- xor a
- ld [de], a
- call Function0x37e77
- call PrintButItFailed
- scf
- ret
-; 3766f
-
-
-BattleCommand5a: ; 3766f
-; endure
-
- call ProtectChance
- ret c
-
- ld a, BATTLE_VARS_SUBSTATUS1
- call GetBattleVarPair
- set SUBSTATUS_ENDURE, [hl]
-
- call Function0x37e01
-
- ld hl, BracedItselfText
- jp StdBattleTextBox
-; 37683
+INCLUDE "battle/effects/endure.asm"
BattleCommand56: ; 37683
diff --git a/battle/effects/endure.asm b/battle/effects/endure.asm
new file mode 100644
index 000000000..b6ae9358e
--- /dev/null
+++ b/battle/effects/endure.asm
@@ -0,0 +1,16 @@
+BattleCommand5a: ; 3766f
+; endure
+
+ call ProtectChance
+ ret c
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVarPair
+ set SUBSTATUS_ENDURE, [hl]
+
+ call Function0x37e01
+
+ ld hl, BracedItselfText
+ jp StdBattleTextBox
+; 37683
+
diff --git a/battle/effects/protect.asm b/battle/effects/protect.asm
new file mode 100644
index 000000000..80edc0d85
--- /dev/null
+++ b/battle/effects/protect.asm
@@ -0,0 +1,81 @@
+BattleCommand55: ; 37618
+; protect
+ call ProtectChance
+ ret c
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVarPair
+ set SUBSTATUS_PROTECT, [hl]
+
+ call Function0x37e01
+
+ ld hl, ProtectedItselfText
+ jp StdBattleTextBox
+; 3762c
+
+
+ProtectChance: ; 3762c
+
+ ld de, PlayerProtectCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .asm_37637
+ ld de, EnemyProtectCount
+.asm_37637
+
+ call Function0x36abf
+ jr nz, .failed
+
+; Can't have a substitute.
+
+ ld a, BATTLE_VARS_SUBSTATUS4
+ call CleanGetBattleVarPair
+ bit SUBSTATUS_SUBSTITUTE, a
+ jr nz, .failed
+
+; Halve the chance of a successful Protect for each consecutive use.
+
+ ld b, $ff
+ ld a, [de]
+ ld c, a
+.loop
+ ld a, c
+ and a
+ jr z, .done
+ dec c
+
+ srl b
+ ld a, b
+ and a
+ jr nz, .loop
+ jr .failed
+.done
+
+.rand
+ call BattleRandom
+ and a
+ jr z, .rand
+
+ dec a
+ cp b
+ jr nc, .failed
+
+; Another consecutive Protect use.
+
+ ld a, [de]
+ inc a
+ ld [de], a
+
+ and a
+ ret
+
+
+.failed
+ xor a
+ ld [de], a
+ call Function0x37e77
+ call PrintButItFailed
+ scf
+ ret
+; 3766f
+