From cdccbfcc678912081d656433673cdb4db0048517 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Sun, 15 Jan 2023 11:40:43 +0100 Subject: [PATCH] Fix for Trick and Recycle --- P3D/Battle/BattleSystemV2/BattleScreen.vb | 8 +++++--- P3D/Pokemon/Attacks/Normal/Recycle.vb | 7 ++++++- P3D/Pokemon/Attacks/Psychic/Trick.vb | 10 +++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/P3D/Battle/BattleSystemV2/BattleScreen.vb b/P3D/Battle/BattleSystemV2/BattleScreen.vb index 7f6541dd7..91b780fc6 100644 --- a/P3D/Battle/BattleSystemV2/BattleScreen.vb +++ b/P3D/Battle/BattleSystemV2/BattleScreen.vb @@ -1250,12 +1250,13 @@ nextIndex: Core.Player.Inventory.AddItem(p.OriginalItem.ID, 1) SoundManager.PlaySound("item_found", True) Screen.TextBox.Show(Core.Player.Name & " found~" & p.OriginalItem.Name & "!*" & Core.Player.Inventory.GetMessageReceive(p.OriginalItem, 1)) + p.OriginalItem = Nothing Else p.Item = P3D.Item.GetItemByID(p.OriginalItem.ID) p.Item.AdditionalData = p.OriginalItem.AdditionalData Screen.TextBox.Show(Core.Player.Name & " found~" & p.OriginalItem.Name & "*and gave it back to~" & p.GetDisplayName) + p.OriginalItem = Nothing End If - p.OriginalItem = Nothing End If End If p.ResetTemp() @@ -1310,13 +1311,14 @@ nextIndex: If p.Item IsNot Nothing Then Core.Player.Inventory.AddItem(p.OriginalItem.ID, 1) SoundManager.PlaySound("item_found", True) - Screen.TextBox.Show(Core.Player.Name & " found~" & p.originalItem.Name & "!*" & Core.Player.Inventory.GetMessageReceive(p.originalItem, 1)) + Screen.TextBox.Show(Core.Player.Name & " found~" & p.OriginalItem.Name & "!*" & Core.Player.Inventory.GetMessageReceive(p.OriginalItem, 1)) + p.OriginalItem = Nothing Else p.Item = P3D.Item.GetItemByID(p.OriginalItem.ID) p.Item.AdditionalData = p.OriginalItem.AdditionalData Screen.TextBox.Show(Core.Player.Name & " found~" & p.OriginalItem.Name & "*and gave it back to~" & p.GetDisplayName) + p.OriginalItem = Nothing End If - p.OriginalItem = Nothing End If End If p.ResetTemp() diff --git a/P3D/Pokemon/Attacks/Normal/Recycle.vb b/P3D/Pokemon/Attacks/Normal/Recycle.vb index b7cc703c2..aac295224 100644 --- a/P3D/Pokemon/Attacks/Normal/Recycle.vb +++ b/P3D/Pokemon/Attacks/Normal/Recycle.vb @@ -58,9 +58,11 @@ Public Overrides Sub MoveHits(own As Boolean, BattleScreen As BattleScreen) If own = True Then Dim p As Pokemon = BattleScreen.OwnPokemon - If Not BattleScreen.FieldEffects.OwnConsumedItem Is Nothing Then p.Item = BattleScreen.FieldEffects.OwnConsumedItem + If p.OriginalItem IsNot Nothing Then + p.OriginalItem = Nothing + End If BattleScreen.BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " found one " & p.Item.Name & "!")) Else BattleScreen.BattleQuery.Add(New TextQueryObject("Recycle failed!")) @@ -70,6 +72,9 @@ If Not BattleScreen.FieldEffects.OppConsumedItem Is Nothing Then p.Item = BattleScreen.FieldEffects.OppConsumedItem + If p.OriginalItem IsNot Nothing Then + p.OriginalItem = Nothing + End If BattleScreen.BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " found one " & p.Item.Name & "!")) Else BattleScreen.BattleQuery.Add(New TextQueryObject("Recycle failed!")) diff --git a/P3D/Pokemon/Attacks/Psychic/Trick.vb b/P3D/Pokemon/Attacks/Psychic/Trick.vb index 36440abc4..363a15a13 100644 --- a/P3D/Pokemon/Attacks/Psychic/Trick.vb +++ b/P3D/Pokemon/Attacks/Psychic/Trick.vb @@ -106,10 +106,14 @@ Namespace BattleSystem.Moves.Psychic If CanSwitchItems Then Dim i1 As Item = Nothing Dim i2 As Item = Nothing - If own = True Then - p.OriginalItem = p.Item + If own = True Then + If p.Item IsNot Nothing Then + p.OriginalItem = p.Item + End If Else - op.OriginalItem = op.Item + If op.Item IsNot Nothing Then + op.OriginalItem = op.Item + End If End If If p.Item IsNot Nothing Then i1 = p.Item