summaryrefslogtreecommitdiff
path: root/battle/effect_commands.asm
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2013-09-09 21:50:34 -0400
committeryenatch <yenatch@gmail.com>2013-09-09 21:50:34 -0400
commitaaf77957bf6e2a149827461a3126fea0a85102c9 (patch)
tree1ace77ef3ed3de0687a520cd02b2ccacdaccfb29 /battle/effect_commands.asm
parentd07cd794431090033b62b8438530a99e1f52bfad (diff)
comment protect and endure move effects
Diffstat (limited to 'battle/effect_commands.asm')
-rw-r--r--battle/effect_commands.asm57
1 files changed, 35 insertions, 22 deletions
diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm
index a7dda2bf4..1ae8976ae 100644
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -9547,66 +9547,77 @@ INCLUDE "battle/effects/curse.asm"
BattleCommand55: ; 37618
; protect
-
- call Function0x3762c
+ call ProtectChance
ret c
+
ld a, BATTLE_VARS_SUBSTATUS1
call GetBattleVarPair
- set 2, [hl]
+ set SUBSTATUS_PROTECT, [hl]
+
call Function0x37e01
+
ld hl, ProtectedItselfText
jp StdBattleTextBox
; 3762c
-Function0x3762c: ; 3762c
- ld de, $c679
+ProtectChance: ; 3762c
+
+ ld de, PlayerProtectCount
ld a, [hBattleTurn]
and a
jr z, .asm_37637
- ld de, $c681
-
+ ld de, EnemyProtectCount
.asm_37637
+
call Function0x36abf
- jr nz, .asm_37665
+ jr nz, .failed
- ld a, $3
+; Can't have a substitute.
+
+ ld a, BATTLE_VARS_SUBSTATUS4
call CleanGetBattleVarPair
- bit 4, a
- jr nz, .asm_37665
+ 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
-.asm_37649
+.loop
ld a, c
and a
- jr z, .asm_37656
-
+ jr z, .done
dec c
+
srl b
ld a, b
and a
- jr nz, .asm_37649
-
- jr .asm_37665
+ jr nz, .loop
+ jr .failed
+.done
-.asm_37656
+.rand
call BattleRandom
and a
- jr z, .asm_37656
+ jr z, .rand
dec a
cp b
- jr nc, .asm_37665
+ jr nc, .failed
+
+; Another consecutive Protect use.
ld a, [de]
inc a
ld [de], a
+
and a
ret
-.asm_37665
+
+.failed
xor a
ld [de], a
call Function0x37e77
@@ -9619,13 +9630,15 @@ Function0x3762c: ; 3762c
BattleCommand5a: ; 3766f
; endure
- call Function0x3762c
+ call ProtectChance
ret c
ld a, BATTLE_VARS_SUBSTATUS1
call GetBattleVarPair
set SUBSTATUS_ENDURE, [hl]
+
call Function0x37e01
+
ld hl, BracedItselfText
jp StdBattleTextBox
; 37683