P3D-Legacy/P3D/Pokemon/Items/Medicine/RareCandy.vb

95 lines
4.1 KiB
VB.net
Raw Normal View History

Namespace Items.Medicine
2016-09-07 18:50:38 +02:00
<Item(32, "Rare Candy")>
2016-09-07 18:50:38 +02:00
Public Class RareCandy
Inherits MedicineItem
2016-09-07 18:50:38 +02:00
2016-09-20 05:11:31 +02:00
Public Overrides ReadOnly Property Description As String = "A candy that is packed with energy. When consumed, it will instantly raise the level of a single Pokémon by one."
Public Overrides ReadOnly Property PokeDollarPrice As Integer = 4800
Public Overrides ReadOnly Property BattlePointsPrice As Integer = 48
2016-09-07 18:50:38 +02:00
2016-09-20 05:11:31 +02:00
Public Sub New()
_textureRectangle = New Rectangle(192, 24, 24, 24)
2016-09-07 18:50:38 +02:00
End Sub
Public Overrides Sub Use()
Dim selScreen = New PartyScreen(Core.CurrentScreen, Me, AddressOf Me.UseOnPokemon, "Use " & Me.Name, True) With {.Mode = Screens.UI.ISelectionScreen.ScreenMode.Selection, .CanExit = True}
AddHandler selScreen.SelectedObject, AddressOf UseItemhandler
Core.SetScreen(selScreen)
2016-09-07 18:50:38 +02:00
End Sub
Public Overrides Function UseOnPokemon(ByVal PokeIndex As Integer) As Boolean
Dim Pokemon As Pokemon = Core.Player.Pokemons(PokeIndex)
If Pokemon.Level < CInt(GameModeManager.GetGameRuleValue("MaxLevel", "100")) And Pokemon.IsEgg() = False Then
Dim beforeHP As Integer = Pokemon.MaxHP
Pokemon.LevelUp(False)
Pokemon.Experience = Pokemon.NeedExperience(Pokemon.Level)
If Pokemon.Status = P3D.Pokemon.StatusProblems.Fainted Then
Pokemon.Status = P3D.Pokemon.StatusProblems.None
2016-09-07 18:50:38 +02:00
Pokemon.HP = (Pokemon.MaxHP - beforeHP).Clamp(1, 999)
End If
Dim s As String =
"version=2" & Environment.NewLine &
"@sound.play(success_small)" & Environment.NewLine &
"@text.show(" & Pokemon.GetDisplayName() & " reached~level " & Pokemon.Level & "!)" & Environment.NewLine
2016-09-07 18:50:38 +02:00
Dim removedItem As Boolean = False
If Pokemon.AttackLearns.ContainsKey(Pokemon.Level) = True Then
If Pokemon.KnowsMove(Pokemon.AttackLearns(Pokemon.Level)) = False Then
If Pokemon.Attacks.Count = 4 Then
s &= "@pokemon.learnattack(" & PokeIndex & "," & Pokemon.AttackLearns(Pokemon.Level).ID & ")" & Environment.NewLine
2016-09-07 18:50:38 +02:00
Dim t As String = Me.RemoveItem()
If t <> "" Then
s &= "@text.show(" & t & ")" & Environment.NewLine
2016-09-07 18:50:38 +02:00
End If
removedItem = True
Else
Pokemon.Attacks.Add(Pokemon.AttackLearns(Pokemon.Level))
s &= "@sound.play(success_small)" & Environment.NewLine &
"@text.show(" & Pokemon.GetDisplayName() & " learned~" & Pokemon.AttackLearns(Pokemon.Level).Name & "!*" & Me.RemoveItem() & ")" & Environment.NewLine
2016-09-07 18:50:38 +02:00
removedItem = True
PlayerStatistics.Track("Moves learned", 1)
End If
End If
End If
If Pokemon.CanEvolve(EvolutionCondition.EvolutionTrigger.LevelUp, "") = True Then
s &= "@pokemon.evolve(" & PokeIndex & ")" & Environment.NewLine
2016-09-07 18:50:38 +02:00
End If
If removedItem = False Then
Dim t As String = Me.RemoveItem()
If t <> "" Then
s &= "@text.show(" & t & ")" & Environment.NewLine
2016-09-07 18:50:38 +02:00
End If
End If
s &= ":end"
Dim sc As Screen = Core.CurrentScreen
While sc.Identification <> Screen.Identifications.OverworldScreen
sc = sc.PreScreen
End While
Core.SetScreen(sc)
CType(sc, OverworldScreen).ActionScript.StartScript(s, 2, False)
PlayerStatistics.Track("[17]Medicine Items used", 1)
Return True
Else
Return False
End If
End Function
End Class
End Namespace