Initial After Fainting Switching implementation

This commit is contained in:
CaptainSegis 2016-10-25 01:58:59 -05:00
parent 6221cf4806
commit a328c279b0
4 changed files with 83 additions and 21 deletions

View File

@ -206,14 +206,12 @@
End If
'Going to menu:
BattleScreen.BattleQuery.Add(New ToggleMenuQueryObject(False))
If BattleScreen.IsRemoteBattle AndAlso BattleScreen.IsHost Then
BattleScreen.BattleQuery.Add(New TriggerNewRoundPVPQueryObject())
BattleScreen.SendHostQuery()
End If
BattleScreen.BattleQuery.Add(New ToggleMenuQueryObject(False))
For i = 0 To 99
BattleScreen.InsertCasualCameramove()
Next
@ -4072,10 +4070,20 @@
If .OwnPokemon.Status = Pokemon.StatusProblems.Fainted Or .OwnPokemon.HP <= 0 Then
.OwnPokemon.Status = Pokemon.StatusProblems.Fainted
BattleScreen.OwnFaint = True
If BattleScreen.IsRemoteBattle AndAlso BattleScreen.IsHost Then
Core.ServersManager.ServerConnection.SendPackage(New Servers.Package(Servers.Package.PackageTypes.BattleHostData,
Core.ServersManager.ID, Servers.Package.ProtocolTypes.TCP, {BattleScreen.PartnerNetworkID.ToString(), "-HostFainted-"}.ToList()))
End If
SwitchOutOwn(BattleScreen, -1, -1)
End If
If .OppPokemon.Status = Pokemon.StatusProblems.Fainted Or .OppPokemon.HP <= 0 Then
.OppPokemon.Status = Pokemon.StatusProblems.Fainted
BattleScreen.OppFaint = True
If BattleScreen.IsRemoteBattle AndAlso BattleScreen.IsHost Then
Core.ServersManager.ServerConnection.SendPackage(New Servers.Package(Servers.Package.PackageTypes.BattleHostData,
Core.ServersManager.ID, Servers.Package.ProtocolTypes.TCP, {BattleScreen.PartnerNetworkID.ToString(), "-ClientFainted-"}.ToList()))
End If
If BattleScreen.IsTrainerBattle = True Then
If BattleScreen.Trainer.HasBattlePokemon() = True Then
BattleScreen.FieldEffects.DefeatedTrainerPokemon = True
@ -5683,7 +5691,11 @@
BattleScreen.AddToQuery(InsertIndex, New ToggleEntityQueryObject(True, ToggleEntityQueryObject.BattleEntities.OwnPokemon, 2, -1, -1, -1, -1))
If Core.Player.CountFightablePokemon > 0 Then
SwitchInOwn(BattleScreen, SwitchInIndex, False, InsertIndex, message)
If BattleScreen.OwnFaint Then
'Next pokemon sent by the player is decided via menu.
Else
SwitchInOwn(BattleScreen, SwitchInIndex, False, InsertIndex, message)
End If
Else
If BattleScreen.IsTrainerBattle = True Then
EndBattle(EndBattleReasons.LooseTrainer, BattleScreen, False)
@ -6000,7 +6012,11 @@
End If
BattleScreen.BattleQuery.Add(New ToggleEntityQueryObject(True, ToggleEntityQueryObject.BattleEntities.OppPokemon, 2, -1, -1, -1, -1))
SwitchInOpp(BattleScreen, False, index)
If BattleScreen.IsRemoteBattle And BattleScreen.OppFaint Then
'Next pokemon is selected by the opponent.
Else
SwitchInOpp(BattleScreen, False, index)
End If
Else
GainEXP(BattleScreen)
@ -6187,6 +6203,8 @@
End Enum
Public Sub EndBattle(ByVal reason As EndBattleReasons, ByVal BattleScreen As BattleScreen, ByVal AddPVP As Boolean)
BattleSystem.BattleScreen.OwnFaint = False
BattleSystem.BattleScreen.OppFaint = False
If AddPVP = True Then
Select Case reason
Case EndBattleReasons.WinTrainer 'Lost

View File

@ -271,7 +271,7 @@
End If
End Sub
Public Sub Update(ByVal BattleScreen As BattleScreen)
Public Sub Update(ByRef BattleScreen As BattleScreen)
Select Case MenuState
Case MenuStates.Main
UpdateMainMenu(BattleScreen)
@ -559,11 +559,13 @@
Next
End Sub
Private Sub UpdateMainMenu(ByVal BattleScreen As BattleScreen)
Private Sub UpdateMainMenu(ByRef BattleScreen As BattleScreen)
If BattleScreen.ClearMenuTime = True Then
_mainMenuItemList.Clear()
BattleScreen.ClearMenuTime = False
End If
If _mainMenuItemList.Count = 0 Then
CreateMainMenuItems(BattleScreen)
End If
@ -576,9 +578,8 @@
UpdateMenuOptions(_mainMenuIndex, _mainMenuNextIndex, _mainMenuItemList.Count)
End Sub
Private Sub CreateMainMenuItems(ByVal BattleScreen As BattleScreen)
Private Sub CreateMainMenuItems(ByRef BattleScreen As BattleScreen)
_mainMenuItemList.Clear()
Select Case BattleScreen.BattleMode
Case BattleSystem.BattleScreen.BattleModes.Safari
Dim safariBallText As String = "Safari Ball x" & Core.Player.Inventory.GetItemAmount(181).ToString()
@ -603,15 +604,33 @@
_mainMenuItemList.Add(New MainMenuItem(3, "Run", 3, AddressOf MainMenuRun))
Case BattleSystem.BattleScreen.BattleModes.Standard
_mainMenuItemList.Add(New MainMenuItem(0, "Battle", 0, AddressOf MainMenuOpenBattleMenu))
_mainMenuItemList.Add(New MainMenuItem(1, "Pokémon", 1, AddressOf MainMenuOpenPokemon))
_mainMenuItemList.Add(New MainMenuItem(2, "Bag", 2, AddressOf MainMenuOpenBag))
If BattleScreen.IsTrainerBattle = False Then
_mainMenuItemList.Add(New MainMenuItem(3, "Run", 3, AddressOf MainMenuRun))
MainMenuAddMegaEvolution(BattleScreen, 4)
If BattleScreen.OwnFaint Then
_mainMenuItemList.Add(New MainMenuItem(1, "Pokémon", 0, AddressOf MainMenuOpenPokemon))
BattleScreen.OwnFaint = False
ElseIf BattleScreen.OppFaint And BattleScreen.IsRemoteBattle Then
If BattleScreen.IsHost Then
BattleScreen.BattleQuery.Clear()
BattleScreen.BattleQuery.Insert(0, New ToggleMenuQueryObject(True))
BattleScreen.OppFaint = False
BattleScreen.Battle.InitializeRound(BattleScreen, New Battle.RoundConst With {.StepType = Battle.RoundConst.StepTypes.Text, .Argument = "The client sends the next pokemon!"})
Else
BattleScreen.OwnStatistics.Switches += 1
BattleScreen.BattleQuery.Clear()
BattleScreen.BattleQuery.Insert(0, New ToggleMenuQueryObject(True))
BattleScreen.SendClientCommand("TEXT|" & "The host sends the next pokemon!")
End If
BattleScreen.OppFaint = False
Else
MainMenuAddMegaEvolution(BattleScreen, 3)
_mainMenuItemList.Add(New MainMenuItem(0, "Battle", 0, AddressOf MainMenuOpenBattleMenu))
_mainMenuItemList.Add(New MainMenuItem(1, "Pokémon", 1, AddressOf MainMenuOpenPokemon))
_mainMenuItemList.Add(New MainMenuItem(2, "Bag", 2, AddressOf MainMenuOpenBag))
If BattleScreen.IsTrainerBattle = False Then
_mainMenuItemList.Add(New MainMenuItem(3, "Run", 3, AddressOf MainMenuRun))
MainMenuAddMegaEvolution(BattleScreen, 4)
Else
MainMenuAddMegaEvolution(BattleScreen, 3)
End If
End If
Case BattleSystem.BattleScreen.BattleModes.PVP

View File

@ -5,7 +5,12 @@
Inherits Screen
'Used for after fainting switching
Public Shared OwnFaint As Boolean = False
Public Shared OppFaint As Boolean = False
'Used for lead picking in PvP Battles
Public Shared OwnLeadIndex As Integer = 0
Public Shared OppLeadIndex As Integer = 0
@ -1270,6 +1275,8 @@ nextIndex:
Battle.Won = True
EndBattle(False)
PVPLobbyScreen.BattleSuccessful = False
OwnFaint = False
OppFaint = False
Return False
End If
Else
@ -1279,6 +1286,8 @@ nextIndex:
Battle.Won = False
EndBattle(False)
PVPLobbyScreen.BattleSuccessful = False
OwnFaint = False
OppFaint = False
Return False
End If
End If
@ -1369,6 +1378,21 @@ nextIndex:
Dim newQueries As New List(Of String)
Dim tempData As String = ""
Dim cData As String = data
Dim s As Screen = Core.CurrentScreen
While Not s.PreScreen Is Nothing And s.Identification <> Identifications.BattleScreen
s = s.PreScreen
End While
If s.Identification = Identifications.BattleScreen Then
If data = "-HostFainted-" Then
OppFaint = True
Exit Sub
End If
If data = "-ClientFainted-" Then
OwnFaint = True
Exit Sub
End If
End If
While cData.Length > 0
If cData(0).ToString() = "|" AndAlso tempData(tempData.Length - 1).ToString() = "}" Then
@ -1385,10 +1409,7 @@ nextIndex:
tempData = ""
End If
Dim s As Screen = Core.CurrentScreen
While Not s.PreScreen Is Nothing And s.Identification <> Identifications.BattleScreen
s = s.PreScreen
End While
If s.Identification = Identifications.BattleScreen Then
CType(s, BattleScreen).BattleQuery.Clear()

View File

@ -603,6 +603,8 @@
MusicManager.PlayMusic("lobby", False)
Core.Player.Pokemons.Clear()
Core.Player.Pokemons.AddRange(TempOriginalTeam.ToArray())
BattleSystem.BattleScreen.OwnFaint = False
BattleSystem.BattleScreen.OppFaint = False
End If
End Sub
@ -655,6 +657,8 @@
Else
PlayerStatistics.Track("PVP Losses", 1)
End If
BattleSystem.BattleScreen.OwnFaint = False
BattleSystem.BattleScreen.OppFaint = False
End Sub
Private Sub DrawBattleResults()