You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-09-08 08:13:02 -07:00
Merge pull request #505 from mid-kid/battlecommands
Battle command fixes
This commit is contained in:
@@ -14,10 +14,10 @@ BattleCommandPointers: ; 3fd28
|
|||||||
dw BattleCommand_DamageVariation ; 34cfd
|
dw BattleCommand_DamageVariation ; 34cfd
|
||||||
dw BattleCommand_CheckHit ; 34d32
|
dw BattleCommand_CheckHit ; 34d32
|
||||||
dw BattleCommand_LowerSub ; 34eee
|
dw BattleCommand_LowerSub ; 34eee
|
||||||
dw BattleCommand_HitTargetNoSub ; 34f60
|
dw BattleCommand_MoveAnimNoSub ; 34f60
|
||||||
dw BattleCommand_RaiseSub ; 35004
|
dw BattleCommand_RaiseSub ; 35004
|
||||||
dw BattleCommand_FailureText ; 35023
|
dw BattleCommand_FailureText ; 35023
|
||||||
dw BattleCommand_CheckFaint ; 3505e
|
dw BattleCommand_ApplyDamage ; 3505e
|
||||||
dw BattleCommand_CriticalText ; 35175
|
dw BattleCommand_CriticalText ; 35175
|
||||||
dw BattleCommand_SuperEffectiveText ; 351ad
|
dw BattleCommand_SuperEffectiveText ; 351ad
|
||||||
dw BattleCommand_CheckDestinyBond ; 351c0
|
dw BattleCommand_CheckDestinyBond ; 351c0
|
||||||
@@ -168,13 +168,13 @@ BattleCommandPointers: ; 3fd28
|
|||||||
dw BattleCommand_RageDamage ; 3527b
|
dw BattleCommand_RageDamage ; 3527b
|
||||||
dw BattleCommand_ResetTypeMatchup ; 34833
|
dw BattleCommand_ResetTypeMatchup ; 34833
|
||||||
dw BattleCommand_AllStatsUp ; 36500
|
dw BattleCommand_AllStatsUp ; 36500
|
||||||
dw BattleCommanda5 ; 35165
|
dw BattleCommand_BideFailText ; 35165
|
||||||
dw BattleCommand_RaiseSubNoAnim ; 365af
|
dw BattleCommand_RaiseSubNoAnim ; 365af
|
||||||
dw BattleCommand_LowerSubNoAnim ; 365c3
|
dw BattleCommand_LowerSubNoAnim ; 365c3
|
||||||
dw BattleCommanda8 ; 355b5
|
dw BattleCommand_BeatUpFailText ; 355b5
|
||||||
dw BattleCommand_ClearMissDamage ; 355d5 - a9
|
dw BattleCommand_ClearMissDamage ; 355d5 - a9
|
||||||
dw BattleCommand_MoveDelay ; 37e80
|
dw BattleCommand_MoveDelay ; 37e80
|
||||||
dw BattleCommand_HitTarget ; 34f57
|
dw BattleCommand_MoveAnim ; 34f57
|
||||||
dw BattleCommand_TriStatusChance ; 3658f
|
dw BattleCommand_TriStatusChance ; 3658f
|
||||||
dw BattleCommand_SuperEffectiveLoopText ; 351a5
|
dw BattleCommand_SuperEffectiveLoopText ; 351a5
|
||||||
dw BattleCommand_StartLoop ; 35197
|
dw BattleCommand_StartLoop ; 35197
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,8 @@ These are known bugs and glitches in the original Pokémon Crystal game: code th
|
|||||||
- [A Pokémon that fainted from Pursuit will have its old status condition when revived](#a-pokémon-that-fainted-from-pursuit-will-have-its-old-status-condition-when-revived)
|
- [A Pokémon that fainted from Pursuit will have its old status condition when revived](#a-pokémon-that-fainted-from-pursuit-will-have-its-old-status-condition-when-revived)
|
||||||
- [Lock-On and Mind Reader don't always bypass Fly and Dig](#lock-on-and-mind-reader-dont-always-bypass-fly-and-dig)
|
- [Lock-On and Mind Reader don't always bypass Fly and Dig](#lock-on-and-mind-reader-dont-always-bypass-fly-and-dig)
|
||||||
- [Beat Up can desynchronize link battles](#beat-up-can-desynchronize-link-battles)
|
- [Beat Up can desynchronize link battles](#beat-up-can-desynchronize-link-battles)
|
||||||
|
- [Beat Up may fail to raise substitute](#beat-up-may-fail-to-raise-substitute)
|
||||||
|
- [Beat Up may trigger King's Rock even if it failed](#beat-up-may-trigger-kings-rock-even-if-it-failed)
|
||||||
- [Present damage is incorrect in link battles](#present-damage-is-incorrect-in-link-battles)
|
- [Present damage is incorrect in link battles](#present-damage-is-incorrect-in-link-battles)
|
||||||
- ["Smart" AI encourages Mean Look if its own Pokémon is badly poisoned](#smart-ai-encourages-mean-look-if-its-own-pokémon-is-badly-poisoned)
|
- ["Smart" AI encourages Mean Look if its own Pokémon is badly poisoned](#smart-ai-encourages-mean-look-if-its-own-pokémon-is-badly-poisoned)
|
||||||
- [AI makes a false assumption about `CheckTypeMatchup`](#ai-makes-a-false-assumption-about-checktypematchup)
|
- [AI makes a false assumption about `CheckTypeMatchup`](#ai-makes-a-false-assumption-about-checktypematchup)
|
||||||
@@ -339,6 +341,82 @@ This is a bug with `BattleCommand_BeatUp` in [engine/battle/move_effects/beat_up
|
|||||||
**Fix:** Change `cp [hl]` to `cp c`.
|
**Fix:** Change `cp [hl]` to `cp c`.
|
||||||
|
|
||||||
|
|
||||||
|
## Beat Up may fail to raise substitute
|
||||||
|
|
||||||
|
*Fixing this bug will break compatibility with standard Pokémon Crystal for link battles.*
|
||||||
|
(Only the fixes denoted with "breaking" will actually break compatibility, the others just affect what's shown on the screen with the patched game)
|
||||||
|
|
||||||
|
This is a bug in `BattleCommand_EndLoop` in [engine/battle/effect_commands.asm](/engine/battle/effect_commands.asm) that prevents the rest of the move's effect from being executed if the player or enemy only has one mon in their party while using Beat Up.
|
||||||
|
|
||||||
|
It prevents the substitute from being raised and the King's Rock from working.
|
||||||
|
|
||||||
|
```asm
|
||||||
|
.only_one_beatup
|
||||||
|
ld a, BATTLE_VARS_SUBSTATUS3
|
||||||
|
call GetBattleVarAddr
|
||||||
|
res SUBSTATUS_IN_LOOP, [hl]
|
||||||
|
call BattleCommand_BeatUpFailText
|
||||||
|
jp EndMoveEffect
|
||||||
|
```
|
||||||
|
|
||||||
|
**Fix (breaking):** Replace the last two lines with `ret`.
|
||||||
|
**Fix (cosmetics):** Call `BattleCommand_RaiseSub` before the `jp`.
|
||||||
|
|
||||||
|
There's a similar oversight in `BattleCommand_FailureText` in [engine/battle/effect_commands.asm](/engine/battle/effect_commands.asm) that will prevent the substitute from being raised if Beat Up is protected against.
|
||||||
|
|
||||||
|
```asm
|
||||||
|
cp EFFECT_MULTI_HIT
|
||||||
|
jr z, .multihit
|
||||||
|
cp EFFECT_DOUBLE_HIT
|
||||||
|
jr z, .multihit
|
||||||
|
cp EFFECT_POISON_MULTI_HIT
|
||||||
|
jr z, .multihit
|
||||||
|
jp EndMoveEffect
|
||||||
|
|
||||||
|
.multihit
|
||||||
|
call BattleCommand_RaiseSub
|
||||||
|
jp EndMoveEffect
|
||||||
|
```
|
||||||
|
|
||||||
|
**Fix:** Check for `EFFECT_BEAT_UP` as well.
|
||||||
|
|
||||||
|
|
||||||
|
## Beat Up may trigger King's Rock even if it failed
|
||||||
|
|
||||||
|
*Fixing this bug will break compatibility with standard Pokémon Crystal for link battles.*
|
||||||
|
|
||||||
|
This is a bug in how `wAttackMissed` is never set by BeatUp, even when none of the 'mon have been able to attack (due to being fainted or having a status effect), the King's Rock may activate.
|
||||||
|
|
||||||
|
This bug can be fixed in a plethora of ways, but the most straight-forward would be in `BattleCommand_BeatUpFailText` in [engine/battle/move_effects/beat_up.asm](/engine/battle/move_effects/beat_up.asm), as that's always ran before the king's rock effect.
|
||||||
|
|
||||||
|
```asm
|
||||||
|
BattleCommand_BeatUpFailText: ; 355b5
|
||||||
|
; beatupfailtext
|
||||||
|
|
||||||
|
ld a, [wBeatUpHitAtLeastOnce]
|
||||||
|
and a
|
||||||
|
ret nz
|
||||||
|
|
||||||
|
jp PrintButItFailed
|
||||||
|
```
|
||||||
|
|
||||||
|
**Fix:**
|
||||||
|
|
||||||
|
```asm
|
||||||
|
BattleCommand_BeatUpFailText: ; 355b5
|
||||||
|
; beatupfailtext
|
||||||
|
|
||||||
|
ld a, [wBeatUpHitAtLeastOnce]
|
||||||
|
and a
|
||||||
|
ret nz
|
||||||
|
|
||||||
|
inc a
|
||||||
|
ld [wAttackMissed], a
|
||||||
|
|
||||||
|
jp PrintButItFailed
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Present damage is incorrect in link battles
|
## Present damage is incorrect in link battles
|
||||||
|
|
||||||
*Fixing this bug will break compatibility with standard Pokémon Crystal for link battles.*
|
*Fixing this bug will break compatibility with standard Pokémon Crystal for link battles.*
|
||||||
|
@@ -556,8 +556,8 @@ CheckEnemyTurn: ; 3421f
|
|||||||
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
||||||
call z, PlayFXAnimID
|
call z, PlayFXAnimID
|
||||||
|
|
||||||
ld c, $1
|
ld c, TRUE
|
||||||
call EnemyHurtItself
|
call DoEnemyDamage
|
||||||
call BattleCommand_RaiseSub
|
call BattleCommand_RaiseSub
|
||||||
call CantMove
|
call CantMove
|
||||||
jp EndTurn
|
jp EndTurn
|
||||||
@@ -676,8 +676,8 @@ HitConfusion: ; 343a5
|
|||||||
call CallBattleCore
|
call CallBattleCore
|
||||||
ld a, $1
|
ld a, $1
|
||||||
ld [hBGMapMode], a
|
ld [hBGMapMode], a
|
||||||
ld c, $1
|
ld c, TRUE
|
||||||
call PlayerHurtItself
|
call DoPlayerDamage
|
||||||
jp BattleCommand_RaiseSub
|
jp BattleCommand_RaiseSub
|
||||||
|
|
||||||
; 343db
|
; 343db
|
||||||
@@ -2081,16 +2081,16 @@ BattleCommand_LowerSub: ; 34eee
|
|||||||
; 34f57
|
; 34f57
|
||||||
|
|
||||||
|
|
||||||
BattleCommand_HitTarget: ; 34f57
|
BattleCommand_MoveAnim: ; 34f57
|
||||||
; hittarget
|
; moveanim
|
||||||
call BattleCommand_LowerSub
|
call BattleCommand_LowerSub
|
||||||
call BattleCommand_HitTargetNoSub
|
call BattleCommand_MoveAnimNoSub
|
||||||
jp BattleCommand_RaiseSub
|
jp BattleCommand_RaiseSub
|
||||||
|
|
||||||
; 34f60
|
; 34f60
|
||||||
|
|
||||||
|
|
||||||
BattleCommand_HitTargetNoSub: ; 34f60
|
BattleCommand_MoveAnimNoSub: ; 34f60
|
||||||
ld a, [wAttackMissed]
|
ld a, [wAttackMissed]
|
||||||
and a
|
and a
|
||||||
jp nz, BattleCommand_MoveDelay
|
jp nz, BattleCommand_MoveDelay
|
||||||
@@ -2274,65 +2274,68 @@ BattleCommand_FailureText: ; 35023
|
|||||||
; 3505e
|
; 3505e
|
||||||
|
|
||||||
|
|
||||||
BattleCommand_CheckFaint: ; 3505e
|
BattleCommand_ApplyDamage: ; 3505e
|
||||||
; checkfaint
|
; applydamage
|
||||||
|
|
||||||
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
||||||
call GetBattleVar
|
call GetBattleVar
|
||||||
bit SUBSTATUS_ENDURE, a
|
bit SUBSTATUS_ENDURE, a
|
||||||
jr z, .not_enduring
|
jr z, .focus_band
|
||||||
call BattleCommand_FalseSwipe
|
|
||||||
ld b, $0
|
|
||||||
jr nc, .okay
|
|
||||||
ld b, $1
|
|
||||||
jr .okay
|
|
||||||
|
|
||||||
.not_enduring
|
call BattleCommand_FalseSwipe
|
||||||
|
ld b, 0
|
||||||
|
jr nc, .damage
|
||||||
|
ld b, 1
|
||||||
|
jr .damage
|
||||||
|
|
||||||
|
.focus_band
|
||||||
call GetOpponentItem
|
call GetOpponentItem
|
||||||
ld a, b
|
ld a, b
|
||||||
cp HELD_FOCUS_BAND
|
cp HELD_FOCUS_BAND
|
||||||
ld b, $0
|
ld b, 0
|
||||||
jr nz, .okay
|
jr nz, .damage
|
||||||
|
|
||||||
call BattleRandom
|
call BattleRandom
|
||||||
cp c
|
cp c
|
||||||
jr nc, .okay
|
jr nc, .damage
|
||||||
call BattleCommand_FalseSwipe
|
call BattleCommand_FalseSwipe
|
||||||
ld b, $0
|
ld b, 0
|
||||||
jr nc, .okay
|
jr nc, .damage
|
||||||
ld b, $2
|
ld b, 2
|
||||||
.okay
|
|
||||||
|
.damage
|
||||||
push bc
|
push bc
|
||||||
call .check_sub
|
call .update_damage_taken
|
||||||
ld c, $0
|
ld c, FALSE
|
||||||
ld a, [hBattleTurn]
|
ld a, [hBattleTurn]
|
||||||
and a
|
and a
|
||||||
jr nz, .damage_player
|
jr nz, .damage_player
|
||||||
call EnemyHurtItself
|
call DoEnemyDamage
|
||||||
jr .done_damage
|
jr .done_damage
|
||||||
|
|
||||||
.damage_player
|
.damage_player
|
||||||
call PlayerHurtItself
|
call DoPlayerDamage
|
||||||
|
|
||||||
.done_damage
|
.done_damage
|
||||||
pop bc
|
pop bc
|
||||||
ld a, b
|
ld a, b
|
||||||
and a
|
and a
|
||||||
ret z
|
ret z
|
||||||
|
|
||||||
dec a
|
dec a
|
||||||
jr nz, .not_enduring2
|
jr nz, .focus_band_text
|
||||||
ld hl, EnduredText
|
ld hl, EnduredText
|
||||||
jp StdBattleTextBox
|
jp StdBattleTextBox
|
||||||
|
|
||||||
.not_enduring2
|
.focus_band_text
|
||||||
call GetOpponentItem
|
call GetOpponentItem
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
ld [wNamedObjectIndexBuffer], a
|
ld [wNamedObjectIndexBuffer], a
|
||||||
call GetItemName
|
call GetItemName
|
||||||
|
|
||||||
ld hl, HungOnText
|
ld hl, HungOnText
|
||||||
jp StdBattleTextBox
|
jp StdBattleTextBox
|
||||||
|
|
||||||
.check_sub
|
.update_damage_taken
|
||||||
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
||||||
call GetBattleVar
|
call GetBattleVar
|
||||||
bit SUBSTATUS_SUBSTITUTE, a
|
bit SUBSTATUS_SUBSTITUTE, a
|
||||||
@@ -2341,10 +2344,10 @@ BattleCommand_CheckFaint: ; 3505e
|
|||||||
ld de, wPlayerDamageTaken + 1
|
ld de, wPlayerDamageTaken + 1
|
||||||
ld a, [hBattleTurn]
|
ld a, [hBattleTurn]
|
||||||
and a
|
and a
|
||||||
jr nz, .damage_taken
|
jr nz, .got_damage_taken
|
||||||
ld de, wEnemyDamageTaken + 1
|
ld de, wEnemyDamageTaken + 1
|
||||||
|
|
||||||
.damage_taken
|
.got_damage_taken
|
||||||
ld a, [wCurDamage + 1]
|
ld a, [wCurDamage + 1]
|
||||||
ld b, a
|
ld b, a
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
@@ -2418,11 +2421,11 @@ GetFailureResultText: ; 350e4
|
|||||||
ld a, $1
|
ld a, $1
|
||||||
ld [wKickCounter], a
|
ld [wKickCounter], a
|
||||||
call LoadMoveAnim
|
call LoadMoveAnim
|
||||||
ld c, $1
|
ld c, TRUE
|
||||||
ld a, [hBattleTurn]
|
ld a, [hBattleTurn]
|
||||||
and a
|
and a
|
||||||
jp nz, EnemyHurtItself
|
jp nz, DoEnemyDamage
|
||||||
jp PlayerHurtItself
|
jp DoPlayerDamage
|
||||||
|
|
||||||
FailText_CheckOpponentProtect: ; 35157
|
FailText_CheckOpponentProtect: ; 35157
|
||||||
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
||||||
@@ -2437,7 +2440,7 @@ FailText_CheckOpponentProtect: ; 35157
|
|||||||
; 35165
|
; 35165
|
||||||
|
|
||||||
|
|
||||||
BattleCommanda5: ; 35165
|
BattleCommand_BideFailText: ; 35165
|
||||||
ld a, [wAttackMissed]
|
ld a, [wAttackMissed]
|
||||||
and a
|
and a
|
||||||
ret z
|
ret z
|
||||||
@@ -3620,15 +3623,13 @@ PlayFXAnimID: ; 35d08
|
|||||||
|
|
||||||
ld c, 3
|
ld c, 3
|
||||||
call DelayFrames
|
call DelayFrames
|
||||||
|
|
||||||
callfar PlayBattleAnim
|
callfar PlayBattleAnim
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; 35d1c
|
; 35d1c
|
||||||
|
|
||||||
|
|
||||||
EnemyHurtItself: ; 35d1c
|
DoEnemyDamage: ; 35d1c
|
||||||
ld hl, wCurDamage
|
ld hl, wCurDamage
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld b, a
|
ld b, a
|
||||||
@@ -3638,13 +3639,14 @@ EnemyHurtItself: ; 35d1c
|
|||||||
|
|
||||||
ld a, c
|
ld a, c
|
||||||
and a
|
and a
|
||||||
jr nz, .mimic_sub_check
|
jr nz, .ignore_substitute
|
||||||
|
|
||||||
ld a, [wEnemySubStatus4]
|
ld a, [wEnemySubStatus4]
|
||||||
bit SUBSTATUS_SUBSTITUTE, a
|
bit SUBSTATUS_SUBSTITUTE, a
|
||||||
jp nz, SelfInflictDamageToSubstitute
|
jp nz, DoSubstituteDamage
|
||||||
|
|
||||||
.mimic_sub_check
|
.ignore_substitute
|
||||||
|
; Substract wCurDamage from wEnemyMonHP.
|
||||||
|
; store original HP in little endian wBuffer3/4
|
||||||
ld a, [hld]
|
ld a, [hld]
|
||||||
ld b, a
|
ld b, a
|
||||||
ld a, [wEnemyMonHP + 1]
|
ld a, [wEnemyMonHP + 1]
|
||||||
@@ -3657,19 +3659,18 @@ EnemyHurtItself: ; 35d1c
|
|||||||
ld [wBuffer4], a
|
ld [wBuffer4], a
|
||||||
sbc b
|
sbc b
|
||||||
ld [wEnemyMonHP], a
|
ld [wEnemyMonHP], a
|
||||||
jr nc, .mimic_faint
|
jr nc, .no_underflow
|
||||||
|
|
||||||
ld a, [wBuffer4]
|
ld a, [wBuffer4]
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld a, [wBuffer3]
|
ld a, [wBuffer3]
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
|
|
||||||
xor a
|
xor a
|
||||||
ld hl, wEnemyMonHP
|
ld hl, wEnemyMonHP
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
|
|
||||||
.mimic_faint
|
.no_underflow
|
||||||
ld hl, wEnemyMonMaxHP
|
ld hl, wEnemyMonMaxHP
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld [wBuffer2], a
|
ld [wBuffer2], a
|
||||||
@@ -3680,6 +3681,7 @@ EnemyHurtItself: ; 35d1c
|
|||||||
ld [wBuffer6], a
|
ld [wBuffer6], a
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
ld [wBuffer5], a
|
ld [wBuffer5], a
|
||||||
|
|
||||||
hlcoord 2, 2
|
hlcoord 2, 2
|
||||||
xor a
|
xor a
|
||||||
ld [wWhichHPBar], a
|
ld [wWhichHPBar], a
|
||||||
@@ -3690,7 +3692,7 @@ EnemyHurtItself: ; 35d1c
|
|||||||
; 35d7e
|
; 35d7e
|
||||||
|
|
||||||
|
|
||||||
PlayerHurtItself: ; 35d7e
|
DoPlayerDamage: ; 35d7e
|
||||||
ld hl, wCurDamage
|
ld hl, wCurDamage
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld b, a
|
ld b, a
|
||||||
@@ -3700,12 +3702,15 @@ PlayerHurtItself: ; 35d7e
|
|||||||
|
|
||||||
ld a, c
|
ld a, c
|
||||||
and a
|
and a
|
||||||
jr nz, .mimic_sub_check
|
jr nz, .ignore_substitute
|
||||||
|
|
||||||
ld a, [wPlayerSubStatus4]
|
ld a, [wPlayerSubStatus4]
|
||||||
bit SUBSTATUS_SUBSTITUTE, a
|
bit SUBSTATUS_SUBSTITUTE, a
|
||||||
jp nz, SelfInflictDamageToSubstitute
|
jp nz, DoSubstituteDamage
|
||||||
.mimic_sub_check
|
|
||||||
|
.ignore_substitute
|
||||||
|
; Substract wCurDamage from wBattleMonHP.
|
||||||
|
; store original HP in little endian wBuffer3/4
|
||||||
|
; store new HP in little endian wBuffer5/6
|
||||||
ld a, [hld]
|
ld a, [hld]
|
||||||
ld b, a
|
ld b, a
|
||||||
ld a, [wBattleMonHP + 1]
|
ld a, [wBattleMonHP + 1]
|
||||||
@@ -3719,14 +3724,13 @@ PlayerHurtItself: ; 35d7e
|
|||||||
sbc b
|
sbc b
|
||||||
ld [wBattleMonHP], a
|
ld [wBattleMonHP], a
|
||||||
ld [wBuffer6], a
|
ld [wBuffer6], a
|
||||||
jr nc, .mimic_faint
|
jr nc, .no_underflow
|
||||||
|
|
||||||
ld a, [wBuffer4]
|
ld a, [wBuffer4]
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld a, [wBuffer3]
|
ld a, [wBuffer3]
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
xor a
|
xor a
|
||||||
|
|
||||||
ld hl, wBattleMonHP
|
ld hl, wBattleMonHP
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
@@ -3734,14 +3738,15 @@ PlayerHurtItself: ; 35d7e
|
|||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
|
|
||||||
.mimic_faint
|
.no_underflow
|
||||||
ld hl, wBattleMonMaxHP
|
ld hl, wBattleMonMaxHP
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld [wBuffer2], a
|
ld [wBuffer2], a
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
ld [wBuffer1], a
|
ld [wBuffer1], a
|
||||||
|
|
||||||
hlcoord 10, 9
|
hlcoord 10, 9
|
||||||
ld a, $1
|
ld a, 1
|
||||||
ld [wWhichHPBar], a
|
ld [wWhichHPBar], a
|
||||||
predef AnimateHPBar
|
predef AnimateHPBar
|
||||||
.did_no_damage
|
.did_no_damage
|
||||||
@@ -3750,8 +3755,7 @@ PlayerHurtItself: ; 35d7e
|
|||||||
; 35de0
|
; 35de0
|
||||||
|
|
||||||
|
|
||||||
SelfInflictDamageToSubstitute: ; 35de0
|
DoSubstituteDamage: ; 35de0
|
||||||
|
|
||||||
ld hl, SubTookDamageText
|
ld hl, SubTookDamageText
|
||||||
call StdBattleTextBox
|
call StdBattleTextBox
|
||||||
|
|
||||||
@@ -4136,6 +4140,7 @@ BattleCommand_EatDream: ; 36008
|
|||||||
|
|
||||||
|
|
||||||
SapHealth: ; 36011
|
SapHealth: ; 36011
|
||||||
|
; Divide damage by 2, store it in hDividend
|
||||||
ld hl, wCurDamage
|
ld hl, wCurDamage
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
srl a
|
srl a
|
||||||
@@ -4145,10 +4150,11 @@ SapHealth: ; 36011
|
|||||||
rr a
|
rr a
|
||||||
ld [hDividend + 1], a
|
ld [hDividend + 1], a
|
||||||
or b
|
or b
|
||||||
jr nz, .ok1
|
jr nz, .at_least_one
|
||||||
ld a, $1
|
ld a, 1
|
||||||
ld [hDividend + 1], a
|
ld [hDividend + 1], a
|
||||||
.ok1
|
.at_least_one
|
||||||
|
|
||||||
ld hl, wBattleMonHP
|
ld hl, wBattleMonHP
|
||||||
ld de, wBattleMonMaxHP
|
ld de, wBattleMonMaxHP
|
||||||
ld a, [hBattleTurn]
|
ld a, [hBattleTurn]
|
||||||
@@ -4157,12 +4163,16 @@ SapHealth: ; 36011
|
|||||||
ld hl, wEnemyMonHP
|
ld hl, wEnemyMonHP
|
||||||
ld de, wEnemyMonMaxHP
|
ld de, wEnemyMonMaxHP
|
||||||
.battlemonhp
|
.battlemonhp
|
||||||
|
|
||||||
|
; Store current HP in little endian wBuffer3/4
|
||||||
ld bc, wBuffer4
|
ld bc, wBuffer4
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld [bc], a
|
ld [bc], a
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
dec bc
|
dec bc
|
||||||
ld [bc], a
|
ld [bc], a
|
||||||
|
|
||||||
|
; Store max HP in little endian wBuffer1/2
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
dec bc
|
dec bc
|
||||||
ld [bc], a
|
ld [bc], a
|
||||||
@@ -4170,6 +4180,8 @@ SapHealth: ; 36011
|
|||||||
ld a, [de]
|
ld a, [de]
|
||||||
dec bc
|
dec bc
|
||||||
ld [bc], a
|
ld [bc], a
|
||||||
|
|
||||||
|
; Add hDividend to current HP and copy it to little endian wBuffer5/6
|
||||||
ld a, [hDividend + 1]
|
ld a, [hDividend + 1]
|
||||||
ld b, [hl]
|
ld b, [hl]
|
||||||
add b
|
add b
|
||||||
@@ -4180,7 +4192,9 @@ SapHealth: ; 36011
|
|||||||
adc b
|
adc b
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld [wBuffer6], a
|
ld [wBuffer6], a
|
||||||
jr c, .okay2
|
jr c, .max_hp
|
||||||
|
|
||||||
|
; Substract current HP from max HP (to see if we have more than max HP)
|
||||||
ld a, [hld]
|
ld a, [hld]
|
||||||
ld b, a
|
ld b, a
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
@@ -4191,8 +4205,10 @@ SapHealth: ; 36011
|
|||||||
ld a, [de]
|
ld a, [de]
|
||||||
inc de
|
inc de
|
||||||
sbc b
|
sbc b
|
||||||
jr nc, .okay3
|
jr nc, .finish
|
||||||
.okay2
|
|
||||||
|
.max_hp
|
||||||
|
; Load max HP into current HP and copy it to little endian wBuffer5/6
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
ld [hld], a
|
ld [hld], a
|
||||||
ld [wBuffer5], a
|
ld [wBuffer5], a
|
||||||
@@ -4201,7 +4217,8 @@ SapHealth: ; 36011
|
|||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld [wBuffer6], a
|
ld [wBuffer6], a
|
||||||
inc de
|
inc de
|
||||||
.okay3
|
|
||||||
|
.finish
|
||||||
ld a, [hBattleTurn]
|
ld a, [hBattleTurn]
|
||||||
and a
|
and a
|
||||||
hlcoord 10, 9
|
hlcoord 10, 9
|
||||||
@@ -5638,7 +5655,7 @@ CheckPlayerHasMonToSwitchTo: ; 36994
|
|||||||
BattleCommand_EndLoop: ; 369b6
|
BattleCommand_EndLoop: ; 369b6
|
||||||
; endloop
|
; endloop
|
||||||
|
|
||||||
; Loop back to the command before 'critical'.
|
; Loop back to 'critical'.
|
||||||
|
|
||||||
ld de, wPlayerRolloutCount
|
ld de, wPlayerRolloutCount
|
||||||
ld bc, wPlayerDamageTaken
|
ld bc, wPlayerDamageTaken
|
||||||
@@ -5701,7 +5718,7 @@ BattleCommand_EndLoop: ; 369b6
|
|||||||
ld a, BATTLE_VARS_SUBSTATUS3
|
ld a, BATTLE_VARS_SUBSTATUS3
|
||||||
call GetBattleVarAddr
|
call GetBattleVarAddr
|
||||||
res SUBSTATUS_IN_LOOP, [hl]
|
res SUBSTATUS_IN_LOOP, [hl]
|
||||||
call BattleCommanda8
|
call BattleCommand_BeatUpFailText
|
||||||
jp EndMoveEffect
|
jp EndMoveEffect
|
||||||
|
|
||||||
.not_triple_kick
|
.not_triple_kick
|
||||||
@@ -5753,7 +5770,6 @@ BattleCommand_EndLoop: ; 369b6
|
|||||||
ld [bc], a
|
ld [bc], a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Loop back to the command before 'critical'.
|
|
||||||
.loop_back_to_critical
|
.loop_back_to_critical
|
||||||
ld a, [wBattleScriptBufferAddress + 1]
|
ld a, [wBattleScriptBufferAddress + 1]
|
||||||
ld h, a
|
ld h, a
|
||||||
|
@@ -5,9 +5,11 @@ BattleCommand_BeatUp: ; 35461
|
|||||||
ld a, [hBattleTurn]
|
ld a, [hBattleTurn]
|
||||||
and a
|
and a
|
||||||
jp nz, .enemy_beats_up
|
jp nz, .enemy_beats_up
|
||||||
|
|
||||||
ld a, [wPlayerSubStatus3]
|
ld a, [wPlayerSubStatus3]
|
||||||
bit SUBSTATUS_IN_LOOP, a
|
bit SUBSTATUS_IN_LOOP, a
|
||||||
jr nz, .next_mon
|
jr nz, .next_mon
|
||||||
|
|
||||||
ld c, 20
|
ld c, 20
|
||||||
call DelayFrames
|
call DelayFrames
|
||||||
xor a
|
xor a
|
||||||
@@ -51,11 +53,13 @@ BattleCommand_BeatUp: ; 35461
|
|||||||
ld [wBeatUpHitAtLeastOnce], a
|
ld [wBeatUpHitAtLeastOnce], a
|
||||||
ld hl, BeatUpAttackText
|
ld hl, BeatUpAttackText
|
||||||
call StdBattleTextBox
|
call StdBattleTextBox
|
||||||
|
|
||||||
ld a, [wEnemyMonSpecies]
|
ld a, [wEnemyMonSpecies]
|
||||||
ld [wCurSpecies], a
|
ld [wCurSpecies], a
|
||||||
call GetBaseData
|
call GetBaseData
|
||||||
ld a, [wBaseDefense]
|
ld a, [wBaseDefense]
|
||||||
ld c, a
|
ld c, a
|
||||||
|
|
||||||
push bc
|
push bc
|
||||||
ld a, MON_SPECIES
|
ld a, MON_SPECIES
|
||||||
call GetBeatupMonLocation
|
call GetBeatupMonLocation
|
||||||
@@ -65,12 +69,14 @@ BattleCommand_BeatUp: ; 35461
|
|||||||
ld a, [wBaseAttack]
|
ld a, [wBaseAttack]
|
||||||
pop bc
|
pop bc
|
||||||
ld b, a
|
ld b, a
|
||||||
|
|
||||||
push bc
|
push bc
|
||||||
ld a, MON_LEVEL
|
ld a, MON_LEVEL
|
||||||
call GetBeatupMonLocation
|
call GetBeatupMonLocation
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
ld e, a
|
ld e, a
|
||||||
pop bc
|
pop bc
|
||||||
|
|
||||||
ld a, [wPlayerMoveStructPower]
|
ld a, [wPlayerMoveStructPower]
|
||||||
ld d, a
|
ld d, a
|
||||||
ret
|
ret
|
||||||
@@ -78,21 +84,22 @@ BattleCommand_BeatUp: ; 35461
|
|||||||
.enemy_beats_up
|
.enemy_beats_up
|
||||||
ld a, [wEnemySubStatus3]
|
ld a, [wEnemySubStatus3]
|
||||||
bit SUBSTATUS_IN_LOOP, a
|
bit SUBSTATUS_IN_LOOP, a
|
||||||
jr nz, .not_first_enemy_beatup
|
jr nz, .enemy_next_mon
|
||||||
|
|
||||||
xor a
|
xor a
|
||||||
ld [wEnemyRolloutCount], a
|
ld [wEnemyRolloutCount], a
|
||||||
ld [wd002], a
|
ld [wd002], a
|
||||||
ld [wBeatUpHitAtLeastOnce], a
|
ld [wBeatUpHitAtLeastOnce], a
|
||||||
jr .enemy_continue
|
jr .enemy_got_mon
|
||||||
|
|
||||||
.not_first_enemy_beatup
|
.enemy_next_mon
|
||||||
ld a, [wEnemyRolloutCount]
|
ld a, [wEnemyRolloutCount]
|
||||||
ld b, a
|
ld b, a
|
||||||
ld a, [wOTPartyCount]
|
ld a, [wOTPartyCount]
|
||||||
sub b
|
sub b
|
||||||
ld [wd002], a
|
ld [wd002], a
|
||||||
.enemy_continue
|
|
||||||
|
.enemy_got_mon
|
||||||
ld a, [wBattleMode]
|
ld a, [wBattleMode]
|
||||||
dec a
|
dec a
|
||||||
jr z, .wild
|
jr z, .wild
|
||||||
@@ -122,19 +129,20 @@ BattleCommand_BeatUp: ; 35461
|
|||||||
call AddNTimes
|
call AddNTimes
|
||||||
ld de, wStringBuffer1
|
ld de, wStringBuffer1
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
.got_enemy_nick
|
.got_enemy_nick
|
||||||
ld a, MON_HP
|
ld a, MON_HP
|
||||||
call GetBeatupMonLocation
|
call GetBeatupMonLocation
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
or [hl]
|
or [hl]
|
||||||
jp z, .beatup_fail
|
jp z, .beatup_fail
|
||||||
|
|
||||||
ld a, [wd002]
|
ld a, [wd002]
|
||||||
ld b, a
|
ld b, a
|
||||||
ld a, [wCurOTMon]
|
ld a, [wCurOTMon]
|
||||||
cp b
|
cp b
|
||||||
ld hl, wEnemyMonStatus
|
ld hl, wEnemyMonStatus
|
||||||
jr z, .active_enemy
|
jr z, .active_enemy
|
||||||
|
|
||||||
ld a, MON_STATUS
|
ld a, MON_STATUS
|
||||||
call GetBeatupMonLocation
|
call GetBeatupMonLocation
|
||||||
.active_enemy
|
.active_enemy
|
||||||
@@ -157,11 +165,13 @@ BattleCommand_BeatUp: ; 35461
|
|||||||
.finish_beatup
|
.finish_beatup
|
||||||
ld hl, BeatUpAttackText
|
ld hl, BeatUpAttackText
|
||||||
call StdBattleTextBox
|
call StdBattleTextBox
|
||||||
|
|
||||||
ld a, [wBattleMonSpecies]
|
ld a, [wBattleMonSpecies]
|
||||||
ld [wCurSpecies], a
|
ld [wCurSpecies], a
|
||||||
call GetBaseData
|
call GetBaseData
|
||||||
ld a, [wBaseDefense]
|
ld a, [wBaseDefense]
|
||||||
ld c, a
|
ld c, a
|
||||||
|
|
||||||
push bc
|
push bc
|
||||||
ld a, MON_SPECIES
|
ld a, MON_SPECIES
|
||||||
call GetBeatupMonLocation
|
call GetBeatupMonLocation
|
||||||
@@ -171,12 +181,14 @@ BattleCommand_BeatUp: ; 35461
|
|||||||
ld a, [wBaseAttack]
|
ld a, [wBaseAttack]
|
||||||
pop bc
|
pop bc
|
||||||
ld b, a
|
ld b, a
|
||||||
|
|
||||||
push bc
|
push bc
|
||||||
ld a, MON_LEVEL
|
ld a, MON_LEVEL
|
||||||
call GetBeatupMonLocation
|
call GetBeatupMonLocation
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
ld e, a
|
ld e, a
|
||||||
pop bc
|
pop bc
|
||||||
|
|
||||||
ld a, [wEnemyMoveStructPower]
|
ld a, [wEnemyMoveStructPower]
|
||||||
ld d, a
|
ld d, a
|
||||||
ret
|
ret
|
||||||
@@ -191,7 +203,9 @@ BattleCommand_BeatUp: ; 35461
|
|||||||
; 355b5
|
; 355b5
|
||||||
|
|
||||||
|
|
||||||
BattleCommanda8: ; 355b5
|
BattleCommand_BeatUpFailText: ; 355b5
|
||||||
|
; beatupfailtext
|
||||||
|
|
||||||
ld a, [wBeatUpHitAtLeastOnce]
|
ld a, [wBeatUpHitAtLeastOnce]
|
||||||
and a
|
and a
|
||||||
ret nz
|
ret nz
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
BattleCommand_FalseSwipe: ; 35c94
|
BattleCommand_FalseSwipe: ; 35c94
|
||||||
; falseswipe
|
; falseswipe
|
||||||
|
|
||||||
|
; Makes sure wCurDamage < MonHP
|
||||||
|
|
||||||
ld hl, wEnemyMonHP
|
ld hl, wEnemyMonHP
|
||||||
ld a, [hBattleTurn]
|
ld a, [hBattleTurn]
|
||||||
and a
|
and a
|
||||||
@@ -15,12 +17,14 @@ BattleCommand_FalseSwipe: ; 35c94
|
|||||||
pop de
|
pop de
|
||||||
pop hl
|
pop hl
|
||||||
jr c, .done
|
jr c, .done
|
||||||
|
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
dec a
|
dec a
|
||||||
ld [de], a
|
ld [de], a
|
||||||
|
|
||||||
inc a
|
inc a
|
||||||
jr nz, .okay
|
jr nz, .okay
|
||||||
dec de
|
dec de
|
||||||
@@ -28,11 +32,13 @@ BattleCommand_FalseSwipe: ; 35c94
|
|||||||
dec a
|
dec a
|
||||||
ld [de], a
|
ld [de], a
|
||||||
.okay
|
.okay
|
||||||
|
|
||||||
ld a, [wCriticalHit]
|
ld a, [wCriticalHit]
|
||||||
cp 2
|
cp 2
|
||||||
jr nz, .carry
|
jr nz, .carry
|
||||||
xor a
|
xor a
|
||||||
ld [wCriticalHit], a
|
ld [wCriticalHit], a
|
||||||
|
|
||||||
.carry
|
.carry
|
||||||
scf
|
scf
|
||||||
ret
|
ret
|
||||||
|
@@ -15,10 +15,10 @@ ENDM
|
|||||||
command damagevariation ; 08
|
command damagevariation ; 08
|
||||||
command checkhit ; 09
|
command checkhit ; 09
|
||||||
command lowersub ; 0a
|
command lowersub ; 0a
|
||||||
command hittargetnosub ; 0b
|
command moveanimnosub ; 0b
|
||||||
command raisesub ; 0c
|
command raisesub ; 0c
|
||||||
command failuretext ; 0d
|
command failuretext ; 0d
|
||||||
command checkfaint ; 0e
|
command applydamage ; 0e
|
||||||
command criticaltext ; 0f
|
command criticaltext ; 0f
|
||||||
command supereffectivetext ; 10
|
command supereffectivetext ; 10
|
||||||
command checkdestinybond ; 11
|
command checkdestinybond ; 11
|
||||||
@@ -169,13 +169,13 @@ ENDM
|
|||||||
command ragedamage ; a2
|
command ragedamage ; a2
|
||||||
command resettypematchup ; a3
|
command resettypematchup ; a3
|
||||||
command allstatsup ; a4
|
command allstatsup ; a4
|
||||||
command effect0xa5 ; a5
|
command bidefailtext ; a5
|
||||||
command raisesubnoanim ; a6
|
command raisesubnoanim ; a6
|
||||||
command lowersubnoanim ; a7
|
command lowersubnoanim ; a7
|
||||||
command effect0xa8 ; a8
|
command beatupfailtext ; a8
|
||||||
command clearmissdamage ; a9
|
command clearmissdamage ; a9
|
||||||
command movedelay ; aa
|
command movedelay ; aa
|
||||||
command hittarget ; ab
|
command moveanim ; ab
|
||||||
command tristatuschance ; ac
|
command tristatuschance ; ac
|
||||||
command supereffectivelooptext ; ad
|
command supereffectivelooptext ; ad
|
||||||
command startloop ; ae
|
command startloop ; ae
|
||||||
|
Reference in New Issue
Block a user