Skip to content

Swift will not hit through fly or dig

Xillicis edited this page Feb 5, 2023 · 1 revision

In generation 1, the move Swift can still hit even if a Pokemon has used fly or dig. This is because the subroutine, MoveHitTest handles Swift before it checks the invulnerable state of Fly and Dig. The fix is somewhat simple, we just need to make the check for invulnerability before the check for swift. Open up engine/battle/core.asm and make the following changes to the subroutine MoveHitTest. Or better yet, try to do it yourself, and if you're having trouble, then check this tutorial.

...
.dreamEaterCheck
	ld a, [de]
	cp DREAM_EATER_EFFECT
-	jr nz, .swiftCheck
+	jr nz, .checkForDigOrFlyStatus
	ld a, [bc]
	and SLP_MASK
	jp z, .moveMissed
+.checkForDigOrFlyStatus
+	bit INVULNERABLE, [hl]
+	jp nz, .moveMissed
.swiftCheck
	ld a, [de]
	cp SWIFT_EFFECT
	ret z ; Swift never misses (this was fixed from the Japanese versions)
	call CheckTargetSubstitute ; substitute check (note that this overwrites a)
-	jr z, .checkForDigOrFlyStatus
+	jr z, .noSubstitute
; The fix for Swift broke this code. It's supposed to prevent HP draining moves from working on Substitutes.
; Since CheckTargetSubstitute overwrites a with either $00 or $01, it never works.
	cp DRAIN_HP_EFFECT
	jp z, .moveMissed
	cp DREAM_EATER_EFFECT
	jp z, .moveMissed
+.noSubstitute
-.checkForDigOrFlyStatus
-	bit INVULNERABLE, [hl]
-	jp nz, .moveMissed
	ldh a, [hWhoseTurn]
	and a
	jr nz, .enemyTurn
.playerTurn
...

That's all.

Clone this wiki locally