diff --git a/engine/battle/core.asm b/engine/battle/core.asm index e229b421b..55b896293 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -1982,6 +1982,7 @@ GetTwoThirdsMaxHP: ld [hDivisor], a ld b, 2 call Divide +GetTwoThirdsMaxHP_end: ld a, [hQuotient + 2] ld b, a ld a, [hQuotient + 3] @@ -1993,6 +1994,19 @@ GetTwoThirdsMaxHP: .ok ret +GetOneSixthMaxHP: + call GetMaxHP + + ld a, b + ld [hDividend + 0], a + ld a, c + ld [hDividend + 1], a + ld a, 6 + ld [hDivisor], a + ld b, 2 + call Divide + jr GetTwoThirdsMaxHP_end + GetMaxHP: ; output: bc, wHPBuffer1 @@ -4242,6 +4256,22 @@ BreakAttraction: res SUBSTATUS_IN_LOVE, [hl] ret +GetSpikesDamage: + dec a + jr z, .one ; one spikes set + dec a + jr z, .two ; two spikes set +; assume three spikes set +.three + call GetQuarterMaxHP + ret +.two + call GetOneSixthMaxHP + ret +.one + call GetEighthMaxHP + ret + SpikesDamage: ld hl, wPlayerScreens ld de, wBattleMonType @@ -4254,7 +4284,9 @@ SpikesDamage: ld bc, UpdateEnemyHUD .ok - bit SCREENS_SPIKES, [hl] + ld a, [hl] + and 3 + ; return if zero spikes set ret z ; Flying-types aren't affected by Spikes. @@ -4267,11 +4299,15 @@ SpikesDamage: ret z push bc + push hl ld hl, BattleText_UserHurtBySpikes ; "hurt by SPIKES!" call StdBattleTextbox - call GetEighthMaxHP + pop hl + ld a, [hl] + and 3 + call GetSpikesDamage call SubtractHPFromTarget pop hl diff --git a/engine/battle/move_effects/rapid_spin.asm b/engine/battle/move_effects/rapid_spin.asm index beac7af45..d63ca9896 100644 --- a/engine/battle/move_effects/rapid_spin.asm +++ b/engine/battle/move_effects/rapid_spin.asm @@ -16,9 +16,12 @@ BattleCommand_ClearHazards: ld hl, wEnemyScreens ld de, wEnemyWrapCount .got_screens_wrap - bit SCREENS_SPIKES, [hl] + ld a, [hl] + and 3 jr z, .no_spikes - res SCREENS_SPIKES, [hl] + ld a, [hl] + and $fc ; Clear spike bits + ld [hl], a ld hl, BlewSpikesText push de call StdBattleTextbox diff --git a/engine/battle/move_effects/spikes.asm b/engine/battle/move_effects/spikes.asm index 24683cc59..d25818f28 100644 --- a/engine/battle/move_effects/spikes.asm +++ b/engine/battle/move_effects/spikes.asm @@ -8,12 +8,21 @@ BattleCommand_Spikes: ; Fails if spikes are already down! - bit SCREENS_SPIKES, [hl] - jr nz, .failed + ld a, [hl] + and 3 + cp 3 + jr nc, .failed ; Nothing else stops it from working. - set SCREENS_SPIKES, [hl] + push bc + inc a + ld b, a + ld a, [hl] + and $fc + or b + ld [hl], a + pop bc call AnimateCurrentMove