From 68a9d197e5e53e57ed5afc1880a29bc8df4ae4f9 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Mon, 26 Dec 2022 20:54:00 +0100 Subject: [PATCH] Improved the Custom Move commands --- P3D/Battle/BattleSystemV2/Battle.vb | 2 +- P3D/Battle/BattleSystemV2/BattleScreen.vb | 12 ++++-- P3D/Pokemon/Attacks/AttackSpecialFunctions.vb | 42 ++++++++++++++++--- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/P3D/Battle/BattleSystemV2/Battle.vb b/P3D/Battle/BattleSystemV2/Battle.vb index b5d272750..1d187dbac 100644 --- a/P3D/Battle/BattleSystemV2/Battle.vb +++ b/P3D/Battle/BattleSystemV2/Battle.vb @@ -218,7 +218,7 @@ End If End Sub - Private Sub DeleteHostQuery(ByVal BattleScreen As BattleScreen) + Public Sub DeleteHostQuery(ByVal BattleScreen As BattleScreen) If BattleScreen.IsRemoteBattle Then BattleScreen.BattleQuery.Clear() BattleScreen.TempPVPBattleQuery.Clear() diff --git a/P3D/Battle/BattleSystemV2/BattleScreen.vb b/P3D/Battle/BattleSystemV2/BattleScreen.vb index 361800d6b..b53963f38 100644 --- a/P3D/Battle/BattleSystemV2/BattleScreen.vb +++ b/P3D/Battle/BattleSystemV2/BattleScreen.vb @@ -4,6 +4,7 @@ Inherits Screen + Public NextPokemonIndex As Integer = -1 'Used for after fainting switching Public OwnFaint As Boolean = False Public OppFaint As Boolean = False @@ -1351,10 +1352,14 @@ nextIndex: End While Else - i = Core.Random.Next(0, Trainer.Pokemons.Count) - While Trainer.Pokemons(i).Status = Pokemon.StatusProblems.Fainted OrElse OppPokemonIndex = i OrElse Trainer.Pokemons(i).HP <= 0 + If Me.NextPokemonIndex <> -1 Then + i = NextPokemonIndex + Else i = Core.Random.Next(0, Trainer.Pokemons.Count) - End While + While Trainer.Pokemons(i).Status = Pokemon.StatusProblems.Fainted OrElse OppPokemonIndex = i OrElse Trainer.Pokemons(i).HP <= 0 + i = Core.Random.Next(0, Trainer.Pokemons.Count) + End While + End If End If End If @@ -1364,6 +1369,7 @@ nextIndex: If Pokedex.GetEntryType(Core.Player.PokedexData, OppPokemon.Number) = 0 Then Core.Player.PokedexData = Pokedex.ChangeEntry(Core.Player.PokedexData, OppPokemon.Number, 1) End If + NextPokemonIndex = -1 End Sub Public Function GetModelName(ByVal own As Boolean) As String diff --git a/P3D/Pokemon/Attacks/AttackSpecialFunctions.vb b/P3D/Pokemon/Attacks/AttackSpecialFunctions.vb index fe1d1c365..4542f7a2f 100644 --- a/P3D/Pokemon/Attacks/AttackSpecialFunctions.vb +++ b/P3D/Pokemon/Attacks/AttackSpecialFunctions.vb @@ -32,7 +32,14 @@ BattleScreen.Battle.ChangeCameraAngle(2, True, BattleScreen) End Select Case "message", "text" - fSub = Localization.GetString(fSub, fSub) + Dim OppPokemon As Pokemon = BattleScreen.OppPokemon + Dim OwnPokemon As Pokemon = BattleScreen.OwnPokemon + If own = False Then + OwnPokemon = BattleScreen.OppPokemon + OppPokemon = BattleScreen.OwnPokemon + End If + + fSub = Localization.GetString(fSub, fSub).Replace("[OPPNAME]", OppPokemon.GetDisplayName).Replace("[OWNNAME]", OwnPokemon.GetDisplayName) BattleScreen.BattleQuery.Add(New TextQueryObject(fSub)) Case "raisestat", "increasestat" Dim Stat As String = f.GetSplit(1, ",") @@ -103,17 +110,36 @@ Case "faint" Dim Target As Boolean = CBool(f.GetSplit(1, ",")) Dim Message As String = "" + Dim NextPokemonIndex As Integer = -1 + + Dim OppPokemon As Pokemon = BattleScreen.OppPokemon + Dim OwnPokemon As Pokemon = BattleScreen.OwnPokemon + If Target = False Then + OwnPokemon = BattleScreen.OppPokemon + OppPokemon = BattleScreen.OwnPokemon + End If + + If Target = True Then + If f.Split(CChar(",")).Count > 3 Then + If f.GetSplit(3, ",").StartsWith("~+") Then + NextPokemonIndex = BattleScreen.OppPokemonIndex + CInt(f.GetSplit(3, ",").Remove(0, 2)) + End If + If f.GetSplit(3, ",").StartsWith("~-") Then + NextPokemonIndex = BattleScreen.OppPokemonIndex - CInt(f.GetSplit(3, ",").Remove(0, 2)) + End If + End If + End If + BattleScreen.NextPokemonIndex = NextPokemonIndex If f.Split(CChar(",")).Count > 2 Then - Message = f.GetSplit(2, ",") + Message = f.GetSplit(2, ",").Replace("[OPPNAME]", OppPokemon.GetDisplayName).Replace("[OWNNAME]", OwnPokemon.GetDisplayName) End If BattleScreen.Battle.FaintPokemon(Not Target, BattleScreen, Message) Case "switch" Dim Target As Boolean = CBool(f.GetSplit(1, ",")) - Dim SwitchTo As Integer = CInt(f.GetSplit(2, ",")) + Dim SwitchTo As Integer = 0 Dim Message As String = "" - If f.Split(CChar(",")).Count > 3 Then Message = f.GetSplit(3, ",") End If @@ -135,8 +161,12 @@ BattleScreen.Battle.SwitchOutOwn(BattleScreen, SwitchTo, -1, Message) End If Case "endround" - Dim Type As Integer = CInt(f.GetSplit(1, ",")) - BattleScreen.Battle.EndRound(BattleScreen, Type) + BattleScreen.Battle.DeleteHostQuery(BattleScreen) + Dim cq1 As ScreenFadeQueryObject = New ScreenFadeQueryObject(ScreenFadeQueryObject.FadeTypes.Vertical, Color.Black, True, 16) + Dim cq2 As ScreenFadeQueryObject = New ScreenFadeQueryObject(ScreenFadeQueryObject.FadeTypes.Vertical, Color.Black, False, 16) + cq2.PassThis = True + BattleScreen.BattleQuery.AddRange({cq1, cq2}) + BattleScreen.Battle.StartRound(BattleScreen) Case Else fSub = CInt(f.GetSplit(1, ",")).Clamp(0, 100).ToString End Select