Prevent wild & trainer battles without pokémon

when the player has no Pokémon in their team, wild and trainer battle commands don't do anything
This commit is contained in:
JappaWakka 2023-02-26 15:26:07 +01:00
parent 94247a7754
commit daef33a886
2 changed files with 132 additions and 119 deletions

View File

@ -12,162 +12,173 @@
Select Case command.ToLower() Select Case command.ToLower()
Case "starttrainer" Case "starttrainer"
Dim t As New Trainer(argument) If Core.Player.Pokemons.Count > 0 Then
If t.IsBeaten() = False Then Dim t As New Trainer(argument)
If ScriptV2.started = False Then If t.IsBeaten() = False Then
CType(Core.CurrentScreen, OverworldScreen).TrainerEncountered = True If ScriptV2.started = False Then
CType(Core.CurrentScreen, OverworldScreen).TrainerEncountered = True
If t.GetInSightMusic() <> "" And t.GetInSightMusic() <> "nomusic" Then If t.GetInSightMusic() <> "" And t.GetInSightMusic() <> "nomusic" Then
MusicManager.Play(t.GetInSightMusic(), True, 0.0F) MusicManager.Play(t.GetInSightMusic(), True, 0.0F)
End If End If
If t.IntroMessage <> "" Then If t.IntroMessage <> "" Then
Screen.TextBox.reDelay = 0.0F Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(t.IntroMessage, {}) Screen.TextBox.Show(t.IntroMessage, {})
End If
ScriptV2.started = True
End If End If
ScriptV2.started = True If Screen.TextBox.Showing = False Then
CType(Core.CurrentScreen, OverworldScreen).TrainerEncountered = False
Dim method As Integer = 0
If Screen.Level.Surfing = True Then
method = 2
End If
Dim b As New BattleSystem.BattleScreen(New Trainer(argument), Core.CurrentScreen, method)
Core.SetScreen(New BattleIntroScreen(Core.CurrentScreen, b, t, t.GetIniMusicName(), t.IntroType))
End If
Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(t.DefeatMessage, {})
IsReady = True
End If End If
If Screen.TextBox.Showing = False Then If Screen.TextBox.Showing = False Then
CType(Core.CurrentScreen, OverworldScreen).TrainerEncountered = False IsReady = True
Dim method As Integer = 0
If Screen.Level.Surfing = True Then
method = 2
End If
Dim b As New BattleSystem.BattleScreen(New Trainer(argument), Core.CurrentScreen, method)
Core.SetScreen(New BattleIntroScreen(Core.CurrentScreen, b, t, t.GetIniMusicName(), t.IntroType))
End If End If
CanContinue = False
Else Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(t.DefeatMessage, {})
IsReady = True IsReady = True
End If End If
If Screen.TextBox.Showing = False Then
IsReady = True
End If
CanContinue = False
Case "trainer" Case "trainer"
Dim ID As String = argument If Core.Player.Pokemons.Count > 0 Then
Dim ID As String = argument
If argument.CountSeperators(",") > 0 Then If argument.CountSeperators(",") > 0 Then
ID = argument.GetSplit(0) ID = argument.GetSplit(0)
For Each v As String In argument.Split(CChar(",")) For Each v As String In argument.Split(CChar(","))
Select Case v Select Case v
Case "generate_pokemon_tower" Case "generate_pokemon_tower"
Dim level As Integer = 0 Dim level As Integer = 0
For Each p As Pokemon In Core.Player.Pokemons For Each p As Pokemon In Core.Player.Pokemons
If p.Level > level Then If p.Level > level Then
level = p.Level level = p.Level
End If End If
Next Next
While CStr(level)(CStr(level).Length - 1) <> "0" While CStr(level)(CStr(level).Length - 1) <> "0"
level += 1 level += 1
End While End While
End Select End Select
Next Next
End If
Dim t As New Trainer(ID)
Dim method As Integer = 0
If Screen.Level.Surfing = True Then
method = 2
End If
Dim b As New BattleSystem.BattleScreen(t, Core.CurrentScreen, method)
Core.SetScreen(New BattleIntroScreen(Core.CurrentScreen, b, t, t.GetIniMusicName(), t.IntroType))
IsReady = True
CanContinue = False
Else
IsReady = True
End If End If
Dim t As New Trainer(ID)
Dim method As Integer = 0
If Screen.Level.Surfing = True Then
method = 2
End If
Dim b As New BattleSystem.BattleScreen(t, Core.CurrentScreen, method)
Core.SetScreen(New BattleIntroScreen(Core.CurrentScreen, b, t, t.GetIniMusicName(), t.IntroType))
IsReady = True
CanContinue = False
Case "wild" Case "wild"
' ID, Level, [shiny], [musicloop], [introtype] ' ID, Level, [shiny], [musicloop], [introtype]
' int int -1 or bool string int ' int int -1 or bool string int
' optional: ' optional:
' {pokemondata}, [musicloop], [introtype] ' {pokemondata}, [musicloop], [introtype]
If Core.Player.Pokemons.Count > 0 Then
Dim p As Pokemon = Nothing
Dim musicLoop As String = ""
Dim introType As Integer = Core.Random.Next(0, 10)
Dim p As Pokemon = Nothing Dim method As Integer = 0
Dim musicLoop As String = "" If Screen.Level.Surfing = True Then
Dim introType As Integer = Core.Random.Next(0, 10) method = 2
End If
Dim method As Integer = 0 If argument.StartsWith("{") = True And argument.Contains("}") = True Then
If Screen.Level.Surfing = True Then If argument.EndsWith("}") = True Then
method = 2 p = Pokemon.GetPokemonByData(argument)
End If Else
Dim pokemonData As String = argument.Remove(argument.LastIndexOf("}") + 1)
p = Pokemon.GetPokemonByData(pokemonData)
If argument.StartsWith("{") = True And argument.Contains("}") = True Then argument = argument.Remove(0, argument.LastIndexOf("}") + 1)
If argument.EndsWith("}") = True Then
p = Pokemon.GetPokemonByData(argument) If argument.Length > 1 And argument.StartsWith(",") = True Then
argument = argument.Remove(0, 1)
Dim args() As String = argument.Split(CChar(","))
For i = 0 To args.Length - 1
Select Case i
Case 0
musicLoop = args(i)
Case 1
introType = int(args(i))
End Select
Next
End If
End If
Else Else
Dim pokemonData As String = argument.Remove(argument.LastIndexOf("}") + 1) If argument.Length > 0 Then
p = Pokemon.GetPokemonByData(pokemonData) Dim ID As Integer = int(argument.GetSplit(0).Split(CChar("_"))(0))
Dim AD As String = ""
If argument.GetSplit(0).Contains(CChar("_")) Then
AD = argument.GetSplit(0).Split(CChar("_"))(1)
End If
Dim Level As Integer = int(argument.GetSplit(1))
If AD IsNot "" Then
p = Pokemon.GetPokemonByID(ID, AD)
p.Generate(Level, True, AD)
Else
p = Pokemon.GetPokemonByID(ID)
p.Generate(Level, True)
End If
argument = argument.Remove(0, argument.LastIndexOf("}") + 1)
If argument.Length > 1 And argument.StartsWith(",") = True Then
argument = argument.Remove(0, 1)
Dim args() As String = argument.Split(CChar(",")) Dim args() As String = argument.Split(CChar(","))
For i = 0 To args.Length - 1 For i = 0 To args.Length - 1
Select Case i Select Case i
Case 0 Case 2
If args(i) <> "-1" Then
p.IsShiny = CBool(args(i))
End If
Case 3
musicLoop = args(i) musicLoop = args(i)
Case 1 Case 4
introType = int(args(i)) introType = int(args(i))
End Select End Select
Next Next
End If End If
End If End If
Core.Player.PokedexData = Pokedex.ChangeEntry(Core.Player.PokedexData, p.Number, 1)
Dim b As New BattleSystem.BattleScreen(p, Core.CurrentScreen, method)
Core.SetScreen(New BattleIntroScreen(Core.CurrentScreen, b, introType, musicLoop))
IsReady = True
CanContinue = False
Else Else
If argument.Length > 0 Then IsReady = True
Dim ID As Integer = int(argument.GetSplit(0).Split(CChar("_"))(0))
Dim AD As String = ""
If argument.GetSplit(0).Contains(CChar("_")) Then
AD = argument.GetSplit(0).Split(CChar("_"))(1)
End If
Dim Level As Integer = int(argument.GetSplit(1))
If AD IsNot "" Then
p = Pokemon.GetPokemonByID(ID, AD)
p.Generate(Level, True, AD)
Else
p = Pokemon.GetPokemonByID(ID)
p.Generate(Level, True)
End If
Dim args() As String = argument.Split(CChar(","))
For i = 0 To args.Length - 1
Select Case i
Case 2
If args(i) <> "-1" Then
p.IsShiny = CBool(args(i))
End If
Case 3
musicLoop = args(i)
Case 4
introType = int(args(i))
End Select
Next
End If
End If End If
Core.Player.PokedexData = Pokedex.ChangeEntry(Core.Player.PokedexData, p.Number, 1)
Dim b As New BattleSystem.BattleScreen(p, Core.CurrentScreen, method)
Core.SetScreen(New BattleIntroScreen(Core.CurrentScreen, b, introType, musicLoop))
IsReady = True
CanContinue = False
Case "setvar" Case "setvar"
Dim varname As String = argument.GetSplit(0) Dim varname As String = argument.GetSplit(0)
Dim varvalue As String = argument.GetSplit(1) Dim varvalue As String = argument.GetSplit(1)

View File

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