From 7ae9ebaa50f103470f85866e85bd550c9bdafedc Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Fri, 13 Jan 2023 14:07:35 +0100 Subject: [PATCH] Multimove Bug Fixed --- P3D/Battle/BattleSystemV2/Battle.vb | 23 ++- P3D/Battle/BattleSystemV2/BattleScreen.vb | 2 + .../QueryObjects/SwitchPokemonQueryObject.vb | 168 +++++++++++++++++- P3D/Pokemon/Attacks/AttackSpecialFunctions.vb | 1 - 4 files changed, 185 insertions(+), 9 deletions(-) diff --git a/P3D/Battle/BattleSystemV2/Battle.vb b/P3D/Battle/BattleSystemV2/Battle.vb index 828c82bc5..99126fdf6 100644 --- a/P3D/Battle/BattleSystemV2/Battle.vb +++ b/P3D/Battle/BattleSystemV2/Battle.vb @@ -234,7 +234,9 @@ SelectedMoveOpp = True If Not BattleScreen.IsRemoteBattle Then - StartMultiTurnAction(BattleScreen) + If BattleScreen.HasSwitchedOwn = False Then + StartMultiTurnAction(BattleScreen) + End If End If 'Going to menu: @@ -247,6 +249,7 @@ For i = 0 To 99 BattleScreen.InsertCasualCameramove() Next + BattleScreen.HasSwitchedOwn = False End Sub Public Function GetOppStep(ByVal BattleScreen As BattleScreen, ByVal OwnStep As RoundConst) As RoundConst @@ -5372,7 +5375,9 @@ BattleScreen.BattleQuery.AddRange({cq1, cq2}) - StartRound(BattleScreen) + If BattleScreen.OppFaint = False Then + StartRound(BattleScreen) + End If BattleScreen.ClearMainMenuTime = True BattleScreen.ClearMoveMenuTime = True Case 1 'Own round @@ -7820,13 +7825,17 @@ BattleScreen.BattleQuery.Add(New TextQueryObject(BattleScreen.Trainer.Name & ": ""Come back, " & BattleScreen.OppPokemon.GetDisplayName() & "!""")) If Core.Player.ShowBattleAnimations <> 0 Then + Dim PositionOffsetY As Single = 0.0F + If BattleScreen.OppPokemonNPC.Model IsNot Nothing Then + PositionOffsetY = 0.5F + End If Dim BallReturn As AnimationQueryObject = New AnimationQueryObject(BattleScreen.OppPokemonNPC, True) ' Ball Closes BallReturn.AnimationPlaySound("Battle\Pokeball\Open", 0, 0) Dim SmokeReturned As Integer = 0 Do - Dim SmokePosition = New Vector3(CSng(Random.Next(-10, 10) / 10), CSng(Random.Next(-10, 10) / 10), CSng(Random.Next(-10, 10) / 10)) + Dim SmokePosition = New Vector3(CSng(Random.Next(-10, 10) / 10), CSng(Random.Next(-10, 10) / 10) + PositionOffsetY, CSng(Random.Next(-10, 10) / 10)) Dim SmokeDestination = New Vector3(0, 0, 0) Dim SmokeTexture As Texture2D = TextureManager.GetTexture("Textures\Battle\Smoke") @@ -7844,8 +7853,8 @@ ' Ball returns BallReturn.AnimationPlaySound("Battle\Pokeball\Throw", 1, 0) - Dim BallReturnEntity = BallReturn.SpawnEntity(New Vector3(0, 0, 0), BattleScreen.OppPokemon.CatchBall.Texture, New Vector3(0.3F), 1.0F) - BallReturn.AnimationMove(BallReturnEntity, True, -2, 0, 0, 0.1, False, True, 0F, 0F,, 0.3) + Dim BallReturnEntity = BallReturn.SpawnEntity(New Vector3(0, 0 + PositionOffsetY, 0), BattleScreen.OppPokemon.CatchBall.Texture, New Vector3(0.3F), 1.0F) + BallReturn.AnimationMove(BallReturnEntity, True, -2, 0, 0 + PositionOffsetY, 0.1, False, True, 0F, 0F,, 0.3) BattleScreen.BattleQuery.Add(BallReturn) Else @@ -7867,7 +7876,7 @@ 'Switch BattleStyle If Core.Player.BattleStyle <> 1 And OppStep.StepType <> RoundConst.StepTypes.Switch Then BattleScreen.BattleQuery.Add(New SwitchPokemonQueryObject(BattleScreen, BattleScreen.OppPokemon)) - ChangeCameraAngle(1, False, BattleScreen) + BattleScreen.Battle.ChangeCameraAngle(1, False, BattleScreen) End If If oppModel = "" Then BattleScreen.BattleQuery.Add(New ToggleEntityQueryObject(True, ToggleEntityQueryObject.BattleEntities.OppPokemon, PokemonForms.GetOverworldSpriteName(BattleScreen.OppPokemon), -1, -1, 0, 1)) @@ -7902,6 +7911,8 @@ BallThrow.AnimationMove(SmokeEntity, True, SmokeDestination.X, SmokeDestination.Y, SmokeDestination.Z, SmokeSpeed, False, False, 3.0F, 0.0F) Threading.Interlocked.Increment(SmokeSpawned) Loop While SmokeSpawned <= 38 + Else + BattleScreen.Battle.ChangeCameraAngle(1, False, BattleScreen) End If If Core.Player.ShowBattleAnimations <> 0 Then diff --git a/P3D/Battle/BattleSystemV2/BattleScreen.vb b/P3D/Battle/BattleSystemV2/BattleScreen.vb index b53963f38..980d58b82 100644 --- a/P3D/Battle/BattleSystemV2/BattleScreen.vb +++ b/P3D/Battle/BattleSystemV2/BattleScreen.vb @@ -61,6 +61,8 @@ Public OwnTrainerNPC As NPC Public OppTrainerNPC As NPC + Public HasSwitchedOwn As Boolean = False + Public OwnPokemonIndex As Integer = 0 Public OppPokemonIndex As Integer = 0 diff --git a/P3D/Battle/BattleSystemV2/QueryObjects/SwitchPokemonQueryObject.vb b/P3D/Battle/BattleSystemV2/QueryObjects/SwitchPokemonQueryObject.vb index 9d745775c..97a70fc7b 100644 --- a/P3D/Battle/BattleSystemV2/QueryObjects/SwitchPokemonQueryObject.vb +++ b/P3D/Battle/BattleSystemV2/QueryObjects/SwitchPokemonQueryObject.vb @@ -121,12 +121,26 @@ If New Rectangle(Core.windowSize.Width - 213, Core.windowSize.Height - 378, 80, 50).Contains(MouseHandler.MousePosition) Then _chooseIndex = 1 SoundManager.PlaySound("select") + TempScreen.BattleQuery.Clear() + FinishOppSwitch(TempScreen) + 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 + TempScreen.BattleQuery.AddRange({cq1, cq2}) + TempScreen.Battle.StartRound(TempScreen) _ready = True End If End If End If If Controls.Dismiss(True, True, True) = True Then SoundManager.PlaySound("select") + TempScreen.BattleQuery.Clear() + FinishOppSwitch(TempScreen) + 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 + TempScreen.BattleQuery.AddRange({cq1, cq2}) + TempScreen.Battle.StartRound(TempScreen) _ready = True End If End Sub @@ -174,12 +188,24 @@ TempScreen.BattleQuery.Clear() TempScreen.Battle.SwitchOutOwn(TempScreen, PokeIndex, TempScreen.BattleQuery.Count) TempScreen.BattleQuery.Reverse() - TempScreen.BattleQuery.AddRange(TempQuery) + FinishOppSwitch(TempScreen) + 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 + TempScreen.BattleQuery.AddRange({cq1, cq2}) + TempScreen.HasSwitchedOwn = True + TempScreen.Battle.StartRound(TempScreen) Else TempScreen.BattleQuery.Clear() TempScreen.Battle.SwitchOutOwn(TempScreen, PokeIndex, TempScreen.BattleQuery.Count) TempScreen.BattleQuery.Reverse() - TempScreen.BattleQuery.AddRange(TempQuery) + FinishOppSwitch(TempScreen) + 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 + TempScreen.BattleQuery.AddRange({cq1, cq2}) + TempScreen.HasSwitchedOwn = True + TempScreen.Battle.StartRound(TempScreen) End If Me._ready = True End If @@ -204,6 +230,144 @@ Dim delay As Single = 2.0F + Public Sub FinishOppSwitch(BattleScreen As BattleScreen) + BattleScreen.OppPokemonNPC.Position.Y = 0 + BattleScreen.Battle.ChangeCameraAngle(1, False, BattleScreen) + Dim oppModel As String = BattleScreen.GetModelName(False) + If oppModel = "" Then + BattleScreen.BattleQuery.Add(New ToggleEntityQueryObject(True, ToggleEntityQueryObject.BattleEntities.OppPokemon, PokemonForms.GetOverworldSpriteName(BattleScreen.OppPokemon), -1, -1, 0, 1)) + Else + BattleScreen.BattleQuery.Add(New ToggleEntityQueryObject(False, oppModel, -1, -1, 1, 0)) + End If + + BattleScreen.BattleQuery.Add(New ToggleEntityQueryObject(True, ToggleEntityQueryObject.BattleEntities.OppPokemon, 1, -1, -1, -1, -1)) + BattleScreen.BattleQuery.Add(New TextQueryObject(BattleScreen.Trainer.Name & ": ""Go, " & BattleScreen.OppPokemon.GetDisplayName() & "!""")) + + Dim BallThrow As AnimationQueryObject = New AnimationQueryObject(BattleScreen.OppPokemonNPC, False) + If Core.Player.ShowBattleAnimations <> 0 Then + ' Ball is thrown + BallThrow.AnimationMove(Nothing, False, 0, 0.5, 0, 0.5, False, False, 0, 0,,, 3) + + BallThrow.AnimationPlaySound("Battle\Pokeball\Throw", 0, 0) + Dim BallThrowEntity = BallThrow.SpawnEntity(New Vector3(2, -0.15, 0), BattleScreen.OppPokemon.CatchBall.Texture, New Vector3(0.3F), 1.0F) + BallThrow.AnimationMove(BallThrowEntity, True, 0, 0.35, 0, 0.1, False, True, 0F, 0.5F,, 0.3,, 0.025F) + + ' Ball opens + BallThrow.AnimationPlaySound("Battle\Pokeball\Open", 3, 0) + Dim SmokeSpawned As Integer = 0 + Do + Dim SmokePosition = New Vector3(0, 0.35, 0) + Dim SmokeDestination = New Vector3(CSng(Random.Next(-10, 10) / 10), CSng(Random.Next(-10, 10) / 10), CSng(Random.Next(-10, 10) / 10)) + + Dim SmokeTexture As Texture2D = TextureManager.GetTexture("Textures\Battle\Smoke") + + Dim SmokeScale = New Vector3(CSng(Random.Next(2, 6) / 10)) + Dim SmokeSpeed = CSng(Random.Next(1, 3) / 20.0F) + Dim SmokeEntity = BallThrow.SpawnEntity(SmokePosition, SmokeTexture, SmokeScale, 1, 3) + + BallThrow.AnimationMove(SmokeEntity, True, SmokeDestination.X, SmokeDestination.Y, SmokeDestination.Z, SmokeSpeed, False, False, 3.0F, 0.0F) + Threading.Interlocked.Increment(SmokeSpawned) + Loop While SmokeSpawned <= 38 + End If + + If Core.Player.ShowBattleAnimations <> 0 Then + ' Pokemon appears + BallThrow.AnimationFade(Nothing, False, 1, True, 1, 3, 0) + BallThrow.AnimationPlaySound(CStr(BattleScreen.OppPokemon.Number), 4, 0,, True) + ' Pokémon falls down + BallThrow.AnimationMove(Nothing, False, 0, 0, 0, 0.05F, False, False, 5, 0) + Else + ' Pokemon appears + BallThrow.AnimationFade(Nothing, False, 1, True, 1, 0, 0) + BallThrow.AnimationPlaySound(CStr(BattleScreen.OppPokemon.Number), 0, 0,, True) + End If + BattleScreen.BattleQuery.Add(BallThrow) + + With BattleScreen + Dim p As Pokemon = .OppPokemon + Dim op As Pokemon = .OwnPokemon + + Dim spikeAffected As Boolean = True + Dim rockAffected As Boolean = True + + spikeAffected = BattleScreen.FieldEffects.IsGrounded(False, BattleScreen) + + If spikeAffected = True Then + If .FieldEffects.OwnSpikes > 0 And p.Ability.Name.ToLower() <> "magic guard" Then + Dim spikeDamage As Double = 1D + Select Case .FieldEffects.OwnSpikes + Case 1 + spikeDamage = (p.MaxHP / 100) * 12.5D + Case 2 + spikeDamage = (p.MaxHP / 100) * 16.7D + Case 3 + spikeDamage = (p.MaxHP / 100) * 25D + End Select + BattleScreen.Battle.ReduceHP(CInt(spikeDamage), False, True, BattleScreen, "The Spikes hurt " & p.GetDisplayName() & "!", "spikes") + End If + End If + 'Sticky Web + If spikeAffected = True Then + If .FieldEffects.OwnStickyWeb > 0 Then + BattleScreen.Battle.LowerStat(False, False, BattleScreen, "Speed", 1, "The opposing pokemon was caught in a Sticky Web!", "stickyweb") + End If + End If + If spikeAffected = True Then + If .FieldEffects.OwnToxicSpikes > 0 And p.Status = Pokemon.StatusProblems.None And p.Type1.Type <> Element.Types.Poison And p.Type2.Type <> Element.Types.Poison Then + Select Case .FieldEffects.OwnToxicSpikes + Case 1 + BattleScreen.Battle.InflictPoison(False, True, BattleScreen, False, "The Toxic Spikes hurt " & p.GetDisplayName() & "!", "toxicspikes") + Case 2 + BattleScreen.Battle.InflictPoison(False, True, BattleScreen, True, "The Toxic Spikes hurt " & p.GetDisplayName() & "!", "toxicspikes") + End Select + End If + If .FieldEffects.OwnToxicSpikes > 0 Then + If p.Type1.Type = Element.Types.Poison Or p.Type2.Type = Element.Types.Poison Then + .BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " removed the Toxic Spikes!")) + .FieldEffects.OwnToxicSpikes = 0 + End If + End If + End If + + If rockAffected = True Then + If .FieldEffects.OwnStealthRock > 0 And p.Ability.Name.ToLower() <> "magic guard" Then + Dim rocksDamage As Double = 1D + + Dim effectiveness As Single = BattleCalculation.ReverseTypeEffectiveness(Element.GetElementMultiplier(New Element(Element.Types.Rock), p.Type1)) * BattleCalculation.ReverseTypeEffectiveness(Element.GetElementMultiplier(New Element(Element.Types.Rock), p.Type2)) + Select Case effectiveness + Case 0.25F + rocksDamage = (p.MaxHP / 100) * 3.125D + Case 0.5F + rocksDamage = (p.MaxHP / 100) * 6.25D + Case 1.0F + rocksDamage = (p.MaxHP / 100) * 12.5D + Case 2.0F + rocksDamage = (p.MaxHP / 100) * 25D + Case 4.0F + rocksDamage = (p.MaxHP / 100) * 50D + End Select + + BattleScreen.Battle.ReduceHP(CInt(rocksDamage), False, True, BattleScreen, "The Stealth Rocks hurt " & p.GetDisplayName() & "!", "stealthrocks") + End If + End If + + BattleScreen.Battle.TriggerAbilityEffect(BattleScreen, False) + BattleScreen.Battle.TriggerItemEffect(BattleScreen, False) + + If .OppPokemon.Status = Pokemon.StatusProblems.Sleep Then + .FieldEffects.OppSleepTurns = Core.Random.Next(1, 4) + End If + + If BattleScreen.FieldEffects.OppHealingWish = True Then + BattleScreen.FieldEffects.OppHealingWish = False + + If .OppPokemon.HP < .OppPokemon.MaxHP Or .OppPokemon.Status <> Pokemon.StatusProblems.None Then + BattleScreen.Battle.GainHP(.OppPokemon.MaxHP - .OppPokemon.HP, False, False, BattleScreen, "The Healing Wish came true for " & .OppPokemon.GetDisplayName() & "!", "move:healingwish") + BattleScreen.Battle.CureStatusProblem(False, False, BattleScreen, "", "move:healingwish") + End If + End If + End With + End Sub Public Overrides Sub Update(BV2Screen As BattleScreen) If TextReady = False Then UpdateText() diff --git a/P3D/Pokemon/Attacks/AttackSpecialFunctions.vb b/P3D/Pokemon/Attacks/AttackSpecialFunctions.vb index c17e07e9f..0fe5af41f 100644 --- a/P3D/Pokemon/Attacks/AttackSpecialFunctions.vb +++ b/P3D/Pokemon/Attacks/AttackSpecialFunctions.vb @@ -166,7 +166,6 @@ Else Select Case f.ToLower() Case "endround" - 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