comment protect and endure move effects

This commit is contained in:
yenatch
2013-09-09 21:50:34 -04:00
parent d07cd79443
commit aaf77957bf

View File

@@ -9547,66 +9547,77 @@ INCLUDE "battle/effects/curse.asm"
BattleCommand55: ; 37618 BattleCommand55: ; 37618
; protect ; protect
call ProtectChance
call Function0x3762c
ret c ret c
ld a, BATTLE_VARS_SUBSTATUS1 ld a, BATTLE_VARS_SUBSTATUS1
call GetBattleVarPair call GetBattleVarPair
set 2, [hl] set SUBSTATUS_PROTECT, [hl]
call Function0x37e01 call Function0x37e01
ld hl, ProtectedItselfText ld hl, ProtectedItselfText
jp StdBattleTextBox jp StdBattleTextBox
; 3762c ; 3762c
Function0x3762c: ; 3762c ProtectChance: ; 3762c
ld de, $c679
ld de, PlayerProtectCount
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_37637 jr z, .asm_37637
ld de, $c681 ld de, EnemyProtectCount
.asm_37637 .asm_37637
call Function0x36abf
jr nz, .asm_37665
ld a, $3 call Function0x36abf
jr nz, .failed
; Can't have a substitute.
ld a, BATTLE_VARS_SUBSTATUS4
call CleanGetBattleVarPair call CleanGetBattleVarPair
bit 4, a bit SUBSTATUS_SUBSTITUTE, a
jr nz, .asm_37665 jr nz, .failed
; Halve the chance of a successful Protect for each consecutive use.
ld b, $ff ld b, $ff
ld a, [de] ld a, [de]
ld c, a ld c, a
.asm_37649 .loop
ld a, c ld a, c
and a and a
jr z, .asm_37656 jr z, .done
dec c dec c
srl b srl b
ld a, b ld a, b
and a and a
jr nz, .asm_37649 jr nz, .loop
jr .failed
.done
jr .asm_37665 .rand
.asm_37656
call BattleRandom call BattleRandom
and a and a
jr z, .asm_37656 jr z, .rand
dec a dec a
cp b cp b
jr nc, .asm_37665 jr nc, .failed
; Another consecutive Protect use.
ld a, [de] ld a, [de]
inc a inc a
ld [de], a ld [de], a
and a and a
ret ret
.asm_37665
.failed
xor a xor a
ld [de], a ld [de], a
call Function0x37e77 call Function0x37e77
@@ -9619,13 +9630,15 @@ Function0x3762c: ; 3762c
BattleCommand5a: ; 3766f BattleCommand5a: ; 3766f
; endure ; endure
call Function0x3762c call ProtectChance
ret c ret c
ld a, BATTLE_VARS_SUBSTATUS1 ld a, BATTLE_VARS_SUBSTATUS1
call GetBattleVarPair call GetBattleVarPair
set SUBSTATUS_ENDURE, [hl] set SUBSTATUS_ENDURE, [hl]
call Function0x37e01 call Function0x37e01
ld hl, BracedItselfText ld hl, BracedItselfText
jp StdBattleTextBox jp StdBattleTextBox
; 37683 ; 37683