Fix No Mon Scenarios Softlock - pret/pokered GitHub Wiki

  1. Don't start wild Pokémon battles, if the player doesn't have any Pokémon:

TryDoWildEncounter in engine\battle\wild_encounter.asm

; try to initiate a wild pokemon encounter
; returns success in Z
TryDoWildEncounter:
+	ld a, [wPartyCount]
+	and a
+	jp z, .CantEncounter
	ld a, [wNPCMovementScriptPointerTableNum]
	and a
	ret nz
...
  1. Don't heal Pokémon in Pokémon Centres if the player doesn't have any Pokémon:

DisplayPokemonCenterDialogue_ in engine\events\pokecenter.asm

DisplayPokemonCenterDialogue_::
	call SaveScreenTilesToBuffer1 ; save screen
	ld hl, PokemonCenterWelcomeText
	call PrintText
+	ld a, [wPartyCount]
+	and a
+	jp z, .naotenho
	ld hl, wd72e
	bit 2, [hl]
	set 1, [hl]
...
...
	ld hl, PokemonCenterFarewellText
	call PrintText
	jp UpdateSprites
+.naotenho
+	ld hl, TemPokemonOuNao
+	jp PrintText

+TemPokemonOuNao:
+	text_far _TemPokemonOuNao
+	text_end

PokemonCenterWelcomeText:
	text_far _PokemonCenterWelcomeText
...

data\text\text_4.asm

...
_NeedYourPokemonText::
	text "OK. We'll need"
	line "your #MON."
	done

+_TemPokemonOuNao::
+	text "You don't have"
+	line "any #MON!"
+	done

_PokemonFightingFitText::
	text "Thank you!"
	line "Your #MON are"
...

3.1. Don't start trainer battles if the player doesn't have any Pokémon:

CheckFightingMapTrainers in home\trainers.asm

...
; checks if any trainers are seeing the player and wanting to fight
CheckFightingMapTrainers::
IF DEF(_DEBUG)
	call DebugPressedOrHeldB
	jr nz, .trainerNotEngaging
ENDC
+	ld a, [wPartyCount]
+	and a
+	jp z, .trainerNotEngaging
	call CheckForEngagingTrainers
	ld a, [wSpriteIndex]
	cp $ff
...

3.2 When you talk to a trainer, they'll display their AfterBattleText instead of starting a battle if you don't have Pokémon:

TalkToTrainer::
	call StoreTrainerHeaderPointer
	xor a
	call ReadTrainerHeaderInfo     ; read flag's bit
	ld a, $2
	call ReadTrainerHeaderInfo     ; read flag's byte ptr
+	ld a, [wPartyCount]
+	and a
+	jr z, .SeNaoTemMonAfterBattleText
	ld a, [wTrainerHeaderFlagBit]
	ld c, a
	ld b, FLAG_TEST
	call TrainerFlagAction      ; read trainer's flag
	ld a, c
	and a
	jr z, .trainerNotYetFought     ; test trainer's flag
+.SeNaoTemMonAfterBattleText
	ld a, $6
	call ReadTrainerHeaderInfo     ; print after battle text
	jp PrintText
...