shithub: pokecrystal

Download patch

ref: 0cce00cb73849dc761bb36b302305c55ff2d54e4
parent: 447da806153d2c56d15a8775ab43511202b269bc
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Fri Feb 28 06:17:58 EST 2020

Document a bug where Teleport cannot fail for wild Pokémon

--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -30,6 +30,7 @@
 - [A Disabled but PP Up–enhanced move may not trigger Struggle](#a-disabled-but-pp-upenhanced-move-may-not-trigger-struggle)
 - [A Pokémon that fainted from Pursuit will have its old status condition when revived](#a-pokémon-that-fainted-from-pursuit-will-have-its-old-status-condition-when-revived)
 - [Lock-On and Mind Reader don't always bypass Fly and Dig](#lock-on-and-mind-reader-dont-always-bypass-fly-and-dig)
+- [Wild Pokémon can always Teleport regardless of level difference](#wild-pokémon-can-always-teleport-regardless-of-level-difference)
 - [Beat Up can desynchronize link battles](#beat-up-can-desynchronize-link-battles)
 - [Beat Up works incorrectly with only one Pokémon in the party](#beat-up-works-incorrectly-with-only-one-pokémon-in-the-party)
 - [Beat Up may fail to raise Substitute](#beat-up-may-fail-to-raise-substitute)
@@ -690,6 +691,25 @@
 -	and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
 +	xor a
  	ret
+```
+
+
+## Wild Pokémon can always Teleport regardless of level difference
+
+**Fix:** Edit `BattleCommand_Teleport` in [engine/battle/move_effects/teleport.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/move_effects/teleport.asm):
+
+```diff
+ .loop_enemy
+ 	call BattleRandom
+ 	cp c
+ 	jr nc, .loop_enemy
+ 	srl b
+ 	srl b
+ 	cp b
+-	; This should be jr c, .failed
+-	; As written, it makes enemy use of Teleport always succeed if able
+-	jr nc, .run_away
++	jr c, .failed
 ```
 
 
--- a/engine/battle/move_effects/teleport.asm
+++ b/engine/battle/move_effects/teleport.asm
@@ -66,10 +66,8 @@
 	srl b
 	srl b
 	cp b
-	; This does the wrong thing. What was
-	; probably intended was jr c, .failed
-	; The way this is made makes enemy use
-	; of Teleport always succeed if able
+	; This should be jr c, .failed
+	; As written, it makes enemy use of Teleport always succeed if able
 	jr nc, .run_away
 .run_away
 	call UpdateBattleMonInParty