diff options
Diffstat (limited to 'engine/battle')
-rwxr-xr-x | engine/battle/animations.asm | 4 | ||||
-rwxr-xr-x | engine/battle/core.asm | 90 | ||||
-rw-r--r-- | engine/battle/experience.asm | 8 | ||||
-rw-r--r-- | engine/battle/init_battle_variables.asm | 10 | ||||
-rw-r--r-- | engine/battle/moveEffects/transform_effect.asm | 6 | ||||
-rw-r--r-- | engine/battle/scroll_draw_trainer_pic.asm | 4 |
6 files changed, 65 insertions, 57 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 1bd48988..6d0f0e5f 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -2170,8 +2170,8 @@ ChangeMonPic: ; 79793 (1e:5793) pop af ld [wBattleMonSpecies2], a .done - ld b, $1 - jp GoPAL_SET + ld b, SET_PAL_BATTLE + jp RunPaletteCommand AnimationHideEnemyMonPic: ; 797d8 (1e:57d8) ; Hides the enemy mon's sprite diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 9dbcf179..0b534dda 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -184,8 +184,8 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) inc a ld [H_AUTOBGTRANSFERENABLED], a call Delay3 - ld b, $1 - call GoPAL_SET + ld b, SET_PAL_BATTLE + call RunPaletteCommand call HideSprites jpab PrintBeginningBattleText @@ -788,7 +788,7 @@ CheckNumAttacksLeft: ; 3c50f (f:450f) HandleEnemyMonFainted: ; 3c525 (f:4525) xor a - ld [wccf0], a + ld [wInHandlePlayerMonFainted], a call FaintEnemyPokemon call AnyPartyAlive ld a, d @@ -888,9 +888,9 @@ FaintEnemyPokemon: ; 0x3c567 ld a, [hli] or [hl] jr nz, .playermonnotfaint - ld a, [wccf0] - and a - jr nz, .playermonnotfaint + ld a, [wInHandlePlayerMonFainted] + and a ; was this called by HandlePlayerMonFainted? + jr nz, .playermonnotfaint ; if so, don't call RemoveFaintedPlayerMon twice call RemoveFaintedPlayerMon .playermonnotfaint call AnyPartyAlive @@ -950,11 +950,13 @@ EnemyMonFaintedText: ; 0x3c63e db "@" EndLowHealthAlarm: ; 3c643 (f:4643) +; This function is called when the player has the won the battle. It turns off +; the low health alarm and prevents it from reactivating until the next battle. xor a - ld [wLowHealthAlarm], a ;disable low health alarm + ld [wLowHealthAlarm], a ; turn off low health alarm ld [wChannelSoundIDs + CH4], a inc a - ld [wccf6], a + ld [wLowHealthAlarmDisabled], a ; prevent it from reactivating ret AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) @@ -976,7 +978,7 @@ AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) ; stores whether enemy ran in Z flag ReplaceFaintedEnemyMon: ; 3c664 (f:4664) - ld hl, wcf1e + ld hl, wEnemyHPBarColor ld e, $30 call GetBattleHealthBarColor callab DrawEnemyPokeballs @@ -1053,8 +1055,8 @@ PlayBattleVictoryMusic: ; 3c6ee (f:46ee) jp Delay3 HandlePlayerMonFainted: ; 3c700 (f:4700) - ld a, $1 - ld [wccf0], a + ld a, 1 + ld [wInHandlePlayerMonFainted], a call RemoveFaintedPlayerMon call AnyPartyAlive ; test if any more mons are alive ld a, d @@ -1115,9 +1117,15 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741) call SlideDownFaintedMonPic ld a, $1 ld [wBattleResult], a - ld a, [wccf0] - and a - ret z + +; When the player mon and enemy mon faint at the same time and the fact that the +; enemy mon has fainted is detected first (e.g. when the player mon knocks out +; the enemy mon using a move with recoil and faints due to the recoil), don't +; play the player mon's cry or show the "[player mon] fainted!" message. + ld a, [wInHandlePlayerMonFainted] + and a ; was this called by HandleEnemyMonFainted? + ret z ; if so, return + ld a, [wBattleMonSpecies] call PlayCry ld hl, PlayerMonFaintedText @@ -1199,7 +1207,7 @@ ChooseNextMon: ; 3c7d8 (f:47d8) call GBPalWhiteOut call LoadHudTilePatterns call LoadScreenTilesFromBuffer1 - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call GBPalNormal call SendOutMon ld hl, wEnemyMonHP @@ -1228,8 +1236,8 @@ HandlePlayerBlackOut: ; 3c837 (f:4837) cp OAKS_LAB ret z ; starter battle in oak's lab: don't black out .notSony1Battle - ld b, $0 - call GoPAL_SET + ld b, SET_PAL_BATTLE_BLACK + call RunPaletteCommand ld hl, PlayerBlackedOutText2 ld a, [wLinkState] cp LINK_STATE_BATTLING @@ -1494,8 +1502,8 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) coord hl, 0, 0 lb bc, 4, 11 call ClearScreenArea - ld b,1 - call GoPAL_SET + ld b, SET_PAL_BATTLE + call RunPaletteCommand call GBPalNormal ld hl,TrainerSentOutText call PrintText @@ -1829,8 +1837,8 @@ SendOutMon: ; 3cc91 (f:4c91) ld [W_PLAYERDISABLEDMOVE], a ld [wPlayerDisabledMoveNumber], a ld [wPlayerMonMinimized], a - ld b, $1 - call GoPAL_SET + ld b, SET_PAL_BATTLE + call RunPaletteCommand ld hl, W_ENEMYBATTSTATUS1 res UsingTrappingMove, [hl] ld a, $1 @@ -1926,17 +1934,17 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) predef DrawHP ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - ld hl, wcf1d + ld hl, wPlayerHPBarColor call GetBattleHealthBarColor ld hl, wBattleMonHP ld a, [hli] or [hl] jr z, .asm_3cdd9 - ld a, [wccf6] - and a - ret nz - ld a, [wcf1d] - cp $2 + ld a, [wLowHealthAlarmDisabled] + and a ; has the alarm been disabled because the player has already won? + ret nz ; if so, return + ld a, [wPlayerHPBarColor] + cp HP_BAR_RED jr z, .asm_3cde6 .asm_3cdd9 ld hl, wLowHealthAlarm @@ -2039,7 +2047,7 @@ DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec) call DrawHPBar ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - ld hl, wcf1e + ld hl, wEnemyHPBarColor GetBattleHealthBarColor: ; 3ce90 (f:4e90) ld b, [hl] @@ -2047,8 +2055,8 @@ GetBattleHealthBarColor: ; 3ce90 (f:4e90) ld a, [hl] cp b ret z - ld b, $1 - jp GoPAL_SET + ld b, SET_PAL_BATTLE + jp RunPaletteCommand ; center's mon's name on the battle screen ; if the name is 1 or 2 letters long, it is printed 2 spaces more to the right than usual @@ -2397,7 +2405,7 @@ PartyMenuOrRockOrRun: call GBPalWhiteOut call LoadHudTilePatterns call LoadScreenTilesFromBuffer2 - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call GBPalNormal jp DisplayBattleMenu .partyMonDeselected @@ -2486,7 +2494,7 @@ PartyMenuOrRockOrRun: call ClearSprites call LoadHudTilePatterns call LoadScreenTilesFromBuffer1 - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call GBPalNormal ; fall through to SwitchPlayerMon @@ -2634,7 +2642,7 @@ MoveSelectionMenu: ; 3d219 (f:5219) cp LINK_STATE_BATTLING jr z, .matchedkeyspicked ld a, [W_FLAGS_D733] - bit 0, a + bit BIT_TEST_BATTLE, a ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON | SELECT jr z, .matchedkeyspicked ld b, $ff @@ -2662,7 +2670,7 @@ SelectMenuItem: ; 3d2fe (f:52fe) jr .select .battleselect ld a, [W_FLAGS_D733] - bit 0, a + bit BIT_TEST_BATTLE, a jr nz, .select call PrintMenuItem ld a, [wMenuItemToSwap] @@ -6170,8 +6178,8 @@ GetCurrentMove: ; 3eabe (f:6abe) .player ld de, W_PLAYERMOVENUM ld a, [W_FLAGS_D733] - bit 0, a - ld a, [wccd9] + bit BIT_TEST_BATTLE, a + ld a, [wTestBattlePlayerSelectedMove] jr nz, .selected ld a, [wPlayerSelectedMove] .selected @@ -6201,7 +6209,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) call GetMonHeader ld a, [W_ENEMYBATTSTATUS3] bit Transformed, a ; is enemy mon transformed? - ld hl, wcceb ; copied DVs from when it used Transform + ld hl, wTransformedEnemyMonOriginalDVs ; original DVs before transforming ld a, [hli] ld b, [hl] jr nz, .storeDVs @@ -6879,7 +6887,7 @@ InitBattleCommon: ; 3ef3d (f:6f3d) ld [wEnemyMonPartyPos], a ld a, $2 ld [W_ISINBATTLE], a - jp InitBattle_Common + jp _InitBattleCommon InitWildBattle: ; 3ef8b (f:6f8b) ld a, $1 @@ -6931,9 +6939,9 @@ InitWildBattle: ; 3ef8b (f:6f8b) predef CopyUncompressedPicToTilemap ; common code that executes after init battle code specific to trainer or wild battles -InitBattle_Common: ; 3efeb (f:6feb) - ld b, $0 - call GoPAL_SET +_InitBattleCommon: ; 3efeb (f:6feb) + ld b, SET_PAL_BATTLE_BLACK + call RunPaletteCommand call SlidePlayerAndEnemySilhouettesOnScreen xor a ld [H_AUTOBGTRANSFERENABLED], a diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index 433588e3..ab3e3c19 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -76,11 +76,11 @@ GainExperience: ; 5524f (15:524f) ld b, [hl] ld a, [wPlayerID + 1] cp b - ld a, $0 + ld a, 0 jr z, .next .tradedMon call BoostExp ; traded mon exp boost - ld a, $1 + ld a, 1 .next ld [wGainBoostedExp], a ld a, [W_ISINBATTLE] @@ -92,12 +92,12 @@ GainExperience: ; 5524f (15:524f) ; add the gained exp to the party mon's exp ld b, [hl] ld a, [H_QUOTIENT + 3] - ld [wcf4c], a + ld [wExpAmountGained + 1], a add b ld [hld], a ld b, [hl] ld a, [H_QUOTIENT + 2] - ld [wcf4b], a + ld [wExpAmountGained], a adc b ld [hl], a jr nc, .noCarry diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm index 3c926858..6a4cd771 100644 --- a/engine/battle/init_battle_variables.asm +++ b/engine/battle/init_battle_variables.asm @@ -16,17 +16,17 @@ InitBattleVariables: ; 525af (14:65af) ld [wPlayerMonNumber], a ld [wEscapedFromBattle], a ld [wMapPalOffset], a - ld hl, wcf1d - ld [hli], a - ld [hl], a + ld hl, wPlayerHPBarColor + ld [hli], a ; wPlayerHPBarColor + ld [hl], a ; wEnemyHPBarColor ld hl, wCanEvolveFlags ld b, $3c .loop ld [hli], a dec b jr nz, .loop - inc a - ld [wccd9], a + inc a ; POUND + ld [wTestBattlePlayerSelectedMove], a ld a, [W_CURMAP] cp SAFARI_ZONE_EAST jr c, .notSafariBattle diff --git a/engine/battle/moveEffects/transform_effect.asm b/engine/battle/moveEffects/transform_effect.asm index 185d47af..6a40eda2 100644 --- a/engine/battle/moveEffects/transform_effect.asm +++ b/engine/battle/moveEffects/transform_effect.asm @@ -67,12 +67,12 @@ TransformEffect_: ; 3bab1 (e:7ab1) ld a, [H_WHOSETURN] and a jr z, .next -; save enemy mon DVs in wcceb/wccec (enemy turn only) +; save enemy mon DVs at wTransformedEnemyMonOriginalDVs ld a, [de] - ld [wcceb], a + ld [wTransformedEnemyMonOriginalDVs], a inc de ld a, [de] - ld [wccec], a + ld [wTransformedEnemyMonOriginalDVs + 1], a dec de .next ; DVs diff --git a/engine/battle/scroll_draw_trainer_pic.asm b/engine/battle/scroll_draw_trainer_pic.asm index b32650e3..5949208c 100644 --- a/engine/battle/scroll_draw_trainer_pic.asm +++ b/engine/battle/scroll_draw_trainer_pic.asm @@ -3,8 +3,8 @@ _ScrollTrainerPicAfterBattle: ; 396d3 (e:56d3) ; the screen from the right. xor a ld [wEnemyMonSpecies2], a - ld b, $1 - call GoPAL_SET + ld b, SET_PAL_BATTLE + call RunPaletteCommand callab _LoadTrainerPic coord hl, 19, 0 ld c, $0 |