Permanent item loss caused by attacks fix

If an item is swapped/removed/whatever in a battle
  If it's a PvP battle or a Trainer battle
    Every Pokémon that has its item removed gets its original item back
  If it's a Wild battle
    If a Pokémon that had its original item removed is holding
    a different item (because of the attack Trick for example)
      The Pokémon keeps the new item and the original item is added to
      the inventory.
This commit is contained in:
JappaWakkaP3D 2021-01-30 22:34:02 +01:00
parent 9147437d7b
commit d8f7319bc7
3 changed files with 30 additions and 7 deletions

View File

@ -1036,8 +1036,6 @@ nextIndex:
End If
TempPokeFile = ""
OwnPokemon.ResetTemp()
If IsRemoteBattle = False Then
If ConnectScreen.Connected = True Then
If Battle.Won = False Then
@ -1081,6 +1079,11 @@ nextIndex:
If p.hasLeveledUp = True Then
hasLevelUp = True
End If
If IsRemoteBattle = True Or IsTrainerBattle = True Then
p.Item = P3D.Item.GetItemByID(p.OriginalItem.ID)
p.Item.AdditionalData = p.OriginalItem.AdditionalData
Screen.TextBox.Show(Core.Player.Name & " received" & p.OriginalItem.Name & "*and gave it back to~" & p.GetDisplayName)
End If
p.ResetTemp()
Next
If hasLevelUp = False Then
@ -1118,6 +1121,14 @@ nextIndex:
End If
Next
Else
For Each p As Pokemon In Core.Player.Pokemons
If IsRemoteBattle = True Or IsTrainerBattle = True Then
p.Item = P3D.Item.GetItemByID(p.OriginalItem.ID)
p.Item.AdditionalData = p.OriginalItem.AdditionalData
Screen.TextBox.Show(Core.Player.Name & " received~" & p.OriginalItem.Name & "*and gave it back to~" & p.GetDisplayName)
End If
p.ResetTemp()
Next
ResetVars()
Core.SetScreen(New TransitionScreen(Me, New BlackOutScreen(Me), Color.Black, False))
End If

View File

@ -106,6 +106,11 @@ 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
Else
op.OriginalItem = op.Item
End If
If p.Item IsNot Nothing Then
i1 = p.Item
End If

View File

@ -1014,11 +1014,18 @@ Public Class Pokemon
Me.Ability = Me._originalAbility
'If Not Me._originalItem Is Nothing Then
' Me.Item = P3D.Item.GetItemByID(Me._originalItem.ID)
' Me.Item.AdditionalData = Me._originalItem.AdditionalData
' Me._originalItem = Nothing
'End If
If Not Me._originalItem Is Nothing Then
If Me.Item IsNot Nothing Then
Core.Player.Inventory.AddItem(Me._originalItem.ID, 1)
SoundManager.PlaySound("item_found", True)
Screen.TextBox.Show(Core.Player.Name & " found~" & Me._originalItem.Name & "!*" & Core.Player.Inventory.GetMessageReceive(_originalItem, 1))
Else
Me.Item = P3D.Item.GetItemByID(Me._originalItem.ID)
Me.Item.AdditionalData = Me._originalItem.AdditionalData
Screen.TextBox.Show(Core.Player.Name & " found~" & Me._originalItem.Name & "*and gave it back to~" & Me.GetDisplayName)
End If
Me._originalItem = Nothing
End If
Me.IsTransformed = False