summaryrefslogtreecommitdiff
path: root/battle/effects
diff options
context:
space:
mode:
Diffstat (limited to 'battle/effects')
-rw-r--r--battle/effects/foresight.asm24
-rw-r--r--battle/effects/metronome.asm62
-rw-r--r--battle/effects/mirror_move.asm53
-rw-r--r--battle/effects/nightmare.asm39
-rw-r--r--battle/effects/perish_song.asm41
-rw-r--r--battle/effects/rollout.asm97
-rw-r--r--battle/effects/sandstorm.asm20
-rw-r--r--battle/effects/thief.asm117
8 files changed, 453 insertions, 0 deletions
diff --git a/battle/effects/foresight.asm b/battle/effects/foresight.asm
new file mode 100644
index 000000000..ed2e629a0
--- /dev/null
+++ b/battle/effects/foresight.asm
@@ -0,0 +1,24 @@
+BattleCommand57: ; 376a0
+; foresight
+
+ ld a, [AttackMissed]
+ and a
+ jr nz, .failed
+
+ call CheckHiddenOpponent
+ jr nz, .failed
+
+ ld a, BATTLE_VARS_SUBSTATUS1_OPP
+ call _GetBattleVar
+ bit SUBSTATUS_IDENTIFIED, [hl]
+ jr nz, .failed
+
+ set SUBSTATUS_IDENTIFIED, [hl]
+ call Function0x37e01
+ ld hl, IdentifiedText
+ jp StdBattleTextBox
+
+.failed
+ jp Function0x37354
+; 376c2
+
diff --git a/battle/effects/metronome.asm b/battle/effects/metronome.asm
new file mode 100644
index 000000000..fd3d151f0
--- /dev/null
+++ b/battle/effects/metronome.asm
@@ -0,0 +1,62 @@
+BattleCommand34: ; 37418
+; metronome
+
+ call Function0x372d8
+ call Function0x34548
+ jr nz, .asm_3742b
+
+ ld a, [$c689]
+ push af
+ call BattleCommand0a
+ pop af
+ ld [$c689], a
+
+.asm_3742b
+ call Function0x37e36
+
+.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 _GetBattleVar
+ 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/battle/effects/mirror_move.asm b/battle/effects/mirror_move.asm
new file mode 100644
index 000000000..c54977a91
--- /dev/null
+++ b/battle/effects/mirror_move.asm
@@ -0,0 +1,53 @@
+BattleCommand1b: ; 373c9
+; mirrormove
+
+ call Function0x372d8
+
+ ld a, BATTLE_VARS_MOVE
+ call _GetBattleVar
+
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
+ call GetBattleVar
+ and a
+ jr z, .failed
+
+ call CheckUserMove
+ jr nz, .use
+
+.failed
+ call Function0x37e77
+
+ ld hl, MirrorMoveFailedText
+ call StdBattleTextBox
+ jp EndMoveEffect
+
+.use
+ ld a, b
+ ld [hl], a
+ ld [$d265], a
+
+ push af
+ ld a, BATTLE_VARS_MOVE_ANIM
+ call _GetBattleVar
+ ld d, h
+ ld e, l
+ pop af
+
+ dec a
+ call GetMoveData
+ call GetMoveName
+ call CopyName1
+ call Function0x34548
+ jr nz, .done
+
+ ld a, [$c689]
+ push af
+ call BattleCommand0a
+ pop af
+ ld [$c689], a
+
+.done
+ call BattleCommandaa
+ jp ResetTurn
+; 37418
+
diff --git a/battle/effects/nightmare.asm b/battle/effects/nightmare.asm
new file mode 100644
index 000000000..6cd1f0a64
--- /dev/null
+++ b/battle/effects/nightmare.asm
@@ -0,0 +1,39 @@
+BattleCommand52: ; 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 _GetBattleVar
+ and SLP
+ jr z, .failed
+
+; Bail if the opponent is already having a nightmare.
+
+ ld a, BATTLE_VARS_SUBSTATUS1_OPP
+ call _GetBattleVar
+ bit SUBSTATUS_NIGHTMARE, [hl]
+ jr nz, .failed
+
+; Otherwise give the opponent a nightmare.
+
+ set SUBSTATUS_NIGHTMARE, [hl]
+ call Function0x37e01
+ ld hl, StartedNightmareText
+ jp StdBattleTextBox
+
+.failed
+ call Function0x37e77
+ jp PrintButItFailed
+; 37563
+
diff --git a/battle/effects/perish_song.asm b/battle/effects/perish_song.asm
new file mode 100644
index 000000000..4f206d5d2
--- /dev/null
+++ b/battle/effects/perish_song.asm
@@ -0,0 +1,41 @@
+BattleCommand58: ; 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 Function0x37e01
+ ld hl, StartPerishText
+ jp StdBattleTextBox
+
+.failed
+ call Function0x37e77
+ jp PrintButItFailed
+; 376f8
+
diff --git a/battle/effects/rollout.asm b/battle/effects/rollout.asm
new file mode 100644
index 000000000..13c91a8d9
--- /dev/null
+++ b/battle/effects/rollout.asm
@@ -0,0 +1,97 @@
+BattleCommand5b: ; 37718
+; checkcurl
+
+ ld de, PlayerRolloutCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .asm_37723
+ ld de, EnemyRolloutCount
+
+.asm_37723
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVar
+ bit SUBSTATUS_ENCORED, a
+ jr z, .asm_37731
+
+ ld b, $4 ; doturn
+ jp SkipToBattleCommand
+
+.asm_37731
+ xor a
+ ld [de], a
+ ret
+; 37734
+
+
+BattleCommand5c: ; 37734
+; rolloutpower
+
+ ld a, BATTLE_VARS_STATUS
+ call GetBattleVar
+ and 7
+ ret nz
+
+ ld hl, PlayerRolloutCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .asm_37747
+ ld hl, EnemyRolloutCount
+
+.asm_37747
+ ld a, [hl]
+ and a
+ jr nz, .asm_37750
+ ld a, 1
+ ld [$c73e], a
+
+.asm_37750
+ ld a, [AttackMissed]
+ and a
+ jr z, .hit
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call _GetBattleVar
+ res 6, [hl]
+ ret
+
+.hit
+ inc [hl]
+ ld a, [hl]
+ ld b, a
+ cp $5
+ jr c, .asm_3776e
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call _GetBattleVar
+ res 6, [hl]
+ jr .asm_37775
+
+.asm_3776e
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call _GetBattleVar
+ set 6, [hl]
+
+.asm_37775
+ ld a, BATTLE_VARS_SUBSTATUS2
+ call GetBattleVar
+ bit 0, a
+ jr z, .asm_3777f
+ inc b
+.asm_3777f
+ dec b
+ jr z, .asm_37790
+
+ ld hl, CurDamage + 1
+ sla [hl]
+ dec hl
+ rl [hl]
+ jr nc, .asm_3777f
+
+ ld a, $ff
+ ld [hli], a
+ ld [hl], a
+
+.asm_37790
+ ret
+; 37791
+
diff --git a/battle/effects/sandstorm.asm b/battle/effects/sandstorm.asm
new file mode 100644
index 000000000..ad3bac9d1
--- /dev/null
+++ b/battle/effects/sandstorm.asm
@@ -0,0 +1,20 @@
+BattleCommand59: ; 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 Function0x37e01
+ ld hl, SandstormBrewedText
+ jp StdBattleTextBox
+
+.failed
+ call Function0x37e77
+ jp PrintButItFailed
+; 37718
+
diff --git a/battle/effects/thief.asm b/battle/effects/thief.asm
new file mode 100644
index 000000000..617e73e37
--- /dev/null
+++ b/battle/effects/thief.asm
@@ -0,0 +1,117 @@
+BattleCommand50: ; 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 [$d265], a
+ ld d, a
+ callba ItemIsMail
+ ret c
+
+ ld a, [EffectFailed]
+ and a
+ ret nz
+
+ ld a, [InLinkBattle]
+ and a
+ jr z, .stealenemyitem
+
+ ld a, [IsInBattle]
+ dec a
+ ret z
+
+.stealenemyitem
+ call .enemyitem
+ xor a
+ ld [hl], a
+ ld [de], a
+
+ call .playeritem
+ ld a, [$d265]
+ 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 [$d265], a
+ ld d, a
+ callba 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, [$d265]
+ 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
+