2013-03-26 17:39:44 -07:00
|
|
|
DoPlayerTurn: ; 34000
|
|
|
|
call SetPlayerTurn
|
|
|
|
|
2018-01-23 13:45:34 -08:00
|
|
|
ld a, [wBattlePlayerAction]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
jr DoTurn
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3400a
|
|
|
|
|
|
|
|
|
|
|
|
DoEnemyTurn: ; 3400a
|
|
|
|
call SetEnemyTurn
|
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, DoTurn
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, [wBattleAction]
|
2015-11-06 11:45:10 -08:00
|
|
|
cp BATTLEACTION_E
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, DoTurn
|
2015-11-06 11:45:10 -08:00
|
|
|
cp BATTLEACTION_SWITCH1
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 3401d
|
|
|
|
|
|
|
|
|
|
|
|
DoTurn: ; 3401d
|
|
|
|
; Read in and execute the user's move effects for this turn.
|
|
|
|
|
|
|
|
xor a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [wTurnEnded], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Effect command checkturn is called for every move.
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckTurn
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, [wTurnEnded]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
call UpdateMoveData
|
|
|
|
; 3402c
|
|
|
|
|
|
|
|
|
|
|
|
DoMove: ; 3402c
|
|
|
|
; Get the user's move effect.
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld hl, MoveEffectsPointers
|
|
|
|
add hl, bc
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, bc
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BANK(MoveEffectsPointers)
|
|
|
|
call GetFarHalfword
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wBattleScriptBuffer
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GetMoveEffect:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BANK(MoveEffects)
|
|
|
|
call GetFarByte
|
|
|
|
inc hl
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -1
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nz, .GetMoveEffect
|
|
|
|
|
|
|
|
; Start at the first command.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleScriptBuffer
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ReadMoveEffectCommand:
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
; ld a, [wBattleScriptBufferAddress++]
|
|
|
|
ld a, [wBattleScriptBufferAddress]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld l, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, a
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
|
|
|
push af
|
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
|
|
|
|
2015-04-13 21:39:54 -07:00
|
|
|
; endturn_command (-2) is used to terminate branches without ending the read cycle.
|
|
|
|
cp endturn_command
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
; The rest of the commands (01-af) are read from BattleCommandPointers.
|
|
|
|
push bc
|
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld hl, BattleCommandPointers
|
|
|
|
add hl, bc
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, bc
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
|
|
|
|
ld a, BANK(BattleCommandPointers)
|
|
|
|
call GetFarHalfword
|
|
|
|
|
|
|
|
call .DoMoveEffectCommand
|
|
|
|
|
|
|
|
jr .ReadMoveEffectCommand
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoMoveEffectCommand:
|
2017-06-09 14:01:10 -07:00
|
|
|
jp hl
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34084
|
|
|
|
|
|
|
|
|
|
|
|
CheckTurn:
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_CheckTurn: ; 34084
|
2013-03-26 17:39:44 -07:00
|
|
|
; checkturn
|
|
|
|
|
|
|
|
; Repurposed as hardcoded turn handling. Useless as a command.
|
|
|
|
|
|
|
|
; Move $ff immediately ends the turn.
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-11-09 13:41:09 -08:00
|
|
|
jp z, EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAttackMissed], a
|
|
|
|
ld [wEffectFailed], a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAlreadyDisobeyed], a
|
|
|
|
ld [wAlreadyFailed], a
|
2016-01-09 13:28:22 -08:00
|
|
|
ld [wSomeoneIsRampaging], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-10 14:30:27 -08:00
|
|
|
ld a, EFFECTIVE
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTypeModifier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jp nz, CheckEnemyTurn
|
|
|
|
|
|
|
|
|
|
|
|
CheckPlayerTurn:
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus4
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_RECHARGE, [hl]
|
|
|
|
jr z, .no_recharge
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_RECHARGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, MustRechargeText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.no_recharge
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonStatus
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
and SLP
|
|
|
|
jr z, .not_asleep
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleMonStatus], a
|
2014-06-13 21:18:14 -07:00
|
|
|
and SLP
|
|
|
|
jr z, .woke_up
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-12-19 01:47:39 -08:00
|
|
|
ld de, ANIM_SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
call FarPlayBattleAnimation
|
2014-06-13 21:18:14 -07:00
|
|
|
jr .fast_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.woke_up
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, WokeUpText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateBattleMonInParty
|
2018-01-16 11:30:10 -08:00
|
|
|
ld hl, UpdatePlayerHUD
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hBGMapMode], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus1
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_NIGHTMARE, [hl]
|
|
|
|
jr .not_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.fast_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, FastAsleepText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Snore and Sleep Talk bypass sleep.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPlayerMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SNORE
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SLEEP_TALK
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_asleep
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_asleep
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonStatus
|
2014-06-13 21:18:14 -07:00
|
|
|
bit FRZ, [hl]
|
|
|
|
jr z, .not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Flame Wheel and Sacred Fire thaw the user.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPlayerMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp FLAME_WHEEL
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SACRED_FIRE
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, FrozenSolidText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_FLINCHED, [hl]
|
|
|
|
jr z, .not_flinched
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_FLINCHED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, FlinchedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_flinched
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerDisableCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_disabled
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
|
|
|
ld [hl], a
|
|
|
|
and $f
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .not_disabled
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wDisabledMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, DisabledNoMoreText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_disabled
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus3]
|
2013-03-26 17:39:44 -07:00
|
|
|
add a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nc, .not_confused
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerConfuseCount
|
2013-03-26 17:39:44 -07:00
|
|
|
dec [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_CONFUSED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, ConfusedNoMoreText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2014-06-13 21:18:14 -07:00
|
|
|
jr .not_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.confused
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, IsConfusedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, ANIM_CONFUSED
|
|
|
|
call FarPlayBattleAnimation
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 50% chance of hitting itself
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 50 percent + 1
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nc, .not_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-09-09 14:05:19 -07:00
|
|
|
; clear confusion-dependent substatus
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus3
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << SUBSTATUS_CONFUSED
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
call HitConfusion
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_confused
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus1]
|
2014-06-13 21:18:14 -07:00
|
|
|
add a ; bit SUBSTATUS_ATTRACT
|
|
|
|
jr nc, .not_infatuated
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, InLoveWithText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-12-19 01:47:39 -08:00
|
|
|
ld de, ANIM_IN_LOVE
|
2013-03-26 17:39:44 -07:00
|
|
|
call FarPlayBattleAnimation
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 50% chance of infatuation
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 50 percent + 1
|
2014-06-13 21:18:14 -07:00
|
|
|
jr c, .not_infatuated
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, InfatuationText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_infatuated
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
|
|
; We can't disable a move that doesn't exist.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wDisabledMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .no_disabled_move
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Are we using the disabled move?
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurPlayerMove
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .no_disabled_move
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call MoveDisabled
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.no_disabled_move
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonStatus
|
2014-06-13 21:18:14 -07:00
|
|
|
bit PAR, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 25% chance to be fully paralyzed
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 25 percent
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
ld hl, FullyParalyzedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 341f0
|
|
|
|
|
|
|
|
|
|
|
|
CantMove: ; 341f0
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-17 12:52:32 -07:00
|
|
|
res SUBSTATUS_ROLLOUT, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-06-17 12:52:32 -07:00
|
|
|
and $ff ^ (1<<SUBSTATUS_BIDE + 1<<SUBSTATUS_RAMPAGE + 1<<SUBSTATUS_CHARGED)
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
call ResetFuryCutterCount
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp FLY
|
2015-11-06 19:36:06 -08:00
|
|
|
jr z, .fly_dig
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
cp DIG
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.fly_dig
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_UNDERGROUND, [hl]
|
|
|
|
res SUBSTATUS_FLYING, [hl]
|
2015-11-09 13:41:09 -08:00
|
|
|
jp AppearUserRaiseSub
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34216
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
OpponentCantMove: ; 34216
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-10-10 04:45:39 -07:00
|
|
|
jp BattleCommand_SwitchTurn
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3421f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CheckEnemyTurn: ; 3421f
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus4
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_RECHARGE, [hl]
|
|
|
|
jr z, .no_recharge
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_RECHARGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, MustRechargeText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.no_recharge
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonStatus
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
and SLP
|
|
|
|
jr z, .not_asleep
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEnemyMonStatus], a
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .woke_up
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, FastAsleepText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-12-19 01:47:39 -08:00
|
|
|
ld de, ANIM_SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
call FarPlayBattleAnimation
|
2014-06-13 21:18:14 -07:00
|
|
|
jr .fast_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.woke_up
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, WokeUpText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateEnemyMonInParty
|
2018-01-16 11:30:10 -08:00
|
|
|
ld hl, UpdateEnemyHUD
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hBGMapMode], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus1
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_NIGHTMARE, [hl]
|
|
|
|
jr .not_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.fast_asleep
|
|
|
|
; Snore and Sleep Talk bypass sleep.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurEnemyMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SNORE
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SLEEP_TALK
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_asleep
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonStatus
|
2014-06-13 21:18:14 -07:00
|
|
|
bit FRZ, [hl]
|
|
|
|
jr z, .not_frozen
|
2018-01-10 14:30:27 -08:00
|
|
|
|
|
|
|
; Flame Wheel and Sacred Fire thaw the user.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurEnemyMove]
|
2014-06-13 21:18:14 -07:00
|
|
|
cp FLAME_WHEEL
|
|
|
|
jr z, .not_frozen
|
|
|
|
cp SACRED_FIRE
|
|
|
|
jr z, .not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, FrozenSolidText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_FLINCHED, [hl]
|
|
|
|
jr z, .not_flinched
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_FLINCHED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, FlinchedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_flinched
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyDisableCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_disabled
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
dec a
|
|
|
|
ld [hl], a
|
|
|
|
and $f
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .not_disabled
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEnemyDisabledMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, DisabledNoMoreText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_disabled
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus3]
|
2014-06-13 21:18:14 -07:00
|
|
|
add a ; bit SUBSTATUS_CONFUSED
|
|
|
|
jr nc, .not_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyConfuseCount
|
2013-03-26 17:39:44 -07:00
|
|
|
dec [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_CONFUSED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, ConfusedNoMoreText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2014-06-13 21:18:14 -07:00
|
|
|
jr .not_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.confused
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, IsConfusedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, ANIM_CONFUSED
|
|
|
|
call FarPlayBattleAnimation
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 50% chance of hitting itself
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 50 percent + 1
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nc, .not_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; clear confusion-dependent substatus
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus3
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << SUBSTATUS_CONFUSED
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
ld hl, HurtItselfText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2015-11-09 13:41:09 -08:00
|
|
|
call HitSelfInConfusion
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_DamageCalc
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Flicker the monster pic unless flying or underground.
|
|
|
|
ld de, ANIM_HIT_CONFUSION
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-03-26 17:39:44 -07:00
|
|
|
call z, PlayFXAnimID
|
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
ld c, TRUE
|
|
|
|
call DoEnemyDamage
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_confused
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus1]
|
2014-06-13 21:18:14 -07:00
|
|
|
add a ; bit SUBSTATUS_ATTRACT
|
|
|
|
jr nc, .not_infatuated
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, InLoveWithText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-12-19 01:47:39 -08:00
|
|
|
ld de, ANIM_IN_LOVE
|
2013-03-26 17:39:44 -07:00
|
|
|
call FarPlayBattleAnimation
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 50% chance of infatuation
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 50 percent + 1
|
2014-06-13 21:18:14 -07:00
|
|
|
jr c, .not_infatuated
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, InfatuationText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_infatuated
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; We can't disable a move that doesn't exist.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyDisabledMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .no_disabled_move
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Are we using the disabled move?
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurEnemyMove
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .no_disabled_move
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call MoveDisabled
|
|
|
|
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.no_disabled_move
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonStatus
|
2014-06-13 21:18:14 -07:00
|
|
|
bit PAR, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 25% chance to be fully paralyzed
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 25 percent
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
ld hl, FullyParalyzedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 34385
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
EndTurn: ; 34385
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [wTurnEnded], a
|
2013-03-26 17:39:44 -07:00
|
|
|
jp ResetDamage
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3438d
|
|
|
|
|
|
|
|
|
|
|
|
MoveDisabled: ; 3438d
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Make sure any charged moves fail
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_CHARGED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-05-02 23:43:44 -07:00
|
|
|
call GetMoveName
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, DisabledMoveText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 343a5
|
|
|
|
|
|
|
|
|
|
|
|
HitConfusion: ; 343a5
|
|
|
|
|
|
|
|
ld hl, HurtItselfText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCriticalHit], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call HitSelfInConfusion
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_DamageCalc
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Flicker the monster pic unless flying or underground.
|
|
|
|
ld de, ANIM_HIT_CONFUSION
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-03-26 17:39:44 -07:00
|
|
|
call z, PlayFXAnimID
|
|
|
|
|
2018-01-16 11:30:10 -08:00
|
|
|
ld hl, UpdatePlayerHUD
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hBGMapMode], a
|
2018-04-04 14:27:40 -07:00
|
|
|
ld c, TRUE
|
|
|
|
call DoPlayerDamage
|
2015-11-06 13:42:38 -08:00
|
|
|
jp BattleCommand_RaiseSub
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 343db
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_CheckObedience: ; 343db
|
2013-03-26 17:39:44 -07:00
|
|
|
; checkobedience
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Enemy can't disobey
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckUserIsCharging
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; If we've already checked this turn
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAlreadyDisobeyed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAlreadyDisobeyed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; No obedience in link battles
|
|
|
|
; (since no handling exists for enemy)
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; If the monster's id doesn't match the player's,
|
|
|
|
; some conditions need to be met.
|
2015-11-04 08:19:58 -08:00
|
|
|
ld a, MON_ID
|
2013-03-26 17:39:44 -07:00
|
|
|
call BattlePartyAttr
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerID]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
|
|
|
jr nz, .obeylevel
|
|
|
|
inc hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerID + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
|
|
|
ret z
|
|
|
|
|
|
|
|
|
|
|
|
.obeylevel
|
2014-06-13 21:18:14 -07:00
|
|
|
; The maximum obedience level is constrained by owned badges:
|
2017-12-28 04:15:46 -08:00
|
|
|
ld hl, wJohtoBadges
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; risingbadge
|
2015-11-07 18:04:54 -08:00
|
|
|
bit RISINGBADGE, [hl]
|
2017-12-25 13:21:31 -08:00
|
|
|
ld a, MAX_LEVEL + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nz, .getlevel
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; stormbadge
|
2015-11-07 18:04:54 -08:00
|
|
|
bit STORMBADGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 70
|
|
|
|
jr nz, .getlevel
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; fogbadge
|
2015-11-07 18:04:54 -08:00
|
|
|
bit FOGBADGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 50
|
|
|
|
jr nz, .getlevel
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; hivebadge
|
2015-11-07 18:04:54 -08:00
|
|
|
bit HIVEBADGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 30
|
|
|
|
jr nz, .getlevel
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; no badges
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 10
|
|
|
|
|
|
|
|
|
|
|
|
.getlevel
|
|
|
|
; c = obedience level
|
|
|
|
; d = monster level
|
|
|
|
; b = c + d
|
|
|
|
|
|
|
|
ld b, a
|
|
|
|
ld c, a
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
|
|
|
|
|
|
|
add b
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
; No overflow (this should never happen)
|
|
|
|
jr nc, .checklevel
|
|
|
|
ld b, $ff
|
|
|
|
|
|
|
|
|
|
|
|
.checklevel
|
|
|
|
; If the monster's level is lower than the obedience level, it will obey.
|
|
|
|
ld a, c
|
|
|
|
cp d
|
|
|
|
ret nc
|
|
|
|
|
|
|
|
|
|
|
|
; Random number from 0 to obedience level + monster level
|
|
|
|
.rand1
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
swap a
|
|
|
|
cp b
|
|
|
|
jr nc, .rand1
|
|
|
|
|
|
|
|
; The higher above the obedience level the monster is,
|
|
|
|
; the more likely it is to disobey.
|
|
|
|
cp c
|
|
|
|
ret c
|
|
|
|
|
|
|
|
; Sleep-only moves have separate handling, and a higher chance of
|
|
|
|
; being ignored. Lazy monsters like their sleep.
|
|
|
|
call IgnoreSleepOnly
|
|
|
|
ret c
|
|
|
|
|
|
|
|
|
|
|
|
; Another random number from 0 to obedience level + monster level
|
|
|
|
.rand2
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
|
|
|
jr nc, .rand2
|
|
|
|
|
|
|
|
; A second chance.
|
|
|
|
cp c
|
|
|
|
jr c, .UseInstead
|
|
|
|
|
|
|
|
|
|
|
|
; No hope of using a move now.
|
|
|
|
|
|
|
|
; b = number of levels the monster is above the obedience level
|
|
|
|
ld a, d
|
|
|
|
sub c
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
; The chance of napping is the difference out of 256.
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
swap a
|
|
|
|
sub b
|
|
|
|
jr c, .Nap
|
|
|
|
|
|
|
|
; The chance of not hitting itself is the same.
|
|
|
|
cp b
|
|
|
|
jr nc, .DoNothing
|
|
|
|
|
|
|
|
ld hl, WontObeyText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
call HitConfusion
|
2015-12-26 15:11:55 -08:00
|
|
|
jp .EndDisobedience
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Nap:
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
add a
|
|
|
|
swap a
|
2014-06-13 21:18:14 -07:00
|
|
|
and SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Nap
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleMonStatus], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, BeganToNapText
|
|
|
|
jr .Print
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoNothing:
|
2018-01-11 09:00:01 -08:00
|
|
|
; 4 random choices
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-11 09:00:01 -08:00
|
|
|
and %11
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, LoafingAroundText
|
2018-01-11 09:00:01 -08:00
|
|
|
and a ; 0
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Print
|
|
|
|
|
|
|
|
ld hl, WontObeyText
|
2018-01-11 09:00:01 -08:00
|
|
|
dec a ; 1
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Print
|
|
|
|
|
|
|
|
ld hl, TurnedAwayText
|
2018-01-11 09:00:01 -08:00
|
|
|
dec a ; 2
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Print
|
|
|
|
|
|
|
|
ld hl, IgnoredOrdersText
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Print:
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
jp .EndDisobedience
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.UseInstead:
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
; Can't use another move if the monster only has one!
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonMoves + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .DoNothing
|
|
|
|
|
|
|
|
; Don't bother trying to handle Disable.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wDisabledMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr nz, .DoNothing
|
|
|
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonPP
|
|
|
|
ld de, wBattleMonMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
ld c, NUM_MOVES
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GetTotalPP:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-11 09:00:01 -08:00
|
|
|
and PP_MASK
|
2013-03-26 17:39:44 -07:00
|
|
|
add b
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
dec c
|
|
|
|
jr z, .CheckMovePP
|
|
|
|
|
|
|
|
; Stop at undefined moves.
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
jr nz, .GetTotalPP
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.CheckMovePP:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonPP
|
|
|
|
ld a, [wCurMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
|
|
|
|
; Can't use another move if only one move has PP.
|
|
|
|
ld a, [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
and PP_MASK
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
|
|
|
jr z, .DoNothing
|
|
|
|
|
|
|
|
|
|
|
|
; Make sure we can actually use the move once we get there.
|
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAlreadyDisobeyed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-19 11:48:30 -08:00
|
|
|
ld a, [w2DMenuNumRows]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
|
|
|
|
; Save the move we originally picked for afterward.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
push af
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.RandomMove:
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-16 14:27:50 -08:00
|
|
|
maskbits NUM_MOVES
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp b
|
|
|
|
jr nc, .RandomMove
|
|
|
|
|
|
|
|
; Not the move we were trying to use.
|
|
|
|
cp c
|
|
|
|
jr z, .RandomMove
|
|
|
|
|
|
|
|
; Make sure it has PP.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurMoveNum], a
|
|
|
|
ld hl, wBattleMonPP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
and PP_MASK
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .RandomMove
|
|
|
|
|
|
|
|
|
|
|
|
; Use it.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPlayerMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call SetPlayerTurn
|
|
|
|
call UpdateMoveData
|
|
|
|
call DoMove
|
|
|
|
|
|
|
|
|
|
|
|
; Restore original move choice.
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurMoveNum], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.EndDisobedience:
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wLastPlayerMove], a
|
|
|
|
ld [wLastPlayerCounterMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-17 12:52:32 -07:00
|
|
|
; Break Encore too.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
res SUBSTATUS_ENCORED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPlayerEncoreCount], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3451f
|
|
|
|
|
|
|
|
|
|
|
|
IgnoreSleepOnly: ; 3451f
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-10 14:30:27 -08:00
|
|
|
; Snore and Sleep Talk bypass sleep.
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SNORE
|
|
|
|
jr z, .CheckSleep
|
|
|
|
cp SLEEP_TALK
|
|
|
|
jr z, .CheckSleep
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.CheckSleep:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-17 12:52:32 -07:00
|
|
|
and SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
; 'ignored orders…sleeping!'
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, IgnoredSleepingText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call EndMoveEffect
|
|
|
|
|
|
|
|
scf
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34541
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_UsedMoveText: ; 34541
|
2013-03-26 17:39:44 -07:00
|
|
|
; usedmovetext
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DisplayUsedMoveText
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34548
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
CheckUserIsCharging: ; 34548
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [wPlayerCharging] ; player
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .end
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [wEnemyCharging] ; enemy
|
2013-03-26 17:39:44 -07:00
|
|
|
.end
|
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34555
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DoTurn: ; 34555
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckUserIsCharging
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonPP
|
|
|
|
ld de, wPlayerSubStatus3
|
|
|
|
ld bc, wPlayerTurnsTaken
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr z, .proceed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonPP
|
|
|
|
ld de, wEnemySubStatus3
|
|
|
|
ld bc, wEnemyTurnsTaken
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
.proceed
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; If we've gotten this far, this counts as a turn.
|
|
|
|
ld a, [bc]
|
|
|
|
inc a
|
|
|
|
ld [bc], a
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp STRUGGLE
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, [de]
|
2014-08-13 19:44:56 -07:00
|
|
|
and 1 << SUBSTATUS_IN_LOOP | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_BIDE
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
call .consume_pp
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
jp nz, EndMoveEffect
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
; SubStatus5
|
2013-03-26 17:39:44 -07:00
|
|
|
inc de
|
2015-12-26 18:59:03 -08:00
|
|
|
inc de
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [de]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1PP
|
|
|
|
ld a, [wCurBattleMon]
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .player
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
; mimic this part entirely if wildbattle
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .wild
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wOTPartyMon1PP
|
|
|
|
ld a, [wCurOTMon]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.player
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetPartyLocation
|
|
|
|
push hl
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckMimicUsed
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.consume_pp
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurMoveNum]
|
2015-11-06 11:45:10 -08:00
|
|
|
jr z, .okay
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurEnemyMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
.okay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
and PP_MASK
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .out_of_pp
|
2013-03-26 17:39:44 -07:00
|
|
|
dec [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.wild
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMoves
|
|
|
|
ld a, [wCurEnemyMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp MIMIC
|
2015-11-06 11:45:10 -08:00
|
|
|
jr z, .mimic
|
2015-11-09 13:41:09 -08:00
|
|
|
ld hl, wWildMonMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp MIMIC
|
|
|
|
ret z
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
.mimic
|
2015-11-09 13:41:09 -08:00
|
|
|
ld hl, wWildMonPP
|
2015-11-06 17:55:16 -08:00
|
|
|
call .consume_pp
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.out_of_pp
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
; get move effect
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
; continuous?
|
|
|
|
ld hl, .continuousmoves
|
2013-03-27 13:19:51 -07:00
|
|
|
ld de, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
; 'has no pp left for [move]'
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, HasNoPPLeftText
|
2013-03-26 17:39:44 -07:00
|
|
|
jr c, .print
|
|
|
|
; 'but no pp is left for the move'
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, NoPPLeftText
|
2013-03-26 17:39:44 -07:00
|
|
|
.print
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-04-27 14:12:23 -07:00
|
|
|
ld b, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34602
|
|
|
|
|
|
|
|
.continuousmoves ; 34602
|
2013-04-27 14:12:23 -07:00
|
|
|
db EFFECT_RAZOR_WIND
|
|
|
|
db EFFECT_SKY_ATTACK
|
|
|
|
db EFFECT_SKULL_BASH
|
|
|
|
db EFFECT_SOLARBEAM
|
|
|
|
db EFFECT_FLY
|
|
|
|
db EFFECT_ROLLOUT
|
|
|
|
db EFFECT_BIDE
|
|
|
|
db EFFECT_RAMPAGE
|
2018-01-10 14:30:27 -08:00
|
|
|
db -1
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3460b
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
CheckMimicUsed: ; 3460b
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurMoveNum]
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .player
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurEnemyMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.player
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, MON_MOVES
|
2013-05-02 23:43:44 -07:00
|
|
|
call UserPartyAttr
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp MIMIC
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .mimic
|
2016-04-10 11:42:14 -07:00
|
|
|
;
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp MIMIC
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .mimic
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.mimic
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34631
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Critical: ; 34631
|
2013-03-26 17:39:44 -07:00
|
|
|
; critical
|
|
|
|
|
|
|
|
; Determine whether this attack's hit will be critical.
|
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCriticalHit], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_POWER
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonItem
|
|
|
|
ld a, [wEnemyMonSpecies]
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nz, .Item
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonItem
|
|
|
|
ld a, [wBattleMonSpecies]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Item:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, 0
|
|
|
|
|
|
|
|
cp CHANSEY
|
|
|
|
jr nz, .Farfetchd
|
|
|
|
ld a, [hl]
|
|
|
|
cp LUCKY_PUNCH
|
|
|
|
jr nz, .FocusEnergy
|
|
|
|
|
|
|
|
; +2 critical level
|
|
|
|
ld c, 2
|
|
|
|
jr .Tally
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Farfetchd:
|
2013-03-26 17:39:44 -07:00
|
|
|
cp FARFETCH_D
|
|
|
|
jr nz, .FocusEnergy
|
|
|
|
ld a, [hl]
|
|
|
|
cp STICK
|
|
|
|
jr nz, .FocusEnergy
|
|
|
|
|
|
|
|
; +2 critical level
|
|
|
|
ld c, 2
|
|
|
|
jr .Tally
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.FocusEnergy:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-23 12:47:07 -07:00
|
|
|
bit SUBSTATUS_FOCUS_ENERGY, a
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .CheckCritical
|
|
|
|
|
|
|
|
; +1 critical level
|
|
|
|
inc c
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.CheckCritical:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, 1
|
2018-01-10 14:30:27 -08:00
|
|
|
ld hl, CriticalHitMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
call IsInArray
|
|
|
|
pop bc
|
|
|
|
jr nc, .ScopeLens
|
|
|
|
|
|
|
|
; +2 critical level
|
|
|
|
inc c
|
2015-12-26 18:59:03 -08:00
|
|
|
inc c
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ScopeLens:
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
call GetUserItem
|
|
|
|
ld a, b
|
2014-01-19 21:07:51 -08:00
|
|
|
cp HELD_CRITICAL_UP ; Increased critical chance. Only Scope Lens has this.
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
jr nz, .Tally
|
|
|
|
|
|
|
|
; +1 critical level
|
|
|
|
inc c
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Tally:
|
2018-01-10 14:30:27 -08:00
|
|
|
ld hl, CriticalHitChances
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
|
|
|
ret nc
|
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCriticalHit], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2018-01-10 14:30:27 -08:00
|
|
|
INCLUDE "data/battle/critical_hits.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
; 346b2
|
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/triple_kick.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Stab: ; 346d2
|
2015-09-09 16:27:07 -07:00
|
|
|
; STAB = Same Type Attack Bonus
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp STRUGGLE
|
|
|
|
ret z
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
ld e, [hl]
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-09-09 16:27:07 -07:00
|
|
|
jr z, .go ; Who Attacks and who Defends
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
ld e, [hl]
|
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
.go
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DoWeatherModifiers
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
|
|
|
|
push de
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DoBadgeTypeBoosts
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wTypeMatchup]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2013-04-19 00:50:45 -07:00
|
|
|
jr z, .stab
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2013-04-19 00:50:45 -07:00
|
|
|
jr z, .stab
|
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
jr .SkipStab
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
.stab
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
add hl, bc
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurDamage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurDamage + 1], a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wTypeModifier
|
2013-03-26 17:39:44 -07:00
|
|
|
set 7, [hl]
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.SkipStab:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2017-12-26 14:47:05 -08:00
|
|
|
ld hl, TypeMatchups
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.TypesLoop:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -1
|
2013-04-19 00:50:45 -07:00
|
|
|
jr z, .end
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; foresight
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -2
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .SkipForesightCheck
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_IDENTIFIED, a
|
2013-04-19 00:50:45 -07:00
|
|
|
jr nz, .end
|
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
jr .TypesLoop
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.SkipForesightCheck:
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .SkipType
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
cp d
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .GotMatchup
|
2013-03-26 17:39:44 -07:00
|
|
|
cp e
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .GotMatchup
|
|
|
|
jr .SkipType
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GotMatchup:
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
inc hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and %10000000
|
|
|
|
ld b, a
|
2015-10-07 10:19:41 -07:00
|
|
|
; If the target is immune to the move, treat it as a miss and calculate the damage as 0
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .NotImmune
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAttackMissed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2016-04-10 11:42:14 -07:00
|
|
|
.NotImmune:
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
add b
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTypeModifier], a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 0], a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
call Multiply
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hProduct + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hProduct + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
|
|
|
ld b, a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hProduct + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .ok ; This is a very convoluted way to get back that we've essentially dealt no damage.
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
; Take the product and divide it by 10.
|
|
|
|
ld a, 10
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
2015-10-07 10:19:41 -07:00
|
|
|
ld b, 4
|
2013-05-02 23:43:44 -07:00
|
|
|
call Divide
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .ok
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
ld a, 1
|
|
|
|
ld [hMultiplicand + 2], a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
.ok
|
|
|
|
ld a, [hMultiplicand + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2015-10-07 10:19:41 -07:00
|
|
|
ld a, [hMultiplicand + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
pop bc
|
|
|
|
pop hl
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.SkipType:
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
inc hl
|
2015-10-07 10:19:41 -07:00
|
|
|
jr .TypesLoop
|
2013-04-19 00:50:45 -07:00
|
|
|
|
|
|
|
.end
|
2015-11-06 17:55:16 -08:00
|
|
|
call BattleCheckTypeMatchup
|
|
|
|
ld a, [wTypeMatchup]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2015-11-06 17:55:16 -08:00
|
|
|
and %10000000
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTypeModifier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 347c8
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
BattleCheckTypeMatchup: ; 347c8
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-16 11:30:10 -08:00
|
|
|
jr z, CheckTypeMatchup
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonType1
|
2018-01-16 11:30:10 -08:00
|
|
|
CheckTypeMatchup: ; 347d3
|
2017-01-07 16:33:38 -08:00
|
|
|
; There is an incorrect assumption about this function made in the AI related code: when
|
2018-02-03 17:40:21 -08:00
|
|
|
; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing the
|
|
|
|
; offensive type in a will make this function do the right thing. Since a is overwritten,
|
2017-01-07 16:33:38 -08:00
|
|
|
; this assumption is incorrect. A simple fix would be to load the move type for the
|
|
|
|
; current move into a in BattleCheckTypeMatchup, before falling through, which is
|
|
|
|
; consistent with how the rest of the code assumes this code works like.
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2013-05-02 23:43:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
2014-06-18 00:55:44 -07:00
|
|
|
ld a, 10 ; 1.0
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2017-12-26 14:47:05 -08:00
|
|
|
ld hl, TypeMatchups
|
2016-04-10 11:42:14 -07:00
|
|
|
.TypesLoop:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -1
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .End
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -2
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .Next
|
2013-05-02 23:43:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_IDENTIFIED, a
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .End
|
|
|
|
jr .TypesLoop
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Next:
|
2013-03-26 17:39:44 -07:00
|
|
|
cp d
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .Nope
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .Yup
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .Yup
|
|
|
|
jr .Nope2
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Nope:
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2016-04-10 11:42:14 -07:00
|
|
|
.Nope2:
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2015-10-07 10:19:41 -07:00
|
|
|
jr .TypesLoop
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Yup:
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDividend + 0], a
|
|
|
|
ld [hMultiplicand + 0], a
|
|
|
|
ld [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wTypeMatchup]
|
2014-08-13 19:44:56 -07:00
|
|
|
ld [hMultiplier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call Multiply
|
2014-08-13 19:44:56 -07:00
|
|
|
ld a, 10
|
|
|
|
ld [hDivisor], a
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2014-08-13 19:44:56 -07:00
|
|
|
ld b, 4
|
2013-03-26 17:39:44 -07:00
|
|
|
call Divide
|
|
|
|
pop bc
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2015-10-07 10:19:41 -07:00
|
|
|
jr .TypesLoop
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.End:
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34833
|
|
|
|
|
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
BattleCommand_ResetTypeMatchup: ; 34833
|
|
|
|
; Reset the type matchup multiplier to 1.0, if the type matchup is not 0.
|
|
|
|
; If there is immunity in play, the move automatically misses.
|
2015-11-06 17:55:16 -08:00
|
|
|
call BattleCheckTypeMatchup
|
|
|
|
ld a, [wTypeMatchup]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-23 12:47:07 -07:00
|
|
|
ld a, 10 ; 1.0
|
2015-11-07 05:05:57 -08:00
|
|
|
jr nz, .reset
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetDamage
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTypeModifier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAttackMissed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-11-06 17:55:16 -08:00
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
.reset
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3484e
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
|
2017-12-26 14:47:05 -08:00
|
|
|
INCLUDE "engine/battle/ai/switch.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-22 13:23:34 -08:00
|
|
|
INCLUDE "data/types/type_matchups.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DamageVariation: ; 34cfd
|
2013-03-26 17:39:44 -07:00
|
|
|
; damagevariation
|
|
|
|
|
|
|
|
; Modify the damage spread between 85% and 100%.
|
|
|
|
|
|
|
|
; Because of the method of division the probability distribution
|
|
|
|
; is not consistent. This makes the highest damage multipliers
|
|
|
|
; rarer than normal.
|
|
|
|
|
|
|
|
|
|
|
|
; No point in reducing 1 or 0 damage.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr nz, .go
|
|
|
|
ld a, [hl]
|
|
|
|
cp 2
|
|
|
|
ret c
|
|
|
|
|
|
|
|
.go
|
|
|
|
; Start with the maximum damage.
|
|
|
|
xor a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 0], a
|
2013-03-26 17:39:44 -07:00
|
|
|
dec hl
|
|
|
|
ld a, [hli]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
; Multiply by 85-100%...
|
|
|
|
.loop
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
rrca
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 85 percent + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
jr c, .loop
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call Multiply
|
|
|
|
|
|
|
|
; ...divide by 100%...
|
|
|
|
ld a, $ff ; 100%
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, $4
|
|
|
|
call Divide
|
|
|
|
|
|
|
|
; ...to get .85-1.00x damage.
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 1]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34d32
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_CheckHit: ; 34d32
|
2013-03-26 17:39:44 -07:00
|
|
|
; checkhit
|
|
|
|
|
|
|
|
call .DreamEater
|
|
|
|
jp z, .Miss
|
|
|
|
|
|
|
|
call .Protect
|
|
|
|
jp nz, .Miss
|
|
|
|
|
|
|
|
call .DrainSub
|
|
|
|
jp z, .Miss
|
|
|
|
|
|
|
|
call .LockOn
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
call .FlyDigMoves
|
|
|
|
jp nz, .Miss
|
|
|
|
|
|
|
|
call .ThunderRain
|
|
|
|
ret z
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call .XAccuracy
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2014-06-23 12:47:07 -07:00
|
|
|
; Perfect-accuracy moves
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_ALWAYS_HIT
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
call .StatModifiers
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wPlayerMoveStruct + MOVE_ACC]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .BrightPowder
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_ACC]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.BrightPowder:
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2013-05-02 22:29:57 -07:00
|
|
|
cp HELD_BRIGHTPOWDER
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c ; % miss
|
|
|
|
pop bc
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .skip_brightpowder
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld c, a
|
|
|
|
ld a, b
|
|
|
|
sub c
|
|
|
|
ld b, a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .skip_brightpowder
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.skip_brightpowder
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -1
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Hit
|
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
|
|
|
jr nc, .Miss
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Hit:
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Miss:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Keep the damage value intact if we're using (Hi) Jump Kick.
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_JUMP_KICK
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Missed
|
|
|
|
call ResetDamage
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Missed:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAttackMissed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DreamEater:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return z if we're trying to eat the dream of
|
|
|
|
; a monster that isn't sleeping.
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_DREAM_EATER
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
and SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Protect:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return nz if the opponent is protected.
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_PROTECT, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
ld c, 40
|
|
|
|
call DelayFrames
|
|
|
|
|
|
|
|
; 'protecting itself!'
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, ProtectingItselfText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld c, 40
|
|
|
|
call DelayFrames
|
|
|
|
|
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.LockOn:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return nz if we are locked-on and aren't trying to use Earthquake,
|
|
|
|
; Fissure or Magnitude on a monster that is flying.
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_LOCK_ON, [hl]
|
|
|
|
res SUBSTATUS_LOCK_ON, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_FLYING, a
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .LockedOn
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp EARTHQUAKE
|
|
|
|
ret z
|
|
|
|
cp FISSURE
|
|
|
|
ret z
|
|
|
|
cp MAGNITUDE
|
|
|
|
ret z
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.LockedOn:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DrainSub:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return z if using an HP drain move on a substitute.
|
2013-05-02 23:43:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .not_draining_sub
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_LEECH_HIT
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_DREAM_EATER
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.not_draining_sub
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.FlyDigMoves:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Check for moves that can hit underground/flying opponents.
|
|
|
|
; Return z if the current move can hit the opponent.
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_FLYING, a
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .DigMoves
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp GUST
|
|
|
|
ret z
|
|
|
|
cp WHIRLWIND
|
|
|
|
ret z
|
|
|
|
cp THUNDER
|
|
|
|
ret z
|
|
|
|
cp TWISTER
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DigMoves:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp EARTHQUAKE
|
|
|
|
ret z
|
|
|
|
cp FISSURE
|
|
|
|
ret z
|
|
|
|
cp MAGNITUDE
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ThunderRain:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return z if the current move always hits in rain, and it is raining.
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_THUNDER
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2018-01-23 13:45:34 -08:00
|
|
|
ld a, [wBattleWeather]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp WEATHER_RAIN
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.XAccuracy:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-08-13 19:44:56 -07:00
|
|
|
bit SUBSTATUS_X_ACCURACY, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.StatModifiers:
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
; load the user's accuracy into b and the opponent's evasion into c.
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, wPlayerMoveStruct + MOVE_ACC
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerAccLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyEvaLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_acc_eva
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, wEnemyMoveStruct + MOVE_ACC
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyAccLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerEvaLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_acc_eva
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2016-01-17 21:39:01 -08:00
|
|
|
jr c, .skip_foresight_check
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
; if the target's evasion is greater than the user's accuracy,
|
|
|
|
; check the target's foresight status
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_IDENTIFIED, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
.skip_foresight_check
|
|
|
|
; subtract evasion from 14
|
2018-01-10 14:30:27 -08:00
|
|
|
ld a, MAX_STAT_LEVEL + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
sub c
|
|
|
|
ld c, a
|
2016-01-17 21:39:01 -08:00
|
|
|
; store the base move accuracy for math ops
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 0], a
|
|
|
|
ld [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
2016-01-17 21:39:01 -08:00
|
|
|
ld d, 2 ; do this twice, once for the user's accuracy and once for the target's evasion
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.accuracy_loop
|
2016-01-17 21:39:01 -08:00
|
|
|
; look up the multiplier from the table
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2018-01-10 14:30:27 -08:00
|
|
|
ld hl, AccuracyLevelMultipliers
|
2013-03-26 17:39:44 -07:00
|
|
|
dec b
|
|
|
|
sla b
|
|
|
|
ld c, b
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
2016-01-17 21:39:01 -08:00
|
|
|
; multiply by the first byte in that row...
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call Multiply
|
2016-01-17 21:39:01 -08:00
|
|
|
; ... and divide by the second byte
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
2015-12-26 15:11:55 -08:00
|
|
|
ld b, 4
|
2013-03-26 17:39:44 -07:00
|
|
|
call Divide
|
2016-01-17 21:39:01 -08:00
|
|
|
; minimum accuracy is $0001
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .min_accuracy
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hQuotient + 1], a
|
2016-01-17 21:39:01 -08:00
|
|
|
ld a, 1
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hQuotient + 2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.min_accuracy
|
2016-01-17 21:39:01 -08:00
|
|
|
; do the same thing to the target's evasion
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, c
|
|
|
|
dec d
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .accuracy_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
; if the result is more than 2 bytes, max out at 100%
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hQuotient + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hQuotient + 2]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .finish_accuracy
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $ff
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.finish_accuracy
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-01-10 14:30:27 -08:00
|
|
|
INCLUDE "data/battle/accuracy_multipliers.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34ecc
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_EffectChance: ; 34ecc
|
2013-03-26 22:52:04 -07:00
|
|
|
; effectchance
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEffectFailed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2013-03-26 22:52:04 -07:00
|
|
|
jr nz, .failed
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, wPlayerMoveStruct + MOVE_CHANCE
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_move_chance
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, wEnemyMoveStruct + MOVE_CHANCE
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_move_chance
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
|
|
|
pop hl
|
|
|
|
ret c
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
.failed
|
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEffectFailed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34eee
|
|
|
|
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
BattleCommand_LowerSub: ; 34eee
|
2014-01-01 05:09:15 -08:00
|
|
|
; lowersub
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_CHARGED, a
|
2015-11-06 13:42:38 -08:00
|
|
|
jr nz, .already_charged
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_RAZOR_WIND
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_SKY_ATTACK
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_SKULL_BASH
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_SOLARBEAM
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_FLY
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
.already_charged
|
2013-03-26 17:39:44 -07:00
|
|
|
call .Rampage
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckUserIsCharging
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
.charge_turn
|
2015-11-06 19:36:06 -08:00
|
|
|
call _CheckBattleScene
|
2015-11-09 13:41:09 -08:00
|
|
|
jr c, .mimic_anims
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2014-01-01 05:09:15 -08:00
|
|
|
ld a, SUBSTITUTE
|
2015-11-09 13:41:09 -08:00
|
|
|
jp LoadAnim
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.mimic_anims
|
2015-11-06 19:36:06 -08:00
|
|
|
call BattleCommand_LowerSubNoAnim
|
2015-11-06 11:45:10 -08:00
|
|
|
jp BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Rampage:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_ROLLOUT
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .rollout_rampage
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_RAMPAGE
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .rollout_rampage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
.rollout_rampage
|
2016-01-09 13:28:22 -08:00
|
|
|
ld a, [wSomeoneIsRampaging]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ld a, 0
|
2016-01-09 13:28:22 -08:00
|
|
|
ld [wSomeoneIsRampaging], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34f57
|
|
|
|
|
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
BattleCommand_MoveAnim: ; 34f57
|
|
|
|
; moveanim
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2018-04-04 14:27:40 -07:00
|
|
|
call BattleCommand_MoveAnimNoSub
|
2015-11-06 13:42:38 -08:00
|
|
|
jp BattleCommand_RaiseSub
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34f60
|
|
|
|
|
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
BattleCommand_MoveAnimNoSub: ; 34f60
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 11:45:10 -08:00
|
|
|
jp nz, BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wPlayerRolloutCount
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_ENEMY_DAMAGE
|
2015-11-07 05:05:57 -08:00
|
|
|
jr z, .got_rollout_count
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wEnemyRolloutCount
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_PLAYER_DAMAGE
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
.got_rollout_count
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_MULTI_HIT
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .alternate_anim
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_CONVERSION
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .alternate_anim
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_DOUBLE_HIT
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .alternate_anim
|
2017-11-15 07:36:13 -08:00
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .alternate_anim
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_TRIPLE_KICK
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .triplekick
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
.triplekick
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
call PlayFXAnimID
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp FLY
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .clear_sprite
|
2013-03-26 17:39:44 -07:00
|
|
|
cp DIG
|
|
|
|
ret nz
|
2018-01-26 08:36:00 -08:00
|
|
|
.clear_sprite
|
2015-11-09 13:41:09 -08:00
|
|
|
jp AppearUserLowerSub
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.alternate_anim
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wKickCounter]
|
2013-05-02 23:43:44 -07:00
|
|
|
and 1
|
|
|
|
xor 1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 1
|
2013-03-26 17:39:44 -07:00
|
|
|
push af
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
2013-05-02 23:43:44 -07:00
|
|
|
ld d, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
|
|
|
jp z, PlayFXAnimID
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
jp PlayFXAnimID
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34fd1
|
|
|
|
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
BattleCommand_StatUpAnim: ; 34fd1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 11:45:10 -08:00
|
|
|
jp nz, BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2015-11-06 13:42:38 -08:00
|
|
|
jr BattleCommand_StatUpDownAnim
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34fdb
|
|
|
|
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
BattleCommand_StatDownAnim: ; 34fdb
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 11:45:10 -08:00
|
|
|
jp nz, BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_ENEMY_STAT_DOWN
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, BattleCommand_StatUpDownAnim
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_WOBBLE
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 34feb
|
|
|
|
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
BattleCommand_StatUpDownAnim: ; 34feb
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
jp PlayFXAnimID
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 34ffd
|
|
|
|
|
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
BattleCommand_SwitchTurn: ; 34ffd
|
2013-03-26 22:52:04 -07:00
|
|
|
; switchturn
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
2013-03-26 22:52:04 -07:00
|
|
|
xor 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hBattleTurn], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35004
|
|
|
|
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
BattleCommand_RaiseSub: ; 35004
|
2014-01-01 05:09:15 -08:00
|
|
|
; raisesub
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
call _CheckBattleScene
|
|
|
|
jp c, BattleCommand_RaiseSubNoAnim
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $2
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2014-01-01 05:09:15 -08:00
|
|
|
ld a, SUBSTITUTE
|
2015-11-09 13:41:09 -08:00
|
|
|
jp LoadAnim
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35023
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
BattleCommand_FailureText: ; 35023
|
|
|
|
; failuretext
|
|
|
|
; If the move missed or failed, load the appropriate
|
|
|
|
; text, and end the effects of multi-turn or multi-
|
|
|
|
; hit moves.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call GetFailureResultText
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
cp FLY
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fly_dig
|
2013-03-26 22:52:04 -07:00
|
|
|
cp DIG
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fly_dig
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-27 14:33:29 -07:00
|
|
|
; Move effect:
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_MULTI_HIT
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .multihit
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_DOUBLE_HIT
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .multihit
|
2017-11-15 07:36:13 -08:00
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .multihit
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.multihit
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.fly_dig
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-05-02 23:43:44 -07:00
|
|
|
res SUBSTATUS_UNDERGROUND, [hl]
|
|
|
|
res SUBSTATUS_FLYING, [hl]
|
2015-11-09 13:41:09 -08:00
|
|
|
call AppearUserRaiseSub
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3505e
|
|
|
|
|
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
BattleCommand_ApplyDamage: ; 3505e
|
|
|
|
; applydamage
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_ENDURE, a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr z, .focus_band
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_FalseSwipe
|
2018-04-04 14:27:40 -07:00
|
|
|
ld b, 0
|
|
|
|
jr nc, .damage
|
|
|
|
ld b, 1
|
|
|
|
jr .damage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.focus_band
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2013-05-02 22:29:57 -07:00
|
|
|
cp HELD_FOCUS_BAND
|
2018-04-04 14:27:40 -07:00
|
|
|
ld b, 0
|
|
|
|
jr nz, .damage
|
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nc, .damage
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_FalseSwipe
|
2018-04-04 14:27:40 -07:00
|
|
|
ld b, 0
|
|
|
|
jr nc, .damage
|
|
|
|
ld b, 2
|
|
|
|
|
|
|
|
.damage
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2018-04-04 14:27:40 -07:00
|
|
|
call .update_damage_taken
|
|
|
|
ld c, FALSE
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .damage_player
|
2018-04-04 14:27:40 -07:00
|
|
|
call DoEnemyDamage
|
2015-11-09 13:41:09 -08:00
|
|
|
jr .done_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.damage_player
|
2018-04-04 14:27:40 -07:00
|
|
|
call DoPlayerDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.done_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
ret z
|
2018-04-04 14:27:40 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nz, .focus_band_text
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, EnduredText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.focus_band_text
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, [hl]
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-05-02 22:29:57 -07:00
|
|
|
call GetItemName
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, HungOnText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.update_damage_taken
|
2013-05-02 22:29:57 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 22:29:57 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2013-05-02 22:29:57 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wPlayerDamageTaken + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nz, .got_damage_taken
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wEnemyDamageTaken + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.got_damage_taken
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
|
|
|
add b
|
|
|
|
ld [de], a
|
|
|
|
dec de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
|
|
|
adc b
|
|
|
|
ld [de], a
|
|
|
|
ret nc
|
|
|
|
ld a, $ff
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 350e4
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
GetFailureResultText: ; 350e4
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, DoesntAffectText
|
|
|
|
ld de, DoesntAffectText
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7f
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .got_text
|
2013-05-02 23:43:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_FUTURE_SIGHT
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, ButItFailedText
|
|
|
|
ld de, ItFailedText
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .got_text
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, AttackMissedText
|
|
|
|
ld de, AttackMissed2Text
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCriticalHit]
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -1
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .got_text
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, UnaffectedText
|
2015-11-09 13:41:09 -08:00
|
|
|
.got_text
|
|
|
|
call FailText_CheckOpponentProtect
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCriticalHit], a
|
2014-06-23 12:47:07 -07:00
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_JUMP_KICK
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7f
|
|
|
|
ret z
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, [hl]
|
2018-05-06 09:16:57 -07:00
|
|
|
rept 3
|
2013-03-26 17:39:44 -07:00
|
|
|
srl a
|
|
|
|
rr b
|
2018-05-06 09:16:57 -07:00
|
|
|
endr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], b
|
|
|
|
dec hl
|
|
|
|
ld [hli], a
|
|
|
|
or b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .do_at_least_1_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
|
|
|
ld [hl], a
|
2015-11-09 13:41:09 -08:00
|
|
|
.do_at_least_1_damage
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, CrashedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2015-11-09 13:41:09 -08:00
|
|
|
call LoadMoveAnim
|
2018-04-04 14:27:40 -07:00
|
|
|
ld c, TRUE
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-04-04 14:27:40 -07:00
|
|
|
jp nz, DoEnemyDamage
|
|
|
|
jp DoPlayerDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
FailText_CheckOpponentProtect: ; 35157
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_PROTECT, a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .not_protected
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, d
|
|
|
|
ld l, e
|
2015-11-09 13:41:09 -08:00
|
|
|
.not_protected
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35165
|
|
|
|
|
|
|
|
|
2018-03-29 01:57:55 -07:00
|
|
|
BattleCommand_BideFailText: ; 35165
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7f
|
|
|
|
jp z, PrintDoesntAffect
|
2013-03-27 15:50:10 -07:00
|
|
|
jp PrintButItFailed
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35175
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_CriticalText: ; 35175
|
2013-03-26 17:39:44 -07:00
|
|
|
; criticaltext
|
|
|
|
; Prints the message for critical hits or one-hit KOs.
|
|
|
|
|
|
|
|
; If there is no message to be printed, wait 20 frames.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCriticalHit]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .wait
|
|
|
|
|
|
|
|
dec a
|
|
|
|
add a
|
2014-06-23 12:47:07 -07:00
|
|
|
ld hl, .texts
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
ld c, a
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCriticalHit], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
.wait
|
|
|
|
ld c, 20
|
|
|
|
jp DelayFrames
|
|
|
|
|
2014-06-23 12:47:07 -07:00
|
|
|
.texts
|
|
|
|
dw CriticalHitText
|
|
|
|
dw OneHitKOText
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35197
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_StartLoop: ; 35197
|
2013-03-26 22:52:04 -07:00
|
|
|
; startloop
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerRolloutCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-23 12:47:07 -07:00
|
|
|
jr z, .ok
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyRolloutCount
|
2014-06-23 12:47:07 -07:00
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 351a5
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SuperEffectiveLoopText: ; 351a5
|
2013-03-26 22:52:04 -07:00
|
|
|
; supereffectivelooptext
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-23 12:47:07 -07:00
|
|
|
bit SUBSTATUS_IN_LOOP, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 351ad
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SuperEffectiveText: ; 351ad
|
2013-03-26 22:52:04 -07:00
|
|
|
; supereffectivetext
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7f
|
|
|
|
cp 10 ; 1.0
|
|
|
|
ret z
|
2014-06-23 12:47:07 -07:00
|
|
|
ld hl, SuperEffectiveText
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nc, .print
|
2014-06-23 12:47:07 -07:00
|
|
|
ld hl, NotVeryEffectiveText
|
2013-03-26 17:39:44 -07:00
|
|
|
.print
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 351c0
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_CheckDestinyBond: ; 351c0
|
2013-03-26 22:52:04 -07:00
|
|
|
; checkdestinybond
|
|
|
|
|
|
|
|
; Faint the user if it fainted an opponent using Destiny Bond.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_hp
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonHP
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_hp
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
ret nz
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_DESTINY_BOND, a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .no_dbond
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, TookDownWithItText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMaxHP + 1
|
2013-04-27 14:12:23 -07:00
|
|
|
bccoord 2, 2 ; hp bar
|
|
|
|
ld a, 0
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .got_max_hp
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonMaxHP + 1
|
2013-04-27 14:12:23 -07:00
|
|
|
bccoord 10, 9 ; hp bar
|
|
|
|
ld a, 1
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_max_hp
|
|
|
|
ld [wWhichHPBar], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer3], a
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hld], a
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer4], a
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer5], a
|
|
|
|
ld [wBuffer6], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, b
|
|
|
|
ld l, c
|
2018-01-16 11:30:10 -08:00
|
|
|
predef AnimateHPBar
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
|
|
|
ld a, DESTINY_BOND
|
2015-11-09 13:41:09 -08:00
|
|
|
call LoadAnim
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .finish
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.no_dbond
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_MULTI_HIT
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .multiple_hit_raise_sub
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_DOUBLE_HIT
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .multiple_hit_raise_sub
|
2017-11-15 07:36:13 -08:00
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .multiple_hit_raise_sub
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_TRIPLE_KICK
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .multiple_hit_raise_sub
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_BEAT_UP
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .finish
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.multiple_hit_raise_sub
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.finish
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35250
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_BuildOpponentRage: ; 35250
|
2013-03-26 22:52:04 -07:00
|
|
|
; buildopponentrage
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
jp .start
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
.start
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_RAGE, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-05 16:13:09 -08:00
|
|
|
ld de, wEnemyRageCounter
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-05 16:13:09 -08:00
|
|
|
jr z, .player
|
|
|
|
ld de, wPlayerRageCounter
|
|
|
|
.player
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
inc a
|
|
|
|
ret z
|
|
|
|
ld [de], a
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, RageBuildingText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2015-10-10 04:45:39 -07:00
|
|
|
jp BattleCommand_SwitchTurn
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3527b
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_RageDamage: ; 3527b
|
2013-03-26 22:52:04 -07:00
|
|
|
; ragedamage
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, a
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld l, a
|
|
|
|
ld c, a
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-05 16:13:09 -08:00
|
|
|
ld a, [wPlayerRageCounter]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .rage_loop
|
2015-11-05 16:13:09 -08:00
|
|
|
ld a, [wEnemyRageCounter]
|
2015-12-26 15:11:55 -08:00
|
|
|
.rage_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
|
|
|
add hl, bc
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .rage_loop
|
2018-01-25 18:34:42 -08:00
|
|
|
ld hl, $ffff
|
2015-12-26 15:11:55 -08:00
|
|
|
.done
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurDamage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurDamage + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 352a3
|
|
|
|
|
|
|
|
|
|
|
|
EndMoveEffect: ; 352a3
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld l, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, a
|
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
2015-12-26 18:59:03 -08:00
|
|
|
ld [hli], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 352b1
|
|
|
|
|
|
|
|
|
|
|
|
DittoMetalPowder: ; 352b1
|
2015-11-04 08:19:58 -08:00
|
|
|
ld a, MON_SPECIES
|
2013-03-26 17:39:44 -07:00
|
|
|
call BattlePartyAttr
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
ld a, [hl]
|
|
|
|
jr nz, .Ditto
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Ditto:
|
2013-03-26 17:39:44 -07:00
|
|
|
cp DITTO
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
push bc
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, [hl]
|
|
|
|
cp METAL_POWDER
|
|
|
|
pop bc
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
ld a, c
|
|
|
|
srl a
|
|
|
|
add c
|
|
|
|
ld c, a
|
|
|
|
ret nc
|
|
|
|
|
|
|
|
srl b
|
|
|
|
ld a, b
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
inc b
|
2015-12-26 15:11:55 -08:00
|
|
|
.done
|
2013-03-26 17:39:44 -07:00
|
|
|
scf
|
|
|
|
rr c
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 352dc
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DamageStats: ; 352dc
|
2013-04-19 23:53:08 -07:00
|
|
|
; damagestats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jp nz, EnemyAttackDamage
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 352e2
|
|
|
|
|
|
|
|
|
|
|
|
PlayerAttackDamage: ; 352e2
|
2013-04-19 23:53:08 -07:00
|
|
|
; Return move power d, player level e, enemy defense c and player attack b.
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call ResetDamage
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2016-01-09 16:34:14 -08:00
|
|
|
ld hl, wPlayerMoveStructPower
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
ld d, a
|
|
|
|
ret z
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-01-05 05:24:27 -08:00
|
|
|
cp SPECIAL
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nc, .special
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.physical
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyScreens]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SCREENS_REFLECT, a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .physicalcrit
|
2013-03-26 17:39:44 -07:00
|
|
|
sla c
|
|
|
|
rl b
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
.physicalcrit
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonAttack
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetDamageStatsCritical
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .thickclub
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerAttack
|
2013-04-19 23:53:08 -07:00
|
|
|
jr .thickclub
|
|
|
|
|
|
|
|
.special
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonSpclDef
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyScreens]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SCREENS_LIGHT_SCREEN, a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .specialcrit
|
2013-03-26 17:39:44 -07:00
|
|
|
sla c
|
|
|
|
rl b
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
.specialcrit
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonSpclAtk
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetDamageStatsCritical
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .lightball
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySpDef
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSpAtk
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
.lightball
|
|
|
|
; Note: Returns player special attack at hl in hl.
|
2013-03-27 15:50:10 -07:00
|
|
|
call LightBallBoost
|
2013-04-19 23:53:08 -07:00
|
|
|
jr .done
|
|
|
|
|
|
|
|
.thickclub
|
|
|
|
; Note: Returns player attack at hl in hl.
|
2013-03-27 15:50:10 -07:00
|
|
|
call ThickClubBoost
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
.done
|
2015-11-09 13:41:09 -08:00
|
|
|
call TruncateHL_BC
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
|
|
|
call DittoMetalPowder
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; 3534d
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
TruncateHL_BC: ; 3534d
|
|
|
|
.loop
|
2013-04-19 23:53:08 -07:00
|
|
|
; Truncate 16-bit values hl and bc to 8-bit values b and c respectively.
|
|
|
|
; b = hl, c = bc
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
|
|
|
or b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .finish
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
srl b
|
|
|
|
rr c
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c
|
|
|
|
or b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .done_bc
|
2013-03-26 17:39:44 -07:00
|
|
|
inc c
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.done_bc
|
2013-03-26 17:39:44 -07:00
|
|
|
srl h
|
|
|
|
rr l
|
|
|
|
srl h
|
|
|
|
rr l
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, l
|
|
|
|
or h
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .finish
|
2013-03-26 17:39:44 -07:00
|
|
|
inc l
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.finish
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-04-19 23:53:08 -07:00
|
|
|
cp 3
|
|
|
|
jr z, .done
|
2016-03-08 16:54:06 -08:00
|
|
|
; If we go back to the loop point,
|
|
|
|
; it's the same as doing this exact
|
|
|
|
; same check twice.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
|
|
|
or b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .loop
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
.done
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, l
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35378
|
|
|
|
|
|
|
|
|
|
|
|
GetDamageStatsCritical: ; 35378
|
|
|
|
; Return carry if non-critical.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCriticalHit]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
scf
|
|
|
|
ret z
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 3537e
|
|
|
|
|
|
|
|
|
|
|
|
GetDamageStats: ; 3537e
|
|
|
|
; Return the attacker's offensive stat and the defender's defensive
|
|
|
|
; stat based on whether the attacking type is physical or special.
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr nz, .enemy
|
2016-01-09 16:34:14 -08:00
|
|
|
ld a, [wPlayerMoveStructType]
|
2014-01-05 05:24:27 -08:00
|
|
|
cp SPECIAL
|
2013-03-26 17:39:44 -07:00
|
|
|
; special
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSAtkLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySDefLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nc, .end
|
|
|
|
; physical
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerAtkLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyDefLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
jr .end
|
|
|
|
|
|
|
|
.enemy
|
2016-01-09 16:34:14 -08:00
|
|
|
ld a, [wEnemyMoveStructType]
|
2014-01-05 05:24:27 -08:00
|
|
|
cp SPECIAL
|
2013-03-26 17:39:44 -07:00
|
|
|
; special
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySAtkLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSDefLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nc, .end
|
|
|
|
; physical
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyAtkLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerDefLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
.end
|
|
|
|
cp b
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 353b5
|
|
|
|
|
|
|
|
|
|
|
|
ThickClubBoost: ; 353b5
|
2013-04-19 23:29:39 -07:00
|
|
|
; Return in hl the stat value at hl.
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; If the attacking monster is Cubone or Marowak and
|
2013-04-19 23:29:39 -07:00
|
|
|
; it's holding a Thick Club, double it.
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
ld b, CUBONE
|
|
|
|
ld c, MAROWAK
|
|
|
|
ld d, THICK_CLUB
|
|
|
|
call SpeciesItemBoost
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 353c3
|
|
|
|
|
|
|
|
|
|
|
|
LightBallBoost: ; 353c3
|
2013-04-19 23:29:39 -07:00
|
|
|
; Return in hl the stat value at hl.
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; If the attacking monster is Pikachu and it's
|
2013-04-19 23:29:39 -07:00
|
|
|
; holding a Light Ball, double it.
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
ld b, PIKACHU
|
|
|
|
ld c, PIKACHU
|
|
|
|
ld d, LIGHT_BALL
|
|
|
|
call SpeciesItemBoost
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 353d1
|
|
|
|
|
|
|
|
|
|
|
|
SpeciesItemBoost: ; 353d1
|
2013-04-19 23:29:39 -07:00
|
|
|
; Return in hl the stat value at hl.
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; If the attacking monster is species b or c and
|
2013-04-19 23:29:39 -07:00
|
|
|
; it's holding item d, double it.
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
ld l, [hl]
|
|
|
|
ld h, a
|
|
|
|
|
|
|
|
push hl
|
2015-11-04 08:19:58 -08:00
|
|
|
ld a, MON_SPECIES
|
2013-03-26 17:39:44 -07:00
|
|
|
call BattlePartyAttr
|
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
ld a, [hl]
|
|
|
|
jr z, .CompareSpecies
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2016-04-10 11:42:14 -07:00
|
|
|
.CompareSpecies:
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
|
|
|
|
cp b
|
2015-11-10 08:05:26 -08:00
|
|
|
jr z, .GetItemHeldEffect
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
|
|
|
ret nz
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GetItemHeldEffect:
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
call GetUserItem
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
cp d
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
; Double the stat
|
|
|
|
sla l
|
|
|
|
rl h
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 353f6
|
|
|
|
|
|
|
|
|
|
|
|
EnemyAttackDamage: ; 353f6
|
|
|
|
call ResetDamage
|
|
|
|
|
|
|
|
; No damage dealt with 0 power.
|
2016-01-09 16:34:14 -08:00
|
|
|
ld hl, wEnemyMoveStructPower
|
|
|
|
ld a, [hli] ; hl = wEnemyMoveStructType
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, [hl]
|
2014-01-05 05:24:27 -08:00
|
|
|
cp SPECIAL
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nc, .Special
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.physical
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerScreens]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SCREENS_REFLECT, a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .physicalcrit
|
2013-03-26 17:39:44 -07:00
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
.physicalcrit
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonAttack
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetDamageStatsCritical
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .thickclub
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyAttack
|
2013-04-19 23:53:08 -07:00
|
|
|
jr .thickclub
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Special:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonSpclDef
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerScreens]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SCREENS_LIGHT_SCREEN, a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .specialcrit
|
2013-03-26 17:39:44 -07:00
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
.specialcrit
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonSpclAtk
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetDamageStatsCritical
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .lightball
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSpDef
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySpAtk
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
.lightball
|
2013-03-27 15:50:10 -07:00
|
|
|
call LightBallBoost
|
2013-04-19 23:53:08 -07:00
|
|
|
jr .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
.thickclub
|
2013-03-27 15:50:10 -07:00
|
|
|
call ThickClubBoost
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
.done
|
2015-11-09 13:41:09 -08:00
|
|
|
call TruncateHL_BC
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
2013-03-27 15:50:10 -07:00
|
|
|
call DittoMetalPowder
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35461
|
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/beat_up.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_ClearMissDamage: ; 355d5
|
2013-03-26 22:52:04 -07:00
|
|
|
; clearmissdamage
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2015-09-09 16:27:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
jp ResetDamage
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 355dd
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
HitSelfInConfusion: ; 355dd
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetDamage
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonDefense
|
|
|
|
ld de, wPlayerScreens
|
|
|
|
ld a, [wBattleMonLevel]
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .got_it
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonDefense
|
|
|
|
ld de, wEnemyScreens
|
|
|
|
ld a, [wEnemyMonLevel]
|
2015-11-09 13:41:09 -08:00
|
|
|
.got_it
|
2013-03-26 17:39:44 -07:00
|
|
|
push af
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
ld a, [de]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SCREENS_REFLECT, a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .mimic_screen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
sla c
|
|
|
|
rl b
|
2015-11-09 13:41:09 -08:00
|
|
|
.mimic_screen
|
2013-03-26 17:39:44 -07:00
|
|
|
dec hl
|
2016-05-10 09:31:49 -07:00
|
|
|
dec hl
|
|
|
|
dec hl
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld l, [hl]
|
|
|
|
ld h, a
|
2015-11-09 13:41:09 -08:00
|
|
|
call TruncateHL_BC
|
2016-01-09 16:34:14 -08:00
|
|
|
ld d, 40
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
|
|
|
ld e, a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35612
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DamageCalc: ; 35612
|
2013-04-19 23:53:08 -07:00
|
|
|
; damagecalc
|
|
|
|
|
|
|
|
; Return a damage value for move power d, player level e, enemy defense c and player attack b.
|
|
|
|
|
|
|
|
; Return 1 if successful, else 0.
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; Selfdestruct and Explosion halve defense.
|
2017-11-15 07:36:13 -08:00
|
|
|
cp EFFECT_SELFDESTRUCT
|
|
|
|
jr nz, .dont_selfdestruct
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
srl c
|
2017-11-15 07:36:13 -08:00
|
|
|
jr nz, .dont_selfdestruct
|
2013-03-26 17:39:44 -07:00
|
|
|
inc c
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2017-11-15 07:36:13 -08:00
|
|
|
.dont_selfdestruct
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; Variable-hit moves and Conversion can have a power of 0.
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_MULTI_HIT
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .skip_zero_damage_check
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_CONVERSION
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .skip_zero_damage_check
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; No damage if move power is 0.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, d
|
|
|
|
and a
|
|
|
|
ret z
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.skip_zero_damage_check
|
2013-04-19 23:53:08 -07:00
|
|
|
; Minimum defense value is 1.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c
|
|
|
|
and a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr nz, .not_dividing_by_zero
|
2013-04-19 23:53:08 -07:00
|
|
|
ld c, 1
|
2015-11-09 20:01:45 -08:00
|
|
|
.not_dividing_by_zero
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2013-04-19 23:53:08 -07:00
|
|
|
ld hl, hDividend
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2015-12-26 18:59:03 -08:00
|
|
|
ld [hli], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; Level * 2
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, e
|
|
|
|
add a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr nc, .level_not_overflowing
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], $1
|
2015-11-09 20:01:45 -08:00
|
|
|
.level_not_overflowing
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld [hli], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; / 5
|
|
|
|
ld a, 5
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hld], a
|
|
|
|
push bc
|
|
|
|
ld b, $4
|
2013-04-19 23:53:08 -07:00
|
|
|
call Divide
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; + 2
|
2013-03-26 17:39:44 -07:00
|
|
|
inc [hl]
|
2015-12-26 18:59:03 -08:00
|
|
|
inc [hl]
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; * bp
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
2013-04-19 23:53:08 -07:00
|
|
|
call Multiply
|
|
|
|
|
|
|
|
; * Attack
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], b
|
2013-04-19 23:53:08 -07:00
|
|
|
call Multiply
|
|
|
|
|
|
|
|
; / Defense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], c
|
|
|
|
ld b, $4
|
2013-04-19 23:53:08 -07:00
|
|
|
call Divide
|
|
|
|
|
|
|
|
; / 50
|
|
|
|
ld [hl], 50
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, $4
|
2013-04-19 23:53:08 -07:00
|
|
|
call Divide
|
|
|
|
|
|
|
|
; Item boosts
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetUserItem
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
and a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .DoneItem
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, TypeBoostItems
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.NextItem:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -1
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .DoneItem
|
|
|
|
|
|
|
|
; Item effect
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
|
|
|
ld a, [hli]
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nz, .NextItem
|
|
|
|
|
|
|
|
; Type
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nz, .DoneItem
|
|
|
|
|
|
|
|
; * 100 + item effect amount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c
|
2013-04-19 23:53:08 -07:00
|
|
|
add 100
|
|
|
|
ld [hMultiplier], a
|
|
|
|
call Multiply
|
|
|
|
|
|
|
|
; / 100
|
|
|
|
ld a, 100
|
|
|
|
ld [hDivisor], a
|
|
|
|
ld b, 4
|
|
|
|
call Divide
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoneItem:
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; Critical hits
|
|
|
|
call .CriticalMultiplier
|
|
|
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
; Update wCurDamage (capped at 997).
|
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
add b
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hProduct + 3], a
|
|
|
|
jr nc, .dont_cap_1
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hProduct + 2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .Cap
|
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.dont_cap_1
|
|
|
|
ld a, [hProduct]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
or a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nz, .Cap
|
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 2]
|
2017-12-25 10:40:10 -08:00
|
|
|
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
|
2015-11-09 20:01:45 -08:00
|
|
|
jr c, .dont_cap_2
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2017-12-25 10:40:10 -08:00
|
|
|
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1) + 1
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nc, .Cap
|
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 3]
|
2017-12-25 10:40:10 -08:00
|
|
|
cp LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nc, .Cap
|
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.dont_cap_2
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
|
|
|
add b
|
|
|
|
ld [hld], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
|
|
|
adc b
|
|
|
|
ld [hl], a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .Cap
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2017-12-25 10:40:10 -08:00
|
|
|
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
|
2015-11-09 20:01:45 -08:00
|
|
|
jr c, .dont_cap_3
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2017-12-25 10:40:10 -08:00
|
|
|
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1) + 1
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nc, .Cap
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld a, [hld]
|
2017-12-25 10:40:10 -08:00
|
|
|
cp LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
|
2015-11-09 20:01:45 -08:00
|
|
|
jr c, .dont_cap_3
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Cap:
|
2017-12-25 10:40:10 -08:00
|
|
|
ld a, HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE)
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2017-12-25 10:40:10 -08:00
|
|
|
ld a, LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE)
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hld], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.dont_cap_3
|
2013-04-19 23:53:08 -07:00
|
|
|
; Minimum neutral damage is 2 (bringing the cap to 999).
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
2017-12-25 10:40:10 -08:00
|
|
|
add MIN_NEUTRAL_DAMAGE
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hld], a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr nc, .dont_floor
|
2013-03-26 17:39:44 -07:00
|
|
|
inc [hl]
|
2015-11-09 20:01:45 -08:00
|
|
|
.dont_floor
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.CriticalMultiplier:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCriticalHit]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
; x2
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hQuotient + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
add a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hProduct + 3], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hQuotient + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
rl a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hProduct + 2], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; Cap at $ffff.
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
ld a, $ff
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hProduct + 2], a
|
|
|
|
ld [hProduct + 3], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35703
|
|
|
|
|
|
|
|
|
2018-01-22 13:23:34 -08:00
|
|
|
INCLUDE "data/types/type_boost_items.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_ConstantDamage: ; 35726
|
2013-03-26 22:52:04 -07:00
|
|
|
; constantdamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonLevel
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .got_turn
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonLevel
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.got_turn
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_LEVEL_DAMAGE
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
|
|
|
ld a, 0
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .got_power
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_PSYWAVE
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .psywave
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_SUPER_FANG
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .super_fang
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_REVERSAL
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .reversal
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_POWER
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, $0
|
2015-11-09 20:01:45 -08:00
|
|
|
jr .got_power
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.psywave
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
srl a
|
|
|
|
add b
|
|
|
|
ld b, a
|
2015-11-09 20:01:45 -08:00
|
|
|
.psywave_loop
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .psywave_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .psywave_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 0
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .got_power
|
2015-11-09 20:01:45 -08:00
|
|
|
|
|
|
|
.super_fang
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_hp
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonHP
|
2015-11-09 20:01:45 -08:00
|
|
|
.got_hp
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
srl a
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
rr a
|
|
|
|
push af
|
|
|
|
ld a, b
|
|
|
|
pop bc
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .got_power
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 0
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .got_power
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, 1
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .got_power
|
2015-11-09 20:01:45 -08:00
|
|
|
|
|
|
|
.got_power
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], b
|
|
|
|
ret
|
2015-11-09 20:01:45 -08:00
|
|
|
|
|
|
|
.reversal
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .reversal_got_hp
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2015-11-09 20:01:45 -08:00
|
|
|
.reversal_got_hp
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hDividend], a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 0], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $30
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplier], a
|
2013-05-02 23:43:44 -07:00
|
|
|
call Multiply
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
and a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .skip_to_divide
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 4]
|
2013-03-26 17:39:44 -07:00
|
|
|
srl b
|
|
|
|
rr a
|
|
|
|
srl b
|
|
|
|
rr a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
|
|
|
ld a, [hProduct + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
srl b
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hProduct + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
rr a
|
|
|
|
srl b
|
|
|
|
rr a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDividend + 3], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDividend + 2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.skip_to_divide
|
2018-01-25 18:34:42 -08:00
|
|
|
ld b, 4
|
2013-05-02 23:43:44 -07:00
|
|
|
call Divide
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-25 18:34:42 -08:00
|
|
|
ld hl, FlailReversalPower
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.reversal_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-11-09 20:01:45 -08:00
|
|
|
jr nc, .break_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2015-11-09 20:01:45 -08:00
|
|
|
jr .reversal_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.break_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
ld a, [hl]
|
2015-09-09 16:27:07 -07:00
|
|
|
jr nz, .notPlayersTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-01-09 16:34:14 -08:00
|
|
|
ld hl, wPlayerMoveStructPower
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
push hl
|
|
|
|
call PlayerAttackDamage
|
2015-09-09 16:27:07 -07:00
|
|
|
jr .notEnemysTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
.notPlayersTurn
|
2016-01-09 16:34:14 -08:00
|
|
|
ld hl, wEnemyMoveStructPower
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
push hl
|
|
|
|
call EnemyAttackDamage
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
.notEnemysTurn
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_DamageCalc
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
ld [hl], 1
|
|
|
|
ret
|
|
|
|
|
2018-01-26 08:01:15 -08:00
|
|
|
INCLUDE "data/moves/flail_reversal_power.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/counter.asm"
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/encore.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/pain_split.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/snore.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/conversion2.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/lock_on.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/sketch.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_DefrostOpponent: ; 35b16
|
|
|
|
; defrostopponent
|
|
|
|
; Thaw the opponent if frozen, and
|
|
|
|
; raise the user's Attack one stage.
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call AnimateCurrentMove
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
call Defrost
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-01-26 08:36:00 -08:00
|
|
|
push hl
|
|
|
|
push af
|
|
|
|
|
|
|
|
ld a, EFFECT_ATTACK_UP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_StatUp
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
pop af
|
|
|
|
pop hl
|
|
|
|
ld [hl], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35b33
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/sleep_talk.asm"
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/destiny_bond.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/spite.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/false_swipe.asm"
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/heal_bell.asm"
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
FarPlayBattleAnimation: ; 35d00
|
|
|
|
; play animation de
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVar
|
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
|
|
|
ret nz
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; fallthrough
|
|
|
|
; 35d08
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
PlayFXAnimID: ; 35d08
|
|
|
|
ld a, e
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFXAnimID], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, d
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, 3
|
|
|
|
call DelayFrames
|
|
|
|
callfar PlayBattleAnim
|
|
|
|
ret
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35d1c
|
|
|
|
|
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
DoEnemyDamage: ; 35d1c
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
or b
|
|
|
|
jr z, .did_no_damage
|
|
|
|
|
|
|
|
ld a, c
|
|
|
|
and a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nz, .ignore_substitute
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEnemySubStatus4]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2018-04-04 14:27:40 -07:00
|
|
|
jp nz, DoSubstituteDamage
|
2018-01-26 08:36:00 -08:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.ignore_substitute
|
|
|
|
; Substract wCurDamage from wEnemyMonHP.
|
|
|
|
; store original HP in little endian wBuffer3/4
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hld]
|
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEnemyMonHP + 1]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer3], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sub b
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wEnemyMonHP + 1], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEnemyMonHP]
|
|
|
|
ld [wBuffer4], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sbc b
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wEnemyMonHP], a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nc, .no_underflow
|
2018-01-26 08:36:00 -08:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBuffer4]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBuffer3]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hl], a
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.no_underflow
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonMaxHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer1], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer6], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer5], a
|
2018-04-04 14:27:40 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
hlcoord 2, 2
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-26 15:11:55 -08:00
|
|
|
ld [wWhichHPBar], a
|
2018-01-16 11:30:10 -08:00
|
|
|
predef AnimateHPBar
|
2018-01-26 08:36:00 -08:00
|
|
|
.did_no_damage
|
|
|
|
jp RefreshBattleHuds
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35d7e
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
DoPlayerDamage: ; 35d7e
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wCurDamage
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
2018-01-26 08:36:00 -08:00
|
|
|
or b
|
|
|
|
jr z, .did_no_damage
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, c
|
|
|
|
and a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nz, .ignore_substitute
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerSubStatus4]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2018-04-04 14:27:40 -07:00
|
|
|
jp nz, DoSubstituteDamage
|
|
|
|
|
|
|
|
.ignore_substitute
|
|
|
|
; Substract wCurDamage from wBattleMonHP.
|
|
|
|
; store original HP in little endian wBuffer3/4
|
|
|
|
; store new HP in little endian wBuffer5/6
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hld]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleMonHP + 1]
|
|
|
|
ld [wBuffer3], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sub b
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBattleMonHP + 1], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer5], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleMonHP]
|
|
|
|
ld [wBuffer4], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sbc b
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBattleMonHP], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer6], a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nc, .no_underflow
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBuffer4]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBuffer3]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hl], a
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonHP
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBuffer5
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.no_underflow
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonMaxHP
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer2], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer1], a
|
2018-04-04 14:27:40 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
hlcoord 10, 9
|
2018-04-04 14:27:40 -07:00
|
|
|
ld a, 1
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [wWhichHPBar], a
|
|
|
|
predef AnimateHPBar
|
|
|
|
.did_no_damage
|
|
|
|
jp RefreshBattleHuds
|
|
|
|
|
|
|
|
; 35de0
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
DoSubstituteDamage: ; 35de0
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, SubTookDamageText
|
|
|
|
call StdBattleTextBox
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemySubstituteHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_hp
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wPlayerSubstituteHP
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_hp
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wCurDamage
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .broke
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
sub [hl]
|
|
|
|
ld [de], a
|
|
|
|
jr z, .broke
|
|
|
|
jr nc, .done
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.broke
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
res SUBSTATUS_SUBSTITUTE, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, SubFadedText
|
|
|
|
call StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
call BattleCommand_LowerSubNoAnim
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVar
|
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
|
|
|
call z, AppearUserLowerSub
|
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVarAddr
|
|
|
|
cp EFFECT_MULTI_HIT
|
|
|
|
jr z, .ok
|
|
|
|
cp EFFECT_DOUBLE_HIT
|
|
|
|
jr z, .ok
|
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
|
|
|
jr z, .ok
|
|
|
|
cp EFFECT_TRIPLE_KICK
|
|
|
|
jr z, .ok
|
|
|
|
cp EFFECT_BEAT_UP
|
|
|
|
jr z, .ok
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
.ok
|
|
|
|
call RefreshBattleHuds
|
|
|
|
.done
|
|
|
|
jp ResetDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35e40
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
UpdateMoveData: ; 35e40
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE
|
|
|
|
call GetBattleVar
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wCurMove], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
dec a
|
|
|
|
call GetMoveData
|
|
|
|
call GetMoveName
|
|
|
|
jp CopyName1
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35e5c
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_SleepTarget: ; 35e5c
|
|
|
|
; sleeptarget
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_SLEEP
|
|
|
|
jr nz, .not_protected_by_item
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetItemName
|
|
|
|
ld hl, ProtectedByText
|
|
|
|
jr .fail
|
|
|
|
|
|
|
|
.not_protected_by_item
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
and SLP
|
|
|
|
ld hl, AlreadyAsleepText
|
|
|
|
jr nz, .fail
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jp nz, PrintDidntAffect2
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, DidntAffect1Text
|
|
|
|
call .CheckAIRandomFail
|
|
|
|
jr c, .fail
|
|
|
|
|
|
|
|
ld a, [de]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .fail
|
|
|
|
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, .fail
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, $7
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .random_loop
|
|
|
|
ld b, $3
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.random_loop
|
|
|
|
call BattleRandom
|
|
|
|
and b
|
|
|
|
jr z, .random_loop
|
|
|
|
cp 7
|
|
|
|
jr z, .random_loop
|
|
|
|
inc a
|
|
|
|
ld [de], a
|
|
|
|
call UpdateOpponentInParty
|
|
|
|
call RefreshBattleHuds
|
|
|
|
|
|
|
|
ld hl, FellAsleepText
|
|
|
|
call StdBattleTextBox
|
|
|
|
|
|
|
|
farcall UseHeldStatusHealingItem
|
|
|
|
|
|
|
|
jp z, OpponentCantMove
|
|
|
|
ret
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.fail
|
2018-01-26 08:36:00 -08:00
|
|
|
push hl
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2018-01-26 08:36:00 -08:00
|
|
|
pop hl
|
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35ece
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.CheckAIRandomFail: ; 35ece
|
|
|
|
; Enemy turn
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .dont_fail
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Not in link battle
|
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
|
|
|
jr nz, .dont_fail
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .dont_fail
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Not locked-on by the enemy
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
|
|
|
jr nz, .dont_fail
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleRandom
|
|
|
|
cp 25 percent + 1 ; 25% chance AI fails
|
|
|
|
ret c
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.dont_fail
|
|
|
|
xor a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35eee
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_PoisonTarget: ; 35eee
|
|
|
|
; poisontarget
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
ret z
|
|
|
|
call CheckIfTargetIsPoisonType
|
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_POISON
|
|
|
|
ret z
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
|
|
|
call SafeCheckSafeguard
|
|
|
|
ret nz
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call PoisonOpponent
|
|
|
|
ld de, ANIM_PSN
|
|
|
|
call PlayOpponentBattleAnim
|
|
|
|
call RefreshBattleHuds
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, WasPoisonedText
|
|
|
|
call StdBattleTextBox
|
|
|
|
|
|
|
|
farcall UseHeldStatusHealingItem
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35f2c
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
BattleCommand_Poison: ; 35f2c
|
|
|
|
; poison
|
|
|
|
|
|
|
|
ld hl, DoesntAffectText
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
jp z, .failed
|
|
|
|
|
|
|
|
call CheckIfTargetIsPoisonType
|
|
|
|
jp z, .failed
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
|
|
|
ld hl, AlreadyPoisonedText
|
|
|
|
and 1 << PSN
|
|
|
|
jp nz, .failed
|
|
|
|
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_POISON
|
|
|
|
jr nz, .do_poison
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetItemName
|
|
|
|
ld hl, ProtectedByText
|
|
|
|
jr .failed
|
|
|
|
|
|
|
|
.do_poison
|
|
|
|
ld hl, DidntAffect1Text
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-02-04 10:16:40 -08:00
|
|
|
jr z, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
2018-02-04 10:16:40 -08:00
|
|
|
jr nz, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
2018-02-04 10:16:40 -08:00
|
|
|
jr nz, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
2018-02-04 10:16:40 -08:00
|
|
|
jr nz, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleRandom
|
|
|
|
cp 25 percent + 1 ; 25% chance AI fails
|
|
|
|
jr c, .failed
|
|
|
|
|
2018-02-04 10:16:40 -08:00
|
|
|
.dont_sample_failure
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, .failed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .failed
|
|
|
|
call .check_toxic
|
|
|
|
jr z, .toxic
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call .apply_poison
|
|
|
|
ld hl, WasPoisonedText
|
|
|
|
call StdBattleTextBox
|
|
|
|
jr .finished
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.toxic
|
|
|
|
set SUBSTATUS_TOXIC, [hl]
|
|
|
|
xor a
|
|
|
|
ld [de], a
|
|
|
|
call .apply_poison
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, BadlyPoisonedText
|
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.finished
|
|
|
|
farcall UseHeldStatusHealingItem
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.failed
|
|
|
|
push hl
|
|
|
|
call AnimateFailedMove
|
|
|
|
pop hl
|
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35fc0
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.apply_poison ; 35fc0
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2018-01-26 08:36:00 -08:00
|
|
|
call PoisonOpponent
|
|
|
|
jp RefreshBattleHuds
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35fc9
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.check_toxic ; 35fc9
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyToxicCount
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wPlayerToxicCount
|
2018-01-26 08:36:00 -08:00
|
|
|
.ok
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_TOXIC
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35fe1
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
CheckIfTargetIsPoisonType: ; 35fe1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wBattleMonType1
|
2018-01-26 08:36:00 -08:00
|
|
|
.ok
|
|
|
|
ld a, [de]
|
2013-03-26 17:39:44 -07:00
|
|
|
inc de
|
2018-01-26 08:36:00 -08:00
|
|
|
cp POISON
|
|
|
|
ret z
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp POISON
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35ff5
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
PoisonOpponent: ; 35ff5
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
set PSN, [hl]
|
|
|
|
jp UpdateOpponentInParty
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 35fff
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_DrainTarget: ; 35fff
|
|
|
|
; draintarget
|
|
|
|
call SapHealth
|
|
|
|
ld hl, SuckedHealthText
|
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36008
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_EatDream: ; 36008
|
|
|
|
; eatdream
|
|
|
|
call SapHealth
|
|
|
|
ld hl, DreamEatenText
|
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36011
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
SapHealth: ; 36011
|
2018-04-04 13:35:47 -07:00
|
|
|
; Divide damage by 2, store it in hDividend
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-26 08:36:00 -08:00
|
|
|
srl a
|
|
|
|
ld [hDividend], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
2018-01-26 08:36:00 -08:00
|
|
|
rr a
|
|
|
|
ld [hDividend + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2018-04-04 13:35:47 -07:00
|
|
|
jr nz, .at_least_one
|
|
|
|
ld a, 1
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hDividend + 1], a
|
2018-04-04 13:35:47 -07:00
|
|
|
.at_least_one
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonHP
|
|
|
|
ld de, wBattleMonMaxHP
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .battlemonhp
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyMonMaxHP
|
2018-01-26 08:36:00 -08:00
|
|
|
.battlemonhp
|
2018-04-04 13:35:47 -07:00
|
|
|
|
|
|
|
; Store current HP in little endian wBuffer3/4
|
2018-02-03 15:21:53 -08:00
|
|
|
ld bc, wBuffer4
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [bc], a
|
|
|
|
ld a, [hl]
|
|
|
|
dec bc
|
|
|
|
ld [bc], a
|
2018-04-04 13:35:47 -07:00
|
|
|
|
|
|
|
; Store max HP in little endian wBuffer1/2
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
dec bc
|
|
|
|
ld [bc], a
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
dec bc
|
|
|
|
ld [bc], a
|
2018-04-04 13:35:47 -07:00
|
|
|
|
|
|
|
; Add hDividend to current HP and copy it to little endian wBuffer5/6
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hDividend + 1]
|
|
|
|
ld b, [hl]
|
|
|
|
add b
|
|
|
|
ld [hld], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer5], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hDividend]
|
|
|
|
ld b, [hl]
|
|
|
|
adc b
|
|
|
|
ld [hli], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer6], a
|
2018-04-04 13:35:47 -07:00
|
|
|
jr c, .max_hp
|
|
|
|
|
|
|
|
; Substract current HP from max HP (to see if we have more than max HP)
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld b, a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
dec de
|
2013-03-26 17:39:44 -07:00
|
|
|
sub b
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2013-03-26 17:39:44 -07:00
|
|
|
sbc b
|
2018-04-04 13:35:47 -07:00
|
|
|
jr nc, .finish
|
|
|
|
|
|
|
|
.max_hp
|
|
|
|
; Load max HP into current HP and copy it to little endian wBuffer5/6
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
ld [hld], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer5], a
|
2018-01-26 08:36:00 -08:00
|
|
|
dec de
|
|
|
|
ld a, [de]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer6], a
|
2018-01-26 08:36:00 -08:00
|
|
|
inc de
|
2018-04-04 13:35:47 -07:00
|
|
|
|
|
|
|
.finish
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
hlcoord 10, 9
|
|
|
|
ld a, $1
|
|
|
|
jr z, .hp_bar
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 2, 2
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-01-26 08:36:00 -08:00
|
|
|
.hp_bar
|
2015-12-26 15:11:55 -08:00
|
|
|
ld [wWhichHPBar], a
|
2018-01-16 11:30:10 -08:00
|
|
|
predef AnimateHPBar
|
2018-01-26 08:36:00 -08:00
|
|
|
call RefreshBattleHuds
|
|
|
|
jp UpdateBattleMonInParty
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3608c
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_BurnTarget: ; 3608c
|
|
|
|
; burntarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
|
|
|
ld [wNumHits], a
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jp nz, Defrost
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
ret z
|
|
|
|
call CheckMoveTypeMatchesTarget ; Don't burn a Fire-type
|
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_BURN
|
|
|
|
ret z
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
call SafeCheckSafeguard
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set BRN, [hl]
|
|
|
|
call UpdateOpponentInParty
|
|
|
|
ld hl, ApplyBrnEffectOnAttack
|
|
|
|
call CallBattleCore
|
|
|
|
ld de, ANIM_BRN
|
|
|
|
call PlayOpponentBattleAnim
|
|
|
|
call RefreshBattleHuds
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, WasBurnedText
|
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
farcall UseHeldStatusHealingItem
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 360dd
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
Defrost: ; 360dd
|
|
|
|
ld a, [hl]
|
|
|
|
and 1 << FRZ
|
|
|
|
ret z
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurOTMon]
|
|
|
|
ld hl, wOTPartyMon1Status
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPartyMon1Status
|
|
|
|
ld a, [wCurBattleMon]
|
2014-06-10 23:08:07 -07:00
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetPartyLocation
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
call UpdateOpponentInParty
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, DefrostedOpponentText
|
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36102
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_FreezeTarget: ; 36102
|
|
|
|
; freezetarget
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
|
|
|
ld [wNumHits], a
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
ret z
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleWeather]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp WEATHER_SUN
|
|
|
|
ret z
|
|
|
|
call CheckMoveTypeMatchesTarget ; Don't freeze an Ice-type
|
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_FREEZE
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
|
|
|
call SafeCheckSafeguard
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set FRZ, [hl]
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateOpponentInParty
|
2018-01-26 08:36:00 -08:00
|
|
|
ld de, ANIM_FRZ
|
|
|
|
call PlayOpponentBattleAnim
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, WasFrozenText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall UseHeldStatusHealingItem
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call OpponentCantMove
|
|
|
|
call EndRechargeOpp
|
|
|
|
ld hl, wEnemyJustGotFrozen
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .finish
|
|
|
|
ld hl, wPlayerJustGotFrozen
|
|
|
|
.finish
|
|
|
|
ld [hl], $1
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36165
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_ParalyzeTarget: ; 36165
|
|
|
|
; paralyzetarget
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7f
|
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2018-01-26 08:36:00 -08:00
|
|
|
cp HELD_PREVENT_PARALYZE
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2015-11-06 19:36:06 -08:00
|
|
|
call SafeCheckSafeguard
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set PAR, [hl]
|
|
|
|
call UpdateOpponentInParty
|
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
|
|
|
call CallBattleCore
|
|
|
|
ld de, ANIM_PAR
|
|
|
|
call PlayOpponentBattleAnim
|
|
|
|
call RefreshBattleHuds
|
|
|
|
call PrintParalyze
|
|
|
|
ld hl, UseHeldStatusHealingItem
|
|
|
|
jp CallBattleCore
|
2015-11-06 19:36:06 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 361ac
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_AttackUp: ; 361ac
|
|
|
|
; attackup
|
|
|
|
ld b, ATTACK
|
|
|
|
jr BattleCommand_StatUp
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_DefenseUp: ; 361b0
|
|
|
|
; defenseup
|
|
|
|
ld b, DEFENSE
|
|
|
|
jr BattleCommand_StatUp
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_SpeedUp: ; 361b4
|
|
|
|
; speedup
|
|
|
|
ld b, SPEED
|
|
|
|
jr BattleCommand_StatUp
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_SpecialAttackUp: ; 361b8
|
|
|
|
; specialattackup
|
|
|
|
ld b, SP_ATTACK
|
|
|
|
jr BattleCommand_StatUp
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_SpecialDefenseUp: ; 361bc
|
|
|
|
; specialdefenseup
|
|
|
|
ld b, SP_DEFENSE
|
|
|
|
jr BattleCommand_StatUp
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_AccuracyUp: ; 361c0
|
|
|
|
; accuracyup
|
|
|
|
ld b, ACCURACY
|
|
|
|
jr BattleCommand_StatUp
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_EvasionUp: ; 361c4
|
|
|
|
; evasionup
|
|
|
|
ld b, EVASION
|
|
|
|
jr BattleCommand_StatUp
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_AttackUp2: ; 361c8
|
|
|
|
; attackup2
|
|
|
|
ld b, $10 | ATTACK
|
|
|
|
jr BattleCommand_StatUp
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_DefenseUp2: ; 361cc
|
|
|
|
; defenseup2
|
|
|
|
ld b, $10 | DEFENSE
|
|
|
|
jr BattleCommand_StatUp
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_SpeedUp2: ; 361d0
|
|
|
|
; speedup2
|
|
|
|
ld b, $10 | SPEED
|
|
|
|
jr BattleCommand_StatUp
|
|
|
|
|
|
|
|
BattleCommand_SpecialAttackUp2: ; 361d4
|
|
|
|
; specialattackup2
|
|
|
|
ld b, $10 | SP_ATTACK
|
|
|
|
jr BattleCommand_StatUp
|
|
|
|
|
|
|
|
BattleCommand_SpecialDefenseUp2: ; 361d8
|
|
|
|
; specialdefenseup2
|
|
|
|
ld b, $10 | SP_DEFENSE
|
|
|
|
jr BattleCommand_StatUp
|
|
|
|
|
|
|
|
BattleCommand_AccuracyUp2: ; 361dc
|
|
|
|
; accuracyup2
|
|
|
|
ld b, $10 | ACCURACY
|
|
|
|
jr BattleCommand_StatUp
|
|
|
|
|
|
|
|
BattleCommand_EvasionUp2: ; 361e0
|
|
|
|
; evasionup2
|
|
|
|
ld b, $10 | EVASION
|
|
|
|
jr BattleCommand_StatUp
|
|
|
|
|
|
|
|
BattleCommand_StatUp: ; 361e4
|
|
|
|
; statup
|
|
|
|
call CheckIfStatCanBeRaised
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wFailedMessage]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
|
|
|
jp StatUpAnimation
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 361ef
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
CheckIfStatCanBeRaised: ; 361ef
|
|
|
|
ld a, b
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wLoweredStat], a
|
|
|
|
ld hl, wPlayerStatLevels
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .got_stat_levels
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyStatLevels
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_stat_levels
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jp nz, .stat_raise_failed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jp nz, .stat_raise_failed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld b, [hl]
|
|
|
|
inc b
|
|
|
|
ld a, $d
|
|
|
|
cp b
|
|
|
|
jp c, .cant_raise_stat
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f0
|
|
|
|
jr z, .got_num_stages
|
|
|
|
inc b
|
|
|
|
ld a, $d
|
|
|
|
cp b
|
|
|
|
jr nc, .got_num_stages
|
|
|
|
ld b, a
|
|
|
|
.got_num_stages
|
|
|
|
ld [hl], b
|
|
|
|
push hl
|
|
|
|
ld a, c
|
|
|
|
cp $5
|
|
|
|
jr nc, .done_calcing_stats
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonStats + 1
|
|
|
|
ld de, wPlayerStats
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .got_stats_pointer
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonStats + 1
|
|
|
|
ld de, wEnemyStats
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_stats_pointer
|
|
|
|
push bc
|
|
|
|
sla c
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld a, c
|
|
|
|
add e
|
|
|
|
ld e, a
|
|
|
|
jr nc, .no_carry
|
|
|
|
inc d
|
|
|
|
.no_carry
|
|
|
|
pop bc
|
|
|
|
ld a, [hld]
|
|
|
|
sub LOW(MAX_STAT_VALUE)
|
|
|
|
jr nz, .not_already_max
|
|
|
|
ld a, [hl]
|
|
|
|
sbc HIGH(MAX_STAT_VALUE)
|
|
|
|
jp z, .stats_already_max
|
|
|
|
.not_already_max
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .calc_player_stats
|
|
|
|
call CalcEnemyStats
|
|
|
|
jr .done_calcing_stats
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.calc_player_stats
|
|
|
|
call CalcPlayerStats
|
|
|
|
.done_calcing_stats
|
|
|
|
pop hl
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3626e
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.stats_already_max ; 3626e
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
2018-01-26 08:36:00 -08:00
|
|
|
dec [hl]
|
|
|
|
; fallthrough
|
|
|
|
; 36270
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.cant_raise_stat ; 36270
|
|
|
|
ld a, $2
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3627b
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.stat_raise_failed ; 3627b
|
|
|
|
ld a, $1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36281
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
StatUpAnimation: ; 36281
|
|
|
|
ld bc, wPlayerMinimized
|
|
|
|
ld hl, DropPlayerSub
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .do_player
|
|
|
|
ld bc, wEnemyMinimized
|
|
|
|
ld hl, DropEnemySub
|
|
|
|
.do_player
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
cp MINIMIZE
|
|
|
|
ret nz
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $1
|
|
|
|
ld [bc], a
|
|
|
|
call _CheckBattleScene
|
|
|
|
ret nc
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
call CallBattleCore
|
|
|
|
call WaitBGMap
|
|
|
|
jp BattleCommand_MoveDelay
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 362ad
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_AttackDown: ; 362ad
|
|
|
|
; attackdown
|
|
|
|
ld a, ATTACK
|
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_DefenseDown: ; 362b1
|
|
|
|
; defensedown
|
|
|
|
ld a, DEFENSE
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_SpeedDown: ; 362b5
|
|
|
|
; speeddown
|
|
|
|
ld a, SPEED
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_SpecialAttackDown: ; 362b9
|
|
|
|
; specialattackdown
|
|
|
|
ld a, SP_ATTACK
|
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_SpecialDefenseDown: ; 362bd
|
|
|
|
; specialdefensedown
|
|
|
|
ld a, SP_DEFENSE
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_AccuracyDown: ; 362c1
|
|
|
|
; accuracydown
|
|
|
|
ld a, ACCURACY
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_EvasionDown: ; 362c5
|
|
|
|
; evasiondown
|
|
|
|
ld a, EVASION
|
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_AttackDown2: ; 362c9
|
|
|
|
; attackdown2
|
|
|
|
ld a, $10 | ATTACK
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_DefenseDown2: ; 362cd
|
|
|
|
; defensedown2
|
|
|
|
ld a, $10 | DEFENSE
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_SpeedDown2: ; 362d1
|
|
|
|
; speeddown2
|
|
|
|
ld a, $10 | SPEED
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_SpecialAttackDown2: ; 362d5
|
|
|
|
; specialattackdown2
|
|
|
|
ld a, $10 | SP_ATTACK
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_SpecialDefenseDown2: ; 362d9
|
|
|
|
; specialdefensedown2
|
|
|
|
ld a, $10 | SP_DEFENSE
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_AccuracyDown2: ; 362dd
|
|
|
|
; accuracydown2
|
|
|
|
ld a, $10 | ACCURACY
|
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_EvasionDown2: ; 362e1
|
|
|
|
; evasiondown2
|
|
|
|
ld a, $10 | EVASION
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_StatDown: ; 362e3
|
|
|
|
; statdown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wLoweredStat], a
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckMist
|
|
|
|
jp nz, .Mist
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyStatLevels
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .GetStatLevel
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerStatLevels
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.GetStatLevel:
|
|
|
|
; Attempt to lower the stat.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f
|
|
|
|
ld c, a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld b, [hl]
|
2018-01-26 08:36:00 -08:00
|
|
|
dec b
|
|
|
|
jp z, .CantLower
|
|
|
|
|
|
|
|
; Sharply lower the stat if applicable.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f0
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .ComputerMiss
|
|
|
|
dec b
|
|
|
|
jr nz, .ComputerMiss
|
2013-03-26 17:39:44 -07:00
|
|
|
inc b
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
.ComputerMiss:
|
|
|
|
; Computer opponents have a 25% chance of failing.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .DidntMiss
|
|
|
|
|
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2013-06-13 13:10:39 -07:00
|
|
|
jr nz, .DidntMiss
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2013-06-13 13:10:39 -07:00
|
|
|
jr nz, .DidntMiss
|
|
|
|
|
|
|
|
; Lock-On still always works.
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2013-06-13 13:10:39 -07:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
|
|
|
jr nz, .DidntMiss
|
|
|
|
|
|
|
|
; Attacking moves that also lower accuracy are unaffected.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_ACCURACY_DOWN_HIT
|
|
|
|
jr z, .DidntMiss
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleRandom
|
|
|
|
cp 25 percent + 1 ; 25% chance AI fails
|
|
|
|
jr c, .Failed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.DidntMiss:
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, .Failed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .Failed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .Failed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckHiddenOpponent
|
|
|
|
jr nz, .Failed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Accuracy/Evasion reduction don't involve stats.
|
|
|
|
ld [hl], b
|
|
|
|
ld a, c
|
|
|
|
cp ACCURACY
|
|
|
|
jr nc, .Hit
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push hl
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonAttack + 1
|
|
|
|
ld de, wEnemyStats
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .do_enemy
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonAttack + 1
|
|
|
|
ld de, wPlayerStats
|
2018-01-26 08:36:00 -08:00
|
|
|
.do_enemy
|
|
|
|
call TryLowerStat
|
|
|
|
pop hl
|
|
|
|
jr z, .CouldntLower
|
|
|
|
|
|
|
|
.Hit:
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
|
|
|
|
|
|
|
.CouldntLower:
|
|
|
|
inc [hl]
|
|
|
|
.CantLower:
|
|
|
|
ld a, 3
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAttackMissed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Failed:
|
|
|
|
ld a, 1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Mist:
|
|
|
|
ld a, 2
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36391
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
CheckMist: ; 36391
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_ATTACK_DOWN
|
|
|
|
jr c, .dont_check_mist
|
|
|
|
cp EFFECT_EVASION_DOWN + 1
|
|
|
|
jr c, .check_mist
|
|
|
|
cp EFFECT_ATTACK_DOWN_2
|
|
|
|
jr c, .dont_check_mist
|
|
|
|
cp EFFECT_EVASION_DOWN_2 + 1
|
|
|
|
jr c, .check_mist
|
|
|
|
cp EFFECT_ATTACK_DOWN_HIT
|
|
|
|
jr c, .dont_check_mist
|
|
|
|
cp EFFECT_EVASION_DOWN_HIT + 1
|
|
|
|
jr c, .check_mist
|
|
|
|
.dont_check_mist
|
|
|
|
xor a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.check_mist
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
bit SUBSTATUS_MIST, a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 363b8
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_StatUpMessage: ; 363b8
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wFailedMessage]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-26 08:36:00 -08:00
|
|
|
inc b
|
|
|
|
call GetStatName
|
|
|
|
ld hl, .stat
|
|
|
|
jp BattleTextBox
|
|
|
|
|
|
|
|
.stat
|
|
|
|
text_jump UnknownText_0x1c0cc6
|
|
|
|
start_asm
|
|
|
|
ld hl, .up
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f0
|
|
|
|
ret z
|
|
|
|
ld hl, .wayup
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.wayup
|
|
|
|
text_jump UnknownText_0x1c0cd0
|
|
|
|
db "@"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.up
|
|
|
|
text_jump UnknownText_0x1c0ce0
|
|
|
|
db "@"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 363e9
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_StatDownMessage: ; 363e9
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wFailedMessage]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
|
|
|
ld b, a
|
|
|
|
inc b
|
|
|
|
call GetStatName
|
|
|
|
ld hl, .stat
|
|
|
|
jp BattleTextBox
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.stat
|
|
|
|
text_jump UnknownText_0x1c0ceb
|
|
|
|
start_asm
|
|
|
|
ld hl, .fell
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f0
|
|
|
|
ret z
|
|
|
|
ld hl, .sharplyfell
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.sharplyfell
|
|
|
|
text_jump UnknownText_0x1c0cf5
|
|
|
|
db "@"
|
|
|
|
.fell
|
|
|
|
text_jump UnknownText_0x1c0d06
|
|
|
|
db "@"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3641a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
TryLowerStat: ; 3641a
|
|
|
|
; Lower stat c from stat struct hl (buffer de).
|
|
|
|
|
|
|
|
push bc
|
|
|
|
sla c
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
; add de, c
|
|
|
|
ld a, c
|
2013-03-26 17:39:44 -07:00
|
|
|
add e
|
2018-01-26 08:36:00 -08:00
|
|
|
ld e, a
|
|
|
|
jr nc, .no_carry
|
|
|
|
inc d
|
|
|
|
.no_carry
|
|
|
|
pop bc
|
|
|
|
|
|
|
|
; The lowest possible stat is 1.
|
|
|
|
ld a, [hld]
|
|
|
|
sub 1
|
|
|
|
jr nz, .not_min
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_min
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .Player
|
|
|
|
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
call CalcPlayerStats
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
jr .end
|
|
|
|
|
|
|
|
.Player:
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
call CalcEnemyStats
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
.end
|
|
|
|
ld a, 1
|
|
|
|
and a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3644c
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_StatUpFailText: ; 3644c
|
|
|
|
; statupfailtext
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wFailedMessage]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
push af
|
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
jp z, TryPrintButItFailed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
|
|
|
ld b, a
|
|
|
|
inc b
|
|
|
|
call GetStatName
|
|
|
|
ld hl, WontRiseAnymoreText
|
|
|
|
jp StdBattleTextBox
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3646a
|
|
|
|
|
|
|
|
|
|
|
|
BattleCommand_StatDownFailText: ; 3646a
|
|
|
|
; statdownfailtext
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wFailedMessage]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2018-01-26 08:36:00 -08:00
|
|
|
push af
|
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
jp z, TryPrintButItFailed
|
|
|
|
dec a
|
|
|
|
ld hl, ProtectedByMistText
|
|
|
|
jp z, StdBattleTextBox
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
|
|
|
ld b, a
|
|
|
|
inc b
|
|
|
|
call GetStatName
|
|
|
|
ld hl, WontDropAnymoreText
|
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3648f
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
GetStatName: ; 3648f
|
|
|
|
ld hl, StatNames
|
|
|
|
ld c, "@"
|
|
|
|
.CheckName:
|
|
|
|
dec b
|
|
|
|
jr z, .Copy
|
|
|
|
.GetName:
|
|
|
|
ld a, [hli]
|
|
|
|
cp c
|
|
|
|
jr z, .CheckName
|
|
|
|
jr .GetName
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Copy:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wStringBuffer2
|
|
|
|
ld bc, wStringBuffer3 - wStringBuffer2
|
2018-01-26 08:36:00 -08:00
|
|
|
jp CopyBytes
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "data/battle/stat_names.asm"
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "data/battle/stat_multipliers.asm"
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_AllStatsUp: ; 36500
|
|
|
|
; allstatsup
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Attack
|
|
|
|
call ResetMiss
|
|
|
|
call BattleCommand_AttackUp
|
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Defense
|
|
|
|
call ResetMiss
|
|
|
|
call BattleCommand_DefenseUp
|
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Speed
|
|
|
|
call ResetMiss
|
|
|
|
call BattleCommand_SpeedUp
|
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Special Attack
|
|
|
|
call ResetMiss
|
|
|
|
call BattleCommand_SpecialAttackUp
|
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Special Defense
|
|
|
|
call ResetMiss
|
|
|
|
call BattleCommand_SpecialDefenseUp
|
|
|
|
jp BattleCommand_StatUpMessage
|
|
|
|
; 3652d
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ResetMiss: ; 3652d
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36532
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
LowerStat: ; 36532
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wLoweredStat], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPlayerStatLevels
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .got_target
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyStatLevels
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_target
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld b, [hl]
|
|
|
|
dec b
|
|
|
|
jr z, .cant_lower_anymore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f0
|
|
|
|
jr z, .got_num_stages
|
|
|
|
dec b
|
|
|
|
jr nz, .got_num_stages
|
|
|
|
inc b
|
|
|
|
|
|
|
|
.got_num_stages
|
|
|
|
ld [hl], b
|
|
|
|
ld a, c
|
|
|
|
cp 5
|
|
|
|
jr nc, .accuracy_evasion
|
|
|
|
|
|
|
|
push hl
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonStats + 1
|
|
|
|
ld de, wPlayerStats
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .got_target_2
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonStats + 1
|
|
|
|
ld de, wEnemyStats
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
.got_target_2
|
|
|
|
call TryLowerStat
|
|
|
|
pop hl
|
|
|
|
jr z, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.accuracy_evasion
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .player
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CalcEnemyStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
jr .finish
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.player
|
|
|
|
call CalcPlayerStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.finish
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.failed
|
|
|
|
inc [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.cant_lower_anymore
|
|
|
|
ld a, 2
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3658f
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_TriStatusChance: ; 3658f
|
|
|
|
; tristatuschance
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_EffectChance
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.loop
|
|
|
|
; 1/3 chance of each status
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-26 08:36:00 -08:00
|
|
|
swap a
|
2018-01-11 09:00:01 -08:00
|
|
|
and %11
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .loop
|
|
|
|
dec a
|
|
|
|
ld hl, .ptrs
|
|
|
|
rst JumpTable
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.ptrs
|
|
|
|
dw BattleCommand_ParalyzeTarget ; paralyze
|
|
|
|
dw BattleCommand_FreezeTarget ; freeze
|
|
|
|
dw BattleCommand_BurnTarget ; burn
|
|
|
|
; 365a7
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_Curl: ; 365a7
|
|
|
|
; curl
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS2
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_CURLED, [hl]
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 365af
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_RaiseSubNoAnim: ; 365af
|
|
|
|
ld hl, GetBattleMonBackpic
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .PlayerTurn
|
|
|
|
ld hl, GetEnemyMonFrontpic
|
|
|
|
.PlayerTurn:
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
call CallBattleCore
|
|
|
|
jp WaitBGMap
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 365c3
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_LowerSubNoAnim: ; 365c3
|
|
|
|
ld hl, DropPlayerSub
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .PlayerTurn
|
|
|
|
ld hl, DropEnemySub
|
|
|
|
.PlayerTurn:
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
call CallBattleCore
|
|
|
|
jp WaitBGMap
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 365d7
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
CalcPlayerStats: ; 365d7
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPlayerAtkLevel
|
|
|
|
ld de, wPlayerStats
|
|
|
|
ld bc, wBattleMonAttack
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 5
|
|
|
|
call CalcStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, BadgeStatBoosts
|
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
|
|
|
call CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, ApplyBrnEffectOnAttack
|
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
jp BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 365fd
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
CalcEnemyStats: ; 365fd
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyAtkLevel
|
|
|
|
ld de, wEnemyStats
|
|
|
|
ld bc, wEnemyMonAttack
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
ld a, 5
|
|
|
|
call CalcStats
|
|
|
|
|
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
|
|
|
call CallBattleCore
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, ApplyBrnEffectOnAttack
|
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
jp BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3661d
|
2013-04-27 14:12:23 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
CalcStats: ; 3661d
|
|
|
|
.loop
|
|
|
|
push af
|
|
|
|
ld a, [hli]
|
|
|
|
push hl
|
|
|
|
push bc
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
|
|
|
dec c
|
|
|
|
ld b, 0
|
|
|
|
ld hl, StatLevelMultipliers
|
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
|
|
|
ld [hMultiplicand + 0], a
|
|
|
|
ld a, [de]
|
|
|
|
ld [hMultiplicand + 1], a
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
ld [hMultiplicand + 2], a
|
|
|
|
inc de
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [hMultiplier], a
|
|
|
|
call Multiply
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
|
|
|
ld [hDivisor], a
|
|
|
|
ld b, 4
|
|
|
|
call Divide
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hQuotient + 1]
|
|
|
|
ld b, a
|
|
|
|
ld a, [hQuotient + 2]
|
|
|
|
or b
|
|
|
|
jr nz, .check_maxed_out
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 1
|
|
|
|
ld [hQuotient + 2], a
|
|
|
|
jr .not_maxed_out
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.check_maxed_out
|
|
|
|
ld a, [hQuotient + 2]
|
|
|
|
cp LOW(MAX_STAT_VALUE)
|
|
|
|
ld a, b
|
|
|
|
sbc HIGH(MAX_STAT_VALUE)
|
|
|
|
jr c, .not_maxed_out
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, LOW(MAX_STAT_VALUE)
|
|
|
|
ld [hQuotient + 2], a
|
|
|
|
ld a, HIGH(MAX_STAT_VALUE)
|
|
|
|
ld [hQuotient + 1], a
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_maxed_out
|
|
|
|
pop bc
|
|
|
|
ld a, [hQuotient + 1]
|
|
|
|
ld [bc], a
|
|
|
|
inc bc
|
|
|
|
ld a, [hQuotient + 2]
|
|
|
|
ld [bc], a
|
|
|
|
inc bc
|
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
jr nz, .loop
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36671
|
2015-09-04 13:30:40 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/bide.asm"
|
2015-09-04 13:30:40 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_CheckRampage: ; 3671a
|
|
|
|
; checkrampage
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wPlayerRolloutCount
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .player
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyRolloutCount
|
2018-01-26 08:36:00 -08:00
|
|
|
.player
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_RAMPAGE, [hl]
|
|
|
|
ret z
|
|
|
|
ld a, [de]
|
|
|
|
dec a
|
|
|
|
ld [de], a
|
|
|
|
jr nz, .continue_rampage
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
res SUBSTATUS_RAMPAGE, [hl]
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
call SafeCheckSafeguard
|
|
|
|
push af
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
pop af
|
|
|
|
jr nz, .continue_rampage
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
set SUBSTATUS_CONFUSED, [hl]
|
|
|
|
call BattleRandom
|
|
|
|
and %00000001
|
|
|
|
inc a
|
|
|
|
inc a
|
|
|
|
inc de ; ConfuseCount
|
|
|
|
ld [de], a
|
|
|
|
.continue_rampage
|
|
|
|
ld b, rampage_command
|
|
|
|
jp SkipToBattleCommand
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36751
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_Rampage: ; 36751
|
|
|
|
; rampage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; No rampage during Sleep Talk.
|
|
|
|
ld a, BATTLE_VARS_STATUS
|
|
|
|
call GetBattleVar
|
|
|
|
and SLP
|
|
|
|
ret nz
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wPlayerRolloutCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyRolloutCount
|
2013-03-26 17:39:44 -07:00
|
|
|
.ok
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_RAMPAGE, [hl]
|
|
|
|
; Rampage for 1 or 2 more turns
|
|
|
|
call BattleRandom
|
|
|
|
and %00000001
|
|
|
|
inc a
|
|
|
|
ld [de], a
|
|
|
|
ld a, 1
|
|
|
|
ld [wSomeoneIsRampaging], a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36778
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/teleport.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
SetBattleDraw: ; 36804
|
|
|
|
ld a, [wBattleResult]
|
2018-04-05 08:44:02 -07:00
|
|
|
and BATTLERESULT_BITMASK
|
|
|
|
or DRAW
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [wBattleResult], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3680f
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_ForceSwitch: ; 3680f
|
|
|
|
; forceswitch
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleType]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp BATTLETYPE_SHINY
|
|
|
|
jp z, .fail
|
|
|
|
cp BATTLETYPE_TRAP
|
|
|
|
jp z, .fail
|
|
|
|
cp BATTLETYPE_CELEBI
|
|
|
|
jp z, .fail
|
|
|
|
cp BATTLETYPE_SUICUNE
|
|
|
|
jp z, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jp nz, .force_player_switch
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .missed
|
|
|
|
ld a, [wBattleMode]
|
|
|
|
dec a
|
|
|
|
jr nz, .trainer
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleMonLevel]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp b
|
|
|
|
jr nc, .wild_force_flee
|
|
|
|
add b
|
|
|
|
ld c, a
|
|
|
|
inc c
|
|
|
|
.random_loop_wild
|
|
|
|
call BattleRandom
|
|
|
|
cp c
|
|
|
|
jr nc, .random_loop_wild
|
|
|
|
srl b
|
|
|
|
srl b
|
|
|
|
cp b
|
|
|
|
jr nc, .wild_force_flee
|
|
|
|
.missed
|
|
|
|
jp .fail
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.wild_force_flee
|
|
|
|
call UpdateBattleMonInParty
|
|
|
|
xor a
|
|
|
|
ld [wNumHits], a
|
|
|
|
inc a
|
|
|
|
ld [wForcedSwitch], a
|
|
|
|
call SetBattleDraw
|
|
|
|
ld a, [wPlayerMoveStructAnimation]
|
|
|
|
jp .succeed
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.trainer
|
|
|
|
call FindAliveEnemyMons
|
|
|
|
jr c, .switch_fail
|
|
|
|
ld a, [wEnemyGoesFirst]
|
|
|
|
and a
|
|
|
|
jr z, .switch_fail
|
|
|
|
call UpdateEnemyMonInParty
|
|
|
|
ld a, $1
|
|
|
|
ld [wKickCounter], a
|
|
|
|
call AnimateCurrentMove
|
|
|
|
ld c, $14
|
|
|
|
call DelayFrames
|
|
|
|
hlcoord 1, 0
|
|
|
|
lb bc, 4, 10
|
|
|
|
call ClearBox
|
|
|
|
ld c, 20
|
|
|
|
call DelayFrames
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wOTPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurOTMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
|
|
|
; select a random enemy mon to switch to
|
|
|
|
.random_loop_trainer
|
|
|
|
call BattleRandom
|
|
|
|
and $7
|
|
|
|
cp b
|
|
|
|
jr nc, .random_loop_trainer
|
|
|
|
cp c
|
|
|
|
jr z, .random_loop_trainer
|
|
|
|
push af
|
|
|
|
push bc
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wOTPartyMon1HP
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetPartyLocation
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-26 08:36:00 -08:00
|
|
|
or [hl]
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
jr z, .random_loop_trainer
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, d
|
2018-01-26 08:36:00 -08:00
|
|
|
inc a
|
|
|
|
ld [wEnemySwitchMonIndex], a
|
|
|
|
callfar ForceEnemySwitch
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, DraggedOutText
|
|
|
|
call StdBattleTextBox
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, SpikesDamage
|
|
|
|
jp CallBattleCore
|
|
|
|
|
|
|
|
.switch_fail
|
|
|
|
jp .fail
|
|
|
|
|
|
|
|
.force_player_switch
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .player_miss
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wBattleMode]
|
|
|
|
dec a
|
|
|
|
jr nz, .vs_trainer
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleMonLevel]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp b
|
|
|
|
jr nc, .wild_succeed_playeristarget
|
|
|
|
|
|
|
|
add b
|
|
|
|
ld c, a
|
|
|
|
inc c
|
|
|
|
.wild_random_loop_playeristarget
|
|
|
|
call BattleRandom
|
|
|
|
cp c
|
|
|
|
jr nc, .wild_random_loop_playeristarget
|
|
|
|
|
|
|
|
srl b
|
|
|
|
srl b
|
|
|
|
cp b
|
|
|
|
jr nc, .wild_succeed_playeristarget
|
|
|
|
|
|
|
|
.player_miss
|
|
|
|
jr .fail
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.wild_succeed_playeristarget
|
|
|
|
call UpdateBattleMonInParty
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2018-01-26 08:36:00 -08:00
|
|
|
inc a
|
|
|
|
ld [wForcedSwitch], a
|
|
|
|
call SetBattleDraw
|
|
|
|
ld a, [wEnemyMoveStructAnimation]
|
|
|
|
jr .succeed
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.vs_trainer
|
|
|
|
call CheckPlayerHasMonToSwitchTo
|
|
|
|
jr c, .fail
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wEnemyGoesFirst]
|
|
|
|
cp $1
|
|
|
|
jr z, .switch_fail
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call UpdateBattleMonInParty
|
|
|
|
ld a, $1
|
|
|
|
ld [wKickCounter], a
|
|
|
|
call AnimateCurrentMove
|
|
|
|
ld c, 20
|
|
|
|
call DelayFrames
|
|
|
|
hlcoord 9, 7
|
|
|
|
lb bc, 5, 11
|
|
|
|
call ClearBox
|
|
|
|
ld c, 20
|
|
|
|
call DelayFrames
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurBattleMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
|
|
|
.random_loop_trainer_playeristarget
|
|
|
|
call BattleRandom
|
|
|
|
and $7
|
|
|
|
cp b
|
|
|
|
jr nc, .random_loop_trainer_playeristarget
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp c
|
|
|
|
jr z, .random_loop_trainer_playeristarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push af
|
|
|
|
push bc
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPartyMon1HP
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetPartyLocation
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
jr z, .random_loop_trainer_playeristarget
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, d
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wCurPartyMon], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, SwitchPlayerMon
|
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, DraggedOutText
|
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, SpikesDamage
|
|
|
|
jp CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.fail
|
|
|
|
call BattleCommand_LowerSub
|
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
call BattleCommand_RaiseSub
|
|
|
|
jp PrintButItFailed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.succeed
|
|
|
|
push af
|
|
|
|
call SetBattleDraw
|
|
|
|
ld a, $1
|
|
|
|
ld [wKickCounter], a
|
|
|
|
call AnimateCurrentMove
|
|
|
|
ld c, 20
|
|
|
|
call DelayFrames
|
|
|
|
pop af
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, FledInFearText
|
|
|
|
cp ROAR
|
|
|
|
jr z, .do_text
|
|
|
|
ld hl, BlownAwayText
|
|
|
|
.do_text
|
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36994
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
CheckPlayerHasMonToSwitchTo: ; 36994
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld d, a
|
|
|
|
ld e, 0
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
.loop
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurBattleMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp e
|
|
|
|
jr z, .next
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, e
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPartyMon1HP
|
2018-01-26 08:36:00 -08:00
|
|
|
call AddNTimes
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
jr nz, .not_fainted
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.next
|
|
|
|
inc e
|
|
|
|
dec d
|
|
|
|
jr nz, .loop
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
scf
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_fainted
|
|
|
|
and a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 369b6
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_EndLoop: ; 369b6
|
|
|
|
; endloop
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-04-02 16:05:44 -07:00
|
|
|
; Loop back to 'critical'.
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wPlayerRolloutCount
|
|
|
|
ld bc, wPlayerDamageTaken
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .got_addrs
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyRolloutCount
|
|
|
|
ld bc, wEnemyDamageTaken
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_addrs
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
bit SUBSTATUS_IN_LOOP, [hl]
|
|
|
|
jp nz, .in_loop
|
|
|
|
set SUBSTATUS_IN_LOOP, [hl]
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVarAddr
|
|
|
|
ld a, [hl]
|
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
|
|
|
jr z, .twineedle
|
|
|
|
cp EFFECT_DOUBLE_HIT
|
|
|
|
ld a, 1
|
|
|
|
jr z, .double_hit
|
|
|
|
ld a, [hl]
|
|
|
|
cp EFFECT_BEAT_UP
|
|
|
|
jr z, .beat_up
|
|
|
|
cp EFFECT_TRIPLE_KICK
|
|
|
|
jr nz, .not_triple_kick
|
|
|
|
.reject_triple_kick_sample
|
|
|
|
call BattleRandom
|
|
|
|
and $3
|
|
|
|
jr z, .reject_triple_kick_sample
|
|
|
|
dec a
|
|
|
|
jr nz, .double_hit
|
|
|
|
ld a, 1
|
|
|
|
ld [bc], a
|
|
|
|
jr .done_loop
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.beat_up
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .check_ot_beat_up
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp 1
|
|
|
|
jp z, .only_one_beatup
|
|
|
|
dec a
|
|
|
|
jr .double_hit
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.check_ot_beat_up
|
|
|
|
ld a, [wBattleMode]
|
|
|
|
cp WILD_BATTLE
|
|
|
|
jp z, .only_one_beatup
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wOTPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp 1
|
|
|
|
jp z, .only_one_beatup
|
|
|
|
dec a
|
|
|
|
jr .double_hit
|
|
|
|
|
|
|
|
.only_one_beatup
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
res SUBSTATUS_IN_LOOP, [hl]
|
2018-04-03 03:00:24 -07:00
|
|
|
call BattleCommand_BeatUpFailText
|
2018-01-26 08:36:00 -08:00
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_triple_kick
|
|
|
|
call BattleRandom
|
|
|
|
and $3
|
|
|
|
cp 2
|
|
|
|
jr c, .got_number_hits
|
|
|
|
call BattleRandom
|
|
|
|
and $3
|
|
|
|
.got_number_hits
|
|
|
|
inc a
|
|
|
|
.double_hit
|
|
|
|
ld [de], a
|
|
|
|
inc a
|
|
|
|
ld [bc], a
|
|
|
|
jr .loop_back_to_critical
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.twineedle
|
|
|
|
ld a, 1
|
|
|
|
jr .double_hit
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.in_loop
|
|
|
|
ld a, [de]
|
|
|
|
dec a
|
|
|
|
ld [de], a
|
|
|
|
jr nz, .loop_back_to_critical
|
|
|
|
.done_loop
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
res SUBSTATUS_IN_LOOP, [hl]
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, PlayerHitTimesText
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_hit_n_times_text
|
|
|
|
ld hl, EnemyHitTimesText
|
|
|
|
.got_hit_n_times_text
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push bc
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_BEAT_UP
|
|
|
|
jr z, .beat_up_2
|
|
|
|
call StdBattleTextBox
|
|
|
|
.beat_up_2
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
pop bc
|
|
|
|
xor a
|
|
|
|
ld [bc], a
|
|
|
|
ret
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.loop_back_to_critical
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress + 1]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld h, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld l, a
|
|
|
|
.not_critical
|
|
|
|
ld a, [hld]
|
|
|
|
cp critical_command
|
|
|
|
jr nz, .not_critical
|
|
|
|
inc hl
|
|
|
|
ld a, h
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBattleScriptBufferAddress + 1], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, l
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBattleScriptBufferAddress], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36a82
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_FakeOut: ; 36a82
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, .fail
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
and 1 << FRZ | SLP
|
|
|
|
jr nz, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckOpponentWentFirst
|
|
|
|
jr z, FlinchTarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.fail
|
|
|
|
ld a, 1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36aa0
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_FlinchTarget: ; 36aa0
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2018-01-26 08:36:00 -08:00
|
|
|
and 1 << FRZ | SLP
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckOpponentWentFirst
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; fallthrough
|
|
|
|
; 36ab5
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
FlinchTarget: ; 36ab5
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_FLINCHED, [hl]
|
|
|
|
jp EndRechargeOpp
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36abf
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
CheckOpponentWentFirst: ; 36abf
|
|
|
|
; Returns a=0, z if user went first
|
|
|
|
; Returns a=1, nz if opponent went first
|
|
|
|
push bc
|
|
|
|
ld a, [wEnemyGoesFirst] ; 0 if player went first
|
|
|
|
ld b, a
|
|
|
|
ld a, [hBattleTurn] ; 0 if it's the player's turn
|
|
|
|
xor b ; 1 if opponent went first
|
|
|
|
pop bc
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36ac9
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_HeldFlinch: ; 36ac9
|
|
|
|
; kingsrock
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetUserItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_FLINCH
|
|
|
|
ret nz
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVarAddr
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
call GetUserItem
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-26 08:36:00 -08:00
|
|
|
cp c
|
|
|
|
ret nc
|
|
|
|
call EndRechargeOpp
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_FLINCHED, [hl]
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36af3
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_OHKO: ; 36af3
|
|
|
|
; ohko
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call ResetDamage
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
jr z, .no_effect
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonLevel
|
|
|
|
ld de, wBattleMonLevel
|
2018-01-26 08:36:00 -08:00
|
|
|
ld bc, wPlayerMoveStruct + MOVE_ACC
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .got_move_accuracy
|
|
|
|
push hl
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
|
|
|
pop de
|
|
|
|
ld bc, wEnemyMoveStruct + MOVE_ACC
|
|
|
|
.got_move_accuracy
|
|
|
|
ld a, [de]
|
|
|
|
sub [hl]
|
|
|
|
jr c, .no_effect
|
|
|
|
add a
|
|
|
|
ld e, a
|
|
|
|
ld a, [bc]
|
|
|
|
add e
|
|
|
|
jr nc, .finish_ohko
|
|
|
|
ld a, $ff
|
|
|
|
.finish_ohko
|
|
|
|
ld [bc], a
|
|
|
|
call BattleCommand_CheckHit
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wCurDamage
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ld a, $2
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wCriticalHit], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
|
|
|
|
|
|
|
.no_effect
|
|
|
|
ld a, $ff
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wCriticalHit], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36b3a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_CheckCharge: ; 36b3a
|
|
|
|
; checkcharge
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
bit SUBSTATUS_CHARGED, [hl]
|
|
|
|
ret z
|
|
|
|
res SUBSTATUS_CHARGED, [hl]
|
|
|
|
res SUBSTATUS_UNDERGROUND, [hl]
|
|
|
|
res SUBSTATUS_FLYING, [hl]
|
|
|
|
ld b, charge_command
|
|
|
|
jp SkipToBattleCommand
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36b4d
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_Charge: ; 36b4d
|
|
|
|
; charge
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_ClearText
|
|
|
|
ld a, BATTLE_VARS_STATUS
|
|
|
|
call GetBattleVar
|
|
|
|
and SLP
|
|
|
|
jr z, .awake
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
call BattleCommand_RaiseSub
|
|
|
|
call PrintButItFailed
|
|
|
|
jp EndMoveEffect
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.awake
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_CHARGED, [hl]
|
|
|
|
|
|
|
|
ld hl, IgnoredOrders2Text
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAlreadyDisobeyed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
call nz, StdBattleTextBox
|
|
|
|
|
|
|
|
call BattleCommand_LowerSub
|
|
|
|
xor a
|
|
|
|
ld [wNumHits], a
|
|
|
|
inc a
|
|
|
|
ld [wKickCounter], a
|
|
|
|
call LoadMoveAnim
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2018-01-26 08:36:00 -08:00
|
|
|
cp FLY
|
|
|
|
jr z, .flying
|
|
|
|
cp DIG
|
|
|
|
jr z, .flying
|
|
|
|
call BattleCommand_RaiseSub
|
|
|
|
jr .not_flying
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.flying
|
|
|
|
call DisappearUser
|
|
|
|
.not_flying
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
ld b, a
|
|
|
|
cp FLY
|
|
|
|
jr z, .set_flying
|
|
|
|
cp DIG
|
|
|
|
jr nz, .dont_set_digging
|
|
|
|
set SUBSTATUS_UNDERGROUND, [hl]
|
|
|
|
jr .dont_set_digging
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.set_flying
|
|
|
|
set SUBSTATUS_FLYING, [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.dont_set_digging
|
|
|
|
call CheckUserIsCharging
|
|
|
|
jr nz, .mimic
|
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE
|
|
|
|
call GetBattleVarAddr
|
|
|
|
ld [hl], b
|
|
|
|
ld a, BATTLE_VARS_LAST_MOVE
|
|
|
|
call GetBattleVarAddr
|
|
|
|
ld [hl], b
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.mimic
|
|
|
|
call ResetDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, .UsedText
|
|
|
|
call BattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_SKULL_BASH
|
|
|
|
ld b, endturn_command
|
|
|
|
jp z, SkipToBattleCommand
|
|
|
|
jp EndMoveEffect
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.UsedText:
|
2018-02-03 15:21:53 -08:00
|
|
|
text_jump UnknownText_0x1c0d0e ; "<USER>"
|
2018-01-26 08:36:00 -08:00
|
|
|
start_asm
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
cp RAZOR_WIND
|
|
|
|
ld hl, .RazorWind
|
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp SOLARBEAM
|
|
|
|
ld hl, .Solarbeam
|
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp SKULL_BASH
|
|
|
|
ld hl, .SkullBash
|
|
|
|
jr z, .done
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp SKY_ATTACK
|
|
|
|
ld hl, .SkyAttack
|
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp FLY
|
|
|
|
ld hl, .Fly
|
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp DIG
|
|
|
|
ld hl, .Dig
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.done
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.RazorWind:
|
|
|
|
; 'made a whirlwind!'
|
|
|
|
text_jump UnknownText_0x1c0d12
|
|
|
|
db "@"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Solarbeam:
|
|
|
|
; 'took in sunlight!'
|
|
|
|
text_jump UnknownText_0x1c0d26
|
|
|
|
db "@"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.SkullBash:
|
|
|
|
; 'lowered its head!'
|
|
|
|
text_jump UnknownText_0x1c0d3a
|
|
|
|
db "@"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.SkyAttack:
|
|
|
|
; 'is glowing!'
|
|
|
|
text_jump UnknownText_0x1c0d4e
|
|
|
|
db "@"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Fly:
|
|
|
|
; 'flew up high!'
|
|
|
|
text_jump UnknownText_0x1c0d5c
|
|
|
|
db "@"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Dig:
|
|
|
|
; 'dug a hole!'
|
|
|
|
text_jump UnknownText_0x1c0d6c
|
|
|
|
db "@"
|
|
|
|
; 36c2c
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand3c: ; 36c2c
|
|
|
|
; unused
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36c2d
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_TrapTarget: ; 36c2d
|
|
|
|
; traptarget
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
ld hl, wEnemyWrapCount
|
|
|
|
ld de, wEnemyTrappingMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_trap
|
|
|
|
ld hl, wPlayerWrapCount
|
|
|
|
ld de, wPlayerTrappingMove
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_trap
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
|
|
|
ret nz
|
|
|
|
call BattleRandom
|
|
|
|
; trapped for 2-5 turns
|
|
|
|
and %11
|
|
|
|
inc a
|
|
|
|
inc a
|
|
|
|
inc a
|
|
|
|
ld [hl], a
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
ld [de], a
|
|
|
|
ld b, a
|
|
|
|
ld hl, .Traps
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.find_trap_text
|
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
|
|
|
jr z, .found_trap_text
|
|
|
|
inc hl
|
|
|
|
inc hl
|
|
|
|
jr .find_trap_text
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.found_trap_text
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Traps:
|
|
|
|
dbw BIND, UsedBindText ; 'used BIND on'
|
|
|
|
dbw WRAP, WrappedByText ; 'was WRAPPED by'
|
|
|
|
dbw FIRE_SPIN, FireSpinTrapText ; 'was trapped!'
|
|
|
|
dbw CLAMP, ClampedByText ; 'was CLAMPED by'
|
|
|
|
dbw WHIRLPOOL, WhirlpoolTrapText ; 'was trapped!'
|
|
|
|
; 36c7e
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/mist.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/focus_energy.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_Recoil: ; 36cb2
|
|
|
|
; recoil
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonMaxHP
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .got_hp
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonMaxHP
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_hp
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
ld d, a
|
|
|
|
; get 1/4 damage or 1 HP, whichever is higher
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurDamage]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurDamage + 1]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
ld a, b
|
|
|
|
or c
|
|
|
|
jr nz, .min_damage
|
|
|
|
inc c
|
|
|
|
.min_damage
|
|
|
|
ld a, [hli]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer2], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer1], a
|
2018-01-26 08:36:00 -08:00
|
|
|
dec hl
|
|
|
|
dec hl
|
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer3], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sub c
|
|
|
|
ld [hld], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer5], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer4], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sbc b
|
|
|
|
ld [hl], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer6], a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nc, .dont_ko
|
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBuffer5
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
.dont_ko
|
|
|
|
hlcoord 10, 9
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
ld a, 1
|
|
|
|
jr z, .animate_hp_bar
|
|
|
|
hlcoord 2, 2
|
|
|
|
xor a
|
|
|
|
.animate_hp_bar
|
|
|
|
ld [wWhichHPBar], a
|
|
|
|
predef AnimateHPBar
|
|
|
|
call RefreshBattleHuds
|
|
|
|
ld hl, RecoilText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36d1d
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_ConfuseTarget: ; 36d1d
|
|
|
|
; confusetarget
|
|
|
|
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_CONFUSE
|
|
|
|
ret z
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2018-01-26 08:36:00 -08:00
|
|
|
call SafeCheckSafeguard
|
|
|
|
ret nz
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
bit SUBSTATUS_CONFUSED, [hl]
|
|
|
|
ret nz
|
|
|
|
jr BattleCommand_FinishConfusingTarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_Confuse: ; 36d3b
|
|
|
|
; confuse
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_CONFUSE
|
|
|
|
jr nz, .no_item_protection
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetItemName
|
|
|
|
call AnimateFailedMove
|
|
|
|
ld hl, ProtectedByText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.no_item_protection
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
bit SUBSTATUS_CONFUSED, [hl]
|
|
|
|
jr z, .not_already_confused
|
|
|
|
call AnimateFailedMove
|
|
|
|
ld hl, AlreadyConfusedText
|
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_already_confused
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit
|
|
|
|
BattleCommand_FinishConfusingTarget: ; 36d70
|
2018-02-03 15:21:53 -08:00
|
|
|
ld bc, wEnemyConfuseCount
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .got_confuse_count
|
2018-02-03 15:21:53 -08:00
|
|
|
ld bc, wPlayerConfuseCount
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_confuse_count
|
|
|
|
set SUBSTATUS_CONFUSED, [hl]
|
|
|
|
; confused for 2-5 turns
|
|
|
|
call BattleRandom
|
|
|
|
and %11
|
|
|
|
inc a
|
|
|
|
inc a
|
|
|
|
ld [bc], a
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_CONFUSE_HIT
|
|
|
|
jr z, .got_effect
|
|
|
|
cp EFFECT_SNORE
|
|
|
|
jr z, .got_effect
|
|
|
|
cp EFFECT_SWAGGER
|
|
|
|
jr z, .got_effect
|
|
|
|
call AnimateCurrentMove
|
|
|
|
|
|
|
|
.got_effect
|
|
|
|
ld de, ANIM_CONFUSED
|
|
|
|
call PlayOpponentBattleAnim
|
|
|
|
|
|
|
|
ld hl, BecameConfusedText
|
|
|
|
call StdBattleTextBox
|
|
|
|
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_HEAL_STATUS
|
|
|
|
jr z, .heal_confusion
|
|
|
|
cp HELD_HEAL_CONFUSION
|
|
|
|
ret nz
|
|
|
|
.heal_confusion
|
|
|
|
ld hl, UseConfusionHealingItem
|
|
|
|
jp CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36db6
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit: ; 36db6
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_CONFUSE_HIT
|
|
|
|
ret z
|
|
|
|
cp EFFECT_SNORE
|
|
|
|
ret z
|
|
|
|
cp EFFECT_SWAGGER
|
|
|
|
ret z
|
|
|
|
jp PrintDidntAffect2
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36dc7
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_Paralyze: ; 36dc7
|
|
|
|
; paralyze
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
bit PAR, a
|
|
|
|
jr nz, .paralyzed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
jr z, .didnt_affect
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_PARALYZE
|
|
|
|
jr nz, .no_item_protection
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetItemName
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, ProtectedByText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.no_item_protection
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
|
|
|
jr nz, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .dont_sample_failure
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
|
|
|
jr nz, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleRandom
|
2018-02-04 10:16:40 -08:00
|
|
|
cp 25 percent + 1 ; 25% chance AI fails
|
2018-01-26 08:36:00 -08:00
|
|
|
jr c, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.dont_sample_failure
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .failed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .failed
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, .failed
|
|
|
|
ld c, 30
|
|
|
|
call DelayFrames
|
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hBGMapMode], a
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
set PAR, [hl]
|
|
|
|
call UpdateOpponentInParty
|
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
|
|
|
call CallBattleCore
|
|
|
|
call UpdateBattleHuds
|
|
|
|
call PrintParalyze
|
|
|
|
ld hl, UseHeldStatusHealingItem
|
|
|
|
jp CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.paralyzed
|
|
|
|
call AnimateFailedMove
|
|
|
|
ld hl, AlreadyParalyzedText
|
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.failed
|
|
|
|
jp PrintDidntAffect2
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.didnt_affect
|
|
|
|
call AnimateFailedMove
|
|
|
|
jp PrintDoesntAffect
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36e5b
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
CheckMoveTypeMatchesTarget: ; 36e5b
|
|
|
|
; Compare move type to opponent type.
|
|
|
|
; Return z if matching the opponent type,
|
|
|
|
; unless the move is Normal (Tri Attack).
|
|
|
|
|
|
|
|
push hl
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
.ok
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
|
|
|
call GetBattleVar
|
|
|
|
cp NORMAL
|
|
|
|
jr z, .normal
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp [hl]
|
|
|
|
jr z, .return
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
inc hl
|
|
|
|
cp [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.return
|
|
|
|
pop hl
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.normal
|
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
pop hl
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36e7c
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/substitute.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_RechargeNextTurn: ; 36f0b
|
|
|
|
; rechargenextturn
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_RECHARGE, [hl]
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36f13
|
2013-09-08 19:44:20 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
EndRechargeOpp: ; 36f13
|
|
|
|
push hl
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
res SUBSTATUS_RECHARGE, [hl]
|
|
|
|
pop hl
|
|
|
|
ret
|
2013-09-08 19:44:20 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36f1d
|
2013-09-08 19:44:20 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/rage.asm"
|
2013-09-08 19:44:20 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_DoubleFlyingDamage: ; 36f25
|
|
|
|
; doubleflyingdamage
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
bit SUBSTATUS_FLYING, a
|
|
|
|
ret z
|
|
|
|
jr DoubleDamage
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36f2f
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_DoubleUndergroundDamage: ; 36f2f
|
|
|
|
; doubleundergrounddamage
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
bit SUBSTATUS_UNDERGROUND, a
|
|
|
|
ret z
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; fallthrough
|
|
|
|
; 36f37
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
DoubleDamage: ; 36f37
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wCurDamage + 1
|
2018-01-26 08:36:00 -08:00
|
|
|
sla [hl]
|
|
|
|
dec hl
|
|
|
|
rl [hl]
|
|
|
|
jr nc, .quit
|
2013-09-08 19:30:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
.quit
|
|
|
|
ret
|
2013-09-08 19:30:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 36f46
|
2013-09-08 19:30:10 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/mimic.asm"
|
2013-09-08 19:30:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/leech_seed.asm"
|
2013-09-08 19:30:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/splash.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/disable.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/pay_day.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/conversion.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_ResetStats: ; 3710e
|
|
|
|
; resetstats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 7 ; neutral
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPlayerStatLevels
|
2018-01-26 08:36:00 -08:00
|
|
|
call .Fill
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyStatLevels
|
2018-01-26 08:36:00 -08:00
|
|
|
call .Fill
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
push af
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call SetPlayerTurn
|
|
|
|
call CalcPlayerStats
|
|
|
|
call SetEnemyTurn
|
|
|
|
call CalcEnemyStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
pop af
|
|
|
|
ld [hBattleTurn], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, EliminatedStatsText
|
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Fill:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld b, wPlayerStatLevelsEnd - wPlayerStatLevels
|
2018-01-26 08:36:00 -08:00
|
|
|
.next
|
|
|
|
ld [hli], a
|
|
|
|
dec b
|
|
|
|
jr nz, .next
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3713e
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_Heal: ; 3713e
|
|
|
|
; heal
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wBattleMonHP
|
|
|
|
ld hl, wBattleMonMaxHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_hp
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyMonHP
|
|
|
|
ld hl, wEnemyMonMaxHP
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_hp
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
ld b, a
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ld c, 2
|
|
|
|
call StringCmp
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
jp z, .hp_full
|
|
|
|
ld a, b
|
|
|
|
cp REST
|
|
|
|
jr nz, .not_rest
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push af
|
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5
|
|
|
|
call GetBattleVarAddr
|
|
|
|
res SUBSTATUS_TOXIC, [hl]
|
|
|
|
ld a, BATTLE_VARS_STATUS
|
|
|
|
call GetBattleVarAddr
|
|
|
|
ld a, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hl], REST_SLEEP_TURNS + 1
|
|
|
|
ld hl, WentToSleepText
|
|
|
|
jr z, .no_status_to_heal
|
|
|
|
ld hl, RestedText
|
|
|
|
.no_status_to_heal
|
|
|
|
call StdBattleTextBox
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr nz, .calc_enemy_stats
|
|
|
|
call CalcPlayerStats
|
|
|
|
jr .got_stats
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.calc_enemy_stats
|
|
|
|
call CalcEnemyStats
|
|
|
|
.got_stats
|
|
|
|
pop af
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_rest
|
|
|
|
jr z, .restore_full_hp
|
|
|
|
ld hl, GetHalfMaxHP
|
|
|
|
call CallBattleCore
|
|
|
|
jr .finish
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.restore_full_hp
|
|
|
|
ld hl, GetMaxHP
|
|
|
|
call CallBattleCore
|
|
|
|
.finish
|
|
|
|
call AnimateCurrentMove
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
ld hl, RestoreHP
|
|
|
|
call CallBattleCore
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
call UpdateUserInParty
|
|
|
|
call RefreshBattleHuds
|
|
|
|
ld hl, RegainedHealthText
|
|
|
|
jp StdBattleTextBox
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.hp_full
|
|
|
|
call AnimateFailedMove
|
|
|
|
ld hl, HPIsFullText
|
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 371cd
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/transform.asm"
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleSideCopy: ; 372c6
|
|
|
|
; Copy bc bytes from hl to de if it's the player's turn.
|
|
|
|
; Copy bc bytes from de to hl if it's the enemy's turn.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .copy
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Swap hl and de
|
|
|
|
push hl
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
|
|
|
pop de
|
|
|
|
.copy
|
|
|
|
jp CopyBytes
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 372d2
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleEffect_ButItFailed: ; 372d2
|
|
|
|
call AnimateFailedMove
|
|
|
|
jp PrintButItFailed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 372d8
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ClearLastMove: ; 372d8
|
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE
|
|
|
|
call GetBattleVarAddr
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_LAST_MOVE
|
|
|
|
call GetBattleVarAddr
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 372e7
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ResetActorDisable: ; 372e7
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .player
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wEnemyDisableCount], a
|
|
|
|
ld [wEnemyDisabledMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.player
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wPlayerDisableCount], a
|
|
|
|
ld [wDisabledMove], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
|
|
|
|
|
|
|
; 372fc
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_Screen: ; 372fc
|
|
|
|
; screen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerScreens
|
2018-02-03 15:21:53 -08:00
|
|
|
ld bc, wPlayerLightScreenCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_screens_pointer
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyScreens
|
2018-02-03 15:21:53 -08:00
|
|
|
ld bc, wEnemyLightScreenCount
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
.got_screens_pointer
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_LIGHT_SCREEN
|
|
|
|
jr nz, .Reflect
|
|
|
|
|
|
|
|
bit SCREENS_LIGHT_SCREEN, [hl]
|
|
|
|
jr nz, .failed
|
|
|
|
set SCREENS_LIGHT_SCREEN, [hl]
|
|
|
|
ld a, 5
|
|
|
|
ld [bc], a
|
|
|
|
ld hl, LightScreenEffectText
|
|
|
|
jr .good
|
|
|
|
|
|
|
|
.Reflect:
|
|
|
|
bit SCREENS_REFLECT, [hl]
|
2014-06-10 23:08:07 -07:00
|
|
|
jr nz, .failed
|
2018-01-26 08:36:00 -08:00
|
|
|
set SCREENS_REFLECT, [hl]
|
|
|
|
|
|
|
|
; LightScreenCount -> ReflectCount
|
|
|
|
inc bc
|
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, 5
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [bc], a
|
|
|
|
ld hl, ReflectEffectText
|
|
|
|
|
|
|
|
.good
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
.failed
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-27 15:50:10 -07:00
|
|
|
jp PrintButItFailed
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3733d
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
PrintDoesntAffect: ; 3733d
|
|
|
|
; 'it doesn't affect'
|
|
|
|
ld hl, DoesntAffectText
|
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37343
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
PrintNothingHappened: ; 37343
|
|
|
|
; 'but nothing happened!'
|
|
|
|
ld hl, NothingHappenedText
|
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37349
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
TryPrintButItFailed: ; 37349
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAlreadyFailed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; fallthrough
|
|
|
|
; 3734e
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
PrintButItFailed: ; 3734e
|
|
|
|
; 'but it failed!'
|
|
|
|
ld hl, ButItFailedText
|
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37354
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
FailMove:
|
|
|
|
call AnimateFailedMove
|
|
|
|
; fallthrough
|
|
|
|
; 37357
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
FailMimic: ; 37357
|
|
|
|
ld hl, ButItFailedText ; 'but it failed!'
|
|
|
|
ld de, ItFailedText ; 'it failed!'
|
|
|
|
jp FailText_CheckOpponentProtect
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37360
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
PrintDidntAffect: ; 37360
|
|
|
|
; 'it didn't affect'
|
|
|
|
ld hl, DidntAffect1Text
|
|
|
|
jp StdBattleTextBox
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37366
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
PrintDidntAffect2: ; 37366
|
|
|
|
call AnimateFailedMove
|
|
|
|
ld hl, DidntAffect1Text ; 'it didn't affect'
|
|
|
|
ld de, DidntAffect2Text ; 'it didn't affect'
|
|
|
|
jp FailText_CheckOpponentProtect
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37372
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
PrintParalyze: ; 37372
|
|
|
|
; 'paralyzed! maybe it can't attack!'
|
|
|
|
ld hl, ParalyzedText
|
|
|
|
jp StdBattleTextBox
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37378
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
CheckSubstituteOpp: ; 37378
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37380
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/selfdestruct.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/mirror_move.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/metronome.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
CheckUserMove: ; 37462
|
|
|
|
; Return z if the user has move a.
|
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wBattleMonMoves
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyMonMoves
|
2018-01-26 08:36:00 -08:00
|
|
|
.ok
|
|
|
|
|
|
|
|
ld c, NUM_MOVES
|
|
|
|
.loop
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
cp b
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 3747b
|
|
|
|
|
|
|
|
|
|
|
|
ResetTurn: ; 3747b
|
|
|
|
ld hl, wPlayerCharging
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .player
|
|
|
|
ld hl, wEnemyCharging
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.player
|
|
|
|
ld [hl], 1
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAlreadyDisobeyed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call DoMove
|
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37492
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/thief.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_ArenaTrap: ; 37517
|
|
|
|
; arenatrap
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Doesn't work on an absent opponent.
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckHiddenOpponent
|
|
|
|
jr nz, .failed
|
|
|
|
|
|
|
|
; Don't trap if the opponent is already trapped.
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5
|
|
|
|
call GetBattleVarAddr
|
|
|
|
bit SUBSTATUS_CANT_RUN, [hl]
|
|
|
|
jr nz, .failed
|
|
|
|
|
|
|
|
; Otherwise trap the opponent.
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
set SUBSTATUS_CANT_RUN, [hl]
|
|
|
|
call AnimateCurrentMove
|
|
|
|
ld hl, CantEscapeNowText
|
|
|
|
jp StdBattleTextBox
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.failed
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-27 15:50:10 -07:00
|
|
|
jp PrintButItFailed
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37536
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/nightmare.asm"
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
BattleCommand_Defrost: ; 37563
|
|
|
|
; defrost
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Thaw the user.
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
bit FRZ, [hl]
|
|
|
|
ret z
|
|
|
|
res FRZ, [hl]
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Don't update the enemy's party struct in a wild battle.
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .party
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wBattleMode]
|
|
|
|
dec a
|
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.party
|
|
|
|
ld a, MON_STATUS
|
|
|
|
call UserPartyAttr
|
|
|
|
res FRZ, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.done
|
|
|
|
call RefreshBattleHuds
|
|
|
|
ld hl, WasDefrostedText
|
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37588
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/curse.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/protect.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/endure.asm"
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/spikes.asm"
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/foresight.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/perish_song.asm"
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/sandstorm.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/rollout.asm"
|
|
|
|
|
|
|
|
|
|
|
|
BattleCommand5d: ; 37791
|
|
|
|
; unused
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; 37792
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/fury_cutter.asm"
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/attract.asm"
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/return.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/present.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/frustration.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/safeguard.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
SafeCheckSafeguard: ; 37962
|
|
|
|
push hl
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyScreens
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_turn
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPlayerScreens
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_turn
|
|
|
|
bit SCREENS_SAFEGUARD, [hl]
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
|
|
|
; 37972
|
|
|
|
|
|
|
|
|
|
|
|
BattleCommand_CheckSafeguard: ; 37972
|
|
|
|
; checksafeguard
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyScreens
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_turn
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPlayerScreens
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_turn
|
|
|
|
bit SCREENS_SAFEGUARD, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
ld hl, SafeguardProtectText
|
|
|
|
call StdBattleTextBox
|
|
|
|
jp EndMoveEffect
|
|
|
|
|
|
|
|
; 37991
|
|
|
|
|
|
|
|
|
|
|
|
INCLUDE "engine/battle/move_effects/magnitude.asm"
|
|
|
|
|
|
|
|
INCLUDE "engine/battle/move_effects/baton_pass.asm"
|
|
|
|
|
|
|
|
INCLUDE "engine/battle/move_effects/pursuit.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/rapid_spin.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_HealMorn: ; 37b74
|
2013-03-26 17:39:44 -07:00
|
|
|
; healmorn
|
2017-12-10 22:02:28 -08:00
|
|
|
ld b, MORN_F
|
2015-12-23 17:46:23 -08:00
|
|
|
jr BattleCommand_TimeBasedHealContinue
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37b78
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_HealDay: ; 37b78
|
2013-03-26 17:39:44 -07:00
|
|
|
; healday
|
2017-12-10 22:02:28 -08:00
|
|
|
ld b, DAY_F
|
2015-12-23 17:46:23 -08:00
|
|
|
jr BattleCommand_TimeBasedHealContinue
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37b7c
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_HealNite: ; 37b7c
|
2013-03-26 17:39:44 -07:00
|
|
|
; healnite
|
2017-12-10 22:02:28 -08:00
|
|
|
ld b, NITE_F
|
2013-03-26 17:39:44 -07:00
|
|
|
; fallthrough
|
|
|
|
; 37b7e
|
|
|
|
|
2015-12-23 17:46:23 -08:00
|
|
|
BattleCommand_TimeBasedHealContinue: ; 37b7e
|
2013-03-26 17:39:44 -07:00
|
|
|
; Time- and weather-sensitive heal.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonMaxHP
|
|
|
|
ld de, wBattleMonHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .start
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMaxHP
|
|
|
|
ld de, wEnemyMonHP
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
.start
|
|
|
|
; Index for .Multipliers
|
|
|
|
; Default restores half max HP.
|
|
|
|
ld c, 2
|
|
|
|
|
|
|
|
; Don't bother healing if HP is already full.
|
|
|
|
push bc
|
|
|
|
call StringCmp
|
|
|
|
pop bc
|
|
|
|
jr z, .Full
|
|
|
|
|
|
|
|
; Don't factor in time of day in link battles.
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr nz, .Weather
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTimeOfDay]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
|
|
|
jr z, .Weather
|
2015-12-23 17:46:23 -08:00
|
|
|
dec c ; double
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Weather:
|
2018-01-23 13:45:34 -08:00
|
|
|
ld a, [wBattleWeather]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .Heal
|
|
|
|
|
|
|
|
; x2 in sun
|
|
|
|
; /2 in rain/sandstorm
|
|
|
|
inc c
|
|
|
|
cp WEATHER_SUN
|
|
|
|
jr z, .Heal
|
|
|
|
dec c
|
2015-12-26 18:59:03 -08:00
|
|
|
dec c
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Heal:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
ld hl, .Multipliers
|
|
|
|
add hl, bc
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, bc
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld a, BANK(GetMaxHP)
|
|
|
|
rst FarCall
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar RestoreHP
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateUserInParty
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
; 'regained health!'
|
|
|
|
ld hl, RegainedHealthText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Full:
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
; 'hp is full!'
|
|
|
|
ld hl, HPIsFullText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Multipliers:
|
2013-03-26 17:39:44 -07:00
|
|
|
dw GetEighthMaxHP
|
|
|
|
dw GetQuarterMaxHP
|
|
|
|
dw GetHalfMaxHP
|
|
|
|
dw GetMaxHP
|
|
|
|
; 37be8
|
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/hidden_power.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/rain_dance.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/sunny_day.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/belly_drum.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/psych_up.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/mirror_coat.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DoubleMinimizeDamage: ; 37ce6
|
2013-03-26 22:52:04 -07:00
|
|
|
; doubleminimizedamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, wEnemyMinimized
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, wPlayerMinimized
|
2014-06-10 23:08:07 -07:00
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
sla [hl]
|
|
|
|
dec hl
|
|
|
|
rl [hl]
|
|
|
|
ret nc
|
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37d02
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SkipSunCharge: ; 37d02
|
2015-11-09 13:41:09 -08:00
|
|
|
; mimicsuncharge
|
2018-01-23 13:45:34 -08:00
|
|
|
ld a, [wBattleWeather]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp WEATHER_SUN
|
|
|
|
ret nz
|
2015-04-13 21:39:54 -07:00
|
|
|
ld b, charge_command
|
2013-03-26 22:52:04 -07:00
|
|
|
jp SkipToBattleCommand
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37d0d
|
|
|
|
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/future_sight.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/thunder.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
CheckHiddenOpponent: ; 37daa
|
2017-12-19 16:04:56 -08:00
|
|
|
; BUG: This routine should account for Lock-On and Mind Reader.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-10 23:08:07 -07:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37db2
|
|
|
|
|
|
|
|
|
|
|
|
GetUserItem: ; 37db2
|
|
|
|
; Return the effect of the user's item in bc, and its id at hl.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonItem
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .go
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonItem
|
2013-03-26 17:39:44 -07:00
|
|
|
.go
|
|
|
|
ld b, [hl]
|
2015-11-10 08:05:26 -08:00
|
|
|
jp GetItemHeldEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37dc1
|
|
|
|
|
|
|
|
|
|
|
|
GetOpponentItem: ; 37dc1
|
|
|
|
; Return the effect of the opponent's item in bc, and its id at hl.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonItem
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .go
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonItem
|
2013-03-26 17:39:44 -07:00
|
|
|
.go
|
|
|
|
ld b, [hl]
|
2015-11-10 08:05:26 -08:00
|
|
|
jp GetItemHeldEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37dd0
|
|
|
|
|
|
|
|
|
2015-11-10 08:05:26 -08:00
|
|
|
GetItemHeldEffect: ; 37dd0
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return the effect of item b in bc.
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push hl
|
2017-12-14 09:19:26 -08:00
|
|
|
ld hl, ItemAttributes + ITEMATTR_EFFECT
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2017-12-12 17:15:07 -08:00
|
|
|
ld a, ITEMATTR_STRUCT_LENGTH
|
2013-03-26 17:39:44 -07:00
|
|
|
call AddNTimes
|
2013-04-29 23:01:54 -07:00
|
|
|
ld a, BANK(ItemAttributes)
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetFarHalfword
|
|
|
|
ld b, l
|
|
|
|
ld c, h
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37de9
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
AnimateCurrentMoveEitherSide: ; 37de9
|
2013-03-27 13:19:51 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wKickCounter]
|
2013-03-27 13:19:51 -07:00
|
|
|
push af
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2013-03-27 13:19:51 -07:00
|
|
|
pop af
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2015-11-09 13:41:09 -08:00
|
|
|
call PlayDamageAnim
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2013-03-27 13:19:51 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37e01
|
|
|
|
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
AnimateCurrentMove: ; 37e01
|
2013-03-27 13:19:51 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wKickCounter]
|
2013-03-27 13:19:51 -07:00
|
|
|
push af
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2013-03-27 13:19:51 -07:00
|
|
|
pop af
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2015-11-09 13:41:09 -08:00
|
|
|
call LoadMoveAnim
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2013-03-27 13:19:51 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37e19
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
PlayDamageAnim: ; 37e19
|
2013-03-27 13:19:51 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-27 13:19:51 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_ENEMY_DAMAGE
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .player
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_PLAYER_DAMAGE
|
2013-03-27 13:19:51 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.player
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
jp PlayUserBattleAnim
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37e36
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
LoadMoveAnim: ; 37e36
|
2013-03-27 13:19:51 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-27 13:19:51 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; fallthrough
|
|
|
|
; 37e44
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
LoadAnim: ; 37e44
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 37e47
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
PlayUserBattleAnim: ; 37e47
|
2013-03-27 13:19:51 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-01-16 11:30:10 -08:00
|
|
|
callfar PlayBattleAnim
|
2013-03-27 13:19:51 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37e54
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
PlayOpponentBattleAnim: ; 37e54
|
2013-03-27 13:19:51 -07:00
|
|
|
ld a, e
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID], a
|
2013-03-27 13:19:51 -07:00
|
|
|
ld a, d
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-27 13:19:51 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-27 13:19:51 -07:00
|
|
|
|
2018-01-16 11:30:10 -08:00
|
|
|
callfar PlayBattleAnim
|
2013-03-27 13:19:51 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-27 13:19:51 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37e73
|
|
|
|
|
|
|
|
|
2013-12-31 00:25:38 -08:00
|
|
|
CallBattleCore: ; 37e73
|
|
|
|
ld a, BANK(BattleCore)
|
2013-03-27 13:19:51 -07:00
|
|
|
rst FarCall
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37e77
|
|
|
|
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
AnimateFailedMove: ; 37e77
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2015-11-06 13:42:38 -08:00
|
|
|
jp BattleCommand_RaiseSub
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37e80
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_MoveDelay: ; 37e80
|
2013-09-30 22:02:33 -07:00
|
|
|
; movedelay
|
2013-03-26 17:39:44 -07:00
|
|
|
; Wait 40 frames.
|
|
|
|
ld c, 40
|
|
|
|
jp DelayFrames
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37e85
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_ClearText: ; 37e85
|
2013-03-26 22:52:04 -07:00
|
|
|
; cleartext
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; Used in multi-hit moves.
|
|
|
|
ld hl, .text
|
|
|
|
jp BattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
.text
|
|
|
|
db "@"
|
|
|
|
; 37e8c
|
|
|
|
|
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
SkipToBattleCommand: ; 37e8c
|
|
|
|
; Skip over commands until reaching command b.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress + 1]
|
2013-03-26 22:52:04 -07:00
|
|
|
ld h, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress]
|
2013-03-26 22:52:04 -07:00
|
|
|
ld l, a
|
2015-11-09 13:41:09 -08:00
|
|
|
.loop
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .loop
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress + 1], a
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress], a
|
2013-03-26 22:52:04 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
; 37ea1
|
|
|
|
|
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
GetMoveAttr: ; 37ea1
|
|
|
|
; Assuming hl = Moves + x, return attribute x of move a.
|
|
|
|
push bc
|
2014-06-10 23:23:55 -07:00
|
|
|
ld bc, MOVE_LENGTH
|
2013-03-27 13:19:51 -07:00
|
|
|
call AddNTimes
|
|
|
|
call GetMoveByte
|
|
|
|
pop bc
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37ead
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
GetMoveData: ; 37ead
|
2013-03-27 13:19:51 -07:00
|
|
|
; Copy move struct a to de.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, Moves
|
2014-06-10 23:23:55 -07:00
|
|
|
ld bc, MOVE_LENGTH
|
2013-03-26 17:39:44 -07:00
|
|
|
call AddNTimes
|
|
|
|
ld a, Bank(Moves)
|
|
|
|
jp FarCopyBytes
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37ebb
|
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
|
|
|
|
GetMoveByte: ; 37ebb
|
|
|
|
ld a, BANK(Moves)
|
|
|
|
jp GetFarByte
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37ec0
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
DisappearUser: ; 37ec0
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _DisappearUser
|
2013-03-27 13:19:51 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37ec7
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
AppearUserLowerSub: ; 37ec7
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _AppearUserLowerSub
|
2013-03-27 13:19:51 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37ece
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
AppearUserRaiseSub: ; 37ece
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _AppearUserRaiseSub
|
2013-03-27 13:19:51 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37ed5
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
_CheckBattleScene: ; 37ed5
|
|
|
|
; Checks the options. Returns carry if battle animations are disabled.
|
2013-03-27 13:19:51 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckBattleScene
|
2013-03-27 13:19:51 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 13:19:51 -07:00
|
|
|
; 37ee2
|