diff options
Diffstat (limited to 'engine/battle')
-rw-r--r-- | engine/battle/ai/items.asm | 4 | ||||
-rw-r--r-- | engine/battle/ai/scoring.asm | 36 | ||||
-rw-r--r-- | engine/battle/ai/switch.asm | 16 | ||||
-rw-r--r-- | engine/battle/core.asm | 152 | ||||
-rw-r--r-- | engine/battle/effect_commands.asm | 58 | ||||
-rw-r--r-- | engine/battle/misc.asm | 10 | ||||
-rw-r--r-- | engine/battle/move_effects/baton_pass.asm | 8 | ||||
-rw-r--r-- | engine/battle/move_effects/counter.asm | 1 | ||||
-rw-r--r-- | engine/battle/move_effects/false_swipe.asm | 2 | ||||
-rw-r--r-- | engine/battle/move_effects/magnitude.asm | 2 | ||||
-rw-r--r-- | engine/battle/move_effects/metronome.asm | 2 | ||||
-rw-r--r-- | engine/battle/move_effects/mirror_coat.asm | 5 | ||||
-rw-r--r-- | engine/battle/move_effects/mirror_move.asm | 2 | ||||
-rw-r--r-- | engine/battle/move_effects/sketch.asm | 2 | ||||
-rw-r--r-- | engine/battle/move_effects/spite.asm | 4 | ||||
-rw-r--r-- | engine/battle/move_effects/thief.asm | 8 | ||||
-rw-r--r-- | engine/battle/start_battle.asm | 2 | ||||
-rw-r--r-- | engine/battle/trainer_huds.asm | 21 | ||||
-rw-r--r-- | engine/battle/used_move_text.asm | 27 |
19 files changed, 184 insertions, 178 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm index 29bc23b20..28dfb1010 100644 --- a/engine/battle/ai/items.asm +++ b/engine/battle/ai/items.asm @@ -806,7 +806,7 @@ EnemyUsedXItem: push bc call PrintText_UsedItemOn pop bc - farcall CheckIfStatCanBeRaised + farcall RaiseStat jp AIUpdateHUD ; Parameter @@ -818,7 +818,7 @@ PrintText_UsedItemOn_AND_AIUpdateHUD: PrintText_UsedItemOn: ld a, [wCurEnemyItem] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetItemName ld hl, wStringBuffer1 ld de, wMonOrItemNameBuffer diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm index 6928a3a83..752796892 100644 --- a/engine/battle/ai/scoring.asm +++ b/engine/battle/ai/scoring.asm @@ -171,10 +171,10 @@ AI_Types: pop bc pop hl - ld a, [wd265] + ld a, [wTypeMatchup] and a jr z, .immune - cp 10 ; 1.0 + cp EFFECTIVE jr z, .checkmove jr c, .noteffective @@ -415,8 +415,8 @@ AI_Smart_LeechHit: pop hl ; 60% chance to discourage this move if not very effective. - ld a, [wd265] - cp 10 ; 1.0 + ld a, [wTypeMatchup] + cp EFFECTIVE jr c, .asm_38815 ; Do nothing if effectiveness is neutral. @@ -491,8 +491,8 @@ AI_Smart_LockOn: push hl push bc farcall BattleCheckTypeMatchup - ld a, [wd265] - cp $a + ld a, [wTypeMatchup] + cp EFFECTIVE pop bc pop hl jr c, .asm_3884f @@ -1292,8 +1292,8 @@ AI_Smart_Mimic: ld [hBattleTurn], a callfar BattleCheckTypeMatchup - ld a, [wd265] - cp $a + ld a, [wTypeMatchup] + cp EFFECTIVE pop hl jr c, .asm_38bef jr z, .asm_38bd4 @@ -1408,8 +1408,8 @@ AI_Smart_Encore: predef CheckTypeMatchup pop hl - ld a, [wd265] - cp $a + ld a, [wTypeMatchup] + cp EFFECTIVE jr nc, .asm_38c68 and a @@ -1550,7 +1550,7 @@ AI_Smart_Spite: dec [hl] ret -Function_0x38d16 +Function_0x38d16: jp AIDiscourageMove AI_Smart_DestinyBond: @@ -1679,8 +1679,8 @@ AI_Smart_Conversion2: callfar BattleCheckTypeMatchup - ld a, [wd265] - cp $a + ld a, [wTypeMatchup] + cp EFFECTIVE pop hl jr c, .asm_38dc9 ret z @@ -2293,8 +2293,8 @@ AI_Smart_HiddenPower: pop hl ; Discourage Hidden Power if not very effective. - ld a, [wd265] - cp 10 + ld a, [wTypeMatchup] + cp EFFECTIVE jr c, .bad ; Discourage Hidden Power if its base power is lower than 50. @@ -2303,8 +2303,8 @@ AI_Smart_HiddenPower: jr c, .bad ; Encourage Hidden Power if super-effective. - ld a, [wd265] - cp 11 + ld a, [wTypeMatchup] + cp EFFECTIVE + 1 jr nc, .good ; Encourage Hidden Power if its base power is 70. @@ -3125,7 +3125,7 @@ AI_Status: pop bc pop hl - ld a, [wd265] + ld a, [wTypeMatchup] and a jr nz, .checkmove diff --git a/engine/battle/ai/switch.asm b/engine/battle/ai/switch.asm index b9bd2ea60..b12087e23 100644 --- a/engine/battle/ai/switch.asm +++ b/engine/battle/ai/switch.asm @@ -30,11 +30,11 @@ CheckPlayerMoveTypeMatchups: ld hl, wEnemyMonType call CheckTypeMatchup ld a, [wTypeMatchup] - cp 10 + 1 ; 1.0 + 0.1 + cp EFFECTIVE + 1 ; 1.0 + 0.1 jr nc, .super_effective and a jr z, .next - cp 10 ; 1.0 + cp EFFECTIVE ; 1.0 jr nc, .neutral .not_very_effective @@ -75,7 +75,7 @@ CheckPlayerMoveTypeMatchups: ld hl, wEnemyMonType1 call CheckTypeMatchup ld a, [wTypeMatchup] - cp 10 + 1 ; 1.0 + 0.1 + cp EFFECTIVE + 1 ; 1.0 + 0.1 jr c, .ok call .DecreaseScore .ok @@ -84,7 +84,7 @@ CheckPlayerMoveTypeMatchups: jr z, .ok2 call CheckTypeMatchup ld a, [wTypeMatchup] - cp 10 + 1 ; 1.0 + 0.1 + cp EFFECTIVE + 1 ; 1.0 + 0.1 jr c, .ok2 call .DecreaseScore .ok2 @@ -130,7 +130,7 @@ CheckPlayerMoveTypeMatchups: ; not very effective inc c - cp 10 + cp EFFECTIVE jr c, .loop2 ; neutral @@ -139,7 +139,7 @@ CheckPlayerMoveTypeMatchups: inc c inc c inc c - cp 10 + cp EFFECTIVE jr z, .loop2 ; super effective @@ -481,7 +481,7 @@ FindEnemyMonsWithASuperEffectiveMove: ; if neutral: load 1 and continue ld e, 1 - cp 10 + 1 + cp EFFECTIVE + 1 jr c, .nope ; if super-effective: load 2 and break @@ -584,7 +584,7 @@ FindEnemyMonsThatResistPlayer: ld hl, wBaseType call CheckTypeMatchup ld a, [wTypeMatchup] - cp 10 + 1 + cp EFFECTIVE + 1 jr nc, .dont_choose_mon ld a, b diff --git a/engine/battle/core.asm b/engine/battle/core.asm index c3c7e9867..2d5e85cef 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -373,7 +373,7 @@ HandleBerserkGene: push bc callfar GetUserItem ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a sub BERSERK_GENE pop bc pop de @@ -447,7 +447,7 @@ DetermineMoveOrder: sub BATTLEACTION_SWITCH1 jr c, .use_move ld a, [wBattlePlayerAction] - cp $2 + cp BATTLEPLAYERACTION_SWITCH jr nz, .switch ld a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK @@ -472,7 +472,7 @@ DetermineMoveOrder: .use_move ld a, [wBattlePlayerAction] - and a + and a ; BATTLEPLAYERACTION_USEMOVE? jp nz, .player_first call CompareMovePriority jr z, .equal_priority @@ -530,7 +530,7 @@ DetermineMoveOrder: ld de, wBattleMonSpeed ld hl, wEnemyMonSpeed ld c, 2 - call StringCmp + call CompareBytes jr z, .speed_tie jp nc, .player_first jp .enemy_first @@ -611,7 +611,7 @@ ParsePlayerAction: .not_encored ld a, [wBattlePlayerAction] - cp $2 + cp BATTLEPLAYERACTION_SWITCH jr z, .reset_rage and a jr nz, .reset_bide @@ -900,7 +900,7 @@ Battle_EnemyFirst: call ResidualDamage jp z, HandlePlayerMonFaint call RefreshBattleHuds - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ret @@ -949,7 +949,7 @@ Battle_PlayerFirst: call ResidualDamage jp z, HandleEnemyMonFaint call RefreshBattleHuds - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ret @@ -1161,7 +1161,7 @@ HandlePerishSong: ret z dec [hl] ld a, [hl] - ld [wd265], a + ld [wDeciramBuffer], a push af ld hl, PerishCountText call StdBattleTextBox @@ -1235,7 +1235,7 @@ HandleWrap: ret nz ld a, [de] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld [wFXAnimID], a call GetMoveName dec [hl] @@ -1288,7 +1288,7 @@ HandleLeftovers: callfar GetUserItem ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetItemName ld a, b cp HELD_LEFTOVERS @@ -1397,7 +1397,7 @@ HandleMysteryberry: push bc push bc ld a, [hl] - ld [wd265], a + ld [wTempByteValue], a ld de, wBattleMonMoves - 1 ld hl, wBattleMonPP ld a, [hBattleTurn] @@ -1417,7 +1417,7 @@ HandleMysteryberry: pop de pop bc - ld a, [wd265] + ld a, [wTempByteValue] cp [hl] jr nz, .skip_checks ld a, [hBattleTurn] @@ -1434,7 +1434,7 @@ HandleMysteryberry: .skip_checks callfar GetUserItem ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a xor a ld [hl], a call GetPartymonItem @@ -2048,18 +2048,18 @@ HandleEnemyMonFaint: call CheckMobileBattleError jp c, WildFled_EnemyFled_LinkBattleCanceled - ld a, $1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a call HandleEnemySwitch jp z, WildFled_EnemyFled_LinkBattleCanceled jr DoubleSwitch .player_mon_not_fainted - ld a, $1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a call HandleEnemySwitch jp z, WildFled_EnemyFled_LinkBattleCanceled - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ret @@ -2088,7 +2088,7 @@ DoubleSwitch: call PlayerPartyMonEntrance .done - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ret @@ -2636,7 +2636,7 @@ HandlePlayerMonFaint: ld a, c and a ret nz - ld a, $1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a call HandleEnemySwitch jp z, WildFled_EnemyFled_LinkBattleCanceled @@ -2716,12 +2716,12 @@ ForcePlayerMonChoice: ld a, [wLinkMode] and a jr z, .skip_link - ld a, $1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a call LinkBattleSendReceiveAction .skip_link - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a call CheckMobileBattleError jr c, .enemy_fainted_mobile_error @@ -3287,8 +3287,8 @@ LookUpTheEffectivenessOfEveryMove: pop bc pop de pop hl - ld a, [wd265] ; Get The Effectiveness Modifier - cp 10 + 1 ; 1.0 + 0.1 + ld a, [wTypeMatchup] + cp EFFECTIVE + 1 jr c, .loop ld hl, wBuffer1 set 0, [hl] @@ -3319,14 +3319,14 @@ IsThePlayerMonTypesEffectiveAgainstOTMon: ld [wPlayerMoveStruct + MOVE_TYPE], a call SetPlayerTurn callfar BattleCheckTypeMatchup - ld a, [wd265] - cp 10 + 1 ; 1.0 + 0.1 + ld a, [wTypeMatchup] + cp EFFECTIVE + 1 jr nc, .super_effective ld a, [wBattleMonType2] ld [wPlayerMoveStruct + MOVE_TYPE], a callfar BattleCheckTypeMatchup - ld a, [wd265] - cp 10 + 1 ; 1.0 + 0.1 + ld a, [wTypeMatchup] + cp EFFECTIVE + 1 jr nc, .super_effective pop bc ret @@ -3619,10 +3619,10 @@ CheckPlayerPartyForFitMon: ld e, a xor a ld hl, wPartyMon1HP - ld bc, wPartyMon2 - (wPartyMon1 + 1) + ld bc, PARTYMON_STRUCT_LENGTH - 1 .loop or [hl] - inc hl + inc hl ; + 1 or [hl] add hl, bc dec e @@ -3695,7 +3695,7 @@ TryToRunAwayFromBattle: push hl push de ld a, [wBattleMonItem] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld b, a callfar GetItemHeldEffect ld a, b @@ -3715,33 +3715,33 @@ TryToRunAwayFromBattle: inc a ld [wNumFleeAttempts], a ld a, [hli] - ld [hStringCmpString2 + 0], a + ld [hPartyMon1Speed + 0], a ld a, [hl] - ld [hStringCmpString2 + 1], a + ld [hPartyMon1Speed + 1], a ld a, [de] inc de - ld [hStringCmpString1 + 0], a + ld [hEnemyMonSpeed + 0], a ld a, [de] - ld [hStringCmpString1 + 1], a + ld [hEnemyMonSpeed + 1], a call Call_LoadTempTileMapToTileMap - ld de, hStringCmpString2 - ld hl, hStringCmpString1 - ld c, $2 - call StringCmp + ld de, hPartyMon1Speed + ld hl, hEnemyMonSpeed + ld c, 2 + call CompareBytes jr nc, .can_escape xor a ld [hMultiplicand], a - ld a, $20 + ld a, 32 ld [hMultiplier], a call Multiply ld a, [hProduct + 2] ld [hDividend + 0], a ld a, [hProduct + 3] ld [hDividend + 1], a - ld a, [hStringCmpString1 + 0] + ld a, [hEnemyMonSpeed + 0] ld b, a - ld a, [hStringCmpString1 + 1] + ld a, [hEnemyMonSpeed + 1] srl b rr a srl b @@ -3772,7 +3772,7 @@ TryToRunAwayFromBattle: ld a, [hQuotient + 2] cp b jr nc, .can_escape - ld a, $1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a ld hl, BattleText_CantEscape2 jr .print_inescapable_text @@ -3786,7 +3786,7 @@ TryToRunAwayFromBattle: .print_inescapable_text call StdBattleTextBox - ld a, $1 + ld a, TRUE ld [wFailedToFlee], a call LoadTileMapToTempTileMap and a @@ -3798,7 +3798,7 @@ TryToRunAwayFromBattle: ld a, DRAW jr z, .fled call LoadTileMapToTempTileMap - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ld a, $f ld [wCurMoveNum], a @@ -4429,7 +4429,7 @@ UseConfusionHealingItem: .heal_status ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVarAddr res SUBSTATUS_CONFUSED, [hl] @@ -4496,7 +4496,7 @@ HandleStatBoostingHeldItems: jr nz, .loop pop bc ld a, [bc] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a push bc dec hl dec hl @@ -4952,7 +4952,7 @@ BattleMenu_Pack: farcall BattlePack ld a, [wBattlePlayerAction] - and a + and a ; BATTLEPLAYERACTION_USEMOVE? jr z, .didnt_use_item jr .got_item @@ -5157,7 +5157,7 @@ TryPlayerSwitch: jp z, BattleMenuPKMN_Loop ld a, [wCurBattleMon] ld [wLastPlayerMon], a - ld a, $2 + ld a, BATTLEPLAYERACTION_SWITCH ld [wBattlePlayerAction], a call ClearPalettes call DelayFrame @@ -5270,8 +5270,8 @@ PassedBattleMonEntrance: ld [wCurBattleMon], a call AddBattleParticipant call InitBattleMon - xor a - ld [wd265], a + xor a ; FALSE + ld [wApplyStatLevelMultipliersToEnemy], a call ApplyStatLevelMultiplierOnAllStats call SendOutPlayerMon call EmptyBattleTextBox @@ -5286,11 +5286,11 @@ BattleMenu_Run: ld hl, wBattleMonSpeed ld de, wEnemyMonSpeed call TryToRunAwayFromBattle - ld a, $0 + ld a, FALSE ld [wFailedToFlee], a ret c ld a, [wBattlePlayerAction] - and a + and a ; BATTLEPLAYERACTION_USEMOVE? ret nz jp BattleMenu @@ -5770,7 +5770,7 @@ ParseEnemyAction: call EmptyBattleTextBox call LoadTileMapToTempTileMap ld a, [wBattlePlayerAction] - and a + and a ; BATTLEPLAYERACTION_USEMOVE? call z, LinkBattleSendReceiveAction call Call_LoadTempTileMapToTileMap ld a, [wBattleAction] @@ -5989,7 +5989,7 @@ LoadEnemyMon: ; Used for Ho-Oh, Lugia and Snorlax encounters ld a, [wBattleType] cp BATTLETYPE_FORCEITEM - ld a, [wBaseItems] + ld a, [wBaseItem1] jr z, .UpdateItem ; Failing that, it's all up to chance @@ -6007,9 +6007,9 @@ LoadEnemyMon: ; From there, an 8% chance for Item2 call BattleRandom cp 8 percent ; 8% of 25% = 2% Item2 - ld a, [wBaseItems] + ld a, [wBaseItem1] jr nc, .UpdateItem - ld a, [wBaseItems+1] + ld a, [wBaseItem2] .UpdateItem: ld [wEnemyMonItem], a @@ -6375,7 +6375,7 @@ LoadEnemyMon: ld [de], a ld a, [wTempEnemyMonSpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName @@ -6661,14 +6661,14 @@ ApplyStatLevelMultiplierOnAllStats: call ApplyStatLevelMultiplier inc c ld a, c - cp 5 + cp NUM_BATTLE_STATS jr nz, .stat_loop ret ApplyStatLevelMultiplier: push bc push bc - ld a, [wd265] + ld a, [wApplyStatLevelMultipliersToEnemy] and a ld a, c ld hl, wBattleMonAttack @@ -6718,7 +6718,7 @@ ApplyStatLevelMultiplier: call Multiply ld a, [hl] ld [hDivisor], a - ld b, $4 + ld b, 4 call Divide pop hl @@ -6992,7 +6992,7 @@ GiveExperiencePoints: ld a, [wCurPartyMon] ld c, a ld b, CHECK_FLAG - ld d, $0 + ld d, FALSE predef SmallFarFlagAction ld a, c and a @@ -7006,7 +7006,7 @@ GiveExperiencePoints: ld e, l ld hl, wEnemyMonBaseStats - 1 push bc - ld c, $5 + ld c, NUM_EXP_STATS .loop1 inc hl ld a, [de] @@ -7113,7 +7113,7 @@ GiveExperiencePoints: push bc call LoadTileMapToTempTileMap pop bc - ld hl, MON_STAT_EXP - 1 + ld hl, MON_EXP + 2 add hl, bc ld d, [hl] ld a, [hQuotient + 2] @@ -7145,7 +7145,7 @@ GiveExperiencePoints: ld d, MAX_LEVEL callfar CalcExpAtLevel pop bc - ld hl, MON_STAT_EXP - 1 + ld hl, MON_EXP + 2 add hl, bc push bc ld a, [hQuotient] @@ -7192,7 +7192,7 @@ GiveExperiencePoints: add hl, bc ld a, [hl] ld [wCurSpecies], a - ld [wd265], a + ld [wTempSpecies], a ; unused? call GetBaseData ld hl, MON_MAXHP + 1 add hl, bc @@ -7256,8 +7256,8 @@ GiveExperiencePoints: call CopyBytes .transformed - xor a - ld [wd265], a + xor a ; FALSE + ld [wApplyStatLevelMultipliersToEnemy], a call ApplyStatLevelMultiplierOnAllStats callfar ApplyStatusEffectOnPlayerStats callfar BadgeStatBoosts @@ -7286,20 +7286,20 @@ GiveExperiencePoints: ld [wMonType], a predef CopyMonToTempMon hlcoord 9, 0 - ld b, $a - ld c, $9 + ld b, 10 + ld c, 9 call TextBox hlcoord 11, 1 ld bc, 4 predef PrintTempMonStats - ld c, $1e + ld c, 30 call DelayFrames call WaitPressAorB_BlinkCursor call Call_LoadTempTileMapToTileMap xor a ; PARTYMON ld [wMonType], a ld a, [wCurSpecies] - ld [wd265], a + ld [wTempSpecies], a ; unused? ld a, [wCurPartyLevel] push af ld c, a @@ -7359,7 +7359,7 @@ GiveExperiencePoints: cp 2 ret c - ld [wd265], a + ld [wTempByteValue], a ld hl, wEnemyMonBaseStats ld c, wEnemyMonEnd - wEnemyMonBaseStats .count_loop2 @@ -7367,7 +7367,7 @@ GiveExperiencePoints: ld [hDividend + 0], a ld a, [hl] ld [hDividend + 1], a - ld a, [wd265] + ld a, [wTempByteValue] ld [hDivisor], a ld b, 2 call Divide @@ -8578,7 +8578,7 @@ ReadAndPrintLinkBattleRecord: db " 0 0 0@" .Format: - db " --- <LNBRK>" + db " --- <LF>" db " - - -@" .Record: db "<PLAYER>'s RECORD@" @@ -8712,7 +8712,7 @@ AddLastMobileBattleToLinkRecord: push de ld bc, 12 ld de, wStringBuffer1 - call CompareLong + call CompareBytesLong pop de pop hl jr c, .done @@ -8821,7 +8821,7 @@ AddLastMobileBattleToLinkRecord: pop hl push bc ld c, 3 - call StringCmp + call CompareBytes pop bc jr z, .equal jr nc, .done2 @@ -9094,7 +9094,7 @@ BattleStartMessage: jr .skip_cry ; cry is played during the animation .cry_no_anim - ld a, $0f + ld a, $f ld [wCryTracks], a ld a, [wTempEnemyMonSpecies] call PlayStereoCry diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index 3e6d928d2..91c021a72 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -2,7 +2,7 @@ DoPlayerTurn: call SetPlayerTurn ld a, [wBattlePlayerAction] - and a + and a ; BATTLEPLAYERACTION_USEMOVE? ret nz jr DoTurn @@ -1210,7 +1210,9 @@ BattleCommand_Critical: ld [wCriticalHit], a ret -INCLUDE "data/battle/critical_hits.asm" +INCLUDE "data/moves/critical_hit_moves.asm" + +INCLUDE "data/battle/critical_hit_chances.asm" INCLUDE "engine/battle/move_effects/triple_kick.asm" @@ -1246,7 +1248,7 @@ BattleCommand_Stab: .go ld a, BATTLE_VARS_MOVE_TYPE call GetBattleVarAddr - ld [wTypeMatchup], a + ld [wCurType], a push hl push de @@ -1262,7 +1264,7 @@ BattleCommand_Stab: pop bc pop de - ld a, [wTypeMatchup] + ld a, [wCurType] cp b jr z, .stab cp c @@ -2361,10 +2363,12 @@ BattleCommand_SuperEffectiveText: .print jp StdBattleTextBox -BattleCommand_CheckDestinyBond: -; checkdestinybond +BattleCommand_CheckFaint: +; checkfaint -; Faint the user if it fainted an opponent using Destiny Bond. +; Faint the opponent if its HP reached zero +; and faint the user along with it if it used Destiny Bond. +; Ends the move effect if the opponent faints. ld hl, wEnemyMonHP ld a, [hBattleTurn] @@ -2592,7 +2596,7 @@ PlayerAttackDamage: .physicalcrit ld hl, wBattleMonAttack - call GetDamageStatsCritical + call CheckDamageStatsCritical jr c, .thickclub ld hl, wEnemyDefense @@ -2616,7 +2620,7 @@ PlayerAttackDamage: .specialcrit ld hl, wBattleMonSpclAtk - call GetDamageStatsCritical + call CheckDamageStatsCritical jr c, .lightball ld hl, wEnemySpDef @@ -2677,7 +2681,7 @@ TruncateHL_BC: .finish ld a, [wLinkMode] - cp 3 + cp LINK_COLOSSEUM jr z, .done ; If we go back to the loop point, ; it's the same as doing this exact @@ -2690,20 +2694,16 @@ TruncateHL_BC: ld b, l ret -GetDamageStatsCritical: -; Return carry if non-critical. +CheckDamageStatsCritical: +; Return carry if boosted stats should be used in damage calculations. +; Unboosted stats should be used if the attack is a critical hit, +; and the stage of the opponent's defense is higher than the user's attack. ld a, [wCriticalHit] and a scf ret z - ; fallthrough - -GetDamageStats: -; Return the attacker's offensive stat and the defender's defensive -; stat based on whether the attacking type is physical or special. - push hl push bc ld a, [hBattleTurn] @@ -2838,7 +2838,7 @@ EnemyAttackDamage: .physicalcrit ld hl, wEnemyMonAttack - call GetDamageStatsCritical + call CheckDamageStatsCritical jr c, .thickclub ld hl, wPlayerDefense @@ -2862,7 +2862,7 @@ EnemyAttackDamage: .specialcrit ld hl, wEnemyMonSpclAtk - call GetDamageStatsCritical + call CheckDamageStatsCritical jr c, .lightball ld hl, wPlayerSpDef ld a, [hli] @@ -3581,7 +3581,7 @@ UpdateMoveData: ld a, BATTLE_VARS_MOVE call GetBattleVar - ld [wCurMove], a + ld [wCurSpecies], a ld [wNamedObjectIndexBuffer], a dec a @@ -4183,13 +4183,13 @@ BattleCommand_EvasionUp2: BattleCommand_StatUp: ; statup - call CheckIfStatCanBeRaised + call RaiseStat ld a, [wFailedMessage] and a ret nz - jp StatUpAnimation + jp MinimizeDropSub -CheckIfStatCanBeRaised: +RaiseStat: ld a, b ld [wLoweredStat], a ld hl, wPlayerStatLevels @@ -4285,7 +4285,9 @@ CheckIfStatCanBeRaised: ld [wFailedMessage], a ret -StatUpAnimation: +MinimizeDropSub: +; Lower the substitute if we're minimizing + ld bc, wPlayerMinimized ld hl, DropPlayerSub ld a, [hBattleTurn] @@ -6152,7 +6154,7 @@ BattleCommand_Heal: push de push bc ld c, 2 - call StringCmp + call CompareBytes pop bc pop de pop hl @@ -6571,7 +6573,7 @@ BattleCommand_TimeBasedHealContinue: ; Don't bother healing if HP is already full. push bc - call StringCmp + call CompareBytes pop bc jr z, .Full @@ -6682,7 +6684,7 @@ INCLUDE "engine/battle/move_effects/future_sight.asm" INCLUDE "engine/battle/move_effects/thunder.asm" CheckHiddenOpponent: -; BUG: This routine should account for Lock-On and Mind Reader. +; BUG: This routine is completely redundant and introduces a bug, since BattleCommand_CheckHit does these checks properly. ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND diff --git a/engine/battle/misc.asm b/engine/battle/misc.asm index 48062f643..8985385a0 100644 --- a/engine/battle/misc.asm +++ b/engine/battle/misc.asm @@ -53,13 +53,13 @@ DoWeatherModifiers: ld de, WeatherTypeModifiers ld a, [wBattleWeather] ld b, a - ld a, [wd265] ; move type + ld a, [wCurType] ld c, a .CheckWeatherType: ld a, [de] inc de - cp $ff + cp -1 jr z, .done_weather_types cp b @@ -84,7 +84,7 @@ DoWeatherModifiers: .CheckWeatherMove: ld a, [de] inc de - cp $ff + cp -1 jr z, .done cp b @@ -116,7 +116,7 @@ DoWeatherModifiers: ld a, 10 ld [hDivisor], a - ld b, $4 + ld b, 4 call Divide ld a, [hQuotient + 0] @@ -176,7 +176,7 @@ DoBadgeTypeBoosts: rr c jr nc, .NextBadge - ld a, [wd265] ; move type + ld a, [wCurType] cp [hl] jr z, .ApplyBoost diff --git a/engine/battle/move_effects/baton_pass.asm b/engine/battle/move_effects/baton_pass.asm index 5d9f19838..7f922b214 100644 --- a/engine/battle/move_effects/baton_pass.asm +++ b/engine/battle/move_effects/baton_pass.asm @@ -68,8 +68,8 @@ BattleCommand_BatonPass: call CallBattleCore ld hl, ResetBattleParticipants call CallBattleCore - ld a, 1 - ld [wTypeMatchup], a + ld a, TRUE + ld [wApplyStatLevelMultipliersToEnemy], a ld hl, ApplyStatLevelMultiplierOnAllStats call CallBattleCore @@ -83,7 +83,7 @@ BatonPass_LinkPlayerSwitch: and a ret z - ld a, 1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a call LoadStandardMenuHeader @@ -91,7 +91,7 @@ BatonPass_LinkPlayerSwitch: call CallBattleCore call CloseWindow - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ret diff --git a/engine/battle/move_effects/counter.asm b/engine/battle/move_effects/counter.asm index f92e1b3ac..031c399a6 100644 --- a/engine/battle/move_effects/counter.asm +++ b/engine/battle/move_effects/counter.asm @@ -36,6 +36,7 @@ BattleCommand_Counter: cp SPECIAL ret nc + ; BUG: Move should fail with all non-damaging battle actions ld hl, wCurDamage ld a, [hli] or [hl] diff --git a/engine/battle/move_effects/false_swipe.asm b/engine/battle/move_effects/false_swipe.asm index 4f4eb329c..0d3f7d47c 100644 --- a/engine/battle/move_effects/false_swipe.asm +++ b/engine/battle/move_effects/false_swipe.asm @@ -13,7 +13,7 @@ BattleCommand_FalseSwipe: ld c, 2 push hl push de - call StringCmp + call CompareBytes pop de pop hl jr c, .done diff --git a/engine/battle/move_effects/magnitude.asm b/engine/battle/move_effects/magnitude.asm index 4dcf919d7..eaa0c2a3a 100644 --- a/engine/battle/move_effects/magnitude.asm +++ b/engine/battle/move_effects/magnitude.asm @@ -18,7 +18,7 @@ BattleCommand_GetMagnitude: push de inc hl ld a, [hl] - ld [wTypeMatchup], a + ld [wDeciramBuffer], a call BattleCommand_MoveDelay ld hl, MagnitudeText call StdBattleTextBox diff --git a/engine/battle/move_effects/metronome.asm b/engine/battle/move_effects/metronome.asm index b8a6b586f..25197d7cd 100644 --- a/engine/battle/move_effects/metronome.asm +++ b/engine/battle/move_effects/metronome.asm @@ -40,4 +40,4 @@ BattleCommand_Metronome: call UpdateMoveData jp ResetTurn -INCLUDE "data/battle/metronome_exception_moves.asm" +INCLUDE "data/moves/metronome_exception_moves.asm" diff --git a/engine/battle/move_effects/mirror_coat.asm b/engine/battle/move_effects/mirror_coat.asm index 8743c389d..96afa3175 100644 --- a/engine/battle/move_effects/mirror_coat.asm +++ b/engine/battle/move_effects/mirror_coat.asm @@ -29,14 +29,15 @@ BattleCommand_MirrorCoat: ld de, wStringBuffer1 call GetMoveData - ld a, [wStringBuffer1 + 2] + ld a, [wStringBuffer1 + MOVE_POWER] and a ret z - ld a, [wStringBuffer1 + 3] + ld a, [wStringBuffer1 + MOVE_TYPE] cp SPECIAL ret c + ; BUG: Move should fail with all non-damaging battle actions ld hl, wCurDamage ld a, [hli] or [hl] diff --git a/engine/battle/move_effects/mirror_move.asm b/engine/battle/move_effects/mirror_move.asm index 089403839..89879c825 100644 --- a/engine/battle/move_effects/mirror_move.asm +++ b/engine/battle/move_effects/mirror_move.asm @@ -24,7 +24,7 @@ BattleCommand_MirrorMove: .use ld a, b ld [hl], a - ld [wd265], a + ld [wNamedObjectIndexBuffer], a push af ld a, BATTLE_VARS_MOVE_ANIM diff --git a/engine/battle/move_effects/sketch.asm b/engine/battle/move_effects/sketch.asm index 4c15dbe02..a5b0d1c03 100644 --- a/engine/battle/move_effects/sketch.asm +++ b/engine/battle/move_effects/sketch.asm @@ -34,7 +34,7 @@ BattleCommand_Sketch: .get_last_move ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar - ld [wTypeMatchup], a + ld [wNamedObjectIndexBuffer], a ld b, a ; Fail if move is invalid or is Struggle. and a diff --git a/engine/battle/move_effects/spite.asm b/engine/battle/move_effects/spite.asm index 8aba187a4..71252fe22 100644 --- a/engine/battle/move_effects/spite.asm +++ b/engine/battle/move_effects/spite.asm @@ -24,7 +24,7 @@ BattleCommand_Spite: ld a, [hli] cp b jr nz, .loop - ld [wTypeMatchup], a + ld [wNamedObjectIndexBuffer], a dec hl ld b, 0 push bc @@ -78,7 +78,7 @@ BattleCommand_Spite: call AnimateCurrentMove pop de ld a, d - ld [wTypeMatchup], a + ld [wDeciramBuffer], a ld hl, SpiteEffectText jp StdBattleTextBox diff --git a/engine/battle/move_effects/thief.asm b/engine/battle/move_effects/thief.asm index 64de1a4fe..34a9699fc 100644 --- a/engine/battle/move_effects/thief.asm +++ b/engine/battle/move_effects/thief.asm @@ -21,7 +21,7 @@ BattleCommand_Thief: ; Can't steal mail. - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld d, a farcall ItemIsMail ret c @@ -45,7 +45,7 @@ BattleCommand_Thief: ld [de], a call .playeritem - ld a, [wd265] + ld a, [wNamedObjectIndexBuffer] ld [hl], a ld [de], a jr .stole @@ -68,7 +68,7 @@ BattleCommand_Thief: ; Can't steal mail! - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld d, a farcall ItemIsMail ret c @@ -86,7 +86,7 @@ BattleCommand_Thief: ld [de], a call .enemyitem - ld a, [wd265] + ld a, [wNamedObjectIndexBuffer] ld [hl], a ld [de], a diff --git a/engine/battle/start_battle.asm b/engine/battle/start_battle.asm index 5c2a633a8..f5fc4a6b0 100644 --- a/engine/battle/start_battle.asm +++ b/engine/battle/start_battle.asm @@ -16,7 +16,7 @@ FindFirstAliveMonAndStartBattle: xor a ld [hMapAnims], a call DelayFrame - ld b, 6 + ld b, PARTY_LENGTH ld hl, wPartyMon1HP ld de, PARTYMON_STRUCT_LENGTH - 1 diff --git a/engine/battle/trainer_huds.asm b/engine/battle/trainer_huds.asm index 3930549b2..7a971e21f 100644 --- a/engine/battle/trainer_huds.asm +++ b/engine/battle/trainer_huds.asm @@ -101,7 +101,7 @@ StageBallTilesData: DrawPlayerHUDBorder: ld hl, .tiles ld de, wTrainerHUDTiles - ld bc, 4 + ld bc, .tiles_end - .tiles call CopyBytes hlcoord 18, 10 ld de, -1 ; start on right @@ -112,11 +112,12 @@ DrawPlayerHUDBorder: db $77 ; bottom right db $6f ; bottom left db $76 ; bottom side +.tiles_end DrawPlayerPartyIconHUDBorder: ld hl, .tiles ld de, wTrainerHUDTiles - ld bc, 4 + ld bc, .tiles_end - .tiles call CopyBytes hlcoord 18, 10 ld de, -1 ; start on right @@ -127,11 +128,12 @@ DrawPlayerPartyIconHUDBorder: db $5c ; bottom right db $6f ; bottom left db $76 ; bottom side +.tiles_end DrawEnemyHUDBorder: ld hl, .tiles ld de, wTrainerHUDTiles - ld bc, 4 + ld bc, .tiles_end - .tiles call CopyBytes hlcoord 1, 2 ld de, 1 ; start on left @@ -152,23 +154,24 @@ DrawEnemyHUDBorder: db $74 ; bottom left db $78 ; bottom right db $76 ; bottom side +.tiles_end PlaceHUDBorderTiles: - ld a, [wTrainerHUDTiles] + ld a, [wTrainerHUDTiles + 0] ld [hl], a ld bc, SCREEN_WIDTH add hl, bc - ld a, [wStartFlypoint] + ld a, [wTrainerHUDTiles + 1] ld [hl], a - ld b, $8 + ld b, 8 .loop add hl, de - ld a, [wMovementBuffer] + ld a, [wTrainerHUDTiles + 3] ld [hl], a dec b jr nz, .loop add hl, de - ld a, [wEndFlypoint] + ld a, [wTrainerHUDTiles + 2] ld [hl], a ret @@ -181,7 +184,7 @@ LinkBattle_TrainerHuds: ld a, 10 * 8 ld [hli], a ld [hl], 8 * 8 - ld a, $8 + ld a, 8 ld [wPlaceBallsDirection], a ld hl, wVirtualOAMSprite00 call LoadTrainerHudOAM diff --git a/engine/battle/used_move_text.asm b/engine/battle/used_move_text.asm index 9307a1a1e..8166094f2 100644 --- a/engine/battle/used_move_text.asm +++ b/engine/battle/used_move_text.asm @@ -26,7 +26,7 @@ UsedMoveText: ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar - ld [wd265], a + ld [wMoveGrammar], a push hl farcall CheckUserIsCharging @@ -34,13 +34,12 @@ UsedMoveText: jr nz, .grammar ; update last move - ld a, [wd265] + ld a, [wMoveGrammar] ld [hl], a ld [de], a .grammar - call GetMoveGrammar -; wd265 now contains MoveGrammar + call GetMoveGrammar ; convert move id to grammar index ; everything except 'instead' made redundant in localization @@ -51,7 +50,7 @@ UsedMoveText: ret nz ; check move grammar - ld a, [wd265] + ld a, [wMoveGrammar] cp $3 ld hl, UsedMove2Text ret c @@ -89,14 +88,14 @@ MoveNameText: ld hl, .endusedmovetexts ; get move id - ld a, [wd265] + ld a, [wMoveGrammar] ; 2-byte pointer add a ; seek push bc - ld b, $0 + ld b, 0 ld c, a add hl, bc pop bc @@ -132,13 +131,13 @@ EndUsedMove5Text: db "@" GetMoveGrammar: -; store move grammar type in wd265 +; store move grammar type in wMoveGrammar push bc -; c = move id - ld a, [wd265] - ld c, a - ld b, $0 +; wMoveGrammar contains move id + ld a, [wMoveGrammar] + ld c, a ; move id + ld b, 0 ; grammar index ; read grammar table ld hl, MoveGrammar @@ -158,9 +157,9 @@ GetMoveGrammar: jr .loop .end -; wd265 now contains move grammar +; wMoveGrammar now contains move grammar ld a, b - ld [wd265], a + ld [wMoveGrammar], a ; we're done pop bc |