From a8375aaee71e37fb1e6d39c525dbd40fd0df09bb Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 31 Mar 2015 20:16:31 +0200 Subject: Split commentary lines that are too long --- engine/battle/core.asm | 58 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 21 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/engine/battle/core.asm b/engine/battle/core.asm index e76a2720..f0f92615 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -454,7 +454,8 @@ MainInBattleLoop: ; 3c233 (f:4233) ld b, 0 add hl, bc ld a, [hl] - cp METRONOME ; a MIRROR MOVE check is missing, might lead to a desync in link battles when combined with multi-turn moves + cp METRONOME ; a MIRROR MOVE check is missing, might lead to a desync in link battles + ; when combined with multi-turn moves jr nz, .asm_3c2dd ld [wPlayerSelectedMove], a .asm_3c2dd @@ -1640,7 +1641,8 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) ld b, a ld a, [H_QUOTIENT + 3] cp b - jr nc, .canEscape ; if the random value was less than or equal to the quotient plus 30 times the number of attempts, the player can escape + jr nc, .canEscape ; if the random value was less than or equal to the quotient + ; plus 30 times the number of attempts, the player can escape ; can't escape ld a, $1 ld [wcd6a], a @@ -2046,8 +2048,10 @@ GetBattleHealthBarColor: ; 3ce90 (f:4e90) jp GoPAL_SET ; 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 (i.e. for names longer than 4 letters) -; if the name is 3 or 4 letters long, it is printed 1 space more to the right than usual (i.e. for names longer than 4 letters) +; if the name is 1 or 2 letters long, it is printed 2 spaces more to the right than usual +; (i.e. for names longer than 4 letters) +; if the name is 3 or 4 letters long, it is printed 1 space more to the right than usual +; (i.e. for names longer than 4 letters) CenterMonName: ; 3ce9c (f:4e9c) push de inc hl @@ -2204,7 +2208,8 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) ld [wcc2d], a jr z, .handleMenuSelection ; not Safari battle -; swap the IDs of the item menu and party menu (this is probably because they swapped the positions of these menu items in first generation English versions) +; swap the IDs of the item menu and party menu (this is probably because they swapped the positions +; of these menu items in first generation English versions) cp $1 ; was the item menu selected? jr nz, .notItemMenu ; item menu was selected @@ -3155,8 +3160,8 @@ CheckIfPlayerNeedsToChargeUp: ; 3d69a (f:569a) PlayerCanExecuteChargingMove: ; 3d6a9 (f:56a9) ld hl,W_PLAYERBATTSTATUS1 res ChargingUp,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack - ; being fully paralyzed or hurting oneself in confusion removes charging up status - ; resulting in the Pokemon being invulnerable for the whole battle + ; being fully paralyzed or hurting oneself in confusion removes charging up status + ; resulting in the Pokemon being invulnerable for the whole battle res Invulnerable,[hl] PlayerCanExecuteMove: ; 3d6b0 (f:56b0) call PrintMonName1Text @@ -3307,9 +3312,9 @@ MirrorMoveCheck ld de,1 call IsInArray call nc,JumpMoveEffect ; move effects not included in SpecialEffects or in either of the ResidualEffect arrays, - ; which are the effects not covered yet. Rage's effect will be executed for a second time (although it's irrelevant). - ; Includes side effects that only need to be called if the target didn't faint. - ; Responsible for executing Twineedle's second effect (poison) + ; which are the effects not covered yet. Rage effect will be executed for a second time (though it's irrelevant). + ; Includes side effects that only need to be called if the target didn't faint. + ; Responsible for executing Twineedle's second side effect (poison). jp ExecutePlayerMoveDone MultiHitText: ; 3d805 (f:5805) @@ -3602,7 +3607,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,[wPlayerNumAttacksLeft] dec a ; did multi-turn move end? ld [wPlayerNumAttacksLeft],a - ld hl,asm_3d714 ; if it didn't, skip damage calculation (deal damage equal to last hit), DecrementPP and MoveHitTest + ld hl,asm_3d714 ; if it didn't, skip damage calculation (deal damage equal to last hit), + ; DecrementPP and MoveHitTest jp nz,.returnToHL jp .returnToHL @@ -3734,7 +3740,8 @@ HandleSelfConfusionDamage: ; 3daad (f:5aad) xor a ld [hl], a call GetDamageVarsForPlayerAttack - call CalculateDamage ; ignores AdjustDamageForMoveType (type-less damage), RandomizeDamage, and MoveHitTest (always hits) + call CalculateDamage ; ignores AdjustDamageForMoveType (type-less damage), RandomizeDamage, + ; and MoveHitTest (always hits) pop af pop hl ld [hl], a @@ -3914,7 +3921,8 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) ; if you get here, the mon used jump kick or hi jump kick and missed ld hl, W_DAMAGE ; since the move missed, W_DAMAGE will always contain 0 at this point. - ; Thus, recoil damage will always be equal to 1 even if it was intended to be potential damage/8. + ; Thus, recoil damage will always be equal to 1 + ; even if it was intended to be potential damage/8. ld a, [hli] ld b, [hl] srl a @@ -4296,7 +4304,8 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) jr nz, .next inc l ; if the player's offensive stat is 0, bump it up to 1 .next - ld b, l ; b = player's offensive stat (possibly scaled) (c already contains enemy's defensive stat (possibly scaled)) + ld b, l ; b = player's offensive stat (possibly scaled) + ; (c already contains enemy's defensive stat (possibly scaled)) ld a, [wBattleMonLevel] ld e, a ; e = level ld a, [wCriticalHitOrOHKO] @@ -4408,7 +4417,8 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) jr nz, .next inc l ; if the enemy's offensive stat is 0, bump it up to 1 .next - ld b, l ; b = enemy's offensive stat (possibly scaled) (c already contains player's defensive stat (possibly scaled)) + ld b, l ; b = enemy's offensive stat (possibly scaled) + ; (c already contains player's defensive stat (possibly scaled)) ld a, [wEnemyMonLevel] ld e, a ld a, [wCriticalHitOrOHKO] @@ -5025,8 +5035,10 @@ ApplyAttackToPlayerPokemonDone AttackSubstitute: ; 3e25e (f:625e) ; Unlike the two ApplyAttackToPokemon functions, Attack Substitute is shared by player and enemy. ; Self-confusion damage as well as Hi-Jump Kick and Jump Kick recoil cause a momentary turn swap before being applied. -; If the user has a Substitute up and would take damage because of that, damage will be applied to the other player's Substitute. -; Normal recoil such as from Double-Edge isn't affected by this glitch, because this function is never called in that case. +; If the user has a Substitute up and would take damage because of that, +; damage will be applied to the other player's Substitute. +; Normal recoil such as from Double-Edge isn't affected by this glitch, +; because this function is never called in that case. ld hl,SubstituteTookDamageText call PrintText @@ -5050,7 +5062,8 @@ AttackSubstitute: ; 3e25e (f:625e) ld [de],a ret nc .substituteBroke -; If the target's Substitute breaks, W_DAMAGE isn't updated with the amount of HP the Substitute had before being attacked. +; If the target's Substitute breaks, W_DAMAGE isn't updated with the amount of HP +; the Substitute had before being attacked. ld h,b ld l,c res 4,[hl] ; unset the substitute bit @@ -5536,7 +5549,8 @@ CalcHitChance: ; 3e624 (f:6624) .next ld a,$0e sub c - ld c,a ; c = 14 - EVASIONMOD (this "reflects" the value over 7, so that an increase in the target's evasion decreases the hit chance instead of increasing the hit chance) + ld c,a ; c = 14 - EVASIONMOD (this "reflects" the value over 7, so that an increase in the target's evasion + ; decreases the hit chance instead of increasing the hit chance) ; zero the high bytes of the multiplicand xor a ld [H_MULTIPLICAND],a @@ -5545,7 +5559,8 @@ CalcHitChance: ; 3e624 (f:6624) ld [H_MULTIPLICAND + 2],a ; set multiplicand to move accuracy push hl ld d,$02 ; loop has two iterations -; loop to do the calculations, the first iteration multiplies by the accuracy ratio and the second iteration multiplies by the evasion ratio +; loop to do the calculations, the first iteration multiplies by the accuracy ratio and +; the second iteration multiplies by the evasion ratio .loop push bc ld hl, StatModifierRatios ; $76cb ; stat modifier ratios @@ -5559,7 +5574,8 @@ CalcHitChance: ; 3e624 (f:6624) ld [H_MULTIPLIER],a ; set multiplier to the numerator of the ratio call Multiply ld a,[hl] - ld [H_DIVISOR],a ; set divisor to the the denominator of the ratio (the dividend is the product of the previous multiplication) + ld [H_DIVISOR],a ; set divisor to the the denominator of the ratio + ; (the dividend is the product of the previous multiplication) ld b,$04 ; number of bytes in the dividend call Divide ld a,[H_QUOTIENT + 3] -- cgit v1.3.1-sl0p From 247b619e9abf12c6790cff72343a8cf8431b0fb9 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 31 Mar 2015 20:28:42 +0200 Subject: Some wram constants --- engine/battle/15.asm | 6 +++--- engine/battle/animations.asm | 2 +- engine/battle/b.asm | 2 +- engine/battle/core.asm | 30 +++++++++++++++--------------- engine/items/items.asm | 2 +- wram.asm | 16 +++++++++++++--- 6 files changed, 34 insertions(+), 24 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/engine/battle/15.asm b/engine/battle/15.asm index 0acf3514..9bd67654 100755 --- a/engine/battle/15.asm +++ b/engine/battle/15.asm @@ -82,7 +82,7 @@ GainExperience: ; 5524f (15:524f) call BoostExp ; traded mon exp boost ld a, $1 .next - ld [wcf4d], a + ld [wGainBoostedExp], a ld a, [W_ISINBATTLE] dec a ; is it a trainer battle? call nz, BoostExp ; if so, boost exp @@ -342,12 +342,12 @@ BoostExp: ; 5549f (15:549f) GainedText: ; 554b2 (15:54b2) TX_FAR _GainedText db $08 ; asm - ld a, [wcc5b] + ld a, [wBoostExpByExpAll] ld hl, WithExpAllText and a ret nz ld hl, ExpPointsText - ld a, [wcf4d] + ld a, [wGainBoostedExp] and a ret z ld hl, BoostedText diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index d4cebb44..17033282 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -2931,7 +2931,7 @@ TossBallAnimation: ; 79e16 (1e:5e16) Func_79e6a: ; 79e6a (1e:5e6a) call WaitForSoundToFinish - ld a, [wd05b] + ld a, [wDamageMultipliers] and $7f ret z cp $a diff --git a/engine/battle/b.asm b/engine/battle/b.asm index 32534b17..17f0bd5b 100755 --- a/engine/battle/b.asm +++ b/engine/battle/b.asm @@ -1,5 +1,5 @@ DisplayEffectiveness: ; 2fb7b (b:7b7b) - ld a, [wd05b] + ld a, [wDamageMultipliers] and a, $7F cp a, $0A ret z diff --git a/engine/battle/core.asm b/engine/battle/core.asm index f0f92615..eb4a2fcd 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -919,7 +919,7 @@ FaintEnemyPokemon ; 0x3c567 ; if exp all is in the bag, this will be only be half of the stat exp and normal exp, due to the above loop .giveExpToMonsThatFought xor a - ld [wcc5b], a + ld [wBoostExpByExpAll], a callab GainExperience pop af ret z ; return if no exp all @@ -928,7 +928,7 @@ FaintEnemyPokemon ; 0x3c567 ; now, set the gain exp flag for every party member ; half of the total stat exp and normal exp will divided evenly amongst every party member ld a, $1 - ld [wcc5b], a + ld [wBoostExpByExpAll], a ld a, [wPartyCount] ld b, 0 .gainExpFlagsLoop @@ -1811,8 +1811,8 @@ SendOutMon: ; 3cc91 (f:4c91) ld hl, wcc2d ld [hli], a ld [hl], a - ld [wcc5b], a - ld [wd05b], a + ld [wBoostExpByExpAll], a + ld [wDamageMultipliers], a ld [W_PLAYERMOVENUM], a ld hl, wPlayerUsedMove ld [hli], a @@ -3129,9 +3129,9 @@ ExecutePlayerMove: ; 3d65e (f:565e) xor a ld [W_MOVEMISSED], a ld [wcced], a - ld [wccf4], a + ld [wMoveDidntMiss], a ld a, $a - ld [wd05b], a + ld [wDamageMultipliers], a ld a, [wcd6a] and a jp nz, ExecutePlayerMoveDone @@ -3277,7 +3277,7 @@ MirrorMoveCheck call PrintCriticalOHKOText callab DisplayEffectiveness ld a,1 - ld [wccf4],a + ld [wMoveDidntMiss],a .notDone ld a,[W_PLAYERMOVEEFFECT] ld hl,AlwaysHappenSideEffects @@ -3901,7 +3901,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) ld de, W_ENEMYMOVEEFFECT .playersTurn ld hl, DoesntAffectMonText - ld a, [wd05b] + ld a, [wDamageMultipliers] and $7f jr z, .gotTextToPrint ld hl, AttackMissedText @@ -5306,7 +5306,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5) ld [W_DAMAGE],a ld a,l ld [W_DAMAGE + 1],a - ld hl,wd05b + ld hl,wDamageMultipliers set 7,[hl] .skipSameTypeAttackBonus ld a,[wd11e] @@ -5329,13 +5329,13 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5) push hl push bc inc hl - ld a,[wd05b] + ld a,[wDamageMultipliers] and a,$80 ld b,a ld a,[hl] ; a = damage multiplier ld [H_MULTIPLIER],a add b - ld [wd05b],a + ld [wDamageMultipliers],a xor a ld [H_MULTIPLICAND],a ld hl,W_DAMAGE @@ -5659,9 +5659,9 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc) inc [hl] xor a ld [W_MOVEMISSED], a - ld [wccf4], a + ld [wMoveDidntMiss], a ld a, $a - ld [wd05b], a + ld [wDamageMultipliers], a call CheckEnemyStatusConditions jr nz, .enemyHasNoSpecialConditions jp [hl] @@ -5812,7 +5812,7 @@ asm_3e7ef: ; 3e7ef (f:67ef) call PrintCriticalOHKOText callab DisplayEffectiveness ld a, 1 - ld [wccf4], a + ld [wMoveDidntMiss], a .asm_3e83e ld a, [W_ENEMYMOVEEFFECT] ld hl, AlwaysHappenSideEffects @@ -8614,7 +8614,7 @@ NoEffectText: ; 3fb49 (f:7b49) db "@" Func_3fb4e: ; 3fb4e (f:7b4e) - ld a, [wccf4] + ld a, [wMoveDidntMiss] and a ret nz diff --git a/engine/items/items.asm b/engine/items/items.asm index 605e5dde..3dc17010 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -321,7 +321,7 @@ ItemUseBall: ; d687 (3:5687) xor a ld [$fff3],a ld [wcc5b],a - ld [wd05b],a + ld [wDamageMultipliers],a ld a,[wWhichPokemon] push af ld a,[wcf91] diff --git a/wram.asm b/wram.asm index a08aae74..0a76370c 100755 --- a/wram.asm +++ b/wram.asm @@ -351,6 +351,7 @@ wNPCMovementScriptBank:: ; cc58 ds 2 wHallOfFame:: ; cc5b +wBoostExpByExpAll:: ; cc5b wcc5b:: ds 1 wcc5c:: ds 1 wcc5d:: ds 1 @@ -431,7 +432,7 @@ wccf0:: ds 1 wPlayerUsedMove:: ds 1 wEnemyUsedMove:: ds 1 wccf3:: ds 1 -wccf4:: ds 1 +wMoveDidntMiss:: ds 1 wPartyFoughtCurrentEnemyFlags:: ; flags that indicate which party members have fought the current enemy mon @@ -783,7 +784,9 @@ wcf30:: ds 7 wcf37:: ds 20 wcf4b:: ds 1 wcf4c:: ds 1 -wcf4d:: ds 18 +wGainBoostedExp:: ; cf4d + ds 1 + ds 17 wGymCityName:: ; cf5f wStringBuffer1:: ; cf5f @@ -967,7 +970,14 @@ W_BATTLETYPE:: ; d05a ; in safari battle, this is 2 ds 1 -wd05b:: ds 1 +wDamageMultipliers:: ; d05b +; bits 0-6: Effectiveness + ; $0 = immune + ; $5 = not very effective + ; $a = neutral + ; $14 = super-effective +; bit 7: STAB + ds 1 W_LONEATTACKNO:: ; d05c ; which entry in LoneAttacks to use -- cgit v1.3.1-sl0p From 4ba8dd609065ee118eccdc56a38dc8666b189c2e Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 31 Mar 2015 20:40:22 +0200 Subject: Further document AI stuff --- engine/battle/core.asm | 18 +++++++-------- engine/battle/e.asm | 62 +++++++++++++++++++++++++++----------------------- wram.asm | 8 +++++-- 3 files changed, 48 insertions(+), 40 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/engine/battle/core.asm b/engine/battle/core.asm index eb4a2fcd..0f9ee548 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -991,7 +991,7 @@ ReplaceFaintedEnemyMon: ; 3c664 (f:4664) xor a ld [W_ENEMYMOVENUM], a ld [wcd6a], a - ld [wccd5], a + ld [wAILayer2Encouragement], a inc a ; reset Z flag ret @@ -3128,7 +3128,7 @@ ExecutePlayerMove: ; 3d65e (f:565e) jp z, ExecutePlayerMoveDone ; for selected move = FF, skip most of player's turn xor a ld [W_MOVEMISSED], a - ld [wcced], a + ld [wMonIsDisobedient], a ld [wMoveDidntMiss], a ld a, $a ld [wDamageMultipliers], a @@ -3251,7 +3251,7 @@ MirrorMoveCheck call MirrorMoveCopyMove jp z,ExecutePlayerMoveDone xor a - ld [wcced],a + ld [wMonIsDisobedient],a jp CheckIfPlayerNeedsToChargeUp ; if Mirror Move was successful go back to damage calculation for copied move .metronomeCheck cp a,METRONOME_EFFECT @@ -3778,7 +3778,7 @@ MonName1Text: ; 3dafb (f:5afb) ld [hl], a ld [wd11e], a call Func_3db85 - ld a, [wcced] + ld a, [wMonIsDisobedient] and a ld hl, Used2Text ret nz @@ -3799,7 +3799,7 @@ Used2Text: ; 3db34 (f:5b34) db $08 ; asm PrintInsteadText: ; 3db39 (f:5b39) - ld a, [wcced] + ld a, [wMonIsDisobedient] and a jr z, PrintCF4BText ld hl, InsteadText @@ -4007,7 +4007,7 @@ OHKOText: ; 3dc83 (f:5c83) ; stores whether the mon will use a move in Z flag CheckForDisobedience: ; 3dc88 (f:5c88) xor a - ld [wcced], a + ld [wMonIsDisobedient], a ld a, [wLinkState] cp LINK_STATE_BATTLING jr nz, .checkIfMonIsTraded @@ -4148,7 +4148,7 @@ CheckForDisobedience: ; 3dc88 (f:5c88) cp b jr z, .monDoesNothing ; mon will not use move if only one move has remaining PP ld a, $1 - ld [wcced], a + ld [wMonIsDisobedient], a ld a, [wMaxMenuItem] ld b, a ld a, [wCurrentMenuItem] @@ -5655,7 +5655,7 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc) cp $4 ret nc .executeEnemyMove - ld hl, wccd5 + ld hl, wAILayer2Encouragement inc [hl] xor a ld [W_MOVEMISSED], a @@ -5693,7 +5693,7 @@ EnemyCanExecuteChargingMove: ; 3e70b (f:670b) call CopyStringToCF4B EnemyCanExecuteMove: ; 3e72b (f:672b) xor a - ld [wcced], a + ld [wMonIsDisobedient], a call PrintMonName1Text ld a, [W_ENEMYMOVEEFFECT] ld hl, ResidualEffects1 diff --git a/engine/battle/e.asm b/engine/battle/e.asm index d124b77a..feb52df1 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -227,17 +227,17 @@ AIMoveChoiceModificationFunctionPointers: ; 397a3 (e:57a3) AIMoveChoiceModification1: ; 397ab (e:57ab) ld a, [wBattleMonStatus] and a - ret z ; return if no status ailment on player's mon - ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) - ld de, wEnemyMonMoves ; enemy moves - ld b, $5 + ret z ; return if no status ailment on player's mon + ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) + ld de, wEnemyMonMoves ; enemy moves + ld b, NUM_MOVES + 1 .nextMove dec b - ret z ; processed all 4 moves + ret z ; processed all 4 moves inc hl ld a, [de] and a - ret z ; no more moves in move set + ret z ; no more moves in move set inc de call ReadMove ld a, [W_ENEMYMOVEPOWER] @@ -255,32 +255,34 @@ AIMoveChoiceModification1: ; 397ab (e:57ab) pop hl jr nc, .nextMove ld a, [hl] - add $5 ; discourage move + add $5 ; heavily discourage move ld [hl], a jr .nextMove StatusAilmentMoveEffects ; 57e2 - db $01 ; some sleep effect? + db $01 ; unused sleep effect db SLEEP_EFFECT db POISON_EFFECT db PARALYZE_EFFECT db $FF -; slightly encourage moves with specific effects +; slightly encourage moves with specific effects. +; in particular, stat-modifying moves and other move effects +; that fall in-bewteen AIMoveChoiceModification2: ; 397e7 (e:57e7) - ld a, [wccd5] - cp $1 + ld a, [wAILayer2Encouragement] + cp $1 ret nz - ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) - ld de, wEnemyMonMoves ; enemy moves - ld b, $5 + ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) + ld de, wEnemyMonMoves ; enemy moves + ld b, NUM_MOVES + 1 .nextMove dec b - ret z ; processed all 4 moves + ret z ; processed all 4 moves inc hl ld a, [de] and a - ret z ; no more moves in move set + ret z ; no more moves in move set inc de call ReadMove ld a, [W_ENEMYMOVEEFFECT] @@ -294,21 +296,23 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7) jr c, .preferMove jr .nextMove .preferMove - dec [hl] ; slighly encourage this move + dec [hl] ; sligthly encourage this move jr .nextMove -; encourages moves that are effective against the player's mon +; encourages moves that are effective against the player's mon (even if non-damaging). +; discourage damaging moves that are ineffective or not very effective against the player's mon, +; unless there's no damaging move that deals at least neutral damage AIMoveChoiceModification3: ; 39817 (e:5817) - ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) - ld de, wEnemyMonMoves ; enemy moves + ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) + ld de, wEnemyMonMoves ; enemy moves ld b, $5 .nextMove dec b - ret z ; processed all 4 moves + ret z ; processed all 4 moves inc hl ld a, [de] and a - ret z ; no more moves in move set + ret z ; no more moves in move set inc de call ReadMove push hl @@ -322,9 +326,9 @@ AIMoveChoiceModification3: ; 39817 (e:5817) cp $10 jr z, .nextMove jr c, .notEffectiveMove - dec [hl] ; slighly encourage this move + dec [hl] ; sligthly encourage this move jr .nextMove -.notEffectiveMove ; discourages non-effective moves if better moves are available +.notEffectiveMove ; discourages non-effective moves if better moves are available push hl push de push bc @@ -342,17 +346,17 @@ AIMoveChoiceModification3: ; 39817 (e:5817) call ReadMove ld a, [W_ENEMYMOVEEFFECT] cp SUPER_FANG_EFFECT - jr z, .betterMoveFound ; Super Fang is considered to be a better move + jr z, .betterMoveFound ; Super Fang is considered to be a better move cp SPECIAL_DAMAGE_EFFECT - jr z, .betterMoveFound ; any special damage moves are considered to be better moves + jr z, .betterMoveFound ; any special damage moves are considered to be better moves cp FLY_EFFECT - jr z, .betterMoveFound ; Fly is considered to be a better move + jr z, .betterMoveFound ; Fly is considered to be a better move ld a, [W_ENEMYMOVETYPE] cp d jr z, .loopMoves ld a, [W_ENEMYMOVEPOWER] and a - jr nz, .betterMoveFound ; damaging moves of a different type are considered to be better moves + jr nz, .betterMoveFound ; damaging moves of a different type are considered to be better moves jr .loopMoves .betterMoveFound ld c, a @@ -363,7 +367,7 @@ AIMoveChoiceModification3: ; 39817 (e:5817) pop hl and a jr z, .nextMove - inc [hl] ; slighly discourage this move + inc [hl] ; sligthly discourage this move jr .nextMove AIMoveChoiceModification4: ; 39883 (e:5883) ret diff --git a/wram.asm b/wram.asm index 0a76370c..898b5386 100755 --- a/wram.asm +++ b/wram.asm @@ -378,7 +378,11 @@ wSimulatedJoypadStatesEnd:: ; ccd3 wccd3:: ds 1 wccd4:: ds 1 -wccd5:: ds 2 + +; if [ccd5] != 1, the second AI layer is not applied +wAILayer2Encouragement:: ; ccd5 + ds 1 + ds 1 ; current HP of player and enemy substitutes wPlayerSubstituteHP:: ; ccd7 @@ -425,7 +429,7 @@ wSafariBaitFactor:: ; cce9 wcceb:: ds 1 wccec:: ds 1 -wcced:: ds 1 +wMonIsDisobedient:: ds 1 wccee:: ds 1 wccef:: ds 1 wccf0:: ds 1 -- cgit v1.3.1-sl0p From c73b5d73f477da2c0a916e683562e0941c5ff1eb Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 31 Mar 2015 20:50:49 +0200 Subject: Label some battle related functions --- engine/battle/core.asm | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 0f9ee548..087b0679 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -875,7 +875,7 @@ FaintEnemyPokemon ; 0x3c567 call WaitForSoundToFinish jr .sfxplayed .wild_win - call Func_3c643 + call EndLowHealthAlarm ld a, MUSIC_DEFEATED_WILD_MON call PlayBattleVictoryMusic .sfxplayed @@ -946,7 +946,7 @@ EnemyMonFaintedText: ; 0x3c63e TX_FAR _EnemyMonFaintedText db "@" -Func_3c643: ; 3c643 (f:4643) +EndLowHealthAlarm: ; 3c643 (f:4643) xor a ld [wLowHealthAlarm], a ;disable low health alarm ld [wc02a], a @@ -996,7 +996,7 @@ ReplaceFaintedEnemyMon: ; 3c664 (f:4664) ret TrainerBattleVictory: ; 3c696 (f:4696) - call Func_3c643 + call EndLowHealthAlarm ld b, MUSIC_DEFEATED_GYM_LEADER ld a, [W_GYMLEADERNO] and a @@ -3188,7 +3188,7 @@ PlayerCalcMoveDamage: ; 3d6dc (f:56dc) jp c,.moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation call CriticalHitTest call HandleCounterMove - jr z,asm_3d705 + jr z,handleIfMoveMissed call GetDamageVarsForPlayerAttack call CalculateDamage jp z,asm_3d74b ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest @@ -3197,7 +3197,7 @@ PlayerCalcMoveDamage: ; 3d6dc (f:56dc) call RandomizeDamage .moveHitTest call MoveHitTest -asm_3d705 +handleIfMoveMissed ld a,[W_MOVEMISSED] and a jr z,asm_3d714 @@ -3573,7 +3573,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld [hl],a ld a,BIDE ld [W_PLAYERMOVENUM],a - ld hl,asm_3d705 ; skip damage calculation, DecrementPP and MoveHitTest + ld hl,handleIfMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest jp .returnToHL .ThrashingAboutCheck @@ -4481,7 +4481,7 @@ CalculateDamage: ; 3df65 (f:5f65) ; d: base power ; e: level - ld a, [$fff3] ; whose turn? + ld a, [H_WHOSETURN] ; whose turn? and a ld a, [W_PLAYERMOVEEFFECT] jr z, .effect @@ -4504,7 +4504,7 @@ CalculateDamage: ; 3df65 (f:5f65) ; Calculate OHKO damage based on remaining HP. cp a, OHKO_EFFECT - jp z, Func_3e016 + jp z, JumpToOHKOMoveEffect ; Don't calculate damage for moves that don't do any. ld a, d ; base power @@ -4636,7 +4636,7 @@ CalculateDamage: ; 3df65 (f:5f65) and a ret -Func_3e016: ; 3e016 (f:6016) +JumpToOHKOMoveEffect: ; 3e016 (f:6016) call JumpMoveEffect ld a, [W_MOVEMISSED] dec a @@ -5066,7 +5066,7 @@ AttackSubstitute: ; 3e25e (f:625e) ; the Substitute had before being attacked. ld h,b ld l,c - res 4,[hl] ; unset the substitute bit + res HasSubstituteUp,[hl] ; unset the substitute bit ld hl,SubstituteBrokeText call PrintText ; flip whose turn it is for the next function call @@ -7096,14 +7096,14 @@ JumpMoveEffect: ; 3f132 (f:7132) ret _JumpMoveEffect: ; 3f138 (f:7138) - ld a, [$fff3] ;whose turn? + ld a, [H_WHOSETURN] and a ld a, [W_PLAYERMOVEEFFECT] jr z, .next1 ld a, [W_ENEMYMOVEEFFECT] .next1 - dec a ;subtract 1, there is no special effect for 00 - add a ;x2, 16bit pointers + dec a ; subtract 1, there is no special effect for 00 + add a ; x2, 16bit pointers ld hl, MoveEffectPointerTable ld b, 0 ld c, a @@ -7111,7 +7111,7 @@ _JumpMoveEffect: ; 3f138 (f:7138) ld a, [hli] ld h, [hl] ld l, a - jp [hl] ;jump to special effect handler + jp [hl] ; jump to special effect handler MoveEffectPointerTable: ; 3f150 (f:7150) dw SleepEffect ; unused effect @@ -7376,7 +7376,7 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) ld [wcc5b], a call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag] ret nz ; return if they have a substitute, can't effect them - ld a, [$fff3] + ld a, [H_WHOSETURN] and a jp nz, opponentAttacker ld a, [wEnemyMonStatus] @@ -7488,7 +7488,7 @@ CheckDefrost: ; 3f3e2 (f:73e2) ; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target and a, 1 << FRZ ; are they frozen? ret z ; return if so - ld a, [$fff3] + ld a, [H_WHOSETURN] and a jr nz, .opponent ;player [attacker] @@ -7885,7 +7885,7 @@ MoveMissed: ; 3f65a (f:765a) ld a, [de] cp $44 ret nc - jp Func_3fb4e + jp ConditionalPrintButItFailed MonsStatsFellText: ; 3f661 (f:7661) TX_FAR _MonsStatsFellText @@ -8084,7 +8084,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) ld a, [W_ENEMYMOVENUM] cp TELEPORT jp nz, PrintText - jp Func_3fb4e + jp ConditionalPrintButItFailed .asm_3f7e4 push af call PlayBattleAnimation @@ -8358,7 +8358,7 @@ ConfusionEffectFailed: ; 3f9a6 (f:79a6) ret z ld c, $32 call DelayFrames - jp Func_3fb4e + jp ConditionalPrintButItFailed ParalyzeEffect: ; 3f9b1 (f:79b1) ld hl, ParalyzeEffect_ @@ -8613,10 +8613,10 @@ NoEffectText: ; 3fb49 (f:7b49) TX_FAR _NoEffectText db "@" -Func_3fb4e: ; 3fb4e (f:7b4e) +ConditionalPrintButItFailed: ; 3fb4e (f:7b4e) ld a, [wMoveDidntMiss] and a - ret nz + ret nz ; return if the side effect failed, yet the attack was successful PrintButItFailedText_: ; 3fb53 (f:7b53) ld hl, ButItFailedText -- cgit v1.3.1-sl0p From e6185ac358b2e548536485781d6ec584c0b7742d Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 31 Mar 2015 21:09:43 +0200 Subject: Label some attack animation functions --- engine/battle/animations.asm | 14 +++++---- engine/battle/core.asm | 73 ++++++++++++++++++++++---------------------- engine/items/items.asm | 2 +- wram.asm | 3 ++ 4 files changed, 49 insertions(+), 43 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 17033282..1ed3a725 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -446,7 +446,7 @@ ShareMoveAnimations: ; 78da6 (1e:4da6) ret Func_78dbd: ; 78dbd (1e:4dbd) - ld a,[wcc5b] + ld a,[wAnimationType] and a ret z dec a @@ -469,12 +469,12 @@ PointerTable_78dcf: ; 78dcf (1e:4dcf) dw Func_78dfe Func_78ddb: ; 78ddb (1e:4ddb) - call Func_79e6a + call PlayApplyingAttackSound ld b, $8 jp Func_79209 Func_78de3: ; 78de3 (1e:4de3) - call Func_79e6a + call PlayApplyingAttackSound ld b, $8 jp Func_79210 @@ -483,11 +483,11 @@ Func_78deb: ; 78deb (1e:4deb) jr Func_78e01 Func_78df0: ; 78df0 (1e:4df0) - call Func_79e6a + call PlayApplyingAttackSound jp AnimationBlinkEnemyMon Func_78df6: ; 78df6 (1e:4df6) - call Func_79e6a + call PlayApplyingAttackSound ld b, $2 jp Func_79210 @@ -2929,7 +2929,9 @@ TossBallAnimation: ; 79e16 (1e:5e16) ld [W_ANIMATIONID],a jp PlayAnimation -Func_79e6a: ; 79e6a (1e:5e6a) +PlayApplyingAttackSound: ; 79e6a (1e:5e6a) +; play a different sound depending if move is not very effective, neutral, or super-effective +; don't play any sound at all if move is ineffective call WaitForSoundToFinish ld a, [wDamageMultipliers] and $7f diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 087b0679..678ade24 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -582,7 +582,7 @@ HandlePoisonBurnLeechSeed: ; 3c3bd (f:43bd) .poisoned call PrintText xor a - ld [wcc5b], a + ld [wAnimationType], a ld a,BURN_PSN_ANIM call PlayMoveAnimation ; play burn/poison animation pop hl @@ -603,7 +603,7 @@ HandlePoisonBurnLeechSeed: ; 3c3bd (f:43bd) xor $1 ld [H_WHOSETURN], a xor a - ld [wcc5b], a + ld [wAnimationType], a ld a,ABSORB call PlayMoveAnimation ; play leech seed animation (from opposing mon) pop af @@ -3219,7 +3219,7 @@ asm_3d71e ld b,BANK(Func_79747) call nz,Bankswitch pop af - ld [wcc5b],a + ld [wAnimationType],a ld a,[W_PLAYERMOVENUM] call PlayMoveAnimation call HandleExplodingAnimation @@ -3241,7 +3241,7 @@ asm_3d74b jr MirrorMoveCheck .playAnim xor a - ld [wcc5b],a + ld [wAnimationType],a ld a,STATUS_AFFECTED_ANIM call PlayMoveAnimation MirrorMoveCheck @@ -3386,7 +3386,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jr z,.WakeUp ; if the number of turns hit 0, wake up ; fast asleep xor a - ld [wcc5b],a + ld [wAnimationType],a ld a,SLP_ANIM - 1 call PlayMoveAnimation ld hl,FastAsleepText @@ -3470,7 +3470,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld hl,IsConfusedText call PrintText xor a - ld [wcc5b],a + ld [wAnimationType],a ld a,CONF_ANIM - 1 call PlayMoveAnimation call BattleRandom @@ -3519,7 +3519,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .FlyOrChargeEffect xor a - ld [wcc5b],a + ld [wAnimationType],a ld a,STATUS_AFFECTED_ANIM call PlayMoveAnimation .NotFlyOrChargeEffect @@ -3751,7 +3751,7 @@ HandleSelfConfusionDamage: ; 3daad (f:5aad) pop af ld [hl], a xor a - ld [wcc5b], a + ld [wAnimationType], a inc a ld [H_WHOSETURN], a call PlayMoveAnimation @@ -5198,7 +5198,7 @@ ReloadMoveData: ; 3e329 (f:6329) ; function that picks a random move for metronome MetronomePickMove: ; 3e348 (f:6348) xor a - ld [wcc5b],a + ld [wAnimationType],a ld a,METRONOME call PlayMoveAnimation ; play Metronome's animation ; values for player turn @@ -5754,7 +5754,7 @@ asm_3e7a4: ; 3e7a4 (f:67a4) ld b, BANK(Func_79747) call nz, Bankswitch pop af - ld [wcc5b], a + ld [wAnimationType], a ld a, [W_ENEMYMOVENUM] call PlayMoveAnimation call HandleExplodingAnimation @@ -5778,7 +5778,7 @@ Func_3e7d1: ; 3e7d1 (f:67d1) jr asm_3e7ef .asm_3e7e6 xor a - ld [wcc5b], a + ld [wAnimationType], a ld a,STATUS_AFFECTED_ANIM call PlayMoveAnimation asm_3e7ef: ; 3e7ef (f:67ef) @@ -5870,7 +5870,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld hl, FastAsleepText call PrintText xor a - ld [wcc5b], a + ld [wAnimationType], a ld a,SLP_ANIM call PlayMoveAnimation jr .next1 @@ -5946,7 +5946,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld hl, IsConfusedText call PrintText xor a - ld [wcc5b], a + ld [wAnimationType], a ld a,CONF_ANIM call PlayMoveAnimation call BattleRandom @@ -5989,7 +5989,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) pop af ld [hl], a xor a - ld [wcc5b], a + ld [wAnimationType], a ld [H_WHOSETURN], a ld a, POUND call PlayMoveAnimation @@ -6030,7 +6030,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jr .notFlyOrChargeEffect .flyOrChargeEffect xor a - ld [wcc5b], a + ld [wAnimationType], a ld a, STATUS_AFFECTED_ANIM call PlayMoveAnimation .notFlyOrChargeEffect @@ -6803,7 +6803,7 @@ HandleExplodingAnimation: ; 3eed3 (f:6ed3) and a ret nz ld a, 5 - ld [wcc5b], a + ld [wAnimationType], a PlayMoveAnimation: ; 3ef07 (f:6f07) ld [W_ANIMATIONID],a @@ -7239,7 +7239,7 @@ SleepEffect: ; 3f1fc (f:71fc) and $7 jr z, .setSleepCounter ld [de], a - call Func_3fb89 + call StoreCurrentMoveAnimationIDAndType ld hl, FellAsleepText jp PrintText .didntAffect @@ -7325,10 +7325,10 @@ PoisonEffect: ; 3f24f (f:724f) cp POISON_EFFECT jr z, .asm_3f2cd ld a, b - call Func_3fb96 + call StoreAnimationIDAndType jp PrintText .asm_3f2cd - call Func_3fb89 + call StoreCurrentMoveAnimationIDAndType jp PrintText .noEffect ld a, [de] @@ -7373,7 +7373,7 @@ ExplodeEffect: ; 3f2f1 (f:72f1) FreezeBurnParalyzeEffect: ; 3f30c (f:730c) xor a - ld [wcc5b], a + ld [wAnimationType], a call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag] ret nz ; return if they have a substitute, can't effect them ld a, [H_WHOSETURN] @@ -7854,7 +7854,7 @@ UpdateLoweredStatDone: ; 3f62c (f:762c) ld a, [de] cp $44 jr nc, .ApplyBadgeBoostsAndStatusPenalties - call Func_3fb89 + call StoreCurrentMoveAnimationIDAndType .ApplyBadgeBoostsAndStatusPenalties ld a, [H_WHOSETURN] and a @@ -7977,7 +7977,7 @@ BideEffect: ; 3f6e5 (f:76e5) ld [bc], a ; set Bide counter to 2 or 3 at random ld a, [H_WHOSETURN] add XSTATITEM_ANIM - jp Func_3fb96 + jp StoreAnimationIDAndType ThrashPetalDanceEffect: ; 3f717 (f:7717) ld hl, W_PLAYERBATTSTATUS1 @@ -7996,7 +7996,7 @@ ThrashPetalDanceEffect: ; 3f717 (f:7717) ld [de], a ; set thrash/petal dance counter to 2 or 3 at random ld a, [H_WHOSETURN] add ANIM_B0 - jp Func_3fb96 + jp StoreAnimationIDAndType SwitchAndTeleportEffect: ; 3f739 (f:7739) ld a, [H_WHOSETURN] @@ -8030,7 +8030,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) .asm_3f76e call ReadPlayerMonCurHPAndStatus xor a - ld [wcc5b], a + ld [wAnimationType], a inc a ld [wEscapedFromBattle], a ld a, [W_PLAYERMOVENUM] @@ -8072,7 +8072,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) .asm_3f7c1 call ReadPlayerMonCurHPAndStatus xor a - ld [wcc5b], a + ld [wAnimationType], a inc a ld [wEscapedFromBattle], a ld a, [W_ENEMYMOVENUM] @@ -8213,7 +8213,7 @@ ChargeEffect: ; 3f88c (f:788c) ld b, ANIM_C0 .notDigOrFly xor a - ld [wcc5b], a + ld [wAnimationType], a ld a, b call PlayBattleAnimation ld a, [de] @@ -8345,7 +8345,7 @@ ConfusionSideEffectSuccess: ; 3f96f (f:796f) ld [bc], a ; confusion status will last 2-5 turns pop af cp CONFUSION_SIDE_EFFECT - call nz, Func_3fb89 + call nz, StoreCurrentMoveAnimationIDAndType ld hl, BecameConfusedText jp PrintText @@ -8550,7 +8550,7 @@ DisableEffect: ; 3fa8a (f:7a8a) swap c add c ld [de], a - call Func_3fb89 + call StoreCurrentMoveAnimationIDAndType ld hl, wccee ld a, [H_WHOSETURN] and a @@ -8658,7 +8658,8 @@ CheckTargetSubstitute: ; 3fb79 (f:7b79) pop hl ret -Func_3fb89: ; 3fb89 (f:7b89) +StoreCurrentMoveAnimationIDAndType: ; 3fb89 (f:7b89) +; animation at MOVENUM will be played unless MOVENUM is 0 ld a, [H_WHOSETURN] and a ld a, [W_PLAYERMOVENUM] @@ -8668,20 +8669,20 @@ Func_3fb89: ; 3fb89 (f:7b89) and a ret z -Func_3fb96: ; 3fb96 (f:7b96) +StoreAnimationIDAndType: ; 3fb96 (f:7b96) ld [W_ANIMATIONID], a ld a, [H_WHOSETURN] and a ld a, $6 - jr z, .asm_3fba2 + jr z, .storeAnimationType ld a, $3 -.asm_3fba2 - ld [wcc5b], a - jp Func_3fbbc +.storeAnimationType + ld [wAnimationType], a + jp PlayBattleAnimationGotID PlayCurrentMoveAnimation: ; 3fba8 (f:7ba8) xor a - ld [wcc5b], a + ld [wAnimationType], a ld a, [H_WHOSETURN] and a ld a, [W_PLAYERMOVENUM] @@ -8694,7 +8695,7 @@ PlayCurrentMoveAnimation: ; 3fba8 (f:7ba8) PlayBattleAnimation: ; 3fbb9 (f:7bb9) ld [W_ANIMATIONID], a -Func_3fbbc: ; 3fbbc (f:7bbc) +PlayBattleAnimationGotID: ; 3fbbc (f:7bbc) push hl push de push bc diff --git a/engine/items/items.asm b/engine/items/items.asm index 3dc17010..21e6e924 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -320,7 +320,7 @@ ItemUseBall: ; d687 (3:5687) ld [W_ANIMATIONID],a xor a ld [$fff3],a - ld [wcc5b],a + ld [wAnimationType],a ld [wDamageMultipliers],a ld a,[wWhichPokemon] push af diff --git a/wram.asm b/wram.asm index 898b5386..ee7d2afe 100755 --- a/wram.asm +++ b/wram.asm @@ -352,6 +352,9 @@ wNPCMovementScriptBank:: ; cc58 wHallOfFame:: ; cc5b wBoostExpByExpAll:: ; cc5b +wAnimationType:: ; cc5b +; values between 0-6. Shake screen horizontally, shake screen vertically, blink Pokemon... + wcc5b:: ds 1 wcc5c:: ds 1 wcc5d:: ds 1 -- cgit v1.3.1-sl0p From 4e2084b0f167a9e5c8d0cde93cc81833fec9056c Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 31 Mar 2015 22:22:12 +0200 Subject: Name more in-battle functions and labels and better document some animation related functions --- engine/battle/core.asm | 115 ++++++++++++++++++++++++++----------------------- engine/battle/e.asm | 4 +- 2 files changed, 64 insertions(+), 55 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 678ade24..bad8f831 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -3188,30 +3188,30 @@ PlayerCalcMoveDamage: ; 3d6dc (f:56dc) jp c,.moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation call CriticalHitTest call HandleCounterMove - jr z,handleIfMoveMissed + jr z,handleIfPlayerMoveMissed call GetDamageVarsForPlayerAttack call CalculateDamage - jp z,asm_3d74b ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest + jp z,playerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest ; for these moves, accuracy tests will only occur if they are called as part of the effect itself call AdjustDamageForMoveType call RandomizeDamage .moveHitTest call MoveHitTest -handleIfMoveMissed +handleIfPlayerMoveMissed ld a,[W_MOVEMISSED] and a - jr z,asm_3d714 + jr z,getPlayerAnimationType ld a,[W_PLAYERMOVEEFFECT] sub a,EXPLODE_EFFECT - jr z,asm_3d71e ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT - jr asm_3d74b -asm_3d714 + jr z,playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT + jr playerCheckIfFlyOrChargeEffect +getPlayerAnimationType ld a,[W_PLAYERMOVEEFFECT] and a - ld a,4 - jr z,asm_3d71e - ld a,5 -asm_3d71e + ld a,4 ; move has no effect other than dealing damage + jr z,playPlayerMoveAnimation + ld a,5 ; move has effect +playPlayerMoveAnimation push af ld a,[W_PLAYERBATTSTATUS2] bit 4,a @@ -3230,7 +3230,7 @@ asm_3d71e ld b,BANK(Func_79771) call nz,Bankswitch jr MirrorMoveCheck -asm_3d74b +playerCheckIfFlyOrChargeEffect ld c,$1E call DelayFrames ld a,[W_PLAYERMOVEEFFECT] @@ -3297,8 +3297,8 @@ MirrorMoveCheck ld a,[wPlayerNumAttacksLeft] dec a ld [wPlayerNumAttacksLeft],a - jp nz,asm_3d714 ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. - ; damage calculation and accuracy tests only happen for the first hit + jp nz,getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. + ; damage calculation and accuracy tests only happen for the first hit res AttackingMultipleTimes,[hl] ; clear attacking multiple times status when all attacks are over ld hl,MultiHitText call PrintText @@ -3573,7 +3573,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld [hl],a ld a,BIDE ld [W_PLAYERMOVENUM],a - ld hl,handleIfMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest + ld hl,handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest jp .returnToHL .ThrashingAboutCheck @@ -3607,7 +3607,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,[wPlayerNumAttacksLeft] dec a ; did multi-turn move end? ld [wPlayerNumAttacksLeft],a - ld hl,asm_3d714 ; if it didn't, skip damage calculation (deal damage equal to last hit), + ld hl,getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit), ; DecrementPP and MoveHitTest jp nz,.returnToHL jp .returnToHL @@ -3783,7 +3783,7 @@ MonName1Text: ; 3dafb (f:5afb) ld hl, Used2Text ret nz ld a, [wd11e] - cp DOUBLESLAP + cp 3 ld hl, Used2Text ret c ld hl, Used1Text @@ -3922,7 +3922,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) ; if you get here, the mon used jump kick or hi jump kick and missed ld hl, W_DAMAGE ; since the move missed, W_DAMAGE will always contain 0 at this point. ; Thus, recoil damage will always be equal to 1 - ; even if it was intended to be potential damage/8. + ; even if it was intended to be potential damage/8. ld a, [hli] ld b, [hl] srl a @@ -5639,6 +5639,7 @@ RandomizeDamage: ; 3e687 (f:6687) ld [hl], a ret +; for more detailed commentary, see equivalent function for player side (ExecutePlayerMove) ExecuteEnemyMove: ; 3e6bc (f:66bc) ld a, [wEnemySelectedMove] inc a @@ -5711,42 +5712,42 @@ EnemyCalcMoveDamage: ; 3e750 (f:6750) ld hl, SetDamageEffects ld de, $1 call IsInArray - jp c, Func_3e77f + jp c, EnemyMoveHitTest call CriticalHitTest call HandleCounterMove - jr z, asm_3e782 + jr z, handleIfEnemyMoveMissed call SwapPlayerAndEnemyLevels call GetDamageVarsForEnemyAttack call SwapPlayerAndEnemyLevels call CalculateDamage - jp z, Func_3e7d1 + jp z, EnemyCheckIfFlyOrChargeEffect call AdjustDamageForMoveType call RandomizeDamage -Func_3e77f: ; 3e77f (f:677f) +EnemyMoveHitTest: ; 3e77f (f:677f) call MoveHitTest -asm_3e782: ; 3e782 (f:6782) +handleIfEnemyMoveMissed: ; 3e782 (f:6782) ld a, [W_MOVEMISSED] and a jr z, .asm_3e791 ld a, [W_ENEMYMOVEEFFECT] cp EXPLODE_EFFECT jr z, asm_3e7a0 - jr Func_3e7d1 + jr EnemyCheckIfFlyOrChargeEffect .asm_3e791 call SwapPlayerAndEnemyLevels -Func_3e794: ; 3e794 (f:6794) +GetEnemyAnimationType: ; 3e794 (f:6794) ld a, [W_ENEMYMOVEEFFECT] and a ld a, $1 - jr z, asm_3e7a4 + jr z, playEnemyMoveAnimation ld a, $2 - jr asm_3e7a4 + jr playEnemyMoveAnimation asm_3e7a0: ; 3e7a0 (f:67a0) call SwapPlayerAndEnemyLevels xor a -asm_3e7a4: ; 3e7a4 (f:67a4) +playEnemyMoveAnimation: ; 3e7a4 (f:67a4) push af ld a, [W_ENEMYBATTSTATUS2] bit HasSubstituteUp, a ; does mon have a substitute? @@ -5764,24 +5765,24 @@ asm_3e7a4: ; 3e7a4 (f:67a4) ld hl, Func_79771 ld b, BANK(Func_79771) call nz, Bankswitch ; slide the substitute's sprite out - jr asm_3e7ef + jr EnemyCheckIfMirrorMoveEffect -Func_3e7d1: ; 3e7d1 (f:67d1) +EnemyCheckIfFlyOrChargeEffect: ; 3e7d1 (f:67d1) call SwapPlayerAndEnemyLevels ld c, $1e call DelayFrames ld a, [W_ENEMYMOVEEFFECT] cp FLY_EFFECT - jr z, .asm_3e7e6 + jr z, .playAnim cp CHARGE_EFFECT - jr z, .asm_3e7e6 - jr asm_3e7ef -.asm_3e7e6 + jr z, .playAnim + jr EnemyCheckIfMirrorMoveEffect +.playAnim xor a ld [wAnimationType], a ld a,STATUS_AFFECTED_ANIM call PlayMoveAnimation -asm_3e7ef: ; 3e7ef (f:67ef) +EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef) ld a, [W_ENEMYMOVEEFFECT] cp MIRROR_MOVE_EFFECT jr nz, .notMirrorMoveEffect @@ -5832,7 +5833,7 @@ asm_3e7ef: ; 3e7ef (f:67ef) ld hl, wEnemyNumAttacksLeft dec [hl] pop hl - jp nz, Func_3e794 + jp nz, GetEnemyAnimationType res AttackingMultipleTimes, [hl] ; mon is no longer hitting multiple times ld hl, HitXTimesText call PrintText @@ -6084,7 +6085,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld a, BIDE ld [W_ENEMYMOVENUM], a call SwapPlayerAndEnemyLevels - ld hl, asm_3e782 + ld hl, handleIfEnemyMoveMissed jp .enemyReturnToHL .checkIfThrashingAbout bit ThrashingAbout, [hl] ; is mon using thrash or petal dance? @@ -6115,7 +6116,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) call PrintText ld hl, wEnemyNumAttacksLeft dec [hl] - ld hl, Func_3e794 + ld hl, GetEnemyAnimationType jp nz, .enemyReturnToHL jp .enemyReturnToHL .checkIfUsingRage @@ -6971,6 +6972,7 @@ _LoadTrainerPic: ; 3f04b (f:704b) ld c, a jp LoadUncompressedSpriteData +; unreferenced Func_3f069: ; 3f069 (f:7069) xor a ld [wc0f1], a @@ -7046,6 +7048,7 @@ asm_3f0d0: ; 3f0d0 (f:70d0) dec b jr nz, .asm_3f0de ret + .asm_3f0ed push bc ld b, $0 @@ -7069,7 +7072,7 @@ asm_3f0d0: ; 3f0d0 (f:70d0) jr nz, .asm_3f0f4 ret -LoadMonBackPic: +LoadMonBackPic: ; 3f103 (f:7103) ; Assumes the monster's attributes have ; been loaded with GetMonHeader. ld a, [wBattleMonSpecies2] @@ -7239,7 +7242,7 @@ SleepEffect: ; 3f1fc (f:71fc) and $7 jr z, .setSleepCounter ld [de], a - call StoreCurrentMoveAnimationIDAndType + call PlayCurrentMoveAnimation2 ld hl, FellAsleepText jp PrintText .didntAffect @@ -7325,10 +7328,10 @@ PoisonEffect: ; 3f24f (f:724f) cp POISON_EFFECT jr z, .asm_3f2cd ld a, b - call StoreAnimationIDAndType + call PlayBattleAnimation2 jp PrintText .asm_3f2cd - call StoreCurrentMoveAnimationIDAndType + call PlayCurrentMoveAnimation2 jp PrintText .noEffect ld a, [de] @@ -7584,7 +7587,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) jr nz, .recalculateStat ld a, [hl] sbc 999 / $100 - jp z, Func_3f520 + jp z, RestoreOriginalStatModifier .recalculateStat ; recalculate affected stat ; paralysis and burn penalties, as well as badge boosts are ignored push hl @@ -7677,7 +7680,7 @@ UpdateStatDone: ; 3f4ca (f:74ca) call QuarterSpeedDueToParalysis ; apply speed penalty to the player whose turn is not, if it's paralyzed jp HalveAttackDueToBurn ; apply attack penalty to the player whose turn is not, if it's burned -Func_3f520: ; 3f520 (f:7520) +RestoreOriginalStatModifier: ; 3f520 (f:7520) pop hl dec [hl] @@ -7854,7 +7857,7 @@ UpdateLoweredStatDone: ; 3f62c (f:762c) ld a, [de] cp $44 jr nc, .ApplyBadgeBoostsAndStatusPenalties - call StoreCurrentMoveAnimationIDAndType + call PlayCurrentMoveAnimation2 .ApplyBadgeBoostsAndStatusPenalties ld a, [H_WHOSETURN] and a @@ -7977,7 +7980,7 @@ BideEffect: ; 3f6e5 (f:76e5) ld [bc], a ; set Bide counter to 2 or 3 at random ld a, [H_WHOSETURN] add XSTATITEM_ANIM - jp StoreAnimationIDAndType + jp PlayBattleAnimation2 ThrashPetalDanceEffect: ; 3f717 (f:7717) ld hl, W_PLAYERBATTSTATUS1 @@ -7996,7 +7999,7 @@ ThrashPetalDanceEffect: ; 3f717 (f:7717) ld [de], a ; set thrash/petal dance counter to 2 or 3 at random ld a, [H_WHOSETURN] add ANIM_B0 - jp StoreAnimationIDAndType + jp PlayBattleAnimation2 SwitchAndTeleportEffect: ; 3f739 (f:7739) ld a, [H_WHOSETURN] @@ -8345,7 +8348,7 @@ ConfusionSideEffectSuccess: ; 3f96f (f:796f) ld [bc], a ; confusion status will last 2-5 turns pop af cp CONFUSION_SIDE_EFFECT - call nz, StoreCurrentMoveAnimationIDAndType + call nz, PlayCurrentMoveAnimation2 ld hl, BecameConfusedText jp PrintText @@ -8550,7 +8553,7 @@ DisableEffect: ; 3fa8a (f:7a8a) swap c add c ld [de], a - call StoreCurrentMoveAnimationIDAndType + call PlayCurrentMoveAnimation2 ld hl, wccee ld a, [H_WHOSETURN] and a @@ -8658,18 +8661,20 @@ CheckTargetSubstitute: ; 3fb79 (f:7b79) pop hl ret -StoreCurrentMoveAnimationIDAndType: ; 3fb89 (f:7b89) +PlayCurrentMoveAnimation2: ; 3fb89 (f:7b89) ; animation at MOVENUM will be played unless MOVENUM is 0 +; plays wAnimationType 3 or 6 ld a, [H_WHOSETURN] and a ld a, [W_PLAYERMOVENUM] - jr z, .asm_3fb94 + jr z, .notEnemyTurn ld a, [W_ENEMYMOVENUM] -.asm_3fb94 +.notEnemyTurn and a ret z -StoreAnimationIDAndType: ; 3fb96 (f:7b96) +PlayBattleAnimation2: ; 3fb96 (f:7b96) +; play animation ID at a and animation type 6 or 3 ld [W_ANIMATIONID], a ld a, [H_WHOSETURN] and a @@ -8681,6 +8686,8 @@ StoreAnimationIDAndType: ; 3fb96 (f:7b96) jp PlayBattleAnimationGotID PlayCurrentMoveAnimation: ; 3fba8 (f:7ba8) +; animation at MOVENUM will be played unless MOVENUM is 0 +; resets wAnimationType xor a ld [wAnimationType], a ld a, [H_WHOSETURN] @@ -8693,9 +8700,11 @@ PlayCurrentMoveAnimation: ; 3fba8 (f:7ba8) ret z PlayBattleAnimation: ; 3fbb9 (f:7bb9) +; play animation ID at a and predefined animation type ld [W_ANIMATIONID], a PlayBattleAnimationGotID: ; 3fbbc (f:7bbc) +; play animation at W_ANIMATIONID push hl push de push bc diff --git a/engine/battle/e.asm b/engine/battle/e.asm index feb52df1..e7802e4e 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -273,7 +273,7 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7) ld a, [wAILayer2Encouragement] cp $1 ret nz - ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) + ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset) ld de, wEnemyMonMoves ; enemy moves ld b, NUM_MOVES + 1 .nextMove @@ -303,7 +303,7 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7) ; discourage damaging moves that are ineffective or not very effective against the player's mon, ; unless there's no damaging move that deals at least neutral damage AIMoveChoiceModification3: ; 39817 (e:5817) - ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) + ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset) ld de, wEnemyMonMoves ; enemy moves ld b, $5 .nextMove -- cgit v1.3.1-sl0p From 46c2a38c7c55ff01e8787dfd624cb1c771248b6c Mon Sep 17 00:00:00 2001 From: xCrystal Date: Wed, 1 Apr 2015 11:41:20 +0200 Subject: Rename battle files and split move effects Part 2 5.asm, 9.asm, and a.asm --- engine/battle/5.asm | 77 --------- engine/battle/9.asm | 190 ---------------------- engine/battle/a.asm | 39 ----- engine/battle/core.asm | 4 +- engine/battle/moveEffects/focus_energy_effect.asm | 24 +++ engine/battle/moveEffects/leech_seed_effect.asm | 39 +++++ engine/battle/moveEffects/substitute_effect.asm | 77 +++++++++ engine/battle/print_type.asm | 52 ++++++ engine/battle/save_trainer_name.asm | 112 +++++++++++++ main.asm | 8 +- 10 files changed, 311 insertions(+), 311 deletions(-) delete mode 100755 engine/battle/5.asm delete mode 100755 engine/battle/9.asm delete mode 100755 engine/battle/a.asm create mode 100644 engine/battle/moveEffects/focus_energy_effect.asm create mode 100644 engine/battle/moveEffects/leech_seed_effect.asm create mode 100644 engine/battle/moveEffects/substitute_effect.asm create mode 100644 engine/battle/print_type.asm create mode 100644 engine/battle/save_trainer_name.asm (limited to 'engine/battle/core.asm') diff --git a/engine/battle/5.asm b/engine/battle/5.asm deleted file mode 100755 index ef3e1362..00000000 --- a/engine/battle/5.asm +++ /dev/null @@ -1,77 +0,0 @@ -SubstituteEffectHandler: ; 17dad (5:7dad) - ld c, 50 - call DelayFrames - ld hl, wBattleMonMaxHP - ld de, wPlayerSubstituteHP - ld bc, W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] - and a - jr z, .notEnemy - ld hl, wEnemyMonMaxHP - ld de, wEnemySubstituteHP - ld bc, W_ENEMYBATTSTATUS2 -.notEnemy - ld a, [bc] ;load flags - bit HasSubstituteUp, a ;user already has substitute? - jr nz, .alreadyHasSubstitute ;skip this code if so - ;user doesn't have a substitute [yet] - push bc - ld a, [hli] ;load max hp - ld b, [hl] - srl a ;max hp / 4, [quarter health to remove from user] - rr b - srl a - rr b - push de - ld de, wBattleMonHP - wBattleMonMaxHP - add hl, de ; point hl to current HP - pop de - ld a, b - ld [de], a ;save copy of HP to subtract in ccd7/ccd8 [how much HP substitute has] - ld a, [hld] ;load current hp - sub b ;subtract [max hp / 4] - ld d, a ;save low byte result in D - ld a, [hl] - sbc a, 0 ;borrow from high byte if needed - pop bc - jr c, .notEnoughHP ;underflow means user would be left with negative health - ;bug: note since it only brances on carry, it will possibly leave user with 0HP -.userHasZeroOrMoreHP - ldi [hl], a ;store high byte HP - ld [hl], d ;store low byte HP - ld h, b - ld l, c - set HasSubstituteUp, [hl] ;set bit 4 of flags, user now has substitute - ld a, [W_OPTIONS] ;load options - bit 7, a ;battle animation is enabled? - ld hl, PlayCurrentMoveAnimation ;animation enabled: 0F:7BA8 - ld b, BANK(PlayCurrentMoveAnimation) - jr z, .animationEnabled - ld hl, AnimationSubstitute ;animation disabled: 1E:56E0 - ld b, BANK(AnimationSubstitute) -.animationEnabled - call Bankswitch ;jump to routine depending on animation setting - ld hl, SubstituteText - call PrintText - ld hl, DrawHUDsAndHPBars - ld b, BANK(DrawHUDsAndHPBars) - jp Bankswitch -.alreadyHasSubstitute - ld hl, HasSubstituteText - jr .printText -.notEnoughHP - ld hl, TooWeakSubstituteText -.printText - jp PrintText - -SubstituteText: ; 17e1d (5:7e1d) - TX_FAR _SubstituteText - db "@" - -HasSubstituteText: ; 17e22 (5:7e22) - TX_FAR _HasSubstituteText - db "@" - -TooWeakSubstituteText: ; 17e27 (5:7e27) - TX_FAR _TooWeakSubstituteText - db "@" diff --git a/engine/battle/9.asm b/engine/battle/9.asm deleted file mode 100755 index e7265f41..00000000 --- a/engine/battle/9.asm +++ /dev/null @@ -1,190 +0,0 @@ -; [wd0b5] = pokemon ID -; hl = dest addr -PrintMonType: ; 27d6b (9:7d6b) - call GetPredefRegisters - push hl - call GetMonHeader - pop hl - push hl - ld a, [W_MONHTYPE1] - call PrintType - ld a, [W_MONHTYPE1] - ld b, a - ld a, [W_MONHTYPE2] - cp b - pop hl - jr z, EraseType2Text - ld bc, SCREEN_WIDTH * 2 - add hl, bc - -; a = type -; hl = dest addr -PrintType: ; 27d89 (9:7d89) - push hl - jr PrintType_ - -; erase "TYPE2/" if the mon only has 1 type -EraseType2Text: ; 27d8c (9:7d8c) - ld a, " " - ld bc, $13 - add hl, bc - ld bc, $6 - jp FillMemory - -PrintMoveType: ; 27d98 (9:7d98) - call GetPredefRegisters - push hl - ld a, [W_PLAYERMOVETYPE] -; fall through - -PrintType_: ; 27d9f (9:7d9f) - add a - ld hl, TypeNames - ld e, a - ld d, $0 - add hl, de - ld a, [hli] - ld e, a - ld d, [hl] - pop hl - jp PlaceString - -INCLUDE "text/type_names.asm" - -SaveTrainerName: ; 27e4a (9:7e4a) - ld hl,TrainerNamePointers - ld a,[W_TRAINERCLASS] - dec a - ld c,a - ld b,0 - add hl,bc - add hl,bc - ld a,[hli] - ld h,[hl] - ld l,a - ld de,wcd6d -.CopyCharacter - ld a,[hli] - ld [de],a - inc de - cp "@" - jr nz,.CopyCharacter - ret - -TrainerNamePointers: ; 27e64 (9:7e64) -; what is the point of these? - dw YoungsterName - dw BugCatcherName - dw LassName - dw W_TRAINERNAME - dw JrTrainerMName - dw JrTrainerFName - dw PokemaniacName - dw SuperNerdName - dw W_TRAINERNAME - dw W_TRAINERNAME - dw BurglarName - dw EngineerName - dw JugglerXName - dw W_TRAINERNAME - dw SwimmerName - dw W_TRAINERNAME - dw W_TRAINERNAME - dw BeautyName - dw W_TRAINERNAME - dw RockerName - dw JugglerName - dw W_TRAINERNAME - dw W_TRAINERNAME - dw BlackbeltName - dw W_TRAINERNAME - dw ProfOakName - dw ChiefName - dw ScientistName - dw W_TRAINERNAME - dw RocketName - dw CooltrainerMName - dw CooltrainerFName - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - dw W_TRAINERNAME - -YoungsterName: ; 27ec2 (9:7ec2) - db "YOUNGSTER@" -BugCatcherName: ; 27ecc (9:7ecc) - db "BUG CATCHER@" -LassName: ; 27ed8 (9:7ed8) - db "LASS@" -JrTrainerMName: ; 27edd (9:7edd) - db "JR.TRAINER♂@" -JrTrainerFName: ; 27ee9 (9:7ee9) - db "JR.TRAINER♀@" -PokemaniacName: ; 27ef5 (9:7ef5) - db "POKéMANIAC@" -SuperNerdName: ; 27f00 (9:7f00) - db "SUPER NERD@" -BurglarName: ; 27f0b (9:7f0b) - db "BURGLAR@" -EngineerName: ; 27f13 (9:7f13) - db "ENGINEER@" -JugglerXName: ; 27f1c (9:7f1c) - db "JUGGLER@" -SwimmerName: ; 27f24 (9:7f24) - db "SWIMMER@" -BeautyName: ; 27f2c (9:7f2c) - db "BEAUTY@" -RockerName: ; 27f33 (9:7f33) - db "ROCKER@" -JugglerName: ; 27f3a (9:7f3a) - db "JUGGLER@" -BlackbeltName: ; 27f42 (9:7f42) - db "BLACKBELT@" -ProfOakName: ; 27f4c (9:7f4c) - db "PROF.OAK@" -ChiefName: ; 27f55 (9:7f55) - db "CHIEF@" -ScientistName: ; 27f5b (9:7f5b) - db "SCIENTIST@" -RocketName: ; 27f65 (9:7f65) - db "ROCKET@" -CooltrainerMName: ; 27f6c (9:7f6c) - db "COOLTRAINER♂@" -CooltrainerFName: ; 27f79 (9:7f79) - db "COOLTRAINER♀@" - -FocusEnergyEffect_: ; 27f86 (9:7f86) - ld hl, W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] - and a - jr z, .notEnemy - ld hl, W_ENEMYBATTSTATUS2 -.notEnemy - bit GettingPumped, [hl] ; is mon already using focus energy? - jr nz, .alreadyUsing - set GettingPumped, [hl] ; mon is now using focus energy - callab PlayCurrentMoveAnimation - ld hl, GettingPumpedText - jp PrintText -.alreadyUsing - ld c, $32 - call DelayFrames - ld hl, PrintButItFailedText_ - ld b, BANK(PrintButItFailedText_) - jp Bankswitch - -GettingPumpedText: ; 27fb3 (9:7fb3) - db $0a - TX_FAR _GettingPumpedText - db "@" diff --git a/engine/battle/a.asm b/engine/battle/a.asm deleted file mode 100755 index a257d143..00000000 --- a/engine/battle/a.asm +++ /dev/null @@ -1,39 +0,0 @@ -LeechSeedEffect_: ; 2bea9 (a:7ea9) - callab MoveHitTest - ld a, [W_MOVEMISSED] ; W_MOVEMISSED - and a - jr nz, .asm_2bee7 - ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 - ld de, wEnemyMonType1 ; wcfea (aliases: wEnemyMonType) - ld a, [H_WHOSETURN] ; $fff3 - and a - jr z, .asm_2bec8 - ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 - ld de, wBattleMonType1 ; wd019 (aliases: wBattleMonType) -.asm_2bec8 - ld a, [de] - cp GRASS - jr z, .asm_2bee7 - inc de - ld a, [de] - cp GRASS - jr z, .asm_2bee7 - bit Seeded, [hl] - jr nz, .asm_2bee7 - set Seeded, [hl] - callab PlayCurrentMoveAnimation - ld hl, WasSeededText ; $7ef2 - jp PrintText -.asm_2bee7 - ld c, $32 - call DelayFrames - ld hl, EvadedAttackText ; $7ef7 - jp PrintText - -WasSeededText: ; 2bef2 (a:7ef2) - TX_FAR _WasSeededText - db "@" - -EvadedAttackText: ; 2bef7 (a:7ef7) - TX_FAR _EvadedAttackText - db "@" diff --git a/engine/battle/core.asm b/engine/battle/core.asm index bad8f831..48bed512 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -8369,8 +8369,8 @@ ParalyzeEffect: ; 3f9b1 (f:79b1) jp Bankswitch SubstituteEffect: ; 3f9b9 (f:79b9) - ld hl, SubstituteEffectHandler - ld b, BANK(SubstituteEffectHandler) + ld hl, SubstituteEffect_ + ld b, BANK(SubstituteEffect_) jp Bankswitch HyperBeamEffect: ; 3f9c1 (f:79c1) diff --git a/engine/battle/moveEffects/focus_energy_effect.asm b/engine/battle/moveEffects/focus_energy_effect.asm new file mode 100644 index 00000000..f01e61cc --- /dev/null +++ b/engine/battle/moveEffects/focus_energy_effect.asm @@ -0,0 +1,24 @@ +FocusEnergyEffect_: ; 27f86 (9:7f86) + ld hl, W_PLAYERBATTSTATUS2 + ld a, [H_WHOSETURN] + and a + jr z, .notEnemy + ld hl, W_ENEMYBATTSTATUS2 +.notEnemy + bit GettingPumped, [hl] ; is mon already using focus energy? + jr nz, .alreadyUsing + set GettingPumped, [hl] ; mon is now using focus energy + callab PlayCurrentMoveAnimation + ld hl, GettingPumpedText + jp PrintText +.alreadyUsing + ld c, $32 + call DelayFrames + ld hl, PrintButItFailedText_ + ld b, BANK(PrintButItFailedText_) + jp Bankswitch + +GettingPumpedText: ; 27fb3 (9:7fb3) + db $0a + TX_FAR _GettingPumpedText + db "@" diff --git a/engine/battle/moveEffects/leech_seed_effect.asm b/engine/battle/moveEffects/leech_seed_effect.asm new file mode 100644 index 00000000..a257d143 --- /dev/null +++ b/engine/battle/moveEffects/leech_seed_effect.asm @@ -0,0 +1,39 @@ +LeechSeedEffect_: ; 2bea9 (a:7ea9) + callab MoveHitTest + ld a, [W_MOVEMISSED] ; W_MOVEMISSED + and a + jr nz, .asm_2bee7 + ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 + ld de, wEnemyMonType1 ; wcfea (aliases: wEnemyMonType) + ld a, [H_WHOSETURN] ; $fff3 + and a + jr z, .asm_2bec8 + ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 + ld de, wBattleMonType1 ; wd019 (aliases: wBattleMonType) +.asm_2bec8 + ld a, [de] + cp GRASS + jr z, .asm_2bee7 + inc de + ld a, [de] + cp GRASS + jr z, .asm_2bee7 + bit Seeded, [hl] + jr nz, .asm_2bee7 + set Seeded, [hl] + callab PlayCurrentMoveAnimation + ld hl, WasSeededText ; $7ef2 + jp PrintText +.asm_2bee7 + ld c, $32 + call DelayFrames + ld hl, EvadedAttackText ; $7ef7 + jp PrintText + +WasSeededText: ; 2bef2 (a:7ef2) + TX_FAR _WasSeededText + db "@" + +EvadedAttackText: ; 2bef7 (a:7ef7) + TX_FAR _EvadedAttackText + db "@" diff --git a/engine/battle/moveEffects/substitute_effect.asm b/engine/battle/moveEffects/substitute_effect.asm new file mode 100644 index 00000000..e88def4a --- /dev/null +++ b/engine/battle/moveEffects/substitute_effect.asm @@ -0,0 +1,77 @@ +SubstituteEffect_: ; 17dad (5:7dad) + ld c, 50 + call DelayFrames + ld hl, wBattleMonMaxHP + ld de, wPlayerSubstituteHP + ld bc, W_PLAYERBATTSTATUS2 + ld a, [H_WHOSETURN] + and a + jr z, .notEnemy + ld hl, wEnemyMonMaxHP + ld de, wEnemySubstituteHP + ld bc, W_ENEMYBATTSTATUS2 +.notEnemy + ld a, [bc] ;load flags + bit HasSubstituteUp, a ;user already has substitute? + jr nz, .alreadyHasSubstitute ;skip this code if so + ;user doesn't have a substitute [yet] + push bc + ld a, [hli] ;load max hp + ld b, [hl] + srl a ;max hp / 4, [quarter health to remove from user] + rr b + srl a + rr b + push de + ld de, wBattleMonHP - wBattleMonMaxHP + add hl, de ; point hl to current HP + pop de + ld a, b + ld [de], a ;save copy of HP to subtract in ccd7/ccd8 [how much HP substitute has] + ld a, [hld] ;load current hp + sub b ;subtract [max hp / 4] + ld d, a ;save low byte result in D + ld a, [hl] + sbc a, 0 ;borrow from high byte if needed + pop bc + jr c, .notEnoughHP ;underflow means user would be left with negative health + ;bug: note since it only brances on carry, it will possibly leave user with 0HP +.userHasZeroOrMoreHP + ldi [hl], a ;store high byte HP + ld [hl], d ;store low byte HP + ld h, b + ld l, c + set HasSubstituteUp, [hl] ;set bit 4 of flags, user now has substitute + ld a, [W_OPTIONS] ;load options + bit 7, a ;battle animation is enabled? + ld hl, PlayCurrentMoveAnimation ;animation enabled: 0F:7BA8 + ld b, BANK(PlayCurrentMoveAnimation) + jr z, .animationEnabled + ld hl, AnimationSubstitute ;animation disabled: 1E:56E0 + ld b, BANK(AnimationSubstitute) +.animationEnabled + call Bankswitch ;jump to routine depending on animation setting + ld hl, SubstituteText + call PrintText + ld hl, DrawHUDsAndHPBars + ld b, BANK(DrawHUDsAndHPBars) + jp Bankswitch +.alreadyHasSubstitute + ld hl, HasSubstituteText + jr .printText +.notEnoughHP + ld hl, TooWeakSubstituteText +.printText + jp PrintText + +SubstituteText: ; 17e1d (5:7e1d) + TX_FAR _SubstituteText + db "@" + +HasSubstituteText: ; 17e22 (5:7e22) + TX_FAR _HasSubstituteText + db "@" + +TooWeakSubstituteText: ; 17e27 (5:7e27) + TX_FAR _TooWeakSubstituteText + db "@" diff --git a/engine/battle/print_type.asm b/engine/battle/print_type.asm new file mode 100644 index 00000000..38c701a8 --- /dev/null +++ b/engine/battle/print_type.asm @@ -0,0 +1,52 @@ +; [wd0b5] = pokemon ID +; hl = dest addr +PrintMonType: ; 27d6b (9:7d6b) + call GetPredefRegisters + push hl + call GetMonHeader + pop hl + push hl + ld a, [W_MONHTYPE1] + call PrintType + ld a, [W_MONHTYPE1] + ld b, a + ld a, [W_MONHTYPE2] + cp b + pop hl + jr z, EraseType2Text + ld bc, SCREEN_WIDTH * 2 + add hl, bc + +; a = type +; hl = dest addr +PrintType: ; 27d89 (9:7d89) + push hl + jr PrintType_ + +; erase "TYPE2/" if the mon only has 1 type +EraseType2Text: ; 27d8c (9:7d8c) + ld a, " " + ld bc, $13 + add hl, bc + ld bc, $6 + jp FillMemory + +PrintMoveType: ; 27d98 (9:7d98) + call GetPredefRegisters + push hl + ld a, [W_PLAYERMOVETYPE] +; fall through + +PrintType_: ; 27d9f (9:7d9f) + add a + ld hl, TypeNames + ld e, a + ld d, $0 + add hl, de + ld a, [hli] + ld e, a + ld d, [hl] + pop hl + jp PlaceString + +INCLUDE "text/type_names.asm" diff --git a/engine/battle/save_trainer_name.asm b/engine/battle/save_trainer_name.asm new file mode 100644 index 00000000..84ef1f69 --- /dev/null +++ b/engine/battle/save_trainer_name.asm @@ -0,0 +1,112 @@ +SaveTrainerName: ; 27e4a (9:7e4a) + ld hl,TrainerNamePointers + ld a,[W_TRAINERCLASS] + dec a + ld c,a + ld b,0 + add hl,bc + add hl,bc + ld a,[hli] + ld h,[hl] + ld l,a + ld de,wcd6d +.CopyCharacter + ld a,[hli] + ld [de],a + inc de + cp "@" + jr nz,.CopyCharacter + ret + +TrainerNamePointers: ; 27e64 (9:7e64) +; what is the point of these? + dw YoungsterName + dw BugCatcherName + dw LassName + dw W_TRAINERNAME + dw JrTrainerMName + dw JrTrainerFName + dw PokemaniacName + dw SuperNerdName + dw W_TRAINERNAME + dw W_TRAINERNAME + dw BurglarName + dw EngineerName + dw JugglerXName + dw W_TRAINERNAME + dw SwimmerName + dw W_TRAINERNAME + dw W_TRAINERNAME + dw BeautyName + dw W_TRAINERNAME + dw RockerName + dw JugglerName + dw W_TRAINERNAME + dw W_TRAINERNAME + dw BlackbeltName + dw W_TRAINERNAME + dw ProfOakName + dw ChiefName + dw ScientistName + dw W_TRAINERNAME + dw RocketName + dw CooltrainerMName + dw CooltrainerFName + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + dw W_TRAINERNAME + +YoungsterName: ; 27ec2 (9:7ec2) + db "YOUNGSTER@" +BugCatcherName: ; 27ecc (9:7ecc) + db "BUG CATCHER@" +LassName: ; 27ed8 (9:7ed8) + db "LASS@" +JrTrainerMName: ; 27edd (9:7edd) + db "JR.TRAINER♂@" +JrTrainerFName: ; 27ee9 (9:7ee9) + db "JR.TRAINER♀@" +PokemaniacName: ; 27ef5 (9:7ef5) + db "POKéMANIAC@" +SuperNerdName: ; 27f00 (9:7f00) + db "SUPER NERD@" +BurglarName: ; 27f0b (9:7f0b) + db "BURGLAR@" +EngineerName: ; 27f13 (9:7f13) + db "ENGINEER@" +JugglerXName: ; 27f1c (9:7f1c) + db "JUGGLER@" +SwimmerName: ; 27f24 (9:7f24) + db "SWIMMER@" +BeautyName: ; 27f2c (9:7f2c) + db "BEAUTY@" +RockerName: ; 27f33 (9:7f33) + db "ROCKER@" +JugglerName: ; 27f3a (9:7f3a) + db "JUGGLER@" +BlackbeltName: ; 27f42 (9:7f42) + db "BLACKBELT@" +ProfOakName: ; 27f4c (9:7f4c) + db "PROF.OAK@" +ChiefName: ; 27f55 (9:7f55) + db "CHIEF@" +ScientistName: ; 27f5b (9:7f5b) + db "SCIENTIST@" +RocketName: ; 27f65 (9:7f65) + db "ROCKET@" +CooltrainerMName: ; 27f6c (9:7f6c) + db "COOLTRAINER♂@" +CooltrainerFName: ; 27f79 (9:7f79) + db "COOLTRAINER♀@" diff --git a/main.asm b/main.asm index 958c774f..1c7f15f9 100755 --- a/main.asm +++ b/main.asm @@ -4825,7 +4825,7 @@ INCLUDE "engine/load_pokedex_tiles.asm" INCLUDE "engine/overworld/map_sprites.asm" INCLUDE "engine/overworld/emotion_bubbles.asm" INCLUDE "engine/evolve_trade.asm" -INCLUDE "engine/battle/5.asm" +INCLUDE "engine/battle/moveEffects/substitute_effect.asm" INCLUDE "engine/menu/pc.asm" @@ -5154,7 +5154,9 @@ TangelaPicBack:: INCBIN "pic/monback/tangelab.pic" SECTION "Battle (bank 9)", ROMX, BANK[$9] -INCLUDE "engine/battle/9.asm" +INCLUDE "engine/battle/print_type.asm" +INCLUDE "engine/battle/save_trainer_name.asm" +INCLUDE "engine/battle/moveEffects/focus_energy_effect.asm" SECTION "Pics 2", ROMX, BANK[PICS_2] @@ -5226,7 +5228,7 @@ MoltresPicBack:: INCBIN "pic/monback/moltresb.pic" SECTION "Battle (bank A)", ROMX, BANK[$A] -INCLUDE "engine/battle/a.asm" +INCLUDE "engine/battle/moveEffects/leech_seed_effect.asm" SECTION "Pics 3", ROMX, BANK[PICS_3] -- cgit v1.3.1-sl0p