summaryrefslogtreecommitdiff
path: root/engine/battle/effect_commands
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/effect_commands')
-rwxr-xr-xengine/battle/effect_commands/attract.asm79
-rw-r--r--engine/battle/effect_commands/curse.asm97
-rw-r--r--engine/battle/effect_commands/endure.asm17
-rw-r--r--engine/battle/effect_commands/foresight.asm23
-rw-r--r--engine/battle/effect_commands/metronome.asm61
-rw-r--r--engine/battle/effect_commands/mirror_move.asm52
-rw-r--r--engine/battle/effect_commands/nightmare.asm38
-rw-r--r--engine/battle/effect_commands/perish_song.asm40
-rwxr-xr-xengine/battle/effect_commands/present.asm93
-rw-r--r--engine/battle/effect_commands/protect.asm80
-rw-r--r--engine/battle/effect_commands/rollout.asm99
-rw-r--r--engine/battle/effect_commands/sandstorm.asm19
-rw-r--r--engine/battle/effect_commands/spikes.asm27
-rw-r--r--engine/battle/effect_commands/thief.asm116
-rwxr-xr-xengine/battle/effect_commands/transform.asm141
15 files changed, 982 insertions, 0 deletions
diff --git a/engine/battle/effect_commands/attract.asm b/engine/battle/effect_commands/attract.asm
new file mode 100755
index 000000000..0a6d7c975
--- /dev/null
+++ b/engine/battle/effect_commands/attract.asm
@@ -0,0 +1,79 @@
+BattleCommand_Attract: ; 377ce
+; attract
+ ld a, [AttackMissed]
+ and a
+ jr nz, .failed
+ call CheckOppositeGender
+ jr c, .failed
+ call CheckHiddenOpponent
+ jr nz, .failed
+ ld a, BATTLE_VARS_SUBSTATUS1_OPP
+ call GetBattleVarAddr
+ bit SUBSTATUS_IN_LOVE, [hl]
+ jr nz, .failed
+
+ set SUBSTATUS_IN_LOVE, [hl]
+ call AnimateCurrentMove
+
+; 'fell in love!'
+ ld hl, FellInLoveText
+ jp StdBattleTextBox
+
+.failed
+ jp FailAttract
+; 377f5
+
+
+CheckOppositeGender: ; 377f5
+ ld a, MON_SPECIES
+ call BattlePartyAttr
+ ld a, [hl]
+ ld [CurPartySpecies], a
+
+ ld a, [CurBattleMon]
+ ld [CurPartyMon], a
+ xor a
+ ld [MonType], a
+
+ farcall GetGender
+ jr c, .genderless_samegender
+
+ ld b, 1
+ jr nz, .got_gender
+ dec b
+
+.got_gender
+ push bc
+ ld a, [TempEnemyMonSpecies]
+ ld [CurPartySpecies], a
+ ld hl, EnemyMonDVs
+ ld a, [EnemySubStatus5]
+ bit SUBSTATUS_TRANSFORMED, a
+ jr z, .not_transformed
+ ld hl, wEnemyBackupDVs
+.not_transformed
+ ld a, [hli]
+ ld [TempMonDVs], a
+ ld a, [hl]
+ ld [TempMonDVs + 1], a
+ ld a, 3
+ ld [MonType], a
+ farcall GetGender
+ pop bc
+ jr c, .genderless_samegender
+
+ ld a, 1
+ jr nz, .got_enemy_gender
+ dec a
+
+.got_enemy_gender
+ xor b
+ jr z, .genderless_samegender
+
+ and a
+ ret
+
+.genderless_samegender
+ scf
+ ret
+; 3784b
diff --git a/engine/battle/effect_commands/curse.asm b/engine/battle/effect_commands/curse.asm
new file mode 100644
index 000000000..dceb3b8d5
--- /dev/null
+++ b/engine/battle/effect_commands/curse.asm
@@ -0,0 +1,97 @@
+BattleCommand_Curse: ; 37588
+; curse
+
+ ld de, BattleMonType1
+ ld bc, PlayerStatLevels
+ ld a, [hBattleTurn]
+ and a
+ jr z, .go
+ ld de, EnemyMonType1
+ ld bc, EnemyStatLevels
+
+.go
+
+; Curse is different for Ghost-types.
+
+ ld a, [de]
+ cp GHOST
+ jr z, .ghost
+ inc de
+ ld a, [de]
+ cp GHOST
+ jr z, .ghost
+
+
+; If no stats can be increased, don't.
+
+; Attack
+ ld a, [bc]
+ cp MAX_STAT_LEVEL
+ jr c, .raise
+
+; Defense
+ inc bc
+ ld a, [bc]
+ cp MAX_STAT_LEVEL
+ jr nc, .cantraise
+
+.raise
+
+; Raise Attack and Defense, and lower Speed.
+
+ ld a, $1
+ ld [wKickCounter], a
+ call AnimateCurrentMove
+ ld a, SPEED
+ call LowerStat
+ call BattleCommand_SwitchTurn
+ call BattleCommand_StatDownMessage
+ call ResetMiss
+ call BattleCommand_SwitchTurn
+ call BattleCommand_AttackUp
+ call BattleCommand_StatUpMessage
+ call ResetMiss
+ call BattleCommand_DefenseUp
+ jp BattleCommand_StatUpMessage
+
+
+.ghost
+
+; Cut HP in half and put a curse on the opponent.
+
+ call CheckHiddenOpponent
+ jr nz, .failed
+
+ call CheckSubstituteOpp
+ jr nz, .failed
+
+ ld a, BATTLE_VARS_SUBSTATUS1_OPP
+ call GetBattleVarAddr
+ bit SUBSTATUS_CURSE, [hl]
+ jr nz, .failed
+
+ set SUBSTATUS_CURSE, [hl]
+ call AnimateCurrentMove
+ ld hl, GetHalfMaxHP
+ call CallBattleCore
+ ld hl, SubtractHPFromUser
+ call CallBattleCore
+ call UpdateUserInParty
+ ld hl, PutACurseText
+ jp StdBattleTextBox
+
+.failed
+ call AnimateFailedMove
+ jp PrintButItFailed
+
+
+.cantraise
+
+; Can't raise either stat.
+
+ ld b, ABILITY + 1
+ call GetStatName
+ call AnimateFailedMove
+ ld hl, WontRiseAnymoreText
+ jp StdBattleTextBox
+; 37618
diff --git a/engine/battle/effect_commands/endure.asm b/engine/battle/effect_commands/endure.asm
new file mode 100644
index 000000000..ed4329ff5
--- /dev/null
+++ b/engine/battle/effect_commands/endure.asm
@@ -0,0 +1,17 @@
+BattleCommand_Endure: ; 3766f
+; endure
+
+; Endure shares code with Protect. See protect.asm.
+
+ call ProtectChance
+ ret c
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVarAddr
+ set SUBSTATUS_ENDURE, [hl]
+
+ call AnimateCurrentMove
+
+ ld hl, BracedItselfText
+ jp StdBattleTextBox
+; 37683
diff --git a/engine/battle/effect_commands/foresight.asm b/engine/battle/effect_commands/foresight.asm
new file mode 100644
index 000000000..6f4f97cd2
--- /dev/null
+++ b/engine/battle/effect_commands/foresight.asm
@@ -0,0 +1,23 @@
+BattleCommand_Foresight: ; 376a0
+; foresight
+
+ ld a, [AttackMissed]
+ and a
+ jr nz, .failed
+
+ call CheckHiddenOpponent
+ jr nz, .failed
+
+ ld a, BATTLE_VARS_SUBSTATUS1_OPP
+ call GetBattleVarAddr
+ bit SUBSTATUS_IDENTIFIED, [hl]
+ jr nz, .failed
+
+ set SUBSTATUS_IDENTIFIED, [hl]
+ call AnimateCurrentMove
+ ld hl, IdentifiedText
+ jp StdBattleTextBox
+
+.failed
+ jp FailForesight
+; 376c2
diff --git a/engine/battle/effect_commands/metronome.asm b/engine/battle/effect_commands/metronome.asm
new file mode 100644
index 000000000..1908df84d
--- /dev/null
+++ b/engine/battle/effect_commands/metronome.asm
@@ -0,0 +1,61 @@
+BattleCommand_Metronome: ; 37418
+; metronome
+
+ call ClearLastMove
+ call CheckUserIsCharging
+ jr nz, .asm_3742b
+
+ ld a, [wKickCounter]
+ push af
+ call BattleCommand_LowerSub
+ pop af
+ ld [wKickCounter], a
+
+.asm_3742b
+ call LoadMoveAnim
+
+.GetMove:
+ call BattleRandom
+
+; No invalid moves.
+ cp NUM_ATTACKS + 1
+ jr nc, .GetMove
+
+; None of the moves in MetronomeExcepts.
+ push af
+ ld de, 1
+ ld hl, MetronomeExcepts
+ call IsInArray
+ pop bc
+ jr c, .GetMove
+
+; No moves the user already has.
+ ld a, b
+ call CheckUserMove
+ jr z, .GetMove
+
+
+ ld a, BATTLE_VARS_MOVE
+ call GetBattleVarAddr
+ ld [hl], b
+ call UpdateMoveData
+ jp ResetTurn
+; 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
diff --git a/engine/battle/effect_commands/mirror_move.asm b/engine/battle/effect_commands/mirror_move.asm
new file mode 100644
index 000000000..c4f208d77
--- /dev/null
+++ b/engine/battle/effect_commands/mirror_move.asm
@@ -0,0 +1,52 @@
+BattleCommand_MirrorMove: ; 373c9
+; mirrormove
+
+ call ClearLastMove
+
+ ld a, BATTLE_VARS_MOVE
+ call GetBattleVarAddr
+
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ and a
+ jr z, .failed
+
+ call CheckUserMove
+ jr nz, .use
+
+.failed
+ call AnimateFailedMove
+
+ ld hl, MirrorMoveFailedText
+ call StdBattleTextBox
+ jp EndMoveEffect
+
+.use
+ ld a, b
+ ld [hl], a
+ ld [wd265], a
+
+ push af
+ ld a, BATTLE_VARS_MOVE_ANIM
+ call GetBattleVarAddr
+ ld d, h
+ ld e, l
+ pop af
+
+ dec a
+ call GetMoveData
+ call GetMoveName
+ call CopyName1
+ call CheckUserIsCharging
+ jr nz, .done
+
+ ld a, [wKickCounter]
+ push af
+ call BattleCommand_LowerSub
+ pop af
+ ld [wKickCounter], a
+
+.done
+ call BattleCommand_MoveDelay
+ jp ResetTurn
+; 37418
diff --git a/engine/battle/effect_commands/nightmare.asm b/engine/battle/effect_commands/nightmare.asm
new file mode 100644
index 000000000..788e3de41
--- /dev/null
+++ b/engine/battle/effect_commands/nightmare.asm
@@ -0,0 +1,38 @@
+BattleCommand_Nightmare: ; 37536
+; nightmare
+
+; Can't hit an absent opponent.
+
+ call CheckHiddenOpponent
+ jr nz, .failed
+
+; Can't hit a substitute.
+
+ call CheckSubstituteOpp
+ jr nz, .failed
+
+; Only works on a sleeping opponent.
+
+ ld a, BATTLE_VARS_STATUS_OPP
+ call GetBattleVarAddr
+ and SLP
+ jr z, .failed
+
+; Bail if the opponent is already having a nightmare.
+
+ ld a, BATTLE_VARS_SUBSTATUS1_OPP
+ call GetBattleVarAddr
+ bit SUBSTATUS_NIGHTMARE, [hl]
+ jr nz, .failed
+
+; Otherwise give the opponent a nightmare.
+
+ set SUBSTATUS_NIGHTMARE, [hl]
+ call AnimateCurrentMove
+ ld hl, StartedNightmareText
+ jp StdBattleTextBox
+
+.failed
+ call AnimateFailedMove
+ jp PrintButItFailed
+; 37563
diff --git a/engine/battle/effect_commands/perish_song.asm b/engine/battle/effect_commands/perish_song.asm
new file mode 100644
index 000000000..ac491ef6b
--- /dev/null
+++ b/engine/battle/effect_commands/perish_song.asm
@@ -0,0 +1,40 @@
+BattleCommand_PerishSong: ; 376c2
+; perishsong
+
+
+ ld hl, PlayerSubStatus1
+ ld de, EnemySubStatus1
+ bit SUBSTATUS_PERISH, [hl]
+ jr z, .ok
+
+ ld a, [de]
+ bit SUBSTATUS_PERISH, a
+ jr nz, .failed
+
+.ok
+ bit SUBSTATUS_PERISH, [hl]
+ jr nz, .enemy
+
+ set SUBSTATUS_PERISH, [hl]
+ ld a, 4
+ ld [PlayerPerishCount], a
+
+.enemy
+ ld a, [de]
+ bit SUBSTATUS_PERISH, a
+ jr nz, .done
+
+ set SUBSTATUS_PERISH, a
+ ld [de], a
+ ld a, 4
+ ld [EnemyPerishCount], a
+
+.done
+ call AnimateCurrentMove
+ ld hl, StartPerishText
+ jp StdBattleTextBox
+
+.failed
+ call AnimateFailedMove
+ jp PrintButItFailed
+; 376f8
diff --git a/engine/battle/effect_commands/present.asm b/engine/battle/effect_commands/present.asm
new file mode 100755
index 000000000..819294f8c
--- /dev/null
+++ b/engine/battle/effect_commands/present.asm
@@ -0,0 +1,93 @@
+BattleCommand_Present: ; 37874
+; present
+
+ ld a, [wLinkMode]
+ cp LINK_COLOSSEUM
+ jr z, .colosseum_skippush
+ push bc
+ push de
+.colosseum_skippush
+
+ call BattleCommand_Stab
+
+ ld a, [wLinkMode]
+ cp LINK_COLOSSEUM
+ jr z, .colosseum_skippop
+ pop de
+ pop bc
+.colosseum_skippop
+
+ ld a, [wTypeMatchup]
+ and a
+ jp z, AnimateFailedMove
+ ld a, [AttackMissed]
+ and a
+ jp nz, AnimateFailedMove
+
+ push bc
+ call BattleRandom
+ ld b, a
+ ld hl, .PresentPower
+ ld c, 0
+.next
+ ld a, [hli]
+ cp $ff
+ jr z, .heal_effect ; 378a4 $11
+ cp b
+ jr nc, .got_power ; 378a7 $4
+ inc c
+ inc hl
+ jr .next ; 378ab $f4
+
+.got_power
+ ld a, c
+ ld [wPresentPower], a
+ call AnimateCurrentMoveEitherSide
+ ld d, [hl]
+ pop bc
+ ret
+
+.heal_effect
+ pop bc
+ ld a, $3
+ ld [wPresentPower], a
+ call AnimateCurrentMove
+ call BattleCommand_SwitchTurn
+ ld hl, AICheckPlayerMaxHP
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_hp_fn_pointer ; 378c9 $3
+ ld hl, AICheckEnemyMaxHP
+.got_hp_fn_pointer
+ ld a, BANK(AICheckPlayerMaxHP)
+ rst FarCall
+ jr c, .already_fully_healed ; 378d1 $20
+
+ ld hl, GetQuarterMaxHP
+ call CallBattleCore
+ call BattleCommand_SwitchTurn
+ ld hl, RestoreHP
+ call CallBattleCore
+ call BattleCommand_SwitchTurn
+ ld hl, RegainedHealthText
+ call StdBattleTextBox
+ call BattleCommand_SwitchTurn
+ call UpdateOpponentInParty
+ jr .do_animation ; 378f1 $11
+
+.already_fully_healed
+ call BattleCommand_SwitchTurn
+ call _CheckBattleScene
+ jr nc, .do_animation ; 378f9 $9
+ call AnimateFailedMove
+ ld hl, RefusedGiftText
+ call StdBattleTextBox
+.do_animation
+ jp EndMoveEffect
+
+.PresentPower:
+ db 40 percent, 40
+ db 70 percent + 1, 80
+ db 80 percent, 120
+ db $ff
+; 3790e
diff --git a/engine/battle/effect_commands/protect.asm b/engine/battle/effect_commands/protect.asm
new file mode 100644
index 000000000..568ac00f8
--- /dev/null
+++ b/engine/battle/effect_commands/protect.asm
@@ -0,0 +1,80 @@
+BattleCommand_Protect: ; 37618
+; protect
+ call ProtectChance
+ ret c
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVarAddr
+ set SUBSTATUS_PROTECT, [hl]
+
+ call AnimateCurrentMove
+
+ ld hl, ProtectedItselfText
+ jp StdBattleTextBox
+; 3762c
+
+
+ProtectChance: ; 3762c
+
+ ld de, PlayerProtectCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .asm_37637
+ ld de, EnemyProtectCount
+.asm_37637
+
+ call CheckOpponentWentFirst
+ jr nz, .failed
+
+; Can't have a substitute.
+
+ ld a, BATTLE_VARS_SUBSTATUS4
+ call GetBattleVar
+ bit SUBSTATUS_SUBSTITUTE, a
+ jr nz, .failed
+
+; Halve the chance of a successful Protect for each consecutive use.
+
+ ld b, $ff
+ ld a, [de]
+ ld c, a
+.loop
+ ld a, c
+ and a
+ jr z, .done
+ dec c
+
+ srl b
+ ld a, b
+ and a
+ jr nz, .loop
+ jr .failed
+.done
+
+.rand
+ call BattleRandom
+ and a
+ jr z, .rand
+
+ dec a
+ cp b
+ jr nc, .failed
+
+; Another consecutive Protect use.
+
+ ld a, [de]
+ inc a
+ ld [de], a
+
+ and a
+ ret
+
+
+.failed
+ xor a
+ ld [de], a
+ call AnimateFailedMove
+ call PrintButItFailed
+ scf
+ ret
+; 3766f
diff --git a/engine/battle/effect_commands/rollout.asm b/engine/battle/effect_commands/rollout.asm
new file mode 100644
index 000000000..4ce9ab3d8
--- /dev/null
+++ b/engine/battle/effect_commands/rollout.asm
@@ -0,0 +1,99 @@
+MAX_ROLLOUT_COUNT EQU 5
+
+
+BattleCommand_CheckCurl: ; 37718
+; checkcurl
+
+ ld de, PlayerRolloutCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .ok
+ ld de, EnemyRolloutCount
+.ok
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVar
+ bit SUBSTATUS_ROLLOUT, a
+ jr z, .reset
+
+ ld b, $4 ; doturn
+ jp SkipToBattleCommand
+
+.reset
+ xor a
+ ld [de], a
+ ret
+; 37734
+
+
+BattleCommand_RolloutPower: ; 37734
+; rolloutpower
+
+ ld a, BATTLE_VARS_STATUS
+ call GetBattleVar
+ and SLP
+ ret nz
+
+ ld hl, PlayerRolloutCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .got_rollout_count
+ ld hl, EnemyRolloutCount
+
+.got_rollout_count
+ ld a, [hl]
+ and a
+ jr nz, .skip_set_rampage
+ ld a, 1
+ ld [wSomeoneIsRampaging], a
+
+.skip_set_rampage
+ ld a, [AttackMissed]
+ and a
+ jr z, .hit
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVarAddr
+ res 6, [hl]
+ ret
+
+.hit
+ inc [hl]
+ ld a, [hl]
+ ld b, a
+ cp MAX_ROLLOUT_COUNT
+ jr c, .not_done_with_rollout
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVarAddr
+ res SUBSTATUS_ROLLOUT, [hl]
+ jr .done_with_substatus_flag
+
+.not_done_with_rollout
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVarAddr
+ set SUBSTATUS_ROLLOUT, [hl]
+
+.done_with_substatus_flag
+ ld a, BATTLE_VARS_SUBSTATUS2
+ call GetBattleVar
+ bit SUBSTATUS_CURLED, a
+ jr z, .not_curled
+ inc b
+.not_curled
+.loop
+ dec b
+ jr z, .done_damage
+
+ ld hl, CurDamage + 1
+ sla [hl]
+ dec hl
+ rl [hl]
+ jr nc, .loop
+
+ ld a, $ff
+ ld [hli], a
+ ld [hl], a
+
+.done_damage
+ ret
+; 37791
diff --git a/engine/battle/effect_commands/sandstorm.asm b/engine/battle/effect_commands/sandstorm.asm
new file mode 100644
index 000000000..27b8e8e2c
--- /dev/null
+++ b/engine/battle/effect_commands/sandstorm.asm
@@ -0,0 +1,19 @@
+BattleCommand_StartSandstorm: ; 376f8
+; startsandstorm
+
+ ld a, [Weather]
+ cp WEATHER_SANDSTORM
+ jr z, .failed
+
+ ld a, WEATHER_SANDSTORM
+ ld [Weather], a
+ ld a, 5
+ ld [WeatherCount], a
+ call AnimateCurrentMove
+ ld hl, SandstormBrewedText
+ jp StdBattleTextBox
+
+.failed
+ call AnimateFailedMove
+ jp PrintButItFailed
+; 37718
diff --git a/engine/battle/effect_commands/spikes.asm b/engine/battle/effect_commands/spikes.asm
new file mode 100644
index 000000000..3d15e4cfd
--- /dev/null
+++ b/engine/battle/effect_commands/spikes.asm
@@ -0,0 +1,27 @@
+BattleCommand_Spikes: ; 37683
+; spikes
+
+ ld hl, EnemyScreens
+ ld a, [hBattleTurn]
+ and a
+ jr z, .asm_3768e
+ ld hl, PlayerScreens
+.asm_3768e
+
+; Fails if spikes are already down!
+
+ bit SCREENS_SPIKES, [hl]
+ jr nz, .failed
+
+; Nothing else stops it from working.
+
+ set SCREENS_SPIKES, [hl]
+
+ call AnimateCurrentMove
+
+ ld hl, SpikesText
+ jp StdBattleTextBox
+
+.failed
+ jp FailSpikes
+; 376a0
diff --git a/engine/battle/effect_commands/thief.asm b/engine/battle/effect_commands/thief.asm
new file mode 100644
index 000000000..6d32d68d4
--- /dev/null
+++ b/engine/battle/effect_commands/thief.asm
@@ -0,0 +1,116 @@
+BattleCommand_Thief: ; 37492
+; thief
+
+ ld a, [hBattleTurn]
+ and a
+ jr nz, .enemy
+
+; The player needs to be able to steal an item.
+
+ call .playeritem
+ ld a, [hl]
+ and a
+ ret nz
+
+; The enemy needs to have an item to steal.
+
+ call .enemyitem
+ ld a, [hl]
+ and a
+ ret z
+
+; Can't steal mail.
+
+ ld [wd265], a
+ ld d, a
+ farcall ItemIsMail
+ ret c
+
+ ld a, [EffectFailed]
+ and a
+ ret nz
+
+ ld a, [wLinkMode]
+ and a
+ jr z, .stealenemyitem
+
+ ld a, [wBattleMode]
+ dec a
+ ret z
+
+.stealenemyitem
+ call .enemyitem
+ xor a
+ ld [hl], a
+ ld [de], a
+
+ call .playeritem
+ ld a, [wd265]
+ ld [hl], a
+ ld [de], a
+ jr .stole
+
+
+.enemy
+
+; The enemy can't already have an item.
+
+ call .enemyitem
+ ld a, [hl]
+ and a
+ ret nz
+
+; The player must have an item to steal.
+
+ call .playeritem
+ ld a, [hl]
+ and a
+ ret z
+
+; Can't steal mail!
+
+ ld [wd265], a
+ ld d, a
+ farcall ItemIsMail
+ ret c
+
+ ld a, [EffectFailed]
+ and a
+ ret nz
+
+; If the enemy steals your item,
+; it's gone for good if you don't get it back.
+
+ call .playeritem
+ xor a
+ ld [hl], a
+ ld [de], a
+
+ call .enemyitem
+ ld a, [wd265]
+ ld [hl], a
+ ld [de], a
+
+
+.stole
+ call GetItemName
+ ld hl, StoleText
+ jp StdBattleTextBox
+
+
+.playeritem
+ ld a, 1
+ call BattlePartyAttr
+ ld d, h
+ ld e, l
+ ld hl, BattleMonItem
+ ret
+
+.enemyitem
+ ld a, 1
+ call OTPartyAttr
+ ld d, h
+ ld e, l
+ ld hl, EnemyMonItem
+ ret
+; 37517
diff --git a/engine/battle/effect_commands/transform.asm b/engine/battle/effect_commands/transform.asm
new file mode 100755
index 000000000..65c3f3e60
--- /dev/null
+++ b/engine/battle/effect_commands/transform.asm
@@ -0,0 +1,141 @@
+
+BattleCommand_Transform: ; 371cd
+; transform
+
+ call ClearLastMove
+ ld a, BATTLE_VARS_SUBSTATUS5_OPP
+ call GetBattleVarAddr
+ bit SUBSTATUS_TRANSFORMED, [hl]
+ jp nz, BattleEffect_ButItFailed
+ call CheckHiddenOpponent
+ jp nz, BattleEffect_ButItFailed
+ xor a
+ ld [wNumHits], a
+ ld [FXAnimID + 1], a
+ ld a, $1
+ ld [wKickCounter], a
+ ld a, BATTLE_VARS_SUBSTATUS4
+ call GetBattleVarAddr
+ bit SUBSTATUS_SUBSTITUTE, [hl]
+ push af
+ jr z, .mimic_substitute
+ call CheckUserIsCharging
+ jr nz, .mimic_substitute
+ ld a, SUBSTITUTE
+ call LoadAnim
+.mimic_substitute
+ ld a, BATTLE_VARS_SUBSTATUS5
+ call GetBattleVarAddr
+ set SUBSTATUS_TRANSFORMED, [hl]
+ call ResetActorDisable
+ ld hl, BattleMonSpecies
+ ld de, EnemyMonSpecies
+ ld a, [hBattleTurn]
+ and a
+ jr nz, .got_mon_species
+ ld hl, EnemyMonSpecies
+ ld de, BattleMonSpecies
+ xor a
+ ld [CurMoveNum], a
+.got_mon_species
+ push hl
+ ld a, [hli]
+ ld [de], a
+ inc hl
+ inc de
+ inc de
+ ld bc, NUM_MOVES
+ call CopyBytes
+ ld a, [hBattleTurn]
+ and a
+ jr z, .mimic_enemy_backup
+ ld a, [de]
+ ld [wEnemyBackupDVs], a
+ inc de
+ ld a, [de]
+ ld [wEnemyBackupDVs + 1], a
+ dec de
+.mimic_enemy_backup
+; copy DVs
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ inc de
+; move pointer to stats
+ ld bc, BattleMonStats - BattleMonPP
+ add hl, bc
+ push hl
+ ld h, d
+ ld l, e
+ add hl, bc
+ ld d, h
+ ld e, l
+ pop hl
+ ld bc, BattleMonStructEnd - BattleMonStats
+ call CopyBytes
+; init the power points
+ ld bc, BattleMonMoves - BattleMonStructEnd
+ add hl, bc
+ push de
+ ld d, h
+ ld e, l
+ pop hl
+ ld bc, BattleMonPP - BattleMonStructEnd
+ add hl, bc
+ ld b, NUM_MOVES
+.pp_loop
+ ld a, [de]
+ inc de
+ and a
+ jr z, .done_move
+ cp SKETCH
+ ld a, 1
+ jr z, .done_move
+ ld a, 5
+.done_move
+ ld [hli], a
+ dec b
+ jr nz, .pp_loop
+ pop hl
+ ld a, [hl]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld hl, EnemyStats
+ ld de, PlayerStats
+ ld bc, 2 * 5
+ call BattleSideCopy
+ ld hl, EnemyStatLevels
+ ld de, PlayerStatLevels
+ ld bc, 8
+ call BattleSideCopy
+ call _CheckBattleScene
+ jr c, .mimic_anims
+ ld a, [hBattleTurn]
+ and a
+ ld a, [wPlayerMinimized]
+ jr z, .got_byte
+ ld a, [wEnemyMinimized]
+.got_byte
+ and a
+ jr nz, .mimic_anims
+ call LoadMoveAnim
+ jr .after_anim
+
+.mimic_anims
+ call BattleCommand_MoveDelay
+ call BattleCommand_RaiseSubNoAnim
+.after_anim
+ xor a
+ ld [wNumHits], a
+ ld [FXAnimID + 1], a
+ ld a, $2
+ ld [wKickCounter], a
+ pop af
+ ld a, SUBSTITUTE
+ call nz, LoadAnim
+ ld hl, TransformedText
+ jp StdBattleTextBox
+
+; 372c6