Entering battle without pokémon triggers blackout

This commit is contained in:
JappaWakka 2023-02-26 17:16:39 +01:00
parent 022597262c
commit 2f0cccb052
4 changed files with 65 additions and 53 deletions

View File

@ -77,16 +77,24 @@
Screen.Level.World.Initialize(Screen.Level.EnvironmentType, Screen.Level.WeatherType)
Dim positionString() As String = Core.Player.LastRestPlacePosition.Split(CChar(","))
CType(BattleScreen.SavedOverworld.Camera, OverworldCamera).YawLocked = False
If PreScreen.Identification = Identifications.BattleScreen Then
CType(BattleScreen.SavedOverworld.Camera, OverworldCamera).YawLocked = False
Else
CType(Screen.Camera, OverworldCamera).YawLocked = False
End If
Screen.Camera.Yaw = MathHelper.Pi
Screen.Camera.Position = New Vector3(CSng(positionString(0).Replace(".", GameController.DecSeparator)), CSng(positionString(1).Replace(".", GameController.DecSeparator)), CSng(positionString(2).Replace(".", GameController.DecSeparator)))
CType(BattleScreen.SavedOverworld.OverworldScreen, OverworldScreen).ActionScript.Scripts.Clear()
If PreScreen.Identification = Identifications.BattleScreen Then
CType(BattleScreen.SavedOverworld.OverworldScreen, OverworldScreen).ActionScript.Scripts.Clear()
Else
CType(PreScreen, OverworldScreen).ActionScript.Scripts.Clear()
End If
While Core.CurrentScreen.Identification <> Identifications.OverworldScreen
Core.SetScreen(Core.CurrentScreen.PreScreen)
End While
Core.SetScreen(Core.CurrentScreen.PreScreen)
End While
End If
End If
End If
End If
End If
End Sub

View File

@ -52,7 +52,7 @@
CanContinue = False
Else
IsReady = True
Core.SetScreen(New TransitionScreen(Core.CurrentScreen, New BlackOutScreen(Core.CurrentScreen), Color.Black, False))
End If
Case "trainer"
If Core.Player.Pokemons.Count > 0 Then
@ -92,7 +92,7 @@
CanContinue = False
Else
IsReady = True
Core.SetScreen(New TransitionScreen(Core.CurrentScreen, New BlackOutScreen(Core.CurrentScreen), Color.Black, False))
End If
Case "wild"
' ID, Level, [shiny], [musicloop], [introtype]
@ -177,7 +177,7 @@
CanContinue = False
Else
IsReady = True
Core.SetScreen(New TransitionScreen(Core.CurrentScreen, New BlackOutScreen(Core.CurrentScreen), Color.Black, False))
End If
Case "setvar"
Dim varname As String = argument.GetSplit(0)

View File

@ -849,9 +849,7 @@ Public Class Level
Me._backdropRenderer.Update()
Me.UpdatePlayerWarp()
If Core.Player.Pokemons.Count > 0 Then
Me._pokemonEncounter.TriggerBattle()
End If
Me._pokemonEncounter.TriggerBattle()
' Reload map from file (Debug or Sandbox Mode):
If GameController.IS_DEBUG_ACTIVE = True Or Core.Player.SandBoxMode = True Then

View File

@ -116,61 +116,67 @@ Public Class PokemonEncounter
Public Sub TriggerBattle()
' If the encounter check is true:
If Me._levelReference.PokemonEncounterData.EncounteredPokemon = True And Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
' If the player met the set position:
If Screen.Camera.Position.X = Me._levelReference.PokemonEncounterData.Position.X And Screen.Camera.Position.Z = Me._levelReference.PokemonEncounterData.Position.Z Then
' Make the player stop and set encounter check to false:
If Core.Player.Pokemons.Count = 0 Then
Core.SetScreen(New TransitionScreen(Core.CurrentScreen, New BlackOutScreen(Core.CurrentScreen), Color.Black, False))
Me._levelReference.PokemonEncounterData.EncounteredPokemon = False
Screen.Camera.StopMovement()
Exit Sub
Else
' If the player met the set position:
If Screen.Camera.Position.X = Me._levelReference.PokemonEncounterData.Position.X And Screen.Camera.Position.Z = Me._levelReference.PokemonEncounterData.Position.Z Then
' Make the player stop and set encounter check to false:
Me._levelReference.PokemonEncounterData.EncounteredPokemon = False
Screen.Camera.StopMovement()
' Generate new wild Pokémon:
Dim Pokemon As Pokemon = Spawner.GetPokemon(Screen.Level.LevelFile, Me._levelReference.PokemonEncounterData.Method, True, Me._levelReference.PokemonEncounterData.PokeFile)
' Generate new wild Pokémon:
Dim Pokemon As Pokemon = Spawner.GetPokemon(Screen.Level.LevelFile, Me._levelReference.PokemonEncounterData.Method, True, Me._levelReference.PokemonEncounterData.PokeFile)
If Not Pokemon Is Nothing And CType(Core.CurrentScreen, OverworldScreen).TrainerEncountered = False And CType(Core.CurrentScreen, OverworldScreen).ActionScript.IsReady = True Then
Screen.Level.RouteSign.Hide() ' When a battle starts, hide the Route sign.
If Not Pokemon Is Nothing And CType(Core.CurrentScreen, OverworldScreen).TrainerEncountered = False And CType(Core.CurrentScreen, OverworldScreen).ActionScript.IsReady = True Then
Screen.Level.RouteSign.Hide() ' When a battle starts, hide the Route sign.
' If the player has a Repel going and the first Pokémon in the party's level is greater than the wild Pokémon's level, don't start the battle:
If Core.Player.RepelSteps > 0 Then
Dim p As Pokemon = Core.Player.GetWalkPokemon()
If Not p Is Nothing Then
If p.Level >= Pokemon.Level Then
Exit Sub
End If
End If
End If
' Cleanse Tag prevents wild Pokémon encounters if held by the first Pokémon in the party:
If Core.Player.Pokemons(0).Level >= Pokemon.Level Then
If Not Core.Player.Pokemons(0).Item Is Nothing Then
If Core.Player.Pokemons(0).Item.ID = 94 Then
If Core.Random.Next(0, 3) = 0 Then
' If the player has a Repel going and the first Pokémon in the party's level is greater than the wild Pokémon's level, don't start the battle:
If Core.Player.RepelSteps > 0 Then
Dim p As Pokemon = Core.Player.GetWalkPokemon()
If Not p Is Nothing Then
If p.Level >= Pokemon.Level Then
Exit Sub
End If
End If
End If
End If
' Pure Incense lowers the chance of encountering wild Pokémon if held by the first Pokémon in the party:
If Core.Player.Pokemons(0).Level >= Pokemon.Level Then
If Not Core.Player.Pokemons(0).Item Is Nothing Then
If Core.Player.Pokemons(0).Item.ID = 291 Then
If Core.Random.Next(0, 3) = 0 Then
Exit Sub
' Cleanse Tag prevents wild Pokémon encounters if held by the first Pokémon in the party:
If Core.Player.Pokemons(0).Level >= Pokemon.Level Then
If Not Core.Player.Pokemons(0).Item Is Nothing Then
If Core.Player.Pokemons(0).Item.ID = 94 Then
If Core.Random.Next(0, 3) = 0 Then
Exit Sub
End If
End If
End If
End If
' Pure Incense lowers the chance of encountering wild Pokémon if held by the first Pokémon in the party:
If Core.Player.Pokemons(0).Level >= Pokemon.Level Then
If Not Core.Player.Pokemons(0).Item Is Nothing Then
If Core.Player.Pokemons(0).Item.ID = 291 Then
If Core.Random.Next(0, 3) = 0 Then
Exit Sub
End If
End If
End If
End If
' Register the wild Pokémon as Seen in the Pokédex:
Core.Player.PokedexData = Pokedex.ChangeEntry(Core.Player.PokedexData, Pokemon.Number, 1)
' Determine wild Pokémon intro type. If it's a Roaming Pokémon battle, set to 12:
Dim introType As Integer = Core.Random.Next(0, 10)
If BattleSystem.BattleScreen.RoamingBattle = True Then
introType = 12
End If
Dim b As New BattleSystem.BattleScreen(Pokemon, Core.CurrentScreen, Me._levelReference.PokemonEncounterData.Method)
Core.SetScreen(New BattleIntroScreen(Core.CurrentScreen, b, introType))
End If
' Register the wild Pokémon as Seen in the Pokédex:
Core.Player.PokedexData = Pokedex.ChangeEntry(Core.Player.PokedexData, Pokemon.Number, 1)
' Determine wild Pokémon intro type. If it's a Roaming Pokémon battle, set to 12:
Dim introType As Integer = Core.Random.Next(0, 10)
If BattleSystem.BattleScreen.RoamingBattle = True Then
introType = 12
End If
Dim b As New BattleSystem.BattleScreen(Pokemon, Core.CurrentScreen, Me._levelReference.PokemonEncounterData.Method)
Core.SetScreen(New BattleIntroScreen(Core.CurrentScreen, b, introType))
End If
End If
End If