From 034fa14393cd5937798d29c170360b3ba6d956a5 Mon Sep 17 00:00:00 2001 From: Jasper Speelman Date: Fri, 22 Aug 2025 16:52:55 +0200 Subject: [PATCH] Implemented Cud Chew Ability --- P3D/Battle/BattleSystemV2/Battle.vb | 93 +++++++++++++++++++++++ P3D/Battle/BattleSystemV2/BattleMenu.vb | 6 ++ P3D/Battle/BattleSystemV2/FieldEffects.vb | 4 + P3D/P3D.vbproj | 1 + P3D/Pokemon/Abilities/Ability.vb | 4 +- P3D/Pokemon/Abilities/CudChew.vb | 13 ++++ 6 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 P3D/Pokemon/Abilities/CudChew.vb diff --git a/P3D/Battle/BattleSystemV2/Battle.vb b/P3D/Battle/BattleSystemV2/Battle.vb index f2a28e4bf..b5203751e 100644 --- a/P3D/Battle/BattleSystemV2/Battle.vb +++ b/P3D/Battle/BattleSystemV2/Battle.vb @@ -4927,6 +4927,59 @@ End If End Sub + Public Sub UseEffectBerry(ByVal own As Boolean, ByVal from As Boolean, ByVal BerryItem As Item, ByVal BattleScreen As BattleScreen, ByVal message As String, ByVal cause As String) + Dim p As Pokemon = BattleScreen.OwnPokemon + Dim op As Pokemon = BattleScreen.OppPokemon + If own = False Then + p = BattleScreen.OppPokemon + op = BattleScreen.OwnPokemon + End If + + Select Case BerryItem.Name.ToLower() + Case "lum" + If p.Status = Pokemon.StatusProblems.Burn Then + BattleScreen.BattleQuery.Add(New PlaySoundQueryObject("single_heal", False)) + CureStatusProblem(own, own, BattleScreen, "The Lum Berry cured the burn of " & p.GetDisplayName() & "!", "berry:lum") + End If + + If p.Status = Pokemon.StatusProblems.Freeze Then + BattleScreen.BattleQuery.Add(New PlaySoundQueryObject("single_heal", False)) + CureStatusProblem(own, own, BattleScreen, "The Lum Berry thraw out " & p.GetDisplayName() & "!", "berry:lum") + End If + + If p.Status = Pokemon.StatusProblems.Paralyzed Then + BattleScreen.BattleQuery.Add(New PlaySoundQueryObject("single_heal", False)) + CureStatusProblem(own, own, BattleScreen, "The Lum Berry cured the paralysis of " & p.GetDisplayName() & "!", "berry:lum") + End If + + If p.Status = Pokemon.StatusProblems.Sleep Then + BattleScreen.BattleQuery.Add(New PlaySoundQueryObject("single_heal", False)) + CureStatusProblem(own, own, BattleScreen, "The Lum Berry woke up " & p.GetDisplayName() & "!", "berry:lum") + End If + Case "rawst" + If p.Status = Pokemon.StatusProblems.Burn Then + BattleScreen.BattleQuery.Add(New PlaySoundQueryObject("single_heal", False)) + CureStatusProblem(own, own, BattleScreen, "The Rawst Berry cured the burn of " & p.GetDisplayName() & "!", "berry:rawst") + End If + Case "aspear" + If p.Status = Pokemon.StatusProblems.Freeze Then + BattleScreen.BattleQuery.Add(New PlaySoundQueryObject("single_heal", False)) + CureStatusProblem(own, own, BattleScreen, "The Aspear Berry thraw out " & p.GetDisplayName() & "!", "berry:aspear") + End If + Case "cheri" + If p.Status = Pokemon.StatusProblems.Paralyzed Then + BattleScreen.BattleQuery.Add(New PlaySoundQueryObject("single_heal", False)) + CureStatusProblem(own, own, BattleScreen, "The Cheri Berry cured the paralysis of " & p.GetDisplayName() & "!", "berry:cheri") + End If + Case "chesto" + If p.Status = Pokemon.StatusProblems.Sleep Then + BattleScreen.BattleQuery.Add(New PlaySoundQueryObject("single_heal", False)) + CureStatusProblem(own, own, BattleScreen, "The Chesto Berry woke up " & p.GetDisplayName() & "!", "berry:chesto") + End If + End Select + + End Sub + Public Sub UseBerry(ByVal own As Boolean, ByVal from As Boolean, ByVal BerryItem As Item, ByVal BattleScreen As BattleScreen, ByVal message As String, ByVal cause As String) Dim p As Pokemon = BattleScreen.OwnPokemon Dim op As Pokemon = BattleScreen.OppPokemon @@ -5056,6 +5109,21 @@ Dim ItemID As Integer = p.Item.ID Dim lostItem As Item = Item.GetItemByID(ItemID.ToString) + Dim CudChewBerries As String() = {"oran", "sitrus", "figy", "wiki", "mago", "aguav", "iapapa", "liechi", "ganlon", "salac", "petaya", "apicot", "lansat", "starf", "lum", "rawst", "aspear", "cheri", "chesto"} + If CudChewBerries.Contains(lostItem.Name.ToLower) Then + If lostItem.IsBerry = True Then + If p.Ability.Name.ToLower() = "cud chew" Then + If own = True Then + BattleScreen.FieldEffects.OwnCudChewBerry = lostItem + BattleScreen.FieldEffects.OwnCudChewIndex = BattleScreen.OwnPokemonIndex + Else + BattleScreen.FieldEffects.OppCudChewBerry = lostItem + BattleScreen.FieldEffects.OppCudChewIndex = BattleScreen.OppPokemonIndex + End If + End If + End If + End If + If from = own Then If own = True Then BattleScreen.FieldEffects.OwnConsumedItem = lostItem @@ -6615,6 +6683,18 @@ End If End If + If .FieldEffects.OwnCudChewIndex <> -1 AndAlso .FieldEffects.OwnCudChewBerry IsNot Nothing Then + .BattleQuery.Add(New TextQueryObject(.OwnPokemon.GetDisplayName() & " regurgitated the " & .FieldEffects.OwnCudChewBerry.Name & " Berry due to Cud Chew!")) + Dim RegularBerries As String() = {"oran", "sitrus", "figy", "wiki", "mago", "aguav", "iapapa", "liechi", "ganlon", "salac", "petaya", "apicot", "lansat", "starf"} + If RegularBerries.Contains(.FieldEffects.OwnCudChewBerry.Name.ToLower) Then + UseBerry(True, True, .FieldEffects.OwnCudChewBerry, BattleScreen, "", "ability:cudchew") + Else + UseEffectBerry(True, True, .FieldEffects.OwnCudChewBerry, BattleScreen, "", "ability:cudchew") + End If + .FieldEffects.OwnCudChewBerry = Nothing + .FieldEffects.OwnCudChewIndex = -1 + End If + If .OwnPokemon.HP > 0 Then If .OwnPokemon.Ability.Name.ToLower() = "moody" Then Dim cannotRaise As New List(Of Integer) @@ -7508,6 +7588,19 @@ End If End If + If .FieldEffects.OppCudChewIndex <> -1 AndAlso .FieldEffects.OppCudChewBerry IsNot Nothing Then + .BattleQuery.Add(New TextQueryObject(.OppPokemon.GetDisplayName() & " regurgitated the " & .FieldEffects.OppCudChewBerry.Name & " Berry due to Cud Chew!")) + Dim RegularBerries As String() = {"oran", "sitrus", "figy", "wiki", "mago", "aguav", "iapapa", "liechi", "ganlon", "salac", "petaya", "apicot", "lansat", "starf"} + If RegularBerries.Contains(.FieldEffects.OppCudChewBerry.Name.ToLower) Then + UseBerry(False, False, .FieldEffects.OppCudChewBerry, BattleScreen, "", "ability:cudchew") + Else + UseEffectBerry(False, False, .FieldEffects.OwnCudChewBerry, BattleScreen, "", "ability:cudchew") + End If + + .FieldEffects.OppCudChewBerry = Nothing + .FieldEffects.OppCudChewIndex = -1 + End If + If .OppPokemon.HP > 0 Then If .OppPokemon.Ability.Name.ToLower() = "moody" Then Dim cannotRaise As New List(Of Integer) diff --git a/P3D/Battle/BattleSystemV2/BattleMenu.vb b/P3D/Battle/BattleSystemV2/BattleMenu.vb index 7ff6b1470..911eac11a 100644 --- a/P3D/Battle/BattleSystemV2/BattleMenu.vb +++ b/P3D/Battle/BattleSystemV2/BattleMenu.vb @@ -1198,6 +1198,12 @@ Dim Item As Item = Item.GetItemByID(TempItemID) If Item.UseOnPokemon(PokeIndex) = True Then + Dim CudChewBerries As String() = {"oran", "sitrus", "figy", "wiki", "mago", "aguav", "iapapa", "liechi", "ganlon", "salac", "petaya", "apicot", "lansat", "starf", "lum", "rawst", "aspear", "cheri", "chesto"} + If Core.Player.Pokemons(PokeIndex).Ability.Name.ToLower() = "cud chew" AndAlso Item.IsBerry = True AndAlso CudChewBerries.Contains(Item.Name.ToLower) Then + TempBattleScreen.FieldEffects.OwnCudChewBerry = Item + TempBattleScreen.FieldEffects.OwnCudChewIndex = PokeIndex + End If + TempBattleScreen.BattleQuery.Clear() TempBattleScreen.BattleQuery.Add(TempBattleScreen.FocusBattle()) TempBattleScreen.BattleQuery.Insert(0, New ToggleMenuQueryObject(True)) diff --git a/P3D/Battle/BattleSystemV2/FieldEffects.vb b/P3D/Battle/BattleSystemV2/FieldEffects.vb index fd4790242..3f87894d5 100644 --- a/P3D/Battle/BattleSystemV2/FieldEffects.vb +++ b/P3D/Battle/BattleSystemV2/FieldEffects.vb @@ -102,6 +102,8 @@ Public OwnUsedMoves As New List(Of Integer) Public OwnMagicCoat As Integer = 0 Public OwnConsumedItem As Item = Nothing + Public OwnCudChewBerry As Item = Nothing 'Cud Chew Ability + Public OwnCudChewIndex As Integer = -1 Public OwnSmacked As Integer = 0 'Smack Down effect condition Public OwnPursuit As Boolean = False Public OwnMegaEvolved As Boolean = False @@ -231,6 +233,8 @@ Public OppPokemonDamagedLastTurn As Boolean = False Public OppMagicCoat As Integer = 0 Public OppConsumedItem As Item = Nothing + Public OppCudChewBerry As Item = Nothing + Public OppCudChewIndex As Integer = -1 Public OppSmacked As Integer = 0 Public OppPursuit As Boolean = False Public OppMegaEvolved As Boolean = False diff --git a/P3D/P3D.vbproj b/P3D/P3D.vbproj index 3249e8c0e..ca454b7a6 100644 --- a/P3D/P3D.vbproj +++ b/P3D/P3D.vbproj @@ -28842,6 +28842,7 @@ + diff --git a/P3D/Pokemon/Abilities/Ability.vb b/P3D/Pokemon/Abilities/Ability.vb index 56be44022..9e8dfc387 100644 --- a/P3D/Pokemon/Abilities/Ability.vb +++ b/P3D/Pokemon/Abilities/Ability.vb @@ -619,8 +619,8 @@ 'Hadron Engine 'Case 290 'Opportunist - 'Case 291 - 'Cud Chew + Case 291 + Return New Abilities.CudChew 'Case 292 'Sharpness 'Case 293 diff --git a/P3D/Pokemon/Abilities/CudChew.vb b/P3D/Pokemon/Abilities/CudChew.vb new file mode 100644 index 000000000..4a307f8ca --- /dev/null +++ b/P3D/Pokemon/Abilities/CudChew.vb @@ -0,0 +1,13 @@ +Namespace Abilities + + Public Class CudChew + + Inherits Ability + + Public Sub New() + MyBase.New(291, "Cud Chew", "When the Pokémon eats a Berry, it will regurgitate that Berry at the end of the next turn and eat it one more time.") + End Sub + + End Class + +End Namespace \ No newline at end of file