diff options
Diffstat (limited to 'battle/effect_commands.asm')
-rw-r--r-- | battle/effect_commands.asm | 208 |
1 files changed, 39 insertions, 169 deletions
diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index 0425cda5d..1350300ca 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -136,7 +136,7 @@ BattleCommand_CheckTurn: ; 34084 ld [wKickCounter], a ld [AlreadyDisobeyed], a ld [AlreadyFailed], a - ld [wc73e], a + ld [wSomeoneIsRampaging], a ld a, 10 ; 1.0 ld [TypeModifier], a @@ -1928,6 +1928,7 @@ BattleCommand_CheckHit: ; 34d32 ld a, [hBattleTurn] and a + ; load the user's accuracy into b and the opponent's evasion into c. ld hl, wPlayerMoveStruct + MOVE_ACC ld a, [PlayerAccLevel] ld b, a @@ -1944,26 +1945,31 @@ BattleCommand_CheckHit: ; 34d32 .got_acc_eva cp b - jr c, .eva_less_than_acc + jr c, .skip_foresight_check + ; if the target's evasion is greater than the user's accuracy, + ; check the target's foresight status ld a, BATTLE_VARS_SUBSTATUS1_OPP call GetBattleVar bit SUBSTATUS_IDENTIFIED, a ret nz -.eva_less_than_acc +.skip_foresight_check + ; subtract evasion from 14 ld a, 14 sub c ld c, a + ; store the base move accuracy for math ops xor a ld [hMultiplicand + 0], a ld [hMultiplicand + 1], a ld a, [hl] ld [hMultiplicand + 2], a push hl - ld d, 2 + ld d, 2 ; do this twice, once for the user's accuracy and once for the target's evasion .accuracy_loop + ; look up the multiplier from the table push bc ld hl, .AccProb dec b @@ -1972,27 +1978,32 @@ BattleCommand_CheckHit: ; 34d32 ld b, 0 add hl, bc pop bc + ; multiply by the first byte in that row... ld a, [hli] ld [hMultiplier], a call Multiply + ; ... and divide by the second byte ld a, [hl] ld [hDivisor], a ld b, 4 call Divide + ; minimum accuracy is $0001 ld a, [hQuotient + 2] ld b, a ld a, [hQuotient + 1] or b jr nz, .min_accuracy ld [hQuotient + 1], a - ld a, $1 + ld a, 1 ld [hQuotient + 2], a .min_accuracy + ; do the same thing to the target's evasion ld b, c dec d jr nz, .accuracy_loop + ; if the result is more than 2 bytes, max out at 100% ld a, [hQuotient + 1] and a ld a, [hQuotient + 2] @@ -2114,10 +2125,10 @@ BattleCommand_LowerSub: ; 34eee ret .rollout_rampage - ld a, [wc73e] + ld a, [wSomeoneIsRampaging] and a ld a, 0 - ld [wc73e], a + ld [wSomeoneIsRampaging], a ret ; 34f57 @@ -2799,7 +2810,7 @@ PlayerAttackDamage: ; 352e2 call ResetDamage - ld hl, wPlayerMoveStruct + MOVE_POWER + ld hl, wPlayerMoveStructPower ld a, [hli] and a ld d, a @@ -2946,7 +2957,7 @@ GetDamageStats: ; 3537e ld a, [hBattleTurn] and a jr nz, .enemy - ld a, [wPlayerMoveStruct + MOVE_TYPE] + ld a, [wPlayerMoveStructType] cp SPECIAL ; special ld a, [PlayerSAtkLevel] @@ -2960,7 +2971,7 @@ GetDamageStats: ; 3537e jr .end .enemy - ld a, [wEnemyMoveStruct + MOVE_TYPE] + ld a, [wEnemyMoveStructType] cp SPECIAL ; special ld a, [EnemySAtkLevel] @@ -3063,8 +3074,8 @@ EnemyAttackDamage: ; 353f6 call ResetDamage ; No damage dealt with 0 power. - ld hl, wEnemyMoveStruct + MOVE_POWER - ld a, [hli] ; hl = wEnemyMoveStruct + MOVE_TYPE + ld hl, wEnemyMoveStructPower + ld a, [hli] ; hl = wEnemyMoveStructType ld d, a and a ret z @@ -3155,7 +3166,7 @@ BattleCommand_BeatUp: ; 35461 xor a ld [PlayerRolloutCount], a ld [wd002], a - ld [wc72d], a + ld [wBeatUpHitAtLeastOnce], a jr .got_mon .next_mon @@ -3188,7 +3199,7 @@ BattleCommand_BeatUp: ; 35461 jp nz, .beatup_fail ld a, $1 - ld [wc72d], a + ld [wBeatUpHitAtLeastOnce], a ld hl, BeatUpAttackText call StdBattleTextBox ld a, [EnemyMonSpecies] @@ -3211,7 +3222,7 @@ BattleCommand_BeatUp: ; 35461 ld a, [hl] ld e, a pop bc - ld a, [wPlayerMoveStruct + MOVE_POWER] + ld a, [wPlayerMoveStructPower] ld d, a ret @@ -3223,7 +3234,7 @@ BattleCommand_BeatUp: ; 35461 xor a ld [EnemyRolloutCount], a ld [wd002], a - ld [wc72d], a + ld [wBeatUpHitAtLeastOnce], a jr .enemy_continue .not_first_enemy_beatup @@ -3283,7 +3294,7 @@ BattleCommand_BeatUp: ; 35461 jr nz, .beatup_fail ld a, $1 - ld [wc72d], a + ld [wBeatUpHitAtLeastOnce], a jr .finish_beatup .wild @@ -3317,7 +3328,7 @@ BattleCommand_BeatUp: ; 35461 ld a, [hl] ld e, a pop bc - ld a, [wEnemyMoveStruct + MOVE_POWER] + ld a, [wEnemyMoveStructPower] ld d, a ret @@ -3332,7 +3343,7 @@ BattleCommand_BeatUp: ; 35461 BattleCommanda8: ; 355b5 - ld a, [wc72d] + ld a, [wBeatUpHitAtLeastOnce] and a ret nz @@ -3401,7 +3412,7 @@ endr ld l, [hl] ld h, a call TruncateHL_BC - ld d, $28 + ld d, 40 pop af ld e, a ret @@ -3806,14 +3817,14 @@ BattleCommand_ConstantDamage: ; 35726 ld a, [hl] jr nz, .notPlayersTurn - ld hl, wPlayerMoveStruct + MOVE_POWER + ld hl, wPlayerMoveStructPower ld [hl], a push hl call PlayerAttackDamage jr .notEnemysTurn .notPlayersTurn - ld hl, wEnemyMoveStruct + MOVE_POWER + ld hl, wEnemyMoveStructPower ld [hl], a push hl call EnemyAttackDamage @@ -6521,8 +6532,8 @@ BattleCommand_UnleashEnergy: ; 366e5 ld [de], a inc de ld [de], a - ld [wPlayerMoveStruct + MOVE_EFFECT], a - ld [wEnemyMoveStruct + MOVE_EFFECT], a + ld [wPlayerMoveStructEffect], a + ld [wEnemyMoveStructEffect], a call BattleRandom and 1 inc a @@ -6600,7 +6611,7 @@ BattleCommand_Rampage: ; 36751 inc a ld [de], a ld a, 1 - ld [wc73e], a + ld [wSomeoneIsRampaging], a ret ; 36778 @@ -6752,7 +6763,7 @@ BattleCommand_ForceSwitch: ; 3680f inc a ld [wForcedSwitch], a call SetBattleDraw - ld a, [wPlayerMoveStruct + MOVE_ANIM] + ld a, [wPlayerMoveStructAnimation] jp .succeed .trainer @@ -6845,7 +6856,7 @@ BattleCommand_ForceSwitch: ; 3680f inc a ld [wForcedSwitch], a call SetBattleDraw - ld a, [wEnemyMoveStruct + MOVE_ANIM] + ld a, [wEnemyMoveStructAnimation] jr .succeed .vs_trainer @@ -8393,148 +8404,7 @@ BattleCommand_Heal: ; 3713e ; 371cd - -BattleCommand_Transform: ; 371cd -; transform - - call ClearLastMove - ld a, BATTLE_VARS_SUBSTATUS5_OPP - call GetBattleVarAddr - bit SUBSTATUS_TRANSFORMED, [hl] - jp nz, BattleEffect_ButItFailed - call CheckHiddenOpponent - jp nz, BattleEffect_ButItFailed - xor a - ld [wNumHits], a - ld [FXAnimIDHi], a - ld a, $1 - ld [wKickCounter], a - ld a, BATTLE_VARS_SUBSTATUS4 - call GetBattleVarAddr - bit SUBSTATUS_SUBSTITUTE, [hl] - push af - jr z, .mimic_substitute - call CheckUserIsCharging - jr nz, .mimic_substitute - ld a, SUBSTITUTE - call LoadAnim -.mimic_substitute - ld a, BATTLE_VARS_SUBSTATUS5 - call GetBattleVarAddr - set SUBSTATUS_TRANSFORMED, [hl] - call ResetActorDisable - ld hl, BattleMonSpecies - ld de, EnemyMonSpecies - ld a, [hBattleTurn] - and a - jr nz, .got_mon_species - ld hl, EnemyMonSpecies - ld de, BattleMonSpecies - xor a - ld [CurMoveNum], a -.got_mon_species - push hl - ld a, [hli] - ld [de], a - inc hl - inc de - inc de - ld bc, NUM_MOVES - call CopyBytes - ld a, [hBattleTurn] - and a - jr z, .mimic_enemy_backup - ld a, [de] - ld [wEnemyBackupDVs], a - inc de - ld a, [de] - ld [wEnemyBackupDVs + 1], a - dec de -.mimic_enemy_backup -; copy DVs - ld a, [hli] - ld [de], a - inc de - ld a, [hli] - ld [de], a - inc de -; move pointer to stats - ld bc, BattleMonStats - BattleMonPP - add hl, bc - push hl - ld h, d - ld l, e - add hl, bc - ld d, h - ld e, l - pop hl - ld bc, BattleMonStructEnd - BattleMonStats - call CopyBytes -; init the power points - ld bc, BattleMonMoves - BattleMonStructEnd - add hl, bc - push de - ld d, h - ld e, l - pop hl - ld bc, BattleMonPP - BattleMonStructEnd - add hl, bc - ld b, NUM_MOVES -.pp_loop - ld a, [de] - inc de - and a - jr z, .done_move - cp SKETCH - ld a, 1 - jr z, .done_move - ld a, 5 -.done_move - ld [hli], a - dec b - jr nz, .pp_loop - pop hl - ld a, [hl] - ld [wNamedObjectIndexBuffer], a - call GetPokemonName - ld hl, EnemyStats - ld de, PlayerStats - ld bc, 2 * 5 - call BattleSideCopy - ld hl, EnemyStatLevels - ld de, PlayerStatLevels - ld bc, 8 - call BattleSideCopy - call _CheckBattleScene - jr c, .mimic_anims - ld a, [hBattleTurn] - and a - ld a, [wPlayerMinimized] - jr z, .got_byte - ld a, [wEnemyMinimized] -.got_byte - and a - jr nz, .mimic_anims - call LoadMoveAnim - jr .after_anim - -.mimic_anims - call BattleCommand_MoveDelay - call BattleCommand_RaiseSubNoAnim -.after_anim - xor a - ld [wNumHits], a - ld [FXAnimIDHi], a - ld a, $2 - ld [wKickCounter], a - pop af - ld a, SUBSTITUTE - call nz, LoadAnim - ld hl, TransformedText - jp StdBattleTextBox - -; 372c6 - +INCLUDE "battle/effects/transform.asm" BattleSideCopy: ; 372c6 ; Copy bc bytes from hl to de if it's the player's turn. |