summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/constants/duel_constants.asm2
-rw-r--r--src/data/effect_commands.asm13
-rw-r--r--src/engine/effect_functions.asm61
-rwxr-xr-xsrc/engine/home.asm24
-rwxr-xr-xsrc/text/text1.asm2
-rwxr-xr-xsrc/text/text_offsets.asm2
-rwxr-xr-xsrc/wram.asm4
7 files changed, 81 insertions, 27 deletions
diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm
index e31bdf5..658798f 100644
--- a/src/constants/duel_constants.asm
+++ b/src/constants/duel_constants.asm
@@ -60,7 +60,7 @@ PASSIVE_STATUS_MASK EQU $f ; confused, asleep or paralyzed
SUBSTATUS1_AGILITY EQU $0c
SUBSTATUS1_FLY EQU $0d
SUBSTATUS1_HARDEN EQU $0e
-SUBSTATUS1_NO_DAMAGE_F EQU $0f
+SUBSTATUS1_NO_DAMAGE_STIFFEN EQU $0f
SUBSTATUS1_NO_DAMAGE_10 EQU $10
SUBSTATUS1_NO_DAMAGE_11 EQU $11
SUBSTATUS1_REDUCE_BY_20 EQU $13
diff --git a/src/data/effect_commands.asm b/src/data/effect_commands.asm
index 9616ea7..1e9ed69 100644
--- a/src/data/effect_commands.asm
+++ b/src/data/effect_commands.asm
@@ -2,15 +2,12 @@ EffectCommands: ; 186f7 (6:46f7)
; Each move has a two-byte effect pointer (move's 7th param) that points to one of these structures.
; Similarly, trainer cards have a two-byte pointer (7th param) to one of these structures, which determines the card's function.
; Energy cards also point to one of these, but their data is just $00.
-; db CommandId ($01 - $0a)
+; db CommandType ($01 - $0a)
; dw Function
; ...
; db $00
-; Apparently every command has a "time", and a function is called multiple times during a turn
-; with an argument identifying the command Id. If said command Id is found in the
-; current move effect's array, its assigned function is immediately executed.
-
+; Commands are associated to a time or a scope (CommandType) that determines when their function is executed during the turn.
; Similar move effects of different Pokemon cards all point to a different command list,
; even though in some cases their commands and function pointers match.
@@ -64,11 +61,11 @@ GloomPoisonPowderEffectCommands:
db $00
GloomFoulOdorEffectCommands:
- dbw $03, $4793
+ dbw $03, FoulOdorEffect
db $00
KakunaStiffenEffectCommands:
- dbw $03, $47a0
+ dbw $03, KakunaStiffenEffect
db $00
KakunaPoisonPowderEffectCommands:
@@ -124,7 +121,7 @@ KoffingFoulGasEffectCommands:
db $00
MetapodStiffenEffectCommands:
- dbw $03, $4836
+ dbw $03, MetapodStiffenEffect
db $00
MetapodStunSporeEffectCommands:
diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm
index a7d44d1..5034151 100644
--- a/src/engine/effect_functions.asm
+++ b/src/engine/effect_functions.asm
@@ -21,6 +21,8 @@ Confusion50PercentEffect: ; 2c01d (b:401d)
text_de ConfusionCheckText
call TossCoin_BankB
ret nc
+
+ConfusionEffect: ; 2c024 (b:4024)
lb bc, $f0, CONFUSED
jr applyEffect
@@ -94,9 +96,26 @@ Func_2c09c: ; 2c09c (b:409c)
ret
; 0x2c0a2
-INCBIN "baserom.gbc",$2c0a2,$2c149 - $2c0a2
+Func_2c0a2: ; 2c0a2 (b:40a2)
+ ld a, $2
+ ld [wcced], a
+ ret
+; 0x2c0a8
+
+INCBIN "baserom.gbc",$2c0a8,$2c140 - $2c0a8
+
+; apply a status condition of type 1 identified by register a to the target
+ApplySubstatus1ToDefendingCard: ; 2c140 (b:4140)
+ push af
+ ld a, DUELVARS_ARENA_CARD_SUBSTATUS1
+ call GetTurnDuelistVariable
+ pop af
+ ld [hli], a
+ ret
+; 0x2c149
-; apply a status condition identified by register a to the target if able
+; apply a status condition of type 2 identified by register a to the target,
+; unless prevented by wNoDamageOrEffect
ApplySubstatus2ToDefendingCard: ; 2c149 (b:4149)
push af
call CheckNoDamageOrEffect
@@ -143,4 +162,40 @@ AcidEffect: ; 2c77e (b:477e)
ret
; 0x2c78b
-INCBIN "baserom.gbc",$2c78b,$30000 - $2c78b
+INCBIN "baserom.gbc",$2c78b,$2c793 - $2c78b
+
+; confuses both the target and the user
+FoulOdorEffect: ; 2c793 (b:4793)
+ call ConfusionEffect
+ call SwapTurn
+ call ConfusionEffect
+ call SwapTurn
+ ret
+; 0x2c7a0
+
+KakunaStiffenEffect: ; 2c7a0 (b:47a0)
+ text_de IfHeadsNoDamageNextTurnText
+ call TossCoin_BankB
+ jp nc, Func_2c0a2
+ ld a, $4f
+ ld [wLoadedMoveAnimation], a
+ ld a, SUBSTATUS1_NO_DAMAGE_STIFFEN
+ call ApplySubstatus1ToDefendingCard
+ ret
+; 0x2c7b4
+
+INCBIN "baserom.gbc",$2c7b4,$2c836 - $2c7b4
+
+; an exact copy of KakunaStiffenEffect
+MetapodStiffenEffect: ; 2c836 (b:4836)
+ text_de IfHeadsNoDamageNextTurnText
+ call TossCoin_BankB
+ jp nc, Func_2c0a2
+ ld a, $4f
+ ld [wLoadedMoveAnimation], a
+ ld a, SUBSTATUS1_NO_DAMAGE_STIFFEN
+ call ApplySubstatus1ToDefendingCard
+ ret
+; 0x2c84a
+
+INCBIN "baserom.gbc",$2c84a,$30000 - $2c84a
diff --git a/src/engine/home.asm b/src/engine/home.asm
index e4dfde8..5c687db 100755
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -2339,7 +2339,7 @@ CreateHandCardBuffer: ; 123b (0:123b)
.checkNextCardLoop
ld a, [hld]
push hl
- ld l, a
+ ld l, a
bit 6, [hl]
pop hl
jr nz, .skipCard
@@ -3162,7 +3162,7 @@ ApplyAttachedDefender: ; 1a7e (0:1a7e)
; hl: address to substract HP from
; de: how much HP to substract (damage to deal)
-; returns carry if the HP does not become 0 as a result
+; returns carry if the HP does not become 0 as a result
SubstractHP: ; 1a96 (0:1a96)
push hl
push de
@@ -5726,9 +5726,11 @@ Func_2fcb: ; 2fcb (0:2fcb)
call BankpopHome
ret
-; Checks if the command ID at a is one of the commands of the move or card effect currently in use,
+; Checks if the command type at a is one of the commands of the move or card effect currently in use,
; and executes its associated function if so.
-; input: a = move or trainer card effect command ID
+; input:
+; a = command type to check
+; [wLoadedMoveEffectCommands] = pointer to list of commands of current move or trainer card
TryExecuteEffectCommandFunction: ; 2fd9 (0:2fd9)
push af
; grab pointer to command list from wLoadedMoveEffectCommands
@@ -5739,7 +5741,7 @@ TryExecuteEffectCommandFunction: ; 2fd9 (0:2fd9)
pop af
call CheckMatchingCommand
jr nc, .executeFunction
-; return if input command ID wasn't found
+; return if no matching command was found
or a
ret
@@ -5761,9 +5763,9 @@ TryExecuteEffectCommandFunction: ; 2fd9 (0:2fd9)
ret
; input:
- ; a = command ID to check
- ; hl = pointer to current move effect or trainer card effect command list
-; return nc if command ID matching a is found, c otherwise
+ ; a = command type to check
+ ; hl = list of commands of current move or trainer card
+; return nc if command type matching a is found, c otherwise
CheckMatchingCommand: ; 2ffe (0:2ffe)
ld c, a
ld a, l
@@ -6235,7 +6237,7 @@ HandleDamageReductionExceptSubstatus2: ; 3269 (0:3269)
call GetTurnDuelistVariable
or a
jr z, .notAffectedBySubstatus1
- cp SUBSTATUS1_NO_DAMAGE_F
+ cp SUBSTATUS1_NO_DAMAGE_STIFFEN
jr z, .noDamage
cp SUBSTATUS1_NO_DAMAGE_10
jr z, .noDamage
@@ -6448,7 +6450,7 @@ HandleNoDamageOrEffectSubstatus: ; 3432 (0:3432)
jr .noDamageOrEffect
; if the Pokemon being attacked is Haunter1, and its Transparency is active,
-; there is a 50% chance that any damage or effect is prevented
+; there is a 50% chance that any damage or effect is prevented
HandleTransparency: ; 348a (0:348a)
ld a, [wTempNonTurnDuelistCardId]
cp HAUNTER1
@@ -7295,7 +7297,7 @@ RunOverworldScript: ; 3aed (0:3aed)
rlca
ld c, a
ld b, $0
- ld hl, OverworldScriptTable
+ ld hl, OverworldScriptTable
add hl, bc
ldh a, [hBankROM]
push af
diff --git a/src/text/text1.asm b/src/text/text1.asm
index 5464784..e6b0034 100755
--- a/src/text/text1.asm
+++ b/src/text/text1.asm
@@ -1127,7 +1127,7 @@ Text00f0: ; 37f24 (d:7f24)
line "If Heads, 8 cards! If Tails, 1 card!"
done
-Text00f1: ; 37f56 (d:7f56)
+IfHeadsNoDamageNextTurnText: ; 37f56 (d:7f56)
text "If Heads, you will not receive"
line "damage during opponent's next turn!"
done
diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm
index 8ed6741..c2b77c2 100755
--- a/src/text/text_offsets.asm
+++ b/src/text/text_offsets.asm
@@ -243,7 +243,7 @@ TextOffsets:: ; 34000 (d:4000)
textpointer Text00ee
textpointer Text00ef
textpointer Text00f0
- textpointer Text00f1
+ textpointer IfHeadsNoDamageNextTurnText
textpointer Text00f2
textpointer Text00f3
textpointer Text00f4
diff --git a/src/wram.asm b/src/wram.asm
index f498697..3b6543f 100755
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -765,7 +765,7 @@ wceb5:: ; ceb5
wcecc:: ; cecc
ds $9c
-
+
wHandCardBuffer:: ; cf68
ds $51
@@ -1367,7 +1367,7 @@ wMusicChannelStackPointers:: ; ddf3
; 1 byte for loop count)
wMusicCh1Stack:: ; ddfb
ds $c
-
+
wMusicCh2Stack:: ; de07
ds $c