Skip to content

Turn to face enemy trainers when seen by them

Rangi edited this page Apr 15, 2021 · 4 revisions

In all the Pokémon games after Gen 1 (with the exception of FireRed/LeafGreen, who wanted to mimic Gen 1 in this way) the player turns to face an enemy trainer after they see you and walk up to you. Have you ever wanted that to happen in your hack of Red and Blue? It's fairly simple to.

First off, let's go to engine/overworld/trainer_sight.asm and add a small routine at the end of the file.


FaceEnemyTrainer::
	ld a, [wTrainerFacingDirection]
	and a ; SPRITE_FACING_DOWN
	jr z, .facingDown
	cp SPRITE_FACING_UP
	jr z, .facingUp
	cp SPRITE_FACING_LEFT
	jr z, .facingLeft
; facing right
	ld a, PLAYER_DIR_LEFT
	jr .done
.facingDown
	ld a, PLAYER_DIR_UP
	jr .done
.facingUp
	ld a, PLAYER_DIR_DOWN
	jr .done
.facingLeft
	ld a, PLAYER_DIR_RIGHT
.done
	ld [wPlayerMovingDirection], a ; update player facing
	ret

Basically, this routine just checks which direction the enemy trainer is facing, then updates the player's facing direction accordingly, so that the player turns toward the enemy trainer.

Next, we have to actually call this routine for it to take effect. So take a look in home/trainers.asm and find the routine called CheckFightingMapTrainers:: and change this line accordingly:

	xor a ; EXCLAMATION_BUBBLE
	ld [wWhichEmotionBubble], a
	predef EmotionBubble
-	ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN
+	ld a, $ff
	ld [wJoyIgnore], a

We want to ignore all input, not just the arrow keys, because in some situations (such as the final trainer in Viridian Forest) pressing "A" can cause interference as well, since there is a hidden item nearby. And let's face it, players are likely to be spamming "A" while this code is running. So we nip that problem in the bud with this change.

Then scroll down a little to find DisplayEnemyTrainerTextAndStartBattle:: and edit it like so:

	ret nz ; return if the enemy trainer hasn't finished walking to the player's sprite
+	farcall FaceEnemyTrainer
+	xor a
	ld [wJoyIgnore], a
	ld a, [wSpriteIndex]

This calls the new routine we wrote before, and continues on with the original code as if nothing ever happened. And it's as simple as that! Now when a trainer spots you and walks up to challenge you, you will turn to look at them before they start talking to you and start the battle, just like they do in every other Pokémon game that isn't Gen 1 or its remakes.

Clone this wiki locally