2013-03-26 17:39:44 -07:00
|
|
|
DoPlayerTurn: ; 34000
|
|
|
|
call SetPlayerTurn
|
|
|
|
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wPlayerAction]
|
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
|
|
|
|
|
|
|
|
ld de, BattleScriptBuffer
|
|
|
|
|
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
|
|
|
|
cp $ff
|
|
|
|
jr nz, .GetMoveEffect
|
|
|
|
|
|
|
|
; Start at the first command.
|
|
|
|
ld hl, BattleScriptBuffer
|
|
|
|
ld a, l
|
2017-12-09 11:22:58 -08:00
|
|
|
ld [BattleScriptBufferAddress], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
2017-12-09 11:22:58 -08:00
|
|
|
ld [BattleScriptBufferAddress + 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
|
|
|
|
2017-12-09 11:22:58 -08:00
|
|
|
; ld a, [BattleScriptBufferAddress++]
|
|
|
|
ld a, [BattleScriptBufferAddress]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld l, a
|
2017-12-09 11:22:58 -08:00
|
|
|
ld a, [BattleScriptBufferAddress + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, a
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
|
|
|
push af
|
|
|
|
ld a, l
|
2017-12-09 11:22:58 -08:00
|
|
|
ld [BattleScriptBufferAddress], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
2017-12-09 11:22:58 -08:00
|
|
|
ld [BattleScriptBufferAddress + 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
|
|
|
|
ld [AttackMissed], a
|
2013-06-13 13:10:39 -07:00
|
|
|
ld [EffectFailed], a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [AlreadyDisobeyed], a
|
2013-03-27 15:50:10 -07:00
|
|
|
ld [AlreadyFailed], a
|
2016-01-09 13:28:22 -08:00
|
|
|
ld [wSomeoneIsRampaging], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, 10 ; 1.0
|
|
|
|
ld [TypeModifier], a
|
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jp nz, CheckEnemyTurn
|
|
|
|
|
|
|
|
|
|
|
|
CheckPlayerTurn:
|
|
|
|
|
|
|
|
ld hl, PlayerSubStatus4
|
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
|
|
|
|
|
|
|
ld hl, BattleMonStatus
|
|
|
|
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
|
|
|
|
ld [BattleMonStatus], 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
|
2014-06-16 22:52:59 -07: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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerSubStatus1
|
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.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CurPlayerMove]
|
|
|
|
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
|
|
|
|
|
|
|
ld hl, BattleMonStatus
|
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.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CurPlayerMove]
|
|
|
|
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
|
|
|
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
ld hl, PlayerSubStatus3
|
|
|
|
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
|
|
|
|
|
|
|
ld hl, PlayerDisableCount
|
|
|
|
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
|
|
|
|
ld [DisabledMove], a
|
|
|
|
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
|
|
|
|
|
|
|
ld a, [PlayerSubStatus3]
|
|
|
|
add a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nc, .not_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerConfuseCount
|
|
|
|
dec [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, PlayerSubStatus3
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
cp $80
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerSubStatus3
|
|
|
|
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
|
|
|
|
|
|
|
ld a, [PlayerSubStatus1]
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
cp $80
|
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.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [DisabledMove]
|
|
|
|
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?
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurPlayerMove
|
|
|
|
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
|
|
|
|
|
|
|
ld hl, BattleMonStatus
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
cp $3f
|
|
|
|
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
|
|
|
|
|
|
|
|
ld hl, EnemySubStatus4
|
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
|
|
|
|
|
|
|
ld hl, EnemyMonStatus
|
|
|
|
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
|
|
|
|
ld [EnemyMonStatus], a
|
|
|
|
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
|
2014-06-16 22:52:59 -07: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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemySubStatus1
|
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.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CurEnemyMove]
|
|
|
|
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
|
|
|
|
|
|
|
ld hl, EnemyMonStatus
|
2014-06-13 21:18:14 -07:00
|
|
|
bit FRZ, [hl]
|
|
|
|
jr z, .not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CurEnemyMove]
|
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
|
|
|
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
ld hl, EnemySubStatus3
|
|
|
|
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
|
|
|
|
2013-05-02 22:29:57 -07:00
|
|
|
ld hl, EnemyDisableCount
|
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
|
2013-05-03 18:04:34 -07:00
|
|
|
ld [EnemyDisabledMove], 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
|
|
|
|
|
|
|
ld a, [EnemySubStatus3]
|
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
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, EnemyConfuseCount
|
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
|
|
|
|
|
|
|
ld hl, EnemySubStatus3
|
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
|
2015-11-09 13:41:09 -08:00
|
|
|
cp 1 + 50 percent
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemySubStatus3
|
|
|
|
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
|
|
|
|
|
|
|
|
ld c, $1
|
2015-11-09 13:41:09 -08:00
|
|
|
call EnemyHurtItself
|
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
|
|
|
|
|
|
|
ld a, [EnemySubStatus1]
|
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
|
2015-11-09 13:41:09 -08:00
|
|
|
cp 1 + 50 percent
|
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.
|
2013-05-03 18:04:34 -07:00
|
|
|
ld a, [EnemyDisabledMove]
|
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?
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurEnemyMove
|
|
|
|
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
|
|
|
|
|
|
|
ld hl, EnemyMonStatus
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
cp $3f
|
|
|
|
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
|
|
|
|
ld [CriticalHit], a
|
|
|
|
|
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
|
|
|
|
|
2014-06-16 22:52:59 -07: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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, $1
|
2015-11-09 13:41:09 -08:00
|
|
|
call PlayerHurtItself
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AlreadyDisobeyed]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
xor a
|
|
|
|
ld [AlreadyDisobeyed], a
|
|
|
|
|
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
|
|
|
|
|
2015-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle]
|
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
|
|
|
|
|
|
|
|
ld a, [PlayerID]
|
|
|
|
cp [hl]
|
|
|
|
jr nz, .obeylevel
|
|
|
|
inc hl
|
|
|
|
ld a, [PlayerID + 1]
|
|
|
|
cp [hl]
|
|
|
|
ret z
|
|
|
|
|
|
|
|
|
|
|
|
.obeylevel
|
2014-06-13 21:18:14 -07:00
|
|
|
; The maximum obedience level is constrained by owned badges:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, JohtoBadges
|
|
|
|
|
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
|
|
|
|
|
|
|
|
ld a, [BattleMonLevel]
|
|
|
|
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
|
|
|
|
|
|
|
|
ld [BattleMonStatus], a
|
|
|
|
|
|
|
|
ld hl, BeganToNapText
|
|
|
|
jr .Print
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoNothing:
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and 3
|
|
|
|
|
|
|
|
ld hl, LoafingAroundText
|
|
|
|
and a
|
|
|
|
jr z, .Print
|
|
|
|
|
|
|
|
ld hl, WontObeyText
|
|
|
|
dec a
|
|
|
|
jr z, .Print
|
|
|
|
|
|
|
|
ld hl, TurnedAwayText
|
|
|
|
dec a
|
|
|
|
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!
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, [BattleMonMoves + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .DoNothing
|
|
|
|
|
|
|
|
; Don't bother trying to handle Disable.
|
|
|
|
ld a, [DisabledMove]
|
|
|
|
and a
|
|
|
|
jr nz, .DoNothing
|
|
|
|
|
|
|
|
|
|
|
|
ld hl, BattleMonPP
|
|
|
|
ld de, BattleMonMoves
|
|
|
|
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]
|
|
|
|
and $3f ; exclude pp up
|
|
|
|
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:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonPP
|
|
|
|
ld a, [CurMoveNum]
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
|
|
|
|
; Can't use another move if only one move has PP.
|
|
|
|
ld a, [hl]
|
|
|
|
and $3f
|
|
|
|
cp b
|
|
|
|
jr z, .DoNothing
|
|
|
|
|
|
|
|
|
|
|
|
; Make sure we can actually use the move once we get there.
|
|
|
|
ld a, 1
|
|
|
|
ld [AlreadyDisobeyed], a
|
|
|
|
|
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.
|
|
|
|
ld a, [CurMoveNum]
|
|
|
|
ld c, a
|
|
|
|
push af
|
|
|
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.RandomMove:
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2014-06-13 21:18:14 -07:00
|
|
|
and 3 ; TODO 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.
|
|
|
|
ld [CurMoveNum], a
|
|
|
|
ld hl, BattleMonPP
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
and $3f
|
|
|
|
jr z, .RandomMove
|
|
|
|
|
|
|
|
|
|
|
|
; Use it.
|
|
|
|
ld a, [CurMoveNum]
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld hl, BattleMonMoves
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld [CurPlayerMove], a
|
|
|
|
|
|
|
|
call SetPlayerTurn
|
|
|
|
call UpdateMoveData
|
|
|
|
call DoMove
|
|
|
|
|
|
|
|
|
|
|
|
; Restore original move choice.
|
|
|
|
pop af
|
|
|
|
ld [CurMoveNum], a
|
|
|
|
|
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
|
|
|
|
ld [LastPlayerMove], a
|
2017-01-07 16:43:25 -08:00
|
|
|
ld [LastPlayerCounterMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-17 12:52:32 -07:00
|
|
|
; Break Encore too.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerSubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
res SUBSTATUS_ENCORED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [PlayerEncoreCount], a
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
ld hl, BattleMonPP
|
|
|
|
ld de, PlayerSubStatus3
|
|
|
|
ld bc, PlayerTurnsTaken
|
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr z, .proceed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, EnemyMonPP
|
|
|
|
ld de, EnemySubStatus3
|
|
|
|
ld bc, EnemyTurnsTaken
|
|
|
|
|
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
|
|
|
|
|
|
|
|
ld hl, PartyMon1PP
|
|
|
|
ld a, [CurBattleMon]
|
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
|
|
|
|
|
|
|
ld hl, OTPartyMon1PP
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
|
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
|
|
|
|
ld a, [CurMoveNum]
|
2015-11-06 11:45:10 -08:00
|
|
|
jr z, .okay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CurEnemyMoveNum]
|
|
|
|
|
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]
|
|
|
|
and $3f
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonMoves
|
|
|
|
ld a, [CurEnemyMoveNum]
|
|
|
|
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
|
|
|
|
db $ff
|
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
|
|
|
|
ld a, [CurMoveNum]
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .player
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CurEnemyMoveNum]
|
|
|
|
|
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
|
|
|
|
ld [CriticalHit], a
|
|
|
|
|
|
|
|
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
|
|
|
|
ld hl, EnemyMonItem
|
|
|
|
ld a, [EnemyMonSpecies]
|
|
|
|
jr nz, .Item
|
|
|
|
ld hl, BattleMonItem
|
|
|
|
ld a, [BattleMonSpecies]
|
|
|
|
|
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
|
|
|
|
ld hl, .Criticals
|
|
|
|
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:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, .Chances
|
|
|
|
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
|
|
|
|
ld [CriticalHit], a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Criticals:
|
2013-03-26 17:39:44 -07:00
|
|
|
db KARATE_CHOP, RAZOR_WIND, RAZOR_LEAF, CRABHAMMER, SLASH, AEROBLAST, CROSS_CHOP, $ff
|
2016-04-10 11:42:14 -07:00
|
|
|
.Chances:
|
2013-03-26 17:39:44 -07:00
|
|
|
; 6.25% 12.1% 24.6% 33.2% 49.6% 49.6% 49.6%
|
|
|
|
db $11, $20, $40, $55, $80, $80, $80
|
|
|
|
; 0 1 2 3 4 5 6
|
|
|
|
; 346b2
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_TripleKick: ; 346b2
|
2013-03-26 22:52:04 -07:00
|
|
|
; triplekick
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wKickCounter]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
inc b
|
|
|
|
ld hl, CurDamage + 1
|
|
|
|
ld a, [hld]
|
|
|
|
ld e, a
|
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
2015-11-06 17:55:16 -08:00
|
|
|
.next_kick
|
2013-03-26 17:39:44 -07:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
ld a, [hl]
|
|
|
|
add e
|
|
|
|
ld [hld], a
|
|
|
|
ld a, [hl]
|
|
|
|
adc d
|
|
|
|
ld [hli], a
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
; No overflow.
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nc, .next_kick
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $ff
|
|
|
|
ld [hld], a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 346cd
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_KickCounter: ; 346cd
|
2013-03-26 22:52:04 -07:00
|
|
|
; kickcounter
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ld hl, wKickCounter
|
2013-03-26 17:39:44 -07:00
|
|
|
inc [hl]
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 346d2
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
ld hl, BattleMonType1
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
ld hl, EnemyMonType1
|
|
|
|
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
|
|
|
|
|
|
|
ld hl, EnemyMonType1
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
ld hl, BattleMonType1
|
|
|
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage + 1
|
|
|
|
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
|
|
|
|
ld [CurDamage], a
|
|
|
|
ld a, l
|
|
|
|
ld [CurDamage + 1], a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, TypeModifier
|
|
|
|
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
|
|
|
|
ld hl, TypeMatchup
|
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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
cp $ff
|
2013-04-19 00:50:45 -07:00
|
|
|
jr z, .end
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; foresight
|
2013-03-26 17:39:44 -07:00
|
|
|
cp $fe
|
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
|
|
|
|
ld a, [TypeModifier]
|
|
|
|
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
|
|
|
|
ld [AttackMissed], a
|
|
|
|
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
|
|
|
|
ld [TypeModifier], 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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
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
|
|
|
|
ld a, [TypeModifier]
|
2015-11-06 17:55:16 -08:00
|
|
|
and %10000000
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
|
|
|
ld [TypeModifier], a
|
|
|
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonType1
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, CheckTypeMatchup
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonType1
|
2015-11-06 17:55:16 -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
|
|
|
|
; 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,
|
|
|
|
; 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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, TypeMatchup
|
2016-04-10 11:42:14 -07:00
|
|
|
.TypesLoop:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp $ff
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .End
|
2013-03-26 17:39:44 -07:00
|
|
|
cp $fe
|
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
|
|
|
|
ld [TypeModifier], a
|
|
|
|
inc a
|
|
|
|
ld [AttackMissed], a
|
|
|
|
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
|
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
INCLUDE "battle/ai/switch.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
TypeMatchup: ; 34bb1
|
|
|
|
INCLUDE "battle/type_matchup.asm"
|
|
|
|
; 34cfd
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
ld hl, CurDamage
|
|
|
|
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
|
|
|
|
cp $d9 ; 85%
|
|
|
|
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]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
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
|
|
|
|
cp $ff
|
|
|
|
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
|
|
|
|
ld [AttackMissed], a
|
|
|
|
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
|
|
|
|
|
|
|
|
ld a, [Weather]
|
|
|
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [PlayerAccLevel]
|
|
|
|
ld b, a
|
|
|
|
ld a, [EnemyEvaLevel]
|
|
|
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [EnemyAccLevel]
|
|
|
|
ld b, a
|
|
|
|
ld a, [PlayerEvaLevel]
|
|
|
|
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
|
2015-12-26 15:11:55 -08:00
|
|
|
ld a, 14
|
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
|
|
|
|
ld hl, .AccProb
|
|
|
|
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
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.AccProb:
|
2013-03-26 17:39:44 -07:00
|
|
|
db 33, 100 ; 33% -6
|
|
|
|
db 36, 100 ; 36% -5
|
|
|
|
db 43, 100 ; 43% -4
|
|
|
|
db 50, 100 ; 50% -3
|
|
|
|
db 60, 100 ; 60% -2
|
|
|
|
db 75, 100 ; 75% -1
|
|
|
|
db 1, 1 ; 100% 0
|
|
|
|
db 133, 100 ; 133% +1
|
|
|
|
db 166, 100 ; 166% +2
|
|
|
|
db 2, 1 ; 200% +3
|
|
|
|
db 233, 100 ; 233% +4
|
|
|
|
db 133, 50 ; 266% +5
|
|
|
|
db 3, 1 ; 300% +6
|
|
|
|
|
|
|
|
; 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
|
2013-06-13 13:10:39 -07:00
|
|
|
ld [EffectFailed], 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
|
2013-06-13 13:10:39 -07:00
|
|
|
ld [EffectFailed], 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
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID + 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
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_HitTarget: ; 34f57
|
2013-03-26 17:39:44 -07:00
|
|
|
; hittarget
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2015-11-06 17:55:16 -08:00
|
|
|
call BattleCommand_HitTargetNoSub
|
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
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
BattleCommand_HitTargetNoSub: ; 34f60
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
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
|
2013-04-19 00:50:45 -07:00
|
|
|
ld de, PlayerRolloutCount
|
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
|
2013-04-19 00:50:45 -07:00
|
|
|
ld de, EnemyRolloutCount
|
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
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .multihit
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_CONVERSION
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .conversion
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_DOUBLE_HIT
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .doublehit
|
2017-11-15 07:36:13 -08:00
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .twineedle
|
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
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .fly_dig
|
2013-03-26 17:39:44 -07:00
|
|
|
cp DIG
|
|
|
|
ret nz
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
.fly_dig
|
2013-03-26 17:39:44 -07:00
|
|
|
; clear sprite
|
2015-11-09 13:41:09 -08:00
|
|
|
jp AppearUserLowerSub
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.multihit
|
|
|
|
.conversion
|
|
|
|
.doublehit
|
|
|
|
.twineedle
|
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]
|
|
|
|
cp $1
|
|
|
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
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
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID + 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.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_CheckFaint: ; 3505e
|
2013-03-27 14:07:00 -07:00
|
|
|
; checkfaint
|
|
|
|
|
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
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .not_enduring
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_FalseSwipe
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, $0
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nc, .okay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, $1
|
2015-11-09 13:41:09 -08:00
|
|
|
jr .okay
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.not_enduring
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, $0
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .okay
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nc, .okay
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_FalseSwipe
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, $0
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nc, .okay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, $2
|
2015-11-09 13:41:09 -08:00
|
|
|
.okay
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2015-11-09 13:41:09 -08:00
|
|
|
call .check_sub
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, $0
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .damage_player
|
|
|
|
call EnemyHurtItself
|
|
|
|
jr .done_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.damage_player
|
|
|
|
call PlayerHurtItself
|
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
|
|
|
|
dec a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .not_enduring2
|
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
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.not_enduring2
|
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
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.check_sub
|
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
|
|
|
|
|
|
|
ld de, PlayerDamageTaken + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .damage_taken
|
2013-05-02 22:29:57 -07:00
|
|
|
ld de, EnemyDamageTaken + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.damage_taken
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CurDamage + 1]
|
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
|
|
|
add b
|
|
|
|
ld [de], a
|
|
|
|
dec de
|
|
|
|
ld a, [CurDamage]
|
|
|
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [TypeModifier]
|
|
|
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CriticalHit]
|
|
|
|
cp $ff
|
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
|
|
|
|
ld [CriticalHit], 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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [TypeModifier]
|
|
|
|
and $7f
|
|
|
|
ret z
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, [hl]
|
2014-06-23 12:47:07 -07:00
|
|
|
rept 3
|
2013-03-26 17:39:44 -07:00
|
|
|
srl a
|
|
|
|
rr b
|
2014-06-23 12:47:07 -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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, $1
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jp nz, EnemyHurtItself
|
|
|
|
jp PlayerHurtItself
|
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
|
|
|
|
|
|
|
|
|
|
|
|
BattleCommanda5: ; 35165
|
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, [TypeModifier]
|
|
|
|
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.
|
|
|
|
ld a, [CriticalHit]
|
|
|
|
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
|
|
|
|
ld [CriticalHit], a
|
|
|
|
|
|
|
|
.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
|
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
ld hl, PlayerRolloutCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-23 12:47:07 -07:00
|
|
|
jr z, .ok
|
2013-04-19 00:50:45 -07:00
|
|
|
ld hl, EnemyRolloutCount
|
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
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [TypeModifier]
|
|
|
|
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.
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonHP
|
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
|
2013-04-27 14:12:23 -07:00
|
|
|
ld hl, EnemyMonMaxHP + 1
|
|
|
|
bccoord 2, 2 ; hp bar
|
|
|
|
ld a, 0
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .got_max_hp
|
2013-04-27 14:12:23 -07:00
|
|
|
ld hl, BattleMonMaxHP + 1
|
|
|
|
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]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer3], a
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hld], a
|
|
|
|
ld a, [hl]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer4], a
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer5], a
|
|
|
|
ld [Buffer6], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, b
|
|
|
|
ld l, c
|
2015-11-07 05:05:57 -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
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID + 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
|
|
|
|
ld a, [AttackMissed]
|
|
|
|
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
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CurDamage]
|
|
|
|
ld h, a
|
|
|
|
ld b, a
|
|
|
|
ld a, [CurDamage + 1]
|
|
|
|
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
|
2015-11-09 20:01:45 -08:00
|
|
|
ld hl, -1
|
2015-12-26 15:11:55 -08:00
|
|
|
.done
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
|
|
|
ld [CurDamage], a
|
|
|
|
ld a, l
|
|
|
|
ld [CurDamage + 1], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 352a3
|
|
|
|
|
|
|
|
|
|
|
|
EndMoveEffect: ; 352a3
|
2017-12-09 11:22:58 -08:00
|
|
|
ld a, [BattleScriptBufferAddress]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld l, a
|
2017-12-09 11:22:58 -08:00
|
|
|
ld a, [BattleScriptBufferAddress + 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
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
|
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
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonDefense
|
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
|
|
|
|
2013-04-19 23:57:11 -07:00
|
|
|
ld a, [EnemyScreens]
|
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
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BattleMonAttack
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetDamageStatsCritical
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .thickclub
|
|
|
|
|
2016-05-15 18:50:31 -07:00
|
|
|
ld hl, EnemyDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2016-05-15 18:50:31 -07:00
|
|
|
ld hl, PlayerAttack
|
2013-04-19 23:53:08 -07:00
|
|
|
jr .thickclub
|
|
|
|
|
|
|
|
.special
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonSpclDef
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-04-19 23:57:11 -07:00
|
|
|
ld a, [EnemyScreens]
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonSpclAtk
|
|
|
|
call GetDamageStatsCritical
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .lightball
|
|
|
|
|
2016-05-15 18:50:31 -07:00
|
|
|
ld hl, EnemySpDef
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2016-05-15 18:50:31 -07:00
|
|
|
ld hl, PlayerSpAtk
|
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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [BattleMonLevel]
|
|
|
|
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.
|
|
|
|
|
|
|
|
ld a, [CriticalHit]
|
|
|
|
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
|
|
|
|
ld a, [PlayerSAtkLevel]
|
|
|
|
ld b, a
|
|
|
|
ld a, [EnemySDefLevel]
|
|
|
|
jr nc, .end
|
|
|
|
; physical
|
|
|
|
ld a, [PlayerAtkLevel]
|
|
|
|
ld b, a
|
|
|
|
ld a, [EnemyDefLevel]
|
|
|
|
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
|
|
|
|
ld a, [EnemySAtkLevel]
|
|
|
|
ld b, a
|
|
|
|
ld a, [PlayerSDefLevel]
|
|
|
|
jr nc, .end
|
|
|
|
; physical
|
|
|
|
ld a, [EnemyAtkLevel]
|
|
|
|
ld b, a
|
|
|
|
ld a, [PlayerDefLevel]
|
|
|
|
.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
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
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
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BattleMonDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
|
|
|
|
ld a, [PlayerScreens]
|
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
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonAttack
|
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
|
|
|
|
2016-05-15 18:50:31 -07:00
|
|
|
ld hl, PlayerDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2016-05-15 18:50:31 -07:00
|
|
|
ld hl, EnemyAttack
|
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:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonSpclDef
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
|
|
|
|
ld a, [PlayerScreens]
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonSpclAtk
|
|
|
|
call GetDamageStatsCritical
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .lightball
|
2016-05-15 18:50:31 -07:00
|
|
|
ld hl, PlayerSpDef
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2016-05-15 18:50:31 -07:00
|
|
|
ld hl, EnemySpAtk
|
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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [EnemyMonLevel]
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_BeatUp: ; 35461
|
2013-03-26 17:39:44 -07:00
|
|
|
; beatup
|
|
|
|
|
|
|
|
call ResetDamage
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jp nz, .enemy_beats_up
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [PlayerSubStatus3]
|
2014-06-23 12:47:07 -07:00
|
|
|
bit SUBSTATUS_IN_LOOP, a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .next_mon
|
2014-06-13 21:18:14 -07:00
|
|
|
ld c, 20
|
2013-03-26 17:39:44 -07:00
|
|
|
call DelayFrames
|
|
|
|
xor a
|
2013-04-19 00:50:45 -07:00
|
|
|
ld [PlayerRolloutCount], a
|
2015-11-10 16:51:13 -08:00
|
|
|
ld [wd002], a
|
2016-01-12 09:46:18 -08:00
|
|
|
ld [wBeatUpHitAtLeastOnce], a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr .got_mon
|
|
|
|
|
|
|
|
.next_mon
|
2013-04-19 00:50:45 -07:00
|
|
|
ld a, [PlayerRolloutCount]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [PartyCount]
|
|
|
|
sub b
|
2015-11-10 16:51:13 -08:00
|
|
|
ld [wd002], a
|
2015-11-06 17:55:16 -08:00
|
|
|
|
|
|
|
.got_mon
|
2015-11-10 16:51:13 -08:00
|
|
|
ld a, [wd002]
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, PartyMonNicknames
|
2013-12-31 01:09:00 -08:00
|
|
|
call GetNick
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, MON_HP
|
|
|
|
call GetBeatupMonLocation
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
2015-11-06 17:55:16 -08:00
|
|
|
jp z, .beatup_fail ; fainted
|
2015-11-10 16:51:13 -08:00
|
|
|
ld a, [wd002]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
ld a, [CurBattleMon]
|
2017-12-14 13:28:16 -08:00
|
|
|
; BUG: this can desynchronize link battles
|
|
|
|
; Change "cp [hl]" to "cp c" to fix
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
|
|
|
ld hl, BattleMonStatus
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .active_mon
|
|
|
|
ld a, MON_STATUS
|
|
|
|
call GetBeatupMonLocation
|
|
|
|
.active_mon
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jp nz, .beatup_fail
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2016-01-12 09:46:18 -08:00
|
|
|
ld [wBeatUpHitAtLeastOnce], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BeatUpAttackText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [EnemyMonSpecies]
|
|
|
|
ld [CurSpecies], a
|
2013-12-31 01:09:00 -08:00
|
|
|
call GetBaseData
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [BaseDefense]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
push bc
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, MON_SPECIES
|
|
|
|
call GetBeatupMonLocation
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld [CurSpecies], a
|
2013-12-31 01:09:00 -08:00
|
|
|
call GetBaseData
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [BaseAttack]
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
ld b, a
|
|
|
|
push bc
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, MON_LEVEL
|
|
|
|
call GetBeatupMonLocation
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld e, a
|
|
|
|
pop bc
|
2016-01-09 16:34:14 -08:00
|
|
|
ld a, [wPlayerMoveStructPower]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
|
|
|
ret
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.enemy_beats_up
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [EnemySubStatus3]
|
2014-06-23 12:47:07 -07:00
|
|
|
bit SUBSTATUS_IN_LOOP, a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .not_first_enemy_beatup
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2013-04-19 00:50:45 -07:00
|
|
|
ld [EnemyRolloutCount], a
|
2015-11-10 16:51:13 -08:00
|
|
|
ld [wd002], a
|
2016-01-12 09:46:18 -08:00
|
|
|
ld [wBeatUpHitAtLeastOnce], a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr .enemy_continue
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.not_first_enemy_beatup
|
2013-04-19 00:50:45 -07:00
|
|
|
ld a, [EnemyRolloutCount]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [OTPartyCount]
|
|
|
|
sub b
|
2015-11-10 16:51:13 -08:00
|
|
|
ld [wd002], a
|
2015-11-06 17:55:16 -08:00
|
|
|
.enemy_continue
|
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
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .link_or_tower
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .link_or_tower
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
ld a, [wd002]
|
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
|
|
|
ld hl, OTPartySpecies
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-12-31 01:09:00 -08:00
|
|
|
call GetPokemonName
|
2015-11-06 17:55:16 -08:00
|
|
|
jr .got_enemy_nick
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.link_or_tower
|
2015-11-10 16:51:13 -08:00
|
|
|
ld a, [wd002]
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, OTPartyMonNicknames
|
2014-06-13 21:18:14 -07:00
|
|
|
ld bc, NAME_LENGTH
|
2013-03-26 17:39:44 -07:00
|
|
|
call AddNTimes
|
|
|
|
ld de, StringBuffer1
|
|
|
|
call CopyBytes
|
2015-11-06 17:55:16 -08:00
|
|
|
.got_enemy_nick
|
|
|
|
ld a, MON_HP
|
|
|
|
call GetBeatupMonLocation
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
2015-11-06 17:55:16 -08:00
|
|
|
jp z, .beatup_fail
|
2015-11-10 16:51:13 -08:00
|
|
|
ld a, [wd002]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
cp b
|
|
|
|
ld hl, EnemyMonStatus
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .active_enemy
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, MON_STATUS
|
|
|
|
call GetBeatupMonLocation
|
|
|
|
.active_enemy
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .beatup_fail
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, $1
|
2016-01-12 09:46:18 -08:00
|
|
|
ld [wBeatUpHitAtLeastOnce], a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr .finish_beatup
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.wild
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [EnemyMonSpecies]
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-12-31 01:09:00 -08:00
|
|
|
call GetPokemonName
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BeatUpAttackText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-27 15:50:10 -07:00
|
|
|
jp EnemyAttackDamage
|
2015-11-06 17:55:16 -08:00
|
|
|
|
|
|
|
.finish_beatup
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BeatUpAttackText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [BattleMonSpecies]
|
|
|
|
ld [CurSpecies], a
|
2013-04-29 12:08:13 -07:00
|
|
|
call GetBaseData
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [BaseDefense]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
push bc
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, MON_SPECIES
|
|
|
|
call GetBeatupMonLocation
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld [CurSpecies], a
|
2013-04-29 12:08:13 -07:00
|
|
|
call GetBaseData
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [BaseAttack]
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
ld b, a
|
|
|
|
push bc
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, MON_LEVEL
|
|
|
|
call GetBeatupMonLocation
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld e, a
|
|
|
|
pop bc
|
2016-01-09 16:34:14 -08:00
|
|
|
ld a, [wEnemyMoveStructPower]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; 355b0
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.beatup_fail ; 355b0
|
2015-04-13 21:39:54 -07:00
|
|
|
ld b, buildopponentrage_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
|
|
|
; 355b5
|
|
|
|
|
|
|
|
|
|
|
|
BattleCommanda8: ; 355b5
|
2016-01-12 09:46:18 -08:00
|
|
|
ld a, [wBeatUpHitAtLeastOnce]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2015-09-09 16:27:07 -07:00
|
|
|
|
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
|
|
|
; 355bd
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
GetBeatupMonLocation: ; 355bd
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
ld hl, PartyMon1Species
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_species
|
2013-04-07 23:15:08 -07:00
|
|
|
ld hl, OTPartyMon1Species
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_species
|
2015-11-10 16:51:13 -08:00
|
|
|
ld a, [wd002]
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
call GetPartyLocation
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_ClearMissDamage: ; 355d5
|
2013-03-26 22:52:04 -07:00
|
|
|
; clearmissdamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
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
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BattleMonDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, PlayerScreens
|
|
|
|
ld a, [BattleMonLevel]
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .got_it
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonDefense
|
2013-04-19 23:57:11 -07:00
|
|
|
ld de, EnemyScreens
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [EnemyMonLevel]
|
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]
|
|
|
|
cp $ff
|
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
|
|
|
|
|
|
|
|
|
|
|
|
; Update CurDamage (capped at 997).
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
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:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CriticalHit]
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
TypeBoostItems: ; 35703
|
2013-05-02 23:43:44 -07:00
|
|
|
db HELD_NORMAL_BOOST, NORMAL ; Pink/Polkadot Bow
|
|
|
|
db HELD_FIGHTING_BOOST, FIGHTING ; Blackbelt
|
|
|
|
db HELD_FLYING_BOOST, FLYING ; Sharp Beak
|
|
|
|
db HELD_POISON_BOOST, POISON ; Poison Barb
|
|
|
|
db HELD_GROUND_BOOST, GROUND ; Soft Sand
|
|
|
|
db HELD_ROCK_BOOST, ROCK ; Hard Stone
|
|
|
|
db HELD_BUG_BOOST, BUG ; Silverpowder
|
|
|
|
db HELD_GHOST_BOOST, GHOST ; Spell Tag
|
|
|
|
db HELD_FIRE_BOOST, FIRE ; Charcoal
|
|
|
|
db HELD_WATER_BOOST, WATER ; Mystic Water
|
|
|
|
db HELD_GRASS_BOOST, GRASS ; Miracle Seed
|
|
|
|
db HELD_ELECTRIC_BOOST, ELECTRIC ; Magnet
|
|
|
|
db HELD_PSYCHIC_BOOST, PSYCHIC ; Twistedspoon
|
|
|
|
db HELD_ICE_BOOST, ICE ; Nevermeltice
|
|
|
|
db HELD_DRAGON_BOOST, DRAGON ; Dragon Scale
|
|
|
|
db HELD_DARK_BOOST, DARK ; Blackglasses
|
|
|
|
db HELD_STEEL_BOOST, STEEL ; Metal Coat
|
2013-03-26 17:39:44 -07:00
|
|
|
db $ff
|
|
|
|
; 35726
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
ld hl, BattleMonLevel
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .got_turn
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonLevel
|
|
|
|
|
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
|
|
|
|
ld a, $0
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .got_power
|
2015-11-09 20:01:45 -08:00
|
|
|
|
|
|
|
.super_fang
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonHP
|
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
|
|
|
|
ld a, $0
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .got_power
|
2013-03-26 17:39:44 -07: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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], b
|
|
|
|
ret
|
2015-11-09 20:01:45 -08:00
|
|
|
|
|
|
|
.reversal
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .reversal_got_hp
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
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
|
2013-03-26 17:39:44 -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 + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2013-05-02 23:43:44 -07:00
|
|
|
ld hl, .FlailPower
|
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
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.FlailPower:
|
2013-05-02 23:43:44 -07:00
|
|
|
; px, bp
|
|
|
|
db 1, 200
|
|
|
|
db 4, 150
|
|
|
|
db 9, 100
|
|
|
|
db 16, 80
|
|
|
|
db 32, 40
|
|
|
|
db 48, 20
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35813
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Counter: ; 35813
|
2013-03-26 22:52:04 -07:00
|
|
|
; counter
|
|
|
|
|
2014-01-05 05:24:27 -08:00
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [AttackMissed], a
|
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2014-01-05 05:24:27 -08:00
|
|
|
ld b, a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar GetMoveEffect
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
2014-01-05 05:24:27 -08:00
|
|
|
cp EFFECT_COUNTER
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
call BattleCommand_ResetTypeMatchup
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wTypeMatchup]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckOpponentWentFirst
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
|
|
|
ld de, StringBuffer1
|
|
|
|
call GetMoveData
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2017-12-19 12:28:06 -08:00
|
|
|
ld a, [StringBuffer1 + MOVE_POWER]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2017-12-19 12:28:06 -08:00
|
|
|
ld a, [StringBuffer1 + MOVE_TYPE]
|
2014-01-05 05:24:27 -08:00
|
|
|
cp SPECIAL
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
ret z
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
add a
|
|
|
|
ld [hld], a
|
|
|
|
ld a, [hl]
|
|
|
|
adc a
|
|
|
|
ld [hl], a
|
2014-01-05 05:24:27 -08:00
|
|
|
jr nc, .capped
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2014-01-05 05:24:27 -08:00
|
|
|
.capped
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [AttackMissed], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35864
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Encore: ; 35864
|
2013-03-26 22:52:04 -07:00
|
|
|
; encore
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonMoves
|
2013-05-02 22:29:57 -07:00
|
|
|
ld de, EnemyEncoreCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-17 12:52:32 -07:00
|
|
|
jr z, .ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonMoves
|
|
|
|
ld de, PlayerEncoreCount
|
2014-06-17 12:52:32 -07:00
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-17 12:52:32 -07:00
|
|
|
jp z, .failed
|
2013-03-27 15:50:10 -07:00
|
|
|
cp STRUGGLE
|
2014-06-17 12:52:32 -07:00
|
|
|
jp z, .failed
|
2013-03-27 15:50:10 -07:00
|
|
|
cp ENCORE
|
2014-06-17 12:52:32 -07:00
|
|
|
jp z, .failed
|
2013-03-27 15:50:10 -07:00
|
|
|
cp MIRROR_MOVE
|
2014-06-17 12:52:32 -07:00
|
|
|
jp z, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_move
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .got_move
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
ld bc, BattleMonPP - BattleMonMoves - 1
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
and $3f
|
2014-06-17 12:52:32 -07:00
|
|
|
jp z, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2014-06-17 12:52:32 -07:00
|
|
|
jp nz, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_ENCORED, [hl]
|
|
|
|
jp nz, .failed
|
|
|
|
set SUBSTATUS_ENCORED, [hl]
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and $3
|
|
|
|
inc a
|
2016-05-10 09:31:49 -07:00
|
|
|
inc a
|
|
|
|
inc a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [de], a
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckOpponentWentFirst
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .finish_move
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .force_last_enemy_move
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
ld a, [LastPlayerMove]
|
|
|
|
ld b, a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld c, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonMoves
|
2015-12-26 15:11:55 -08:00
|
|
|
.find_player_move
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_player_move
|
2013-03-26 17:39:44 -07:00
|
|
|
inc c
|
|
|
|
ld a, c
|
2014-06-13 21:18:14 -07:00
|
|
|
cp NUM_MOVES
|
2015-12-26 15:11:55 -08:00
|
|
|
jr c, .find_player_move
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
2014-06-17 12:52:32 -07:00
|
|
|
res SUBSTATUS_ENCORED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [de], a
|
2014-06-17 12:52:32 -07:00
|
|
|
jr .failed
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_player_move
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
ld a, c
|
|
|
|
ld [CurMoveNum], a
|
|
|
|
ld a, b
|
|
|
|
ld [CurPlayerMove], a
|
|
|
|
dec a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld de, wPlayerMoveStruct
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetMoveData
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .finish_move
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.force_last_enemy_move
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
ld a, [LastEnemyMove]
|
|
|
|
ld b, a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld c, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonMoves
|
2015-12-26 15:11:55 -08:00
|
|
|
.find_enemy_move
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_enemy_move
|
2013-03-26 17:39:44 -07:00
|
|
|
inc c
|
|
|
|
ld a, c
|
2014-06-13 21:18:14 -07:00
|
|
|
cp NUM_MOVES
|
2015-12-26 15:11:55 -08:00
|
|
|
jr c, .find_enemy_move
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
2014-06-17 12:52:32 -07:00
|
|
|
res SUBSTATUS_ENCORED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [de], a
|
2014-06-17 12:52:32 -07:00
|
|
|
jr .failed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_enemy_move
|
|
|
|
pop hl
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c
|
|
|
|
ld [CurEnemyMoveNum], a
|
|
|
|
ld a, b
|
|
|
|
ld [CurEnemyMove], a
|
|
|
|
dec a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld de, wEnemyMoveStruct
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetMoveData
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.finish_move
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, GotAnEncoreText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2014-06-17 12:52:32 -07:00
|
|
|
.failed
|
2013-03-26 17:39:44 -07:00
|
|
|
jp PrintDidntAffect2
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35926
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_PainSplit: ; 35926
|
2013-03-26 22:52:04 -07:00
|
|
|
; painsplit
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jp nz, .ButItFailed
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2015-12-26 15:11:55 -08:00
|
|
|
jp nz, .ButItFailed
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, BattleMonMaxHP + 1
|
2014-06-12 18:32:42 -07:00
|
|
|
ld de, EnemyMonMaxHP + 1
|
2015-11-09 13:41:09 -08:00
|
|
|
call .PlayerShareHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-12-26 15:11:55 -08:00
|
|
|
ld [wWhichHPBar], a
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 10, 9
|
2015-11-07 05:05:57 -08:00
|
|
|
predef AnimateHPBar
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer4], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer3], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer1], a
|
2015-11-09 13:41:09 -08:00
|
|
|
call .EnemyShareHP
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-26 15:11:55 -08:00
|
|
|
ld [wWhichHPBar], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetDamage
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 2, 2
|
2015-11-07 05:05:57 -08:00
|
|
|
predef AnimateHPBar
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _UpdateBattleHUDs
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, SharedPainText
|
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
|
|
|
.PlayerShareHP:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld b, a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer3], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer4], a
|
2013-03-26 17:39:44 -07:00
|
|
|
dec de
|
2015-12-26 18:59:03 -08:00
|
|
|
dec de
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
dec de
|
|
|
|
add b
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [CurDamage + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
|
|
|
ld a, [de]
|
|
|
|
adc b
|
|
|
|
srl a
|
|
|
|
ld [CurDamage], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [CurDamage + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
rr a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [CurDamage + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2016-05-10 09:31:49 -07:00
|
|
|
inc hl
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
inc de
|
2013-03-26 17:39:44 -07:00
|
|
|
inc de
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.EnemyShareHP: ; 359ac
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, [hl]
|
|
|
|
dec hl
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [CurDamage + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
sub c
|
|
|
|
ld b, [hl]
|
|
|
|
dec hl
|
|
|
|
ld a, [CurDamage]
|
|
|
|
sbc b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nc, .skip
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [CurDamage]
|
|
|
|
ld b, a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [CurDamage + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
2015-11-09 13:41:09 -08:00
|
|
|
.skip
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c
|
|
|
|
ld [hld], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer5], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
ld [hli], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer6], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; 359cd
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ButItFailed:
|
2013-03-27 15:50:10 -07:00
|
|
|
jp PrintDidntAffect2
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 359d0
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Snore: ; 359d0
|
2013-03-26 22:52:04 -07:00
|
|
|
; snore
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS
|
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 nz
|
|
|
|
call ResetDamage
|
|
|
|
ld a, $1
|
|
|
|
ld [AttackMissed], a
|
2015-11-09 13:41:09 -08:00
|
|
|
call FailSnore
|
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
|
|
|
; 359e6
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Conversion2: ; 359e6
|
2013-03-26 22:52:04 -07:00
|
|
|
; conversion2
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonType1
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_type
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonType1
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_type
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
dec a
|
2014-06-10 23:23:55 -07:00
|
|
|
ld hl, Moves + MOVE_TYPE
|
2013-03-27 13:19:51 -07:00
|
|
|
call GetMoveAttr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
|
|
|
pop hl
|
2013-05-02 23:43:44 -07:00
|
|
|
cp CURSE_T
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .failed
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.loop
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and $1f
|
2014-06-13 21:18:14 -07:00
|
|
|
cp UNUSED_TYPES
|
2015-12-26 15:11:55 -08:00
|
|
|
jr c, .okay
|
2014-06-13 21:18:14 -07:00
|
|
|
cp UNUSED_TYPES_END
|
2015-12-26 15:11:55 -08:00
|
|
|
jr c, .loop
|
2014-06-13 21:18:14 -07:00
|
|
|
cp TYPES_END
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .loop
|
|
|
|
.okay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
|
|
|
ld [hld], a
|
|
|
|
push hl
|
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
push af
|
|
|
|
push hl
|
|
|
|
ld a, d
|
|
|
|
ld [hl], a
|
2015-11-06 17:55:16 -08:00
|
|
|
call BattleCheckTypeMatchup
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
ld [hl], a
|
|
|
|
pop hl
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wTypeMatchup]
|
|
|
|
cp 10
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .loop
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2014-06-16 11:20:01 -07:00
|
|
|
predef GetTypeName
|
2014-01-05 04:28:55 -08:00
|
|
|
ld hl, TransformedTypeText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.failed
|
2015-11-09 13:41:09 -08:00
|
|
|
jp FailConversion2
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35a53
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_LockOn: ; 35a53
|
2013-03-26 22:52:04 -07:00
|
|
|
; lockon
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .fail
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .fail
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-05-02 23:43:44 -07:00
|
|
|
set SUBSTATUS_LOCK_ON, [hl]
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, TookAimText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.fail
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
jp PrintDidntAffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35a74
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Sketch: ; 35a74
|
2013-03-26 22:52:04 -07:00
|
|
|
; sketch
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call ClearLastMove
|
|
|
|
; Don't sketch during a link battle
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .not_linked
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
jp PrintNothingHappened
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.not_linked
|
|
|
|
; If the opponent has a substitute up, fail.
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2015-11-09 13:41:09 -08:00
|
|
|
jp nz, .fail
|
|
|
|
; If the opponent is transformed, fail.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_TRANSFORMED, [hl]
|
2015-11-09 13:41:09 -08:00
|
|
|
jp nz, .fail
|
|
|
|
; Get the user's moveset in its party struct.
|
|
|
|
; This move replacement shall be permanent.
|
|
|
|
; Pointer will be in de.
|
2015-11-04 08:19:58 -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 d, h
|
|
|
|
ld e, l
|
2015-11-09 13:41:09 -08:00
|
|
|
; Get the battle move structs.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonMoves
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .get_last_move
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonMoves
|
2015-11-09 13:41:09 -08:00
|
|
|
.get_last_move
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2015-11-09 13:41:09 -08:00
|
|
|
; Fail if move is invalid or is Struggle.
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fail
|
2013-05-02 23:43:44 -07:00
|
|
|
cp STRUGGLE
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fail
|
|
|
|
; Fail if user already knows that move
|
2014-06-13 21:18:14 -07:00
|
|
|
ld c, NUM_MOVES
|
2015-11-09 13:41:09 -08:00
|
|
|
.does_user_already_know_move
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
dec c
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .does_user_already_know_move
|
|
|
|
; Find Sketch in the user's moveset.
|
|
|
|
; Pointer in hl, and index in c.
|
2013-03-26 17:39:44 -07:00
|
|
|
dec hl
|
2014-06-13 21:18:14 -07:00
|
|
|
ld c, NUM_MOVES
|
2015-11-09 13:41:09 -08:00
|
|
|
.find_sketch
|
2013-03-26 17:39:44 -07:00
|
|
|
dec c
|
|
|
|
ld a, [hld]
|
2013-05-02 23:43:44 -07:00
|
|
|
cp SKETCH
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .find_sketch
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2015-11-09 13:41:09 -08:00
|
|
|
; The Sketched move is loaded to that slot.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
ld [hl], a
|
2015-11-09 13:41:09 -08:00
|
|
|
; Copy the base PP from that move.
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
dec a
|
2014-06-10 23:23:55 -07:00
|
|
|
ld hl, Moves + MOVE_PP
|
2013-03-27 13:19:51 -07:00
|
|
|
call GetMoveAttr
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
2014-06-10 23:23:55 -07:00
|
|
|
ld bc, BattleMonPP - BattleMonMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
pop bc
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .user_trainer
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .user_trainer
|
|
|
|
; wildmon
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
push bc
|
2015-11-09 13:41:09 -08:00
|
|
|
ld hl, wWildMonPP
|
2014-06-13 21:18:14 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld hl, wWildMonMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
ld [hl], b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr .done_copy
|
|
|
|
|
|
|
|
.user_trainer
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
ld l, c
|
2014-06-13 21:18:14 -07:00
|
|
|
ld h, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, de
|
|
|
|
ld a, b
|
|
|
|
ld [hl], a
|
|
|
|
pop af
|
2015-11-09 13:41:09 -08:00
|
|
|
ld de, MON_PP - MON_MOVES
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, de
|
|
|
|
ld [hl], a
|
2015-11-09 13:41:09 -08:00
|
|
|
.done_copy
|
2013-05-02 23:43:44 -07:00
|
|
|
call GetMoveName
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, SketchedText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.fail
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
jp PrintDidntAffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35b16
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DefrostOpponent: ; 35b16
|
2013-03-26 22:52:04 -07:00
|
|
|
; defrostopponent
|
2014-06-13 21:18:14 -07:00
|
|
|
; Thaw the opponent if frozen, and
|
|
|
|
; raise the user's Attack one stage.
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 22:52:04 -07:00
|
|
|
|
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 22:52:04 -07:00
|
|
|
call Defrost
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
push hl
|
|
|
|
push af
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, EFFECT_ATTACK_UP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_StatUp
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
|
|
|
pop hl
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35b33
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SleepTalk: ; 35b33
|
2013-03-26 22:52:04 -07:00
|
|
|
; sleeptalk
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call ClearLastMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, BattleMonMoves + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [DisabledMove]
|
|
|
|
ld d, a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_moves
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonMoves + 1
|
2013-05-03 18:04:34 -07:00
|
|
|
ld a, [EnemyDisabledMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_moves
|
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-10 23:08:07 -07:00
|
|
|
and SLP
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fail
|
2015-12-26 15:11:55 -08:00
|
|
|
call .safely_check_has_usable_move
|
2015-11-09 13:41:09 -08:00
|
|
|
jr c, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
dec hl
|
2015-12-26 15:11:55 -08:00
|
|
|
.sample_move
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2014-06-10 23:08:07 -07:00
|
|
|
and 3 ; TODO factor in NUM_MOVES
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .sample_move
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
|
|
|
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 e
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .sample_move
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, e
|
|
|
|
cp d
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .sample_move
|
|
|
|
call .check_two_turn_move
|
|
|
|
jr z, .sample_move
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, e
|
|
|
|
ld [hl], a
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckUserIsCharging
|
|
|
|
jr nz, .charging
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wKickCounter]
|
2013-03-26 17:39:44 -07:00
|
|
|
push af
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2015-11-09 13:41:09 -08:00
|
|
|
.charging
|
|
|
|
call LoadMoveAnim
|
2013-03-26 17:39:44 -07:00
|
|
|
call UpdateMoveData
|
|
|
|
jp ResetTurn
|
2015-11-09 13:41:09 -08:00
|
|
|
|
|
|
|
.fail
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-27 15:50:10 -07:00
|
|
|
jp TryPrintButItFailed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.safely_check_has_usable_move
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2015-12-26 15:11:55 -08:00
|
|
|
call .check_has_usable_move
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.check_has_usable_move
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ld a, [DisabledMove]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_move_2
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-05-03 18:04:34 -07:00
|
|
|
ld a, [EnemyDisabledMove]
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_move_2
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2014-06-10 23:08:07 -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
|
|
|
ld c, a
|
|
|
|
dec hl
|
2014-06-10 23:08:07 -07:00
|
|
|
ld d, NUM_MOVES
|
2015-12-26 15:11:55 -08:00
|
|
|
.loop2
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .carry
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp c
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .nope
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .nope
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
call .check_two_turn_move
|
|
|
|
jr nz, .no_carry
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.nope
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
dec d
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .loop2
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.carry
|
2013-03-26 17:39:44 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.no_carry
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.check_two_turn_move
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
|
|
|
|
ld b, a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar GetMoveEffect
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
cp EFFECT_SKULL_BASH
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-06-10 23:08:07 -07:00
|
|
|
cp EFFECT_RAZOR_WIND
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-06-10 23:08:07 -07:00
|
|
|
cp EFFECT_SKY_ATTACK
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-06-10 23:08:07 -07:00
|
|
|
cp EFFECT_SOLARBEAM
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-06-10 23:08:07 -07:00
|
|
|
cp EFFECT_FLY
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-06-10 23:08:07 -07:00
|
|
|
cp EFFECT_BIDE
|
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
|
|
|
; 35bff
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DestinyBond: ; 35bff
|
2013-03-26 22:52:04 -07:00
|
|
|
; destinybond
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
set SUBSTATUS_DESTINY_BOND, [hl]
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, DestinyBondEffectText
|
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
|
|
|
; 35c0f
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Spite: ; 35c0f
|
2013-03-26 22:52:04 -07:00
|
|
|
; spite
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jp nz, .failed
|
2015-11-04 08:19:58 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH ; ????
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonMoves
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_moves
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonMoves
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_moves
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .failed
|
2014-06-10 23:08:07 -07:00
|
|
|
cp STRUGGLE
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2014-06-23 12:45:30 -07:00
|
|
|
ld c, -1
|
2015-12-26 15:11:55 -08:00
|
|
|
.loop
|
2013-03-26 17:39:44 -07:00
|
|
|
inc c
|
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .loop
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2013-03-26 17:39:44 -07:00
|
|
|
dec hl
|
2014-06-23 12:45:30 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2014-06-23 12:45:30 -07:00
|
|
|
ld c, BattleMonPP - BattleMonMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
ld a, [hl]
|
|
|
|
and $3f
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2013-05-02 23:43:44 -07:00
|
|
|
call GetMoveName
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2014-06-10 23:08:07 -07:00
|
|
|
and 3
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-12-26 18:59:03 -08:00
|
|
|
inc a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
and $3f
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .deplete_pp
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2015-12-26 15:11:55 -08:00
|
|
|
.deplete_pp
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
sub b
|
|
|
|
ld [hl], a
|
|
|
|
push af
|
2015-11-04 08:19:58 -08:00
|
|
|
ld a, MON_PP
|
2013-05-02 23:43:44 -07:00
|
|
|
call OpponentPartyAttr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, b
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
add hl, bc
|
|
|
|
ld e, a
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .transformed
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .not_wildmon
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .not_wildmon
|
|
|
|
ld hl, wWildMonPP
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
2015-12-26 15:11:55 -08:00
|
|
|
.not_wildmon
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], e
|
2015-12-26 15:11:55 -08:00
|
|
|
.transformed
|
2013-03-26 17:39:44 -07:00
|
|
|
push de
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
pop de
|
|
|
|
ld a, d
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, SpiteEffectText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.failed
|
2013-03-26 17:39:44 -07:00
|
|
|
jp PrintDidntAffect2
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35c94
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_FalseSwipe: ; 35c94
|
2013-03-26 22:52:04 -07:00
|
|
|
; falseswipe
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonHP
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_hp
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, CurDamage
|
2015-12-26 15:11:55 -08:00
|
|
|
ld c, 2
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
call StringCmp
|
|
|
|
pop de
|
|
|
|
pop hl
|
2015-12-26 15:11:55 -08:00
|
|
|
jr c, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
dec a
|
|
|
|
ld [de], a
|
|
|
|
inc a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .okay
|
2013-03-26 17:39:44 -07:00
|
|
|
dec de
|
|
|
|
ld a, [de]
|
|
|
|
dec a
|
|
|
|
ld [de], a
|
2015-12-26 15:11:55 -08:00
|
|
|
.okay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CriticalHit]
|
|
|
|
cp $2
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .carry
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [CriticalHit], a
|
2015-12-26 15:11:55 -08:00
|
|
|
.carry
|
2013-03-26 17:39:44 -07:00
|
|
|
scf
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.done
|
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
|
|
|
; 35cc9
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_HealBell: ; 35cc9
|
2013-03-26 22:52:04 -07:00
|
|
|
; healbell
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
res SUBSTATUS_NIGHTMARE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, PartyMon1Status
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_status
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, OTPartyMon1Status
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_status
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
2015-11-04 08:19:58 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2015-12-26 15:11:55 -08:00
|
|
|
ld d, PARTY_LENGTH
|
|
|
|
.loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
add hl, bc
|
|
|
|
dec d
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .loop
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, BellChimedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jp z, CalcPlayerStats
|
|
|
|
jp CalcEnemyStats
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35d00
|
|
|
|
|
|
|
|
|
|
|
|
FarPlayBattleAnimation: ; 35d00
|
|
|
|
; play animation de
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
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
|
|
|
ret nz
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 35d08
|
|
|
|
|
|
|
|
PlayFXAnimID: ; 35d08
|
|
|
|
ld a, e
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, d
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld c, 3
|
|
|
|
call DelayFrames
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar PlayBattleAnim
|
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
|
|
|
; 35d1c
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
EnemyHurtItself: ; 35d1c
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
or b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .did_no_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, c
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .mimic_sub_check
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [EnemySubStatus4]
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2015-11-09 13:41:09 -08:00
|
|
|
jp nz, SelfInflictDamageToSubstitute
|
|
|
|
|
|
|
|
.mimic_sub_check
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld b, a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, [EnemyMonHP + 1]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer3], a
|
2013-03-26 17:39:44 -07:00
|
|
|
sub b
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [EnemyMonHP + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld b, a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, [EnemyMonHP]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer4], a
|
2013-03-26 17:39:44 -07:00
|
|
|
sbc b
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [EnemyMonHP], a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nc, .mimic_faint
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
ld a, [Buffer4]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld a, [Buffer3]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.mimic_faint
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonMaxHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer1], a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer6], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer5], a
|
2014-06-04 01:10:56 -07: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
|
2015-11-07 05:05:57 -08:00
|
|
|
predef AnimateHPBar
|
2015-11-09 13:41:09 -08:00
|
|
|
.did_no_damage
|
2013-05-02 21:22:28 -07:00
|
|
|
jp RefreshBattleHuds
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35d7e
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
PlayerHurtItself: ; 35d7e
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
or b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .did_no_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, c
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .mimic_sub_check
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [PlayerSubStatus4]
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2015-11-09 13:41:09 -08:00
|
|
|
jp nz, SelfInflictDamageToSubstitute
|
|
|
|
.mimic_sub_check
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld b, a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, [BattleMonHP + 1]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer3], a
|
2013-03-26 17:39:44 -07:00
|
|
|
sub b
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [BattleMonHP + 1], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer5], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
|
|
|
ld a, [BattleMonHP]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer4], a
|
2013-03-26 17:39:44 -07:00
|
|
|
sbc b
|
|
|
|
ld [BattleMonHP], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer6], a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nc, .mimic_faint
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
ld a, [Buffer4]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld a, [Buffer3]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
xor a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld hl, Buffer5
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.mimic_faint
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonMaxHP
|
|
|
|
ld a, [hli]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer1], a
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 10, 9
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-12-26 15:11:55 -08:00
|
|
|
ld [wWhichHPBar], a
|
2015-11-07 05:05:57 -08:00
|
|
|
predef AnimateHPBar
|
2015-11-09 13:41:09 -08:00
|
|
|
.did_no_damage
|
2013-05-02 21:22:28 -07:00
|
|
|
jp RefreshBattleHuds
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35de0
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
SelfInflictDamageToSubstitute: ; 35de0
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, SubTookDamageText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
ld de, EnemySubstituteHP
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .got_hp
|
|
|
|
ld de, PlayerSubstituteHP
|
|
|
|
.got_hp
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, CurDamage
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
2014-06-10 23:08:07 -07:00
|
|
|
jr nz, .broke
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [de]
|
|
|
|
sub [hl]
|
|
|
|
ld [de], a
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .broke
|
|
|
|
jr nc, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
.broke
|
2013-05-02 22:29:57 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
res SUBSTATUS_SUBSTITUTE, [hl]
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, SubFadedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2015-11-06 19:36:06 -08:00
|
|
|
call BattleCommand_LowerSubNoAnim
|
2013-05-02 22:29:57 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
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
|
2015-11-09 13:41:09 -08:00
|
|
|
call z, AppearUserLowerSub
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-05-02 22:29:57 -07:00
|
|
|
cp EFFECT_MULTI_HIT
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2013-05-02 22:29:57 -07:00
|
|
|
cp EFFECT_DOUBLE_HIT
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2017-11-15 07:36:13 -08:00
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2013-05-02 22:29:57 -07:00
|
|
|
cp EFFECT_TRIPLE_KICK
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2013-05-02 22:29:57 -07:00
|
|
|
cp EFFECT_BEAT_UP
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2014-06-10 23:08:07 -07:00
|
|
|
.ok
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
2014-06-10 23:08:07 -07:00
|
|
|
.done
|
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
|
|
|
; 35e40
|
|
|
|
|
|
|
|
|
|
|
|
UpdateMoveData: ; 35e40
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [CurMove], a
|
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
dec a
|
|
|
|
call GetMoveData
|
|
|
|
call GetMoveName
|
|
|
|
jp CopyName1
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35e5c
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SleepTarget: ; 35e5c
|
2013-03-26 17:39:44 -07:00
|
|
|
; sleeptarget
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
cp HELD_PREVENT_SLEEP
|
2015-11-06 19:36:06 -08:00
|
|
|
jr nz, .not_protected_by_item
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
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, ProtectedByText
|
2015-11-06 19:36:06 -08:00
|
|
|
jr .fail
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.not_protected_by_item
|
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
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
ld a, [de]
|
2014-06-13 21:18:14 -07:00
|
|
|
and SLP
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, AlreadyAsleepText
|
2015-11-06 19:36:06 -08:00
|
|
|
jr nz, .fail
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
|
|
|
jp nz, PrintDidntAffect2
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, DidntAffect1Text
|
2015-11-06 19:36:06 -08:00
|
|
|
call .CheckAIRandomFail
|
|
|
|
jr c, .fail
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
and a
|
2015-11-06 19:36:06 -08:00
|
|
|
jr nz, .fail
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2015-11-06 19:36:06 -08:00
|
|
|
jr nz, .fail
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, $7
|
2015-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 19:36:06 -08:00
|
|
|
jr z, .random_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, $3
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.random_loop
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and b
|
2015-11-06 19:36:06 -08:00
|
|
|
jr z, .random_loop
|
2013-03-27 14:07:00 -07:00
|
|
|
cp 7
|
2015-11-06 19:36:06 -08:00
|
|
|
jr z, .random_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
|
|
|
ld [de], a
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateOpponentInParty
|
|
|
|
call RefreshBattleHuds
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, FellAsleepText
|
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
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
jp z, OpponentCantMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.fail
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
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
|
|
|
; 35ece
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.CheckAIRandomFail: ; 35ece
|
2014-06-13 21:18:14 -07:00
|
|
|
; Enemy turn
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 19:36:06 -08:00
|
|
|
jr z, .dont_fail
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Not in link battle
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 19:36:06 -08:00
|
|
|
jr nz, .dont_fail
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 19:36:06 -08:00
|
|
|
jr nz, .dont_fail
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Not locked-on by the enemy
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [PlayerSubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
2015-11-06 19:36:06 -08:00
|
|
|
jr nz, .dont_fail
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2015-11-06 19:36:06 -08:00
|
|
|
cp $40 ; 25%
|
2013-03-26 17:39:44 -07:00
|
|
|
ret c
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.dont_fail
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35eee
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_PoisonTarget: ; 35eee
|
2013-03-26 22:52:04 -07:00
|
|
|
; poisontarget
|
|
|
|
|
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
|
|
|
|
ld a, [TypeModifier]
|
|
|
|
and $7f
|
|
|
|
ret z
|
2015-11-06 19:36:06 -08:00
|
|
|
call CheckIfTargetIsPoisonType
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
cp HELD_PREVENT_POISON
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [EffectFailed]
|
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
|
2015-11-06 19:36:06 -08:00
|
|
|
|
|
|
|
call PoisonOpponent
|
2014-06-13 21:18:14 -07:00
|
|
|
ld de, ANIM_PSN
|
2015-11-06 17:55:16 -08:00
|
|
|
call PlayOpponentBattleAnim
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, WasPoisonedText
|
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
|
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
|
|
|
; 35f2c
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Poison: ; 35f2c
|
2013-03-26 22:52:04 -07:00
|
|
|
; poison
|
|
|
|
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, DoesntAffectText
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [TypeModifier]
|
|
|
|
and $7f
|
2015-11-06 19:36:06 -08:00
|
|
|
jp z, .failed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
call CheckIfTargetIsPoisonType
|
|
|
|
jp z, .failed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, AlreadyPoisonedText
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << PSN
|
2015-11-06 19:36:06 -08:00
|
|
|
jp nz, .failed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
cp HELD_PREVENT_POISON
|
2015-11-06 19:36:06 -08:00
|
|
|
jr nz, .do_poison
|
2013-03-26 17:39:44 -07:00
|
|
|
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, ProtectedByText
|
2015-11-06 19:36:06 -08:00
|
|
|
jr .failed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.do_poison
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, DidntAffect1Text
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 19:36:06 -08:00
|
|
|
jr nz, .failed
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .mimic_random
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .mimic_random
|
2015-09-04 13:30:40 -07:00
|
|
|
|
|
|
|
ld a, [InBattleTowerBattle]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .mimic_random
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [PlayerSubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .mimic_random
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2015-11-06 19:36:06 -08:00
|
|
|
cp $40 ; 25% chance AI fails
|
|
|
|
jr c, .failed
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.mimic_random
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2015-11-06 19:36:06 -08:00
|
|
|
jr nz, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-11-06 19:36:06 -08:00
|
|
|
jr nz, .failed
|
|
|
|
call .check_toxic
|
|
|
|
jr z, .toxic
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
call .apply_poison
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, WasPoisonedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2015-11-06 19:36:06 -08:00
|
|
|
jr .finished
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.toxic
|
2014-06-13 21:18:14 -07:00
|
|
|
set SUBSTATUS_TOXIC, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [de], a
|
2015-11-06 19:36:06 -08:00
|
|
|
call .apply_poison
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, BadlyPoisonedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.finished
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall UseHeldStatusHealingItem
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.failed
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
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
|
|
|
; 35fc0
|
|
|
|
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.apply_poison ; 35fc0
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2015-11-06 19:36:06 -08:00
|
|
|
call PoisonOpponent
|
2013-05-02 21:22:28 -07:00
|
|
|
jp RefreshBattleHuds
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35fc9
|
|
|
|
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.check_toxic ; 35fc9
|
2013-05-02 22:29:57 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-17 12:52:32 -07:00
|
|
|
ld de, EnemyToxicCount
|
|
|
|
jr z, .ok
|
|
|
|
ld de, PlayerToxicCount
|
|
|
|
.ok
|
2013-05-02 22:29:57 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 22:29:57 -07:00
|
|
|
cp EFFECT_TOXIC
|
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
|
|
|
; 35fe1
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
CheckIfTargetIsPoisonType: ; 35fe1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, EnemyMonType1
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-17 12:52:32 -07:00
|
|
|
jr z, .ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, BattleMonType1
|
2014-06-17 12:52:32 -07:00
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2013-05-02 22:29:57 -07:00
|
|
|
cp POISON
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
ld a, [de]
|
2013-05-02 22:29:57 -07:00
|
|
|
cp POISON
|
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
|
|
|
; 35ff5
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
PoisonOpponent: ; 35ff5
|
2013-05-02 22:29:57 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-05-02 22:29:57 -07:00
|
|
|
set PSN, [hl]
|
2013-05-02 21:22:28 -07:00
|
|
|
jp UpdateOpponentInParty
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 35fff
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DrainTarget: ; 35fff
|
2013-03-27 14:07:00 -07:00
|
|
|
; draintarget
|
2015-11-06 19:36:06 -08:00
|
|
|
call SapHealth
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, SuckedHealthText
|
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
|
|
|
; 36008
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_EatDream: ; 36008
|
2013-03-27 14:07:00 -07:00
|
|
|
; eatdream
|
2015-11-06 19:36:06 -08:00
|
|
|
call SapHealth
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, DreamEatenText
|
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
|
|
|
; 36011
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
SapHealth: ; 36011
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
ld a, [hli]
|
|
|
|
srl a
|
2015-11-06 19:36:06 -08:00
|
|
|
ld [hDividend], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
rr a
|
2015-11-06 19:36:06 -08:00
|
|
|
ld [hDividend + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .ok1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-06 19:36:06 -08:00
|
|
|
ld [hDividend + 1], a
|
|
|
|
.ok1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld de, BattleMonMaxHP
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .battlemonhp
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
|
|
|
ld de, EnemyMonMaxHP
|
2015-11-06 19:36:06 -08:00
|
|
|
.battlemonhp
|
2015-11-07 05:05:57 -08:00
|
|
|
ld bc, Buffer4
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld [bc], a
|
|
|
|
ld a, [hl]
|
|
|
|
dec bc
|
|
|
|
ld [bc], a
|
|
|
|
ld a, [de]
|
|
|
|
dec bc
|
|
|
|
ld [bc], a
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
dec bc
|
|
|
|
ld [bc], a
|
2015-11-06 19:36:06 -08:00
|
|
|
ld a, [hDividend + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
|
|
|
add b
|
|
|
|
ld [hld], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer5], a
|
2015-11-06 19:36:06 -08:00
|
|
|
ld a, [hDividend]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
|
|
|
adc b
|
|
|
|
ld [hli], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer6], a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr c, .okay2
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
|
|
|
dec de
|
|
|
|
sub b
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
sbc b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .okay3
|
2015-11-06 19:36:06 -08:00
|
|
|
.okay2
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
ld [hld], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer5], a
|
2013-03-26 17:39:44 -07:00
|
|
|
dec de
|
|
|
|
ld a, [de]
|
|
|
|
ld [hli], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer6], a
|
2013-03-26 17:39:44 -07:00
|
|
|
inc de
|
2015-11-06 19:36:06 -08:00
|
|
|
.okay3
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 10, 9
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-12-26 15:11:55 -08:00
|
|
|
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
|
2015-11-06 19:36:06 -08:00
|
|
|
.hp_bar
|
2015-12-26 15:11:55 -08:00
|
|
|
ld [wWhichHPBar], a
|
2015-11-07 05:05:57 -08:00
|
|
|
predef AnimateHPBar
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
|
|
|
jp UpdateBattleMonInParty
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3608c
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_BurnTarget: ; 3608c
|
2013-03-26 22:52:04 -07:00
|
|
|
; burntarget
|
|
|
|
|
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
|
|
|
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
|
2013-03-26 22:52:04 -07:00
|
|
|
jp nz, Defrost
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [TypeModifier]
|
|
|
|
and $7f
|
|
|
|
ret z
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckMoveTypeMatchesTarget ; Don't burn a Fire-type
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
cp HELD_PREVENT_BURN
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [EffectFailed]
|
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
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
set BRN, [hl]
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateOpponentInParty
|
2015-11-06 17:55:16 -08:00
|
|
|
ld hl, ApplyBrnEffectOnAttack
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2014-06-13 21:18:14 -07:00
|
|
|
ld de, ANIM_BRN
|
2015-11-06 17:55:16 -08:00
|
|
|
call PlayOpponentBattleAnim
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, WasBurnedText
|
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
|
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
|
|
|
; 360dd
|
|
|
|
|
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
Defrost: ; 360dd
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << FRZ
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
ld hl, OTPartyMon1Status
|
2013-03-26 22:52:04 -07:00
|
|
|
jr z, .ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PartyMon1Status
|
|
|
|
ld a, [CurBattleMon]
|
2013-03-26 22:52:04 -07:00
|
|
|
.ok
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetPartyLocation
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateOpponentInParty
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, DefrostedOpponentText
|
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
|
|
|
; 36102
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_FreezeTarget: ; 36102
|
2013-03-26 22:52:04 -07:00
|
|
|
; freezetarget
|
|
|
|
|
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
|
|
|
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
|
|
|
|
ld a, [TypeModifier]
|
|
|
|
and $7f
|
|
|
|
ret z
|
|
|
|
ld a, [Weather]
|
2014-06-13 21:18:14 -07:00
|
|
|
cp WEATHER_SUN
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckMoveTypeMatchesTarget ; Don't freeze an Ice-type
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
cp HELD_PREVENT_FREEZE
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [EffectFailed]
|
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
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
set FRZ, [hl]
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateOpponentInParty
|
2014-06-13 21:18:14 -07:00
|
|
|
ld de, ANIM_FRZ
|
2015-11-06 17:55:16 -08:00
|
|
|
call PlayOpponentBattleAnim
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
2013-03-27 14:07:00 -07: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
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2015-11-10 13:53:37 -08:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
call OpponentCantMove
|
2013-03-26 17:39:44 -07:00
|
|
|
call EndRechargeOpp
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, wEnemyJustGotFrozen
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 19:36:06 -08:00
|
|
|
jr z, .finish
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, wPlayerJustGotFrozen
|
2015-11-06 19:36:06 -08:00
|
|
|
.finish
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], $1
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36165
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_ParalyzeTarget: ; 36165
|
2013-03-26 22:52:04 -07:00
|
|
|
; paralyzetarget
|
|
|
|
|
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
|
|
|
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
|
|
|
|
ld a, [TypeModifier]
|
|
|
|
and $7f
|
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
cp HELD_PREVENT_PARALYZE
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [EffectFailed]
|
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
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
set PAR, [hl]
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateOpponentInParty
|
2015-11-06 17:55:16 -08:00
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2014-06-13 21:18:14 -07:00
|
|
|
ld de, ANIM_PAR
|
2015-11-06 17:55:16 -08:00
|
|
|
call PlayOpponentBattleAnim
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
2013-03-26 17:39:44 -07:00
|
|
|
call PrintParalyze
|
2015-11-06 19:36:06 -08:00
|
|
|
ld hl, UseHeldStatusHealingItem
|
2013-12-31 00:25:38 -08:00
|
|
|
jp CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 361ac
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_AttackUp: ; 361ac
|
2013-03-26 17:39:44 -07:00
|
|
|
; attackup
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, ATTACK
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DefenseUp: ; 361b0
|
2013-03-26 17:39:44 -07:00
|
|
|
; defenseup
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, DEFENSE
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpeedUp: ; 361b4
|
2013-03-26 17:39:44 -07:00
|
|
|
; speedup
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, SPEED
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpecialAttackUp: ; 361b8
|
2013-03-26 17:39:44 -07:00
|
|
|
; specialattackup
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, SP_ATTACK
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpecialDefenseUp: ; 361bc
|
2013-03-26 17:39:44 -07:00
|
|
|
; specialdefenseup
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, SP_DEFENSE
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_AccuracyUp: ; 361c0
|
2013-03-26 17:39:44 -07:00
|
|
|
; accuracyup
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, ACCURACY
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_EvasionUp: ; 361c4
|
2013-03-26 17:39:44 -07:00
|
|
|
; evasionup
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, EVASION
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_AttackUp2: ; 361c8
|
2013-03-26 17:39:44 -07:00
|
|
|
; attackup2
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, $10 | ATTACK
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DefenseUp2: ; 361cc
|
2013-03-26 17:39:44 -07:00
|
|
|
; defenseup2
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, $10 | DEFENSE
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpeedUp2: ; 361d0
|
2013-03-26 17:39:44 -07:00
|
|
|
; speedup2
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, $10 | SPEED
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpecialAttackUp2: ; 361d4
|
2013-03-26 17:39:44 -07:00
|
|
|
; specialattackup2
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, $10 | SP_ATTACK
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpecialDefenseUp2: ; 361d8
|
2013-03-26 17:39:44 -07:00
|
|
|
; specialdefenseup2
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, $10 | SP_DEFENSE
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_AccuracyUp2: ; 361dc
|
2013-03-26 17:39:44 -07:00
|
|
|
; accuracyup2
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, $10 | ACCURACY
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_EvasionUp2: ; 361e0
|
2013-03-26 17:39:44 -07:00
|
|
|
; evasionup2
|
2015-11-06 17:55:16 -08:00
|
|
|
ld b, $10 | EVASION
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatUp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_StatUp: ; 361e4
|
2013-03-26 17:39:44 -07:00
|
|
|
; statup
|
2015-10-07 18:27:32 -07:00
|
|
|
call CheckIfStatCanBeRaised
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [FailedMessage]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2015-11-09 13:41:09 -08:00
|
|
|
jp StatUpAnimation
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 361ef
|
|
|
|
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
CheckIfStatCanBeRaised: ; 361ef
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
2013-06-13 13:10:39 -07:00
|
|
|
ld [LoweredStat], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerStatLevels
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_stat_levels
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyStatLevels
|
2015-11-06 17:55:16 -08:00
|
|
|
.got_stat_levels
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jp nz, .stat_raise_failed
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [EffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jp nz, .stat_raise_failed
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [LoweredStat]
|
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]
|
|
|
|
inc b
|
|
|
|
ld a, $d
|
|
|
|
cp b
|
2015-11-06 17:55:16 -08:00
|
|
|
jp c, .cant_raise_stat
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [LoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f0
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_num_stages
|
2013-03-26 17:39:44 -07:00
|
|
|
inc b
|
|
|
|
ld a, $d
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .got_num_stages
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2015-11-06 17:55:16 -08:00
|
|
|
.got_num_stages
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], b
|
|
|
|
push hl
|
|
|
|
ld a, c
|
|
|
|
cp $5
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .done_calcing_stats
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, BattleMonStats + 1
|
2013-06-13 13:10:39 -07:00
|
|
|
ld de, PlayerStats
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_stats_pointer
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, EnemyMonStats + 1
|
2013-06-13 13:10:39 -07:00
|
|
|
ld de, EnemyStats
|
2015-11-06 17:55:16 -08:00
|
|
|
.got_stats_pointer
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
sla c
|
2014-06-13 21:18:14 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, c
|
|
|
|
add e
|
|
|
|
ld e, a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .no_carry
|
2013-03-26 17:39:44 -07:00
|
|
|
inc d
|
2015-11-06 17:55:16 -08:00
|
|
|
.no_carry
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
ld a, [hld]
|
2017-12-25 10:40:10 -08:00
|
|
|
sub LOW(MAX_STAT_VALUE)
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .not_already_max
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2017-12-25 10:40:10 -08:00
|
|
|
sbc HIGH(MAX_STAT_VALUE)
|
2015-11-06 17:55:16 -08:00
|
|
|
jp z, .stats_already_max
|
|
|
|
.not_already_max
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .calc_player_stats
|
2015-11-06 17:55:16 -08:00
|
|
|
call CalcEnemyStats
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .done_calcing_stats
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.calc_player_stats
|
|
|
|
call CalcPlayerStats
|
|
|
|
.done_calcing_stats
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
xor a
|
2013-06-13 13:10:39 -07:00
|
|
|
ld [FailedMessage], 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
|
|
|
; 3626e
|
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.stats_already_max ; 3626e
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
dec [hl]
|
2013-03-27 15:50:10 -07:00
|
|
|
; fallthrough
|
|
|
|
; 36270
|
|
|
|
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.cant_raise_stat ; 36270
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $2
|
2013-06-13 13:10:39 -07:00
|
|
|
ld [FailedMessage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
|
|
|
ld [AttackMissed], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3627b
|
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.stat_raise_failed ; 3627b
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2013-06-13 13:10:39 -07:00
|
|
|
ld [FailedMessage], 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
|
|
|
; 36281
|
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
StatUpAnimation: ; 36281
|
2015-11-10 13:53:37 -08:00
|
|
|
ld bc, wPlayerMinimized
|
2015-12-23 17:46:23 -08:00
|
|
|
ld hl, DropPlayerSub
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .do_player
|
2015-11-10 13:53:37 -08:00
|
|
|
ld bc, wEnemyMinimized
|
2015-12-23 17:46:23 -08:00
|
|
|
ld hl, DropEnemySub
|
2015-11-06 17:55:16 -08:00
|
|
|
.do_player
|
2014-01-05 04:28:55 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-01-05 04:28:55 -08:00
|
|
|
cp MINIMIZE
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2015-11-06 17:55:16 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
|
|
|
ld [bc], a
|
2015-11-06 19:36:06 -08:00
|
|
|
call _CheckBattleScene
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
2015-11-06 17:55:16 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hBGMapMode], a
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
call WaitBGMap
|
2015-11-06 11:45:10 -08:00
|
|
|
jp BattleCommand_MoveDelay
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 362ad
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_AttackDown: ; 362ad
|
2013-03-26 17:39:44 -07:00
|
|
|
; attackdown
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, ATTACK
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DefenseDown: ; 362b1
|
2013-03-26 17:39:44 -07:00
|
|
|
; defensedown
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, DEFENSE
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpeedDown: ; 362b5
|
2013-03-26 17:39:44 -07:00
|
|
|
; speeddown
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, SPEED
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpecialAttackDown: ; 362b9
|
2013-03-26 17:39:44 -07:00
|
|
|
; specialattackdown
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, SP_ATTACK
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpecialDefenseDown: ; 362bd
|
2013-03-26 17:39:44 -07:00
|
|
|
; specialdefensedown
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, SP_DEFENSE
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_AccuracyDown: ; 362c1
|
2013-03-26 17:39:44 -07:00
|
|
|
; accuracydown
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, ACCURACY
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_EvasionDown: ; 362c5
|
2013-03-26 17:39:44 -07:00
|
|
|
; evasiondown
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, EVASION
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_AttackDown2: ; 362c9
|
2013-03-26 17:39:44 -07:00
|
|
|
; attackdown2
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, $10 | ATTACK
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DefenseDown2: ; 362cd
|
2013-03-26 17:39:44 -07:00
|
|
|
; defensedown2
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, $10 | DEFENSE
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpeedDown2: ; 362d1
|
2013-03-26 17:39:44 -07:00
|
|
|
; speeddown2
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, $10 | SPEED
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpecialAttackDown2: ; 362d5
|
2013-03-26 17:39:44 -07:00
|
|
|
; specialattackdown2
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, $10 | SP_ATTACK
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_SpecialDefenseDown2: ; 362d9
|
2013-03-26 17:39:44 -07:00
|
|
|
; specialdefensedown2
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, $10 | SP_DEFENSE
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_AccuracyDown2: ; 362dd
|
2013-03-26 17:39:44 -07:00
|
|
|
; accuracydown2
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, $10 | ACCURACY
|
2015-11-06 11:45:10 -08:00
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_EvasionDown2: ; 362e1
|
2013-03-26 17:39:44 -07:00
|
|
|
; evasiondown2
|
2013-06-13 13:31:50 -07:00
|
|
|
ld a, $10 | EVASION
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_StatDown: ; 362e3
|
2013-03-26 17:39:44 -07:00
|
|
|
; statdown
|
2013-06-13 13:10:39 -07:00
|
|
|
|
|
|
|
ld [LoweredStat], a
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
call CheckMist
|
2013-06-13 13:10:39 -07:00
|
|
|
jp nz, .Mist
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyStatLevels
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2013-06-13 13:10:39 -07:00
|
|
|
jr z, .GetStatLevel
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerStatLevels
|
2013-06-13 13:10:39 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GetStatLevel:
|
2013-06-13 13:10:39 -07:00
|
|
|
; Attempt to lower the stat.
|
|
|
|
ld a, [LoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f
|
|
|
|
ld c, a
|
2013-06-13 13:10:39 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld b, [hl]
|
|
|
|
dec b
|
2013-06-13 13:10:39 -07:00
|
|
|
jp z, .CantLower
|
|
|
|
|
|
|
|
; Sharply lower the stat if applicable.
|
|
|
|
ld a, [LoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f0
|
2013-06-13 13:10:39 -07:00
|
|
|
jr z, .ComputerMiss
|
2013-03-26 17:39:44 -07:00
|
|
|
dec b
|
2013-06-13 13:10:39 -07:00
|
|
|
jr nz, .ComputerMiss
|
2013-03-26 17:39:44 -07:00
|
|
|
inc b
|
2013-06-13 13:10:39 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ComputerMiss:
|
2013-06-13 13:10:39 -07:00
|
|
|
; Computer opponents have a 1/4 chance of failing.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2013-06-13 13:10:39 -07:00
|
|
|
jr z, .DidntMiss
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2013-06-13 13:10:39 -07:00
|
|
|
jr nz, .DidntMiss
|
|
|
|
|
2015-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle]
|
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.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [PlayerSubStatus5]
|
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
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-06-13 13:10:39 -07:00
|
|
|
cp EFFECT_ACCURACY_DOWN_HIT
|
|
|
|
jr z, .DidntMiss
|
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp $40
|
2013-06-13 13:10:39 -07:00
|
|
|
jr c, .Failed
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DidntMiss:
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2013-06-13 13:10:39 -07:00
|
|
|
jr nz, .Failed
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2013-06-13 13:10:39 -07:00
|
|
|
jr nz, .Failed
|
|
|
|
|
|
|
|
ld a, [EffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2013-06-13 13:10:39 -07:00
|
|
|
jr nz, .Failed
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckHiddenOpponent
|
2013-06-13 13:10:39 -07:00
|
|
|
jr nz, .Failed
|
|
|
|
|
|
|
|
; Accuracy/Evasion reduction don't involve stats.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], b
|
|
|
|
ld a, c
|
2013-06-13 13:10:39 -07:00
|
|
|
cp ACCURACY
|
|
|
|
jr nc, .Hit
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonAttack + 1
|
2013-06-13 13:10:39 -07:00
|
|
|
ld de, EnemyStats
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .do_enemy
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BattleMonAttack + 1
|
2013-06-13 13:10:39 -07:00
|
|
|
ld de, PlayerStats
|
2015-11-06 17:55:16 -08:00
|
|
|
.do_enemy
|
|
|
|
call TryLowerStat
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
2013-06-13 13:10:39 -07:00
|
|
|
jr z, .CouldntLower
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Hit:
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2013-06-13 13:10:39 -07:00
|
|
|
ld [FailedMessage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2013-06-13 13:10:39 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.CouldntLower:
|
2013-03-26 17:39:44 -07:00
|
|
|
inc [hl]
|
2016-04-10 11:42:14 -07:00
|
|
|
.CantLower:
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, 3
|
|
|
|
ld [FailedMessage], a
|
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [AttackMissed], a
|
|
|
|
ret
|
2013-06-13 13:10:39 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Failed:
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, 1
|
|
|
|
ld [FailedMessage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [AttackMissed], a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Mist:
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, 2
|
|
|
|
ld [FailedMessage], a
|
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [AttackMissed], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36391
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
CheckMist: ; 36391
|
2013-05-02 22:29:57 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 22:29:57 -07:00
|
|
|
cp EFFECT_ATTACK_DOWN
|
2015-11-06 17:55:16 -08:00
|
|
|
jr c, .dont_check_mist
|
2013-05-02 22:29:57 -07:00
|
|
|
cp EFFECT_EVASION_DOWN + 1
|
2015-11-06 17:55:16 -08:00
|
|
|
jr c, .check_mist
|
2013-05-02 22:29:57 -07:00
|
|
|
cp EFFECT_ATTACK_DOWN_2
|
2015-11-06 17:55:16 -08:00
|
|
|
jr c, .dont_check_mist
|
2013-05-02 22:29:57 -07:00
|
|
|
cp EFFECT_EVASION_DOWN_2 + 1
|
2015-11-06 17:55:16 -08:00
|
|
|
jr c, .check_mist
|
2013-05-02 22:29:57 -07:00
|
|
|
cp EFFECT_ATTACK_DOWN_HIT
|
2015-11-06 17:55:16 -08:00
|
|
|
jr c, .dont_check_mist
|
2013-05-02 22:29:57 -07:00
|
|
|
cp EFFECT_EVASION_DOWN_HIT + 1
|
2015-11-06 17:55:16 -08:00
|
|
|
jr c, .check_mist
|
|
|
|
.dont_check_mist
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ret
|
2015-11-06 17:55:16 -08:00
|
|
|
|
|
|
|
.check_mist
|
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_MIST, 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
|
|
|
; 363b8
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
BattleCommand_StatUpMessage: ; 363b8
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [FailedMessage]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [LoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f
|
|
|
|
ld b, a
|
|
|
|
inc b
|
2013-03-27 15:50:10 -07:00
|
|
|
call GetStatName
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, .stat
|
|
|
|
jp BattleTextBox
|
|
|
|
|
|
|
|
.stat
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0cc6
|
2013-03-26 17:39:44 -07:00
|
|
|
start_asm
|
|
|
|
ld hl, .up
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [LoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f0
|
|
|
|
ret z
|
|
|
|
ld hl, .wayup
|
|
|
|
ret
|
|
|
|
|
|
|
|
.wayup
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0cd0
|
2013-03-26 17:39:44 -07:00
|
|
|
db "@"
|
|
|
|
|
|
|
|
.up
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0ce0
|
2013-03-26 17:39:44 -07:00
|
|
|
db "@"
|
|
|
|
|
|
|
|
; 363e9
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
BattleCommand_StatDownMessage: ; 363e9
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [FailedMessage]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [LoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f
|
|
|
|
ld b, a
|
|
|
|
inc b
|
2013-03-27 15:50:10 -07:00
|
|
|
call GetStatName
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, .stat
|
|
|
|
jp BattleTextBox
|
|
|
|
|
|
|
|
.stat
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0ceb
|
2013-03-26 17:39:44 -07:00
|
|
|
start_asm
|
|
|
|
ld hl, .fell
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [LoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f0
|
|
|
|
ret z
|
|
|
|
ld hl, .sharplyfell
|
|
|
|
ret
|
|
|
|
|
|
|
|
.sharplyfell
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0cf5
|
2013-03-26 17:39:44 -07:00
|
|
|
db "@"
|
|
|
|
.fell
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0d06
|
2013-03-26 17:39:44 -07:00
|
|
|
db "@"
|
|
|
|
|
|
|
|
; 3641a
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
TryLowerStat: ; 3641a
|
2013-06-13 13:10:39 -07:00
|
|
|
; Lower stat c from stat struct hl (buffer de).
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
sla c
|
2013-03-26 22:52:04 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
2013-06-13 13:10:39 -07:00
|
|
|
; add de, c
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c
|
|
|
|
add e
|
|
|
|
ld e, a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nc, .no_carry
|
2013-03-26 17:39:44 -07:00
|
|
|
inc d
|
2015-11-06 17:55:16 -08:00
|
|
|
.no_carry
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
2013-06-13 13:10:39 -07:00
|
|
|
|
|
|
|
; The lowest possible stat is 1.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2013-03-26 22:52:04 -07:00
|
|
|
sub 1
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .not_min
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.not_min
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2013-06-13 13:10:39 -07:00
|
|
|
jr z, .Player
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2015-11-06 17:55:16 -08:00
|
|
|
call CalcPlayerStats
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-06-13 13:10:39 -07:00
|
|
|
jr .end
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Player:
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2015-11-06 17:55:16 -08:00
|
|
|
call CalcEnemyStats
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-06-13 13:10:39 -07:00
|
|
|
.end
|
|
|
|
ld a, 1
|
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
|
|
|
; 3644c
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_StatUpFailText: ; 3644c
|
2013-03-26 22:52:04 -07:00
|
|
|
; statupfailtext
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [FailedMessage]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
push af
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
|
|
|
dec a
|
2013-03-27 15:50:10 -07:00
|
|
|
jp z, TryPrintButItFailed
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [LoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f
|
|
|
|
ld b, a
|
|
|
|
inc b
|
2013-03-27 15:50:10 -07:00
|
|
|
call GetStatName
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, WontRiseAnymoreText
|
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
|
|
|
; 3646a
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_StatDownFailText: ; 3646a
|
2013-03-26 22:52:04 -07:00
|
|
|
; statdownfailtext
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [FailedMessage]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
push af
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
|
|
|
dec a
|
2013-03-27 15:50:10 -07:00
|
|
|
jp z, TryPrintButItFailed
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2013-03-26 22:52:04 -07:00
|
|
|
ld hl, ProtectedByMistText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp z, StdBattleTextBox
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [LoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f
|
|
|
|
ld b, a
|
|
|
|
inc b
|
2013-03-27 15:50:10 -07:00
|
|
|
call GetStatName
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, WontDropAnymoreText
|
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
|
|
|
; 3648f
|
|
|
|
|
|
|
|
|
|
|
|
GetStatName: ; 3648f
|
|
|
|
ld hl, .names
|
|
|
|
ld c, "@"
|
2016-04-10 11:42:14 -07:00
|
|
|
.CheckName:
|
2013-03-26 17:39:44 -07:00
|
|
|
dec b
|
|
|
|
jr z, .Copy
|
2016-04-10 11:42:14 -07:00
|
|
|
.GetName:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp c
|
|
|
|
jr z, .CheckName
|
|
|
|
jr .GetName
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Copy:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, StringBuffer2
|
|
|
|
ld bc, StringBuffer3 - StringBuffer2
|
|
|
|
jp CopyBytes
|
|
|
|
|
|
|
|
.names
|
|
|
|
db "ATTACK@"
|
|
|
|
db "DEFENSE@"
|
|
|
|
db "SPEED@"
|
|
|
|
db "SPCL.ATK@"
|
|
|
|
db "SPCL.DEF@"
|
|
|
|
db "ACCURACY@"
|
|
|
|
db "EVASION@"
|
|
|
|
db "ABILITY@"
|
|
|
|
; 364e6
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
StatLevelMultipliers: ; 364e6
|
|
|
|
db 25, 100 ; 0.25x
|
|
|
|
db 28, 100 ; 0.28x
|
|
|
|
db 33, 100 ; 0.33x
|
|
|
|
db 40, 100 ; 0.40x
|
|
|
|
db 50, 100 ; 0.50x
|
|
|
|
db 66, 100 ; 0.66x
|
|
|
|
db 1, 1 ; 1.00x
|
|
|
|
db 15, 10 ; 1.50x
|
|
|
|
db 2, 1 ; 2.00x
|
|
|
|
db 25, 10 ; 2.50x
|
|
|
|
db 3, 1 ; 3.00x
|
|
|
|
db 35, 10 ; 3.50x
|
|
|
|
db 4, 1 ; 4.00x
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36500
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_AllStatsUp: ; 36500
|
2013-03-27 15:50:10 -07:00
|
|
|
; allstatsup
|
|
|
|
|
|
|
|
; Attack
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetMiss
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_AttackUp
|
2015-11-06 17:55:16 -08:00
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; Defense
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetMiss
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_DefenseUp
|
2015-11-06 17:55:16 -08:00
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; Speed
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetMiss
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_SpeedUp
|
2015-11-06 17:55:16 -08:00
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; Special Attack
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetMiss
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_SpecialAttackUp
|
2015-11-06 17:55:16 -08:00
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; Special Defense
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetMiss
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_SpecialDefenseUp
|
2015-11-06 17:55:16 -08:00
|
|
|
jp BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3652d
|
|
|
|
|
|
|
|
|
|
|
|
ResetMiss: ; 3652d
|
|
|
|
xor a
|
|
|
|
ld [AttackMissed], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36532
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
LowerStat: ; 36532
|
2013-06-13 13:10:39 -07:00
|
|
|
ld [LoweredStat], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, PlayerStatLevels
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .got_target
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyStatLevels
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.got_target
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [LoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld b, [hl]
|
|
|
|
dec b
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .cant_lower_anymore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [LoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f0
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .got_num_stages
|
2013-03-26 17:39:44 -07:00
|
|
|
dec b
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .got_num_stages
|
2013-03-26 17:39:44 -07:00
|
|
|
inc b
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.got_num_stages
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], b
|
|
|
|
ld a, c
|
|
|
|
cp 5
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nc, .accuracy_evasion
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
push hl
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, BattleMonStats + 1
|
2013-06-13 13:10:39 -07:00
|
|
|
ld de, PlayerStats
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .got_target_2
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, EnemyMonStats + 1
|
2013-06-13 13:10:39 -07:00
|
|
|
ld de, EnemyStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.got_target_2
|
|
|
|
call TryLowerStat
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.accuracy_evasion
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .player
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
call CalcEnemyStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
jr .finish
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.player
|
|
|
|
call CalcPlayerStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.finish
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2013-06-13 13:10:39 -07:00
|
|
|
ld [FailedMessage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.failed
|
2013-03-26 17:39:44 -07:00
|
|
|
inc [hl]
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.cant_lower_anymore
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 2
|
2013-06-13 13:10:39 -07:00
|
|
|
ld [FailedMessage], 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
|
|
|
; 3658f
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_TriStatusChance: ; 3658f
|
2013-03-26 22:52:04 -07:00
|
|
|
; tristatuschance
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_EffectChance
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
; 1/3 chance of each status
|
2013-03-26 17:39:44 -07:00
|
|
|
.loop
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
swap a
|
2013-03-26 22:52:04 -07:00
|
|
|
and 3
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .loop
|
|
|
|
; jump
|
|
|
|
dec a
|
|
|
|
ld hl, .ptrs
|
2013-07-04 12:42:01 -07:00
|
|
|
rst JumpTable
|
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
|
|
|
.ptrs
|
2015-11-06 11:45:10 -08:00
|
|
|
dw BattleCommand_ParalyzeTarget ; paralyze
|
|
|
|
dw BattleCommand_FreezeTarget ; freeze
|
|
|
|
dw BattleCommand_BurnTarget ; burn
|
2013-03-26 17:39:44 -07:00
|
|
|
; 365a7
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Curl: ; 365a7
|
2013-03-26 22:52:04 -07:00
|
|
|
; curl
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS2
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-17 11:58:11 -07:00
|
|
|
set SUBSTATUS_CURLED, [hl]
|
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
|
|
|
; 365af
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
BattleCommand_RaiseSubNoAnim: ; 365af
|
2017-12-24 12:03:20 -08:00
|
|
|
ld hl, GetBattleMonBackpic
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .PlayerTurn
|
2017-12-24 12:03:20 -08:00
|
|
|
ld hl, GetEnemyMonFrontpic
|
2016-04-10 11:42:14 -07:00
|
|
|
.PlayerTurn:
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hBGMapMode], a
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-12-01 11:19:57 -08:00
|
|
|
jp WaitBGMap
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 365c3
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
BattleCommand_LowerSubNoAnim: ; 365c3
|
2015-12-23 17:46:23 -08:00
|
|
|
ld hl, DropPlayerSub
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .PlayerTurn
|
2015-12-23 17:46:23 -08:00
|
|
|
ld hl, DropEnemySub
|
2016-04-10 11:42:14 -07:00
|
|
|
.PlayerTurn:
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hBGMapMode], a
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-12-01 11:19:57 -08:00
|
|
|
jp WaitBGMap
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 365d7
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
CalcPlayerStats: ; 365d7
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerAtkLevel
|
2013-06-13 13:10:39 -07:00
|
|
|
ld de, PlayerStats
|
2014-06-12 18:32:42 -07:00
|
|
|
ld bc, BattleMonAttack
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, 5
|
|
|
|
call CalcStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-07-29 10:58:20 -07:00
|
|
|
ld hl, BadgeStatBoosts
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ld hl, ApplyBrnEffectOnAttack
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
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
|
|
|
; 365fd
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
CalcEnemyStats: ; 365fd
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyAtkLevel
|
2013-06-13 13:10:39 -07:00
|
|
|
ld de, EnemyStats
|
2014-06-12 18:32:42 -07:00
|
|
|
ld bc, EnemyMonAttack
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, 5
|
|
|
|
call CalcStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ld hl, ApplyBrnEffectOnAttack
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
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
|
|
|
; 3661d
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
CalcStats: ; 3661d
|
|
|
|
.loop
|
2013-03-26 17:39:44 -07:00
|
|
|
push af
|
|
|
|
ld a, [hli]
|
|
|
|
push hl
|
|
|
|
push bc
|
2013-12-01 11:19:57 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
dec c
|
|
|
|
ld b, 0
|
2015-11-06 17:55:16 -08:00
|
|
|
ld hl, StatLevelMultipliers
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, bc
|
2013-12-01 11:19:57 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 0], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
2013-12-01 11:19:57 -08:00
|
|
|
ld [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
inc de
|
|
|
|
ld a, [de]
|
2013-12-01 11:19:57 -08:00
|
|
|
ld [hMultiplicand + 2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
inc de
|
2013-12-01 11:19:57 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2013-12-01 11:19:57 -08:00
|
|
|
ld [hMultiplier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call Multiply
|
|
|
|
|
|
|
|
ld a, [hl]
|
2013-12-01 11:19:57 -08:00
|
|
|
ld [hDivisor], a
|
|
|
|
ld b, 4
|
2013-03-26 17:39:44 -07:00
|
|
|
call Divide
|
|
|
|
|
2013-12-01 11:19:57 -08:00
|
|
|
ld a, [hQuotient + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2013-12-01 11:19:57 -08:00
|
|
|
ld a, [hQuotient + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .check_maxed_out
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-12-01 11:19:57 -08:00
|
|
|
ld a, 1
|
|
|
|
ld [hQuotient + 2], a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr .not_maxed_out
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.check_maxed_out
|
2013-12-01 11:19:57 -08:00
|
|
|
ld a, [hQuotient + 2]
|
2017-12-25 10:40:10 -08:00
|
|
|
cp LOW(MAX_STAT_VALUE)
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
2017-12-25 10:40:10 -08:00
|
|
|
sbc HIGH(MAX_STAT_VALUE)
|
2015-11-06 17:55:16 -08:00
|
|
|
jr c, .not_maxed_out
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2017-12-25 10:40:10 -08:00
|
|
|
ld a, LOW(MAX_STAT_VALUE)
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hQuotient + 2], a
|
2017-12-25 10:40:10 -08:00
|
|
|
ld a, HIGH(MAX_STAT_VALUE)
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hQuotient + 1], a
|
2013-12-01 11:19:57 -08:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.not_maxed_out
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hQuotient + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [bc], a
|
|
|
|
inc bc
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hQuotient + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [bc], a
|
|
|
|
inc bc
|
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
dec a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .loop
|
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
|
|
|
; 36671
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_StoreEnergy: ; 36671
|
2013-03-26 22:52:04 -07:00
|
|
|
; storeenergy
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-08-13 19:44:56 -07:00
|
|
|
bit SUBSTATUS_BIDE, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
ld hl, PlayerRolloutCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .check_still_storing_energy
|
2013-04-19 00:50:45 -07:00
|
|
|
ld hl, EnemyRolloutCount
|
2015-11-06 17:55:16 -08:00
|
|
|
.check_still_storing_energy
|
2013-03-26 17:39:44 -07:00
|
|
|
dec [hl]
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .still_storing
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-08-13 19:44:56 -07:00
|
|
|
res SUBSTATUS_BIDE, [hl]
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, UnleashedEnergyText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_POWER
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-05-02 22:29:57 -07:00
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2013-05-02 22:29:57 -07:00
|
|
|
ld hl, PlayerDamageTaken + 1
|
2015-11-07 18:04:54 -08:00
|
|
|
ld de, wPlayerCharging ; player
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .player
|
2013-05-02 22:29:57 -07:00
|
|
|
ld hl, EnemyDamageTaken + 1
|
2015-11-07 18:04:54 -08:00
|
|
|
ld de, wEnemyCharging ; enemy
|
2015-11-06 17:55:16 -08:00
|
|
|
.player
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
|
|
|
add a
|
|
|
|
ld b, a
|
|
|
|
ld [CurDamage + 1], a
|
|
|
|
ld a, [hl]
|
|
|
|
rl a
|
|
|
|
ld [CurDamage], a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nc, .not_maxed
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $ff
|
|
|
|
ld [CurDamage], a
|
|
|
|
ld [CurDamage + 1], a
|
2015-11-06 17:55:16 -08:00
|
|
|
.not_maxed
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .built_up_something
|
2013-05-02 22:29:57 -07:00
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [AttackMissed], a
|
2015-11-06 17:55:16 -08:00
|
|
|
.built_up_something
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ld [de], a
|
2013-05-02 22:29:57 -07:00
|
|
|
|
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-05-02 22:29:57 -07:00
|
|
|
ld a, BIDE
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-04-13 21:39:54 -07:00
|
|
|
ld b, unleashenergy_command
|
2013-03-26 22:52:04 -07:00
|
|
|
jp SkipToBattleCommand
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.still_storing
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, StoringEnergyText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
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
|
|
|
; 366e5
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_UnleashEnergy: ; 366e5
|
2013-03-26 22:52:04 -07:00
|
|
|
; unleashenergy
|
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, PlayerDamageTaken
|
2013-04-19 00:50:45 -07:00
|
|
|
ld bc, PlayerRolloutCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_damage
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, EnemyDamageTaken
|
2013-04-19 00:50:45 -07:00
|
|
|
ld bc, EnemyRolloutCount
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-08-13 19:44:56 -07:00
|
|
|
set SUBSTATUS_BIDE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
2016-01-09 16:34:14 -08:00
|
|
|
ld [wPlayerMoveStructEffect], a
|
|
|
|
ld [wEnemyMoveStructEffect], a
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2014-08-13 19:44:56 -07:00
|
|
|
and 1
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-12-26 18:59:03 -08:00
|
|
|
inc a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [bc], a
|
2014-08-13 19:44:56 -07:00
|
|
|
ld a, 1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
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
|
|
|
; 3671a
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_CheckRampage: ; 3671a
|
2013-03-26 22:52:04 -07:00
|
|
|
; checkrampage
|
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
ld de, PlayerRolloutCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .player
|
2013-04-19 00:50:45 -07:00
|
|
|
ld de, EnemyRolloutCount
|
2015-11-06 17:55:16 -08:00
|
|
|
.player
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2015-11-06 17:55:16 -08:00
|
|
|
bit SUBSTATUS_RAMPAGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
ld a, [de]
|
|
|
|
dec a
|
|
|
|
ld [de], a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .continue_rampage
|
2015-11-06 17:55:16 -08:00
|
|
|
|
|
|
|
res SUBSTATUS_RAMPAGE, [hl]
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2015-11-06 19:36:06 -08:00
|
|
|
call SafeCheckSafeguard
|
2013-03-26 17:39:44 -07:00
|
|
|
push af
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .continue_rampage
|
2015-11-06 17:55:16 -08:00
|
|
|
|
|
|
|
set SUBSTATUS_CONFUSED, [hl]
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2015-11-06 17:55:16 -08:00
|
|
|
and %00000001
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-12-26 18:59:03 -08:00
|
|
|
inc a
|
2015-11-06 17:55:16 -08:00
|
|
|
inc de ; ConfuseCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [de], a
|
2015-11-06 17:55:16 -08:00
|
|
|
.continue_rampage
|
2015-04-13 21:39:54 -07:00
|
|
|
ld b, rampage_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
|
|
|
; 36751
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Rampage: ; 36751
|
2013-03-26 22:52:04 -07:00
|
|
|
; rampage
|
|
|
|
|
|
|
|
; No rampage during Sleep Talk.
|
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 11:58:11 -07:00
|
|
|
and SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
ld de, PlayerRolloutCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-17 11:58:11 -07:00
|
|
|
jr z, .ok
|
2013-04-19 00:50:45 -07:00
|
|
|
ld de, EnemyRolloutCount
|
2014-06-17 11:58:11 -07:00
|
|
|
.ok
|
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-17 12:52:32 -07:00
|
|
|
set SUBSTATUS_RAMPAGE, [hl]
|
2015-11-06 17:55:16 -08:00
|
|
|
; Rampage for 1 or 2 more turns
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2015-11-06 17:55:16 -08:00
|
|
|
and %00000001
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
|
|
|
ld [de], a
|
2013-04-19 00:50:45 -07:00
|
|
|
ld a, 1
|
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
|
|
|
; 36778
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Teleport: ; 36778
|
2013-03-26 22:52:04 -07:00
|
|
|
; teleport
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [BattleType]
|
2013-05-02 23:43:44 -07:00
|
|
|
cp BATTLETYPE_SHINY
|
2014-06-17 11:58:11 -07:00
|
|
|
jr z, .failed
|
|
|
|
cp BATTLETYPE_TRAP
|
|
|
|
jr z, .failed
|
2014-06-13 22:53:20 -07:00
|
|
|
cp BATTLETYPE_CELEBI
|
2014-06-17 11:58:11 -07:00
|
|
|
jr z, .failed
|
2013-05-02 23:43:44 -07:00
|
|
|
cp BATTLETYPE_SUICUNE
|
2014-06-17 11:58:11 -07:00
|
|
|
jr z, .failed
|
2013-05-02 23:43:44 -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_CANT_RUN, a
|
2014-06-17 11:58:11 -07:00
|
|
|
jr nz, .failed
|
2015-11-06 17:55:16 -08:00
|
|
|
; Only need to check these next things if it's your turn
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .enemy_turn
|
|
|
|
; Can't teleport from a trainer battle
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2014-06-17 11:58:11 -07:00
|
|
|
jr nz, .failed
|
2015-11-06 17:55:16 -08:00
|
|
|
; If your level is greater than the opponent's, you run without fail.
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [CurPartyLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [BattleMonLevel]
|
|
|
|
cp b
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nc, .run_away
|
|
|
|
; Generate a number between 0 and (YourLevel + TheirLevel).
|
2013-03-26 17:39:44 -07:00
|
|
|
add b
|
|
|
|
ld c, a
|
|
|
|
inc c
|
2015-11-06 17:55:16 -08:00
|
|
|
.loop_player
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .loop_player
|
2015-11-06 17:55:16 -08:00
|
|
|
; If that number is greater than 4 times your level, run away.
|
2013-03-26 17:39:44 -07:00
|
|
|
srl b
|
|
|
|
srl b
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .run_away
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
.failed
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-27 15:50:10 -07:00
|
|
|
jp PrintButItFailed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.enemy_turn
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2014-06-17 11:58:11 -07:00
|
|
|
jr nz, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [BattleMonLevel]
|
|
|
|
ld b, a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [CurPartyLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .run_away
|
2013-03-26 17:39:44 -07:00
|
|
|
add b
|
|
|
|
ld c, a
|
|
|
|
inc c
|
2015-11-06 17:55:16 -08:00
|
|
|
.loop_enemy
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .loop_enemy
|
2013-03-26 17:39:44 -07:00
|
|
|
srl b
|
|
|
|
srl b
|
|
|
|
cp b
|
2016-10-28 17:08:18 -07:00
|
|
|
; This does the wrong thing. What was
|
|
|
|
; probably intended was jr c, .failed
|
|
|
|
; The way this is made makes enemy use
|
|
|
|
; of Teleport always succeed if able
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .run_away
|
2015-11-06 17:55:16 -08:00
|
|
|
.run_away
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateBattleMonInParty
|
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
|
|
|
inc a
|
2015-11-08 16:09:36 -08:00
|
|
|
ld [wForcedSwitch], a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
|
|
|
call SetBattleDraw
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2015-11-09 13:41:09 -08:00
|
|
|
call LoadMoveAnim
|
2013-05-02 23:43:44 -07:00
|
|
|
ld c, 20
|
2013-03-26 17:39:44 -07:00
|
|
|
call DelayFrames
|
2015-11-06 17:55:16 -08:00
|
|
|
call SetBattleDraw
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, FledFromBattleText
|
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
|
|
|
; 36804
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
SetBattleDraw: ; 36804
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wBattleResult]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $c0
|
|
|
|
or $2
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wBattleResult], 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
|
|
|
; 3680f
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_ForceSwitch: ; 3680f
|
2013-03-26 22:52:04 -07:00
|
|
|
; forceswitch
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [BattleType]
|
2013-05-02 23:43:44 -07:00
|
|
|
cp BATTLETYPE_SHINY
|
2015-11-07 06:48:32 -08:00
|
|
|
jp z, .fail
|
2015-09-09 16:27:07 -07:00
|
|
|
cp BATTLETYPE_TRAP
|
2015-11-07 06:48:32 -08:00
|
|
|
jp z, .fail
|
2014-06-13 22:53:20 -07:00
|
|
|
cp BATTLETYPE_CELEBI
|
2015-11-07 06:48:32 -08:00
|
|
|
jp z, .fail
|
2013-05-02 23:43:44 -07:00
|
|
|
cp BATTLETYPE_SUICUNE
|
2015-11-07 06:48:32 -08:00
|
|
|
jp z, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-07 06:48:32 -08:00
|
|
|
jp nz, .force_player_switch
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .missed
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .trainer
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [CurPartyLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [BattleMonLevel]
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .wild_force_flee
|
2013-03-26 17:39:44 -07:00
|
|
|
add b
|
|
|
|
ld c, a
|
|
|
|
inc c
|
2015-11-07 06:48:32 -08:00
|
|
|
.random_loop_wild
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .random_loop_wild
|
2013-03-26 17:39:44 -07:00
|
|
|
srl b
|
|
|
|
srl b
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .wild_force_flee
|
2015-11-07 06:48:32 -08:00
|
|
|
.missed
|
|
|
|
jp .fail
|
|
|
|
|
|
|
|
.wild_force_flee
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateBattleMonInParty
|
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
|
|
|
inc a
|
2015-11-08 16:09:36 -08:00
|
|
|
ld [wForcedSwitch], a
|
2015-11-06 17:55:16 -08:00
|
|
|
call SetBattleDraw
|
2016-01-09 16:34:14 -08:00
|
|
|
ld a, [wPlayerMoveStructAnimation]
|
2015-11-07 06:48:32 -08:00
|
|
|
jp .succeed
|
|
|
|
|
|
|
|
.trainer
|
2015-11-08 16:09:36 -08:00
|
|
|
call FindAliveEnemyMons
|
2015-12-26 15:11:55 -08:00
|
|
|
jr c, .switch_fail
|
2015-11-08 16:09:36 -08:00
|
|
|
ld a, [wEnemyGoesFirst]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .switch_fail
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateEnemyMonInParty
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, $14
|
|
|
|
call DelayFrames
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 1, 0
|
2015-11-01 06:38:48 -08:00
|
|
|
lb bc, 4, 10
|
2013-03-26 17:39:44 -07:00
|
|
|
call ClearBox
|
2015-11-07 06:48:32 -08:00
|
|
|
ld c, 20
|
2013-03-26 17:39:44 -07:00
|
|
|
call DelayFrames
|
|
|
|
ld a, [OTPartyCount]
|
|
|
|
ld b, a
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
ld c, a
|
2015-11-07 06:48:32 -08:00
|
|
|
; select a random enemy mon to switch to
|
|
|
|
.random_loop_trainer
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .random_loop_trainer
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .random_loop_trainer
|
2013-03-26 17:39:44 -07:00
|
|
|
push af
|
|
|
|
push bc
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, OTPartyMon1HP
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetPartyLocation
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
pop bc
|
|
|
|
pop de
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .random_loop_trainer
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, d
|
|
|
|
inc a
|
2015-11-08 16:09:36 -08:00
|
|
|
ld [wEnemySwitchMonIndex], a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar ForceEnemySwitch
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, DraggedOutText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
ld hl, SpikesDamage
|
2013-12-31 00:25:38 -08:00
|
|
|
jp CallBattleCore
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
.switch_fail
|
|
|
|
jp .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
.force_player_switch
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-11-07 06:48:32 -08:00
|
|
|
jr nz, .player_miss
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2015-11-07 06:48:32 -08:00
|
|
|
jr nz, .vs_trainer
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [BattleMonLevel]
|
|
|
|
ld b, a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [CurPartyLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2015-11-07 06:48:32 -08:00
|
|
|
jr nc, .wild_succeed_playeristarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
add b
|
|
|
|
ld c, a
|
|
|
|
inc c
|
2015-11-07 06:48:32 -08:00
|
|
|
.wild_random_loop_playeristarget
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2015-11-07 06:48:32 -08:00
|
|
|
jr nc, .wild_random_loop_playeristarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
srl b
|
|
|
|
srl b
|
|
|
|
cp b
|
2015-11-07 06:48:32 -08:00
|
|
|
jr nc, .wild_succeed_playeristarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
.player_miss
|
|
|
|
jr .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
.wild_succeed_playeristarget
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateBattleMonInParty
|
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
|
|
|
inc a
|
2015-11-08 16:09:36 -08:00
|
|
|
ld [wForcedSwitch], a
|
2015-11-06 17:55:16 -08:00
|
|
|
call SetBattleDraw
|
2016-01-09 16:34:14 -08:00
|
|
|
ld a, [wEnemyMoveStructAnimation]
|
2015-11-07 06:48:32 -08:00
|
|
|
jr .succeed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
.vs_trainer
|
|
|
|
call CheckPlayerHasMonToSwitchTo
|
|
|
|
jr c, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
ld a, [wEnemyGoesFirst]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp $1
|
2015-11-07 06:48:32 -08:00
|
|
|
jr z, .switch_fail
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateBattleMonInParty
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2015-11-07 06:48:32 -08:00
|
|
|
ld c, 20
|
2013-03-26 17:39:44 -07:00
|
|
|
call DelayFrames
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 9, 7
|
2015-11-01 06:38:48 -08:00
|
|
|
lb bc, 5, 11
|
2013-12-31 01:09:00 -08:00
|
|
|
call ClearBox
|
2015-11-07 06:48:32 -08:00
|
|
|
ld c, 20
|
2013-03-26 17:39:44 -07:00
|
|
|
call DelayFrames
|
|
|
|
ld a, [PartyCount]
|
|
|
|
ld b, a
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld c, a
|
2015-11-07 06:48:32 -08:00
|
|
|
.random_loop_trainer_playeristarget
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7
|
|
|
|
cp b
|
2015-11-07 06:48:32 -08:00
|
|
|
jr nc, .random_loop_trainer_playeristarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp c
|
2015-11-07 06:48:32 -08:00
|
|
|
jr z, .random_loop_trainer_playeristarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
push af
|
|
|
|
push bc
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, PartyMon1HP
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetPartyLocation
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
pop bc
|
|
|
|
pop de
|
2015-11-07 06:48:32 -08:00
|
|
|
jr z, .random_loop_trainer_playeristarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, d
|
|
|
|
ld [CurPartyMon], a
|
2015-11-07 06:48:32 -08:00
|
|
|
ld hl, SwitchPlayerMon
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, DraggedOutText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
ld hl, SpikesDamage
|
2013-12-31 00:25:38 -08:00
|
|
|
jp CallBattleCore
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
.fail
|
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
|
|
|
call BattleCommand_RaiseSub
|
2013-03-27 15:50:10 -07:00
|
|
|
jp PrintButItFailed
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
.succeed
|
2013-03-26 17:39:44 -07:00
|
|
|
push af
|
2015-11-06 17:55:16 -08:00
|
|
|
call SetBattleDraw
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2015-11-07 06:48:32 -08:00
|
|
|
ld c, 20
|
2013-03-26 17:39:44 -07:00
|
|
|
call DelayFrames
|
|
|
|
pop af
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, FledInFearText
|
2015-11-07 06:48:32 -08:00
|
|
|
cp ROAR
|
|
|
|
jr z, .do_text
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, BlownAwayText
|
2015-11-07 06:48:32 -08:00
|
|
|
.do_text
|
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
|
|
|
; 36994
|
|
|
|
|
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
CheckPlayerHasMonToSwitchTo: ; 36994
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [PartyCount]
|
|
|
|
ld d, a
|
|
|
|
ld e, 0
|
2015-11-04 08:19:58 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2015-11-07 06:48:32 -08:00
|
|
|
.loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CurBattleMon]
|
|
|
|
cp e
|
2015-11-07 06:48:32 -08:00
|
|
|
jr z, .next
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, e
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, PartyMon1HP
|
2013-03-26 17:39:44 -07:00
|
|
|
call AddNTimes
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
2015-11-07 06:48:32 -08:00
|
|
|
jr nz, .not_fainted
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
.next
|
2013-03-26 17:39:44 -07:00
|
|
|
inc e
|
|
|
|
dec d
|
2015-11-07 06:48:32 -08:00
|
|
|
jr nz, .loop
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
.not_fainted
|
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
|
|
|
; 369b6
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_EndLoop: ; 369b6
|
2013-03-26 22:52:04 -07:00
|
|
|
; endloop
|
|
|
|
|
|
|
|
; Loop back to the command before 'critical'.
|
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
ld de, PlayerRolloutCount
|
2015-02-08 00:03:32 -08:00
|
|
|
ld bc, PlayerDamageTaken
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_addrs
|
2013-04-19 00:50:45 -07:00
|
|
|
ld de, EnemyRolloutCount
|
2015-02-08 00:03:32 -08:00
|
|
|
ld bc, EnemyDamageTaken
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_addrs
|
2013-03-26 22:52:04 -07:00
|
|
|
|
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, [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
jp nz, .in_loop
|
2014-06-23 12:47:07 -07:00
|
|
|
set SUBSTATUS_IN_LOOP, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2017-11-15 07:36:13 -08:00
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .twineedle
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_DOUBLE_HIT
|
2015-12-26 15:11:55 -08:00
|
|
|
ld a, 1
|
|
|
|
jr z, .double_hit
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_BEAT_UP
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .beat_up
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_TRIPLE_KICK
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .not_triple_kick
|
|
|
|
.reject_triple_kick_sample
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and $3
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .reject_triple_kick_sample
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .double_hit
|
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [bc], a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .done_loop
|
|
|
|
|
|
|
|
.beat_up
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .check_ot_beat_up
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [PartyCount]
|
2015-12-26 15:11:55 -08:00
|
|
|
cp 1
|
|
|
|
jp z, .only_one_beatup
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .double_hit
|
|
|
|
|
|
|
|
.check_ot_beat_up
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2015-12-26 15:11:55 -08:00
|
|
|
cp WILD_BATTLE
|
|
|
|
jp z, .only_one_beatup
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [OTPartyCount]
|
2015-12-26 15:11:55 -08:00
|
|
|
cp 1
|
|
|
|
jp z, .only_one_beatup
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .double_hit
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.only_one_beatup
|
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
|
|
|
res SUBSTATUS_IN_LOOP, [hl]
|
2013-03-27 15:50:10 -07:00
|
|
|
call BattleCommanda8
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.not_triple_kick
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and $3
|
2015-12-26 15:11:55 -08:00
|
|
|
cp 2
|
|
|
|
jr c, .got_number_hits
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and $3
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_number_hits
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-12-26 15:11:55 -08:00
|
|
|
.double_hit
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [de], a
|
|
|
|
inc a
|
|
|
|
ld [bc], a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .loop_back_to_critical
|
|
|
|
|
|
|
|
.twineedle
|
|
|
|
ld a, 1
|
|
|
|
jr .double_hit
|
2013-05-02 23:43:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.in_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
dec a
|
|
|
|
ld [de], a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .loop_back_to_critical
|
|
|
|
.done_loop
|
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
|
|
|
res SUBSTATUS_IN_LOOP, [hl]
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, PlayerHitTimesText
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_hit_n_times_text
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, EnemyHitTimesText
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_hit_n_times_text
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
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_BEAT_UP
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .beat_up_2
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
.beat_up_2
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
xor a
|
|
|
|
ld [bc], a
|
|
|
|
ret
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
; Loop back to the command before 'critical'.
|
2015-12-26 15:11:55 -08:00
|
|
|
.loop_back_to_critical
|
2017-12-09 11:22:58 -08:00
|
|
|
ld a, [BattleScriptBufferAddress + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, a
|
2017-12-09 11:22:58 -08:00
|
|
|
ld a, [BattleScriptBufferAddress]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld l, a
|
2015-12-26 15:11:55 -08:00
|
|
|
.not_critical
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2015-12-26 15:11:55 -08:00
|
|
|
cp critical_command
|
|
|
|
jr nz, .not_critical
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld a, h
|
2017-12-09 11:22:58 -08:00
|
|
|
ld [BattleScriptBufferAddress + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, l
|
2017-12-09 11:22:58 -08:00
|
|
|
ld [BattleScriptBufferAddress], 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
|
|
|
; 36a82
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_FakeOut: ; 36a82
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
|
|
|
ret nz
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .fail
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << FRZ | SLP
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .fail
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckOpponentWentFirst
|
|
|
|
jr z, FlinchTarget
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.fail
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
|
|
|
ld [AttackMissed], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36aa0
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_FlinchTarget: ; 36aa0
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << FRZ | SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckOpponentWentFirst
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [EffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 36ab5
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
FlinchTarget: ; 36ab5
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
set SUBSTATUS_FLINCHED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndRechargeOpp
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36abf
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
CheckOpponentWentFirst: ; 36abf
|
|
|
|
; Returns a=0, z if user went first
|
|
|
|
; Returns a=1, nz if opponent went first
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, [wEnemyGoesFirst] ; 0 if player went first
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, [hBattleTurn] ; 0 if it's the player's turn
|
|
|
|
xor b ; 1 if opponent went first
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36ac9
|
|
|
|
|
|
|
|
|
2017-12-13 06:22:01 -08:00
|
|
|
BattleCommand_HeldFlinch: ; 36ac9
|
2013-03-26 22:52:04 -07:00
|
|
|
; kingsrock
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
|
|
|
ret nz
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetUserItem
|
|
|
|
ld a, b
|
2017-12-13 06:22:01 -08:00
|
|
|
cp HELD_FLINCH
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
call GetUserItem
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
|
|
|
ret nc
|
|
|
|
call EndRechargeOpp
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
set SUBSTATUS_FLINCHED, [hl]
|
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
|
|
|
; 36af3
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_OHKO: ; 36af3
|
2013-03-26 22:52:04 -07:00
|
|
|
; ohko
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetDamage
|
|
|
|
ld a, [TypeModifier]
|
|
|
|
and $7f
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .no_effect
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonLevel
|
|
|
|
ld de, BattleMonLevel
|
2014-06-12 18:32:42 -07:00
|
|
|
ld bc, wPlayerMoveStruct + MOVE_ACC
|
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_accuracy
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
|
|
|
pop de
|
2014-06-12 18:32:42 -07:00
|
|
|
ld bc, wEnemyMoveStruct + MOVE_ACC
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_move_accuracy
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
sub [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr c, .no_effect
|
2013-03-26 17:39:44 -07:00
|
|
|
add a
|
|
|
|
ld e, a
|
|
|
|
ld a, [bc]
|
|
|
|
add e
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .finish_ohko
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $ff
|
2015-12-26 15:11:55 -08:00
|
|
|
.finish_ohko
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [bc], a
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_CheckHit
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ld a, $2
|
|
|
|
ld [CriticalHit], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.no_effect
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $ff
|
|
|
|
ld [CriticalHit], a
|
|
|
|
ld a, $1
|
|
|
|
ld [AttackMissed], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36b3a
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_CheckCharge: ; 36b3a
|
2013-03-26 22:52:04 -07:00
|
|
|
; checkcharge
|
|
|
|
|
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
|
|
|
bit SUBSTATUS_CHARGED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_CHARGED, [hl]
|
|
|
|
res SUBSTATUS_UNDERGROUND, [hl]
|
|
|
|
res SUBSTATUS_FLYING, [hl]
|
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
|
|
|
; 36b4d
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Charge: ; 36b4d
|
2013-03-26 22:52:04 -07:00
|
|
|
; charge
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_ClearText
|
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-13 21:18:14 -07:00
|
|
|
and SLP
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .awake
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2013-03-27 15:50:10 -07:00
|
|
|
call PrintButItFailed
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.awake
|
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
|
|
|
set SUBSTATUS_CHARGED, [hl]
|
2013-03-27 14:07:00 -07:00
|
|
|
|
|
|
|
ld hl, IgnoredOrders2Text
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AlreadyDisobeyed]
|
|
|
|
and a
|
2013-08-31 00:54:02 -07:00
|
|
|
call nz, StdBattleTextBox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
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
|
|
|
inc a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2015-11-09 13:41:09 -08:00
|
|
|
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
|
2014-06-13 21:18:14 -07:00
|
|
|
cp FLY
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .flying
|
2014-06-13 21:18:14 -07:00
|
|
|
cp DIG
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .flying
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2015-11-09 13:41:09 -08:00
|
|
|
jr .not_flying
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.flying
|
|
|
|
call DisappearUser
|
|
|
|
.not_flying
|
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, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2014-06-13 21:18:14 -07:00
|
|
|
cp FLY
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .set_flying
|
2014-06-13 21:18:14 -07:00
|
|
|
cp DIG
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .dont_set_digging
|
2014-06-13 21:18:14 -07:00
|
|
|
set SUBSTATUS_UNDERGROUND, [hl]
|
2015-11-09 13:41:09 -08:00
|
|
|
jr .dont_set_digging
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.set_flying
|
2014-06-13 21:18:14 -07:00
|
|
|
set SUBSTATUS_FLYING, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.dont_set_digging
|
|
|
|
call CheckUserIsCharging
|
|
|
|
jr nz, .mimic
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], b
|
|
|
|
ld a, BATTLE_VARS_LAST_MOVE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], b
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.mimic
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetDamage
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
ld hl, .UsedText
|
2013-03-26 17:39:44 -07:00
|
|
|
call BattleTextBox
|
|
|
|
|
|
|
|
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_SKULL_BASH
|
2015-04-13 21:39:54 -07:00
|
|
|
ld b, endturn_command
|
2013-03-26 22:52:04 -07:00
|
|
|
jp z, SkipToBattleCommand
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.UsedText:
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0d0e ; "[USER]"
|
2013-03-26 17:39:44 -07:00
|
|
|
start_asm
|
|
|
|
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 RAZOR_WIND
|
|
|
|
ld hl, .RazorWind
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp SOLARBEAM
|
|
|
|
ld hl, .Solarbeam
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp SKULL_BASH
|
|
|
|
ld hl, .SkullBash
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp SKY_ATTACK
|
|
|
|
ld hl, .SkyAttack
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp FLY
|
|
|
|
ld hl, .Fly
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp DIG
|
|
|
|
ld hl, .Dig
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.done
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.RazorWind:
|
2013-03-26 17:39:44 -07:00
|
|
|
; 'made a whirlwind!'
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0d12
|
2013-03-26 17:39:44 -07:00
|
|
|
db "@"
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Solarbeam:
|
2013-03-26 17:39:44 -07:00
|
|
|
; 'took in sunlight!'
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0d26
|
2013-03-26 17:39:44 -07:00
|
|
|
db "@"
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.SkullBash:
|
2013-03-26 17:39:44 -07:00
|
|
|
; 'lowered its head!'
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0d3a
|
2013-03-26 17:39:44 -07:00
|
|
|
db "@"
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.SkyAttack:
|
2013-03-26 17:39:44 -07:00
|
|
|
; 'is glowing!'
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0d4e
|
2013-03-26 17:39:44 -07:00
|
|
|
db "@"
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Fly:
|
2013-03-26 17:39:44 -07:00
|
|
|
; 'flew up high!'
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0d5c
|
2013-03-26 17:39:44 -07:00
|
|
|
db "@"
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Dig:
|
2013-03-26 17:39:44 -07:00
|
|
|
; 'dug a hole!'
|
2015-07-22 12:57:02 -07:00
|
|
|
text_jump UnknownText_0x1c0d6c
|
2013-03-26 17:39:44 -07:00
|
|
|
db "@"
|
|
|
|
; 36c2c
|
|
|
|
|
|
|
|
|
|
|
|
BattleCommand3c: ; 36c2c
|
|
|
|
; unused
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36c2d
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_TrapTarget: ; 36c2d
|
2013-03-26 22:52:04 -07:00
|
|
|
; traptarget
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
|
|
|
ret nz
|
2015-11-08 10:27:26 -08:00
|
|
|
ld hl, wEnemyWrapCount
|
|
|
|
ld de, wEnemyTrappingMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_trap
|
2015-11-08 10:27:26 -08:00
|
|
|
ld hl, wPlayerWrapCount
|
|
|
|
ld de, wPlayerTrappingMove
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_trap
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and 3
|
|
|
|
inc a
|
2016-05-10 09:31:49 -07:00
|
|
|
inc a
|
|
|
|
inc a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
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], a
|
|
|
|
ld b, a
|
|
|
|
ld hl, .Traps
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.find_trap_text
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .found_trap_text
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
inc hl
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .find_trap_text
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.found_trap_text
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
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
|
|
|
.Traps:
|
2013-03-26 17:39:44 -07:00
|
|
|
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-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Mist: ; 36c7e
|
2013-03-26 22:52:04 -07:00
|
|
|
; mist
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_MIST, [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .already_mist
|
2014-06-13 21:18:14 -07:00
|
|
|
set SUBSTATUS_MIST, [hl]
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, MistText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.already_mist
|
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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36c98
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_FocusEnergy: ; 36c98
|
2013-03-26 22:52:04 -07:00
|
|
|
; focusenergy
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_FOCUS_ENERGY, [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .already_pumped
|
2014-06-13 21:18:14 -07:00
|
|
|
set SUBSTATUS_FOCUS_ENERGY, [hl]
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, GettingPumpedText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.already_pumped
|
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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36cb2
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Recoil: ; 36cb2
|
2013-03-26 22:52:04 -07:00
|
|
|
; recoil
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonMaxHP
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_hp
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonMaxHP
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_hp
|
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 d, a
|
2015-12-26 15:11:55 -08:00
|
|
|
; get 1/4 damage or 1 HP, whichever is higher
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CurDamage]
|
|
|
|
ld b, a
|
|
|
|
ld a, [CurDamage + 1]
|
|
|
|
ld c, a
|
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
ld a, b
|
|
|
|
or c
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .min_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
inc c
|
2015-12-26 15:11:55 -08:00
|
|
|
.min_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [Buffer1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
dec hl
|
2015-12-26 18:59:03 -08:00
|
|
|
dec hl
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer3], a
|
2013-03-26 17:39:44 -07:00
|
|
|
sub c
|
|
|
|
ld [hld], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer5], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer4], a
|
2013-03-26 17:39:44 -07:00
|
|
|
sbc b
|
|
|
|
ld [hl], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer6], a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .dont_ko
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld hl, Buffer5
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2015-12-26 15:11:55 -08:00
|
|
|
.dont_ko
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 10, 9
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
ld a, 1
|
|
|
|
jr z, .animate_hp_bar
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 2, 2
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-26 15:11:55 -08:00
|
|
|
.animate_hp_bar
|
|
|
|
ld [wWhichHPBar], a
|
2015-11-07 05:05:57 -08:00
|
|
|
predef AnimateHPBar
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, RecoilText
|
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
|
|
|
; 36d1d
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_ConfuseTarget: ; 36d1d
|
2013-03-26 22:52:04 -07:00
|
|
|
; confusetarget
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
cp HELD_PREVENT_CONFUSE
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-06-13 13:10:39 -07:00
|
|
|
ld a, [EffectFailed]
|
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
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_CONFUSED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2015-12-26 15:11:55 -08:00
|
|
|
jr BattleCommand_FinishConfusingTarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Confuse: ; 36d3b
|
2013-03-26 22:52:04 -07:00
|
|
|
; confuse
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
cp HELD_PREVENT_CONFUSE
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .no_item_protection
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-05-02 22:29:57 -07:00
|
|
|
call GetItemName
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, ProtectedByText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.no_item_protection
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_CONFUSED, [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .not_already_confused
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, AlreadyConfusedText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.not_already_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit
|
|
|
|
BattleCommand_FinishConfusingTarget: ; 36d70
|
2013-04-27 14:12:23 -07:00
|
|
|
ld bc, EnemyConfuseCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_confuse_count
|
2013-03-26 17:39:44 -07:00
|
|
|
ld bc, PlayerConfuseCount
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_confuse_count
|
2014-06-13 21:18:14 -07:00
|
|
|
set SUBSTATUS_CONFUSED, [hl]
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-04-27 14:12:23 -07:00
|
|
|
and 3
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-12-26 18:59:03 -08:00
|
|
|
inc a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [bc], a
|
2013-04-27 14:12:23 -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-27 14:12:23 -07:00
|
|
|
cp EFFECT_CONFUSE_HIT
|
2015-11-28 12:13:40 -08:00
|
|
|
jr z, .got_effect
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_SNORE
|
2015-11-28 12:13:40 -08:00
|
|
|
jr z, .got_effect
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_SWAGGER
|
2015-11-28 12:13:40 -08:00
|
|
|
jr z, .got_effect
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2015-11-28 12:13:40 -08:00
|
|
|
.got_effect
|
2014-06-13 21:18:14 -07:00
|
|
|
ld de, ANIM_CONFUSED
|
2015-11-06 17:55:16 -08:00
|
|
|
call PlayOpponentBattleAnim
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BecameConfusedText
|
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
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
cp HELD_HEAL_STATUS
|
2015-11-28 12:13:40 -08:00
|
|
|
jr z, .heal_confusion
|
2014-06-13 21:18:14 -07:00
|
|
|
cp HELD_HEAL_CONFUSION
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2015-11-28 12:13:40 -08:00
|
|
|
.heal_confusion
|
|
|
|
ld hl, UseConfusionHealingItem
|
2013-12-31 00:25:38 -08:00
|
|
|
jp CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36db6
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit: ; 36db6
|
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_CONFUSE_HIT
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_SNORE
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_SWAGGER
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
jp PrintDidntAffect2
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36dc7
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Paralyze: ; 36dc7
|
2013-03-26 22:52:04 -07:00
|
|
|
; paralyze
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
bit PAR, a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .paralyzed
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [TypeModifier]
|
|
|
|
and $7f
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .didnt_affect
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
cp HELD_PREVENT_PARALYZE
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .no_item_protection
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-05-02 22:29:57 -07:00
|
|
|
call GetItemName
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, ProtectedByText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.no_item_protection
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .dont_sample_failure
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .dont_sample_failure
|
2015-09-04 13:30:40 -07:00
|
|
|
|
|
|
|
ld a, [InBattleTowerBattle]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .dont_sample_failure
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [PlayerSubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .dont_sample_failure
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2015-12-26 15:11:55 -08:00
|
|
|
cp 1 + 25 percent
|
|
|
|
jr c, .failed
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.dont_sample_failure
|
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
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .failed
|
2014-06-13 21:18:14 -07:00
|
|
|
ld c, 30
|
2013-03-26 17:39:44 -07:00
|
|
|
call DelayFrames
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hBGMapMode], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
set PAR, [hl]
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateOpponentInParty
|
2015-11-06 17:55:16 -08:00
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateBattleHuds
|
2013-03-26 17:39:44 -07:00
|
|
|
call PrintParalyze
|
2015-11-06 19:36:06 -08:00
|
|
|
ld hl, UseHeldStatusHealingItem
|
2013-12-31 00:25:38 -08:00
|
|
|
jp CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.paralyzed
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, AlreadyParalyzedText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.failed
|
2013-03-26 17:39:44 -07:00
|
|
|
jp PrintDidntAffect2
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.didnt_affect
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
jp PrintDoesntAffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36e5b
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
CheckMoveTypeMatchesTarget: ; 36e5b
|
2014-06-13 21:18:14 -07:00
|
|
|
; Compare move type to opponent type.
|
|
|
|
; Return z if matching the opponent type,
|
|
|
|
; unless the move is Normal (Tri Attack).
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
push hl
|
|
|
|
|
|
|
|
ld hl, EnemyMonType1
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .ok
|
|
|
|
ld hl, BattleMonType1
|
|
|
|
.ok
|
|
|
|
|
|
|
|
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 NORMAL
|
|
|
|
jr z, .normal
|
|
|
|
|
|
|
|
cp [hl]
|
|
|
|
jr z, .return
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
cp [hl]
|
|
|
|
|
|
|
|
.return
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
|
|
|
.normal
|
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36e7c
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Substitute: ; 36e7c
|
2013-03-26 22:52:04 -07:00
|
|
|
; substitute
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonMaxHP
|
2014-06-10 23:08:07 -07:00
|
|
|
ld de, PlayerSubstituteHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .got_hp
|
|
|
|
ld hl, EnemyMonMaxHP
|
|
|
|
ld de, EnemySubstituteHP
|
|
|
|
.got_hp
|
|
|
|
|
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-10 23:08:07 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr nz, .already_has_sub
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, [hl]
|
|
|
|
srl a
|
|
|
|
rr b
|
|
|
|
srl a
|
|
|
|
rr b
|
|
|
|
dec hl
|
2015-12-26 18:59:03 -08:00
|
|
|
dec hl
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
ld [de], a
|
|
|
|
ld a, [hld]
|
|
|
|
sub b
|
|
|
|
ld e, a
|
|
|
|
ld a, [hl]
|
2014-06-10 23:08:07 -07:00
|
|
|
sbc 0
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr c, .too_weak_to_sub
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, d
|
|
|
|
or e
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .too_weak_to_sub
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], d
|
|
|
|
inc hl
|
|
|
|
ld [hl], e
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
set SUBSTATUS_SUBSTITUTE, [hl]
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
ld hl, wPlayerWrapCount
|
|
|
|
ld de, wPlayerTrappingMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .player
|
2015-11-08 10:27:26 -08:00
|
|
|
ld hl, wEnemyWrapCount
|
|
|
|
ld de, wEnemyTrappingMove
|
2015-11-06 17:55:16 -08:00
|
|
|
.player
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
ld [de], a
|
2015-11-06 19:36:06 -08:00
|
|
|
call _CheckBattleScene
|
2016-03-27 09:47:28 -07:00
|
|
|
jr c, .no_anim
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID + 1], a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, SUBSTITUTE
|
2015-11-09 13:41:09 -08:00
|
|
|
call LoadAnim
|
2015-11-06 17:55:16 -08:00
|
|
|
jr .finish
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2016-03-27 09:47:28 -07:00
|
|
|
.no_anim
|
2015-11-06 19:36:06 -08:00
|
|
|
call BattleCommand_RaiseSubNoAnim
|
2015-11-06 17:55:16 -08:00
|
|
|
.finish
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, MadeSubstituteText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-05-02 21:22:28 -07:00
|
|
|
jp RefreshBattleHuds
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.already_has_sub
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckUserIsCharging
|
2015-11-06 13:42:38 -08:00
|
|
|
call nz, BattleCommand_RaiseSub
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, HasSubstituteText
|
2015-11-06 17:55:16 -08:00
|
|
|
jr .jp_stdbattletextbox
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.too_weak_to_sub
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckUserIsCharging
|
2015-11-06 13:42:38 -08:00
|
|
|
call nz, BattleCommand_RaiseSub
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, TooWeakSubText
|
2015-11-06 17:55:16 -08:00
|
|
|
.jp_stdbattletextbox
|
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
|
|
|
; 36f0b
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_RechargeNextTurn: ; 36f0b
|
2013-03-26 22:52:04 -07:00
|
|
|
; rechargenextturn
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
set SUBSTATUS_RECHARGE, [hl]
|
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
|
|
|
; 36f13
|
|
|
|
|
|
|
|
|
|
|
|
EndRechargeOpp: ; 36f13
|
|
|
|
push hl
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
res SUBSTATUS_RECHARGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36f1d
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Rage: ; 36f1d
|
2013-03-26 22:52:04 -07:00
|
|
|
; rage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
set SUBSTATUS_RAGE, [hl]
|
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
|
|
|
; 36f25
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DoubleFlyingDamage: ; 36f25
|
2013-03-26 22:52:04 -07:00
|
|
|
; doubleflyingdamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-07-29 10:58:20 -07:00
|
|
|
bit SUBSTATUS_FLYING, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-03-26 22:52:04 -07:00
|
|
|
jr DoubleDamage
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36f2f
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_DoubleUndergroundDamage: ; 36f2f
|
2013-03-26 22:52:04 -07:00
|
|
|
; doubleundergrounddamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-07-29 10:58:20 -07:00
|
|
|
bit SUBSTATUS_UNDERGROUND, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 36f37
|
|
|
|
|
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
DoubleDamage: ; 36f37
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage + 1
|
|
|
|
sla [hl]
|
|
|
|
dec hl
|
|
|
|
rl [hl]
|
|
|
|
jr nc, .quit
|
|
|
|
|
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
.quit
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36f46
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Mimic: ; 36f46
|
2013-03-26 22:52:04 -07:00
|
|
|
; mimic
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call ClearLastMove
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonMoves
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .player_turn
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonMoves
|
2015-11-09 13:41:09 -08:00
|
|
|
.player_turn
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckHiddenOpponent
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fail
|
2014-06-10 23:08:07 -07:00
|
|
|
cp STRUGGLE
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld c, NUM_MOVES
|
2015-11-09 13:41:09 -08:00
|
|
|
.check_already_knows_move
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
dec c
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .check_already_knows_move
|
2013-03-26 17:39:44 -07:00
|
|
|
dec hl
|
2015-11-09 13:41:09 -08:00
|
|
|
.find_mimic
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2014-06-10 23:08:07 -07:00
|
|
|
cp MIMIC
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .find_mimic
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld bc, BattleMonPP - BattleMonMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [hl], 5
|
2013-05-02 23:43:44 -07:00
|
|
|
call GetMoveName
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, LearnedMoveText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-11-09 13:41:09 -08:00
|
|
|
|
|
|
|
.fail
|
|
|
|
jp FailMimic
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36f9d
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_LeechSeed: ; 36f9d
|
2013-03-26 17:39:44 -07:00
|
|
|
; leechseed
|
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2014-06-10 23:08:07 -07:00
|
|
|
jr nz, .evaded
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2014-06-10 23:08:07 -07:00
|
|
|
jr nz, .evaded
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, EnemyMonType1
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, BattleMonType1
|
2014-06-10 23:08:07 -07:00
|
|
|
.ok
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
2014-06-10 23:08:07 -07:00
|
|
|
cp GRASS
|
|
|
|
jr z, .grass
|
2013-03-26 17:39:44 -07:00
|
|
|
inc de
|
|
|
|
ld a, [de]
|
2014-06-10 23:08:07 -07:00
|
|
|
cp GRASS
|
|
|
|
jr z, .grass
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SUBSTATUS_LEECH_SEED, [hl]
|
|
|
|
jr nz, .evaded
|
|
|
|
set SUBSTATUS_LEECH_SEED, [hl]
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, WasSeededText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
.grass
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
jp PrintDoesntAffect
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
.evaded
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EvadedText
|
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
|
|
|
; 36fe1
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Splash: ; 36fe1
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall TrainerRankings_Splash
|
2013-03-26 17:39:44 -07:00
|
|
|
jp PrintNothingHappened
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 36fed
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Disable: ; 36fed
|
2013-03-26 17:39:44 -07:00
|
|
|
; disable
|
|
|
|
|
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .failed
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-05-02 22:29:57 -07:00
|
|
|
ld de, EnemyDisableCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonMoves
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_moves
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, PlayerDisableCount
|
|
|
|
ld hl, BattleMonMoves
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_moves
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .failed
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .failed
|
2014-06-10 23:08:07 -07:00
|
|
|
cp STRUGGLE
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .failed
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld c, $ff
|
2015-12-26 15:11:55 -08:00
|
|
|
.loop
|
2013-03-26 17:39:44 -07:00
|
|
|
inc c
|
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .loop
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonPP
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_pp
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonPP
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_pp
|
2014-06-10 23:08:07 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .failed
|
|
|
|
.loop2
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2014-06-10 23:08:07 -07:00
|
|
|
and 7
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .loop2
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
|
|
|
inc c
|
|
|
|
swap c
|
|
|
|
add c
|
|
|
|
ld [de], a
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, DisabledMove
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .got_disabled_move_pointer
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_disabled_move_pointer
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
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, WasDisabledText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.failed
|
2015-11-09 13:41:09 -08:00
|
|
|
jp FailDisable
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3705c
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_PayDay: ; 3705c
|
2013-03-26 22:52:04 -07:00
|
|
|
; payday
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld hl, StringBuffer1
|
|
|
|
ld [hli], a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
ld a, [BattleMonLevel]
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [EnemyMonLevel]
|
2014-06-10 23:08:07 -07:00
|
|
|
.ok
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
add a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld hl, wPayDayMoney + 2
|
2013-03-26 17:39:44 -07:00
|
|
|
add [hl]
|
|
|
|
ld [hld], a
|
2014-06-10 23:08:07 -07:00
|
|
|
jr nc, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
inc [hl]
|
|
|
|
dec hl
|
2014-06-10 23:08:07 -07:00
|
|
|
jr nz, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
inc [hl]
|
2014-06-10 23:08:07 -07:00
|
|
|
.done
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CoinsScatteredText
|
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
|
|
|
; 3707f
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Conversion: ; 3707f
|
2013-03-26 22:52:04 -07:00
|
|
|
; conversion
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BattleMonMoves
|
|
|
|
ld de, BattleMonType1
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_moves
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonMoves
|
|
|
|
ld de, EnemyMonType1
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_moves
|
2013-03-26 17:39:44 -07:00
|
|
|
push de
|
2014-06-13 21:18:14 -07:00
|
|
|
ld c, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, StringBuffer1
|
2015-12-26 15:11:55 -08:00
|
|
|
.loop
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
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]
|
|
|
|
pop hl
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .okay
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
dec a
|
2014-06-10 23:23:55 -07:00
|
|
|
ld hl, Moves + MOVE_TYPE
|
2013-03-27 13:19:51 -07:00
|
|
|
call GetMoveAttr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
inc c
|
|
|
|
ld a, c
|
2014-06-10 23:08:07 -07:00
|
|
|
cp NUM_MOVES
|
2015-12-26 15:11:55 -08:00
|
|
|
jr c, .loop
|
|
|
|
.okay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $ff
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
|
|
|
pop de
|
|
|
|
ld hl, StringBuffer1
|
2015-12-26 15:11:55 -08:00
|
|
|
.loop2
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
cp -1
|
|
|
|
jr z, .fail
|
2014-06-10 23:08:07 -07:00
|
|
|
cp CURSE_T
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .next
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
cp [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .next
|
2013-03-26 17:39:44 -07:00
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
dec de
|
|
|
|
cp [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .done
|
|
|
|
.next
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .loop2
|
|
|
|
|
|
|
|
.fail
|
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
|
|
|
|
|
|
|
.done
|
|
|
|
.loop3
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2014-06-10 23:08:07 -07:00
|
|
|
and 3 ; TODO factor in NUM_MOVES
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, StringBuffer1
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
cp -1
|
|
|
|
jr z, .loop3
|
2014-06-10 23:08:07 -07:00
|
|
|
cp CURSE_T
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .loop3
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
cp [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .loop3
|
2013-03-26 17:39:44 -07:00
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
dec de
|
|
|
|
cp [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .loop3
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall GetTypeName
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, TransformedTypeText
|
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
|
|
|
; 3710e
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_ResetStats: ; 3710e
|
2013-03-26 17:39:44 -07:00
|
|
|
; resetstats
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 7 ; neutral
|
|
|
|
ld hl, PlayerStatLevels
|
|
|
|
call .Fill
|
|
|
|
ld hl, EnemyStatLevels
|
|
|
|
call .Fill
|
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
push af
|
|
|
|
|
|
|
|
call SetPlayerTurn
|
2015-11-06 17:55:16 -08:00
|
|
|
call CalcPlayerStats
|
2013-03-26 17:39:44 -07:00
|
|
|
call SetEnemyTurn
|
2015-11-06 17:55:16 -08:00
|
|
|
call CalcEnemyStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
pop af
|
|
|
|
ld [hBattleTurn], a
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, EliminatedStatsText
|
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
|
|
|
.Fill:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, PlayerStatLevelsEnd - PlayerStatLevels
|
2014-06-10 23:08:07 -07:00
|
|
|
.next
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
|
|
|
dec b
|
2014-06-10 23:08:07 -07:00
|
|
|
jr nz, .next
|
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
|
|
|
; 3713e
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Heal: ; 3713e
|
2013-03-26 22:52:04 -07:00
|
|
|
; heal
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, BattleMonHP
|
|
|
|
ld hl, BattleMonMaxHP
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_hp
|
2014-06-10 23:08:07 -07:00
|
|
|
ld de, EnemyMonHP
|
|
|
|
ld hl, EnemyMonMaxHP
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_hp
|
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 b, a
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2014-06-10 23:08:07 -07:00
|
|
|
ld c, 2
|
2013-03-26 17:39:44 -07:00
|
|
|
call StringCmp
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2015-12-26 15:11:55 -08:00
|
|
|
jp z, .hp_full
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
2014-06-10 23:08:07 -07:00
|
|
|
cp REST
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .not_rest
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push af
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
res SUBSTATUS_TOXIC, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2017-12-25 10:40:10 -08:00
|
|
|
ld [hl], REST_SLEEP_TURNS + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, WentToSleepText
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .no_status_to_heal
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, RestedText
|
2015-12-26 15:11:55 -08:00
|
|
|
.no_status_to_heal
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .calc_enemy_stats
|
2015-11-06 17:55:16 -08:00
|
|
|
call CalcPlayerStats
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .got_stats
|
|
|
|
|
|
|
|
.calc_enemy_stats
|
2015-11-06 17:55:16 -08:00
|
|
|
call CalcEnemyStats
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_stats
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
|
|
|
pop de
|
|
|
|
pop hl
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.not_rest
|
|
|
|
jr z, .restore_full_hp
|
2013-12-31 01:09:00 -08:00
|
|
|
ld hl, GetHalfMaxHP
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .finish
|
|
|
|
|
|
|
|
.restore_full_hp
|
2013-12-31 01:09:00 -08:00
|
|
|
ld hl, GetMaxHP
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
.finish
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2015-11-06 19:36:06 -08:00
|
|
|
ld hl, RestoreHP
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateUserInParty
|
|
|
|
call RefreshBattleHuds
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, RegainedHealthText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.hp_full
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, HPIsFullText
|
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
|
|
|
; 371cd
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
INCLUDE "battle/effects/transform.asm"
|
2013-03-26 17:39:44 -07: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.
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .copy
|
|
|
|
|
|
|
|
; Swap hl and de
|
|
|
|
push hl
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
|
|
|
pop de
|
|
|
|
.copy
|
|
|
|
jp CopyBytes
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 372d2
|
|
|
|
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
BattleEffect_ButItFailed: ; 372d2
|
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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 372d8
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
ClearLastMove: ; 372d8
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_LAST_MOVE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
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
|
|
|
; 372e7
|
|
|
|
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
ResetActorDisable: ; 372e7
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .player
|
|
|
|
|
|
|
|
xor a
|
2013-05-02 22:29:57 -07:00
|
|
|
ld [EnemyDisableCount], a
|
2013-05-03 18:04:34 -07:00
|
|
|
ld [EnemyDisabledMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.player
|
|
|
|
xor a
|
|
|
|
ld [PlayerDisableCount], a
|
|
|
|
ld [DisabledMove], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 372fc
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Screen: ; 372fc
|
2013-03-26 22:52:04 -07:00
|
|
|
; screen
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerScreens
|
|
|
|
ld bc, PlayerLightScreenCount
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_screens_pointer
|
2013-04-19 23:57:11 -07:00
|
|
|
ld hl, EnemyScreens
|
2013-04-27 14:12:23 -07:00
|
|
|
ld bc, EnemyLightScreenCount
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_screens_pointer
|
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_LIGHT_SCREEN
|
|
|
|
jr nz, .Reflect
|
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SCREENS_LIGHT_SCREEN, [hl]
|
|
|
|
jr nz, .failed
|
|
|
|
set SCREENS_LIGHT_SCREEN, [hl]
|
|
|
|
ld a, 5
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [bc], a
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, LightScreenEffectText
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .good
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Reflect:
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SCREENS_REFLECT, [hl]
|
|
|
|
jr nz, .failed
|
|
|
|
set SCREENS_REFLECT, [hl]
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; LightScreenCount -> ReflectCount
|
2013-03-26 17:39:44 -07:00
|
|
|
inc bc
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, 5
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [bc], a
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, ReflectEffectText
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.good
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-03-27 14:07:00 -07: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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3733d
|
|
|
|
|
|
|
|
|
|
|
|
PrintDoesntAffect: ; 3733d
|
|
|
|
; 'it doesn't affect'
|
|
|
|
ld hl, DoesntAffectText
|
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
|
|
|
; 37343
|
|
|
|
|
|
|
|
|
|
|
|
PrintNothingHappened: ; 37343
|
|
|
|
; 'but nothing happened!'
|
|
|
|
ld hl, NothingHappenedText
|
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
|
|
|
; 37349
|
|
|
|
|
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
TryPrintButItFailed: ; 37349
|
|
|
|
ld a, [AlreadyFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; fallthrough
|
|
|
|
; 3734e
|
|
|
|
|
|
|
|
|
|
|
|
PrintButItFailed: ; 3734e
|
2013-03-26 17:39:44 -07:00
|
|
|
; 'but it failed!'
|
|
|
|
ld hl, ButItFailedText
|
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
|
|
|
; 37354
|
|
|
|
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
FailSnore:
|
|
|
|
FailDisable:
|
|
|
|
FailConversion2:
|
|
|
|
FailAttract:
|
|
|
|
FailForesight:
|
|
|
|
FailSpikes:
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-27 15:50:10 -07:00
|
|
|
; fallthrough
|
|
|
|
; 37357
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
FailMimic: ; 37357
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, ButItFailedText ; 'but it failed!'
|
|
|
|
ld de, ItFailedText ; 'it failed!'
|
2015-11-09 13:41:09 -08:00
|
|
|
jp FailText_CheckOpponentProtect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37360
|
|
|
|
|
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
PrintDidntAffect: ; 37360
|
2013-03-26 17:39:44 -07:00
|
|
|
; 'it didn't affect'
|
|
|
|
ld hl, DidntAffect1Text
|
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
|
|
|
; 37366
|
|
|
|
|
|
|
|
|
|
|
|
PrintDidntAffect2: ; 37366
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, DidntAffect1Text ; 'it didn't affect'
|
|
|
|
ld de, DidntAffect2Text ; 'it didn't affect'
|
2015-11-09 13:41:09 -08:00
|
|
|
jp FailText_CheckOpponentProtect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37372
|
|
|
|
|
|
|
|
|
|
|
|
PrintParalyze: ; 37372
|
|
|
|
; 'paralyzed! maybe it can't attack!'
|
|
|
|
ld hl, ParalyzedText
|
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
|
|
|
; 37378
|
|
|
|
|
|
|
|
|
|
|
|
CheckSubstituteOpp: ; 37378
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, 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
|
|
|
; 37380
|
|
|
|
|
|
|
|
|
2017-11-18 08:28:12 -08:00
|
|
|
BattleCommand_Selfdestruct: ; 37380
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall TrainerRankings_Selfdestruct
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_PLAYER_DAMAGE
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld c, 3
|
2013-03-26 17:39:44 -07:00
|
|
|
call DelayFrames
|
|
|
|
ld a, BATTLE_VARS_STATUS
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
inc hl
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ld a, $1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2015-11-09 13:41:09 -08:00
|
|
|
call LoadMoveAnim
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
res SUBSTATUS_LEECH_SEED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
res SUBSTATUS_DESTINY_BOND, [hl]
|
2015-11-06 19:36:06 -08:00
|
|
|
call _CheckBattleScene
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DrawPlayerHUD
|
|
|
|
farcall DrawEnemyHUD
|
2013-12-01 11:19:57 -08:00
|
|
|
call WaitBGMap
|
2013-05-02 21:22:28 -07:00
|
|
|
jp RefreshBattleHuds
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 373c9
|
|
|
|
|
|
|
|
|
2013-12-01 11:19:57 -08:00
|
|
|
INCLUDE "battle/effects/mirror_move.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-12-01 11:19:57 -08:00
|
|
|
INCLUDE "battle/effects/metronome.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
CheckUserMove: ; 37462
|
|
|
|
; Return z if the user has move a.
|
|
|
|
ld b, a
|
|
|
|
ld de, BattleMonMoves
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .ok
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
.ok
|
|
|
|
|
|
|
|
ld c, NUM_MOVES
|
|
|
|
.loop
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
cp b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 3747b
|
|
|
|
|
|
|
|
|
|
|
|
ResetTurn: ; 3747b
|
2015-11-07 18:04:54 -08:00
|
|
|
ld hl, wPlayerCharging
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .player
|
2015-11-07 18:04:54 -08:00
|
|
|
ld hl, wEnemyCharging
|
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 [hl], 1
|
|
|
|
xor a
|
|
|
|
ld [AlreadyDisobeyed], a
|
2013-03-27 15:50:10 -07:00
|
|
|
call DoMove
|
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37492
|
|
|
|
|
|
|
|
|
2013-12-01 11:19:57 -08:00
|
|
|
INCLUDE "battle/effects/thief.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_ArenaTrap: ; 37517
|
2013-03-26 17:39:44 -07:00
|
|
|
; arenatrap
|
2013-09-08 19:44:20 -07:00
|
|
|
|
|
|
|
; Doesn't work on an absent opponent.
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckHiddenOpponent
|
2013-09-08 19:44:20 -07:00
|
|
|
jr nz, .failed
|
|
|
|
|
|
|
|
; Don't trap if the opponent is already trapped.
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-09-08 19:44:20 -07:00
|
|
|
bit SUBSTATUS_CANT_RUN, [hl]
|
|
|
|
jr nz, .failed
|
|
|
|
|
|
|
|
; Otherwise trap the opponent.
|
|
|
|
|
|
|
|
set SUBSTATUS_CANT_RUN, [hl]
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CantEscapeNowText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2013-09-08 19:44:20 -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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37536
|
|
|
|
|
|
|
|
|
2013-12-01 11:19:57 -08:00
|
|
|
INCLUDE "battle/effects/nightmare.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Defrost: ; 37563
|
2013-03-26 17:39:44 -07:00
|
|
|
; defrost
|
|
|
|
|
2013-09-08 19:30:10 -07:00
|
|
|
; Thaw the user.
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-09-08 19:30:10 -07:00
|
|
|
bit FRZ, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-09-08 19:30:10 -07:00
|
|
|
res FRZ, [hl]
|
|
|
|
|
|
|
|
; Don't update the enemy's party struct in a wild battle.
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2013-09-08 19:30:10 -07:00
|
|
|
jr z, .party
|
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2013-09-08 19:30:10 -07:00
|
|
|
jr z, .done
|
|
|
|
|
|
|
|
.party
|
2015-11-04 08:19:58 -08:00
|
|
|
ld a, MON_STATUS
|
2013-05-02 23:43:44 -07:00
|
|
|
call UserPartyAttr
|
2013-09-08 19:30:10 -07:00
|
|
|
res FRZ, [hl]
|
|
|
|
|
|
|
|
.done
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, WasDefrostedText
|
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
|
|
|
; 37588
|
|
|
|
|
|
|
|
|
2013-09-09 15:43:22 -07:00
|
|
|
INCLUDE "battle/effects/curse.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-09-09 18:51:41 -07:00
|
|
|
INCLUDE "battle/effects/protect.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-09-09 18:51:41 -07:00
|
|
|
INCLUDE "battle/effects/endure.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-09-09 19:02:26 -07:00
|
|
|
INCLUDE "battle/effects/spikes.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-12-01 11:19:57 -08:00
|
|
|
INCLUDE "battle/effects/foresight.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-12-01 11:19:57 -08:00
|
|
|
INCLUDE "battle/effects/perish_song.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-12-01 11:19:57 -08:00
|
|
|
INCLUDE "battle/effects/sandstorm.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-12-01 11:19:57 -08:00
|
|
|
INCLUDE "battle/effects/rollout.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
BattleCommand5d: ; 37791
|
|
|
|
; unused
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37792
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_FuryCutter: ; 37792
|
2013-03-26 17:39:44 -07:00
|
|
|
; furycutter
|
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
ld hl, PlayerFuryCutterCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2013-04-19 00:50:45 -07:00
|
|
|
jr z, .go
|
|
|
|
ld hl, EnemyFuryCutterCount
|
|
|
|
|
|
|
|
.go
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2013-04-19 00:50:45 -07:00
|
|
|
jp nz, ResetFuryCutterCount
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
inc [hl]
|
2013-04-19 00:50:45 -07:00
|
|
|
|
|
|
|
; Damage capped at 5 turns' worth (16x).
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld b, a
|
2013-04-19 00:50:45 -07:00
|
|
|
cp 6
|
|
|
|
jr c, .checkdouble
|
|
|
|
ld b, 5
|
|
|
|
|
|
|
|
.checkdouble
|
2013-03-26 17:39:44 -07:00
|
|
|
dec b
|
|
|
|
ret z
|
2013-04-19 00:50:45 -07:00
|
|
|
|
|
|
|
; Double the damage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage + 1
|
|
|
|
sla [hl]
|
|
|
|
dec hl
|
|
|
|
rl [hl]
|
2013-04-19 00:50:45 -07:00
|
|
|
jr nc, .checkdouble
|
|
|
|
|
|
|
|
; No overflow
|
2013-03-26 17:39:44 -07:00
|
|
|
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
|
|
|
; 377be
|
|
|
|
|
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
ResetFuryCutterCount: ; 377be
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
ld hl, PlayerFuryCutterCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2013-04-19 00:50:45 -07:00
|
|
|
jr z, .reset
|
|
|
|
ld hl, EnemyFuryCutterCount
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
.reset
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 377ce
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
INCLUDE "battle/effects/attract.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_HappinessPower: ; 3784b
|
2013-03-26 22:52:04 -07:00
|
|
|
; happinesspower
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
ld hl, BattleMonHappiness
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonHappiness
|
2014-06-10 23:08:07 -07:00
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 0], a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
|
|
|
ld a, 10
|
|
|
|
ld [hMultiplier], a
|
2013-05-02 23:43:44 -07:00
|
|
|
call Multiply
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, 25
|
|
|
|
ld [hDivisor], a
|
|
|
|
ld b, 4
|
2013-05-02 23:43:44 -07:00
|
|
|
call Divide
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
|
|
|
pop bc
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37874
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
INCLUDE "battle/effects/present.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_FrustrationPower: ; 3790e
|
2013-03-26 22:52:04 -07:00
|
|
|
; frustrationpower
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
push bc
|
|
|
|
ld hl, BattleMonHappiness
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_happiness
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemyMonHappiness
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_happiness
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $ff
|
|
|
|
sub [hl]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
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
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, 10
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplier], a
|
2013-05-02 23:43:44 -07:00
|
|
|
call Multiply
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, 25
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
2014-06-10 23:08:07 -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 + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
|
|
|
pop bc
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37939
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Safeguard: ; 37939
|
2013-03-26 17:39:44 -07:00
|
|
|
; safeguard
|
|
|
|
|
|
|
|
ld hl, PlayerScreens
|
2014-06-10 23:08:07 -07:00
|
|
|
ld de, PlayerSafeguardCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2013-04-19 23:57:11 -07:00
|
|
|
ld hl, EnemyScreens
|
2014-06-10 23:08:07 -07:00
|
|
|
ld de, EnemySafeguardCount
|
|
|
|
.ok
|
|
|
|
bit SCREENS_SAFEGUARD, [hl]
|
|
|
|
jr nz, .failed
|
|
|
|
set SCREENS_SAFEGUARD, [hl]
|
|
|
|
ld a, 5
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [de], a
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CoveredByVeilText
|
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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37962
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
SafeCheckSafeguard: ; 37962
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
2013-04-19 23:57:11 -07:00
|
|
|
ld hl, EnemyScreens
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-06 19:36:06 -08:00
|
|
|
jr z, .got_turn
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerScreens
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.got_turn
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SCREENS_SAFEGUARD, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37972
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_CheckSafeguard: ; 37972
|
2013-03-26 22:52:04 -07:00
|
|
|
; checksafeguard
|
2013-04-19 23:57:11 -07:00
|
|
|
ld hl, EnemyScreens
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_turn
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerScreens
|
2015-11-06 19:36:06 -08:00
|
|
|
.got_turn
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SCREENS_SAFEGUARD, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [AttackMissed], a
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, SafeguardProtectText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
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
|
|
|
; 37991
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_GetMagnitude: ; 37991
|
2013-03-26 17:39:44 -07:00
|
|
|
; getmagnitude
|
|
|
|
|
|
|
|
push bc
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld hl, .Magnitudes
|
2014-06-10 23:08:07 -07:00
|
|
|
.loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2014-06-10 23:08:07 -07:00
|
|
|
jr nc, .ok
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
inc hl
|
2014-06-10 23:08:07 -07:00
|
|
|
jr .loop
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, [hl]
|
|
|
|
push de
|
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, MagnitudeText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Magnitudes:
|
2013-03-26 17:39:44 -07:00
|
|
|
; /255, BP, magnitude
|
|
|
|
db 13, 10, 4
|
|
|
|
db 38, 30, 5
|
|
|
|
db 89, 50, 6
|
|
|
|
db 166, 70, 7
|
|
|
|
db 217, 90, 8
|
|
|
|
db 242, 110, 9
|
|
|
|
db 255, 150, 10
|
|
|
|
; 379c9
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_BatonPass: ; 379c9
|
2013-03-26 17:39:44 -07:00
|
|
|
; batonpass
|
|
|
|
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jp nz, .Enemy
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
|
|
; Need something to switch to
|
|
|
|
call CheckAnyOtherAlivePartyMons
|
|
|
|
jp z, FailedBatonPass
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateBattleMonInParty
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld c, 50
|
|
|
|
call DelayFrames
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
; Transition into switchmon menu
|
2015-11-11 13:11:08 -08:00
|
|
|
call LoadStandardMenuDataHeader
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall SetUpBattlePartyMenu_NoLoop
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall ForcePickSwitchMonInBattle
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
|
|
; Return to battle scene
|
2013-12-02 11:18:03 -08:00
|
|
|
call ClearPalettes
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _LoadBattleFontsHPBar
|
2015-12-24 19:58:42 -08:00
|
|
|
call CloseWindow
|
2013-12-02 11:18:03 -08:00
|
|
|
call ClearSprites
|
2013-12-31 01:09:00 -08:00
|
|
|
hlcoord 1, 0
|
|
|
|
lb bc, 4, 10
|
2013-03-26 17:39:44 -07:00
|
|
|
call ClearBox
|
2015-12-28 07:57:04 -08:00
|
|
|
ld b, SCGB_BATTLE_COLORS
|
2013-12-02 11:18:03 -08:00
|
|
|
call GetSGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
call SetPalettes
|
2014-01-05 04:28:55 -08:00
|
|
|
call BatonPass_LinkPlayerSwitch
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
; Mobile link battles handle entrances differently
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckMobileBattleError
|
2013-03-26 17:39:44 -07:00
|
|
|
jp c, EndMoveEffect
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
ld hl, PassedBattleMonEntrance
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
|
|
call ResetBatonPassStatus
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Enemy:
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
|
|
; Wildmons don't have anything to switch to
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2014-01-05 04:28:55 -08:00
|
|
|
dec a ; WILDMON
|
2014-01-01 05:09:15 -08:00
|
|
|
jp z, FailedBatonPass
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
call CheckAnyOtherAliveEnemyMons
|
|
|
|
jp z, FailedBatonPass
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateEnemyMonInParty
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2014-01-05 04:28:55 -08:00
|
|
|
call BatonPass_LinkEnemySwitch
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
; Mobile link battles handle entrances differently
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckMobileBattleError
|
2013-03-27 15:50:10 -07:00
|
|
|
jp c, EndMoveEffect
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
; Passed enemy PartyMon entrance
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-11-08 16:09:36 -08:00
|
|
|
ld [wEnemySwitchMonIndex], a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld hl, EnemySwitch_SetMode
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2015-11-07 18:04:54 -08:00
|
|
|
ld hl, ResetBattleParticipants
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, ApplyStatLevelMultiplierOnAllStats
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
ld hl, SpikesDamage
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
jr ResetBatonPassStatus
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; 37a67
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-05 04:28:55 -08:00
|
|
|
BatonPass_LinkPlayerSwitch: ; 37a67
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, 1
|
2015-12-17 14:51:32 -08:00
|
|
|
ld [wPlayerAction], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-11 13:11:08 -08:00
|
|
|
call LoadStandardMenuDataHeader
|
2015-11-23 13:04:53 -08:00
|
|
|
ld hl, LinkBattleSendReceiveAction
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2015-12-24 19:58:42 -08:00
|
|
|
call CloseWindow
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2015-12-17 14:51:32 -08:00
|
|
|
ld [wPlayerAction], 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
|
|
|
; 37a82
|
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2014-01-05 04:28:55 -08:00
|
|
|
BatonPass_LinkEnemySwitch: ; 37a82
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2015-11-11 13:11:08 -08:00
|
|
|
call LoadStandardMenuDataHeader
|
2015-11-23 13:04:53 -08:00
|
|
|
ld hl, LinkBattleSendReceiveAction
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [OTPartyCount]
|
2015-11-06 11:45:10 -08:00
|
|
|
add BATTLEACTION_SWITCH1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, [wBattleAction]
|
2015-11-06 11:45:10 -08:00
|
|
|
cp BATTLEACTION_SWITCH1
|
|
|
|
jr c, .baton_pass
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2015-11-06 11:45:10 -08:00
|
|
|
jr c, .switch
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
.baton_pass
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [CurOTMon]
|
2015-11-06 11:45:10 -08:00
|
|
|
add BATTLEACTION_SWITCH1
|
2014-06-13 21:18:14 -07:00
|
|
|
ld [wBattleAction], a
|
2015-11-06 11:45:10 -08:00
|
|
|
.switch
|
2015-12-24 19:58:42 -08:00
|
|
|
jp CloseWindow
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; 37aab
|
|
|
|
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
FailedBatonPass: ; 37aab
|
|
|
|
call AnimateFailedMove
|
2013-03-27 15:50:10 -07:00
|
|
|
jp PrintButItFailed
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; 37ab1
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
ResetBatonPassStatus: ; 37ab1
|
|
|
|
; Reset status changes that aren't passed by Baton Pass.
|
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
; Nightmare isn't passed.
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-01-01 05:09:15 -08:00
|
|
|
and SLP
|
|
|
|
jr nz, .ok
|
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-01-01 05:09:15 -08:00
|
|
|
res SUBSTATUS_NIGHTMARE, [hl]
|
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
; Disable isn't passed.
|
2014-01-01 05:09:15 -08:00
|
|
|
call ResetActorDisable
|
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
; Attraction isn't passed.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerSubStatus1
|
2014-01-01 05:09:15 -08:00
|
|
|
res SUBSTATUS_IN_LOVE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, EnemySubStatus1
|
2014-01-01 05:09:15 -08:00
|
|
|
res SUBSTATUS_IN_LOVE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerSubStatus5
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_TRANSFORMED, [hl]
|
2014-06-17 12:52:32 -07:00
|
|
|
res SUBSTATUS_ENCORED, [hl]
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
; New mon hasn't used a move yet.
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_MOVE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 22:52:04 -07:00
|
|
|
ld [hl], 0
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-11-08 10:27:26 -08:00
|
|
|
ld [wPlayerWrapCount], a
|
|
|
|
ld [wEnemyWrapCount], 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
|
|
|
; 37ae9
|
|
|
|
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
CheckAnyOtherAlivePartyMons: ; 37ae9
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, PartyMon1HP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [PartyCount]
|
|
|
|
ld d, a
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld e, a
|
2014-01-01 05:09:15 -08:00
|
|
|
jr CheckAnyOtherAliveMons
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; 37af6
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
CheckAnyOtherAliveEnemyMons: ; 37af6
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, OTPartyMon1HP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [OTPartyCount]
|
|
|
|
ld d, a
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
ld e, a
|
2013-03-27 15:50:10 -07:00
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 37b01
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
CheckAnyOtherAliveMons: ; 37b01
|
|
|
|
; Check for nonzero HP starting from partymon
|
|
|
|
; HP at hl for d partymons, besides current mon e.
|
|
|
|
|
|
|
|
; Return nz if any are alive.
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld b, a
|
|
|
|
ld c, a
|
2014-01-01 05:09:15 -08:00
|
|
|
.loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c
|
|
|
|
cp d
|
2014-01-01 05:09:15 -08:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
cp e
|
2014-01-01 05:09:15 -08:00
|
|
|
jr z, .next
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
or b
|
|
|
|
ld b, a
|
|
|
|
ld a, [hld]
|
|
|
|
or b
|
|
|
|
ld b, a
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
|
|
.next
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2015-11-04 08:19:58 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
inc c
|
2014-01-01 05:09:15 -08:00
|
|
|
jr .loop
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
.done
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37b1d
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_Pursuit: ; 37b1d
|
2014-06-12 18:32:42 -07:00
|
|
|
; pursuit
|
|
|
|
; Double damage if the opponent is switching.
|
|
|
|
|
|
|
|
ld hl, wEnemyIsSwitching
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-12 18:32:42 -07:00
|
|
|
jr z, .ok
|
|
|
|
ld hl, wPlayerIsSwitching
|
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage + 1
|
|
|
|
sla [hl]
|
|
|
|
dec hl
|
|
|
|
rl [hl]
|
|
|
|
ret nc
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
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
|
|
|
; 37b39
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_ClearHazards: ; 37b39
|
2013-03-26 17:39:44 -07:00
|
|
|
; clearhazards
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SUBSTATUS_LEECH_SEED, [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .not_leeched
|
2014-06-10 23:08:07 -07:00
|
|
|
res SUBSTATUS_LEECH_SEED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, ShedLeechSeedText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2015-12-26 15:11:55 -08:00
|
|
|
.not_leeched
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, PlayerScreens
|
2015-11-08 10:27:26 -08:00
|
|
|
ld de, wPlayerWrapCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_screens_wrap
|
2013-04-19 23:57:11 -07:00
|
|
|
ld hl, EnemyScreens
|
2015-11-08 10:27:26 -08:00
|
|
|
ld de, wEnemyWrapCount
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_screens_wrap
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SCREENS_SPIKES, [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .no_spikes
|
2014-06-10 23:08:07 -07:00
|
|
|
res SCREENS_SPIKES, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BlewSpikesText
|
|
|
|
push de
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2013-03-26 17:39:44 -07:00
|
|
|
pop de
|
2015-12-26 15:11:55 -08:00
|
|
|
.no_spikes
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
xor a
|
|
|
|
ld [de], a
|
|
|
|
ld hl, ReleasedByText
|
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
|
|
|
; 37b74
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
ld hl, BattleMonMaxHP
|
|
|
|
ld de, BattleMonHP
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .start
|
|
|
|
ld hl, EnemyMonMaxHP
|
|
|
|
ld de, EnemyMonHP
|
|
|
|
|
|
|
|
.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
|
|
|
|
|
|
|
|
ld a, [TimeOfDay]
|
|
|
|
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:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [Weather]
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_HiddenPower: ; 37be8
|
2013-03-26 22:52:04 -07:00
|
|
|
; hiddenpower
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
|
|
|
ret nz
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall HiddenPowerDamage
|
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
|
|
|
; 37bf4
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_StartRain: ; 37bf4
|
2013-03-26 17:39:44 -07:00
|
|
|
; startrain
|
|
|
|
ld a, WEATHER_RAIN
|
|
|
|
ld [Weather], a
|
|
|
|
ld a, 5
|
|
|
|
ld [WeatherCount], a
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, DownpourText
|
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
|
|
|
; 37c07
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_StartSun: ; 37c07
|
2013-03-26 17:39:44 -07:00
|
|
|
; startsun
|
|
|
|
ld a, WEATHER_SUN
|
|
|
|
ld [Weather], a
|
|
|
|
ld a, 5
|
|
|
|
ld [WeatherCount], a
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, SunGotBrightText
|
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
|
|
|
; 37c1a
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_BellyDrum: ; 37c1a
|
2013-03-26 17:39:44 -07:00
|
|
|
; bellydrum
|
2015-11-09 13:41:09 -08:00
|
|
|
; This command is buggy because it raises the user's attack
|
|
|
|
; before checking that it has enough HP to use the move.
|
|
|
|
; Swap the order of these two blocks to fix.
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_AttackUp2
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [AttackMissed]
|
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .failed
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar GetHalfMaxHP
|
|
|
|
callfar CheckUserHasEnoughHP
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nc, .failed
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar SubtractHPFromUser
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateUserInParty
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, 5
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.max_attack_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
push af
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_AttackUp2
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
|
|
|
dec a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .max_attack_loop
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, BellyDrumText
|
2013-08-31 00:54:02 -07:00
|
|
|
jp StdBattleTextBox
|
2015-11-09 13:41:09 -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
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37c55
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_PsychUp: ; 37c55
|
2013-03-26 17:39:44 -07:00
|
|
|
; psychup
|
|
|
|
|
|
|
|
ld hl, EnemyStatLevels
|
|
|
|
ld de, PlayerStatLevels
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .pointers_correct
|
2015-11-09 13:41:09 -08:00
|
|
|
; It's the enemy's turn, so swap the pointers.
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
|
|
|
pop de
|
2015-11-09 13:41:09 -08:00
|
|
|
.pointers_correct
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
2015-11-09 13:41:09 -08:00
|
|
|
ld b, NUM_LEVEL_STATS
|
|
|
|
; If any of the enemy's stats is modified from its base level,
|
|
|
|
; the move succeeds. Otherwise, it fails.
|
|
|
|
.loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2015-11-09 13:41:09 -08:00
|
|
|
cp BASE_STAT_LEVEL
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .break
|
2013-03-26 17:39:44 -07:00
|
|
|
dec b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .loop
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-27 15:50:10 -07:00
|
|
|
jp PrintButItFailed
|
2015-11-09 13:41:09 -08:00
|
|
|
|
|
|
|
.break
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
2015-11-09 13:41:09 -08:00
|
|
|
ld b, NUM_LEVEL_STATS
|
|
|
|
.loop2
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .loop2
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .calc_enemy_stats
|
2015-11-06 17:55:16 -08:00
|
|
|
call CalcPlayerStats
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .merge
|
2015-11-09 13:41:09 -08:00
|
|
|
|
|
|
|
.calc_enemy_stats
|
2015-11-06 17:55:16 -08:00
|
|
|
call CalcEnemyStats
|
2015-11-09 13:41:09 -08:00
|
|
|
.merge
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CopiedStatsText
|
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
|
|
|
; 37c95
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_MirrorCoat: ; 37c95
|
2013-03-26 17:39:44 -07:00
|
|
|
; mirrorcoat
|
|
|
|
|
2014-01-05 05:24:27 -08:00
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [AttackMissed], a
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar GetMoveEffect
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
2014-01-05 05:24:27 -08:00
|
|
|
cp EFFECT_MIRROR_COAT
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
call BattleCommand_ResetTypeMatchup
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wTypeMatchup]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckOpponentWentFirst
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
|
|
|
ld de, StringBuffer1
|
|
|
|
call GetMoveData
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [StringBuffer1 + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [StringBuffer1 + 3]
|
2014-01-05 05:24:27 -08:00
|
|
|
cp SPECIAL
|
2013-03-26 17:39:44 -07:00
|
|
|
ret c
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
ret z
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
add a
|
|
|
|
ld [hld], a
|
|
|
|
ld a, [hl]
|
|
|
|
adc a
|
|
|
|
ld [hl], a
|
2014-01-05 05:24:27 -08:00
|
|
|
jr nc, .capped
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2014-01-05 05:24:27 -08:00
|
|
|
.capped
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [AttackMissed], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; 37ce6
|
|
|
|
|
|
|
|
|
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
|
|
|
|
ld hl, CurDamage + 1
|
|
|
|
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
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [Weather]
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_CheckFutureSight: ; 37d0d
|
2013-03-26 22:52:04 -07:00
|
|
|
; checkfuturesight
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
ld hl, wPlayerFutureSightCount
|
2015-12-26 15:11:55 -08:00
|
|
|
ld de, wPlayerFutureSightDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2013-03-26 22:52:04 -07:00
|
|
|
jr z, .ok
|
2015-11-08 10:27:26 -08:00
|
|
|
ld hl, wEnemyFutureSightCount
|
2015-12-26 15:11:55 -08:00
|
|
|
ld de, wEnemyFutureSightDamage
|
2013-03-26 22:52:04 -07:00
|
|
|
.ok
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
2013-03-26 22:52:04 -07:00
|
|
|
cp 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
ld [hl], 0
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [CurDamage], a
|
|
|
|
ld a, [de]
|
|
|
|
ld [CurDamage + 1], a
|
2015-04-13 21:39:54 -07:00
|
|
|
ld b, futuresight_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
|
|
|
; 37d34
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_FutureSight: ; 37d34
|
2013-03-26 17:39:44 -07:00
|
|
|
; futuresight
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckUserIsCharging
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .AlreadyChargingFutureSight
|
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 b, a
|
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], b
|
|
|
|
ld a, BATTLE_VARS_LAST_MOVE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], b
|
2016-04-10 11:42:14 -07:00
|
|
|
.AlreadyChargingFutureSight:
|
2015-11-08 10:27:26 -08:00
|
|
|
ld hl, wPlayerFutureSightCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .GotFutureSightCount
|
2015-11-08 10:27:26 -08:00
|
|
|
ld hl, wEnemyFutureSightCount
|
2016-04-10 11:42:14 -07:00
|
|
|
.GotFutureSightCount:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .failed
|
|
|
|
ld a, 4
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, ForesawAttackText
|
2013-08-31 00:54:02 -07:00
|
|
|
call StdBattleTextBox
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2015-12-26 15:11:55 -08:00
|
|
|
ld de, wPlayerFutureSightDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .StoreDamage
|
|
|
|
ld de, wEnemyFutureSightDamage
|
2016-04-10 11:42:14 -07:00
|
|
|
.StoreDamage:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, CurDamage
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [hl], 0
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [hl], 0
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
|
|
|
.failed
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
call ResetDamage
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-27 15:50:10 -07:00
|
|
|
call PrintButItFailed
|
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
|
|
|
; 37d94
|
|
|
|
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
BattleCommand_ThunderAccuracy: ; 37d94
|
2013-03-26 17:39:44 -07:00
|
|
|
; thunderaccuracy
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld a, [Weather]
|
|
|
|
cp WEATHER_RAIN
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .rain
|
2013-03-26 17:39:44 -07:00
|
|
|
cp WEATHER_SUN
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [hl], 50 percent + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
.rain
|
2016-10-28 17:08:18 -07:00
|
|
|
; Redundant with CheckHit guranteeing hit
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [hl], 100 percent
|
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
|
|
|
; 37daa
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
ld hl, BattleMonItem
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .go
|
|
|
|
ld hl, EnemyMonItem
|
|
|
|
.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.
|
|
|
|
ld hl, EnemyMonItem
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr z, .go
|
|
|
|
ld hl, BattleMonItem
|
|
|
|
.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
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID + 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
|
|
|
|
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID], 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
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID + 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
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID], 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
|
2017-12-24 09:47:30 -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
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID], a
|
2013-03-27 13:19:51 -07:00
|
|
|
ld a, d
|
2017-12-09 16:41:03 -08:00
|
|
|
ld [FXAnimID + 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
|
|
|
|
2017-12-24 09:47:30 -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.
|
2017-12-09 11:22:58 -08:00
|
|
|
ld a, [BattleScriptBufferAddress + 1]
|
2013-03-26 22:52:04 -07:00
|
|
|
ld h, a
|
2017-12-09 11:22:58 -08:00
|
|
|
ld a, [BattleScriptBufferAddress]
|
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
|
2017-12-09 11:22:58 -08:00
|
|
|
ld [BattleScriptBufferAddress + 1], a
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, l
|
2017-12-09 11:22:58 -08:00
|
|
|
ld [BattleScriptBufferAddress], 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
|