From 88d72bb45114e6b2f252265313e2e7602ea02cf2 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Tue, 2 Apr 2024 11:06:33 +0200 Subject: [PATCH] Implemented script after catch or defeat roamer --- P3D/Battle/BattleSystemV2/BattleScreen.vb | 3 +++ P3D/Overworld/OverworldScreen.vb | 5 +++++ P3D/Pokemon/Monster/RoamingPokemon.vb | 16 +++++++++++++--- P3D/Pokemon/Wild/Spawner.vb | 2 +- .../ActionScript/V2/ScriptCommands/DoPokemon.vb | 7 ++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/P3D/Battle/BattleSystemV2/BattleScreen.vb b/P3D/Battle/BattleSystemV2/BattleScreen.vb index 41dbb740c..46a536599 100644 --- a/P3D/Battle/BattleSystemV2/BattleScreen.vb +++ b/P3D/Battle/BattleSystemV2/BattleScreen.vb @@ -1276,6 +1276,9 @@ nextIndex: 'Shift the Roaming Pokemon. If RoamingBattle = True Then If FieldEffects.RoamingFled = False AndAlso Battle.Fled = False AndAlso Battle.Caught = True Or OppPokemon.HP <= 0 Or OppPokemon.Status = Pokemon.StatusProblems.Fainted Then + If RoamingPokemonStorage.ScriptPath <> "" Then + CType(SavedOverworld.OverworldScreen, OverworldScreen).AfterRoamingBattleScript = RoamingPokemonStorage.ScriptPath + End If Core.Player.RoamingPokemonData = RoamingPokemon.RemoveRoamingPokemon(RoamingPokemonStorage) Else Core.Player.RoamingPokemonData = RoamingPokemon.ReplaceRoamingPokemon(RoamingPokemonStorage) diff --git a/P3D/Overworld/OverworldScreen.vb b/P3D/Overworld/OverworldScreen.vb index 68e12bef6..d8c5763eb 100644 --- a/P3D/Overworld/OverworldScreen.vb +++ b/P3D/Overworld/OverworldScreen.vb @@ -24,6 +24,7 @@ Public Class OverworldScreen ''' The delay until the XBOX buttons get shown since the player last pressed a button. ''' Private ShowControlsDelay As Single = 4.0F + Public AfterRoamingBattleScript As String = "" #End Region @@ -468,6 +469,10 @@ Public Class OverworldScreen MusicManager.Play(theme, True) 'remove when debugging music End If End If + If AfterRoamingBattleScript <> "" Then + ActionScript.StartScript(AfterRoamingBattleScript, 0,,, "AfterRoamingBattleScript") + AfterRoamingBattleScript = "" + End If End Sub ''' diff --git a/P3D/Pokemon/Monster/RoamingPokemon.vb b/P3D/Pokemon/Monster/RoamingPokemon.vb index 464a35c36..2bdd70e11 100644 --- a/P3D/Pokemon/Monster/RoamingPokemon.vb +++ b/P3D/Pokemon/Monster/RoamingPokemon.vb @@ -4,6 +4,7 @@ Public Class RoamingPokemon Public LevelFile As String = "" Public MusicLoop As String = "" Public PokemonReference As Pokemon = Nothing + Public ScriptPath As String = "" Public Sub New(ByVal DataLine As String) Dim data() As String = DataLine.Split(CChar("|")) @@ -13,6 +14,10 @@ Public Class RoamingPokemon Me.WorldID = CInt(data(2)) Me.LevelFile = data(3) Me.MusicLoop = data(4) + + If data.Length = 8 Then + ScriptPath = data(7) + End If End Sub Public Function CompareData() As String @@ -53,9 +58,14 @@ Public Class RoamingPokemon If nextIndex > levelList.Count - 1 Then nextIndex = 0 End If + If data.Length = 7 Then + 'PokémonID,Level,regionID,startLevelFile,MusicLoop,Shiny,PokemonData,ScriptPath + newData &= data(0) & "|" & data(1) & "|" & CInt(data(2)).ToString() & "|" & levelList(nextIndex) & "|" & data(4) & "|" & data(5) & "|" & data(6) & "|" + Else + 'PokémonID,Level,regionID,startLevelFile,MusicLoop,Shiny,PokemonData,ScriptPath + newData &= data(0) & "|" & data(1) & "|" & CInt(data(2)).ToString() & "|" & levelList(nextIndex) & "|" & data(4) & "|" & data(5) & "|" & data(6) & "|" & data(7) + End If - 'PokémonID,Level,regionID,startLevelFile,MusicLoop,Shiny,PokemonData - newData &= data(0) & "|" & data(1) & "|" & CInt(data(2)).ToString() & "|" & levelList(nextIndex) & "|" & data(4) & "|" & data(5) & "|" & data(6) Else newData &= line End If @@ -98,7 +108,7 @@ Public Class RoamingPokemon If line.StartsWith(compareData) = False Then newData &= line Else - newData &= p.PokemonReference.Number & "|" & p.PokemonReference.Level & "|" & p.WorldID.ToString() & "|" & p.LevelFile & "|" & p.MusicLoop & "|" & p.PokemonReference.IsShiny & "|" & p.PokemonReference.GetSaveData() + newData &= p.PokemonReference.Number & "|" & p.PokemonReference.Level & "|" & p.WorldID.ToString() & "|" & p.LevelFile & "|" & p.MusicLoop & "|" & p.PokemonReference.IsShiny & "|" & p.PokemonReference.GetSaveData() & "|" & p.ScriptPath End If Next diff --git a/P3D/Pokemon/Wild/Spawner.vb b/P3D/Pokemon/Wild/Spawner.vb index f760811d6..befb90fb7 100644 --- a/P3D/Pokemon/Wild/Spawner.vb +++ b/P3D/Pokemon/Wild/Spawner.vb @@ -108,7 +108,7 @@ Public Class Spawner Dim possibleEncounters As New List(Of String) For Each cLine As String In roamingData - If cLine <> "" And cLine.CountSeperators("|") = 6 Then + If cLine <> "" And cLine.CountSeperators("|") >= 6 Then possibleEncounters.Add(cLine) End If Next diff --git a/P3D/World/ActionScript/V2/ScriptCommands/DoPokemon.vb b/P3D/World/ActionScript/V2/ScriptCommands/DoPokemon.vb index 357e23f78..f2840f092 100644 --- a/P3D/World/ActionScript/V2/ScriptCommands/DoPokemon.vb +++ b/P3D/World/ActionScript/V2/ScriptCommands/DoPokemon.vb @@ -682,11 +682,16 @@ p.IsShiny = CBool(data(5)) End If + Dim ScriptPath As String = "" + If data.Length > 6 AndAlso data(6) <> "" Then + ScriptPath = data(6) + End If + If Core.Player.RoamingPokemonData <> "" Then Core.Player.RoamingPokemonData &= Environment.NewLine End If - Core.Player.RoamingPokemonData &= data(0) & "|" & data(1) & "|" & data(2) & "|" & data(3) & "|" & data(4) & "|" & p.IsShiny & "|" & p.GetSaveData() + Core.Player.RoamingPokemonData &= data(0) & "|" & data(1) & "|" & data(2) & "|" & data(3) & "|" & data(4) & "|" & p.IsShiny & "|" & p.GetSaveData() & "|" & ScriptPath Case "evolve" Dim args() As String = argument.Split(CChar(",")) Dim triggerStr As String = "level"