Document DisableEffect and CheckEnemyStatusConditions

basically copy/paste comments and labels from
CheckPlayerStatusConditions
This commit is contained in:
xCrystal 2015-04-09 01:17:56 +02:00
parent b2dc57576d
commit 61edd43974
3 changed files with 91 additions and 75 deletions

View file

@ -847,7 +847,7 @@ FaintEnemyPokemon ; 0x3c567
ld [hli], a ld [hli], a
ld [hl], a ld [hl], a
ld [W_ENEMYDISABLEDMOVE], a ld [W_ENEMYDISABLEDMOVE], a
ld [wccef], a ld [wEnemyDisabledMoveNumber], a
ld [wccf3], a ld [wccf3], a
ld hl, wPlayerUsedMove ld hl, wPlayerUsedMove
ld [hli], a ld [hli], a
@ -1374,7 +1374,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
ld [hli],a ld [hli],a
ld [hl],a ld [hl],a
ld [W_ENEMYDISABLEDMOVE],a ld [W_ENEMYDISABLEDMOVE],a
ld [wccef],a ld [wEnemyDisabledMoveNumber],a
ld [wccf3],a ld [wccf3],a
ld hl,wPlayerUsedMove ld hl,wPlayerUsedMove
ld [hli],a ld [hli],a
@ -1824,7 +1824,7 @@ SendOutMon: ; 3cc91 (f:4c91)
ld [hli], a ld [hli], a
ld [hl], a ld [hl], a
ld [W_PLAYERDISABLEDMOVE], a ld [W_PLAYERDISABLEDMOVE], a
ld [wccee], a ld [wPlayerDisabledMoveNumber], a
ld [wccf7], a ld [wccf7], a
ld b, $1 ld b, $1
call GoPAL_SET call GoPAL_SET
@ -3447,10 +3447,10 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
jr z,.ConfusedCheck jr z,.ConfusedCheck
dec a dec a
ld [hl],a ld [hl],a
and a,$F ; did Disable counter hit 0? and $f ; did Disable counter hit 0?
jr nz,.ConfusedCheck jr nz,.ConfusedCheck
ld [hl],a ld [hl],a
ld [wccee],a ld [wPlayerDisabledMoveNumber],a
ld hl,DisabledNoMoreText ld hl,DisabledNoMoreText
call PrintText call PrintText
@ -3484,7 +3484,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
jr .MonHurtItselfOrFullyParalysed jr .MonHurtItselfOrFullyParalysed
.TriedToUseDisabledMoveCheck .TriedToUseDisabledMoveCheck
ld a,[wccee] ; prevents a disabled move that was selected before being disabled from being used
ld a,[wPlayerDisabledMoveNumber]
and a and a
jr z,.ParalysisCheck jr z,.ParalysisCheck
ld hl,wPlayerSelectedMove ld hl,wPlayerSelectedMove
@ -4112,7 +4113,7 @@ CheckForDisobedience: ; 3dc88 (f:5c88)
ld a, [wBattleMonMoves + 1] ld a, [wBattleMonMoves + 1]
and a ; is the second move slot empty? and a ; is the second move slot empty?
jr z, .monDoesNothing ; mon will not use move if it only knows one move jr z, .monDoesNothing ; mon will not use move if it only knows one move
ld a, [wccee] ld a, [wPlayerDisabledMoveNumber]
and a and a
jr nz, .monDoesNothing jr nz, .monDoesNothing
ld a, [wPlayerSelectedMove] ld a, [wPlayerSelectedMove]
@ -5874,14 +5875,14 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld [wAnimationType], a ld [wAnimationType], a
ld a,SLP_ANIM ld a,SLP_ANIM
call PlayMoveAnimation call PlayMoveAnimation
jr .next1 jr .sleepDone
.wokeUp .wokeUp
ld hl, WokeUpText ld hl, WokeUpText
call PrintText call PrintText
.next1 .sleepDone
xor a xor a
ld [wEnemyUsedMove], a ld [wEnemyUsedMove], a
ld hl, ExecuteEnemyMoveDone ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL jp .enemyReturnToHL
.checkIfFrozen .checkIfFrozen
bit FRZ, [hl] bit FRZ, [hl]
@ -5890,7 +5891,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
call PrintText call PrintText
xor a xor a
ld [wEnemyUsedMove], a ld [wEnemyUsedMove], a
ld hl, ExecuteEnemyMoveDone ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL jp .enemyReturnToHL
.checkIfTrapped .checkIfTrapped
ld a, [W_PLAYERBATTSTATUS1] ld a, [W_PLAYERBATTSTATUS1]
@ -5898,7 +5899,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
jp z, .checkIfFlinched jp z, .checkIfFlinched
ld hl, CantMoveText ld hl, CantMoveText
call PrintText call PrintText
ld hl, ExecuteEnemyMoveDone ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL jp .enemyReturnToHL
.checkIfFlinched .checkIfFlinched
ld hl, W_ENEMYBATTSTATUS1 ld hl, W_ENEMYBATTSTATUS1
@ -5907,7 +5908,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
res Flinched, [hl] res Flinched, [hl]
ld hl, FlinchedText ld hl, FlinchedText
call PrintText call PrintText
ld hl, ExecuteEnemyMoveDone ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL jp .enemyReturnToHL
.checkIfMustRecharge .checkIfMustRecharge
ld hl, W_ENEMYBATTSTATUS2 ld hl, W_ENEMYBATTSTATUS2
@ -5916,19 +5917,19 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
res NeedsToRecharge, [hl] res NeedsToRecharge, [hl]
ld hl, MustRechargeText ld hl, MustRechargeText
call PrintText call PrintText
ld hl, ExecuteEnemyMoveDone ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL jp .enemyReturnToHL
.checkIfAnyMoveDisabled .checkIfAnyMoveDisabled
ld hl, W_ENEMYDISABLEDMOVE ld hl, W_ENEMYDISABLEDMOVE
ld a, [hl] ld a, [hl]
and a and a
jr z, .checkIfConfused jr z, .checkIfConfused
dec a dec a ; decrement disable counter
ld [hl], a ld [hl], a
and $f and $f ; did disable counter hit 0?
jr nz, .checkIfConfused jr nz, .checkIfConfused
ld [hl], a ld [hl], a
ld [wccef], a ld [wEnemyDisabledMoveNumber], a
ld hl, DisabledNoMoreText ld hl, DisabledNoMoreText
call PrintText call PrintText
.checkIfConfused .checkIfConfused
@ -5939,7 +5940,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
dec [hl] dec [hl]
jr nz, .isConfused jr nz, .isConfused
ld hl, W_ENEMYBATTSTATUS1 ld hl, W_ENEMYBATTSTATUS1
res Confused, [hl] res Confused, [hl] ; if confused counter hit 0, reset confusion status
ld hl, ConfusedNoMoreText ld hl, ConfusedNoMoreText
call PrintText call PrintText
jp .checkIfTriedToUseDisabledMove jp .checkIfTriedToUseDisabledMove
@ -5955,7 +5956,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
jr c, .checkIfTriedToUseDisabledMove jr c, .checkIfTriedToUseDisabledMove
ld hl, W_ENEMYBATTSTATUS1 ld hl, W_ENEMYBATTSTATUS1
ld a, [hl] ld a, [hl]
and 1 << Confused and 1 << Confused ; if mon hurts itself, clear every other status from W_ENEMYBATTSTATUS1
ld [hl], a ld [hl], a
ld hl, HurtItselfText ld hl, HurtItselfText
call PrintText call PrintText
@ -5999,21 +6000,22 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
call ApplyDamageToEnemyPokemon call ApplyDamageToEnemyPokemon
jr .monHurtItselfOrFullyParalysed jr .monHurtItselfOrFullyParalysed
.checkIfTriedToUseDisabledMove .checkIfTriedToUseDisabledMove
ld a, [wccef] ; prevents a disabled move that was selected before being disabled from being used
ld a, [wEnemyDisabledMoveNumber]
and a and a
jr z, .checkIfParalysed jr z, .checkIfParalysed
ld hl, wEnemySelectedMove ld hl, wEnemySelectedMove
cp [hl] cp [hl]
jr nz, .checkIfParalysed jr nz, .checkIfParalysed
call PrintMoveIsDisabledText call PrintMoveIsDisabledText
ld hl, ExecuteEnemyMoveDone ld hl, ExecuteEnemyMoveDone ; if a disabled move was somehow selected, player can't move this turn
jp .enemyReturnToHL jp .enemyReturnToHL
.checkIfParalysed .checkIfParalysed
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
bit PAR, [hl] bit PAR, [hl]
jr z, .checkIfUsingBide jr z, .checkIfUsingBide
call BattleRandom call BattleRandom
cp $3f cp $3f ; 25% to be fully paralysed
jr nc, .checkIfUsingBide jr nc, .checkIfUsingBide
ld hl, FullyParalyzedText ld hl, FullyParalyzedText
call PrintText call PrintText
@ -6036,7 +6038,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
call PlayMoveAnimation call PlayMoveAnimation
.notFlyOrChargeEffect .notFlyOrChargeEffect
ld hl, ExecuteEnemyMoveDone ld hl, ExecuteEnemyMoveDone
jp .enemyReturnToHL jp .enemyReturnToHL ; if using a two-turn move, enemy needs to recharge the first turn
.checkIfUsingBide .checkIfUsingBide
ld hl, W_ENEMYBATTSTATUS1 ld hl, W_ENEMYBATTSTATUS1
bit StoringEnergy, [hl] ; is mon using bide? bit StoringEnergy, [hl] ; is mon using bide?
@ -6049,16 +6051,16 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld c, [hl] ld c, [hl]
ld hl, wEnemyBideAccumulatedDamage + 1 ld hl, wEnemyBideAccumulatedDamage + 1
ld a, [hl] ld a, [hl]
add c add c ; accumulate damage taken
ld [hld], a ld [hld], a
ld a, [hl] ld a, [hl]
adc b adc b
ld [hl], a ld [hl], a
ld hl, wEnemyNumAttacksLeft ld hl, wEnemyNumAttacksLeft
dec [hl] dec [hl] ; did Bide counter hit 0?
jr z, .unleashEnergy jr z, .unleashEnergy
ld hl, ExecuteEnemyMoveDone ld hl, ExecuteEnemyMoveDone
jp .enemyReturnToHL jp .enemyReturnToHL ; unless mon unleashes energy, can't move this turn
.unleashEnergy .unleashEnergy
ld hl, W_ENEMYBATTSTATUS1 ld hl, W_ENEMYBATTSTATUS1
res StoringEnergy, [hl] ; not using bide any more res StoringEnergy, [hl] ; not using bide any more
@ -6072,20 +6074,20 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld b, a ld b, a
ld [W_DAMAGE + 1], a ld [W_DAMAGE + 1], a
ld a, [hl] ld a, [hl]
rl a rl a ; double the damage
ld [W_DAMAGE], a ld [W_DAMAGE], a
or b or b
jr nz, .next2 jr nz, .next
ld a, $1 ld a, $1
ld [W_MOVEMISSED], a ld [W_MOVEMISSED], a
.next2 .next
xor a xor a
ld [hli], a ld [hli], a
ld [hl], a ld [hl], a
ld a, BIDE ld a, BIDE
ld [W_ENEMYMOVENUM], a ld [W_ENEMYMOVENUM], a
call SwapPlayerAndEnemyLevels call SwapPlayerAndEnemyLevels
ld hl, handleIfEnemyMoveMissed ld hl, handleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .enemyReturnToHL jp .enemyReturnToHL
.checkIfThrashingAbout .checkIfThrashingAbout
bit ThrashingAbout, [hl] ; is mon using thrash or petal dance? bit ThrashingAbout, [hl] ; is mon using thrash or petal dance?
@ -6095,8 +6097,8 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, ThrashingAboutText ld hl, ThrashingAboutText
call PrintText call PrintText
ld hl, wEnemyNumAttacksLeft ld hl, wEnemyNumAttacksLeft
dec [hl] dec [hl] ; did Trashing About counter hit 0?
ld hl, EnemyCalcMoveDamage ld hl, EnemyCalcMoveDamage ; skip DecrementPP
jp nz, .enemyReturnToHL jp nz, .enemyReturnToHL
push hl push hl
ld hl, W_ENEMYBATTSTATUS1 ld hl, W_ENEMYBATTSTATUS1
@ -6105,9 +6107,9 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
call BattleRandom call BattleRandom
and $3 and $3
inc a inc a
inc a inc a ; confused for 2-5 turns
ld [W_ENEMYCONFUSEDCOUNTER], a ld [W_ENEMYCONFUSEDCOUNTER], a
pop hl pop hl ; skip DecrementPP
jp .enemyReturnToHL jp .enemyReturnToHL
.checkIfUsingMultiturnMove .checkIfUsingMultiturnMove
bit UsingTrappingMove, [hl] ; is mon using multi-turn move? bit UsingTrappingMove, [hl] ; is mon using multi-turn move?
@ -6115,14 +6117,15 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, AttackContinuesText ld hl, AttackContinuesText
call PrintText call PrintText
ld hl, wEnemyNumAttacksLeft ld hl, wEnemyNumAttacksLeft
dec [hl] dec [hl] ; did multi-turn move end?
ld hl, GetEnemyAnimationType ld hl, GetEnemyAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
; DecrementPP and MoveHitTest
jp nz, .enemyReturnToHL jp nz, .enemyReturnToHL
jp .enemyReturnToHL jp .enemyReturnToHL
.checkIfUsingRage .checkIfUsingRage
ld a, [W_ENEMYBATTSTATUS2] ld a, [W_ENEMYBATTSTATUS2]
bit UsingRage, a ; is mon using rage? bit UsingRage, a ; is mon using rage?
jp z, .checkEnemyStatusConditionsDone jp z, .checkEnemyStatusConditionsDone ; if we made it this far, mon can move normally this turn
ld a, RAGE ld a, RAGE
ld [wd11e], a ld [wd11e], a
call GetMoveName call GetMoveName
@ -8494,19 +8497,20 @@ DisableEffect: ; 3fa8a (f:7a8a)
call MoveHitTest call MoveHitTest
ld a, [W_MOVEMISSED] ld a, [W_MOVEMISSED]
and a and a
jr nz, .asm_3fb06 jr nz, .moveMissed
ld de, W_ENEMYDISABLEDMOVE ld de, W_ENEMYDISABLEDMOVE
ld hl, wEnemyMonMoves ld hl, wEnemyMonMoves
ld a, [H_WHOSETURN] ld a, [H_WHOSETURN]
and a and a
jr z, .asm_3faa4 jr z, .disableEffect
ld de, W_PLAYERDISABLEDMOVE ld de, W_PLAYERDISABLEDMOVE
ld hl, wBattleMonMoves ld hl, wBattleMonMoves
.asm_3faa4 .disableEffect
; no effect if target already has a move disabled
ld a, [de] ld a, [de]
and a and a
jr nz, .asm_3fb06 jr nz, .moveMissed
.asm_3faa8 .pickMoveToDisable
push hl push hl
call BattleRandom call BattleRandom
and $3 and $3
@ -8516,20 +8520,21 @@ DisableEffect: ; 3fa8a (f:7a8a)
ld a, [hl] ld a, [hl]
pop hl pop hl
and a and a
jr z, .asm_3faa8 jr z, .pickMoveToDisable ; loop until a non-00 move slot is found
ld [wd11e], a ld [wd11e], a ; store move number
push hl push hl
ld a, [H_WHOSETURN] ld a, [H_WHOSETURN]
and a and a
ld hl, wBattleMonPP ld hl, wBattleMonPP
jr nz, .asm_3facf jr nz, .enemyTurn
ld a, [wLinkState] ld a, [wLinkState]
cp LINK_STATE_BATTLING cp LINK_STATE_BATTLING
pop hl pop hl ; wEnemyMonMoves
jr nz, .asm_3fae1 jr nz, .playerTurnNotLinkBattle
; .playerTurnLinkBattle
push hl push hl
ld hl, wEnemyMonPP ld hl, wEnemyMonPP
.asm_3facf .enemyTurn
push hl push hl
ld a, [hli] ld a, [hli]
or [hl] or [hl]
@ -8538,36 +8543,37 @@ DisableEffect: ; 3fa8a (f:7a8a)
inc hl inc hl
or [hl] or [hl]
and $3f and $3f
pop hl pop hl ; wBattleMonPP or wEnemyMonPP
jr z, .asm_3fb05 jr z, .moveMissedPopHL ; nothing to do if all moves have no PP left
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
pop hl pop hl
and a and a
jr z, .asm_3faa8 jr z, .pickMoveToDisable ; pick another move if this one had 0 PP
.asm_3fae1 .playerTurnNotLinkBattle
; non-link battle enemies have unlimited PP so the previous checks aren't needed
call BattleRandom call BattleRandom
and $7 and $7
inc a inc a ; 1-8 turns disabled
inc c inc c ; move 1-4 will be disabled
swap c swap c
add c add c ; map disabled move to high nibble of W_ENEMYDISABLEDMOVE / W_PLAYERDISABLEDMOVE
ld [de], a ld [de], a
call PlayCurrentMoveAnimation2 call PlayCurrentMoveAnimation2
ld hl, wccee ld hl, wPlayerDisabledMoveNumber
ld a, [H_WHOSETURN] ld a, [H_WHOSETURN]
and a and a
jr nz, .asm_3faf8 jr nz, .printDisableText
inc hl inc hl ; wEnemyDisabledMoveNumber
.asm_3faf8 .printDisableText
ld a, [wd11e] ld a, [wd11e] ; move number
ld [hl], a ld [hl], a
call GetMoveName call GetMoveName
ld hl, MoveWasDisabledText ld hl, MoveWasDisabledText
jp PrintText jp PrintText
.asm_3fb05 .moveMissedPopHL
pop hl pop hl
.asm_3fb06 .moveMissed
jp PrintButItFailedText_ jp PrintButItFailedText_
MoveWasDisabledText: ; 3fb09 (f:7b09) MoveWasDisabledText: ; 3fb09 (f:7b09)

View file

@ -33,7 +33,7 @@ HazeEffect_: ; 139da (4:79da)
xor a xor a
ld [W_PLAYERDISABLEDMOVE], a ld [W_PLAYERDISABLEDMOVE], a
ld [W_ENEMYDISABLEDMOVE], a ld [W_ENEMYDISABLEDMOVE], a
ld hl, wccee ld hl, wPlayerDisabledMoveNumber
ld [hli], a ld [hli], a
ld [hl], a ld [hl], a
ld hl, W_PLAYERBATTSTATUS1 ld hl, W_PLAYERBATTSTATUS1

View file

@ -432,16 +432,22 @@ wSafariBaitFactor:: ; cce9
wcceb:: ds 1 wcceb:: ds 1
wccec:: ds 1 wccec:: ds 1
wMonIsDisobedient:: ds 1
wccee:: ds 1
wccef:: ds 1
wccf0:: ds 1
wPlayerUsedMove:: ds 1
wEnemyUsedMove:: ds 1
wccf3:: ds 1
wMoveDidntMiss:: ds 1
wPartyFoughtCurrentEnemyFlags:: wMonIsDisobedient:: ds 1 ; cced
wPlayerDisabledMoveNumber:: ds 1 ; ccee
wEnemyDisabledMoveNumber:: ds 1 ; ccef
wccf0:: ds 1
wPlayerUsedMove:: ds 1 ; ccf1
wEnemyUsedMove:: ds 1 ; ccf2
wccf3:: ds 1
wMoveDidntMiss:: ds 1 ; ccf4
wPartyFoughtCurrentEnemyFlags:: ; ccf5
; flags that indicate which party members have fought the current enemy mon ; flags that indicate which party members have fought the current enemy mon
flag_array 6 flag_array 6
@ -1066,11 +1072,13 @@ W_PLAYERCONFUSEDCOUNTER:: ; wd06b
W_PLAYERTOXICCOUNTER:: ; d06c W_PLAYERTOXICCOUNTER:: ; d06c
ds 1 ds 1
W_PLAYERDISABLEDMOVE:: ; d06d W_PLAYERDISABLEDMOVE:: ; d06d
; high nibble: which move is disabled (1-4)
; low nibble: disable turns left
ds 1 ds 1
ds 1 ds 1
wEnemyNumAttacksLeft:: wEnemyNumAttacksLeft:: ; d06f
; when the enemy is attacking multiple times, the number of attacks left ; when the enemy is attacking multiple times, the number of attacks left
ds 1 ds 1
@ -1080,6 +1088,8 @@ W_ENEMYCONFUSEDCOUNTER:: ; wd070
W_ENEMYTOXICCOUNTER:: ; d071 W_ENEMYTOXICCOUNTER:: ; d071
ds 1 ds 1
W_ENEMYDISABLEDMOVE:: ; d072 W_ENEMYDISABLEDMOVE:: ; d072
; high nibble: which move is disabled (1-4)
; low nibble: disable turns left
ds 1 ds 1
ds 1 ds 1