From f1484c77ca8e0a8cb35b060b938e8bf4075088f1 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Mon, 27 Mar 2023 17:09:08 +0200 Subject: [PATCH] Fix for PP items in battle not starting round --- P3D/Pokemon/Items/Berries/LeppaBerry.vb | 26 +++++++++++++++++++----- P3D/Pokemon/Items/Medicine/Ether.vb | 27 +++++++++++++++++++------ P3D/Pokemon/Items/Medicine/MaxEther.vb | 13 +++++++----- P3D/Pokemon/Items/Medicine/PPMax.vb | 26 +++++++++++++++++++----- P3D/Pokemon/Items/Medicine/PPUp.vb | 26 +++++++++++++++++++----- 5 files changed, 92 insertions(+), 26 deletions(-) diff --git a/P3D/Pokemon/Items/Berries/LeppaBerry.vb b/P3D/Pokemon/Items/Berries/LeppaBerry.vb index e59f7a7cb..7caa17208 100644 --- a/P3D/Pokemon/Items/Berries/LeppaBerry.vb +++ b/P3D/Pokemon/Items/Berries/LeppaBerry.vb @@ -27,12 +27,15 @@ Namespace Items.Berries Public Overrides Function UseOnPokemon(ByVal PokeIndex As Integer) As Boolean Core.SetScreen(New ChooseAttackScreen(Core.CurrentScreen, Core.Player.Pokemons(PokeIndex), True, True, AddressOf UseOnAttack)) - If Core.CurrentScreen.Identification <> Screen.Identifications.ChooseAttackScreen Then - If ChooseAttackScreen.Selected <> -1 Then - Return True - End If + Dim s As Screen = Core.CurrentScreen + While s.Identification <> Screen.Identifications.BattleScreen AndAlso s.PreScreen IsNot Nothing + s = s.PreScreen + End While + If s.Identification = Screen.Identifications.BattleScreen Then + Return False + Else + Return True End If - Return False End Function Private Sub UseOnAttack(ByVal Pokemon As Pokemon, ByVal AttackIndex As Integer) @@ -44,6 +47,19 @@ Namespace Items.Berries SoundManager.PlaySound("Use_Item", False) Screen.TextBox.Show(t, {}, True, True) + Dim s As Screen = Core.CurrentScreen + While s.Identification <> Screen.Identifications.BattleScreen AndAlso s.PreScreen IsNot Nothing + s = s.PreScreen + End While + If s.Identification = Screen.Identifications.BattleScreen Then + Dim TempBattleScreen As BattleSystem.BattleScreen = CType(s, BattleSystem.BattleScreen) + + TempBattleScreen.BattleQuery.Clear() + TempBattleScreen.BattleQuery.Add(TempBattleScreen.FocusBattle()) + TempBattleScreen.BattleQuery.Insert(0, New BattleSystem.ToggleMenuQueryObject(True)) + TempBattleScreen.Battle.InitializeRound(TempBattleScreen, New BattleSystem.Battle.RoundConst With {.StepType = BattleSystem.Battle.RoundConst.StepTypes.Item, .Argument = Me.ID.ToString()}) + Core.SetScreen(TempBattleScreen) + End If Else Screen.TextBox.Show("The move already has~full PP.", {}, True, True) End If diff --git a/P3D/Pokemon/Items/Medicine/Ether.vb b/P3D/Pokemon/Items/Medicine/Ether.vb index f2209c885..c9eedb16e 100644 --- a/P3D/Pokemon/Items/Medicine/Ether.vb +++ b/P3D/Pokemon/Items/Medicine/Ether.vb @@ -4,7 +4,6 @@ Namespace Items.Medicine Public Class Ether Inherits MedicineItem - Public Overrides ReadOnly Property PokeDollarPrice As Integer = 1200 Public Overrides ReadOnly Property Description As String = "This medicine can restore 10 PP to a single selected move that has been learned by a Pokémon." @@ -21,12 +20,15 @@ Namespace Items.Medicine Public Overrides Function UseOnPokemon(ByVal PokeIndex As Integer) As Boolean Core.SetScreen(New ChooseAttackScreen(Core.CurrentScreen, Core.Player.Pokemons(PokeIndex), True, True, AddressOf UseOnAttack)) - If Core.CurrentScreen.Identification <> Screen.Identifications.ChooseAttackScreen Then - If ChooseAttackScreen.Selected <> -1 Then - Return True - End If + Dim s As Screen = Core.CurrentScreen + While s.Identification <> Screen.Identifications.BattleScreen AndAlso s.PreScreen IsNot Nothing + s = s.PreScreen + End While + If s.Identification = Screen.Identifications.BattleScreen Then + Return False + Else + Return True End If - Return False End Function Private Sub UseOnAttack(ByVal Pokemon As Pokemon, ByVal AttackIndex As Integer) @@ -39,6 +41,19 @@ Namespace Items.Medicine SoundManager.PlaySound("Use_Item", False) Screen.TextBox.Show(t, {}, True, True) + Dim s As Screen = Core.CurrentScreen + While s.Identification <> Screen.Identifications.BattleScreen AndAlso s.PreScreen IsNot Nothing + s = s.PreScreen + End While + If s.Identification = Screen.Identifications.BattleScreen Then + Dim TempBattleScreen As BattleSystem.BattleScreen = CType(s, BattleSystem.BattleScreen) + + TempBattleScreen.BattleQuery.Clear() + TempBattleScreen.BattleQuery.Add(TempBattleScreen.FocusBattle()) + TempBattleScreen.BattleQuery.Insert(0, New BattleSystem.ToggleMenuQueryObject(True)) + TempBattleScreen.Battle.InitializeRound(TempBattleScreen, New BattleSystem.Battle.RoundConst With {.StepType = BattleSystem.Battle.RoundConst.StepTypes.Item, .Argument = Me.ID.ToString()}) + Core.SetScreen(TempBattleScreen) + End If Else Screen.TextBox.Show("The move already has~full PP.", {}, True, True) End If diff --git a/P3D/Pokemon/Items/Medicine/MaxEther.vb b/P3D/Pokemon/Items/Medicine/MaxEther.vb index bf8ae883f..04b47d595 100644 --- a/P3D/Pokemon/Items/Medicine/MaxEther.vb +++ b/P3D/Pokemon/Items/Medicine/MaxEther.vb @@ -21,12 +21,15 @@ Namespace Items.Medicine Public Overrides Function UseOnPokemon(ByVal PokeIndex As Integer) As Boolean Core.SetScreen(New ChooseAttackScreen(Core.CurrentScreen, Core.Player.Pokemons(PokeIndex), True, True, AddressOf UseOnAttack)) - If Core.CurrentScreen.Identification <> Screen.Identifications.ChooseAttackScreen Then - If ChooseAttackScreen.Selected <> -1 Then - Return True - End If + Dim s As Screen = Core.CurrentScreen + While s.Identification <> Screen.Identifications.BattleScreen AndAlso s.PreScreen IsNot Nothing + s = s.PreScreen + End While + If s.Identification = Screen.Identifications.BattleScreen Then + Return False + Else + Return True End If - Return False End Function Private Sub UseOnAttack(ByVal Pokemon As Pokemon, ByVal AttackIndex As Integer) diff --git a/P3D/Pokemon/Items/Medicine/PPMax.vb b/P3D/Pokemon/Items/Medicine/PPMax.vb index 968161979..10f4c4144 100644 --- a/P3D/Pokemon/Items/Medicine/PPMax.vb +++ b/P3D/Pokemon/Items/Medicine/PPMax.vb @@ -21,12 +21,15 @@ Namespace Items.Medicine Public Overrides Function UseOnPokemon(ByVal PokeIndex As Integer) As Boolean Core.SetScreen(New ChooseAttackScreen(Core.CurrentScreen, Core.Player.Pokemons(PokeIndex), True, True, AddressOf UseOnAttack)) - If Core.CurrentScreen.Identification <> Screen.Identifications.ChooseAttackScreen Then - If ChooseAttackScreen.Selected <> -1 Then - Return True - End If + Dim s As Screen = Core.CurrentScreen + While s.Identification <> Screen.Identifications.BattleScreen AndAlso s.PreScreen IsNot Nothing + s = s.PreScreen + End While + If s.Identification = Screen.Identifications.BattleScreen Then + Return False + Else + Return True End If - Return False End Function Private Sub UseOnAttack(ByVal Pokemon As Pokemon, ByVal AttackIndex As Integer) @@ -44,6 +47,19 @@ Namespace Items.Medicine PlayerStatistics.Track("[17]Medicine Items used", 1) Screen.TextBox.Show(t, {}, True, True) + Dim s As Screen = Core.CurrentScreen + While s.Identification <> Screen.Identifications.BattleScreen AndAlso s.PreScreen IsNot Nothing + s = s.PreScreen + End While + If s.Identification = Screen.Identifications.BattleScreen Then + Dim TempBattleScreen As BattleSystem.BattleScreen = CType(s, BattleSystem.BattleScreen) + + TempBattleScreen.BattleQuery.Clear() + TempBattleScreen.BattleQuery.Add(TempBattleScreen.FocusBattle()) + TempBattleScreen.BattleQuery.Insert(0, New BattleSystem.ToggleMenuQueryObject(True)) + TempBattleScreen.Battle.InitializeRound(TempBattleScreen, New BattleSystem.Battle.RoundConst With {.StepType = BattleSystem.Battle.RoundConst.StepTypes.Item, .Argument = Me.ID.ToString()}) + Core.SetScreen(TempBattleScreen) + End If Else Screen.TextBox.Show("The move already has~full PP.", {}, True, True) End If diff --git a/P3D/Pokemon/Items/Medicine/PPUp.vb b/P3D/Pokemon/Items/Medicine/PPUp.vb index ee52f556a..d495af3b9 100644 --- a/P3D/Pokemon/Items/Medicine/PPUp.vb +++ b/P3D/Pokemon/Items/Medicine/PPUp.vb @@ -21,12 +21,15 @@ Namespace Items.Medicine Public Overrides Function UseOnPokemon(ByVal PokeIndex As Integer) As Boolean Core.SetScreen(New ChooseAttackScreen(Core.CurrentScreen, Core.Player.Pokemons(PokeIndex), True, True, AddressOf UseOnAttack)) - If Core.CurrentScreen.Identification <> Screen.Identifications.ChooseAttackScreen Then - If ChooseAttackScreen.Selected <> -1 Then - Return True - End If + Dim s As Screen = Core.CurrentScreen + While s.Identification <> Screen.Identifications.BattleScreen AndAlso s.PreScreen IsNot Nothing + s = s.PreScreen + End While + If s.Identification = Screen.Identifications.BattleScreen Then + Return False + Else + Return True End If - Return False End Function Private Sub UseOnAttack(ByVal Pokemon As Pokemon, ByVal AttackIndex As Integer) @@ -37,6 +40,19 @@ Namespace Items.Medicine PlayerStatistics.Track("[17]Medicine Items used", 1) Screen.TextBox.Show(t, {}, True, True) + Dim s As Screen = Core.CurrentScreen + While s.Identification <> Screen.Identifications.BattleScreen AndAlso s.PreScreen IsNot Nothing + s = s.PreScreen + End While + If s.Identification = Screen.Identifications.BattleScreen Then + Dim TempBattleScreen As BattleSystem.BattleScreen = CType(s, BattleSystem.BattleScreen) + + TempBattleScreen.BattleQuery.Clear() + TempBattleScreen.BattleQuery.Add(TempBattleScreen.FocusBattle()) + TempBattleScreen.BattleQuery.Insert(0, New BattleSystem.ToggleMenuQueryObject(True)) + TempBattleScreen.Battle.InitializeRound(TempBattleScreen, New BattleSystem.Battle.RoundConst With {.StepType = BattleSystem.Battle.RoundConst.StepTypes.Item, .Argument = Me.ID.ToString()}) + Core.SetScreen(TempBattleScreen) + End If Else Screen.TextBox.Show("The move already has~full PP.", {}, True, True) End If