From 944e42cadd50b21e97c96cc01b1e4ababd7ab9ee Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Tue, 15 Aug 2023 18:36:02 +0200 Subject: [PATCH] Fixed Baton Pass, PVP needs testing --- P3D/Battle/BattleSystemV2/Battle.vb | 14 +++++++++--- P3D/Battle/BattleSystemV2/BattleMenu.vb | 25 +++++++++++++++++---- P3D/Battle/BattleSystemV2/FieldEffects.vb | 2 ++ P3D/Pokemon/Attacks/Normal/BatonPass.vb | 27 +++++++++++++++++------ 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/P3D/Battle/BattleSystemV2/Battle.vb b/P3D/Battle/BattleSystemV2/Battle.vb index 0d91f20f2..d1b8a6e9f 100644 --- a/P3D/Battle/BattleSystemV2/Battle.vb +++ b/P3D/Battle/BattleSystemV2/Battle.vb @@ -405,7 +405,15 @@ If BattleScreen.ReceivedInput.StartsWith("MEGA|") Then BattleScreen.IsMegaEvolvingOpp = True End If - Dim moveID As Integer = CInt(BattleScreen.ReceivedInput.Remove(0, 5)) + Dim moveID As Integer + Dim inputString As String = BattleScreen.ReceivedInput.Remove(0, 5) + If inputString.Contains("|BATON|") Then + BattleScreen.FieldEffects.OppBatonPassIndex = CInt(inputString.GetSplit(2, "|")) + moveID = CInt(inputString.GetSplit(0, "|")) + Else + moveID = CInt(inputString) + End If + Return New RoundConst() With {.StepType = RoundConst.StepTypes.Move, .Argument = GetPokemonMoveFromID(BattleScreen.OppPokemon, moveID)} ElseIf BattleScreen.ReceivedInput.StartsWith("SWITCH|") Then BattleScreen.OppStatistics.Switches += 1 @@ -7383,7 +7391,7 @@ If .OwnUsedBatonPass = False Then .OwnEmbargo = 0 .OwnYawn = 0 If .OwnUsedBatonPass = False Then .OwnPerishSongCount = 0 - .OwnConfusionTurns = 0 + If .OwnUsedBatonPass = False Then .OwnConfusionTurns = 0 .OwnTorment = 0 .OwnTormentMove = Nothing .OwnChoiceMove = Nothing @@ -7794,7 +7802,7 @@ If .OppUsedBatonPass = False Then .OppEmbargo = 0 .OppYawn = 0 If .OppUsedBatonPass = False Then .OppPerishSongCount = 0 - .OppConfusionTurns = 0 + If .OppUsedBatonPass = False Then .OppConfusionTurns = 0 .OppTorment = 0 .OppTormentMove = Nothing .OppChoiceMove = Nothing diff --git a/P3D/Battle/BattleSystemV2/BattleMenu.vb b/P3D/Battle/BattleSystemV2/BattleMenu.vb index e220bddfb..05910744f 100644 --- a/P3D/Battle/BattleSystemV2/BattleMenu.vb +++ b/P3D/Battle/BattleSystemV2/BattleMenu.vb @@ -913,8 +913,21 @@ _moveMenuAlpha -= 15 If _moveMenuAlpha <= 0 Then _moveMenuAlpha = 0 - MoveMenuStartRound(BattleScreen) - Visible = False + If BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).ID = 226 Then + If PartyScreen.Selected <> -1 Then + BattleScreen.FieldEffects.OwnBatonPassIndex = PartyScreen.Selected + MoveMenuStartRound(BattleScreen) + PartyScreen.Selected = -1 + Else + Dim selScreen = New PartyScreen(Core.CurrentScreen, Item.GetItemByID(5.ToString), Nothing, "Choose Pokémon", False, False, False) With {.Mode = Screens.UI.ISelectionScreen.ScreenMode.Selection, .CanExit = False} + AddHandler selScreen.SelectedObject, Nothing + + Core.SetScreen(selScreen) + End If + Else + MoveMenuStartRound(BattleScreen) + Visible = False + End If End If Else UseStruggle(BattleScreen) @@ -980,12 +993,16 @@ BattleScreen.BattleQuery.Clear() BattleScreen.BattleQuery.Add(BattleScreen.FocusBattle()) BattleScreen.BattleQuery.Insert(0, New ToggleMenuQueryObject(True)) + Dim BatonPassSuffix As String = "" + If BattleScreen.FieldEffects.OwnBatonPassIndex <> -1 Then + BatonPassSuffix = "|BATON|" & BattleScreen.FieldEffects.OwnBatonPassIndex + End If If BattleScreen.IsMegaEvolvingOwn Then - BattleScreen.SendClientCommand("MEGA|" & BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).ID.ToString()) + BattleScreen.SendClientCommand("MEGA|" & BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).ID.ToString() & BatonPassSuffix) BattleScreen.IsMegaEvolvingOwn = False BattleScreen.FieldEffects.OwnMegaEvolved = True Else - BattleScreen.SendClientCommand("MOVE|" & BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).ID.ToString()) + BattleScreen.SendClientCommand("MOVE|" & BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).ID.ToString() & BatonPassSuffix) End If Else If BattleScreen.IsMegaEvolvingOwn Then diff --git a/P3D/Battle/BattleSystemV2/FieldEffects.vb b/P3D/Battle/BattleSystemV2/FieldEffects.vb index 607585129..79eaee125 100644 --- a/P3D/Battle/BattleSystemV2/FieldEffects.vb +++ b/P3D/Battle/BattleSystemV2/FieldEffects.vb @@ -291,10 +291,12 @@ Public OwnUsedBatonPass As Boolean = False Public OwnBatonPassStats As List(Of Integer) Public OwnBatonPassConfusion As Boolean = False + Public OwnBatonPassIndex As Integer = -1 Public OppUsedBatonPass As Boolean = False Public OppBatonPassStats As List(Of Integer) Public OppBatonPassConfusion As Boolean = False + Public OppBatonPassIndex As Integer = -1 Public Function CanUseItem(ByVal own As Boolean) As Boolean Dim embargo As Integer = OwnEmbargo diff --git a/P3D/Pokemon/Attacks/Normal/BatonPass.vb b/P3D/Pokemon/Attacks/Normal/BatonPass.vb index db016868e..dc13361b7 100644 --- a/P3D/Pokemon/Attacks/Normal/BatonPass.vb +++ b/P3D/Pokemon/Attacks/Normal/BatonPass.vb @@ -57,21 +57,34 @@ Public Overrides Sub MoveHits(own As Boolean, BattleScreen As BattleScreen) If own = True Then - If Core.Player.CountFightablePokemon > 1 Then + If Core.Player.CountFightablePokemon > 1 AndAlso BattleScreen.FieldEffects.OwnBatonPassIndex <> BattleScreen.OwnPokemonIndex AndAlso BattleScreen.FieldEffects.OwnBatonPassIndex <> -1 Then BattleScreen.FieldEffects.OwnUsedBatonPass = True - BattleScreen.Battle.SwitchOutOwn(BattleScreen, GetPokemonIndex(BattleScreen, own), -1) + BattleScreen.Battle.SwitchOutOwn(BattleScreen, BattleScreen.FieldEffects.OwnBatonPassIndex, -1) + BattleScreen.FieldEffects.OwnBatonPassIndex = -1 Else BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!")) End If Else - If BattleScreen.IsTrainerBattle = True Or BattleScreen.IsRemoteBattle = True Or BattleScreen.IsPVPBattle = True Then - If BattleScreen.Trainer.CountUseablePokemon > 1 Then + If BattleScreen.IsTrainerBattle = True Then + If BattleScreen.IsRemoteBattle = True Or BattleScreen.IsPVPBattle = True Then BattleScreen.FieldEffects.OppUsedBatonPass = True + If BattleScreen.Trainer.CountUseablePokemon > 1 AndAlso BattleScreen.FieldEffects.OppBatonPassIndex <> BattleScreen.OppPokemonIndex AndAlso BattleScreen.FieldEffects.OppBatonPassIndex <> -1 Then + BattleScreen.FieldEffects.OppUsedBatonPass = True - BattleScreen.Battle.SwitchOutOpp(BattleScreen, GetPokemonIndex(BattleScreen, own)) + BattleScreen.Battle.SwitchOutOpp(BattleScreen, BattleScreen.FieldEffects.OppBatonPassIndex) + BattleScreen.FieldEffects.OppBatonPassIndex = -1 + Else + BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!")) + End If Else - BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!")) + If BattleScreen.Trainer.CountUseablePokemon > 1 Then + BattleScreen.FieldEffects.OppUsedBatonPass = True + + BattleScreen.Battle.SwitchOutOpp(BattleScreen, GetPokemonIndex(BattleScreen, own)) + Else + BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!")) + End If End If Else BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!")) @@ -96,6 +109,6 @@ Return -1 End Function - End Class + End Class End Namespace \ No newline at end of file