diff options
Diffstat (limited to 'engine/battle/move_effects')
-rw-r--r-- | engine/battle/move_effects/beat_up.asm | 220 | ||||
-rw-r--r-- | engine/battle/move_effects/conversion2.asm | 64 | ||||
-rw-r--r-- | engine/battle/move_effects/counter.asm | 59 | ||||
-rw-r--r-- | engine/battle/move_effects/destiny_bond.asm | 9 | ||||
-rw-r--r-- | engine/battle/move_effects/encore.asm | 120 | ||||
-rw-r--r-- | engine/battle/move_effects/false_swipe.asm | 48 | ||||
-rw-r--r-- | engine/battle/move_effects/heal_bell.asm | 34 | ||||
-rw-r--r-- | engine/battle/move_effects/lock_on.asm | 21 | ||||
-rw-r--r-- | engine/battle/move_effects/pain_split.asm | 92 | ||||
-rw-r--r-- | engine/battle/move_effects/sketch.asm | 117 | ||||
-rw-r--r-- | engine/battle/move_effects/sleep_talk.asm | 143 | ||||
-rw-r--r-- | engine/battle/move_effects/snore.asm | 11 | ||||
-rw-r--r-- | engine/battle/move_effects/spite.asm | 86 |
13 files changed, 1024 insertions, 0 deletions
diff --git a/engine/battle/move_effects/beat_up.asm b/engine/battle/move_effects/beat_up.asm new file mode 100644 index 00000000..8546c37d --- /dev/null +++ b/engine/battle/move_effects/beat_up.asm @@ -0,0 +1,220 @@ +BattleCommand_BeatUp: +; beatup + + call ResetDamage + ldh a, [hBattleTurn] + and a + jp nz, .enemy_beats_up + + ld a, [wPlayerSubStatus3] + bit SUBSTATUS_IN_LOOP, a + jr nz, .next_mon + + ld c, 20 + call DelayFrames + xor a + ld [wPlayerRolloutCount], a + ld [wceed], a + ld [wBeatUpHitAtLeastOnce], a + jr .got_mon + +.next_mon + ld a, [wPlayerRolloutCount] + ld b, a + ld a, [wPartyCount] + sub b + ld [wceed], a + +.got_mon + ld a, [wceed] + ld hl, wPartyMonNicknames + call GetNick + ld a, MON_HP + call GetBeatupMonLocation + ld a, [hli] + or [hl] + jp z, .beatup_fail ; fainted + ld a, [wceed] + ld c, a + ld a, [wCurBattleMon] + ; BUG: this can desynchronize link battles + ; Change "cp [hl]" to "cp c" to fix + cp [hl] + ld hl, wBattleMonStatus + jr z, .active_mon + ld a, MON_STATUS + call GetBeatupMonLocation +.active_mon + ld a, [hl] + and a + jp nz, .beatup_fail + + ld a, $1 + ld [wBeatUpHitAtLeastOnce], a + ld hl, BeatUpAttackText + call StdBattleTextbox + + ld a, [wEnemyMonSpecies] + ld [wCurSpecies], a + call GetBaseData + ld a, [wBaseDefense] + ld c, a + + push bc + ld a, MON_SPECIES + call GetBeatupMonLocation + ld a, [hl] + ld [wCurSpecies], a + call GetBaseData + ld a, [wBaseAttack] + pop bc + ld b, a + + push bc + ld a, MON_LEVEL + call GetBeatupMonLocation + ld a, [hl] + ld e, a + pop bc + + ld a, [wPlayerMoveStructPower] + ld d, a + ret + +.enemy_beats_up + ld a, [wEnemySubStatus3] + bit SUBSTATUS_IN_LOOP, a + jr nz, .enemy_next_mon + + xor a + ld [wEnemyRolloutCount], a + ld [wceed], a + ld [wBeatUpHitAtLeastOnce], a + jr .enemy_got_mon + +.enemy_next_mon + ld a, [wEnemyRolloutCount] + ld b, a + ld a, [wOTPartyCount] + sub b + ld [wceed], a + +.enemy_got_mon + ld a, [wBattleMode] + dec a + jr z, .wild + + ld a, [wLinkMode] + and a + jr nz, .linked + + ld a, [wceed] + ld c, a + ld b, 0 + ld hl, wOTPartySpecies + add hl, bc + ld a, [hl] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + jr .got_enemy_nick + +.linked + ld a, [wceed] + ld hl, wOTPartyMonNicknames + ld bc, NAME_LENGTH + call AddNTimes + ld de, wStringBuffer1 + call CopyBytes + +.got_enemy_nick + ld a, MON_HP + call GetBeatupMonLocation + ld a, [hli] + or [hl] + jp z, .beatup_fail + + ld a, [wceed] + ld b, a + ld a, [wCurOTMon] + cp b + ld hl, wEnemyMonStatus + jr z, .active_enemy + ld a, MON_STATUS + call GetBeatupMonLocation +.active_enemy + ld a, [hl] + and a + jr nz, .beatup_fail + + ld a, $1 + ld [wBeatUpHitAtLeastOnce], a + jr .finish_beatup + +.wild + ld a, [wEnemyMonSpecies] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld hl, BeatUpAttackText + call StdBattleTextbox + jp EnemyAttackDamage + +.finish_beatup + ld hl, BeatUpAttackText + call StdBattleTextbox + + ld a, [wBattleMonSpecies] + ld [wCurSpecies], a + call GetBaseData + ld a, [wBaseDefense] + ld c, a + + push bc + ld a, MON_SPECIES + call GetBeatupMonLocation + ld a, [hl] + ld [wCurSpecies], a + call GetBaseData + ld a, [wBaseAttack] + pop bc + ld b, a + + push bc + ld a, MON_LEVEL + call GetBeatupMonLocation + ld a, [hl] + ld e, a + pop bc + + ld a, [wEnemyMoveStructPower] + ld d, a + ret + +.beatup_fail + ld b, buildopponentrage_command + jp SkipToBattleCommand + +BattleCommand_BeatUpFailText: +; beatupfailtext + + ld a, [wBeatUpHitAtLeastOnce] + and a + ret nz + + jp PrintButItFailed + +GetBeatupMonLocation: + push bc + ld c, a + ld b, 0 + ldh a, [hBattleTurn] + and a + ld hl, wPartyMon1Species + jr z, .got_species + ld hl, wOTPartyMon1Species + +.got_species + ld a, [wceed] + add hl, bc + call GetPartyLocation + pop bc + ret diff --git a/engine/battle/move_effects/conversion2.asm b/engine/battle/move_effects/conversion2.asm new file mode 100644 index 00000000..bc866727 --- /dev/null +++ b/engine/battle/move_effects/conversion2.asm @@ -0,0 +1,64 @@ +BattleCommand_Conversion2: +; conversion2 + + ld a, [wAttackMissed] + and a + jr nz, .failed + ld hl, wBattleMonType1 + ldh a, [hBattleTurn] + and a + jr z, .got_type + ld hl, wEnemyMonType1 +.got_type + ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP + call GetBattleVar + and a + jr z, .failed + push hl + dec a + ld hl, Moves + MOVE_TYPE + call GetMoveAttr + ld d, a + pop hl + cp CURSE_TYPE + jr z, .failed + call AnimateCurrentMove + call BattleCommand_SwitchTurn + +.loop + call BattleRandom + maskbits NUM_TYPES + cp UNUSED_TYPES + jr c, .okay + cp UNUSED_TYPES_END + jr c, .loop + cp TYPES_END + jr nc, .loop +.okay + ld [hli], a + ld [hld], a + push hl + ld a, BATTLE_VARS_MOVE_TYPE + call GetBattleVarAddr + push af + push hl + ld a, d + ld [hl], a + call BattleCheckTypeMatchup + pop hl + pop af + ld [hl], a + pop hl + ld a, [wTypeMatchup] + cp EFFECTIVE + jr nc, .loop + call BattleCommand_SwitchTurn + + ld a, [hl] + ld [wNamedObjectIndexBuffer], a + predef GetTypeName + ld hl, TransformedTypeText + jp StdBattleTextbox + +.failed + jp FailMove diff --git a/engine/battle/move_effects/counter.asm b/engine/battle/move_effects/counter.asm new file mode 100644 index 00000000..031c399a --- /dev/null +++ b/engine/battle/move_effects/counter.asm @@ -0,0 +1,59 @@ +BattleCommand_Counter: +; counter + + ld a, 1 + ld [wAttackMissed], a + ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP + call GetBattleVar + and a + ret z + + ld b, a + callfar GetMoveEffect + ld a, b + cp EFFECT_COUNTER + ret z + + call BattleCommand_ResetTypeMatchup + ld a, [wTypeMatchup] + and a + ret z + + call CheckOpponentWentFirst + ret z + + ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP + call GetBattleVar + dec a + ld de, wStringBuffer1 + call GetMoveData + + ld a, [wStringBuffer1 + MOVE_POWER] + and a + ret z + + ld a, [wStringBuffer1 + MOVE_TYPE] + cp SPECIAL + ret nc + + ; BUG: Move should fail with all non-damaging battle actions + ld hl, wCurDamage + ld a, [hli] + or [hl] + ret z + + ld a, [hl] + add a + ld [hld], a + ld a, [hl] + adc a + ld [hl], a + jr nc, .capped + ld a, $ff + ld [hli], a + ld [hl], a +.capped + + xor a + ld [wAttackMissed], a + ret diff --git a/engine/battle/move_effects/destiny_bond.asm b/engine/battle/move_effects/destiny_bond.asm new file mode 100644 index 00000000..6a03b9a7 --- /dev/null +++ b/engine/battle/move_effects/destiny_bond.asm @@ -0,0 +1,9 @@ +BattleCommand_DestinyBond: +; destinybond + + ld a, BATTLE_VARS_SUBSTATUS5 + call GetBattleVarAddr + set SUBSTATUS_DESTINY_BOND, [hl] + call AnimateCurrentMove + ld hl, DestinyBondEffectText + jp StdBattleTextbox diff --git a/engine/battle/move_effects/encore.asm b/engine/battle/move_effects/encore.asm new file mode 100644 index 00000000..8ca3595f --- /dev/null +++ b/engine/battle/move_effects/encore.asm @@ -0,0 +1,120 @@ +BattleCommand_Encore: +; encore + + ld hl, wEnemyMonMoves + ld de, wEnemyEncoreCount + ldh a, [hBattleTurn] + and a + jr z, .ok + ld hl, wBattleMonMoves + ld de, wPlayerEncoreCount +.ok + ld a, BATTLE_VARS_LAST_MOVE_OPP + call GetBattleVar + and a + jp z, .failed + cp STRUGGLE + jp z, .failed + cp ENCORE + jp z, .failed + cp MIRROR_MOVE + jp z, .failed + ld b, a + +.got_move + ld a, [hli] + cp b + jr nz, .got_move + + ld bc, wBattleMonPP - wBattleMonMoves - 1 + add hl, bc + ld a, [hl] + and PP_MASK + jp z, .failed + ld a, [wAttackMissed] + and a + jp nz, .failed + ld a, BATTLE_VARS_SUBSTATUS5_OPP + call GetBattleVarAddr + bit SUBSTATUS_ENCORED, [hl] + jp nz, .failed + set SUBSTATUS_ENCORED, [hl] + call BattleRandom + and $3 + inc a + inc a + inc a + ld [de], a + call CheckOpponentWentFirst + jr nz, .finish_move + ldh a, [hBattleTurn] + and a + jr z, .force_last_enemy_move + + push hl + ld a, [wLastPlayerMove] + ld b, a + ld c, 0 + ld hl, wBattleMonMoves +.find_player_move + ld a, [hli] + cp b + jr z, .got_player_move + inc c + ld a, c + cp NUM_MOVES + jr c, .find_player_move + pop hl + res SUBSTATUS_ENCORED, [hl] + xor a + ld [de], a + jr .failed + +.got_player_move + pop hl + ld a, c + ld [wCurMoveNum], a + ld a, b + ld [wCurPlayerMove], a + dec a + ld de, wPlayerMoveStruct + call GetMoveData + jr .finish_move + +.force_last_enemy_move + push hl + ld a, [wLastEnemyMove] + ld b, a + ld c, 0 + ld hl, wEnemyMonMoves +.find_enemy_move + ld a, [hli] + cp b + jr z, .got_enemy_move + inc c + ld a, c + cp NUM_MOVES + jr c, .find_enemy_move + pop hl + res SUBSTATUS_ENCORED, [hl] + xor a + ld [de], a + jr .failed + +.got_enemy_move + pop hl + ld a, c + ld [wCurEnemyMoveNum], a + ld a, b + ld [wCurEnemyMove], a + dec a + ld de, wEnemyMoveStruct + call GetMoveData + +.finish_move + call AnimateCurrentMove + ld hl, GotAnEncoreText + jp StdBattleTextbox + +.failed + jp PrintDidntAffect2 diff --git a/engine/battle/move_effects/false_swipe.asm b/engine/battle/move_effects/false_swipe.asm new file mode 100644 index 00000000..e2e0c6f1 --- /dev/null +++ b/engine/battle/move_effects/false_swipe.asm @@ -0,0 +1,48 @@ +BattleCommand_FalseSwipe: +; falseswipe + +; Makes sure wCurDamage < MonHP + + ld hl, wEnemyMonHP + ldh a, [hBattleTurn] + and a + jr z, .got_hp + ld hl, wBattleMonHP +.got_hp + ld de, wCurDamage + ld c, 2 + push hl + push de + call CompareBytes + pop de + pop hl + jr c, .done + + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + dec a + ld [de], a + + inc a + jr nz, .okay + dec de + ld a, [de] + dec a + ld [de], a +.okay + + ld a, [wCriticalHit] + cp 2 + jr nz, .carry + xor a + ld [wCriticalHit], a + +.carry + scf + ret + +.done + and a + ret diff --git a/engine/battle/move_effects/heal_bell.asm b/engine/battle/move_effects/heal_bell.asm new file mode 100644 index 00000000..62309f1d --- /dev/null +++ b/engine/battle/move_effects/heal_bell.asm @@ -0,0 +1,34 @@ +BattleCommand_HealBell: +; healbell + + ld a, BATTLE_VARS_SUBSTATUS1 + call GetBattleVarAddr + res SUBSTATUS_NIGHTMARE, [hl] + ld de, wPartyMon1Status + ldh a, [hBattleTurn] + and a + jr z, .got_status + ld de, wOTPartyMon1Status +.got_status + ld a, BATTLE_VARS_STATUS + call GetBattleVarAddr + xor a + ld [hl], a + ld h, d + ld l, e + ld bc, PARTYMON_STRUCT_LENGTH + ld d, PARTY_LENGTH +.loop + ld [hl], a + add hl, bc + dec d + jr nz, .loop + call AnimateCurrentMove + + ld hl, BellChimedText + call StdBattleTextbox + + ldh a, [hBattleTurn] + and a + jp z, CalcPlayerStats + jp CalcEnemyStats diff --git a/engine/battle/move_effects/lock_on.asm b/engine/battle/move_effects/lock_on.asm new file mode 100644 index 00000000..1de3e14b --- /dev/null +++ b/engine/battle/move_effects/lock_on.asm @@ -0,0 +1,21 @@ +BattleCommand_LockOn: +; lockon + + call CheckSubstituteOpp + jr nz, .fail + + ld a, [wAttackMissed] + and a + jr nz, .fail + + ld a, BATTLE_VARS_SUBSTATUS5_OPP + call GetBattleVarAddr + set SUBSTATUS_LOCK_ON, [hl] + call AnimateCurrentMove + + ld hl, TookAimText + jp StdBattleTextbox + +.fail + call AnimateFailedMove + jp PrintDidntAffect diff --git a/engine/battle/move_effects/pain_split.asm b/engine/battle/move_effects/pain_split.asm new file mode 100644 index 00000000..68d7cfb4 --- /dev/null +++ b/engine/battle/move_effects/pain_split.asm @@ -0,0 +1,92 @@ +BattleCommand_PainSplit: +; painsplit + + ld a, [wAttackMissed] + and a + jp nz, .ButItFailed + call CheckSubstituteOpp + jp nz, .ButItFailed + call AnimateCurrentMove + ld hl, wBattleMonMaxHP + 1 + ld de, wEnemyMonMaxHP + 1 + call .PlayerShareHP + ld a, $1 + ld [wWhichHPBar], a + hlcoord 10, 9 + predef AnimateHPBar + ld hl, wEnemyMonHP + ld a, [hli] + ld [wBuffer4], a + ld a, [hli] + ld [wBuffer3], a + ld a, [hli] + ld [wBuffer2], a + ld a, [hl] + ld [wBuffer1], a + call .EnemyShareHP + xor a + ld [wWhichHPBar], a + call ResetDamage + hlcoord 2, 2 + predef AnimateHPBar + + ld hl, SharedPainText + jp StdBattleTextbox + +.PlayerShareHP: + ld a, [hld] + ld [wBuffer1], a + ld a, [hld] + ld [wBuffer2], a + ld a, [hld] + ld b, a + ld [wBuffer3], a + ld a, [hl] + ld [wBuffer4], a + dec de + dec de + ld a, [de] + dec de + add b + ld [wCurDamage + 1], a + ld b, [hl] + ld a, [de] + adc b + srl a + ld [wCurDamage], a + ld a, [wCurDamage + 1] + rr a + ld [wCurDamage + 1], a + inc hl + inc hl + inc hl + inc de + inc de + inc de + +.EnemyShareHP: + ld c, [hl] + dec hl + ld a, [wCurDamage + 1] + sub c + ld b, [hl] + dec hl + ld a, [wCurDamage] + sbc b + jr nc, .skip + + ld a, [wCurDamage] + ld b, a + ld a, [wCurDamage + 1] + ld c, a +.skip + ld a, c + ld [hld], a + ld [wBuffer5], a + ld a, b + ld [hli], a + ld [wBuffer6], a + ret + +.ButItFailed: + jp PrintDidntAffect2 diff --git a/engine/battle/move_effects/sketch.asm b/engine/battle/move_effects/sketch.asm new file mode 100644 index 00000000..654fb3f5 --- /dev/null +++ b/engine/battle/move_effects/sketch.asm @@ -0,0 +1,117 @@ +BattleCommand_Sketch: +; sketch + + call ClearLastMove +; Don't sketch during a link battle + ld a, [wLinkMode] + and a + jr z, .not_linked + call AnimateFailedMove + jp PrintNothingHappened + +.not_linked +; If the opponent has a substitute up, fail. + call CheckSubstituteOpp + jp nz, .fail +; If the opponent is transformed, fail. + ld a, BATTLE_VARS_SUBSTATUS5_OPP + call GetBattleVarAddr + bit SUBSTATUS_TRANSFORMED, [hl] + jp nz, .fail +; Get the user's moveset in its party struct. +; This move replacement shall be permanent. +; Pointer will be in de. + ld a, MON_MOVES + call UserPartyAttr + ld d, h + ld e, l +; Get the battle move structs. + ld hl, wBattleMonMoves + ldh a, [hBattleTurn] + and a + jr z, .get_last_move + ld hl, wEnemyMonMoves +.get_last_move + ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP + call GetBattleVar + ld [wNamedObjectIndexBuffer], a + ld b, a +; Fail if move is invalid or is Struggle. + and a + jr z, .fail + cp STRUGGLE + jr z, .fail +; Fail if user already knows that move + ld c, NUM_MOVES +.does_user_already_know_move + ld a, [hli] + cp b + jr z, .fail + dec c + jr nz, .does_user_already_know_move +; Find Sketch in the user's moveset. +; Pointer in hl, and index in c. + dec hl + ld c, NUM_MOVES +.find_sketch + dec c + ld a, [hld] + cp SKETCH + jr nz, .find_sketch + inc hl +; The Sketched move is loaded to that slot. + ld a, b + ld [hl], a +; Copy the base PP from that move. + push bc + push hl + dec a + ld hl, Moves + MOVE_PP + call GetMoveAttr + pop hl + ld bc, wBattleMonPP - wBattleMonMoves + add hl, bc + ld [hl], a + pop bc + + ldh a, [hBattleTurn] + and a + jr z, .user_trainer + ld a, [wBattleMode] + dec a + jr nz, .user_trainer +; wildmon + ld a, [hl] + push bc + ld hl, wWildMonPP + ld b, 0 + add hl, bc + ld [hl], a + ld hl, wWildMonMoves + add hl, bc + pop bc + ld [hl], b + jr .done_copy + +.user_trainer + ld a, [hl] + push af + ld l, c + ld h, 0 + add hl, de + ld a, b + ld [hl], a + pop af + ld de, MON_PP - MON_MOVES + add hl, de + ld [hl], a +.done_copy + call GetMoveName + call AnimateCurrentMove + + ld hl, SketchedText + jp StdBattleTextbox + +.fail + call AnimateFailedMove + jp PrintDidntAffect diff --git a/engine/battle/move_effects/sleep_talk.asm b/engine/battle/move_effects/sleep_talk.asm new file mode 100644 index 00000000..92bff260 --- /dev/null +++ b/engine/battle/move_effects/sleep_talk.asm @@ -0,0 +1,143 @@ +BattleCommand_SleepTalk: +; sleeptalk + + call ClearLastMove + ld a, [wAttackMissed] + and a + jr nz, .fail + ldh a, [hBattleTurn] + and a + ld hl, wBattleMonMoves + 1 + ld a, [wDisabledMove] + ld d, a + jr z, .got_moves + ld hl, wEnemyMonMoves + 1 + ld a, [wEnemyDisabledMove] + ld d, a +.got_moves + ld a, BATTLE_VARS_STATUS + call GetBattleVar + and SLP + jr z, .fail + ld a, [hl] + and a + jr z, .fail + call .safely_check_has_usable_move + jr c, .fail + dec hl +.sample_move + push hl + call BattleRandom + maskbits NUM_MOVES + ld c, a + ld b, 0 + add hl, bc + ld a, [hl] + pop hl + and a + jr z, .sample_move + ld e, a + ld a, BATTLE_VARS_MOVE_ANIM + call GetBattleVar + cp e + jr z, .sample_move + ld a, e + cp d + jr z, .sample_move + call .check_two_turn_move + jr z, .sample_move + ld a, BATTLE_VARS_MOVE + call GetBattleVarAddr + ld a, e + ld [hl], a + call CheckUserIsCharging + jr nz, .charging + ld a, [wKickCounter] + push af + call BattleCommand_LowerSub + pop af + ld [wKickCounter], a +.charging + call LoadMoveAnim + call UpdateMoveData + jp ResetTurn + +.fail + call AnimateFailedMove + jp TryPrintButItFailed + +.safely_check_has_usable_move + push hl + push de + push bc + call .check_has_usable_move + pop bc + pop de + pop hl + ret + +.check_has_usable_move + ldh a, [hBattleTurn] + and a + ld a, [wDisabledMove] + jr z, .got_move_2 + + ld a, [wEnemyDisabledMove] +.got_move_2 + ld b, a + ld a, BATTLE_VARS_MOVE + call GetBattleVar + ld c, a + dec hl + ld d, NUM_MOVES +.loop2 + ld a, [hl] + and a + jr z, .carry + + cp c + jr z, .nope + cp b + jr z, .nope + + call .check_two_turn_move + jr nz, .no_carry + +.nope + inc hl + dec d + jr nz, .loop2 + +.carry + scf + ret + +.no_carry + and a + ret + +.check_two_turn_move + push hl + push de + push bc + + ld b, a + callfar GetMoveEffect + ld a, b + + pop bc + pop de + pop hl + + cp EFFECT_SKULL_BASH + ret z + cp EFFECT_RAZOR_WIND + ret z + cp EFFECT_SKY_ATTACK + ret z + cp EFFECT_SOLARBEAM + ret z + cp EFFECT_FLY + ret z + cp EFFECT_BIDE + ret diff --git a/engine/battle/move_effects/snore.asm b/engine/battle/move_effects/snore.asm new file mode 100644 index 00000000..e2432c59 --- /dev/null +++ b/engine/battle/move_effects/snore.asm @@ -0,0 +1,11 @@ +BattleCommand_Snore: +; snore + ld a, BATTLE_VARS_STATUS + call GetBattleVar + and SLP + ret nz + call ResetDamage + ld a, $1 + ld [wAttackMissed], a + call FailMove + jp EndMoveEffect diff --git a/engine/battle/move_effects/spite.asm b/engine/battle/move_effects/spite.asm new file mode 100644 index 00000000..06627268 --- /dev/null +++ b/engine/battle/move_effects/spite.asm @@ -0,0 +1,86 @@ +BattleCommand_Spite: +; spite + + ld a, [wAttackMissed] + and a + jp nz, .failed + ld bc, PARTYMON_STRUCT_LENGTH ; ???? + ld hl, wEnemyMonMoves + ldh a, [hBattleTurn] + and a + jr z, .got_moves + ld hl, wBattleMonMoves +.got_moves + ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP + call GetBattleVar + and a + jr z, .failed + cp STRUGGLE + jr z, .failed + ld b, a + ld c, -1 +.loop + inc c + ld a, [hli] + cp b + jr nz, .loop + ld [wNamedObjectIndexBuffer], a + dec hl + ld b, 0 + push bc + ld c, wBattleMonPP - wBattleMonMoves + add hl, bc + pop bc + ld a, [hl] + and PP_MASK + jr z, .failed + push bc + call GetMoveName + ; lose 2-5 PP + call BattleRandom + and %11 + inc a + inc a + ld b, a + ld a, [hl] + and PP_MASK + cp b + jr nc, .deplete_pp + ld b, a +.deplete_pp + ld a, [hl] + sub b + ld [hl], a + push af + ld a, MON_PP + call OpponentPartyAttr + ld d, b + pop af + pop bc + add hl, bc + ld e, a + ld a, BATTLE_VARS_SUBSTATUS5_OPP + call GetBattleVar + bit SUBSTATUS_TRANSFORMED, a + jr nz, .transformed + ldh a, [hBattleTurn] + and a + jr nz, .not_wildmon + ld a, [wBattleMode] + dec a + jr nz, .not_wildmon + ld hl, wWildMonPP + add hl, bc +.not_wildmon + ld [hl], e +.transformed + push de + call AnimateCurrentMove + pop de + ld a, d + ld [wDeciramBuffer], a + ld hl, SpiteEffectText + jp StdBattleTextbox + +.failed + jp PrintDidntAffect2 |