From 4ead64d18d1852c9c94e4b6335f0239e5319ed01 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Wed, 6 Nov 2024 22:44:53 +0000 Subject: [PATCH 1/2] Misc findings and documentation fixes --- src/audio/sfx_headers.asm | 2 +- src/engine/duel/ai/hand_pokemon.asm | 2 +- src/engine/duel/core.asm | 4 ++-- src/engine/duel/effect_functions.asm | 23 +++++++++++------------ src/engine/menus/deck_configuration.asm | 4 ++-- src/engine/menus/deck_machine.asm | 4 ++-- src/home/card_color.asm | 2 +- src/home/duel.asm | 10 +++++----- src/macros/scripts.asm | 6 +++--- src/scripts/water_club.asm | 6 +++--- 10 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/audio/sfx_headers.asm b/src/audio/sfx_headers.asm index b65a5610..edab54d2 100644 --- a/src/audio/sfx_headers.asm +++ b/src/audio/sfx_headers.asm @@ -1,5 +1,5 @@ NumberOfSFX: - db $60 + db NUM_SFX SFXHeaderPointers: table_width 2, SFXHeaderPointers diff --git a/src/engine/duel/ai/hand_pokemon.asm b/src/engine/duel/ai/hand_pokemon.asm index 4c619b59..9262964a 100644 --- a/src/engine/duel/ai/hand_pokemon.asm +++ b/src/engine/duel/ai/hand_pokemon.asm @@ -573,7 +573,7 @@ AIDecidePlayLegendaryBirds: ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable ld d, a - ld e, $00 + ld e, FIRST_ATTACK_OR_PKMN_POWER call CopyAttackDataAndDamage_FromDeckIndex call SwapTurn ld a, [wLoadedAttackCategory] diff --git a/src/engine/duel/core.asm b/src/engine/duel/core.asm index 9b425da4..ca8c854f 100644 --- a/src/engine/duel/core.asm +++ b/src/engine/duel/core.asm @@ -5649,7 +5649,7 @@ DisplayPlayAreaScreenToUsePkmnPower: ld a, [hl] ldh [hTempCardIndex_ff98], a ld d, a - ld e, $00 + ld e, FIRST_ATTACK_OR_PKMN_POWER call CopyAttackDataAndDamage_FromDeckIndex call DisplayUsePokemonPowerScreen ld a, EFFECTCMDTYPE_INITIAL_EFFECT_1 @@ -6699,7 +6699,7 @@ OppAction_ForceSwitchActive: OppAction_UsePokemonPower: ldh a, [hTempCardIndex_ff9f] ld d, a - ld e, $00 + ld e, FIRST_ATTACK_OR_PKMN_POWER call CopyAttackDataAndDamage_FromDeckIndex ldh a, [hTemp_ffa0] ldh [hTempPlayAreaLocation_ff9d], a diff --git a/src/engine/duel/effect_functions.asm b/src/engine/duel/effect_functions.asm index 7a3971e4..0eb4b876 100644 --- a/src/engine/duel/effect_functions.asm +++ b/src/engine/duel/effect_functions.asm @@ -3514,7 +3514,7 @@ AIPickFireEnergyCardToDiscard: ArcanineFlamethrower_CheckEnergy: ld e, PLAY_AREA_ARENA call GetPlayAreaCardAttachedEnergies - ld a, [wAttachedEnergies] + ld a, [wAttachedEnergies + FIRE] ldtx hl, NotEnoughFireEnergyText cp 1 ret @@ -3556,7 +3556,7 @@ ArcanineQuickAttack_DamageBoostEffect: FlamesOfRage_CheckEnergy: ld e, PLAY_AREA_ARENA call GetPlayAreaCardAttachedEnergies - ld a, [wAttachedEnergies] + ld a, [wAttachedEnergies + FIRE] ldtx hl, NotEnoughFireEnergyText cp 2 ret @@ -3673,7 +3673,7 @@ FireBlast_CheckEnergy: ld e, PLAY_AREA_ARENA call GetPlayAreaCardAttachedEnergies ldtx hl, NotEnoughFireEnergyText - ld a, [wAttachedEnergies] + ld a, [wAttachedEnergies + FIRE] cp 1 ret @@ -3695,7 +3695,7 @@ Ember_CheckEnergy: ld e, PLAY_AREA_ARENA call GetPlayAreaCardAttachedEnergies ldtx hl, NotEnoughFireEnergyText - ld a, [wAttachedEnergies] + ld a, [wAttachedEnergies + FIRE] cp 1 ret @@ -3717,7 +3717,7 @@ Wildfire_CheckEnergy: ld e, PLAY_AREA_ARENA call GetPlayAreaCardAttachedEnergies ldtx hl, NotEnoughFireEnergyText - ld a, [wAttachedEnergies] + ld a, [wAttachedEnergies + FIRE] cp 1 ret @@ -3857,7 +3857,7 @@ FlareonFlamethrower_CheckEnergy: ld e, PLAY_AREA_ARENA call GetPlayAreaCardAttachedEnergies ldtx hl, NotEnoughFireEnergyText - ld a, [wAttachedEnergies] + ld a, [wAttachedEnergies + FIRE] cp 1 ret @@ -3879,7 +3879,7 @@ MagmarFlamethrower_CheckEnergy: ld e, PLAY_AREA_ARENA call GetPlayAreaCardAttachedEnergies ldtx hl, NotEnoughFireEnergyText - ld a, [wAttachedEnergies] + ld a, [wAttachedEnergies + FIRE] cp 1 ret @@ -3911,7 +3911,7 @@ CharmeleonFlamethrower_CheckEnergy: ld e, PLAY_AREA_ARENA call GetPlayAreaCardAttachedEnergies ldtx hl, NotEnoughFireEnergyText - ld a, [wAttachedEnergies] + ld a, [wAttachedEnergies + FIRE] cp 1 ret @@ -8646,8 +8646,7 @@ MorphEffect: ret ; picks a random Pokemon in the Deck to morph. -; needs to be a Basic Pokemon that doesn't have -; the same ID as the Arena card. +; needs to be a Basic Pokemon that isn't Ditto ; returns carry if no Pokemon were found. .PickRandomBasicPokemonFromDeck call CreateDeckCardList @@ -8667,8 +8666,8 @@ MorphEffect: or a jr nz, .loop_deck ; skip non-Basic cards ld a, [wLoadedCard2ID] - cp DUELVARS_ARENA_CARD - jr z, .loop_deck ; skip cards with same ID as Arena card + cp DITTO + jr z, .loop_deck ; skip other Ditto cards ldh a, [hTempCardIndex_ff98] or a ret diff --git a/src/engine/menus/deck_configuration.asm b/src/engine/menus/deck_configuration.asm index c73f6730..20ca6224 100644 --- a/src/engine/menus/deck_configuration.asm +++ b/src/engine/menus/deck_configuration.asm @@ -2411,9 +2411,9 @@ HandleDeckConfirmationMenu: ld a, [wCardListCursorPos] ld [wced7], a - ; set wOwnedCardsCountList as current card list + ; set wUniqueDeckCardList as current card list ; and show card page screen - ld de, wOwnedCardsCountList + ld de, wUniqueDeckCardList ld hl, wCurCardListPtr ld [hl], e inc hl diff --git a/src/engine/menus/deck_machine.asm b/src/engine/menus/deck_machine.asm index 559ec754..9dec9668 100644 --- a/src/engine/menus/deck_machine.asm +++ b/src/engine/menus/deck_machine.asm @@ -71,9 +71,9 @@ HandleDeckMissingCardsList: ld a, [wCardListCursorPos] ld [wced7], a - ; set wOwnedCardsCountList as current card list + ; set wUniqueDeckCardList as current card list ; and show card page screen - ld de, wOwnedCardsCountList + ld de, wUniqueDeckCardList ld hl, wCurCardListPtr ld [hl], e inc hl diff --git a/src/home/card_color.asm b/src/home/card_color.asm index 99b3cde6..952ab6a2 100644 --- a/src/home/card_color.asm +++ b/src/home/card_color.asm @@ -108,5 +108,5 @@ HandleEnergyBurn:: dec c jr nz, .zero_next_energy ld a, [wTotalAttachedEnergies] - ld [wAttachedEnergies], a + ld [wAttachedEnergies + FIRE], a ret diff --git a/src/home/duel.asm b/src/home/duel.asm index 3e87b64e..746135c3 100644 --- a/src/home/duel.asm +++ b/src/home/duel.asm @@ -1342,7 +1342,7 @@ ProcessPlayedPokemonCard:: call ClearChangedTypesIfMuk ldh a, [hTempCardIndex_ff98] ld d, a - ld e, $00 + ld e, FIRST_ATTACK_OR_PKMN_POWER call CopyAttackDataAndDamage_FromDeckIndex call UpdateArenaCardIDsAndClearTwoTurnDuelVars ldh a, [hTempCardIndex_ff98] @@ -1861,14 +1861,14 @@ ApplyDamageModifiers_DamageToTarget:: ld d, [hl] dec hl ld e, [hl] - bit 7, d - jr z, .safe - res 7, d ; cap at 2^15 + bit UNAFFECTED_BY_WEAKNESS_RESISTANCE_F, d + jr z, .affected_by_wr + res UNAFFECTED_BY_WEAKNESS_RESISTANCE_F, d xor a ld [wDamageEffectiveness], a call HandleDoubleDamageSubstatus jr .check_pluspower_and_defender -.safe +.affected_by_wr call HandleDoubleDamageSubstatus ld a, e or d diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index 5c0a956e..2f150cac 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -337,9 +337,9 @@ ENDM ; Sets some NPC sprite attributes MACRO set_sprite_attributes run_command ScriptCommand_SetSpriteAttributes - db \1 ; Relates to LOADED_NPC_ANIM - db \2 ; Relates to LOADED_NPC_ANIM - db \3 ; Relates to LOADED_NPC_FLAGS + db \1 ; sprite animation non-CGB (SPRITE_ANIM_*) + db \2 ; sprite animation CGB (SPRITE_ANIM_*) + db \3 ; NPC animation flags (NPC_FLAG_*) ENDM ; Sets the active NPC's coords diff --git a/src/scripts/water_club.asm b/src/scripts/water_club.asm index 6ed61219..880e8bfd 100644 --- a/src/scripts/water_club.asm +++ b/src/scripts/water_club.asm @@ -254,9 +254,9 @@ Script_MeetAmy: set_dialog_npc NPC_AMY print_npc_text AmyMeetsPlayer2Text close_text_box - set_sprite_attributes $09, $2f, $10 + set_sprite_attributes SPRITE_ANIM_SGB_AMY_STAND, SPRITE_ANIM_CGB_AMY_STAND, NPC_FLAG_DIRECTIONLESS do_frames 32 - set_sprite_attributes $04, $0e, $00 + set_sprite_attributes SPRITE_ANIM_DARK_NPC_UP, SPRITE_ANIM_BLUE_NPC_UP, $00 set_active_npc_coords 20, 4 set_player_direction WEST move_player WEST, 1 @@ -306,7 +306,7 @@ Script_LostToAmy: quit_script_fully .ows_e34e - set_sprite_attributes $08, $2e, $10 + set_sprite_attributes SPRITE_ANIM_SGB_AMY_LAYING, SPRITE_ANIM_CGB_AMY_LAYING, NPC_FLAG_DIRECTIONLESS set_active_npc_coords 22, 4 quit_script_fully From 81842fed3b781501945566bb5235c79ba069eb1d Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 10 Nov 2024 22:05:00 +0000 Subject: [PATCH 2/2] Use CARD_LOCATION_PLAY_AREA instead of CARD_LOCATION_ARENA --- src/engine/duel/core.asm | 6 +++--- src/home/duel.asm | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/engine/duel/core.asm b/src/engine/duel/core.asm index ca8c854f..e34cb4d8 100644 --- a/src/engine/duel/core.asm +++ b/src/engine/duel/core.asm @@ -6908,7 +6908,7 @@ DiscardAttachedPluspowers: dec e jr nz, .unattach_pluspower_loop ld de, PLUSPOWER - jp MoveCardToDiscardPileIfInArena + jp MoveCardToDiscardPileIfInPlayArea ; discard any DEFENDER attached to the turn holder's arena and/or bench Pokemon DiscardAttachedDefenders: @@ -6921,7 +6921,7 @@ DiscardAttachedDefenders: dec e jr nz, .unattach_defender_loop ld de, DEFENDER - jp MoveCardToDiscardPileIfInArena + jp MoveCardToDiscardPileIfInPlayArea ; return carry if the turn holder's arena Pokemon card is asleep, poisoned, or double poisoned. ; also, if confused, paralyzed, or asleep, return the status condition in a. @@ -7594,7 +7594,7 @@ GetCardOneStageBelow: ; loads deck indices of the stages present in hTempPlayAreaLocation_ff9d. ; the three stages are loaded consecutively in wAllStagesIndices. ldh a, [hTempPlayAreaLocation_ff9d] - or CARD_LOCATION_ARENA + or CARD_LOCATION_PLAY_AREA ld c, a ld a, DUELVARS_CARD_LOCATIONS call GetTurnDuelistVariable diff --git a/src/home/duel.asm b/src/home/duel.asm index 746135c3..7f00fb7c 100644 --- a/src/home/duel.asm +++ b/src/home/duel.asm @@ -2268,15 +2268,16 @@ GetPlayAreaCardRetreatCost:: call GetLoadedCard1RetreatCost ret -; move the turn holder's card with ID at de to the discard pile -; if it's currently in the arena. -MoveCardToDiscardPileIfInArena:: +; move all turn holder's card with ID at de to the discard pile +; that are currently in the Play Area +; this is used to discard all attached Pluspowers and Defenders +MoveCardToDiscardPileIfInPlayArea:: ld c, e ld b, d ld l, DUELVARS_CARD_LOCATIONS .next_card ld a, [hl] - and CARD_LOCATION_ARENA + and CARD_LOCATION_PLAY_AREA jr z, .skip ; jump if card not in arena ld a, l call GetCardIDFromDeckIndex