Some battle fixes & move implementations

* Baton Pass, Volt Switch, Parting Shot and U-Turn technically work, however the camera is aimed at the wrong pokémon
* Fixed softlock when the PVP client selects a move before the host has finished the battle intro dialogue
This commit is contained in:
JappaWakka 2023-08-21 18:43:40 +02:00
parent 0b183bb5f8
commit 888371c914
10 changed files with 163 additions and 41 deletions

View File

@ -407,9 +407,12 @@
End If
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, "|"))
If inputString.Contains(";BATON;") Then
BattleScreen.FieldEffects.OppBatonPassIndex = CInt(inputString.GetSplit(2, ";"))
moveID = CInt(inputString.GetSplit(0, ";"))
ElseIf inputString.Contains(";SWAP;") Then
BattleScreen.FieldEffects.OppSwapIndex = CInt(inputString.GetSplit(2, ";"))
moveID = CInt(inputString.GetSplit(0, ";"))
Else
moveID = CInt(inputString)
End If
@ -5508,7 +5511,7 @@
cq2.PassThis = True
BattleScreen.BattleQuery.AddRange({cq1, cq2})
BattleScreen.FirstRound = False
StartRound(BattleScreen)
BattleScreen.ClearMainMenuTime = True

View File

@ -772,6 +772,7 @@
Private Sub MainMenuOpenBattleMenu(ByVal BattleScreen As BattleScreen)
_retractMenu = True
_nextMenuState = MenuStates.Moves
PartyScreen.Selected = -1
BattleScreen.BattleQuery.Clear()
Dim q As New CameraQueryObject(New Vector3(11, 0.5F, 14.0F), New Vector3(11, 0.5F, 14.0F), Screen.Camera.Speed, Screen.Camera.Speed, -(CSng(MathHelper.PiOver4) + 0.3F), -(CSng(MathHelper.PiOver4) + 0.3F), -0.3F, -0.3F, 0.04F, 0.04F)
@ -913,17 +914,23 @@
_moveMenuAlpha -= 15
If _moveMenuAlpha <= 0 Then
_moveMenuAlpha = 0
If BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).ID = 226 Then
If PartyScreen.Selected <> -1 Then
BattleScreen.FieldEffects.OwnBatonPassIndex = PartyScreen.Selected
MoveMenuStartRound(BattleScreen)
PartyScreen.Selected = -1
Else
If BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).SwapsOutOwnPokemon = True Then
If PartyScreen.Selected = -1 Then
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
If CurrentScreen.Identification <> Screen.Identifications.PartyScreen AndAlso PartyScreen.Selected <> -1 Then
If BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).ID = 226 Then
BattleScreen.FieldEffects.OwnBatonPassIndex = PartyScreen.Selected
Else
BattleScreen.FieldEffects.OwnSwapIndex = PartyScreen.Selected
End If
PartyScreen.Selected = -1
MoveMenuStartRound(BattleScreen)
Visible = False
End If
Else
MoveMenuStartRound(BattleScreen)
Visible = False
@ -993,16 +1000,18 @@
BattleScreen.BattleQuery.Clear()
BattleScreen.BattleQuery.Add(BattleScreen.FocusBattle())
BattleScreen.BattleQuery.Insert(0, New ToggleMenuQueryObject(True))
Dim BatonPassSuffix As String = ""
Dim SwitchPokeSuffix As String = ""
If BattleScreen.FieldEffects.OwnBatonPassIndex <> -1 Then
BatonPassSuffix = "|BATON|" & BattleScreen.FieldEffects.OwnBatonPassIndex
SwitchPokeSuffix = ";BATON;" & BattleScreen.FieldEffects.OwnBatonPassIndex
ElseIf BattleScreen.FieldEffects.OwnSwapIndex <> -1 Then
SwitchPokeSuffix = ";SWAP;" & BattleScreen.FieldEffects.OwnSwapIndex
End If
If BattleScreen.IsMegaEvolvingOwn Then
BattleScreen.SendClientCommand("MEGA|" & BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).ID.ToString() & BatonPassSuffix)
BattleScreen.SendClientCommand("MEGA|" & BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).ID.ToString() & SwitchPokeSuffix)
BattleScreen.IsMegaEvolvingOwn = False
BattleScreen.FieldEffects.OwnMegaEvolved = True
Else
BattleScreen.SendClientCommand("MOVE|" & BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).ID.ToString() & BatonPassSuffix)
BattleScreen.SendClientCommand("MOVE|" & BattleScreen.OwnPokemon.Attacks(_moveMenuIndex).ID.ToString() & SwitchPokeSuffix)
End If
Else
If BattleScreen.IsMegaEvolvingOwn Then

View File

@ -134,6 +134,8 @@
Me.IsTrainerBattle = True
Me.MouseVisible = False
Me.PVPGameJoltID = ""
'Reset variable when new battle starts
FirstRound = True
End Sub
#Region "Initialize"
@ -1655,6 +1657,7 @@ nextIndex:
'Client:
Public SentInput As Boolean = False
Public Shared ReceivedQuery As String = ""
Public Shared FirstRound As Boolean = True
Public ClientWaitForData As Boolean = False
Public ReceivedPokemonData As Boolean = False
Public TempPVPBattleQuery As New Dictionary(Of Integer, QueryObject)

View File

@ -287,6 +287,10 @@
Public DefeatedTrainerPokemon As Boolean = False
Public RoamingFled As Boolean = False
'Moves that swap out Pokémon
Public OwnSwapIndex As Integer = -1
Public OppSwapIndex As Integer = -1
'BatonPassTemp:
Public OwnUsedBatonPass As Boolean = False
Public OwnBatonPassStats As List(Of Integer)

View File

@ -10,7 +10,9 @@
End Sub
Public Overrides Sub Update(BV2Screen As BattleScreen)
BattleScreen.ReceivedInput = ""
If BattleScreen.FirstRound = False Then
BattleScreen.ReceivedInput = ""
End If
BV2Screen.SentHostData = False
BattleScreen.ReceivedQuery = ""
BV2Screen.SentInput = False

View File

@ -202,6 +202,8 @@
Public IsTrappingMove As Boolean = False
Public RemovesOwnFrozen As Boolean = False
Public RemovesOppFrozen As Boolean = False
Public SwapsOutOwnPokemon As Boolean = False
Public SwapsOutOppPokemon As Boolean = False
'effected by various moves items and abilities
Public ProtectAffected As Boolean = True

View File

@ -15,7 +15,7 @@
Me.Accuracy = 100
Me.Category = Categories.Physical
Me.ContestCategory = ContestCategories.Cute
Me.Name = Localization.GetString("move_name_" & Me.ID,"U-turn")
Me.Name = Localization.GetString("move_name_" & Me.ID, "U-turn")
Me.Description = "After making its attack, the user rushes back to switch places with a party Pokémon in waiting."
Me.CriticalChance = 1
Me.IsHMMove = False
@ -25,6 +25,7 @@
'#End
'#SpecialDefinitions
Me.SwapsOutOwnPokemon = True
Me.MakesContact = True
Me.ProtectAffected = True
Me.MagicCoatAffected = False
@ -54,14 +55,43 @@
Public Overrides Sub MoveSwitch(own As Boolean, BattleScreen As BattleScreen)
If own = True Then
If Core.Player.CountFightablePokemon > 1 Then
BattleScreen.Battle.SwitchOutOwn(BattleScreen, GetPokemonIndex(BattleScreen, own), -1)
If BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.Fainted Then
If Core.Player.CountFightablePokemon > 1 AndAlso BattleScreen.FieldEffects.OwnSwapIndex <> BattleScreen.OwnPokemonIndex AndAlso BattleScreen.FieldEffects.OwnSwapIndex <> -1 Then
BattleScreen.Battle.SwitchOutOwn(BattleScreen, BattleScreen.FieldEffects.OwnSwapIndex, -1)
BattleScreen.FieldEffects.OwnSwapIndex = -1
Else
BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!"))
End If
Else
BattleScreen.FieldEffects.OwnSwapIndex = -1
End If
Else
If BattleScreen.IsTrainerBattle = True Or BattleScreen.IsRemoteBattle = True Or BattleScreen.IsPVPBattle = True Then
If BattleScreen.Trainer.CountUseablePokemon > 1 Then
BattleScreen.Battle.SwitchOutOpp(BattleScreen, GetPokemonIndex(BattleScreen, own))
If BattleScreen.IsTrainerBattle = True Then
If BattleScreen.IsRemoteBattle = True Or BattleScreen.IsPVPBattle = True Then
If BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.Fainted Then
BattleScreen.FieldEffects.OppUsedBatonPass = True
If BattleScreen.Trainer.CountUseablePokemon > 1 AndAlso BattleScreen.FieldEffects.OppSwapIndex <> BattleScreen.OppPokemonIndex AndAlso BattleScreen.FieldEffects.OppSwapIndex <> -1 Then
BattleScreen.FieldEffects.OppUsedBatonPass = True
BattleScreen.Battle.SwitchOutOpp(BattleScreen, BattleScreen.FieldEffects.OppSwapIndex)
BattleScreen.FieldEffects.OppSwapIndex = -1
Else
BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!"))
End If
Else
BattleScreen.FieldEffects.OppSwapIndex = -1
End If
Else
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!"))
End If
End If
End Sub

View File

@ -25,6 +25,7 @@
'#End
'#SpecialDefinitions
Me.SwapsOutOwnPokemon = True
Me.MakesContact = False
Me.ProtectAffected = True
Me.MagicCoatAffected = True
@ -62,14 +63,43 @@
Public Overrides Sub MoveSwitch(own As Boolean, BattleScreen As BattleScreen)
If own = True Then
If Core.Player.CountFightablePokemon > 1 Then
BattleScreen.Battle.SwitchOutOwn(BattleScreen, GetPokemonIndex(BattleScreen, own), -1)
If BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.Fainted Then
If Core.Player.CountFightablePokemon > 1 AndAlso BattleScreen.FieldEffects.OwnSwapIndex <> BattleScreen.OwnPokemonIndex AndAlso BattleScreen.FieldEffects.OwnSwapIndex <> -1 Then
BattleScreen.Battle.SwitchOutOwn(BattleScreen, BattleScreen.FieldEffects.OwnSwapIndex, -1)
BattleScreen.FieldEffects.OwnSwapIndex = -1
Else
BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!"))
End If
Else
BattleScreen.FieldEffects.OwnSwapIndex = -1
End If
Else
If BattleScreen.IsTrainerBattle = True Or BattleScreen.IsRemoteBattle = True Or BattleScreen.IsPVPBattle = True Then
If BattleScreen.Trainer.CountUseablePokemon > 1 Then
BattleScreen.Battle.SwitchOutOpp(BattleScreen, GetPokemonIndex(BattleScreen, own))
If BattleScreen.IsTrainerBattle = True Then
If BattleScreen.IsRemoteBattle = True Or BattleScreen.IsPVPBattle = True Then
If BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.Fainted Then
BattleScreen.FieldEffects.OppUsedBatonPass = True
If BattleScreen.Trainer.CountUseablePokemon > 1 AndAlso BattleScreen.FieldEffects.OppSwapIndex <> BattleScreen.OppPokemonIndex AndAlso BattleScreen.FieldEffects.OppSwapIndex <> -1 Then
BattleScreen.FieldEffects.OppUsedBatonPass = True
BattleScreen.Battle.SwitchOutOpp(BattleScreen, BattleScreen.FieldEffects.OppSwapIndex)
BattleScreen.FieldEffects.OppSwapIndex = -1
Else
BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!"))
End If
Else
BattleScreen.FieldEffects.OppSwapIndex = -1
End If
Else
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!"))
End If
End If
End Sub

View File

@ -25,6 +25,7 @@ Namespace BattleSystem.Moves.Electric
'#End
'#SpecialDefinitions
Me.SwapsOutOwnPokemon = True
Me.MakesContact = False
Me.ProtectAffected = True
Me.MagicCoatAffected = False
@ -54,14 +55,43 @@ Namespace BattleSystem.Moves.Electric
Public Overrides Sub MoveSwitch(own As Boolean, BattleScreen As BattleScreen)
If own = True Then
If Core.Player.CountFightablePokemon > 1 Then
BattleScreen.Battle.SwitchOutOwn(BattleScreen, GetPokemonIndex(BattleScreen, own), -1)
If BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.Fainted Then
If Core.Player.CountFightablePokemon > 1 AndAlso BattleScreen.FieldEffects.OwnSwapIndex <> BattleScreen.OwnPokemonIndex AndAlso BattleScreen.FieldEffects.OwnSwapIndex <> -1 Then
BattleScreen.Battle.SwitchOutOwn(BattleScreen, BattleScreen.FieldEffects.OwnSwapIndex, -1)
BattleScreen.FieldEffects.OwnSwapIndex = -1
Else
BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!"))
End If
Else
BattleScreen.FieldEffects.OwnSwapIndex = -1
End If
Else
If BattleScreen.IsTrainerBattle = True Or BattleScreen.IsRemoteBattle = True Or BattleScreen.IsPVPBattle = True Then
If BattleScreen.Trainer.CountUseablePokemon > 1 Then
BattleScreen.Battle.SwitchOutOpp(BattleScreen, GetPokemonIndex(BattleScreen, own))
If BattleScreen.IsTrainerBattle = True Then
If BattleScreen.IsRemoteBattle = True Or BattleScreen.IsPVPBattle = True Then
If BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.Fainted Then
BattleScreen.FieldEffects.OppUsedBatonPass = True
If BattleScreen.Trainer.CountUseablePokemon > 1 AndAlso BattleScreen.FieldEffects.OppSwapIndex <> BattleScreen.OppPokemonIndex AndAlso BattleScreen.FieldEffects.OppSwapIndex <> -1 Then
BattleScreen.FieldEffects.OppUsedBatonPass = True
BattleScreen.Battle.SwitchOutOpp(BattleScreen, BattleScreen.FieldEffects.OppSwapIndex)
BattleScreen.FieldEffects.OppSwapIndex = -1
Else
BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!"))
End If
Else
BattleScreen.FieldEffects.OppSwapIndex = -1
End If
Else
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!"))
End If
End If
End Sub

View File

@ -25,6 +25,7 @@
'#End
'#SpecialDefinitions
Me.SwapsOutOwnPokemon = True
Me.MakesContact = False
Me.ProtectAffected = False
Me.MagicCoatAffected = False
@ -57,25 +58,33 @@
Public Overrides Sub MoveHits(own As Boolean, BattleScreen As BattleScreen)
If own = True Then
If Core.Player.CountFightablePokemon > 1 AndAlso BattleScreen.FieldEffects.OwnBatonPassIndex <> BattleScreen.OwnPokemonIndex AndAlso BattleScreen.FieldEffects.OwnBatonPassIndex <> -1 Then
BattleScreen.FieldEffects.OwnUsedBatonPass = True
If BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.Fainted 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, BattleScreen.FieldEffects.OwnBatonPassIndex, -1)
BattleScreen.FieldEffects.OwnBatonPassIndex = -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
BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!"))
BattleScreen.FieldEffects.OwnBatonPassIndex = -1
End If
Else
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
If BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.Fainted 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, BattleScreen.FieldEffects.OppBatonPassIndex)
BattleScreen.FieldEffects.OppBatonPassIndex = -1
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!"))
BattleScreen.FieldEffects.OppBatonPassIndex = -1
End If
Else
If BattleScreen.Trainer.CountUseablePokemon > 1 Then