shithub: pokered

Download patch

ref: 319c29c751ea23bed8d57587500e73bb2a599656
parent: 9c93fb0b7559e9d657a91d2b508ecebe58eee544
author: SnorlaxMonster <snorlaxmonster+github@gmail.com>
date: Mon Jun 14 17:47:19 EDT 2021

Correct comments on SwitchAndTeleportEffect

The comments in the SwitchAndTeleportEffect section incorrectly stated
that the random number was generated in the
half-open interval [0, playerLevel + enemyLevel),
instead of the closed interval [0, playerLevel + enemyLevel].

--- a/engine/battle/effects.asm
+++ b/engine/battle/effects.asm
@@ -819,7 +819,7 @@
 	jr nc, .playerMoveWasSuccessful ; if so, teleport will always succeed
 	add b
 	ld c, a
-	inc c ; c = sum of player level and enemy level
+	inc c ; c = playerLevel + enemyLevel + 1
 .rejectionSampleLoop1
 	call BattleRandom
 	cp c ; get a random number between 0 and c
@@ -826,7 +826,7 @@
 	jr nc, .rejectionSampleLoop1
 	srl b
 	srl b  ; b = enemyLevel / 4
-	cp b ; is rand[0, playerLevel + enemyLevel) >= (enemyLevel / 4)?
+	cp b ; is rand[0, playerLevel + enemyLevel] >= (enemyLevel / 4)?
 	jr nc, .playerMoveWasSuccessful ; if so, allow teleporting
 	ld c, 50
 	call DelayFrames