summaryrefslogtreecommitdiff
path: root/engine/battle
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle')
-rw-r--r--engine/battle/ai/items.asm32
-rwxr-xr-xengine/battle/ai/move.asm1
-rw-r--r--engine/battle/ai/scoring.asm181
-rwxr-xr-xengine/battle/anim_hp_bar.asm5
-rw-r--r--engine/battle/battle_transition.asm42
-rw-r--r--engine/battle/consumehelditem.asm29
-rw-r--r--engine/battle/core.asm144
-rw-r--r--engine/battle/effect_commands.asm2698
-rwxr-xr-xengine/battle/menu.asm18
-rw-r--r--engine/battle/misc.asm41
-rwxr-xr-xengine/battle/move_effects/attract.asm (renamed from engine/battle/effect_commands/attract.asm)2
-rw-r--r--engine/battle/move_effects/baton_pass.asm241
-rw-r--r--engine/battle/move_effects/beat_up.asm219
-rw-r--r--engine/battle/move_effects/belly_drum.asm36
-rw-r--r--engine/battle/move_effects/bide.asm105
-rw-r--r--engine/battle/move_effects/conversion.asm98
-rw-r--r--engine/battle/move_effects/conversion2.asm66
-rw-r--r--engine/battle/move_effects/counter.asm60
-rw-r--r--engine/battle/move_effects/curse.asm (renamed from engine/battle/effect_commands/curse.asm)0
-rw-r--r--engine/battle/move_effects/destiny_bond.asm11
-rw-r--r--engine/battle/move_effects/disable.asm74
-rw-r--r--engine/battle/move_effects/encore.asm122
-rw-r--r--engine/battle/move_effects/endure.asm (renamed from engine/battle/effect_commands/endure.asm)0
-rw-r--r--engine/battle/move_effects/false_swipe.asm44
-rw-r--r--engine/battle/move_effects/focus_energy.asm17
-rw-r--r--engine/battle/move_effects/foresight.asm (renamed from engine/battle/effect_commands/foresight.asm)2
-rw-r--r--engine/battle/move_effects/frustration.asm29
-rw-r--r--engine/battle/move_effects/fury_cutter.asm61
-rw-r--r--engine/battle/move_effects/future_sight.asm85
-rw-r--r--engine/battle/move_effects/heal_bell.asm36
-rw-r--r--engine/battle/move_effects/hidden_power.asm10
-rw-r--r--engine/battle/move_effects/leech_seed.asm42
-rw-r--r--engine/battle/move_effects/lock_on.asm23
-rw-r--r--engine/battle/move_effects/magnitude.asm29
-rw-r--r--engine/battle/move_effects/metronome.asm (renamed from engine/battle/effect_commands/metronome.asm)17
-rw-r--r--engine/battle/move_effects/mimic.asm52
-rw-r--r--engine/battle/move_effects/mirror_coat.asm61
-rw-r--r--engine/battle/move_effects/mirror_move.asm (renamed from engine/battle/effect_commands/mirror_move.asm)0
-rw-r--r--engine/battle/move_effects/mist.asm17
-rw-r--r--engine/battle/move_effects/nightmare.asm (renamed from engine/battle/effect_commands/nightmare.asm)0
-rw-r--r--engine/battle/move_effects/pain_split.asm97
-rw-r--r--engine/battle/move_effects/pay_day.asm28
-rw-r--r--engine/battle/move_effects/perish_song.asm (renamed from engine/battle/effect_commands/perish_song.asm)0
-rwxr-xr-xengine/battle/move_effects/present.asm (renamed from engine/battle/effect_commands/present.asm)11
-rw-r--r--engine/battle/move_effects/protect.asm (renamed from engine/battle/effect_commands/protect.asm)0
-rw-r--r--engine/battle/move_effects/psych_up.asm51
-rw-r--r--engine/battle/move_effects/pursuit.asm26
-rw-r--r--engine/battle/move_effects/rage.asm8
-rw-r--r--engine/battle/move_effects/rain_dance.asm11
-rw-r--r--engine/battle/move_effects/rapid_spin.asm38
-rw-r--r--engine/battle/move_effects/return.asm27
-rw-r--r--engine/battle/move_effects/rollout.asm (renamed from engine/battle/effect_commands/rollout.asm)0
-rw-r--r--engine/battle/move_effects/safeguard.asm25
-rw-r--r--engine/battle/move_effects/sandstorm.asm (renamed from engine/battle/effect_commands/sandstorm.asm)0
-rw-r--r--engine/battle/move_effects/selfdestruct.asm31
-rw-r--r--engine/battle/move_effects/sketch.asm119
-rw-r--r--engine/battle/move_effects/sleep_talk.asm145
-rw-r--r--engine/battle/move_effects/snore.asm13
-rw-r--r--engine/battle/move_effects/spikes.asm (renamed from engine/battle/effect_commands/spikes.asm)2
-rw-r--r--engine/battle/move_effects/spite.asm88
-rw-r--r--engine/battle/move_effects/splash.asm6
-rw-r--r--engine/battle/move_effects/substitute.asm90
-rw-r--r--engine/battle/move_effects/sunny_day.asm11
-rw-r--r--engine/battle/move_effects/teleport.asm91
-rw-r--r--engine/battle/move_effects/thief.asm (renamed from engine/battle/effect_commands/thief.asm)0
-rw-r--r--engine/battle/move_effects/thunder.asm20
-rwxr-xr-xengine/battle/move_effects/transform.asm (renamed from engine/battle/effect_commands/transform.asm)0
-rw-r--r--engine/battle/move_effects/triple_kick.asm39
-rwxr-xr-xengine/battle/read_trainer_party.asm3
-rw-r--r--engine/battle/returntobattle_useball.asm2
-rwxr-xr-xengine/battle/used_move_text.asm1
71 files changed, 2709 insertions, 3024 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm
index 8fb420bd6..218ecd375 100644
--- a/engine/battle/ai/items.asm
+++ b/engine/battle/ai/items.asm
@@ -52,7 +52,7 @@ SwitchOften: ; 38045
cp $10
jr nz, .not_10
call Random
- cp 1 + 50 percent
+ cp 50 percent + 1
jr c, .switch
jp DontSwitch
.not_10
@@ -60,7 +60,7 @@ SwitchOften: ; 38045
cp $20
jr nz, .not_20
call Random
- cp -1 + 79 percent
+ cp 79 percent - 1
jr c, .switch
jp DontSwitch
.not_20
@@ -103,7 +103,7 @@ SwitchRarely: ; 38083
; $30
call Random
- cp -1 + 79 percent
+ cp 79 percent - 1
jp c, DontSwitch
.switch
@@ -123,7 +123,7 @@ SwitchSometimes: ; 380c1
cp $10
jr nz, .not_10
call Random
- cp -1 + 20 percent
+ cp 20 percent - 1
jr c, .switch
jp DontSwitch
.not_10
@@ -131,14 +131,14 @@ SwitchSometimes: ; 380c1
cp $20
jr nz, .not_20
call Random
- cp 1 + 50 percent
+ cp 50 percent + 1
jr c, .switch
jp DontSwitch
.not_20
; $30
call Random
- cp -1 + 20 percent
+ cp 20 percent - 1
jp c, DontSwitch
.switch
@@ -313,7 +313,7 @@ AI_Items: ; 39196
bit ALWAYS_USE_F, a
jp nz, .Use
call Random
- cp -1 + 20 percent
+ cp 20 percent - 1
jp c, .Use
jp .DontUse
@@ -325,7 +325,7 @@ AI_Items: ; 39196
cp 4
jr c, .FailToxicCheck
call Random
- cp 1 + 50 percent
+ cp 50 percent + 1
jp c, .Use
.FailToxicCheck:
ld a, [wEnemyMonStatus]
@@ -366,7 +366,7 @@ AI_Items: ; 39196
callfar AICheckEnemyQuarterHP
jp nc, .UseHealItem
call Random
- cp 1 + 50 percent
+ cp 50 percent + 1
jp c, .UseHealItem
jp .DontUse
@@ -374,7 +374,7 @@ AI_Items: ; 39196
callfar AICheckEnemyQuarterHP
jp c, .DontUse
call Random
- cp -1 + 20 percent
+ cp 20 percent - 1
jp c, .DontUse
jr .UseHealItem
@@ -384,7 +384,7 @@ AI_Items: ; 39196
callfar AICheckEnemyQuarterHP
jp nc, .UseHealItem
call Random
- cp -1 + 20 percent
+ cp 20 percent - 1
jp nc, .DontUse
.UseHealItem: ; 38281 (e:4281)
@@ -442,7 +442,7 @@ AI_Items: ; 39196
bit UNKNOWN_USE_F, a
jp z, .Use
call Random
- cp 1 + 50 percent
+ cp 50 percent + 1
jp c, .Use
.dont_use
@@ -454,7 +454,7 @@ AI_Items: ; 39196
bit UNKNOWN_USE_F, a
jp z, .DontUse
call Random
- cp 1 + 39 percent
+ cp 39 percent + 1
jp c, .Use
jp .DontUse
; 382f9
@@ -516,13 +516,13 @@ AI_Items: ; 39196
bit ALWAYS_USE_F, a
jp nz, .Use
call Random
- cp 1 + 50 percent
+ cp 50 percent + 1
jp c, .DontUse
ld a, [bc]
bit CONTEXT_USE_F, a
jp nz, .Use
call Random
- cp 1 + 50 percent
+ cp 50 percent + 1
jp c, .DontUse
jp .Use
.notfirstturnout
@@ -530,7 +530,7 @@ AI_Items: ; 39196
bit ALWAYS_USE_F, a
jp z, .DontUse
call Random
- cp -1 + 20 percent
+ cp 20 percent - 1
jp nc, .DontUse
jp .Use
diff --git a/engine/battle/ai/move.asm b/engine/battle/ai/move.asm
index b5ac966f8..dd4357fe2 100755
--- a/engine/battle/ai/move.asm
+++ b/engine/battle/ai/move.asm
@@ -202,6 +202,7 @@ AIChooseMove: ; 440ce
AIScoringPointers: ; 441af
+; entries correspond to AI_* constants
dw AI_Basic
dw AI_Setup
dw AI_Types
diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm
index b250128a4..7af2db8ad 100644
--- a/engine/battle/ai/scoring.asm
+++ b/engine/battle/ai/scoring.asm
@@ -40,7 +40,7 @@ AI_Basic: ; 38591
push hl
push de
push bc
- ld hl, .statusonlyeffects
+ ld hl, StatusOnlyEffects
ld de, 1
call IsInArray
@@ -63,13 +63,7 @@ AI_Basic: ; 38591
jr .checkmove
; 385db
-.statusonlyeffects
- db EFFECT_SLEEP
- db EFFECT_TOXIC
- db EFFECT_POISON
- db EFFECT_PARALYZE
- db -1 ; end
-; 385e0
+INCLUDE "data/battle/ai/status_only_effects.asm"
@@ -1502,7 +1496,7 @@ AI_Smart_Encore: ; 38c3b
.asm_38c68
push hl
ld a, [wLastPlayerCounterMove]
- ld hl, .EncoreMoves
+ ld hl, EncoreMoves
ld de, 1
call IsInArray
pop hl
@@ -1522,39 +1516,7 @@ AI_Smart_Encore: ; 38c3b
inc [hl]
ret
-.EncoreMoves:
- db SWORDS_DANCE
- db WHIRLWIND
- db LEER
- db ROAR
- db DISABLE
- db MIST
- db LEECH_SEED
- db GROWTH
- db POISONPOWDER
- db STRING_SHOT
- db MEDITATE
- db AGILITY
- db TELEPORT
- db SCREECH
- db HAZE
- db FOCUS_ENERGY
- db DREAM_EATER
- db POISON_GAS
- db SPLASH
- db SHARPEN
- db CONVERSION
- db SUPER_FANG
- db SUBSTITUTE
- db TRIPLE_KICK
- db SPIDER_WEB
- db MIND_READER
- db FLAME_WHEEL
- db AEROBLAST
- db COTTON_SPORE
- db POWDER_SNOW
- db -1 ; end
-; 38ca4
+INCLUDE "data/battle/ai/encore_moves.asm"
AI_Smart_PainSplit: ; 38ca4
@@ -2521,20 +2483,7 @@ AI_Smart_RainDance: ; 390cb
jr AI_Smart_WeatherMove
; 390e7
-RainDanceMoves: ; 390e7
- db WATER_GUN
- db HYDRO_PUMP
- db SURF
- db BUBBLEBEAM
- db THUNDER
- db WATERFALL
- db CLAMP
- db BUBBLE
- db CRABHAMMER
- db OCTAZOOKA
- db WHIRLPOOL
- db -1 ; end
-; 390f3
+INCLUDE "data/battle/ai/rain_dance_moves.asm"
AI_Smart_SunnyDay: ; 390f3
@@ -2613,17 +2562,7 @@ AIGoodWeatherType: ; 39122
; 39134
-SunnyDayMoves: ; 39134
- db FIRE_PUNCH
- db EMBER
- db FLAMETHROWER
- db FIRE_SPIN
- db FIRE_BLAST
- db SACRED_FIRE
- db MORNING_SUN
- db SYNTHESIS
- db -1 ; end
-; 3913d
+INCLUDE "data/battle/ai/sunny_day_moves.asm"
AI_Smart_BellyDrum: ; 3913d
@@ -3104,29 +3043,7 @@ AIHasMoveInArray: ; 392e6
; 39301
-UsefulMoves: ; 39301
-; Moves that are usable all-around.
- db DOUBLE_EDGE
- db SING
- db FLAMETHROWER
- db HYDRO_PUMP
- db SURF
- db ICE_BEAM
- db BLIZZARD
- db HYPER_BEAM
- db SLEEP_POWDER
- db THUNDERBOLT
- db THUNDER
- db EARTHQUAKE
- db TOXIC
- db PSYCHIC_M
- db HYPNOSIS
- db RECOVER
- db FIRE_BLAST
- db SOFTBOILED
- db SUPER_FANG
- db -1 ; end
-; 39315
+INCLUDE "data/battle/ai/useful_moves.asm"
AI_Opportunist: ; 39315
@@ -3161,7 +3078,7 @@ AI_Opportunist: ; 39315
push hl
push de
push bc
- ld hl, .stallmoves
+ ld hl, StallMoves
ld de, 1
call IsInArray
@@ -3176,41 +3093,7 @@ AI_Opportunist: ; 39315
.asm_39347
ret
-.stallmoves
- db SWORDS_DANCE
- db TAIL_WHIP
- db LEER
- db GROWL
- db DISABLE
- db MIST
- db COUNTER
- db LEECH_SEED
- db GROWTH
- db STRING_SHOT
- db MEDITATE
- db AGILITY
- db RAGE
- db MIMIC
- db SCREECH
- db HARDEN
- db WITHDRAW
- db DEFENSE_CURL
- db BARRIER
- db LIGHT_SCREEN
- db HAZE
- db REFLECT
- db FOCUS_ENERGY
- db BIDE
- db AMNESIA
- db TRANSFORM
- db SPLASH
- db ACID_ARMOR
- db SHARPEN
- db CONVERSION
- db SUBSTITUTE
- db FLAME_WHEEL
- db -1 ; end
-; 39369
+INCLUDE "data/battle/ai/stall_moves.asm"
@@ -3304,7 +3187,7 @@ AI_Aggressive: ; 39369
push de
push bc
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
- ld hl, .RecklessMoves
+ ld hl, RecklessMoves
ld de, 1
call IsInArray
pop bc
@@ -3319,13 +3202,7 @@ AI_Aggressive: ; 39369
.done
ret
-.RecklessMoves:
- db EFFECT_SELFDESTRUCT
- db EFFECT_RAMPAGE
- db EFFECT_MULTI_HIT
- db EFFECT_DOUBLE_HIT
- db -1 ; end
-; 393e7
+INCLUDE "data/battle/ai/reckless_moves.asm"
AIDamageCalc: ; 393e7
@@ -3333,7 +3210,7 @@ AIDamageCalc: ; 393e7
ld [hBattleTurn], a
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
ld de, 1
- ld hl, .ConstantDamageEffects
+ ld hl, ConstantDamageEffects
call IsInArray
jr nc, .asm_39400
callfar BattleCommand_ConstantDamage
@@ -3345,13 +3222,7 @@ AIDamageCalc: ; 393e7
callfar BattleCommand_Stab
ret
-.ConstantDamageEffects:
- db EFFECT_SUPER_FANG
- db EFFECT_STATIC_DAMAGE
- db EFFECT_LEVEL_DAMAGE
- db EFFECT_PSYWAVE
- db -1 ; end
-; 39418
+INCLUDE "data/battle/ai/constant_damage_effects.asm"
AI_Cautious: ; 39418
@@ -3377,7 +3248,7 @@ AI_Cautious: ; 39418
push hl
push de
push bc
- ld hl, .residualmoves
+ ld hl, ResidualMoves
ld de, 1
call IsInArray
@@ -3393,21 +3264,7 @@ AI_Cautious: ; 39418
inc [hl]
jr .asm_39425
-.residualmoves
- db MIST
- db LEECH_SEED
- db POISONPOWDER
- db STUN_SPORE
- db THUNDER_WAVE
- db FOCUS_ENERGY
- db BIDE
- db POISON_GAS
- db TRANSFORM
- db CONVERSION
- db SUBSTITUTE
- db SPIKES
- db -1 ; end
-; 39453
+INCLUDE "data/battle/ai/residual_moves.asm"
@@ -3504,7 +3361,7 @@ AI_Risky: ; 394a9
; Don't use risky moves at max hp.
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
ld de, 1
- ld hl, .RiskyMoves
+ ld hl, RiskyEffects
call IsInArray
jr nc, .checkko
@@ -3541,11 +3398,7 @@ endr
pop de
jr .checkmove
-.RiskyMoves:
- db EFFECT_SELFDESTRUCT
- db EFFECT_OHKO
- db -1 ; end
-; 39502
+INCLUDE "data/battle/ai/risky_effects.asm"
diff --git a/engine/battle/anim_hp_bar.asm b/engine/battle/anim_hp_bar.asm
index 7d51a8629..5c453d0ff 100755
--- a/engine/battle/anim_hp_bar.asm
+++ b/engine/battle/anim_hp_bar.asm
@@ -384,8 +384,9 @@ ShortHPBar_CalcPixelFrame: ; d839
call AddNTimes
ld b, 0
-; This routine is buggy. If [wCurHPAnimMaxHP] * [wCurHPBarPixels] is divisible
-; by 48, the loop runs one extra time. To fix, uncomment the line below.
+; This routine is buggy. If [wCurHPAnimMaxHP] * [wCurHPBarPixels] is
+; divisible by HP_BAR_LENGTH_PX, the loop runs one extra time.
+; To fix, uncomment the line below.
.loop
ld a, l
sub HP_BAR_LENGTH_PX
diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm
index 29b2d8663..1de84421d 100644
--- a/engine/battle/battle_transition.asm
+++ b/engine/battle/battle_transition.asm
@@ -749,47 +749,7 @@ WipeLYOverrides: ; 8c6d8
StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7)
-; a = d * sin(a * pi/32)
- and %111111
- cp %100000
- jr nc, .negative
- call .ApplySineWave
- ld a, h
- ret
-
-.negative
- and %011111
- call .ApplySineWave
- ld a, h
- xor $ff
- inc a
- ret
-
-.ApplySineWave: ; 8c70c (23:470c)
- ld e, a
- ld a, d
- ld d, 0
- ld hl, .sinewave
- add hl, de
- add hl, de
- ld e, [hl]
- inc hl
- ld d, [hl]
- ld hl, 0
-.multiply
- srl a
- jr nc, .even
- add hl, de
-.even
- sla e
- rl d
- and a
- jr nz, .multiply
- ret
-; 8c728 (23:4728)
-
-.sinewave ; 8c728
- sine_wave $100
+ calc_sine_wave
; 8c768
StartTrainerBattle_ZoomToBlack: ; 8c768 (23:4768)
diff --git a/engine/battle/consumehelditem.asm b/engine/battle/consumehelditem.asm
index 39ddbc27e..d727a44e0 100644
--- a/engine/battle/consumehelditem.asm
+++ b/engine/battle/consumehelditem.asm
@@ -18,7 +18,7 @@ ConsumeHeldItem: ; 27192
ld a, [de]
ld b, a
farcall GetItemHeldEffect
- ld hl, .ConsumableEffects
+ ld hl, ConsumableEffects
.loop
ld a, [hli]
cp b
@@ -46,7 +46,7 @@ ConsumeHeldItem: ; 27192
jr z, .done
.ourturn
- ld [hl], $0
+ ld [hl], NO_ITEM
.done
pop bc
@@ -54,27 +54,4 @@ ConsumeHeldItem: ; 27192
pop hl
ret
-.ConsumableEffects: ; 271de
-; Consumable items?
- db HELD_BERRY
- db HELD_2
- db HELD_5
- db HELD_HEAL_POISON
- db HELD_HEAL_FREEZE
- db HELD_HEAL_BURN
- db HELD_HEAL_SLEEP
- db HELD_HEAL_PARALYZE
- db HELD_HEAL_STATUS
- db HELD_30
- db HELD_ATTACK_UP
- db HELD_DEFENSE_UP
- db HELD_SPEED_UP
- db HELD_SP_ATTACK_UP
- db HELD_SP_DEFENSE_UP
- db HELD_ACCURACY_UP
- db HELD_EVASION_UP
- db HELD_38
- db HELD_71
- db HELD_ESCAPE
- db HELD_CRITICAL_UP
- db -1
+INCLUDE "data/battle/held_consumables.asm"
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index df9d4cbc5..fe20333b5 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -463,13 +463,13 @@ DetermineMoveOrder: ; 3c314
jr z, .player_2
call BattleRandom
- cp 1 + (50 percent)
+ cp 50 percent + 1
jp c, .player_first
jp .enemy_first
.player_2
call BattleRandom
- cp 1 + (50 percent)
+ cp 50 percent + 1
jp c, .enemy_first
jp .player_first
@@ -549,13 +549,13 @@ DetermineMoveOrder: ; 3c314
cp USING_INTERNAL_CLOCK
jr z, .player_2c
call BattleRandom
- cp 1 + (50 percent)
+ cp 50 percent + 1
jp c, .player_first
jp .enemy_first
.player_2c
call BattleRandom
- cp 1 + (50 percent)
+ cp 50 percent + 1
jp c, .enemy_first
.player_first
scf
@@ -791,7 +791,7 @@ TryEnemyFlee: ; 3c543
call BattleRandom
ld b, a
- cp 1 + (50 percent)
+ cp 50 percent + 1
jr nc, .Stay
push bc
@@ -803,7 +803,7 @@ TryEnemyFlee: ; 3c543
jr c, .Flee
ld a, b
- cp 1 + (10 percent)
+ cp 10 percent + 1
jr nc, .Stay
ld a, [wTempEnemyMonSpecies]
@@ -1807,10 +1807,13 @@ HandleWeather: ; 3cb9e
; 3cc2d
.WeatherMessages:
+; entries correspond to WEATHER_* constants
dw BattleText_RainContinuesToFall
dw BattleText_TheSunlightIsStrong
dw BattleText_TheSandstormRages
+
.WeatherEndedMessages:
+; entries correspond to WEATHER_* constants
dw BattleText_TheRainStopped
dw BattleText_TheSunlightFaded
dw BattleText_TheSandstormSubsided
@@ -2471,22 +2474,22 @@ WinTrainerBattle: ; 3cfa4
call nz, .DoubleReward
call .CheckMaxedOutMomMoney
push af
- ld a, $0
+ ld a, FALSE
jr nc, .okay
ld a, [wMomSavingMoney]
- and $7
- cp $3
+ and MOM_SAVING_MONEY_MASK
+ cp (1 << MOM_SAVING_SOME_MONEY_F) | (1 << MOM_SAVING_HALF_MONEY_F)
jr nz, .okay
- inc a
+ inc a ; TRUE
.okay
ld b, a
- ld c, $4
+ ld c, 4
.loop
ld a, b
and a
jr z, .loop2
- call .SendMoneyToMom
+ call .AddMoneyToMom
dec c
dec b
jr .loop
@@ -2505,7 +2508,7 @@ WinTrainerBattle: ; 3cfa4
pop af
jr nc, .KeepItAll
ld a, [wMomSavingMoney]
- and $7
+ and MOM_SAVING_MONEY_MASK
jr z, .KeepItAll
ld hl, .SentToMomTexts
dec a
@@ -2523,7 +2526,7 @@ WinTrainerBattle: ; 3cfa4
jp StdBattleTextBox
; 3d081
-.SendMoneyToMom: ; 3d081
+.AddMoneyToMom: ; 3d081
push bc
ld hl, wBattleReward + 2
ld de, wMomsMoney + 2
@@ -2557,6 +2560,7 @@ WinTrainerBattle: ; 3cfa4
; 3d0ab
.SentToMomTexts: ; 3d0ab
+; entries correspond to MOM_SAVING_* constants
dw SentSomeToMomText
dw SentHalfToMomText
dw SentAllToMomText
@@ -2574,7 +2578,7 @@ WinTrainerBattle: ; 3cfa4
; 3d0be
AddBattleMoneyToAccount: ; 3d0be
- ld c, $3
+ ld c, 3
and a
push de
push hl
@@ -2653,7 +2657,7 @@ IsGymLeader: ; 0x3d128
IsGymLeaderCommon:
push de
ld a, [wOtherTrainerClass]
- ld de, $1
+ ld de, 1
call IsInArray
pop de
ret
@@ -2781,7 +2785,7 @@ AskUseNextPokemon: ; 3d1f8
ForcePlayerMonChoice: ; 3d227
call EmptyBattleTextBox
- call LoadStandardMenuDataHeader
+ call LoadStandardMenuHeader
call SetUpBattlePartyMenu_NoLoop
call ForcePickPartyMonInBattle
ld a, [wLinkMode]
@@ -3300,7 +3304,7 @@ ResetEnemyBattleVars: ; 3d557
ld a, 8
call SlideBattlePicOut
call EmptyBattleTextBox
- jp LoadStandardMenuDataHeader
+ jp LoadStandardMenuHeader
; 3d57a
ResetBattleParticipants: ; 3d57a
@@ -3320,7 +3324,7 @@ AddBattleParticipant: ; 3d581
; 3d599
FindMonInOTPartyToSwitchIntoBattle: ; 3d599
- ld b, $ff
+ ld b, -1
ld a, $1
ld [wBuffer1], a
ld [wBuffer2], a
@@ -3464,7 +3468,7 @@ ScoreMonTypeMatchups: ; 3d672
ld a, [wBuffer1]
and a
jr z, .okay2
- ld b, $ff
+ ld b, -1
ld c, a
.loop3
inc b
@@ -3473,7 +3477,7 @@ ScoreMonTypeMatchups: ; 3d672
jr .quit
.okay2
- ld b, $ff
+ ld b, -1
ld a, [wBuffer2]
ld c, a
.loop4
@@ -4427,7 +4431,7 @@ HandleHPHealingItem: ; 3dd2f
ld c, a
dec de
ld a, [de]
- adc $0
+ adc 0
ld [wBuffer6], a
ld b, a
ld a, [hld]
@@ -4488,7 +4492,7 @@ ItemRecoveryAnim: ; 3ddc8
UseHeldStatusHealingItem: ; 3dde9
callfar GetOpponentItem
- ld hl, .Statuses
+ ld hl, HeldStatusHealingEffects
.loop
ld a, [hli]
cp $ff
@@ -4541,15 +4545,7 @@ UseHeldStatusHealingItem: ; 3dde9
ret
; 3de44
-.Statuses: ; 3de44
- db HELD_HEAL_POISON, 1 << PSN
- db HELD_HEAL_FREEZE, 1 << FRZ
- db HELD_HEAL_BURN, 1 << BRN
- db HELD_HEAL_SLEEP, SLP
- db HELD_HEAL_PARALYZE, 1 << PAR
- db HELD_HEAL_STATUS, ALL_STATUS
- db -1 ; end
-; 3de51
+INCLUDE "data/battle/held_heal_status.asm"
UseConfusionHealingItem: ; 3de51
ld a, BATTLE_VARS_SUBSTATUS3_OPP
@@ -4624,10 +4620,10 @@ HandleStatBoostingHeldItems: ; 3de97
ld a, [bc]
ld b, a
callfar GetItemHeldEffect
- ld hl, .StatUpItems
+ ld hl, HeldStatUpItems
.loop
ld a, [hli]
- cp $ff
+ cp -1
jr z, .finish
inc hl
inc hl
@@ -4664,16 +4660,7 @@ HandleStatBoostingHeldItems: ; 3de97
ret
; 3defc
-.StatUpItems:
- dbw HELD_ATTACK_UP, BattleCommand_AttackUp
- dbw HELD_DEFENSE_UP, BattleCommand_DefenseUp
- dbw HELD_SPEED_UP, BattleCommand_SpeedUp
- dbw HELD_SP_ATTACK_UP, BattleCommand_SpecialAttackUp
- dbw HELD_SP_DEFENSE_UP, BattleCommand_SpecialDefenseUp
- dbw HELD_ACCURACY_UP, BattleCommand_AccuracyUp
- dbw HELD_EVASION_UP, BattleCommand_EvasionUp
- db -1 ; end
-; 3df12
+INCLUDE "data/battle/held_stat_up.asm"
GetPartymonItem: ; 3df12
ld hl, wPartyMon1Item
@@ -5107,7 +5094,7 @@ BattleMenu_Pack: ; 3e1c7
and a
jp nz, .ItemsCantBeUsed
- call LoadStandardMenuDataHeader
+ call LoadStandardMenuHeader
ld a, [wBattleType]
cp BATTLETYPE_TUTORIAL
@@ -5202,10 +5189,10 @@ BattleMenu_Pack: ; 3e1c7
; 3e28d
BattleMenu_PKMN: ; 3e28d
- call LoadStandardMenuDataHeader
+ call LoadStandardMenuHeader
BattleMenuPKMN_ReturnFromStats:
call ExitMenu
- call LoadStandardMenuDataHeader
+ call LoadStandardMenuHeader
call ClearBGPalettes
BattleMenuPKMN_Loop:
call SetUpBattlePartyMenu
@@ -5345,7 +5332,7 @@ PlayerSwitch: ; 3e3ad
ld a, [wLinkMode]
and a
jr z, .not_linked
- call LoadStandardMenuDataHeader
+ call LoadStandardMenuHeader
call LinkBattleSendReceiveAction
call CloseWindow
@@ -6190,7 +6177,7 @@ LoadEnemyMon: ; 3e8eb
; 25% chance of getting an item
call BattleRandom
- cp 1 + (75 percent)
+ cp 75 percent + 1
ld a, NO_ITEM
jr c, .UpdateItem
@@ -6642,7 +6629,7 @@ CheckUnownLetter: ; 3eb75
jr nc, .next
; Is our letter in the set?
- ld hl, .LetterSets
+ ld hl, UnlockedUnownLetterSets
add hl, de
ld a, [hli]
ld h, [hl]
@@ -6663,7 +6650,7 @@ CheckUnownLetter: ; 3eb75
inc e
inc e
ld a, e
- cp .Set1 - .LetterSets
+ cp UnlockedUnownLetterSets.End - UnlockedUnownLetterSets
jr c, .loop
; Hasn't been unlocked, or the letter is invalid
@@ -6675,26 +6662,8 @@ CheckUnownLetter: ; 3eb75
and a
ret
-.LetterSets:
- dw .Set1
- dw .Set2
- dw .Set3
- dw .Set4
+INCLUDE "data/wild/unlocked_unowns.asm"
-.Set1:
- ; A B C D E F G H I J K
- db 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, $ff
-.Set2:
- ; L M N O P Q R
- db 12, 13, 14, 15, 16, 17, 18, $ff
-.Set3:
- ; S T U V W
- db 19, 20, 21, 22, 23, $ff
-.Set4:
- ; X Y Z
- db 24, 25, 26, $ff
-
-; 3ebc7
Unreferenced_SwapBattlerLevels: ; 3ebc7
push bc
@@ -6920,7 +6889,7 @@ ApplyStatLevelMultiplier: ; 3ecb7
.okay2
pop bc
push hl
- ld hl, .StatLevelMultipliers
+ ld hl, StatLevelMultipliers_Applied
dec b
sla b
ld c, b
@@ -6969,24 +6938,7 @@ ApplyStatLevelMultiplier: ; 3ecb7
ret
; 3ed2b
-.StatLevelMultipliers:
-; /
- db 25, 100 ; 25%
- db 28, 100 ; 28%
- db 33, 100 ; 33%
- db 40, 100 ; 40%
- db 50, 100 ; 50%
- db 66, 100 ; 66%
-
- db 1, 1 ; 100%
-
- db 15, 10 ; 150%
- db 2, 1 ; 200%
- db 25, 10 ; 250%
- db 3, 1 ; 300%
- db 35, 10 ; 350%
- db 4, 1 ; 400%
-; 3ed45
+INCLUDE "data/battle/stat_multipliers_2.asm"
BadgeStatBoosts: ; 3ed45
; Raise the stats of the battle mon in wBattleMon
@@ -8728,7 +8680,7 @@ IsMobileBattle2: ; 3f830
ret
; 3f836
-DisplayLinkRecord: ; 3f836
+_DisplayLinkRecord: ; 3f836
ld a, BANK(sLinkBattleStats)
call GetSRAMBank
@@ -8897,13 +8849,13 @@ BattleEnd_HandleRoamMons: ; 3f998
.caught_or_defeated_roam_mon
call GetRoamMonHP
- ld [hl], $0
+ ld [hl], 0
call GetRoamMonMapGroup
- ld [hl], $ff
+ ld [hl], GROUP_N_A
call GetRoamMonMapNumber
- ld [hl], $ff
+ ld [hl], MAP_N_A
call GetRoamMonSpecies
- ld [hl], $0
+ ld [hl], 0
ret
.not_roaming
@@ -9282,10 +9234,10 @@ GetTrainerBackpic: ; 3fbff
; What gender are we?
ld a, [wPlayerSpriteSetupFlags]
- bit 2, a ; transformed to male
+ bit PLAYERSPRITESETUP_FEMALE_TO_MALE_F, a
jr nz, .Chris
ld a, [wPlayerGender]
- bit 0, a
+ bit PLAYERGENDER_FEMALE_F, a
jr z, .Chris
; It's a girl.
diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm
index 48efba8fa..376624e44 100644
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -532,7 +532,7 @@ CheckEnemyTurn: ; 3421f
; 50% chance of hitting itself
call BattleRandom
- cp 1 + 50 percent
+ cp 50 percent + 1
jr nc, .not_confused
; clear confusion-dependent substatus
@@ -578,7 +578,7 @@ CheckEnemyTurn: ; 3421f
; 50% chance of infatuation
call BattleRandom
- cp 1 + 50 percent
+ cp 50 percent + 1
jr c, .not_infatuated
ld hl, InfatuationText
@@ -1306,45 +1306,7 @@ INCLUDE "data/battle/critical_hits.asm"
; 346b2
-BattleCommand_TripleKick: ; 346b2
-; triplekick
-
- ld a, [wKickCounter]
- ld b, a
- inc b
- ld hl, wCurDamage + 1
- ld a, [hld]
- ld e, a
- ld a, [hli]
- ld d, a
-.next_kick
- dec b
- ret z
- ld a, [hl]
- add e
- ld [hld], a
- ld a, [hl]
- adc d
- ld [hli], a
-
-; No overflow.
- jr nc, .next_kick
- ld a, $ff
- ld [hld], a
- ld [hl], a
- ret
-
-; 346cd
-
-
-BattleCommand_KickCounter: ; 346cd
-; kickcounter
-
- ld hl, wKickCounter
- inc [hl]
- ret
-
-; 346d2
+INCLUDE "engine/battle/move_effects/triple_kick.asm"
BattleCommand_Stab: ; 346d2
@@ -1542,8 +1504,8 @@ BattleCheckTypeMatchup: ; 347c8
ld hl, wBattleMonType1
CheckTypeMatchup: ; 347d3
; 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,
+; 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.
@@ -1637,9 +1599,11 @@ BattleCommand_ResetTypeMatchup: ; 34833
; 3484e
+
INCLUDE "engine/battle/ai/switch.asm"
-INCLUDE "data/battle/type_matchups.asm"
+INCLUDE "data/types/type_matchups.asm"
+
BattleCommand_DamageVariation: ; 34cfd
; damagevariation
@@ -2144,20 +2108,19 @@ BattleCommand_HitTargetNoSub: ; 34f60
ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar
cp EFFECT_MULTI_HIT
- jr z, .multihit
+ jr z, .alternate_anim
cp EFFECT_CONVERSION
- jr z, .conversion
+ jr z, .alternate_anim
cp EFFECT_DOUBLE_HIT
- jr z, .doublehit
+ jr z, .alternate_anim
cp EFFECT_POISON_MULTI_HIT
- jr z, .twineedle
+ jr z, .alternate_anim
cp EFFECT_TRIPLE_KICK
jr z, .triplekick
xor a
ld [wKickCounter], a
.triplekick
-
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
ld e, a
@@ -2167,18 +2130,13 @@ BattleCommand_HitTargetNoSub: ; 34f60
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
cp FLY
- jr z, .fly_dig
+ jr z, .clear_sprite
cp DIG
ret nz
-
-.fly_dig
-; clear sprite
+.clear_sprite
jp AppearUserLowerSub
-.multihit
-.conversion
-.doublehit
-.twineedle
+.alternate_anim
ld a, [wKickCounter]
and 1
xor 1
@@ -2713,7 +2671,7 @@ BattleCommand_RageDamage: ; 3527b
dec a
add hl, bc
jr nc, .rage_loop
- ld hl, -1
+ ld hl, $ffff
.done
ld a, h
ld [wCurDamage], a
@@ -3136,225 +3094,7 @@ EnemyAttackDamage: ; 353f6
; 35461
-BattleCommand_BeatUp: ; 35461
-; beatup
-
- call ResetDamage
- ld a, [hBattleTurn]
- and a
- jp nz, .enemy_beats_up
- ld a, [wPlayerSubStatus3]
- bit SUBSTATUS_IN_LOOP, a
- jr nz, .next_mon
- ld c, 20
- call DelayFrames
- xor a
- ld [wPlayerRolloutCount], a
- ld [wd002], a
- ld [wBeatUpHitAtLeastOnce], a
- jr .got_mon
-
-.next_mon
- ld a, [wPlayerRolloutCount]
- ld b, a
- ld a, [wPartyCount]
- sub b
- ld [wd002], a
-
-.got_mon
- ld a, [wd002]
- ld hl, wPartyMonNicknames
- call GetNick
- ld a, MON_HP
- call GetBeatupMonLocation
- ld a, [hli]
- or [hl]
- jp z, .beatup_fail ; fainted
- ld a, [wd002]
- ld c, a
- ld a, [wCurBattleMon]
- ; BUG: this can desynchronize link battles
- ; Change "cp [hl]" to "cp c" to fix
- cp [hl]
- ld hl, wBattleMonStatus
- jr z, .active_mon
- ld a, MON_STATUS
- call GetBeatupMonLocation
-.active_mon
- ld a, [hl]
- and a
- jp nz, .beatup_fail
-
- ld a, $1
- ld [wBeatUpHitAtLeastOnce], a
- ld hl, BeatUpAttackText
- call StdBattleTextBox
- ld a, [wEnemyMonSpecies]
- ld [wCurSpecies], a
- call GetBaseData
- ld a, [wBaseDefense]
- ld c, a
- push bc
- ld a, MON_SPECIES
- call GetBeatupMonLocation
- ld a, [hl]
- ld [wCurSpecies], a
- call GetBaseData
- ld a, [wBaseAttack]
- pop bc
- ld b, a
- push bc
- ld a, MON_LEVEL
- call GetBeatupMonLocation
- ld a, [hl]
- ld e, a
- pop bc
- ld a, [wPlayerMoveStructPower]
- ld d, a
- ret
-
-.enemy_beats_up
- ld a, [wEnemySubStatus3]
- bit SUBSTATUS_IN_LOOP, a
- jr nz, .not_first_enemy_beatup
-
- xor a
- ld [wEnemyRolloutCount], a
- ld [wd002], a
- ld [wBeatUpHitAtLeastOnce], a
- jr .enemy_continue
-
-.not_first_enemy_beatup
- ld a, [wEnemyRolloutCount]
- ld b, a
- ld a, [wOTPartyCount]
- sub b
- ld [wd002], a
-.enemy_continue
- ld a, [wBattleMode]
- dec a
- jr z, .wild
-
- ld a, [wLinkMode]
- and a
- jr nz, .link_or_tower
-
- ld a, [wInBattleTowerBattle]
- and a
- jr nz, .link_or_tower
-
- ld a, [wd002]
- ld c, a
- ld b, 0
- ld hl, wOTPartySpecies
- add hl, bc
- ld a, [hl]
- ld [wNamedObjectIndexBuffer], a
- call GetPokemonName
- jr .got_enemy_nick
-
-.link_or_tower
- ld a, [wd002]
- ld hl, wOTPartyMonNicknames
- ld bc, NAME_LENGTH
- call AddNTimes
- ld de, wStringBuffer1
- call CopyBytes
-.got_enemy_nick
- ld a, MON_HP
- call GetBeatupMonLocation
- ld a, [hli]
- or [hl]
- jp z, .beatup_fail
- ld a, [wd002]
- ld b, a
- ld a, [wCurOTMon]
- cp b
- ld hl, wEnemyMonStatus
- jr z, .active_enemy
-
- ld a, MON_STATUS
- call GetBeatupMonLocation
-.active_enemy
- ld a, [hl]
- and a
- jr nz, .beatup_fail
-
- ld a, $1
- ld [wBeatUpHitAtLeastOnce], a
- jr .finish_beatup
-
-.wild
- ld a, [wEnemyMonSpecies]
- ld [wNamedObjectIndexBuffer], a
- call GetPokemonName
- ld hl, BeatUpAttackText
- call StdBattleTextBox
- jp EnemyAttackDamage
-
-.finish_beatup
- ld hl, BeatUpAttackText
- call StdBattleTextBox
- ld a, [wBattleMonSpecies]
- ld [wCurSpecies], a
- call GetBaseData
- ld a, [wBaseDefense]
- ld c, a
- push bc
- ld a, MON_SPECIES
- call GetBeatupMonLocation
- ld a, [hl]
- ld [wCurSpecies], a
- call GetBaseData
- ld a, [wBaseAttack]
- pop bc
- ld b, a
- push bc
- ld a, MON_LEVEL
- call GetBeatupMonLocation
- ld a, [hl]
- ld e, a
- pop bc
- ld a, [wEnemyMoveStructPower]
- ld d, a
- ret
-
-; 355b0
-
-
-.beatup_fail ; 355b0
- ld b, buildopponentrage_command
- jp SkipToBattleCommand
-
-; 355b5
-
-
-BattleCommanda8: ; 355b5
- ld a, [wBeatUpHitAtLeastOnce]
- and a
- ret nz
-
- jp PrintButItFailed
-
-; 355bd
-
-
-GetBeatupMonLocation: ; 355bd
- push bc
- ld c, a
- ld b, 0
- ld a, [hBattleTurn]
- and a
- ld hl, wPartyMon1Species
- jr z, .got_species
- ld hl, wOTPartyMon1Species
-
-.got_species
- ld a, [wd002]
- add hl, bc
- call GetPartyLocation
- pop bc
- ret
+INCLUDE "engine/battle/move_effects/beat_up.asm"
BattleCommand_ClearMissDamage: ; 355d5
@@ -3642,7 +3382,7 @@ BattleCommand_DamageCalc: ; 35612
; 35703
-INCLUDE "data/battle/type_boost_items.asm"
+INCLUDE "data/types/type_boost_items.asm"
BattleCommand_ConstantDamage: ; 35726
@@ -3691,7 +3431,7 @@ BattleCommand_ConstantDamage: ; 35726
cp b
jr nc, .psywave_loop
ld b, a
- ld a, $0
+ ld a, 0
jr .got_power
.super_fang
@@ -3712,9 +3452,9 @@ BattleCommand_ConstantDamage: ; 35726
and a
jr nz, .got_power
or b
- ld a, $0
+ ld a, 0
jr nz, .got_power
- ld b, $1
+ ld b, 1
jr .got_power
.got_power
@@ -3766,11 +3506,11 @@ BattleCommand_ConstantDamage: ; 35726
ld [hDividend + 2], a
.skip_to_divide
- ld b, $4
+ ld b, 4
call Divide
ld a, [hQuotient + 2]
ld b, a
- ld hl, .FlailPower
+ ld hl, FlailReversalPower
.reversal_loop
ld a, [hli]
@@ -3803,529 +3543,22 @@ BattleCommand_ConstantDamage: ; 35726
ld [hl], 1
ret
-.FlailPower:
- ; px, bp
- db 1, 200
- db 4, 150
- db 9, 100
- db 16, 80
- db 32, 40
- db 48, 20
-; 35813
-
-
-BattleCommand_Counter: ; 35813
-; counter
-
- ld a, 1
- ld [wAttackMissed], a
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
- call GetBattleVar
- and a
- ret z
-
- ld b, a
- callfar GetMoveEffect
- ld a, b
- cp EFFECT_COUNTER
- ret z
-
- call BattleCommand_ResetTypeMatchup
- ld a, [wTypeMatchup]
- and a
- ret z
-
- call CheckOpponentWentFirst
- ret z
-
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
- call GetBattleVar
- dec a
- ld de, wStringBuffer1
- call GetMoveData
-
- ld a, [wStringBuffer1 + MOVE_POWER]
- and a
- ret z
-
- ld a, [wStringBuffer1 + MOVE_TYPE]
- cp SPECIAL
- ret nc
-
- ld hl, wCurDamage
- ld a, [hli]
- or [hl]
- ret z
-
- ld a, [hl]
- add a
- ld [hld], a
- ld a, [hl]
- adc a
- ld [hl], a
- jr nc, .capped
- ld a, $ff
- ld [hli], a
- ld [hl], a
-.capped
-
- xor a
- ld [wAttackMissed], a
- ret
-
-; 35864
-
-
-BattleCommand_Encore: ; 35864
-; encore
-
- ld hl, wEnemyMonMoves
- ld de, wEnemyEncoreCount
- ld a, [hBattleTurn]
- and a
- jr z, .ok
- ld hl, wBattleMonMoves
- ld de, wPlayerEncoreCount
-.ok
- ld a, BATTLE_VARS_LAST_MOVE_OPP
- call GetBattleVar
- and a
- jp z, .failed
- cp STRUGGLE
- jp z, .failed
- cp ENCORE
- jp z, .failed
- cp MIRROR_MOVE
- jp z, .failed
- ld b, a
-
-.got_move
- ld a, [hli]
- cp b
- jr nz, .got_move
-
- ld bc, wBattleMonPP - wBattleMonMoves - 1
- add hl, bc
- ld a, [hl]
- and PP_MASK
- jp z, .failed
- ld a, [wAttackMissed]
- and a
- jp nz, .failed
- ld a, BATTLE_VARS_SUBSTATUS5_OPP
- call GetBattleVarAddr
- bit SUBSTATUS_ENCORED, [hl]
- jp nz, .failed
- set SUBSTATUS_ENCORED, [hl]
- call BattleRandom
- and $3
- inc a
- inc a
- inc a
- ld [de], a
- call CheckOpponentWentFirst
- jr nz, .finish_move
- ld a, [hBattleTurn]
- and a
- jr z, .force_last_enemy_move
-
- push hl
- ld a, [wLastPlayerMove]
- ld b, a
- ld c, 0
- ld hl, wBattleMonMoves
-.find_player_move
- ld a, [hli]
- cp b
- jr z, .got_player_move
- inc c
- ld a, c
- cp NUM_MOVES
- jr c, .find_player_move
- pop hl
- res SUBSTATUS_ENCORED, [hl]
- xor a
- ld [de], a
- jr .failed
-
-.got_player_move
- pop hl
- ld a, c
- ld [wCurMoveNum], a
- ld a, b
- ld [wCurPlayerMove], a
- dec a
- ld de, wPlayerMoveStruct
- call GetMoveData
- jr .finish_move
-
-.force_last_enemy_move
- push hl
- ld a, [wLastEnemyMove]
- ld b, a
- ld c, 0
- ld hl, wEnemyMonMoves
-.find_enemy_move
- ld a, [hli]
- cp b
- jr z, .got_enemy_move
- inc c
- ld a, c
- cp NUM_MOVES
- jr c, .find_enemy_move
- pop hl
- res SUBSTATUS_ENCORED, [hl]
- xor a
- ld [de], a
- jr .failed
-
-.got_enemy_move
- pop hl
- ld a, c
- ld [wCurEnemyMoveNum], a
- ld a, b
- ld [wCurEnemyMove], a
- dec a
- ld de, wEnemyMoveStruct
- call GetMoveData
-
-.finish_move
- call AnimateCurrentMove
- ld hl, GotAnEncoreText
- jp StdBattleTextBox
-
-.failed
- jp PrintDidntAffect2
-
-; 35926
-
-
-BattleCommand_PainSplit: ; 35926
-; painsplit
-
- ld a, [wAttackMissed]
- and a
- jp nz, .ButItFailed
- call CheckSubstituteOpp
- jp nz, .ButItFailed
- call AnimateCurrentMove
- ld hl, wBattleMonMaxHP + 1
- ld de, wEnemyMonMaxHP + 1
- call .PlayerShareHP
- ld a, $1
- ld [wWhichHPBar], a
- hlcoord 10, 9
- predef AnimateHPBar
- ld hl, wEnemyMonHP
- ld a, [hli]
- ld [wBuffer4], a
- ld a, [hli]
- ld [wBuffer3], a
- ld a, [hli]
- ld [wBuffer2], a
- ld a, [hl]
- ld [wBuffer1], a
- call .EnemyShareHP
- xor a
- ld [wWhichHPBar], a
- call ResetDamage
- hlcoord 2, 2
- predef AnimateHPBar
- farcall _UpdateBattleHUDs
-
- ld hl, SharedPainText
- jp StdBattleTextBox
-
-.PlayerShareHP:
- ld a, [hld]
- ld [wBuffer1], a
- ld a, [hld]
- ld [wBuffer2], a
- ld a, [hld]
- ld b, a
- ld [wBuffer3], a
- ld a, [hl]
- ld [wBuffer4], a
- dec de
- dec de
- ld a, [de]
- dec de
- add b
- ld [wCurDamage + 1], a
- ld b, [hl]
- ld a, [de]
- adc b
- srl a
- ld [wCurDamage], a
- ld a, [wCurDamage + 1]
- rr a
- ld [wCurDamage + 1], a
- inc hl
- inc hl
- inc hl
- inc de
- inc de
- inc de
-
-.EnemyShareHP: ; 359ac
- ld c, [hl]
- dec hl
- ld a, [wCurDamage + 1]
- sub c
- ld b, [hl]
- dec hl
- ld a, [wCurDamage]
- sbc b
- jr nc, .skip
-
- ld a, [wCurDamage]
- ld b, a
- ld a, [wCurDamage + 1]
- ld c, a
-.skip
- ld a, c
- ld [hld], a
- ld [wBuffer5], a
- ld a, b
- ld [hli], a
- ld [wBuffer6], a
- ret
-
-; 359cd
-
-.ButItFailed:
- jp PrintDidntAffect2
-
-; 359d0
-
-
-BattleCommand_Snore: ; 359d0
-; snore
- ld a, BATTLE_VARS_STATUS
- call GetBattleVar
- and SLP
- ret nz
- call ResetDamage
- ld a, $1
- ld [wAttackMissed], a
- call FailSnore
- jp EndMoveEffect
-
-; 359e6
-
-
-BattleCommand_Conversion2: ; 359e6
-; conversion2
-
- ld a, [wAttackMissed]
- and a
- jr nz, .failed
- ld hl, wBattleMonType1
- ld a, [hBattleTurn]
- and a
- jr z, .got_type
- ld hl, wEnemyMonType1
-.got_type
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
- call GetBattleVar
- and a
- jr z, .failed
- push hl
- dec a
- ld hl, Moves + MOVE_TYPE
- call GetMoveAttr
- ld d, a
- pop hl
- cp CURSE_T
- jr z, .failed
- call AnimateCurrentMove
- call BattleCommand_SwitchTurn
-
-.loop
- call BattleRandom
- and $1f
- cp UNUSED_TYPES
- jr c, .okay
- cp UNUSED_TYPES_END
- jr c, .loop
- cp TYPES_END
- jr nc, .loop
-.okay
- ld [hli], a
- ld [hld], a
- push hl
- ld a, BATTLE_VARS_MOVE_TYPE
- call GetBattleVarAddr
- push af
- push hl
- ld a, d
- ld [hl], a
- call BattleCheckTypeMatchup
- pop hl
- pop af
- ld [hl], a
- pop hl
- ld a, [wTypeMatchup]
- cp 10
- jr nc, .loop
- call BattleCommand_SwitchTurn
-
- ld a, [hl]
- ld [wNamedObjectIndexBuffer], a
- predef GetTypeName
- ld hl, TransformedTypeText
- jp StdBattleTextBox
-
-.failed
- jp FailConversion2
-
-; 35a53
-
-
-BattleCommand_LockOn: ; 35a53
-; lockon
+INCLUDE "data/moves/flail_reversal_power.asm"
- call CheckSubstituteOpp
- jr nz, .fail
- ld a, [wAttackMissed]
- and a
- jr nz, .fail
-
- ld a, BATTLE_VARS_SUBSTATUS5_OPP
- call GetBattleVarAddr
- set SUBSTATUS_LOCK_ON, [hl]
- call AnimateCurrentMove
+INCLUDE "engine/battle/move_effects/counter.asm"
- ld hl, TookAimText
- jp StdBattleTextBox
+INCLUDE "engine/battle/move_effects/encore.asm"
-.fail
- call AnimateFailedMove
- jp PrintDidntAffect
+INCLUDE "engine/battle/move_effects/pain_split.asm"
-; 35a74
+INCLUDE "engine/battle/move_effects/snore.asm"
+INCLUDE "engine/battle/move_effects/conversion2.asm"
-BattleCommand_Sketch: ; 35a74
-; sketch
+INCLUDE "engine/battle/move_effects/lock_on.asm"
- call ClearLastMove
-; Don't sketch during a link battle
- ld a, [wLinkMode]
- and a
- jr z, .not_linked
- call AnimateFailedMove
- jp PrintNothingHappened
-
-.not_linked
-; If the opponent has a substitute up, fail.
- call CheckSubstituteOpp
- jp nz, .fail
-; If the opponent is transformed, fail.
- ld a, BATTLE_VARS_SUBSTATUS5_OPP
- call GetBattleVarAddr
- bit SUBSTATUS_TRANSFORMED, [hl]
- jp nz, .fail
-; Get the user's moveset in its party struct.
-; This move replacement shall be permanent.
-; Pointer will be in de.
- ld a, MON_MOVES
- call UserPartyAttr
- ld d, h
- ld e, l
-; Get the battle move structs.
- ld hl, wBattleMonMoves
- ld a, [hBattleTurn]
- and a
- jr z, .get_last_move
- ld hl, wEnemyMonMoves
-.get_last_move
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
- call GetBattleVar
- ld [wTypeMatchup], a
- ld b, a
-; Fail if move is invalid or is Struggle.
- and a
- jr z, .fail
- cp STRUGGLE
- jr z, .fail
-; Fail if user already knows that move
- ld c, NUM_MOVES
-.does_user_already_know_move
- ld a, [hli]
- cp b
- jr z, .fail
- dec c
- jr nz, .does_user_already_know_move
-; Find Sketch in the user's moveset.
-; Pointer in hl, and index in c.
- dec hl
- ld c, NUM_MOVES
-.find_sketch
- dec c
- ld a, [hld]
- cp SKETCH
- jr nz, .find_sketch
- inc hl
-; The Sketched move is loaded to that slot.
- ld a, b
- ld [hl], a
-; Copy the base PP from that move.
- push bc
- push hl
- dec a
- ld hl, Moves + MOVE_PP
- call GetMoveAttr
- pop hl
- ld bc, wBattleMonPP - wBattleMonMoves
- add hl, bc
- ld [hl], a
- pop bc
-
- ld a, [hBattleTurn]
- and a
- jr z, .user_trainer
- ld a, [wBattleMode]
- dec a
- jr nz, .user_trainer
-; wildmon
- ld a, [hl]
- push bc
- ld hl, wWildMonPP
- ld b, 0
- add hl, bc
- ld [hl], a
- ld hl, wWildMonMoves
- add hl, bc
- pop bc
- ld [hl], b
- jr .done_copy
-
-.user_trainer
- ld a, [hl]
- push af
- ld l, c
- ld h, 0
- add hl, de
- ld a, b
- ld [hl], a
- pop af
- ld de, MON_PP - MON_MOVES
- add hl, de
- ld [hl], a
-.done_copy
- call GetMoveName
- call AnimateCurrentMove
-
- ld hl, SketchedText
- jp StdBattleTextBox
-
-.fail
- call AnimateFailedMove
- jp PrintDidntAffect
-
-; 35b16
+INCLUDE "engine/battle/move_effects/sketch.asm"
BattleCommand_DefrostOpponent: ; 35b16
@@ -4357,338 +3590,15 @@ BattleCommand_DefrostOpponent: ; 35b16
; 35b33
-BattleCommand_SleepTalk: ; 35b33
-; sleeptalk
-
- call ClearLastMove
- ld a, [wAttackMissed]
- and a
- jr nz, .fail
- ld a, [hBattleTurn]
- and a
- ld hl, wBattleMonMoves + 1
- ld a, [wDisabledMove]
- ld d, a
- jr z, .got_moves
- ld hl, wEnemyMonMoves + 1
- ld a, [wEnemyDisabledMove]
- ld d, a
-.got_moves
- ld a, BATTLE_VARS_STATUS
- call GetBattleVar
- and SLP
- jr z, .fail
- ld a, [hl]
- and a
- jr z, .fail
- call .safely_check_has_usable_move
- jr c, .fail
- dec hl
-.sample_move
- push hl
- call BattleRandom
- maskbits NUM_MOVES
- ld c, a
- ld b, 0
- add hl, bc
- ld a, [hl]
- pop hl
- and a
- jr z, .sample_move
- ld e, a
- ld a, BATTLE_VARS_MOVE_ANIM
- call GetBattleVar
- cp e
- jr z, .sample_move
- ld a, e
- cp d
- jr z, .sample_move
- call .check_two_turn_move
- jr z, .sample_move
- ld a, BATTLE_VARS_MOVE
- call GetBattleVarAddr
- ld a, e
- ld [hl], a
- call CheckUserIsCharging
- jr nz, .charging
- ld a, [wKickCounter]
- push af
- call BattleCommand_LowerSub
- pop af
- ld [wKickCounter], a
-.charging
- call LoadMoveAnim
- call UpdateMoveData
- jp ResetTurn
-
-.fail
- call AnimateFailedMove
- jp TryPrintButItFailed
-
-.safely_check_has_usable_move
- push hl
- push de
- push bc
- call .check_has_usable_move
- pop bc
- pop de
- pop hl
- ret
-
-.check_has_usable_move
- ld a, [hBattleTurn]
- and a
- ld a, [wDisabledMove]
- jr z, .got_move_2
-
- ld a, [wEnemyDisabledMove]
-.got_move_2
- ld b, a
- ld a, BATTLE_VARS_MOVE
- call GetBattleVar
- ld c, a
- dec hl
- ld d, NUM_MOVES
-.loop2
- ld a, [hl]
- and a
- jr z, .carry
-
- cp c
- jr z, .nope
- cp b
- jr z, .nope
-
- call .check_two_turn_move
- jr nz, .no_carry
-
-.nope
- inc hl
- dec d
- jr nz, .loop2
-
-.carry
- scf
- ret
-
-.no_carry
- and a
- ret
-
-.check_two_turn_move
- push hl
- push de
- push bc
-
- ld b, a
- callfar GetMoveEffect
- ld a, b
-
- pop bc
- pop de
- pop hl
-
- cp EFFECT_SKULL_BASH
- ret z
- cp EFFECT_RAZOR_WIND
- ret z
- cp EFFECT_SKY_ATTACK
- ret z
- cp EFFECT_SOLARBEAM
- ret z
- cp EFFECT_FLY
- ret z
- cp EFFECT_BIDE
- ret
-
-; 35bff
-
-
-BattleCommand_DestinyBond: ; 35bff
-; destinybond
-
- ld a, BATTLE_VARS_SUBSTATUS5
- call GetBattleVarAddr
- set SUBSTATUS_DESTINY_BOND, [hl]
- call AnimateCurrentMove
- ld hl, DestinyBondEffectText
- jp StdBattleTextBox
-
-; 35c0f
-
-
-BattleCommand_Spite: ; 35c0f
-; spite
-
- ld a, [wAttackMissed]
- and a
- jp nz, .failed
- ld bc, PARTYMON_STRUCT_LENGTH ; ????
- ld hl, wEnemyMonMoves
- ld a, [hBattleTurn]
- and a
- jr z, .got_moves
- ld hl, wBattleMonMoves
-.got_moves
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
- call GetBattleVar
- and a
- jr z, .failed
- cp STRUGGLE
- jr z, .failed
- ld b, a
- ld c, -1
-.loop
- inc c
- ld a, [hli]
- cp b
- jr nz, .loop
- ld [wTypeMatchup], a
- dec hl
- ld b, 0
- push bc
- ld c, wBattleMonPP - wBattleMonMoves
- add hl, bc
- pop bc
- ld a, [hl]
- and PP_MASK
- jr z, .failed
- push bc
- call GetMoveName
- ; lose 2-5 PP
- call BattleRandom
- and %11
- inc a
- inc a
- ld b, a
- ld a, [hl]
- and PP_MASK
- cp b
- jr nc, .deplete_pp
- ld b, a
-.deplete_pp
- ld a, [hl]
- sub b
- ld [hl], a
- push af
- ld a, MON_PP
- call OpponentPartyAttr
- ld d, b
- pop af
- pop bc
- add hl, bc
- ld e, a
- ld a, BATTLE_VARS_SUBSTATUS5_OPP
- call GetBattleVar
- bit SUBSTATUS_TRANSFORMED, a
- jr nz, .transformed
- ld a, [hBattleTurn]
- and a
- jr nz, .not_wildmon
- ld a, [wBattleMode]
- dec a
- jr nz, .not_wildmon
- ld hl, wWildMonPP
- add hl, bc
-.not_wildmon
- ld [hl], e
-.transformed
- push de
- call AnimateCurrentMove
- pop de
- ld a, d
- ld [wTypeMatchup], a
- ld hl, SpiteEffectText
- jp StdBattleTextBox
-
-.failed
- jp PrintDidntAffect2
-
-; 35c94
+INCLUDE "engine/battle/move_effects/sleep_talk.asm"
+INCLUDE "engine/battle/move_effects/destiny_bond.asm"
-BattleCommand_FalseSwipe: ; 35c94
-; falseswipe
+INCLUDE "engine/battle/move_effects/spite.asm"
- ld hl, wEnemyMonHP
- ld a, [hBattleTurn]
- and a
- jr z, .got_hp
- ld hl, wBattleMonHP
-.got_hp
- ld de, wCurDamage
- ld c, 2
- push hl
- push de
- call StringCmp
- pop de
- pop hl
- jr c, .done
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hl]
- dec a
- ld [de], a
- inc a
- jr nz, .okay
- dec de
- ld a, [de]
- dec a
- ld [de], a
-.okay
- ld a, [wCriticalHit]
- cp 2
- jr nz, .carry
- xor a
- ld [wCriticalHit], a
-.carry
- scf
- ret
+INCLUDE "engine/battle/move_effects/false_swipe.asm"
-.done
- and a
- ret
-
-; 35cc9
-
-
-BattleCommand_HealBell: ; 35cc9
-; healbell
-
- ld a, BATTLE_VARS_SUBSTATUS1
- call GetBattleVarAddr
- res SUBSTATUS_NIGHTMARE, [hl]
- ld de, wPartyMon1Status
- ld a, [hBattleTurn]
- and a
- jr z, .got_status
- ld de, wOTPartyMon1Status
-.got_status
- ld a, BATTLE_VARS_STATUS
- call GetBattleVarAddr
- xor a
- ld [hl], a
- ld h, d
- ld l, e
- ld bc, PARTYMON_STRUCT_LENGTH
- ld d, PARTY_LENGTH
-.loop
- ld [hl], a
- add hl, bc
- dec d
- jr nz, .loop
- call AnimateCurrentMove
-
- ld hl, BellChimedText
- call StdBattleTextBox
-
- ld a, [hBattleTurn]
- and a
- jp z, CalcPlayerStats
- jp CalcEnemyStats
-
-; 35d00
+INCLUDE "engine/battle/move_effects/heal_bell.asm"
FarPlayBattleAnimation: ; 35d00
@@ -5101,25 +4011,25 @@ BattleCommand_Poison: ; 35f2c
ld a, [hBattleTurn]
and a
- jr z, .mimic_random
+ jr z, .dont_sample_failure
ld a, [wLinkMode]
and a
- jr nz, .mimic_random
+ jr nz, .dont_sample_failure
ld a, [wInBattleTowerBattle]
and a
- jr nz, .mimic_random
+ jr nz, .dont_sample_failure
ld a, [wPlayerSubStatus5]
bit SUBSTATUS_LOCK_ON, a
- jr nz, .mimic_random
+ jr nz, .dont_sample_failure
call BattleRandom
cp 25 percent + 1 ; 25% chance AI fails
jr c, .failed
-.mimic_random
+.dont_sample_failure
call CheckSubstituteOpp
jr nz, .failed
ld a, [wAttackMissed]
@@ -6385,111 +5295,7 @@ CalcStats: ; 3661d
; 36671
-BattleCommand_StoreEnergy: ; 36671
-; storeenergy
-
- ld a, BATTLE_VARS_SUBSTATUS3
- call GetBattleVar
- bit SUBSTATUS_BIDE, a
- ret z
-
- ld hl, wPlayerRolloutCount
- ld a, [hBattleTurn]
- and a
- jr z, .check_still_storing_energy
- ld hl, wEnemyRolloutCount
-.check_still_storing_energy
- dec [hl]
- jr nz, .still_storing
-
- ld a, BATTLE_VARS_SUBSTATUS3
- call GetBattleVarAddr
- res SUBSTATUS_BIDE, [hl]
-
- ld hl, UnleashedEnergyText
- call StdBattleTextBox
-
- ld a, BATTLE_VARS_MOVE_POWER
- call GetBattleVarAddr
- ld a, 1
- ld [hl], a
- ld hl, wPlayerDamageTaken + 1
- ld de, wPlayerCharging ; player
- ld a, [hBattleTurn]
- and a
- jr z, .player
- ld hl, wEnemyDamageTaken + 1
- ld de, wEnemyCharging ; enemy
-.player
- ld a, [hld]
- add a
- ld b, a
- ld [wCurDamage + 1], a
- ld a, [hl]
- rl a
- ld [wCurDamage], a
- jr nc, .not_maxed
- ld a, $ff
- ld [wCurDamage], a
- ld [wCurDamage + 1], a
-.not_maxed
- or b
- jr nz, .built_up_something
- ld a, 1
- ld [wAttackMissed], a
-.built_up_something
- xor a
- ld [hli], a
- ld [hl], a
- ld [de], a
-
- ld a, BATTLE_VARS_MOVE_ANIM
- call GetBattleVarAddr
- ld a, BIDE
- ld [hl], a
-
- ld b, unleashenergy_command
- jp SkipToBattleCommand
-
-.still_storing
- ld hl, StoringEnergyText
- call StdBattleTextBox
- jp EndMoveEffect
-
-; 366e5
-
-
-BattleCommand_UnleashEnergy: ; 366e5
-; unleashenergy
-
- ld de, wPlayerDamageTaken
- ld bc, wPlayerRolloutCount
- ld a, [hBattleTurn]
- and a
- jr z, .got_damage
- ld de, wEnemyDamageTaken
- ld bc, wEnemyRolloutCount
-.got_damage
- ld a, BATTLE_VARS_SUBSTATUS3
- call GetBattleVarAddr
- set SUBSTATUS_BIDE, [hl]
- xor a
- ld [de], a
- inc de
- ld [de], a
- ld [wPlayerMoveStructEffect], a
- ld [wEnemyMoveStructEffect], a
- call BattleRandom
- and 1
- inc a
- inc a
- ld [bc], a
- ld a, 1
- ld [wKickCounter], a
- call AnimateCurrentMove
- jp EndMoveEffect
-
-; 3671a
+INCLUDE "engine/battle/move_effects/bide.asm"
BattleCommand_CheckRampage: ; 3671a
@@ -6562,97 +5368,7 @@ BattleCommand_Rampage: ; 36751
; 36778
-BattleCommand_Teleport: ; 36778
-; teleport
-
- ld a, [wBattleType]
- cp BATTLETYPE_SHINY
- jr z, .failed
- cp BATTLETYPE_TRAP
- jr z, .failed
- cp BATTLETYPE_CELEBI
- jr z, .failed
- cp BATTLETYPE_SUICUNE
- jr z, .failed
-
- ld a, BATTLE_VARS_SUBSTATUS5_OPP
- call GetBattleVar
- bit SUBSTATUS_CANT_RUN, a
- jr nz, .failed
-; Only need to check these next things if it's your turn
- ld a, [hBattleTurn]
- and a
- jr nz, .enemy_turn
-; Can't teleport from a trainer battle
- ld a, [wBattleMode]
- dec a
- jr nz, .failed
-; If your level is greater than the opponent's, you run without fail.
- ld a, [wCurPartyLevel]
- ld b, a
- ld a, [wBattleMonLevel]
- cp b
- jr nc, .run_away
-; Generate a number between 0 and (YourLevel + TheirLevel).
- add b
- ld c, a
- inc c
-.loop_player
- call BattleRandom
- cp c
- jr nc, .loop_player
-; If that number is greater than 4 times your level, run away.
- srl b
- srl b
- cp b
- jr nc, .run_away
-
-.failed
- call AnimateFailedMove
- jp PrintButItFailed
-
-.enemy_turn
- ld a, [wBattleMode]
- dec a
- jr nz, .failed
- ld a, [wBattleMonLevel]
- ld b, a
- ld a, [wCurPartyLevel]
- cp b
- jr nc, .run_away
- add b
- ld c, a
- inc c
-.loop_enemy
- call BattleRandom
- cp c
- jr nc, .loop_enemy
- srl b
- srl b
- cp b
- ; 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
- jr nc, .run_away
-.run_away
- call UpdateBattleMonInParty
- xor a
- ld [wNumHits], a
- inc a
- ld [wForcedSwitch], a
- ld [wKickCounter], a
- call SetBattleDraw
- call BattleCommand_LowerSub
- call LoadMoveAnim
- ld c, 20
- call DelayFrames
- call SetBattleDraw
-
- ld hl, FledFromBattleText
- jp StdBattleTextBox
-
-; 36804
+INCLUDE "engine/battle/move_effects/teleport.asm"
SetBattleDraw: ; 36804
@@ -7301,7 +6017,7 @@ BattleCommand_Charge: ; 36b4d
jp EndMoveEffect
.UsedText:
- text_jump UnknownText_0x1c0d0e ; "[USER]"
+ text_jump UnknownText_0x1c0d0e ; "<USER>"
start_asm
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
@@ -7428,42 +6144,9 @@ BattleCommand_TrapTarget: ; 36c2d
; 36c7e
-BattleCommand_Mist: ; 36c7e
-; mist
-
- ld a, BATTLE_VARS_SUBSTATUS4
- call GetBattleVarAddr
- bit SUBSTATUS_MIST, [hl]
- jr nz, .already_mist
- set SUBSTATUS_MIST, [hl]
- call AnimateCurrentMove
- ld hl, MistText
- jp StdBattleTextBox
-
-.already_mist
- call AnimateFailedMove
- jp PrintButItFailed
-
-; 36c98
-
-
-BattleCommand_FocusEnergy: ; 36c98
-; focusenergy
-
- ld a, BATTLE_VARS_SUBSTATUS4
- call GetBattleVarAddr
- bit SUBSTATUS_FOCUS_ENERGY, [hl]
- jr nz, .already_pumped
- set SUBSTATUS_FOCUS_ENERGY, [hl]
- call AnimateCurrentMove
- ld hl, GettingPumpedText
- jp StdBattleTextBox
-
-.already_pumped
- call AnimateFailedMove
- jp PrintButItFailed
+INCLUDE "engine/battle/move_effects/mist.asm"
-; 36cb2
+INCLUDE "engine/battle/move_effects/focus_energy.asm"
BattleCommand_Recoil: ; 36cb2
@@ -7681,7 +6364,7 @@ BattleCommand_Paralyze: ; 36dc7
jr nz, .dont_sample_failure
call BattleRandom
- cp 1 + 25 percent
+ cp 25 percent + 1 ; 25% chance AI fails
jr c, .failed
.dont_sample_failure
@@ -7763,96 +6446,8 @@ CheckMoveTypeMatchesTarget: ; 36e5b
; 36e7c
-BattleCommand_Substitute: ; 36e7c
-; substitute
+INCLUDE "engine/battle/move_effects/substitute.asm"
- call BattleCommand_MoveDelay
- ld hl, wBattleMonMaxHP
- ld de, wPlayerSubstituteHP
- ld a, [hBattleTurn]
- and a
- jr z, .got_hp
- ld hl, wEnemyMonMaxHP
- ld de, wEnemySubstituteHP
-.got_hp
-
- ld a, BATTLE_VARS_SUBSTATUS4
- call GetBattleVar
- bit SUBSTATUS_SUBSTITUTE, a
- jr nz, .already_has_sub
-
- ld a, [hli]
- ld b, [hl]
- srl a
- rr b
- srl a
- rr b
- dec hl
- dec hl
- ld a, b
- ld [de], a
- ld a, [hld]
- sub b
- ld e, a
- ld a, [hl]
- sbc 0
- ld d, a
- jr c, .too_weak_to_sub
- ld a, d
- or e
- jr z, .too_weak_to_sub
- ld [hl], d
- inc hl
- ld [hl], e
-
- ld a, BATTLE_VARS_SUBSTATUS4
- call GetBattleVarAddr
- set SUBSTATUS_SUBSTITUTE, [hl]
-
- ld hl, wPlayerWrapCount
- ld de, wPlayerTrappingMove
- ld a, [hBattleTurn]
- and a
- jr z, .player
- ld hl, wEnemyWrapCount
- ld de, wEnemyTrappingMove
-.player
-
- xor a
- ld [hl], a
- ld [de], a
- call _CheckBattleScene
- jr c, .no_anim
-
- xor a
- ld [wNumHits], a
- ld [wFXAnimID + 1], a
- ld [wKickCounter], a
- ld a, SUBSTITUTE
- call LoadAnim
- jr .finish
-
-.no_anim
- call BattleCommand_RaiseSubNoAnim
-.finish
- ld hl, MadeSubstituteText
- call StdBattleTextBox
- jp RefreshBattleHuds
-
-.already_has_sub
- call CheckUserIsCharging
- call nz, BattleCommand_RaiseSub
- ld hl, HasSubstituteText
- jr .jp_stdbattletextbox
-
-.too_weak_to_sub
- call CheckUserIsCharging
- call nz, BattleCommand_RaiseSub
- ld hl, TooWeakSubText
-.jp_stdbattletextbox
- jp StdBattleTextBox
-
-; 36f0b
BattleCommand_RechargeNextTurn: ; 36f0b
; rechargenextturn
@@ -7875,14 +6470,7 @@ EndRechargeOpp: ; 36f13
; 36f1d
-BattleCommand_Rage: ; 36f1d
-; rage
- ld a, BATTLE_VARS_SUBSTATUS4
- call GetBattleVarAddr
- set SUBSTATUS_RAGE, [hl]
- ret
-
-; 36f25
+INCLUDE "engine/battle/move_effects/rage.asm"
BattleCommand_DoubleFlyingDamage: ; 36f25
@@ -7923,316 +6511,17 @@ DoubleDamage: ; 36f37
; 36f46
-BattleCommand_Mimic: ; 36f46
-; mimic
-
- call ClearLastMove
- call BattleCommand_MoveDelay
- ld a, [wAttackMissed]
- and a
- jr nz, .fail
- ld hl, wBattleMonMoves
- ld a, [hBattleTurn]
- and a
- jr z, .player_turn
- ld hl, wEnemyMonMoves
-.player_turn
- call CheckHiddenOpponent
- jr nz, .fail
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
- call GetBattleVar
- and a
- jr z, .fail
- cp STRUGGLE
- jr z, .fail
- ld b, a
- ld c, NUM_MOVES
-.check_already_knows_move
- ld a, [hli]
- cp b
- jr z, .fail
- dec c
- jr nz, .check_already_knows_move
- dec hl
-.find_mimic
- ld a, [hld]
- cp MIMIC
- jr nz, .find_mimic
- inc hl
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
- call GetBattleVar
- ld [hl], a
- ld [wNamedObjectIndexBuffer], a
- ld bc, wBattleMonPP - wBattleMonMoves
- add hl, bc
- ld [hl], 5
- call GetMoveName
- call AnimateCurrentMove
- ld hl, LearnedMoveText
- jp StdBattleTextBox
-
-.fail
- jp FailMimic
-
-; 36f9d
-
-
-BattleCommand_LeechSeed: ; 36f9d
-; leechseed
- ld a, [wAttackMissed]
- and a
- jr nz, .evaded
- call CheckSubstituteOpp
- jr nz, .evaded
-
- ld de, wEnemyMonType1
- ld a, [hBattleTurn]
- and a
- jr z, .ok
- ld de, wBattleMonType1
-.ok
-
- ld a, [de]
- cp GRASS
- jr z, .grass
- inc de
- ld a, [de]
- cp GRASS
- jr z, .grass
-
- ld a, BATTLE_VARS_SUBSTATUS4_OPP
- call GetBattleVarAddr
- bit SUBSTATUS_LEECH_SEED, [hl]
- jr nz, .evaded
- set SUBSTATUS_LEECH_SEED, [hl]
- call AnimateCurrentMove
- ld hl, WasSeededText
- jp StdBattleTextBox
-
-.grass
- call AnimateFailedMove
- jp PrintDoesntAffect
-
-.evaded
- call AnimateFailedMove
- ld hl, EvadedText
- jp StdBattleTextBox
-
-; 36fe1
-
-
-BattleCommand_Splash: ; 36fe1
- call AnimateCurrentMove
- farcall StubbedTrainerRankings_Splash
- jp PrintNothingHappened
-
-; 36fed
-
-
-BattleCommand_Disable: ; 36fed
-; disable
-
- ld a, [wAttackMissed]
- and a
- jr nz, .failed
-
- ld de, wEnemyDisableCount
- ld hl, wEnemyMonMoves
- ld a, [hBattleTurn]
- and a
- jr z, .got_moves
- ld de, wPlayerDisableCount
- ld hl, wBattleMonMoves
-.got_moves
-
- ld a, [de]
- and a
- jr nz, .failed
-
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
- call GetBattleVar
- and a
- jr z, .failed
- cp STRUGGLE
- jr z, .failed
-
- ld b, a
- ld c, $ff
-.loop
- inc c
- ld a, [hli]
- cp b
- jr nz, .loop
-
- ld a, [hBattleTurn]
- and a
- ld hl, wEnemyMonPP
- jr z, .got_pp
- ld hl, wBattleMonPP
-.got_pp
- ld b, 0
- add hl, bc
- ld a, [hl]
- and a
- jr z, .failed
-.loop2
- call BattleRandom
- and 7
- jr z, .loop2
- inc a
- inc c
- swap c
- add c
- ld [de], a
- call AnimateCurrentMove
- ld hl, wDisabledMove
- ld a, [hBattleTurn]
- and a
- jr nz, .got_disabled_move_pointer
- inc hl
-.got_disabled_move_pointer
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
- call GetBattleVar
- ld [hl], a
- ld [wNamedObjectIndexBuffer], a
- call GetMoveName
- ld hl, WasDisabledText
- jp StdBattleTextBox
-
-.failed
- jp FailDisable
-
-; 3705c
+INCLUDE "engine/battle/move_effects/mimic.asm"
+INCLUDE "engine/battle/move_effects/leech_seed.asm"
-BattleCommand_PayDay: ; 3705c
-; payday
-
- xor a
- ld hl, wStringBuffer1
- ld [hli], a
-
- ld a, [hBattleTurn]
- and a
- ld a, [wBattleMonLevel]
- jr z, .ok
- ld a, [wEnemyMonLevel]
-.ok
+INCLUDE "engine/battle/move_effects/splash.asm"
- add a
- ld hl, wPayDayMoney + 2
- add [hl]
- ld [hld], a
- jr nc, .done
- inc [hl]
- dec hl
- jr nz, .done
- inc [hl]
-.done
- ld hl, CoinsScatteredText
- jp StdBattleTextBox
+INCLUDE "engine/battle/move_effects/disable.asm"
-; 3707f
+INCLUDE "engine/battle/move_effects/pay_day.asm"
-
-BattleCommand_Conversion: ; 3707f
-; conversion
-
- ld hl, wBattleMonMoves
- ld de, wBattleMonType1
- ld a, [hBattleTurn]
- and a
- jr z, .got_moves
- ld hl, wEnemyMonMoves
- ld de, wEnemyMonType1
-.got_moves
- push de
- ld c, 0
- ld de, wStringBuffer1
-.loop
- push hl
- ld b, 0
- add hl, bc
- ld a, [hl]
- pop hl
- and a
- jr z, .okay
- push hl
- push bc
- dec a
- ld hl, Moves + MOVE_TYPE
- call GetMoveAttr
- ld [de], a
- inc de
- pop bc
- pop hl
- inc c
- ld a, c
- cp NUM_MOVES
- jr c, .loop
-.okay
- ld a, $ff
- ld [de], a
- inc de
- ld [de], a
- inc de
- ld [de], a
- pop de
- ld hl, wStringBuffer1
-.loop2
- ld a, [hl]
- cp -1
- jr z, .fail
- cp CURSE_T
- jr z, .next
- ld a, [de]
- cp [hl]
- jr z, .next
- inc de
- ld a, [de]
- dec de
- cp [hl]
- jr nz, .done
-.next
- inc hl
- jr .loop2
-
-.fail
- call AnimateFailedMove
- jp PrintButItFailed
-
-.done
-.loop3
- call BattleRandom
- maskbits NUM_MOVES
- ld c, a
- ld b, 0
- ld hl, wStringBuffer1
- add hl, bc
- ld a, [hl]
- cp -1
- jr z, .loop3
- cp CURSE_T
- jr z, .loop3
- ld a, [de]
- cp [hl]
- jr z, .loop3
- inc de
- ld a, [de]
- dec de
- cp [hl]
- jr z, .loop3
- ld a, [hl]
- ld [de], a
- inc de
- ld [de], a
- ld [wNamedObjectIndexBuffer], a
- farcall GetTypeName
- call AnimateCurrentMove
- ld hl, TransformedTypeText
- jp StdBattleTextBox
-
-; 3710e
+INCLUDE "engine/battle/move_effects/conversion.asm"
BattleCommand_ResetStats: ; 3710e
@@ -8355,7 +6644,9 @@ BattleCommand_Heal: ; 3713e
; 371cd
-INCLUDE "engine/battle/effect_commands/transform.asm"
+
+INCLUDE "engine/battle/move_effects/transform.asm"
+
BattleSideCopy: ; 372c6
; Copy bc bytes from hl to de if it's the player's turn.
@@ -8497,12 +6788,7 @@ PrintButItFailed: ; 3734e
; 37354
-FailSnore:
-FailDisable:
-FailConversion2:
-FailAttract:
-FailForesight:
-FailSpikes:
+FailMove:
call AnimateFailedMove
; fallthrough
; 37357
@@ -8549,42 +6835,11 @@ CheckSubstituteOpp: ; 37378
; 37380
-BattleCommand_Selfdestruct: ; 37380
- farcall StubbedTrainerRankings_Selfdestruct
- ld a, BATTLEANIM_PLAYER_DAMAGE
- ld [wNumHits], a
- ld c, 3
- call DelayFrames
- ld a, BATTLE_VARS_STATUS
- call GetBattleVarAddr
- xor a
- ld [hli], a
- inc hl
- ld [hli], a
- ld [hl], a
- ld a, $1
- ld [wKickCounter], a
- call BattleCommand_LowerSub
- call LoadMoveAnim
- ld a, BATTLE_VARS_SUBSTATUS4
- call GetBattleVarAddr
- res SUBSTATUS_LEECH_SEED, [hl]
- ld a, BATTLE_VARS_SUBSTATUS5_OPP
- call GetBattleVarAddr
- res SUBSTATUS_DESTINY_BOND, [hl]
- call _CheckBattleScene
- ret nc
- farcall DrawPlayerHUD
- farcall DrawEnemyHUD
- call WaitBGMap
- jp RefreshBattleHuds
-
-; 373c9
+INCLUDE "engine/battle/move_effects/selfdestruct.asm"
+INCLUDE "engine/battle/move_effects/mirror_move.asm"
-INCLUDE "engine/battle/effect_commands/mirror_move.asm"
-
-INCLUDE "engine/battle/effect_commands/metronome.asm"
+INCLUDE "engine/battle/move_effects/metronome.asm"
CheckUserMove: ; 37462
@@ -8631,7 +6886,7 @@ ResetTurn: ; 3747b
; 37492
-INCLUDE "engine/battle/effect_commands/thief.asm"
+INCLUDE "engine/battle/move_effects/thief.asm"
BattleCommand_ArenaTrap: ; 37517
@@ -8663,7 +6918,7 @@ BattleCommand_ArenaTrap: ; 37517
; 37536
-INCLUDE "engine/battle/effect_commands/nightmare.asm"
+INCLUDE "engine/battle/move_effects/nightmare.asm"
BattleCommand_Defrost: ; 37563
@@ -8700,21 +6955,21 @@ BattleCommand_Defrost: ; 37563
; 37588
-INCLUDE "engine/battle/effect_commands/curse.asm"
+INCLUDE "engine/battle/move_effects/curse.asm"
-INCLUDE "engine/battle/effect_commands/protect.asm"
+INCLUDE "engine/battle/move_effects/protect.asm"
-INCLUDE "engine/battle/effect_commands/endure.asm"
+INCLUDE "engine/battle/move_effects/endure.asm"
-INCLUDE "engine/battle/effect_commands/spikes.asm"
+INCLUDE "engine/battle/move_effects/spikes.asm"
-INCLUDE "engine/battle/effect_commands/foresight.asm"
+INCLUDE "engine/battle/move_effects/foresight.asm"
-INCLUDE "engine/battle/effect_commands/perish_song.asm"
+INCLUDE "engine/battle/move_effects/perish_song.asm"
-INCLUDE "engine/battle/effect_commands/sandstorm.asm"
+INCLUDE "engine/battle/move_effects/sandstorm.asm"
-INCLUDE "engine/battle/effect_commands/rollout.asm"
+INCLUDE "engine/battle/move_effects/rollout.asm"
BattleCommand5d: ; 37791
@@ -8724,158 +6979,17 @@ BattleCommand5d: ; 37791
; 37792
-BattleCommand_FuryCutter: ; 37792
-; furycutter
-
- ld hl, wPlayerFuryCutterCount
- ld a, [hBattleTurn]
- and a
- jr z, .go
- ld hl, wEnemyFuryCutterCount
-
-.go
- ld a, [wAttackMissed]
- and a
- jp nz, ResetFuryCutterCount
-
- inc [hl]
-
-; Damage capped at 5 turns' worth (16x).
- ld a, [hl]
- ld b, a
- cp 6
- jr c, .checkdouble
- ld b, 5
-
-.checkdouble
- dec b
- ret z
-
-; Double the damage
- ld hl, wCurDamage + 1
- sla [hl]
- dec hl
- rl [hl]
- jr nc, .checkdouble
-
-; No overflow
- ld a, $ff
- ld [hli], a
- ld [hl], a
- ret
-
-; 377be
-
+INCLUDE "engine/battle/move_effects/fury_cutter.asm"
-ResetFuryCutterCount: ; 377be
-
- push hl
-
- ld hl, wPlayerFuryCutterCount
- ld a, [hBattleTurn]
- and a
- jr z, .reset
- ld hl, wEnemyFuryCutterCount
+INCLUDE "engine/battle/move_effects/attract.asm"
-.reset
- xor a
- ld [hl], a
+INCLUDE "engine/battle/move_effects/return.asm"
- pop hl
- ret
+INCLUDE "engine/battle/move_effects/present.asm"
-; 377ce
+INCLUDE "engine/battle/move_effects/frustration.asm"
-
-INCLUDE "engine/battle/effect_commands/attract.asm"
-
-BattleCommand_HappinessPower: ; 3784b
-; happinesspower
- push bc
- ld hl, wBattleMonHappiness
- ld a, [hBattleTurn]
- and a
- jr z, .ok
- ld hl, wEnemyMonHappiness
-.ok
- xor a
- ld [hMultiplicand + 0], a
- ld [hMultiplicand + 1], a
- ld a, [hl]
- ld [hMultiplicand + 2], a
- ld a, 10
- ld [hMultiplier], a
- call Multiply
- ld a, 25
- ld [hDivisor], a
- ld b, 4
- call Divide
- ld a, [hQuotient + 2]
- ld d, a
- pop bc
- ret
-
-; 37874
-
-
-INCLUDE "engine/battle/effect_commands/present.asm"
-
-BattleCommand_FrustrationPower: ; 3790e
-; frustrationpower
-
- push bc
- ld hl, wBattleMonHappiness
- ld a, [hBattleTurn]
- and a
- jr z, .got_happiness
- ld hl, wEnemyMonHappiness
-.got_happiness
- ld a, $ff
- sub [hl]
- ld [hMultiplicand + 2], a
- xor a
- ld [hMultiplicand + 0], a
- ld [hMultiplicand + 1], a
- ld a, 10
- ld [hMultiplier], a
- call Multiply
- ld a, 25
- ld [hDivisor], a
- ld b, 4
- call Divide
- ld a, [hQuotient + 2]
- ld d, a
- pop bc
- ret
-
-; 37939
-
-
-BattleCommand_Safeguard: ; 37939
-; safeguard
-
- ld hl, wPlayerScreens
- ld de, wPlayerSafeguardCount
- ld a, [hBattleTurn]
- and a
- jr z, .ok
- ld hl, wEnemyScreens
- ld de, wEnemySafeguardCount
-.ok
- bit SCREENS_SAFEGUARD, [hl]
- jr nz, .failed
- set SCREENS_SAFEGUARD, [hl]
- ld a, 5
- ld [de], a
- call AnimateCurrentMove
- ld hl, CoveredByVeilText
- jp StdBattleTextBox
-
-.failed
- call AnimateFailedMove
- jp PrintButItFailed
-
-; 37962
+INCLUDE "engine/battle/move_effects/safeguard.asm"
SafeCheckSafeguard: ; 37962
@@ -8914,355 +7028,13 @@ BattleCommand_CheckSafeguard: ; 37972
; 37991
-BattleCommand_GetMagnitude: ; 37991
-; getmagnitude
-
- push bc
- call BattleRandom
- ld b, a
- ld hl, .Magnitudes
-.loop
- ld a, [hli]
- cp b
- jr nc, .ok
- inc hl
- inc hl
- jr .loop
-
-.ok
- ld d, [hl]
- push de
- inc hl
- ld a, [hl]
- ld [wTypeMatchup], a
- call BattleCommand_MoveDelay
- ld hl, MagnitudeText
- call StdBattleTextBox
- pop de
- pop bc
- ret
-
-.Magnitudes:
- ; /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
-
+INCLUDE "engine/battle/move_effects/magnitude.asm"
-BattleCommand_BatonPass: ; 379c9
-; batonpass
-
- ld a, [hBattleTurn]
- and a
- jp nz, .Enemy
+INCLUDE "engine/battle/move_effects/baton_pass.asm"
+INCLUDE "engine/battle/move_effects/pursuit.asm"
-; Need something to switch to
- call CheckAnyOtherAlivePartyMons
- jp z, FailedBatonPass
-
- call UpdateBattleMonInParty
- call AnimateCurrentMove
-
- ld c, 50
- call DelayFrames
-
-; Transition into switchmon menu
- call LoadStandardMenuDataHeader
- farcall SetUpBattlePartyMenu_NoLoop
-
- farcall ForcePickSwitchMonInBattle
-
-; Return to battle scene
- call ClearPalettes
- farcall _LoadBattleFontsHPBar
- call CloseWindow
- call ClearSprites
- hlcoord 1, 0
- lb bc, 4, 10
- call ClearBox
- ld b, SCGB_BATTLE_COLORS
- call GetSGBLayout
- call SetPalettes
- call BatonPass_LinkPlayerSwitch
-
-; Mobile link battles handle entrances differently
- farcall CheckMobileBattleError
- jp c, EndMoveEffect
-
- ld hl, PassedBattleMonEntrance
- call CallBattleCore
-
- call ResetBatonPassStatus
- ret
-
-
-.Enemy:
-
-; Wildmons don't have anything to switch to
- ld a, [wBattleMode]
- dec a ; WILDMON
- jp z, FailedBatonPass
-
- call CheckAnyOtherAliveEnemyMons
- jp z, FailedBatonPass
-
- call UpdateEnemyMonInParty
- call AnimateCurrentMove
- call BatonPass_LinkEnemySwitch
-
-; Mobile link battles handle entrances differently
- farcall CheckMobileBattleError
- jp c, EndMoveEffect
-
-; Passed enemy PartyMon entrance
- xor a
- ld [wEnemySwitchMonIndex], a
- ld hl, EnemySwitch_SetMode
- call CallBattleCore
- ld hl, ResetBattleParticipants
- call CallBattleCore
- ld a, 1
- ld [wTypeMatchup], a
- ld hl, ApplyStatLevelMultiplierOnAllStats
- call CallBattleCore
-
- ld hl, SpikesDamage
- call CallBattleCore
-
- jr ResetBatonPassStatus
-
-; 37a67
-
-
-BatonPass_LinkPlayerSwitch: ; 37a67
- ld a, [wLinkMode]
- and a
- ret z
-
- ld a, 1
- ld [wBattlePlayerAction], a
-
- call LoadStandardMenuDataHeader
- ld hl, LinkBattleSendReceiveAction
- call CallBattleCore
- call CloseWindow
-
- xor a
- ld [wBattlePlayerAction], a
- ret
-
-; 37a82
-
-
-BatonPass_LinkEnemySwitch: ; 37a82
- ld a, [wLinkMode]
- and a
- ret z
-
- call LoadStandardMenuDataHeader
- ld hl, LinkBattleSendReceiveAction
- call CallBattleCore
-
- ld a, [wOTPartyCount]
- add BATTLEACTION_SWITCH1
- ld b, a
- ld a, [wBattleAction]
- cp BATTLEACTION_SWITCH1
- jr c, .baton_pass
- cp b
- jr c, .switch
-
-.baton_pass
- ld a, [wCurOTMon]
- add BATTLEACTION_SWITCH1
- ld [wBattleAction], a
-.switch
- jp CloseWindow
-
-; 37aab
-
-
-FailedBatonPass: ; 37aab
- call AnimateFailedMove
- jp PrintButItFailed
-
-; 37ab1
-
-
-ResetBatonPassStatus: ; 37ab1
-; Reset status changes that aren't passed by Baton Pass.
-
- ; Nightmare isn't passed.
- ld a, BATTLE_VARS_STATUS
- call GetBattleVar
- and SLP
- jr nz, .ok
-
- ld a, BATTLE_VARS_SUBSTATUS1
- call GetBattleVarAddr
- res SUBSTATUS_NIGHTMARE, [hl]
-.ok
-
- ; Disable isn't passed.
- call ResetActorDisable
-
- ; Attraction isn't passed.
- ld hl, wPlayerSubStatus1
- res SUBSTATUS_IN_LOVE, [hl]
- ld hl, wEnemySubStatus1
- res SUBSTATUS_IN_LOVE, [hl]
- ld hl, wPlayerSubStatus5
-
- ld a, BATTLE_VARS_SUBSTATUS5
- call GetBattleVarAddr
- res SUBSTATUS_TRANSFORMED, [hl]
- res SUBSTATUS_ENCORED, [hl]
-
- ; New mon hasn't used a move yet.
- ld a, BATTLE_VARS_LAST_MOVE
- call GetBattleVarAddr
- ld [hl], 0
-
- xor a
- ld [wPlayerWrapCount], a
- ld [wEnemyWrapCount], a
- ret
-
-; 37ae9
-
-
-CheckAnyOtherAlivePartyMons: ; 37ae9
- ld hl, wPartyMon1HP
- ld a, [wPartyCount]
- ld d, a
- ld a, [wCurBattleMon]
- ld e, a
- jr CheckAnyOtherAliveMons
-
-; 37af6
-
-
-CheckAnyOtherAliveEnemyMons: ; 37af6
- ld hl, wOTPartyMon1HP
- ld a, [wOTPartyCount]
- ld d, a
- ld a, [wCurOTMon]
- ld e, a
-
- ; fallthrough
-; 37b01
-
-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.
-
- xor a
- ld b, a
- ld c, a
-.loop
- ld a, c
- cp d
- jr z, .done
- cp e
- jr z, .next
-
- ld a, [hli]
- or b
- ld b, a
- ld a, [hld]
- or b
- ld b, a
-
-.next
- push bc
- ld bc, PARTYMON_STRUCT_LENGTH
- add hl, bc
- pop bc
- inc c
- jr .loop
-
-.done
- ld a, b
- and a
- ret
-
-; 37b1d
-
-
-BattleCommand_Pursuit: ; 37b1d
-; pursuit
-; Double damage if the opponent is switching.
-
- ld hl, wEnemyIsSwitching
- ld a, [hBattleTurn]
- and a
- jr z, .ok
- ld hl, wPlayerIsSwitching
-.ok
- ld a, [hl]
- and a
- ret z
-
- ld hl, wCurDamage + 1
- sla [hl]
- dec hl
- rl [hl]
- ret nc
-
- ld a, $ff
- ld [hli], a
- ld [hl], a
- ret
-
-; 37b39
-
-
-BattleCommand_ClearHazards: ; 37b39
-; clearhazards
-
- ld a, BATTLE_VARS_SUBSTATUS4
- call GetBattleVarAddr
- bit SUBSTATUS_LEECH_SEED, [hl]
- jr z, .not_leeched
- res SUBSTATUS_LEECH_SEED, [hl]
- ld hl, ShedLeechSeedText
- call StdBattleTextBox
-.not_leeched
-
- ld hl, wPlayerScreens
- ld de, wPlayerWrapCount
- ld a, [hBattleTurn]
- and a
- jr z, .got_screens_wrap
- ld hl, wEnemyScreens
- ld de, wEnemyWrapCount
-.got_screens_wrap
- bit SCREENS_SPIKES, [hl]
- jr z, .no_spikes
- res SCREENS_SPIKES, [hl]
- ld hl, BlewSpikesText
- push de
- call StdBattleTextBox
- pop de
-.no_spikes
-
- ld a, [de]
- and a
- ret z
- xor a
- ld [de], a
- ld hl, ReleasedByText
- jp StdBattleTextBox
-
-; 37b74
+INCLUDE "engine/battle/move_effects/rapid_spin.asm"
BattleCommand_HealMorn: ; 37b74
@@ -9310,14 +7082,14 @@ BattleCommand_TimeBasedHealContinue: ; 37b7e
; Don't factor in time of day in link battles.
ld a, [wLinkMode]
and a
- jr nz, .checkWeather
+ jr nz, .Weather
ld a, [wTimeOfDay]
cp b
- jr z, .checkWeather
+ jr z, .Weather
dec c ; double
-.checkWeather:
+.Weather:
ld a, [wBattleWeather]
and a
jr z, .Heal
@@ -9369,196 +7141,17 @@ BattleCommand_TimeBasedHealContinue: ; 37b7e
; 37be8
-BattleCommand_HiddenPower: ; 37be8
-; hiddenpower
-
- ld a, [wAttackMissed]
- and a
- ret nz
- farcall HiddenPowerDamage
- ret
-
-; 37bf4
-
-
-BattleCommand_StartRain: ; 37bf4
-; startrain
- ld a, WEATHER_RAIN
- ld [wBattleWeather], a
- ld a, 5
- ld [wWeatherCount], a
- call AnimateCurrentMove
- ld hl, DownpourText
- jp StdBattleTextBox
-
-; 37c07
-
-
-BattleCommand_StartSun: ; 37c07
-; startsun
- ld a, WEATHER_SUN
- ld [wBattleWeather], a
- ld a, 5
- ld [wWeatherCount], a
- call AnimateCurrentMove
- ld hl, SunGotBrightText
- jp StdBattleTextBox
-
-; 37c1a
-
-
-BattleCommand_BellyDrum: ; 37c1a
-; bellydrum
-; 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.
- call BattleCommand_AttackUp2
- ld a, [wAttackMissed]
- and a
- jr nz, .failed
-
- callfar GetHalfMaxHP
- callfar CheckUserHasEnoughHP
- jr nc, .failed
-
- push bc
- call AnimateCurrentMove
- pop bc
- callfar SubtractHPFromUser
- call UpdateUserInParty
- ld a, 5
-
-.max_attack_loop
- push af
- call BattleCommand_AttackUp2
- pop af
- dec a
- jr nz, .max_attack_loop
-
- ld hl, BellyDrumText
- jp StdBattleTextBox
-
-.failed
- call AnimateFailedMove
- jp PrintButItFailed
-
-; 37c55
-
-
-BattleCommand_PsychUp: ; 37c55
-; psychup
-
- ld hl, wEnemyStatLevels
- ld de, wPlayerStatLevels
- ld a, [hBattleTurn]
- and a
- jr z, .pointers_correct
-; It's the enemy's turn, so swap the pointers.
- push hl
- ld h, d
- ld l, e
- pop de
-.pointers_correct
- push hl
- 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
- ld a, [hli]
- cp BASE_STAT_LEVEL
- jr nz, .break
- dec b
- jr nz, .loop
- pop hl
- call AnimateFailedMove
- jp PrintButItFailed
-
-.break
- pop hl
- ld b, NUM_LEVEL_STATS
-.loop2
- ld a, [hli]
- ld [de], a
- inc de
- dec b
- jr nz, .loop2
- ld a, [hBattleTurn]
- and a
- jr nz, .calc_enemy_stats
- call CalcPlayerStats
- jr .merge
-
-.calc_enemy_stats
- call CalcEnemyStats
-.merge
- call AnimateCurrentMove
- ld hl, CopiedStatsText
- jp StdBattleTextBox
-
-; 37c95
-
-
-BattleCommand_MirrorCoat: ; 37c95
-; mirrorcoat
-
- ld a, 1
- ld [wAttackMissed], a
-
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
- call GetBattleVar
- and a
- ret z
-
- ld b, a
- callfar GetMoveEffect
- ld a, b
- cp EFFECT_MIRROR_COAT
- ret z
+INCLUDE "engine/battle/move_effects/hidden_power.asm"
- call BattleCommand_ResetTypeMatchup
- ld a, [wTypeMatchup]
- and a
- ret z
+INCLUDE "engine/battle/move_effects/rain_dance.asm"
- call CheckOpponentWentFirst
- ret z
+INCLUDE "engine/battle/move_effects/sunny_day.asm"
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
- call GetBattleVar
- dec a
- ld de, wStringBuffer1
- call GetMoveData
+INCLUDE "engine/battle/move_effects/belly_drum.asm"
- ld a, [wStringBuffer1 + 2]
- and a
- ret z
+INCLUDE "engine/battle/move_effects/psych_up.asm"
- ld a, [wStringBuffer1 + 3]
- cp SPECIAL
- ret c
-
- ld hl, wCurDamage
- ld a, [hli]
- or [hl]
- ret z
-
- ld a, [hl]
- add a
- ld [hld], a
- ld a, [hl]
- adc a
- ld [hl], a
- jr nc, .capped
- ld a, $ff
- ld [hli], a
- ld [hl], a
-.capped
-
- xor a
- ld [wAttackMissed], a
- ret
-
-; 37ce6
+INCLUDE "engine/battle/move_effects/mirror_coat.asm"
BattleCommand_DoubleMinimizeDamage: ; 37ce6
@@ -9597,113 +7190,9 @@ BattleCommand_SkipSunCharge: ; 37d02
; 37d0d
-BattleCommand_CheckFutureSight: ; 37d0d
-; checkfuturesight
-
- ld hl, wPlayerFutureSightCount
- ld de, wPlayerFutureSightDamage
- ld a, [hBattleTurn]
- and a
- jr z, .ok
- ld hl, wEnemyFutureSightCount
- ld de, wEnemyFutureSightDamage
-.ok
-
- ld a, [hl]
- and a
- ret z
- cp 1
- ret nz
-
- ld [hl], 0
- ld a, [de]
- inc de
- ld [wCurDamage], a
- ld a, [de]
- ld [wCurDamage + 1], a
- ld b, futuresight_command
- jp SkipToBattleCommand
-
-; 37d34
-
-BattleCommand_FutureSight: ; 37d34
-; futuresight
+INCLUDE "engine/battle/move_effects/future_sight.asm"
- call CheckUserIsCharging
- jr nz, .AlreadyChargingFutureSight
- ld a, BATTLE_VARS_MOVE_ANIM
- call GetBattleVar
- ld b, a
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE
- call GetBattleVarAddr
- ld [hl], b
- ld a, BATTLE_VARS_LAST_MOVE
- call GetBattleVarAddr
- ld [hl], b
-.AlreadyChargingFutureSight:
- ld hl, wPlayerFutureSightCount
- ld a, [hBattleTurn]
- and a
- jr z, .GotFutureSightCount
- ld hl, wEnemyFutureSightCount
-.GotFutureSightCount:
- ld a, [hl]
- and a
- jr nz, .failed
- ld a, 4
- ld [hl], a
- call BattleCommand_LowerSub
- call BattleCommand_MoveDelay
- ld hl, ForesawAttackText
- call StdBattleTextBox
- call BattleCommand_RaiseSub
- ld de, wPlayerFutureSightDamage
- ld a, [hBattleTurn]
- and a
- jr z, .StoreDamage
- ld de, wEnemyFutureSightDamage
-.StoreDamage:
- ld hl, wCurDamage
- ld a, [hl]
- ld [de], a
- ld [hl], 0
- inc hl
- inc de
- ld a, [hl]
- ld [de], a
- ld [hl], 0
- jp EndMoveEffect
-
-.failed
- pop bc
- call ResetDamage
- call AnimateFailedMove
- call PrintButItFailed
- jp EndMoveEffect
-
-; 37d94
-
-
-BattleCommand_ThunderAccuracy: ; 37d94
-; thunderaccuracy
-
- ld a, BATTLE_VARS_MOVE_TYPE
- call GetBattleVarAddr
- inc hl
- ld a, [wBattleWeather]
- cp WEATHER_RAIN
- jr z, .rain
- cp WEATHER_SUN
- ret nz
- ld [hl], 50 percent + 1
- ret
-
-.rain
- ; Redundant with CheckHit guranteeing hit
- ld [hl], 100 percent
- ret
-
-; 37daa
+INCLUDE "engine/battle/move_effects/thunder.asm"
CheckHiddenOpponent: ; 37daa
@@ -9845,7 +7334,6 @@ LoadMoveAnim: ; 37e36
LoadAnim: ; 37e44
-
ld [wFXAnimID], a
; fallthrough
diff --git a/engine/battle/menu.asm b/engine/battle/menu.asm
index c97cd7854..705df3729 100755
--- a/engine/battle/menu.asm
+++ b/engine/battle/menu.asm
@@ -1,6 +1,6 @@
LoadBattleMenu: ; 24ef2
- ld hl, BattleMenuDataHeader
- call LoadMenuDataHeader
+ ld hl, BattleMenuHeader
+ call LoadMenuHeader
ld a, [wBattleMenuCursorBuffer]
ld [wMenuCursorBuffer], a
call InterpretBattleMenu
@@ -12,14 +12,14 @@ LoadBattleMenu: ; 24ef2
SafariBattleMenu: ; 24f0b
; untranslated
- ld hl, MenuDataHeader_0x24f4e
- call LoadMenuDataHeader
+ ld hl, MenuHeader_0x24f4e
+ call LoadMenuHeader
jr Function24f19
; 24f13
ContestBattleMenu: ; 24f13
- ld hl, MenuDataHeader_0x24f89
- call LoadMenuDataHeader
+ ld hl, MenuHeader_0x24f89
+ call LoadMenuHeader
; 24f19
Function24f19: ; 24f19
@@ -32,7 +32,7 @@ Function24f19: ; 24f19
ret
; 24f2c
-BattleMenuDataHeader: ; 24f2c
+BattleMenuHeader: ; 24f2c
db MENU_BACKUP_TILES ; flags
menu_coords 8, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw MenuData_0x24f34
@@ -54,7 +54,7 @@ Strings24f3d: ; 0x24f3d
db "RUN@"
; 24f4e
-MenuDataHeader_0x24f4e: ; 24f4e
+MenuHeader_0x24f4e: ; 24f4e
db MENU_BACKUP_TILES ; flags
menu_coords 0, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw MenuData_0x24f56
@@ -84,7 +84,7 @@ Function24f7c: ; 24f7c
ret
; 24f89
-MenuDataHeader_0x24f89: ; 24f89
+MenuHeader_0x24f89: ; 24f89
db MENU_BACKUP_TILES ; flags
menu_coords 2, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw MenuData_0x24f91
diff --git a/engine/battle/misc.asm b/engine/battle/misc.asm
index b79c274b9..581f5381e 100644
--- a/engine/battle/misc.asm
+++ b/engine/battle/misc.asm
@@ -52,7 +52,7 @@ GetPlayerBackpicCoords: ; fbd9d (3e:7d9d)
DoWeatherModifiers: ; fbda4
- ld de, .WeatherTypeModifiers
+ ld de, WeatherTypeModifiers
ld a, [wBattleWeather]
ld b, a
ld a, [wd265] ; move type
@@ -78,7 +78,7 @@ DoWeatherModifiers: ; fbda4
.done_weather_types
- ld de, .WeatherMoveModifiers
+ ld de, WeatherMoveModifiers
ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar
@@ -145,17 +145,7 @@ DoWeatherModifiers: ; fbda4
.done
ret
-.WeatherTypeModifiers:
- db WEATHER_RAIN, WATER, MORE_EFFECTIVE
- db WEATHER_RAIN, FIRE, NOT_VERY_EFFECTIVE
- db WEATHER_SUN, FIRE, MORE_EFFECTIVE
- db WEATHER_SUN, WATER, NOT_VERY_EFFECTIVE
- db -1 ; end
-
-.WeatherMoveModifiers:
- db WEATHER_RAIN, EFFECT_SOLARBEAM, NOT_VERY_EFFECTIVE
- db -1 ; end
-; fbe24
+INCLUDE "data/battle/weather_modifiers.asm"
DoBadgeTypeBoosts: ; fbe24
@@ -174,7 +164,7 @@ DoBadgeTypeBoosts: ; fbe24
push de
push bc
- ld hl, .BadgeTypes
+ ld hl, BadgeTypeBoosts
ld a, [wKantoBadges]
ld b, a
@@ -235,25 +225,4 @@ DoBadgeTypeBoosts: ; fbe24
pop de
ret
-.BadgeTypes:
-; entries correspond to wJohtoBadges constants
- db FLYING ; ZEPHYRBADGE
- db BUG ; HIVEBADGE
- db NORMAL ; PLAINBADGE
- db GHOST ; FOGBADGE
- db STEEL ; MINERALBADGE
- db FIGHTING ; STORMBADGE
- db ICE ; GLACIERBADGE
- db DRAGON ; RISINGBADGE
- ; fallthrough
-; entries correspond to wKantoBadges constants
- db ROCK ; BOULDERBADGE
- db WATER ; CASCADEBADGE
- db ELECTRIC ; THUNDERBADGE
- db GRASS ; RAINBOWBADGE
- db POISON ; SOULBADGE
- db PSYCHIC ; MARSHBADGE
- db FIRE ; VOLCANOBADGE
- db GROUND ; EARTHBADGE
- db -1 ; end
-; fbe91
+INCLUDE "data/types/badge_type_boosts.asm"
diff --git a/engine/battle/effect_commands/attract.asm b/engine/battle/move_effects/attract.asm
index da6a9c0e9..026176694 100755
--- a/engine/battle/effect_commands/attract.asm
+++ b/engine/battle/move_effects/attract.asm
@@ -20,7 +20,7 @@ BattleCommand_Attract: ; 377ce
jp StdBattleTextBox
.failed
- jp FailAttract
+ jp FailMove
; 377f5
diff --git a/engine/battle/move_effects/baton_pass.asm b/engine/battle/move_effects/baton_pass.asm
new file mode 100644
index 000000000..369565877
--- /dev/null
+++ b/engine/battle/move_effects/baton_pass.asm
@@ -0,0 +1,241 @@
+BattleCommand_BatonPass: ; 379c9
+; batonpass
+
+ ld a, [hBattleTurn]
+ and a
+ jp nz, .Enemy
+
+
+; Need something to switch to
+ call CheckAnyOtherAlivePartyMons
+ jp z, FailedBatonPass
+
+ call UpdateBattleMonInParty
+ call AnimateCurrentMove
+
+ ld c, 50
+ call DelayFrames
+
+; Transition into switchmon menu
+ call LoadStandardMenuHeader
+ farcall SetUpBattlePartyMenu_NoLoop
+
+ farcall ForcePickSwitchMonInBattle
+
+; Return to battle scene
+ call ClearPalettes
+ farcall _LoadBattleFontsHPBar
+ call CloseWindow
+ call ClearSprites
+ hlcoord 1, 0
+ lb bc, 4, 10
+ call ClearBox
+ ld b, SCGB_BATTLE_COLORS
+ call GetSGBLayout
+ call SetPalettes
+ call BatonPass_LinkPlayerSwitch
+
+; Mobile link battles handle entrances differently
+ farcall CheckMobileBattleError
+ jp c, EndMoveEffect
+
+ ld hl, PassedBattleMonEntrance
+ call CallBattleCore
+
+ call ResetBatonPassStatus
+ ret
+
+
+.Enemy:
+
+; Wildmons don't have anything to switch to
+ ld a, [wBattleMode]
+ dec a ; WILDMON
+ jp z, FailedBatonPass
+
+ call CheckAnyOtherAliveEnemyMons
+ jp z, FailedBatonPass
+
+ call UpdateEnemyMonInParty
+ call AnimateCurrentMove
+ call BatonPass_LinkEnemySwitch
+
+; Mobile link battles handle entrances differently
+ farcall CheckMobileBattleError
+ jp c, EndMoveEffect
+
+; Passed enemy PartyMon entrance
+ xor a
+ ld [wEnemySwitchMonIndex], a
+ ld hl, EnemySwitch_SetMode
+ call CallBattleCore
+ ld hl, ResetBattleParticipants
+ call CallBattleCore
+ ld a, 1
+ ld [wTypeMatchup], a
+ ld hl, ApplyStatLevelMultiplierOnAllStats
+ call CallBattleCore
+
+ ld hl, SpikesDamage
+ call CallBattleCore
+
+ jr ResetBatonPassStatus
+
+; 37a67
+
+
+BatonPass_LinkPlayerSwitch: ; 37a67
+ ld a, [wLinkMode]
+ and a
+ ret z
+
+ ld a, 1
+ ld [wBattlePlayerAction], a
+
+ call LoadStandardMenuHeader
+ ld hl, LinkBattleSendReceiveAction
+ call CallBattleCore
+ call CloseWindow
+
+ xor a
+ ld [wBattlePlayerAction], a
+ ret
+
+; 37a82
+
+
+BatonPass_LinkEnemySwitch: ; 37a82
+ ld a, [wLinkMode]
+ and a
+ ret z
+
+ call LoadStandardMenuHeader
+ ld hl, LinkBattleSendReceiveAction
+ call CallBattleCore
+
+ ld a, [wOTPartyCount]
+ add BATTLEACTION_SWITCH1
+ ld b, a
+ ld a, [wBattleAction]
+ cp BATTLEACTION_SWITCH1
+ jr c, .baton_pass
+ cp b
+ jr c, .switch
+
+.baton_pass
+ ld a, [wCurOTMon]
+ add BATTLEACTION_SWITCH1
+ ld [wBattleAction], a
+.switch
+ jp CloseWindow
+
+; 37aab
+
+
+FailedBatonPass: ; 37aab
+ call AnimateFailedMove
+ jp PrintButItFailed
+
+; 37ab1
+
+
+ResetBatonPassStatus: ; 37ab1
+; Reset status changes that aren't passed by Baton Pass.
+
+ ; Nightmare isn't passed.
+ ld a, BATTLE_VARS_STATUS
+ call GetBattleVar
+ and SLP
+ jr nz, .ok
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVarAddr
+ res SUBSTATUS_NIGHTMARE, [hl]
+.ok
+
+ ; Disable isn't passed.
+ call ResetActorDisable
+
+ ; Attraction isn't passed.
+ ld hl, wPlayerSubStatus1
+ res SUBSTATUS_IN_LOVE, [hl]
+ ld hl, wEnemySubStatus1
+ res SUBSTATUS_IN_LOVE, [hl]
+ ld hl, wPlayerSubStatus5
+
+ ld a, BATTLE_VARS_SUBSTATUS5
+ call GetBattleVarAddr
+ res SUBSTATUS_TRANSFORMED, [hl]
+ res SUBSTATUS_ENCORED, [hl]
+
+ ; New mon hasn't used a move yet.
+ ld a, BATTLE_VARS_LAST_MOVE
+ call GetBattleVarAddr
+ ld [hl], 0
+
+ xor a
+ ld [wPlayerWrapCount], a
+ ld [wEnemyWrapCount], a
+ ret
+
+; 37ae9
+
+
+CheckAnyOtherAlivePartyMons: ; 37ae9
+ ld hl, wPartyMon1HP
+ ld a, [wPartyCount]
+ ld d, a
+ ld a, [wCurBattleMon]
+ ld e, a
+ jr CheckAnyOtherAliveMons
+
+; 37af6
+
+
+CheckAnyOtherAliveEnemyMons: ; 37af6
+ ld hl, wOTPartyMon1HP
+ ld a, [wOTPartyCount]
+ ld d, a
+ ld a, [wCurOTMon]
+ ld e, a
+
+ ; fallthrough
+; 37b01
+
+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.
+
+ xor a
+ ld b, a
+ ld c, a
+.loop
+ ld a, c
+ cp d
+ jr z, .done
+ cp e
+ jr z, .next
+
+ ld a, [hli]
+ or b
+ ld b, a
+ ld a, [hld]
+ or b
+ ld b, a
+
+.next
+ push bc
+ ld bc, PARTYMON_STRUCT_LENGTH
+ add hl, bc
+ pop bc
+ inc c
+ jr .loop
+
+.done
+ ld a, b
+ and a
+ ret
+
+; 37b1d
diff --git a/engine/battle/move_effects/beat_up.asm b/engine/battle/move_effects/beat_up.asm
new file mode 100644
index 000000000..18e350504
--- /dev/null
+++ b/engine/battle/move_effects/beat_up.asm
@@ -0,0 +1,219 @@
+BattleCommand_BeatUp: ; 35461
+; beatup
+
+ call ResetDamage
+ ld a, [hBattleTurn]
+ and a
+ jp nz, .enemy_beats_up
+ ld a, [wPlayerSubStatus3]
+ bit SUBSTATUS_IN_LOOP, a
+ jr nz, .next_mon
+ ld c, 20
+ call DelayFrames
+ xor a
+ ld [wPlayerRolloutCount], a
+ ld [wd002], a
+ ld [wBeatUpHitAtLeastOnce], a
+ jr .got_mon
+
+.next_mon
+ ld a, [wPlayerRolloutCount]
+ ld b, a
+ ld a, [wPartyCount]
+ sub b
+ ld [wd002], a
+
+.got_mon
+ ld a, [wd002]
+ ld hl, wPartyMonNicknames
+ call GetNick
+ ld a, MON_HP
+ call GetBeatupMonLocation
+ ld a, [hli]
+ or [hl]
+ jp z, .beatup_fail ; fainted
+ ld a, [wd002]
+ ld c, a
+ ld a, [wCurBattleMon]
+ ; BUG: this can desynchronize link battles
+ ; Change "cp [hl]" to "cp c" to fix
+ cp [hl]
+ ld hl, wBattleMonStatus
+ jr z, .active_mon
+ ld a, MON_STATUS
+ call GetBeatupMonLocation
+.active_mon
+ ld a, [hl]
+ and a
+ jp nz, .beatup_fail
+
+ ld a, $1
+ ld [wBeatUpHitAtLeastOnce], a
+ ld hl, BeatUpAttackText
+ call StdBattleTextBox
+ ld a, [wEnemyMonSpecies]
+ ld [wCurSpecies], a
+ call GetBaseData
+ ld a, [wBaseDefense]
+ ld c, a
+ push bc
+ ld a, MON_SPECIES
+ call GetBeatupMonLocation
+ ld a, [hl]
+ ld [wCurSpecies], a
+ call GetBaseData
+ ld a, [wBaseAttack]
+ pop bc
+ ld b, a
+ push bc
+ ld a, MON_LEVEL
+ call GetBeatupMonLocation
+ ld a, [hl]
+ ld e, a
+ pop bc
+ ld a, [wPlayerMoveStructPower]
+ ld d, a
+ ret
+
+.enemy_beats_up
+ ld a, [wEnemySubStatus3]
+ bit SUBSTATUS_IN_LOOP, a
+ jr nz, .not_first_enemy_beatup
+
+ xor a
+ ld [wEnemyRolloutCount], a
+ ld [wd002], a
+ ld [wBeatUpHitAtLeastOnce], a
+ jr .enemy_continue
+
+.not_first_enemy_beatup
+ ld a, [wEnemyRolloutCount]
+ ld b, a
+ ld a, [wOTPartyCount]
+ sub b
+ ld [wd002], a
+.enemy_continue
+ ld a, [wBattleMode]
+ dec a
+ jr z, .wild
+
+ ld a, [wLinkMode]
+ and a
+ jr nz, .link_or_tower
+
+ ld a, [wInBattleTowerBattle]
+ and a
+ jr nz, .link_or_tower
+
+ ld a, [wd002]
+ ld c, a
+ ld b, 0
+ ld hl, wOTPartySpecies
+ add hl, bc
+ ld a, [hl]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ jr .got_enemy_nick
+
+.link_or_tower
+ ld a, [wd002]
+ ld hl, wOTPartyMonNicknames
+ ld bc, NAME_LENGTH
+ call AddNTimes
+ ld de, wStringBuffer1
+ call CopyBytes
+.got_enemy_nick
+ ld a, MON_HP
+ call GetBeatupMonLocation
+ ld a, [hli]
+ or [hl]
+ jp z, .beatup_fail
+ ld a, [wd002]
+ ld b, a
+ ld a, [wCurOTMon]
+ cp b
+ ld hl, wEnemyMonStatus
+ jr z, .active_enemy
+
+ ld a, MON_STATUS
+ call GetBeatupMonLocation
+.active_enemy
+ ld a, [hl]
+ and a
+ jr nz, .beatup_fail
+
+ ld a, $1
+ ld [wBeatUpHitAtLeastOnce], a
+ jr .finish_beatup
+
+.wild
+ ld a, [wEnemyMonSpecies]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld hl, BeatUpAttackText
+ call StdBattleTextBox
+ jp EnemyAttackDamage
+
+.finish_beatup
+ ld hl, BeatUpAttackText
+ call StdBattleTextBox
+ ld a, [wBattleMonSpecies]
+ ld [wCurSpecies], a
+ call GetBaseData
+ ld a, [wBaseDefense]
+ ld c, a
+ push bc
+ ld a, MON_SPECIES
+ call GetBeatupMonLocation
+ ld a, [hl]
+ ld [wCurSpecies], a
+ call GetBaseData
+ ld a, [wBaseAttack]
+ pop bc
+ ld b, a
+ push bc
+ ld a, MON_LEVEL
+ call GetBeatupMonLocation
+ ld a, [hl]
+ ld e, a
+ pop bc
+ ld a, [wEnemyMoveStructPower]
+ ld d, a
+ ret
+
+; 355b0
+
+
+.beatup_fail ; 355b0
+ ld b, buildopponentrage_command
+ jp SkipToBattleCommand
+
+; 355b5
+
+
+BattleCommanda8: ; 355b5
+ ld a, [wBeatUpHitAtLeastOnce]
+ and a
+ ret nz
+
+ jp PrintButItFailed
+
+; 355bd
+
+
+GetBeatupMonLocation: ; 355bd
+ push bc
+ ld c, a
+ ld b, 0
+ ld a, [hBattleTurn]
+ and a
+ ld hl, wPartyMon1Species
+ jr z, .got_species
+ ld hl, wOTPartyMon1Species
+
+.got_species
+ ld a, [wd002]
+ add hl, bc
+ call GetPartyLocation
+ pop bc
+ ret
diff --git a/engine/battle/move_effects/belly_drum.asm b/engine/battle/move_effects/belly_drum.asm
new file mode 100644
index 000000000..bd300c9cd
--- /dev/null
+++ b/engine/battle/move_effects/belly_drum.asm
@@ -0,0 +1,36 @@
+BattleCommand_BellyDrum: ; 37c1a
+; bellydrum
+; 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.
+ call BattleCommand_AttackUp2
+ ld a, [wAttackMissed]
+ and a
+ jr nz, .failed
+
+ callfar GetHalfMaxHP
+ callfar CheckUserHasEnoughHP
+ jr nc, .failed
+
+ push bc
+ call AnimateCurrentMove
+ pop bc
+ callfar SubtractHPFromUser
+ call UpdateUserInParty
+ ld a, 5
+
+.max_attack_loop
+ push af
+ call BattleCommand_AttackUp2
+ pop af
+ dec a
+ jr nz, .max_attack_loop
+
+ ld hl, BellyDrumText
+ jp StdBattleTextBox
+
+.failed
+ call AnimateFailedMove
+ jp PrintButItFailed
+
+; 37c55
diff --git a/engine/battle/move_effects/bide.asm b/engine/battle/move_effects/bide.asm
new file mode 100644
index 000000000..d9958ca53
--- /dev/null
+++ b/engine/battle/move_effects/bide.asm
@@ -0,0 +1,105 @@
+BattleCommand_StoreEnergy: ; 36671
+; storeenergy
+
+ ld a, BATTLE_VARS_SUBSTATUS3
+ call GetBattleVar
+ bit SUBSTATUS_BIDE, a
+ ret z
+
+ ld hl, wPlayerRolloutCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .check_still_storing_energy
+ ld hl, wEnemyRolloutCount
+.check_still_storing_energy
+ dec [hl]
+ jr nz, .still_storing
+
+ ld a, BATTLE_VARS_SUBSTATUS3
+ call GetBattleVarAddr
+ res SUBSTATUS_BIDE, [hl]
+
+ ld hl, UnleashedEnergyText
+ call StdBattleTextBox
+
+ ld a, BATTLE_VARS_MOVE_POWER
+ call GetBattleVarAddr
+ ld a, 1
+ ld [hl], a
+ ld hl, wPlayerDamageTaken + 1
+ ld de, wPlayerCharging ; player
+ ld a, [hBattleTurn]
+ and a
+ jr z, .player
+ ld hl, wEnemyDamageTaken + 1
+ ld de, wEnemyCharging ; enemy
+.player
+ ld a, [hld]
+ add a
+ ld b, a
+ ld [wCurDamage + 1], a
+ ld a, [hl]
+ rl a
+ ld [wCurDamage], a
+ jr nc, .not_maxed
+ ld a, $ff
+ ld [wCurDamage], a
+ ld [wCurDamage + 1], a
+.not_maxed
+ or b
+ jr nz, .built_up_something
+ ld a, 1
+ ld [wAttackMissed], a
+.built_up_something
+ xor a
+ ld [hli], a
+ ld [hl], a
+ ld [de], a
+
+ ld a, BATTLE_VARS_MOVE_ANIM
+ call GetBattleVarAddr
+ ld a, BIDE
+ ld [hl], a
+
+ ld b, unleashenergy_command
+ jp SkipToBattleCommand
+
+.still_storing
+ ld hl, StoringEnergyText
+ call StdBattleTextBox
+ jp EndMoveEffect
+
+; 366e5
+
+
+BattleCommand_UnleashEnergy: ; 366e5
+; unleashenergy
+
+ ld de, wPlayerDamageTaken
+ ld bc, wPlayerRolloutCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_damage
+ ld de, wEnemyDamageTaken
+ ld bc, wEnemyRolloutCount
+.got_damage
+ ld a, BATTLE_VARS_SUBSTATUS3
+ call GetBattleVarAddr
+ set SUBSTATUS_BIDE, [hl]
+ xor a
+ ld [de], a
+ inc de
+ ld [de], a
+ ld [wPlayerMoveStructEffect], a
+ ld [wEnemyMoveStructEffect], a
+ call BattleRandom
+ and 1
+ inc a
+ inc a
+ ld [bc], a
+ ld a, 1
+ ld [wKickCounter], a
+ call AnimateCurrentMove
+ jp EndMoveEffect
+
+; 3671a
diff --git a/engine/battle/move_effects/conversion.asm b/engine/battle/move_effects/conversion.asm
new file mode 100644
index 000000000..d66d23a5e
--- /dev/null
+++ b/engine/battle/move_effects/conversion.asm
@@ -0,0 +1,98 @@
+BattleCommand_Conversion: ; 3707f
+; conversion
+
+ ld hl, wBattleMonMoves
+ ld de, wBattleMonType1
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_moves
+ ld hl, wEnemyMonMoves
+ ld de, wEnemyMonType1
+.got_moves
+ push de
+ ld c, 0
+ ld de, wStringBuffer1
+.loop
+ push hl
+ ld b, 0
+ add hl, bc
+ ld a, [hl]
+ pop hl
+ and a
+ jr z, .okay
+ push hl
+ push bc
+ dec a
+ ld hl, Moves + MOVE_TYPE
+ call GetMoveAttr
+ ld [de], a
+ inc de
+ pop bc
+ pop hl
+ inc c
+ ld a, c
+ cp NUM_MOVES
+ jr c, .loop
+.okay
+ ld a, $ff
+ ld [de], a
+ inc de
+ ld [de], a
+ inc de
+ ld [de], a
+ pop de
+ ld hl, wStringBuffer1
+.loop2
+ ld a, [hl]
+ cp -1
+ jr z, .fail
+ cp CURSE_T
+ jr z, .next
+ ld a, [de]
+ cp [hl]
+ jr z, .next
+ inc de
+ ld a, [de]
+ dec de
+ cp [hl]
+ jr nz, .done
+.next
+ inc hl
+ jr .loop2
+
+.fail
+ call AnimateFailedMove
+ jp PrintButItFailed
+
+.done
+.loop3
+ call BattleRandom
+ maskbits NUM_MOVES
+ ld c, a
+ ld b, 0
+ ld hl, wStringBuffer1
+ add hl, bc
+ ld a, [hl]
+ cp -1
+ jr z, .loop3
+ cp CURSE_T
+ jr z, .loop3
+ ld a, [de]
+ cp [hl]
+ jr z, .loop3
+ inc de
+ ld a, [de]
+ dec de
+ cp [hl]
+ jr z, .loop3
+ ld a, [hl]
+ ld [de], a
+ inc de
+ ld [de], a
+ ld [wNamedObjectIndexBuffer], a
+ farcall GetTypeName
+ call AnimateCurrentMove
+ ld hl, TransformedTypeText
+ jp StdBattleTextBox
+
+; 3710e
diff --git a/engine/battle/move_effects/conversion2.asm b/engine/battle/move_effects/conversion2.asm
new file mode 100644
index 000000000..074ca93ba
--- /dev/null
+++ b/engine/battle/move_effects/conversion2.asm
@@ -0,0 +1,66 @@
+BattleCommand_Conversion2: ; 359e6
+; conversion2
+
+ ld a, [wAttackMissed]
+ and a
+ jr nz, .failed
+ ld hl, wBattleMonType1
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_type
+ ld hl, wEnemyMonType1
+.got_type
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ and a
+ jr z, .failed
+ push hl
+ dec a
+ ld hl, Moves + MOVE_TYPE
+ call GetMoveAttr
+ ld d, a
+ pop hl
+ cp CURSE_T
+ jr z, .failed
+ call AnimateCurrentMove
+ call BattleCommand_SwitchTurn
+
+.loop
+ call BattleRandom
+ maskbits NUM_TYPES
+ cp UNUSED_TYPES
+ jr c, .okay
+ cp UNUSED_TYPES_END
+ jr c, .loop
+ cp TYPES_END
+ jr nc, .loop
+.okay
+ ld [hli], a
+ ld [hld], a
+ push hl
+ ld a, BATTLE_VARS_MOVE_TYPE
+ call GetBattleVarAddr
+ push af
+ push hl
+ ld a, d
+ ld [hl], a
+ call BattleCheckTypeMatchup
+ pop hl
+ pop af
+ ld [hl], a
+ pop hl
+ ld a, [wTypeMatchup]
+ cp 10
+ jr nc, .loop
+ call BattleCommand_SwitchTurn
+
+ ld a, [hl]
+ ld [wNamedObjectIndexBuffer], a
+ predef GetTypeName
+ ld hl, TransformedTypeText
+ jp StdBattleTextBox
+
+.failed
+ jp FailMove
+
+; 35a53
diff --git a/engine/battle/move_effects/counter.asm b/engine/battle/move_effects/counter.asm
new file mode 100644
index 000000000..b811b293c
--- /dev/null
+++ b/engine/battle/move_effects/counter.asm
@@ -0,0 +1,60 @@
+BattleCommand_Counter: ; 35813
+; counter
+
+ ld a, 1
+ ld [wAttackMissed], a
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ and a
+ ret z
+
+ ld b, a
+ callfar GetMoveEffect
+ ld a, b
+ cp EFFECT_COUNTER
+ ret z
+
+ call BattleCommand_ResetTypeMatchup
+ ld a, [wTypeMatchup]
+ and a
+ ret z
+
+ call CheckOpponentWentFirst
+ ret z
+
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ dec a
+ ld de, wStringBuffer1
+ call GetMoveData
+
+ ld a, [wStringBuffer1 + MOVE_POWER]
+ and a
+ ret z
+
+ ld a, [wStringBuffer1 + MOVE_TYPE]
+ cp SPECIAL
+ ret nc
+
+ ld hl, wCurDamage
+ ld a, [hli]
+ or [hl]
+ ret z
+
+ ld a, [hl]
+ add a
+ ld [hld], a
+ ld a, [hl]
+ adc a
+ ld [hl], a
+ jr nc, .capped
+ ld a, $ff
+ ld [hli], a
+ ld [hl], a
+.capped
+
+ xor a
+ ld [wAttackMissed], a
+ ret
+
+; 35864
diff --git a/engine/battle/effect_commands/curse.asm b/engine/battle/move_effects/curse.asm
index b11b9f3fb..b11b9f3fb 100644
--- a/engine/battle/effect_commands/curse.asm
+++ b/engine/battle/move_effects/curse.asm
diff --git a/engine/battle/move_effects/destiny_bond.asm b/engine/battle/move_effects/destiny_bond.asm
new file mode 100644
index 000000000..2dc125ddf
--- /dev/null
+++ b/engine/battle/move_effects/destiny_bond.asm
@@ -0,0 +1,11 @@
+BattleCommand_DestinyBond: ; 35bff
+; destinybond
+
+ ld a, BATTLE_VARS_SUBSTATUS5
+ call GetBattleVarAddr
+ set SUBSTATUS_DESTINY_BOND, [hl]
+ call AnimateCurrentMove
+ ld hl, DestinyBondEffectText
+ jp StdBattleTextBox
+
+; 35c0f
diff --git a/engine/battle/move_effects/disable.asm b/engine/battle/move_effects/disable.asm
new file mode 100644
index 000000000..5df785d24
--- /dev/null
+++ b/engine/battle/move_effects/disable.asm
@@ -0,0 +1,74 @@
+BattleCommand_Disable: ; 36fed
+; disable
+
+ ld a, [wAttackMissed]
+ and a
+ jr nz, .failed
+
+ ld de, wEnemyDisableCount
+ ld hl, wEnemyMonMoves
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_moves
+ ld de, wPlayerDisableCount
+ ld hl, wBattleMonMoves
+.got_moves
+
+ ld a, [de]
+ and a
+ jr nz, .failed
+
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ and a
+ jr z, .failed
+ cp STRUGGLE
+ jr z, .failed
+
+ ld b, a
+ ld c, $ff
+.loop
+ inc c
+ ld a, [hli]
+ cp b
+ jr nz, .loop
+
+ ld a, [hBattleTurn]
+ and a
+ ld hl, wEnemyMonPP
+ jr z, .got_pp
+ ld hl, wBattleMonPP
+.got_pp
+ ld b, 0
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .failed
+.loop2
+ call BattleRandom
+ and 7
+ jr z, .loop2
+ inc a
+ inc c
+ swap c
+ add c
+ ld [de], a
+ call AnimateCurrentMove
+ ld hl, wDisabledMove
+ ld a, [hBattleTurn]
+ and a
+ jr nz, .got_disabled_move_pointer
+ inc hl
+.got_disabled_move_pointer
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ ld [hl], a
+ ld [wNamedObjectIndexBuffer], a
+ call GetMoveName
+ ld hl, WasDisabledText
+ jp StdBattleTextBox
+
+.failed
+ jp FailMove
+
+; 3705c
diff --git a/engine/battle/move_effects/encore.asm b/engine/battle/move_effects/encore.asm
new file mode 100644
index 000000000..e6607fb11
--- /dev/null
+++ b/engine/battle/move_effects/encore.asm
@@ -0,0 +1,122 @@
+BattleCommand_Encore: ; 35864
+; encore
+
+ ld hl, wEnemyMonMoves
+ ld de, wEnemyEncoreCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .ok
+ ld hl, wBattleMonMoves
+ ld de, wPlayerEncoreCount
+.ok
+ ld a, BATTLE_VARS_LAST_MOVE_OPP
+ call GetBattleVar
+ and a
+ jp z, .failed
+ cp STRUGGLE
+ jp z, .failed
+ cp ENCORE
+ jp z, .failed
+ cp MIRROR_MOVE
+ jp z, .failed
+ ld b, a
+
+.got_move
+ ld a, [hli]
+ cp b
+ jr nz, .got_move
+
+ ld bc, wBattleMonPP - wBattleMonMoves - 1
+ add hl, bc
+ ld a, [hl]
+ and PP_MASK
+ jp z, .failed
+ ld a, [wAttackMissed]
+ and a
+ jp nz, .failed
+ ld a, BATTLE_VARS_SUBSTATUS5_OPP
+ call GetBattleVarAddr
+ bit SUBSTATUS_ENCORED, [hl]
+ jp nz, .failed
+ set SUBSTATUS_ENCORED, [hl]
+ call BattleRandom
+ and $3
+ inc a
+ inc a
+ inc a
+ ld [de], a
+ call CheckOpponentWentFirst
+ jr nz, .finish_move
+ ld a, [hBattleTurn]
+ and a
+ jr z, .force_last_enemy_move
+
+ push hl
+ ld a, [wLastPlayerMove]
+ ld b, a
+ ld c, 0
+ ld hl, wBattleMonMoves
+.find_player_move
+ ld a, [hli]
+ cp b
+ jr z, .got_player_move
+ inc c
+ ld a, c
+ cp NUM_MOVES
+ jr c, .find_player_move
+ pop hl
+ res SUBSTATUS_ENCORED, [hl]
+ xor a
+ ld [de], a
+ jr .failed
+
+.got_player_move
+ pop hl
+ ld a, c
+ ld [wCurMoveNum], a
+ ld a, b
+ ld [wCurPlayerMove], a
+ dec a
+ ld de, wPlayerMoveStruct
+ call GetMoveData
+ jr .finish_move
+
+.force_last_enemy_move
+ push hl
+ ld a, [wLastEnemyMove]
+ ld b, a
+ ld c, 0
+ ld hl, wEnemyMonMoves
+.find_enemy_move
+ ld a, [hli]
+ cp b
+ jr z, .got_enemy_move
+ inc c
+ ld a, c
+ cp NUM_MOVES
+ jr c, .find_enemy_move
+ pop hl
+ res SUBSTATUS_ENCORED, [hl]
+ xor a
+ ld [de], a
+ jr .failed
+
+.got_enemy_move
+ pop hl
+ ld a, c
+ ld [wCurEnemyMoveNum], a
+ ld a, b
+ ld [wCurEnemyMove], a
+ dec a
+ ld de, wEnemyMoveStruct
+ call GetMoveData
+
+.finish_move
+ call AnimateCurrentMove
+ ld hl, GotAnEncoreText
+ jp StdBattleTextBox
+
+.failed
+ jp PrintDidntAffect2
+
+; 35926
diff --git a/engine/battle/effect_commands/endure.asm b/engine/battle/move_effects/endure.asm
index ed4329ff5..ed4329ff5 100644
--- a/engine/battle/effect_commands/endure.asm
+++ b/engine/battle/move_effects/endure.asm
diff --git a/engine/battle/move_effects/false_swipe.asm b/engine/battle/move_effects/false_swipe.asm
new file mode 100644
index 000000000..e93b627ec
--- /dev/null
+++ b/engine/battle/move_effects/false_swipe.asm
@@ -0,0 +1,44 @@
+BattleCommand_FalseSwipe: ; 35c94
+; falseswipe
+
+ ld hl, wEnemyMonHP
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_hp
+ ld hl, wBattleMonHP
+.got_hp
+ ld de, wCurDamage
+ ld c, 2
+ push hl
+ push de
+ call StringCmp
+ pop de
+ pop hl
+ jr c, .done
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ dec a
+ ld [de], a
+ inc a
+ jr nz, .okay
+ dec de
+ ld a, [de]
+ dec a
+ ld [de], a
+.okay
+ ld a, [wCriticalHit]
+ cp 2
+ jr nz, .carry
+ xor a
+ ld [wCriticalHit], a
+.carry
+ scf
+ ret
+
+.done
+ and a
+ ret
+
+; 35cc9
diff --git a/engine/battle/move_effects/focus_energy.asm b/engine/battle/move_effects/focus_energy.asm
new file mode 100644
index 000000000..2a3726c53
--- /dev/null
+++ b/engine/battle/move_effects/focus_energy.asm
@@ -0,0 +1,17 @@
+BattleCommand_FocusEnergy: ; 36c98
+; focusenergy
+
+ ld a, BATTLE_VARS_SUBSTATUS4
+ call GetBattleVarAddr
+ bit SUBSTATUS_FOCUS_ENERGY, [hl]
+ jr nz, .already_pumped
+ set SUBSTATUS_FOCUS_ENERGY, [hl]
+ call AnimateCurrentMove
+ ld hl, GettingPumpedText
+ jp StdBattleTextBox
+
+.already_pumped
+ call AnimateFailedMove
+ jp PrintButItFailed
+
+; 36cb2
diff --git a/engine/battle/effect_commands/foresight.asm b/engine/battle/move_effects/foresight.asm
index 006e3b3d7..8c51bb220 100644
--- a/engine/battle/effect_commands/foresight.asm
+++ b/engine/battle/move_effects/foresight.asm
@@ -19,5 +19,5 @@ BattleCommand_Foresight: ; 376a0
jp StdBattleTextBox
.failed
- jp FailForesight
+ jp FailMove
; 376c2
diff --git a/engine/battle/move_effects/frustration.asm b/engine/battle/move_effects/frustration.asm
new file mode 100644
index 000000000..3f8456ced
--- /dev/null
+++ b/engine/battle/move_effects/frustration.asm
@@ -0,0 +1,29 @@
+BattleCommand_FrustrationPower: ; 3790e
+; frustrationpower
+
+ push bc
+ ld hl, wBattleMonHappiness
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_happiness
+ ld hl, wEnemyMonHappiness
+.got_happiness
+ ld a, $ff
+ sub [hl]
+ ld [hMultiplicand + 2], a
+ xor a
+ ld [hMultiplicand + 0], a
+ ld [hMultiplicand + 1], a
+ ld a, 10
+ ld [hMultiplier], a
+ call Multiply
+ ld a, 25
+ ld [hDivisor], a
+ ld b, 4
+ call Divide
+ ld a, [hQuotient + 2]
+ ld d, a
+ pop bc
+ ret
+
+; 37939
diff --git a/engine/battle/move_effects/fury_cutter.asm b/engine/battle/move_effects/fury_cutter.asm
new file mode 100644
index 000000000..91679368f
--- /dev/null
+++ b/engine/battle/move_effects/fury_cutter.asm
@@ -0,0 +1,61 @@
+BattleCommand_FuryCutter: ; 37792
+; furycutter
+
+ ld hl, wPlayerFuryCutterCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .go
+ ld hl, wEnemyFuryCutterCount
+
+.go
+ ld a, [wAttackMissed]
+ and a
+ jp nz, ResetFuryCutterCount
+
+ inc [hl]
+
+; Damage capped at 5 turns' worth (16x).
+ ld a, [hl]
+ ld b, a
+ cp 6
+ jr c, .checkdouble
+ ld b, 5
+
+.checkdouble
+ dec b
+ ret z
+
+; Double the damage
+ ld hl, wCurDamage + 1
+ sla [hl]
+ dec hl
+ rl [hl]
+ jr nc, .checkdouble
+
+; No overflow
+ ld a, $ff
+ ld [hli], a
+ ld [hl], a
+ ret
+
+; 377be
+
+
+ResetFuryCutterCount: ; 377be
+
+ push hl
+
+ ld hl, wPlayerFuryCutterCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .reset
+ ld hl, wEnemyFuryCutterCount
+
+.reset
+ xor a
+ ld [hl], a
+
+ pop hl
+ ret
+
+; 377ce
diff --git a/engine/battle/move_effects/future_sight.asm b/engine/battle/move_effects/future_sight.asm
new file mode 100644
index 000000000..fa2148ab7
--- /dev/null
+++ b/engine/battle/move_effects/future_sight.asm
@@ -0,0 +1,85 @@
+BattleCommand_CheckFutureSight: ; 37d0d
+; checkfuturesight
+
+ ld hl, wPlayerFutureSightCount
+ ld de, wPlayerFutureSightDamage
+ ld a, [hBattleTurn]
+ and a
+ jr z, .ok
+ ld hl, wEnemyFutureSightCount
+ ld de, wEnemyFutureSightDamage
+.ok
+
+ ld a, [hl]
+ and a
+ ret z
+ cp 1
+ ret nz
+
+ ld [hl], 0
+ ld a, [de]
+ inc de
+ ld [wCurDamage], a
+ ld a, [de]
+ ld [wCurDamage + 1], a
+ ld b, futuresight_command
+ jp SkipToBattleCommand
+
+; 37d34
+
+BattleCommand_FutureSight: ; 37d34
+; futuresight
+
+ call CheckUserIsCharging
+ jr nz, .AlreadyChargingFutureSight
+ ld a, BATTLE_VARS_MOVE_ANIM
+ call GetBattleVar
+ ld b, a
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE
+ call GetBattleVarAddr
+ ld [hl], b
+ ld a, BATTLE_VARS_LAST_MOVE
+ call GetBattleVarAddr
+ ld [hl], b
+.AlreadyChargingFutureSight:
+ ld hl, wPlayerFutureSightCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .GotFutureSightCount
+ ld hl, wEnemyFutureSightCount
+.GotFutureSightCount:
+ ld a, [hl]
+ and a
+ jr nz, .failed
+ ld a, 4
+ ld [hl], a
+ call BattleCommand_LowerSub
+ call BattleCommand_MoveDelay
+ ld hl, ForesawAttackText
+ call StdBattleTextBox
+ call BattleCommand_RaiseSub
+ ld de, wPlayerFutureSightDamage
+ ld a, [hBattleTurn]
+ and a
+ jr z, .StoreDamage
+ ld de, wEnemyFutureSightDamage
+.StoreDamage:
+ ld hl, wCurDamage
+ ld a, [hl]
+ ld [de], a
+ ld [hl], 0
+ inc hl
+ inc de
+ ld a, [hl]
+ ld [de], a
+ ld [hl], 0
+ jp EndMoveEffect
+
+.failed
+ pop bc
+ call ResetDamage
+ call AnimateFailedMove
+ call PrintButItFailed
+ jp EndMoveEffect
+
+; 37d94
diff --git a/engine/battle/move_effects/heal_bell.asm b/engine/battle/move_effects/heal_bell.asm
new file mode 100644
index 000000000..c79362f9c
--- /dev/null
+++ b/engine/battle/move_effects/heal_bell.asm
@@ -0,0 +1,36 @@
+BattleCommand_HealBell: ; 35cc9
+; healbell
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVarAddr
+ res SUBSTATUS_NIGHTMARE, [hl]
+ ld de, wPartyMon1Status
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_status
+ ld de, wOTPartyMon1Status
+.got_status
+ ld a, BATTLE_VARS_STATUS
+ call GetBattleVarAddr
+ xor a
+ ld [hl], a
+ ld h, d
+ ld l, e
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld d, PARTY_LENGTH
+.loop
+ ld [hl], a
+ add hl, bc
+ dec d
+ jr nz, .loop
+ call AnimateCurrentMove
+
+ ld hl, BellChimedText
+ call StdBattleTextBox
+
+ ld a, [hBattleTurn]
+ and a
+ jp z, CalcPlayerStats
+ jp CalcEnemyStats
+
+; 35d00
diff --git a/engine/battle/move_effects/hidden_power.asm b/engine/battle/move_effects/hidden_power.asm
new file mode 100644
index 000000000..f96becf97
--- /dev/null
+++ b/engine/battle/move_effects/hidden_power.asm
@@ -0,0 +1,10 @@
+BattleCommand_HiddenPower: ; 37be8
+; hiddenpower
+
+ ld a, [wAttackMissed]
+ and a
+ ret nz
+ farcall HiddenPowerDamage
+ ret
+
+; 37bf4
diff --git a/engine/battle/move_effects/leech_seed.asm b/engine/battle/move_effects/leech_seed.asm
new file mode 100644
index 000000000..328a2c416
--- /dev/null
+++ b/engine/battle/move_effects/leech_seed.asm
@@ -0,0 +1,42 @@
+BattleCommand_LeechSeed: ; 36f9d
+; leechseed
+ ld a, [wAttackMissed]
+ and a
+ jr nz, .evaded
+ call CheckSubstituteOpp
+ jr nz, .evaded
+
+ ld de, wEnemyMonType1
+ ld a, [hBattleTurn]
+ and a
+ jr z, .ok
+ ld de, wBattleMonType1
+.ok
+
+ ld a, [de]
+ cp GRASS
+ jr z, .grass
+ inc de
+ ld a, [de]
+ cp GRASS
+ jr z, .grass
+
+ ld a, BATTLE_VARS_SUBSTATUS4_OPP
+ call GetBattleVarAddr
+ bit SUBSTATUS_LEECH_SEED, [hl]
+ jr nz, .evaded
+ set SUBSTATUS_LEECH_SEED, [hl]
+ call AnimateCurrentMove
+ ld hl, WasSeededText
+ jp StdBattleTextBox
+
+.grass
+ call AnimateFailedMove
+ jp PrintDoesntAffect
+
+.evaded
+ call AnimateFailedMove
+ ld hl, EvadedText
+ jp StdBattleTextBox
+
+; 36fe1
diff --git a/engine/battle/move_effects/lock_on.asm b/engine/battle/move_effects/lock_on.asm
new file mode 100644
index 000000000..36d8db926
--- /dev/null
+++ b/engine/battle/move_effects/lock_on.asm
@@ -0,0 +1,23 @@
+BattleCommand_LockOn: ; 35a53
+; lockon
+
+ call CheckSubstituteOpp
+ jr nz, .fail
+
+ ld a, [wAttackMissed]
+ and a
+ jr nz, .fail
+
+ ld a, BATTLE_VARS_SUBSTATUS5_OPP
+ call GetBattleVarAddr
+ set SUBSTATUS_LOCK_ON, [hl]
+ call AnimateCurrentMove
+
+ ld hl, TookAimText
+ jp StdBattleTextBox
+
+.fail
+ call AnimateFailedMove
+ jp PrintDidntAffect
+
+; 35a74
diff --git a/engine/battle/move_effects/magnitude.asm b/engine/battle/move_effects/magnitude.asm
new file mode 100644
index 000000000..f56ec5c1b
--- /dev/null
+++ b/engine/battle/move_effects/magnitude.asm
@@ -0,0 +1,29 @@
+BattleCommand_GetMagnitude: ; 37991
+; getmagnitude
+
+ push bc
+ call BattleRandom
+ ld b, a
+ ld hl, MagnitudePower
+.loop
+ ld a, [hli]
+ cp b
+ jr nc, .ok
+ inc hl
+ inc hl
+ jr .loop
+
+.ok
+ ld d, [hl]
+ push de
+ inc hl
+ ld a, [hl]
+ ld [wTypeMatchup], a
+ call BattleCommand_MoveDelay
+ ld hl, MagnitudeText
+ call StdBattleTextBox
+ pop de
+ pop bc
+ ret
+
+INCLUDE "data/moves/magnitude_power.asm"
diff --git a/engine/battle/effect_commands/metronome.asm b/engine/battle/move_effects/metronome.asm
index 1908df84d..6835ab569 100644
--- a/engine/battle/effect_commands/metronome.asm
+++ b/engine/battle/move_effects/metronome.asm
@@ -43,19 +43,4 @@ BattleCommand_Metronome: ; 37418
; 37454
-MetronomeExcepts: ; 37454
- db NO_MOVE
- db METRONOME
- db STRUGGLE
- db SKETCH
- db MIMIC
- db COUNTER
- db MIRROR_COAT
- db PROTECT
- db DETECT
- db ENDURE
- db DESTINY_BOND
- db SLEEP_TALK
- db THIEF
- db -1
-; 37462
+INCLUDE "data/battle/metronome_exception_moves.asm"
diff --git a/engine/battle/move_effects/mimic.asm b/engine/battle/move_effects/mimic.asm
new file mode 100644
index 000000000..712b42df1
--- /dev/null
+++ b/engine/battle/move_effects/mimic.asm
@@ -0,0 +1,52 @@
+BattleCommand_Mimic: ; 36f46
+; mimic
+
+ call ClearLastMove
+ call BattleCommand_MoveDelay
+ ld a, [wAttackMissed]
+ and a
+ jr nz, .fail
+ ld hl, wBattleMonMoves
+ ld a, [hBattleTurn]
+ and a
+ jr z, .player_turn
+ ld hl, wEnemyMonMoves
+.player_turn
+ call CheckHiddenOpponent
+ jr nz, .fail
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ and a
+ jr z, .fail
+ cp STRUGGLE
+ jr z, .fail
+ ld b, a
+ ld c, NUM_MOVES
+.check_already_knows_move
+ ld a, [hli]
+ cp b
+ jr z, .fail
+ dec c
+ jr nz, .check_already_knows_move
+ dec hl
+.find_mimic
+ ld a, [hld]
+ cp MIMIC
+ jr nz, .find_mimic
+ inc hl
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ ld [hl], a
+ ld [wNamedObjectIndexBuffer], a
+ ld bc, wBattleMonPP - wBattleMonMoves
+ add hl, bc
+ ld [hl], 5
+ call GetMoveName
+ call AnimateCurrentMove
+ ld hl, LearnedMoveText
+ jp StdBattleTextBox
+
+.fail
+ jp FailMimic
+
+; 36f9d
diff --git a/engine/battle/move_effects/mirror_coat.asm b/engine/battle/move_effects/mirror_coat.asm
new file mode 100644
index 000000000..41e296108
--- /dev/null
+++ b/engine/battle/move_effects/mirror_coat.asm
@@ -0,0 +1,61 @@
+BattleCommand_MirrorCoat: ; 37c95
+; mirrorcoat
+
+ ld a, 1
+ ld [wAttackMissed], a
+
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ and a
+ ret z
+
+ ld b, a
+ callfar GetMoveEffect
+ ld a, b
+ cp EFFECT_MIRROR_COAT
+ ret z
+
+ call BattleCommand_ResetTypeMatchup
+ ld a, [wTypeMatchup]
+ and a
+ ret z
+
+ call CheckOpponentWentFirst
+ ret z
+
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ dec a
+ ld de, wStringBuffer1
+ call GetMoveData
+
+ ld a, [wStringBuffer1 + 2]
+ and a
+ ret z
+
+ ld a, [wStringBuffer1 + 3]
+ cp SPECIAL
+ ret c
+
+ ld hl, wCurDamage
+ ld a, [hli]
+ or [hl]
+ ret z
+
+ ld a, [hl]
+ add a
+ ld [hld], a
+ ld a, [hl]
+ adc a
+ ld [hl], a
+ jr nc, .capped
+ ld a, $ff
+ ld [hli], a
+ ld [hl], a
+.capped
+
+ xor a
+ ld [wAttackMissed], a
+ ret
+
+; 37ce6
diff --git a/engine/battle/effect_commands/mirror_move.asm b/engine/battle/move_effects/mirror_move.asm
index c4f208d77..c4f208d77 100644
--- a/engine/battle/effect_commands/mirror_move.asm
+++ b/engine/battle/move_effects/mirror_move.asm
diff --git a/engine/battle/move_effects/mist.asm b/engine/battle/move_effects/mist.asm
new file mode 100644
index 000000000..9ffd86c8e
--- /dev/null
+++ b/engine/battle/move_effects/mist.asm
@@ -0,0 +1,17 @@
+BattleCommand_Mist: ; 36c7e
+; mist
+
+ ld a, BATTLE_VARS_SUBSTATUS4
+ call GetBattleVarAddr
+ bit SUBSTATUS_MIST, [hl]
+ jr nz, .already_mist
+ set SUBSTATUS_MIST, [hl]
+ call AnimateCurrentMove
+ ld hl, MistText
+ jp StdBattleTextBox
+
+.already_mist
+ call AnimateFailedMove
+ jp PrintButItFailed
+
+; 36c98
diff --git a/engine/battle/effect_commands/nightmare.asm b/engine/battle/move_effects/nightmare.asm
index 788e3de41..788e3de41 100644
--- a/engine/battle/effect_commands/nightmare.asm
+++ b/engine/battle/move_effects/nightmare.asm
diff --git a/engine/battle/move_effects/pain_split.asm b/engine/battle/move_effects/pain_split.asm
new file mode 100644
index 000000000..2db3726c6
--- /dev/null
+++ b/engine/battle/move_effects/pain_split.asm
@@ -0,0 +1,97 @@
+BattleCommand_PainSplit: ; 35926
+; painsplit
+
+ ld a, [wAttackMissed]
+ and a
+ jp nz, .ButItFailed
+ call CheckSubstituteOpp
+ jp nz, .ButItFailed
+ call AnimateCurrentMove
+ ld hl, wBattleMonMaxHP + 1
+ ld de, wEnemyMonMaxHP + 1
+ call .PlayerShareHP
+ ld a, $1
+ ld [wWhichHPBar], a
+ hlcoord 10, 9
+ predef AnimateHPBar
+ ld hl, wEnemyMonHP
+ ld a, [hli]
+ ld [wBuffer4], a
+ ld a, [hli]
+ ld [wBuffer3], a
+ ld a, [hli]
+ ld [wBuffer2], a
+ ld a, [hl]
+ ld [wBuffer1], a
+ call .EnemyShareHP
+ xor a
+ ld [wWhichHPBar], a
+ call ResetDamage
+ hlcoord 2, 2
+ predef AnimateHPBar
+ farcall _UpdateBattleHUDs
+
+ ld hl, SharedPainText
+ jp StdBattleTextBox
+
+.PlayerShareHP:
+ ld a, [hld]
+ ld [wBuffer1], a
+ ld a, [hld]
+ ld [wBuffer2], a
+ ld a, [hld]
+ ld b, a
+ ld [wBuffer3], a
+ ld a, [hl]
+ ld [wBuffer4], a
+ dec de
+ dec de
+ ld a, [de]
+ dec de
+ add b
+ ld [wCurDamage + 1], a
+ ld b, [hl]
+ ld a, [de]
+ adc b
+ srl a
+ ld [wCurDamage], a
+ ld a, [wCurDamage + 1]
+ rr a
+ ld [wCurDamage + 1], a
+ inc hl
+ inc hl
+ inc hl
+ inc de
+ inc de
+ inc de
+
+.EnemyShareHP: ; 359ac
+ ld c, [hl]
+ dec hl
+ ld a, [wCurDamage + 1]
+ sub c
+ ld b, [hl]
+ dec hl
+ ld a, [wCurDamage]
+ sbc b
+ jr nc, .skip
+
+ ld a, [wCurDamage]
+ ld b, a
+ ld a, [wCurDamage + 1]
+ ld c, a
+.skip
+ ld a, c
+ ld [hld], a
+ ld [wBuffer5], a
+ ld a, b
+ ld [hli], a
+ ld [wBuffer6], a
+ ret
+
+; 359cd
+
+.ButItFailed:
+ jp PrintDidntAffect2
+
+; 359d0
diff --git a/engine/battle/move_effects/pay_day.asm b/engine/battle/move_effects/pay_day.asm
new file mode 100644
index 000000000..a5d2fed0d
--- /dev/null
+++ b/engine/battle/move_effects/pay_day.asm
@@ -0,0 +1,28 @@
+BattleCommand_PayDay: ; 3705c
+; payday
+
+ xor a
+ ld hl, wStringBuffer1
+ ld [hli], a
+
+ ld a, [hBattleTurn]
+ and a
+ ld a, [wBattleMonLevel]
+ jr z, .ok
+ ld a, [wEnemyMonLevel]
+.ok
+
+ add a
+ ld hl, wPayDayMoney + 2
+ add [hl]
+ ld [hld], a
+ jr nc, .done
+ inc [hl]
+ dec hl
+ jr nz, .done
+ inc [hl]
+.done
+ ld hl, CoinsScatteredText
+ jp StdBattleTextBox
+
+; 3707f
diff --git a/engine/battle/effect_commands/perish_song.asm b/engine/battle/move_effects/perish_song.asm
index 8c88c8739..8c88c8739 100644
--- a/engine/battle/effect_commands/perish_song.asm
+++ b/engine/battle/move_effects/perish_song.asm
diff --git a/engine/battle/effect_commands/present.asm b/engine/battle/move_effects/present.asm
index f0cf8006d..a2ef5bc64 100755
--- a/engine/battle/effect_commands/present.asm
+++ b/engine/battle/move_effects/present.asm
@@ -27,7 +27,7 @@ BattleCommand_Present: ; 37874
push bc
call BattleRandom
ld b, a
- ld hl, .PresentPower
+ ld hl, PresentPower
ld c, 0
.next
ld a, [hli]
@@ -49,7 +49,7 @@ BattleCommand_Present: ; 37874
.heal_effect
pop bc
- ld a, $3
+ ld a, 3
ld [wPresentPower], a
call AnimateCurrentMove
call BattleCommand_SwitchTurn
@@ -85,9 +85,4 @@ BattleCommand_Present: ; 37874
.do_animation
jp EndMoveEffect
-.PresentPower:
- db 40 percent, 40
- db 70 percent + 1, 80
- db 80 percent, 120
- db -1 ; end
-; 3790e
+INCLUDE "data/moves/present_power.asm"
diff --git a/engine/battle/effect_commands/protect.asm b/engine/battle/move_effects/protect.asm
index 6c65e0ed1..6c65e0ed1 100644
--- a/engine/battle/effect_commands/protect.asm
+++ b/engine/battle/move_effects/protect.asm
diff --git a/engine/battle/move_effects/psych_up.asm b/engine/battle/move_effects/psych_up.asm
new file mode 100644
index 000000000..c57fff9cd
--- /dev/null
+++ b/engine/battle/move_effects/psych_up.asm
@@ -0,0 +1,51 @@
+BattleCommand_PsychUp: ; 37c55
+; psychup
+
+ ld hl, wEnemyStatLevels
+ ld de, wPlayerStatLevels
+ ld a, [hBattleTurn]
+ and a
+ jr z, .pointers_correct
+; It's the enemy's turn, so swap the pointers.
+ push hl
+ ld h, d
+ ld l, e
+ pop de
+.pointers_correct
+ push hl
+ 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
+ ld a, [hli]
+ cp BASE_STAT_LEVEL
+ jr nz, .break
+ dec b
+ jr nz, .loop
+ pop hl
+ call AnimateFailedMove
+ jp PrintButItFailed
+
+.break
+ pop hl
+ ld b, NUM_LEVEL_STATS
+.loop2
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .loop2
+ ld a, [hBattleTurn]
+ and a
+ jr nz, .calc_enemy_stats
+ call CalcPlayerStats
+ jr .merge
+
+.calc_enemy_stats
+ call CalcEnemyStats
+.merge
+ call AnimateCurrentMove
+ ld hl, CopiedStatsText
+ jp StdBattleTextBox
+
+; 37c95
diff --git a/engine/battle/move_effects/pursuit.asm b/engine/battle/move_effects/pursuit.asm
new file mode 100644
index 000000000..969e08f73
--- /dev/null
+++ b/engine/battle/move_effects/pursuit.asm
@@ -0,0 +1,26 @@
+BattleCommand_Pursuit: ; 37b1d
+; pursuit
+; Double damage if the opponent is switching.
+
+ ld hl, wEnemyIsSwitching
+ ld a, [hBattleTurn]
+ and a
+ jr z, .ok
+ ld hl, wPlayerIsSwitching
+.ok
+ ld a, [hl]
+ and a
+ ret z
+
+ ld hl, wCurDamage + 1
+ sla [hl]
+ dec hl
+ rl [hl]
+ ret nc
+
+ ld a, $ff
+ ld [hli], a
+ ld [hl], a
+ ret
+
+; 37b39
diff --git a/engine/battle/move_effects/rage.asm b/engine/battle/move_effects/rage.asm
new file mode 100644
index 000000000..ac01f8137
--- /dev/null
+++ b/engine/battle/move_effects/rage.asm
@@ -0,0 +1,8 @@
+BattleCommand_Rage: ; 36f1d
+; rage
+ ld a, BATTLE_VARS_SUBSTATUS4
+ call GetBattleVarAddr
+ set SUBSTATUS_RAGE, [hl]
+ ret
+
+; 36f25
diff --git a/engine/battle/move_effects/rain_dance.asm b/engine/battle/move_effects/rain_dance.asm
new file mode 100644
index 000000000..6c587d551
--- /dev/null
+++ b/engine/battle/move_effects/rain_dance.asm
@@ -0,0 +1,11 @@
+BattleCommand_StartRain: ; 37bf4
+; startrain
+ ld a, WEATHER_RAIN
+ ld [wBattleWeather], a
+ ld a, 5
+ ld [wWeatherCount], a
+ call AnimateCurrentMove
+ ld hl, DownpourText
+ jp StdBattleTextBox
+
+; 37c07
diff --git a/engine/battle/move_effects/rapid_spin.asm b/engine/battle/move_effects/rapid_spin.asm
new file mode 100644
index 000000000..84bcbad7f
--- /dev/null
+++ b/engine/battle/move_effects/rapid_spin.asm
@@ -0,0 +1,38 @@
+BattleCommand_ClearHazards: ; 37b39
+; clearhazards
+
+ ld a, BATTLE_VARS_SUBSTATUS4
+ call GetBattleVarAddr
+ bit SUBSTATUS_LEECH_SEED, [hl]
+ jr z, .not_leeched
+ res SUBSTATUS_LEECH_SEED, [hl]
+ ld hl, ShedLeechSeedText
+ call StdBattleTextBox
+.not_leeched
+
+ ld hl, wPlayerScreens
+ ld de, wPlayerWrapCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_screens_wrap
+ ld hl, wEnemyScreens
+ ld de, wEnemyWrapCount
+.got_screens_wrap
+ bit SCREENS_SPIKES, [hl]
+ jr z, .no_spikes
+ res SCREENS_SPIKES, [hl]
+ ld hl, BlewSpikesText
+ push de
+ call StdBattleTextBox
+ pop de
+.no_spikes
+
+ ld a, [de]
+ and a
+ ret z
+ xor a
+ ld [de], a
+ ld hl, ReleasedByText
+ jp StdBattleTextBox
+
+; 37b74
diff --git a/engine/battle/move_effects/return.asm b/engine/battle/move_effects/return.asm
new file mode 100644
index 000000000..e1d568e7c
--- /dev/null
+++ b/engine/battle/move_effects/return.asm
@@ -0,0 +1,27 @@
+BattleCommand_HappinessPower: ; 3784b
+; happinesspower
+ push bc
+ ld hl, wBattleMonHappiness
+ ld a, [hBattleTurn]
+ and a
+ jr z, .ok
+ ld hl, wEnemyMonHappiness
+.ok
+ xor a
+ ld [hMultiplicand + 0], a
+ ld [hMultiplicand + 1], a
+ ld a, [hl]
+ ld [hMultiplicand + 2], a
+ ld a, 10
+ ld [hMultiplier], a
+ call Multiply
+ ld a, 25
+ ld [hDivisor], a
+ ld b, 4
+ call Divide
+ ld a, [hQuotient + 2]
+ ld d, a
+ pop bc
+ ret
+
+; 37874
diff --git a/engine/battle/effect_commands/rollout.asm b/engine/battle/move_effects/rollout.asm
index f6966c48a..f6966c48a 100644
--- a/engine/battle/effect_commands/rollout.asm
+++ b/engine/battle/move_effects/rollout.asm
diff --git a/engine/battle/move_effects/safeguard.asm b/engine/battle/move_effects/safeguard.asm
new file mode 100644
index 000000000..1dc233eab
--- /dev/null
+++ b/engine/battle/move_effects/safeguard.asm
@@ -0,0 +1,25 @@
+BattleCommand_Safeguard: ; 37939
+; safeguard
+
+ ld hl, wPlayerScreens
+ ld de, wPlayerSafeguardCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .ok
+ ld hl, wEnemyScreens
+ ld de, wEnemySafeguardCount
+.ok
+ bit SCREENS_SAFEGUARD, [hl]
+ jr nz, .failed
+ set SCREENS_SAFEGUARD, [hl]
+ ld a, 5
+ ld [de], a
+ call AnimateCurrentMove
+ ld hl, CoveredByVeilText
+ jp StdBattleTextBox
+
+.failed
+ call AnimateFailedMove
+ jp PrintButItFailed
+
+; 37962
diff --git a/engine/battle/effect_commands/sandstorm.asm b/engine/battle/move_effects/sandstorm.asm
index 5aaa61deb..5aaa61deb 100644
--- a/engine/battle/effect_commands/sandstorm.asm
+++ b/engine/battle/move_effects/sandstorm.asm
diff --git a/engine/battle/move_effects/selfdestruct.asm b/engine/battle/move_effects/selfdestruct.asm
new file mode 100644
index 000000000..6f6b0966f
--- /dev/null
+++ b/engine/battle/move_effects/selfdestruct.asm
@@ -0,0 +1,31 @@
+BattleCommand_Selfdestruct: ; 37380
+ farcall StubbedTrainerRankings_Selfdestruct
+ ld a, BATTLEANIM_PLAYER_DAMAGE
+ ld [wNumHits], a
+ ld c, 3
+ call DelayFrames
+ ld a, BATTLE_VARS_STATUS
+ call GetBattleVarAddr
+ xor a
+ ld [hli], a
+ inc hl
+ ld [hli], a
+ ld [hl], a
+ ld a, $1
+ ld [wKickCounter], a
+ call BattleCommand_LowerSub
+ call LoadMoveAnim
+ ld a, BATTLE_VARS_SUBSTATUS4
+ call GetBattleVarAddr
+ res SUBSTATUS_LEECH_SEED, [hl]
+ ld a, BATTLE_VARS_SUBSTATUS5_OPP
+ call GetBattleVarAddr
+ res SUBSTATUS_DESTINY_BOND, [hl]
+ call _CheckBattleScene
+ ret nc
+ farcall DrawPlayerHUD
+ farcall DrawEnemyHUD
+ call WaitBGMap
+ jp RefreshBattleHuds
+
+; 373c9
diff --git a/engine/battle/move_effects/sketch.asm b/engine/battle/move_effects/sketch.asm
new file mode 100644
index 000000000..93f7ff30c
--- /dev/null
+++ b/engine/battle/move_effects/sketch.asm
@@ -0,0 +1,119 @@
+BattleCommand_Sketch: ; 35a74
+; sketch
+
+ call ClearLastMove
+; Don't sketch during a link battle
+ ld a, [wLinkMode]
+ and a
+ jr z, .not_linked
+ call AnimateFailedMove
+ jp PrintNothingHappened
+
+.not_linked
+; If the opponent has a substitute up, fail.
+ call CheckSubstituteOpp
+ jp nz, .fail
+; If the opponent is transformed, fail.
+ ld a, BATTLE_VARS_SUBSTATUS5_OPP
+ call GetBattleVarAddr
+ bit SUBSTATUS_TRANSFORMED, [hl]
+ jp nz, .fail
+; Get the user's moveset in its party struct.
+; This move replacement shall be permanent.
+; Pointer will be in de.
+ ld a, MON_MOVES
+ call UserPartyAttr
+ ld d, h
+ ld e, l
+; Get the battle move structs.
+ ld hl, wBattleMonMoves
+ ld a, [hBattleTurn]
+ and a
+ jr z, .get_last_move
+ ld hl, wEnemyMonMoves
+.get_last_move
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ ld [wTypeMatchup], a
+ ld b, a
+; Fail if move is invalid or is Struggle.
+ and a
+ jr z, .fail
+ cp STRUGGLE
+ jr z, .fail
+; Fail if user already knows that move
+ ld c, NUM_MOVES
+.does_user_already_know_move
+ ld a, [hli]
+ cp b
+ jr z, .fail
+ dec c
+ jr nz, .does_user_already_know_move
+; Find Sketch in the user's moveset.
+; Pointer in hl, and index in c.
+ dec hl
+ ld c, NUM_MOVES
+.find_sketch
+ dec c
+ ld a, [hld]
+ cp SKETCH
+ jr nz, .find_sketch
+ inc hl
+; The Sketched move is loaded to that slot.
+ ld a, b
+ ld [hl], a
+; Copy the base PP from that move.
+ push bc
+ push hl
+ dec a
+ ld hl, Moves + MOVE_PP
+ call GetMoveAttr
+ pop hl
+ ld bc, wBattleMonPP - wBattleMonMoves
+ add hl, bc
+ ld [hl], a
+ pop bc
+
+ ld a, [hBattleTurn]
+ and a
+ jr z, .user_trainer
+ ld a, [wBattleMode]
+ dec a
+ jr nz, .user_trainer
+; wildmon
+ ld a, [hl]
+ push bc
+ ld hl, wWildMonPP
+ ld b, 0
+ add hl, bc
+ ld [hl], a
+ ld hl, wWildMonMoves
+ add hl, bc
+ pop bc
+ ld [hl], b
+ jr .done_copy
+
+.user_trainer
+ ld a, [hl]
+ push af
+ ld l, c
+ ld h, 0
+ add hl, de
+ ld a, b
+ ld [hl], a
+ pop af
+ ld de, MON_PP - MON_MOVES
+ add hl, de
+ ld [hl], a
+.done_copy
+ call GetMoveName
+ call AnimateCurrentMove
+
+ ld hl, SketchedText
+ jp StdBattleTextBox
+
+.fail
+ call AnimateFailedMove
+ jp PrintDidntAffect
+
+; 35b16
diff --git a/engine/battle/move_effects/sleep_talk.asm b/engine/battle/move_effects/sleep_talk.asm
new file mode 100644
index 000000000..3f62d4e36
--- /dev/null
+++ b/engine/battle/move_effects/sleep_talk.asm
@@ -0,0 +1,145 @@
+BattleCommand_SleepTalk: ; 35b33
+; sleeptalk
+
+ call ClearLastMove
+ ld a, [wAttackMissed]
+ and a
+ jr nz, .fail
+ ld a, [hBattleTurn]
+ and a
+ ld hl, wBattleMonMoves + 1
+ ld a, [wDisabledMove]
+ ld d, a
+ jr z, .got_moves
+ ld hl, wEnemyMonMoves + 1
+ ld a, [wEnemyDisabledMove]
+ ld d, a
+.got_moves
+ ld a, BATTLE_VARS_STATUS
+ call GetBattleVar
+ and SLP
+ jr z, .fail
+ ld a, [hl]
+ and a
+ jr z, .fail
+ call .safely_check_has_usable_move
+ jr c, .fail
+ dec hl
+.sample_move
+ push hl
+ call BattleRandom
+ maskbits NUM_MOVES
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [hl]
+ pop hl
+ and a
+ jr z, .sample_move
+ ld e, a
+ ld a, BATTLE_VARS_MOVE_ANIM
+ call GetBattleVar
+ cp e
+ jr z, .sample_move
+ ld a, e
+ cp d
+ jr z, .sample_move
+ call .check_two_turn_move
+ jr z, .sample_move
+ ld a, BATTLE_VARS_MOVE
+ call GetBattleVarAddr
+ ld a, e
+ ld [hl], a
+ call CheckUserIsCharging
+ jr nz, .charging
+ ld a, [wKickCounter]
+ push af
+ call BattleCommand_LowerSub
+ pop af
+ ld [wKickCounter], a
+.charging
+ call LoadMoveAnim
+ call UpdateMoveData
+ jp ResetTurn
+
+.fail
+ call AnimateFailedMove
+ jp TryPrintButItFailed
+
+.safely_check_has_usable_move
+ push hl
+ push de
+ push bc
+ call .check_has_usable_move
+ pop bc
+ pop de
+ pop hl
+ ret
+
+.check_has_usable_move
+ ld a, [hBattleTurn]
+ and a
+ ld a, [wDisabledMove]
+ jr z, .got_move_2
+
+ ld a, [wEnemyDisabledMove]
+.got_move_2
+ ld b, a
+ ld a, BATTLE_VARS_MOVE
+ call GetBattleVar
+ ld c, a
+ dec hl
+ ld d, NUM_MOVES
+.loop2
+ ld a, [hl]
+ and a
+ jr z, .carry
+
+ cp c
+ jr z, .nope
+ cp b
+ jr z, .nope
+
+ call .check_two_turn_move
+ jr nz, .no_carry
+
+.nope
+ inc hl
+ dec d
+ jr nz, .loop2
+
+.carry
+ scf
+ ret
+
+.no_carry
+ and a
+ ret
+
+.check_two_turn_move
+ push hl
+ push de
+ push bc
+
+ ld b, a
+ callfar GetMoveEffect
+ ld a, b
+
+ pop bc
+ pop de
+ pop hl
+
+ cp EFFECT_SKULL_BASH
+ ret z
+ cp EFFECT_RAZOR_WIND
+ ret z
+ cp EFFECT_SKY_ATTACK
+ ret z
+ cp EFFECT_SOLARBEAM
+ ret z
+ cp EFFECT_FLY
+ ret z
+ cp EFFECT_BIDE
+ ret
+
+; 35bff
diff --git a/engine/battle/move_effects/snore.asm b/engine/battle/move_effects/snore.asm
new file mode 100644
index 000000000..49fb1b210
--- /dev/null
+++ b/engine/battle/move_effects/snore.asm
@@ -0,0 +1,13 @@
+BattleCommand_Snore: ; 359d0
+; snore
+ ld a, BATTLE_VARS_STATUS
+ call GetBattleVar
+ and SLP
+ ret nz
+ call ResetDamage
+ ld a, $1
+ ld [wAttackMissed], a
+ call FailMove
+ jp EndMoveEffect
+
+; 359e6
diff --git a/engine/battle/effect_commands/spikes.asm b/engine/battle/move_effects/spikes.asm
index a5e22a706..6cab0b96f 100644
--- a/engine/battle/effect_commands/spikes.asm
+++ b/engine/battle/move_effects/spikes.asm
@@ -23,5 +23,5 @@ BattleCommand_Spikes: ; 37683
jp StdBattleTextBox
.failed
- jp FailSpikes
+ jp FailMove
; 376a0
diff --git a/engine/battle/move_effects/spite.asm b/engine/battle/move_effects/spite.asm
new file mode 100644
index 000000000..30a908ae7
--- /dev/null
+++ b/engine/battle/move_effects/spite.asm
@@ -0,0 +1,88 @@
+BattleCommand_Spite: ; 35c0f
+; spite
+
+ ld a, [wAttackMissed]
+ and a
+ jp nz, .failed
+ ld bc, PARTYMON_STRUCT_LENGTH ; ????
+ ld hl, wEnemyMonMoves
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_moves
+ ld hl, wBattleMonMoves
+.got_moves
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ and a
+ jr z, .failed
+ cp STRUGGLE
+ jr z, .failed
+ ld b, a
+ ld c, -1
+.loop
+ inc c
+ ld a, [hli]
+ cp b
+ jr nz, .loop
+ ld [wTypeMatchup], a
+ dec hl
+ ld b, 0
+ push bc
+ ld c, wBattleMonPP - wBattleMonMoves
+ add hl, bc
+ pop bc
+ ld a, [hl]
+ and PP_MASK
+ jr z, .failed
+ push bc
+ call GetMoveName
+ ; lose 2-5 PP
+ call BattleRandom
+ and %11
+ inc a
+ inc a
+ ld b, a
+ ld a, [hl]
+ and PP_MASK
+ cp b
+ jr nc, .deplete_pp
+ ld b, a
+.deplete_pp
+ ld a, [hl]
+ sub b
+ ld [hl], a
+ push af
+ ld a, MON_PP
+ call OpponentPartyAttr
+ ld d, b
+ pop af
+ pop bc
+ add hl, bc
+ ld e, a
+ ld a, BATTLE_VARS_SUBSTATUS5_OPP
+ call GetBattleVar
+ bit SUBSTATUS_TRANSFORMED, a
+ jr nz, .transformed
+ ld a, [hBattleTurn]
+ and a
+ jr nz, .not_wildmon
+ ld a, [wBattleMode]
+ dec a
+ jr nz, .not_wildmon
+ ld hl, wWildMonPP
+ add hl, bc
+.not_wildmon
+ ld [hl], e
+.transformed
+ push de
+ call AnimateCurrentMove
+ pop de
+ ld a, d
+ ld [wTypeMatchup], a
+ ld hl, SpiteEffectText
+ jp StdBattleTextBox
+
+.failed
+ jp PrintDidntAffect2
+
+; 35c94
diff --git a/engine/battle/move_effects/splash.asm b/engine/battle/move_effects/splash.asm
new file mode 100644
index 000000000..5b5e504b8
--- /dev/null
+++ b/engine/battle/move_effects/splash.asm
@@ -0,0 +1,6 @@
+BattleCommand_Splash: ; 36fe1
+ call AnimateCurrentMove
+ farcall StubbedTrainerRankings_Splash
+ jp PrintNothingHappened
+
+; 36fed
diff --git a/engine/battle/move_effects/substitute.asm b/engine/battle/move_effects/substitute.asm
new file mode 100644
index 000000000..1deaa848d
--- /dev/null
+++ b/engine/battle/move_effects/substitute.asm
@@ -0,0 +1,90 @@
+BattleCommand_Substitute: ; 36e7c
+; substitute
+
+ call BattleCommand_MoveDelay
+ ld hl, wBattleMonMaxHP
+ ld de, wPlayerSubstituteHP
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_hp
+ ld hl, wEnemyMonMaxHP
+ ld de, wEnemySubstituteHP
+.got_hp
+
+ ld a, BATTLE_VARS_SUBSTATUS4
+ call GetBattleVar
+ bit SUBSTATUS_SUBSTITUTE, a
+ jr nz, .already_has_sub
+
+ ld a, [hli]
+ ld b, [hl]
+ srl a
+ rr b
+ srl a
+ rr b
+ dec hl
+ dec hl
+ ld a, b
+ ld [de], a
+ ld a, [hld]
+ sub b
+ ld e, a
+ ld a, [hl]
+ sbc 0
+ ld d, a
+ jr c, .too_weak_to_sub
+ ld a, d
+ or e
+ jr z, .too_weak_to_sub
+ ld [hl], d
+ inc hl
+ ld [hl], e
+
+ ld a, BATTLE_VARS_SUBSTATUS4
+ call GetBattleVarAddr
+ set SUBSTATUS_SUBSTITUTE, [hl]
+
+ ld hl, wPlayerWrapCount
+ ld de, wPlayerTrappingMove
+ ld a, [hBattleTurn]
+ and a
+ jr z, .player
+ ld hl, wEnemyWrapCount
+ ld de, wEnemyTrappingMove
+.player
+
+ xor a
+ ld [hl], a
+ ld [de], a
+ call _CheckBattleScene
+ jr c, .no_anim
+
+ xor a
+ ld [wNumHits], a
+ ld [wFXAnimID + 1], a
+ ld [wKickCounter], a
+ ld a, SUBSTITUTE
+ call LoadAnim
+ jr .finish
+
+.no_anim
+ call BattleCommand_RaiseSubNoAnim
+.finish
+ ld hl, MadeSubstituteText
+ call StdBattleTextBox
+ jp RefreshBattleHuds
+
+.already_has_sub
+ call CheckUserIsCharging
+ call nz, BattleCommand_RaiseSub
+ ld hl, HasSubstituteText
+ jr .jp_stdbattletextbox
+
+.too_weak_to_sub
+ call CheckUserIsCharging
+ call nz, BattleCommand_RaiseSub
+ ld hl, TooWeakSubText
+.jp_stdbattletextbox
+ jp StdBattleTextBox
+
+; 36f0b
diff --git a/engine/battle/move_effects/sunny_day.asm b/engine/battle/move_effects/sunny_day.asm
new file mode 100644
index 000000000..ef8c37c5c
--- /dev/null
+++ b/engine/battle/move_effects/sunny_day.asm
@@ -0,0 +1,11 @@
+BattleCommand_StartSun: ; 37c07
+; startsun
+ ld a, WEATHER_SUN
+ ld [wBattleWeather], a
+ ld a, 5
+ ld [wWeatherCount], a
+ call AnimateCurrentMove
+ ld hl, SunGotBrightText
+ jp StdBattleTextBox
+
+; 37c1a
diff --git a/engine/battle/move_effects/teleport.asm b/engine/battle/move_effects/teleport.asm
new file mode 100644
index 000000000..1bd1eb725
--- /dev/null
+++ b/engine/battle/move_effects/teleport.asm
@@ -0,0 +1,91 @@
+BattleCommand_Teleport: ; 36778
+; teleport
+
+ ld a, [wBattleType]
+ cp BATTLETYPE_SHINY
+ jr z, .failed
+ cp BATTLETYPE_TRAP
+ jr z, .failed
+ cp BATTLETYPE_CELEBI
+ jr z, .failed
+ cp BATTLETYPE_SUICUNE
+ jr z, .failed
+
+ ld a, BATTLE_VARS_SUBSTATUS5_OPP
+ call GetBattleVar
+ bit SUBSTATUS_CANT_RUN, a
+ jr nz, .failed
+; Only need to check these next things if it's your turn
+ ld a, [hBattleTurn]
+ and a
+ jr nz, .enemy_turn
+; Can't teleport from a trainer battle
+ ld a, [wBattleMode]
+ dec a
+ jr nz, .failed
+; If your level is greater than the opponent's, you run without fail.
+ ld a, [wCurPartyLevel]
+ ld b, a
+ ld a, [wBattleMonLevel]
+ cp b
+ jr nc, .run_away
+; Generate a number between 0 and (YourLevel + TheirLevel).
+ add b
+ ld c, a
+ inc c
+.loop_player
+ call BattleRandom
+ cp c
+ jr nc, .loop_player
+; If that number is greater than 4 times your level, run away.
+ srl b
+ srl b
+ cp b
+ jr nc, .run_away
+
+.failed
+ call AnimateFailedMove
+ jp PrintButItFailed
+
+.enemy_turn
+ ld a, [wBattleMode]
+ dec a
+ jr nz, .failed
+ ld a, [wBattleMonLevel]
+ ld b, a
+ ld a, [wCurPartyLevel]
+ cp b
+ jr nc, .run_away
+ add b
+ ld c, a
+ inc c
+.loop_enemy
+ call BattleRandom
+ cp c
+ jr nc, .loop_enemy
+ srl b
+ srl b
+ cp b
+ ; 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
+ jr nc, .run_away
+.run_away
+ call UpdateBattleMonInParty
+ xor a
+ ld [wNumHits], a
+ inc a
+ ld [wForcedSwitch], a
+ ld [wKickCounter], a
+ call SetBattleDraw
+ call BattleCommand_LowerSub
+ call LoadMoveAnim
+ ld c, 20
+ call DelayFrames
+ call SetBattleDraw
+
+ ld hl, FledFromBattleText
+ jp StdBattleTextBox
+
+; 36804
diff --git a/engine/battle/effect_commands/thief.asm b/engine/battle/move_effects/thief.asm
index 5397c2bdf..5397c2bdf 100644
--- a/engine/battle/effect_commands/thief.asm
+++ b/engine/battle/move_effects/thief.asm
diff --git a/engine/battle/move_effects/thunder.asm b/engine/battle/move_effects/thunder.asm
new file mode 100644
index 000000000..3705e1a28
--- /dev/null
+++ b/engine/battle/move_effects/thunder.asm
@@ -0,0 +1,20 @@
+BattleCommand_ThunderAccuracy: ; 37d94
+; thunderaccuracy
+
+ ld a, BATTLE_VARS_MOVE_TYPE
+ call GetBattleVarAddr
+ inc hl
+ ld a, [wBattleWeather]
+ cp WEATHER_RAIN
+ jr z, .rain
+ cp WEATHER_SUN
+ ret nz
+ ld [hl], 50 percent + 1
+ ret
+
+.rain
+ ; Redundant with CheckHit guranteeing hit
+ ld [hl], 100 percent
+ ret
+
+; 37daa
diff --git a/engine/battle/effect_commands/transform.asm b/engine/battle/move_effects/transform.asm
index 5ae7c1511..5ae7c1511 100755
--- a/engine/battle/effect_commands/transform.asm
+++ b/engine/battle/move_effects/transform.asm
diff --git a/engine/battle/move_effects/triple_kick.asm b/engine/battle/move_effects/triple_kick.asm
new file mode 100644
index 000000000..cef56a1ae
--- /dev/null
+++ b/engine/battle/move_effects/triple_kick.asm
@@ -0,0 +1,39 @@
+BattleCommand_TripleKick: ; 346b2
+; triplekick
+
+ ld a, [wKickCounter]
+ ld b, a
+ inc b
+ ld hl, wCurDamage + 1
+ ld a, [hld]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+.next_kick
+ dec b
+ ret z
+ ld a, [hl]
+ add e
+ ld [hld], a
+ ld a, [hl]
+ adc d
+ ld [hli], a
+
+; No overflow.
+ jr nc, .next_kick
+ ld a, $ff
+ ld [hld], a
+ ld [hl], a
+ ret
+
+; 346cd
+
+
+BattleCommand_KickCounter: ; 346cd
+; kickcounter
+
+ ld hl, wKickCounter
+ inc [hl]
+ ret
+
+; 346d2
diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm
index 9f7a4a4a8..3227236c1 100755
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -44,7 +44,7 @@ ReadTrainerParty: ; 39771
jr z, .got_trainer
.loop
ld a, [hli]
- cp $ff
+ cp -1
jr nz, .loop
jr .skip_trainer
.got_trainer
@@ -82,6 +82,7 @@ ReadTrainerParty: ; 39771
; 397e3
TrainerTypes: ; 397e3
+; entries correspond to TRAINERTYPE_* constants
dw TrainerType1 ; level, species
dw TrainerType2 ; level, species, moves
dw TrainerType3 ; level, species, item
diff --git a/engine/battle/returntobattle_useball.asm b/engine/battle/returntobattle_useball.asm
index b63881b2c..952239f94 100644
--- a/engine/battle/returntobattle_useball.asm
+++ b/engine/battle/returntobattle_useball.asm
@@ -14,6 +14,6 @@ _ReturnToBattle_UseBall: ; 2715c
farcall _LoadBattleFontsHPBar
call GetMemSGBLayout
call CloseWindow
- call LoadStandardMenuDataHeader
+ call LoadStandardMenuHeader
call WaitBGMap
jp SetPalettes
diff --git a/engine/battle/used_move_text.asm b/engine/battle/used_move_text.asm
index bab0ea834..f2182f378 100755
--- a/engine/battle/used_move_text.asm
+++ b/engine/battle/used_move_text.asm
@@ -114,6 +114,7 @@ MoveNameText: ; 105e23
; 105e39
.endusedmovetexts ; 105e39
+; entries correspond to MoveGrammar sets
dw EndUsedMove1Text
dw EndUsedMove2Text
dw EndUsedMove3Text