Implemented Regenerator and Imposter abilities, fixed critical EV Gaining crash

This commit is contained in:
CaptainSegis 2016-10-30 16:53:09 -05:00
parent 9f11078e6b
commit 45d770ed97
2 changed files with 130 additions and 74 deletions

View File

@ -3850,6 +3850,52 @@
.BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & "'s type changed to " & p.Type1.ToString() & "!"))
Case "imposter"
'Doing the ditto stuff!
ChangeCameraAngel(1, own, BattleScreen)
If op.IsTransformed = False Then
'Save old stats:
p.OriginalNumber = p.Number
p.OriginalType1 = New Element(p.Type1.Type)
p.OriginalType2 = New Element(p.Type2.Type)
p.OriginalStats = {p.Attack, p.Defense, p.SpAttack, p.SpDefense, p.Speed}
p.OriginalShiny = CInt(p.IsShiny.ToNumberString())
p.OriginalMoves = New List(Of BattleSystem.Attack)
p.OriginalMoves.AddRange(p.Attacks.ToArray())
p.OriginalAbility = Ability.GetAbilityByID(p.Ability.ID)
'Apply new stats:
p.Number = op.Number
p.Type1 = New Element(op.Type1.Type)
p.Type2 = New Element(op.Type2.Type)
p.Attack = op.Attack
p.Defense = op.Defense
p.SpAttack = op.SpAttack
p.SpDefense = op.SpDefense
p.Speed = op.Speed
p.StatAttack = op.StatAttack
p.StatDefense = op.StatDefense
p.StatSpAttack = op.StatSpAttack
p.StatSpDefense = op.StatSpDefense
p.StatSpeed = op.StatSpeed
p.IsShiny = op.IsShiny
p.Attacks.Clear()
p.Attacks.AddRange(op.Attacks.ToArray())
p.Ability = Ability.GetAbilityByID(op.Ability.ID)
p.IsTransformed = True
'Apply new image to sprite:
BattleScreen.BattleQuery.Add(New ToggleEntityQueryObject(own, ToggleEntityQueryObject.BattleEntities.OwnPokemon, PokemonForms.GetOverworldSpriteName(p), 0, 1, -1, -1))
BattleScreen.BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " transformed into " & op.OriginalName & "!"))
Else
'Fails
BattleScreen.BattleQuery.Add(New TextQueryObject("imposter failed!"))
End If
End Select
End If
End With
@ -5609,7 +5655,15 @@
.AddToQuery(InsertIndex, New TextQueryObject(.OwnPokemon.GetDisplayName() & "'s status problem got healed by Natural Cure"))
End If
End If
'Regenerator ability heals 1/3 of it's max HP
If .OwnPokemon.Ability.Name.ToLower() = "regenerator" Then
If Not (.OwnPokemon.Status = Pokemon.StatusProblems.Fainted Or .OwnPokemon.HP = 0) Then
Dim restoreHP = CInt(.OwnPokemon.MaxHP / 3)
If restoreHP > 0 And .OwnPokemon.HP < .OwnPokemon.MaxHP And .OwnPokemon.HP > 0 Then
BattleScreen.Battle.GainHP(restoreHP, True, True, BattleScreen, .OwnPokemon.GetDisplayName() & "'s HP was restored!", "ability:regenerator")
End If
End If
End If
'save baton pass stuff:
If .FieldEffects.OwnUsedBatonPass = True Then
.FieldEffects.OwnBatonPassStats = New List(Of Integer)
@ -5920,7 +5974,15 @@
.BattleQuery.Add(New TextQueryObject(.OppPokemon.GetDisplayName() & "'s status problem got healed by Natural Cure"))
End If
End If
'Regenerator ability heals 1/3 of it's max HP
If .OppPokemon.Ability.Name.ToLower() = "regenerator" Then
If Not (.OppPokemon.Status = Pokemon.StatusProblems.Fainted Or .OppPokemon.HP = 0) Then
Dim restoreHP = CInt(.OppPokemon.MaxHP / 3)
If restoreHP > 0 And .OppPokemon.HP < .OppPokemon.MaxHP And .OppPokemon.HP > 0 Then
BattleScreen.Battle.GainHP(restoreHP, False, True, BattleScreen, .OppPokemon.GetDisplayName() & "'s HP was restored!", "ability:regenerator")
End If
End If
End If
'save baton pass stuff:
If .FieldEffects.OppUsedBatonPass = True Then
.FieldEffects.OppBatonPassStats = New List(Of Integer)

View File

@ -2695,93 +2695,87 @@ Public Class Pokemon
If allEV < 510 Then
maxGainEV = 510 - allEV
End If
Dim EVfactor As Integer = 1
If maxGainEV > 0 Then
maxGainEV = CInt(MathHelper.Clamp(maxGainEV, 1, 6))
Select Case pokemon.Item.ID()
Case 582, 583, 584, 585, 586, 587 'EV Items
If Not pokemon.Item Is Nothing Then
Select Case pokemon.Item.ID()
Case 582, 583, 584, 585, 586, 587 'EV Items
If Me.EVHP < 252 And pokemon.Item.ID = 582 Then
Me.EVHP += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
If Me.EVAttack < 252 And pokemon.Item.ID = 583 Then
Me.EVAttack += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
If Me.EVDefense < 252 And pokemon.Item.ID = 584 Then
Me.EVDefense += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
If Me.EVSpAttack < 252 And pokemon.Item.ID = 585 Then
Me.EVSpAttack += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
If Me.EVSpDefense < 252 And pokemon.Item.ID = 586 Then
Me.EVSpDefense += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
If Me.Speed < 252 And pokemon.Item.ID = 587 Then
Me.Speed += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
Case Else
'Item 581 is Macho Brace
If Me.EVHP < 252 And DefeatedPokemon.GiveEVHP > 0 Then
Dim gainHPEV As Integer = DefeatedPokemon.GiveEVHP
If pokemon.Item.ID = 581 Then
gainHPEV *= 2
If Me.EVHP < 252 And pokemon.Item.ID = 582 Then
Me.EVHP += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
gainHPEV = CInt(MathHelper.Clamp(gainHPEV, 0, 252 - Me.EVHP))
Me.EVHP += gainHPEV
End If
If Me.EVAttack < 252 And DefeatedPokemon.GiveEVAttack > 0 Then
Dim gainAttackEV As Integer = DefeatedPokemon.GiveEVAttack
If pokemon.Item.ID = 581 Then
gainAttackEV *= 2
If Me.EVAttack < 252 And pokemon.Item.ID = 583 Then
Me.EVAttack += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
gainAttackEV = CInt(MathHelper.Clamp(gainAttackEV, 0, 252 - Me.EVAttack))
Me.EVAttack += gainAttackEV
End If
If Me.EVDefense < 252 And DefeatedPokemon.GiveEVDefense > 0 Then
Dim gainDefenseEV As Integer = DefeatedPokemon.GiveEVDefense
If pokemon.Item.ID = 581 Then
gainDefenseEV *= 2
If Me.EVDefense < 252 And pokemon.Item.ID = 584 Then
Me.EVDefense += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
gainDefenseEV = CInt(MathHelper.Clamp(gainDefenseEV, 0, 252 - Me.EVDefense))
Me.EVDefense += gainDefenseEV
End If
If Me.EVSpAttack < 252 And DefeatedPokemon.GiveEVSpAttack > 0 Then
Dim gainSpAttackEV As Integer = DefeatedPokemon.GiveEVSpAttack
If pokemon.Item.ID = 581 Then
gainSpAttackEV *= 2
If Me.EVSpAttack < 252 And pokemon.Item.ID = 585 Then
Me.EVSpAttack += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
gainSpAttackEV = CInt(MathHelper.Clamp(gainSpAttackEV, 0, 252 - Me.EVSpAttack))
Me.EVSpAttack += gainSpAttackEV
End If
If Me.EVSpDefense < 252 And DefeatedPokemon.GiveEVSpDefense > 0 Then
Dim gainSpDefenseEV As Integer = DefeatedPokemon.GiveEVSpDefense
If pokemon.Item.ID = 581 Then
gainSpDefenseEV *= 2
If Me.EVSpDefense < 252 And pokemon.Item.ID = 586 Then
Me.EVSpDefense += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
gainSpDefenseEV = CInt(MathHelper.Clamp(gainSpDefenseEV, 0, 252 - Me.EVSpDefense))
Me.EVSpDefense += gainSpDefenseEV
End If
If Me.EVSpeed < 252 And DefeatedPokemon.GiveEVSpeed > 0 Then
Dim gainSpeedEV As Integer = DefeatedPokemon.GiveEVSpeed
If pokemon.Item.ID = 581 Then
gainSpeedEV *= 2
If Me.Speed < 252 And pokemon.Item.ID = 587 Then
Me.Speed += CInt(MathHelper.Clamp(4, 0, 252 - Me.EVHP))
End If
gainSpeedEV = CInt(MathHelper.Clamp(gainSpeedEV, 0, 252 - Me.EVSpeed))
Me.EVSpeed += gainSpeedEV
End If
End Select
Exit Sub
Case 581 'Item 581 is Macho Brace
EVfactor = 2
End Select
End If
If Me.EVHP < 252 And DefeatedPokemon.GiveEVHP > 0 Then
Dim gainHPEV As Integer = DefeatedPokemon.GiveEVHP
gainHPEV = gainHPEV * EVfactor
gainHPEV = CInt(MathHelper.Clamp(gainHPEV, 0, 252 - Me.EVHP))
Me.EVHP += gainHPEV
End If
If Me.EVAttack < 252 And DefeatedPokemon.GiveEVAttack > 0 Then
Dim gainAttackEV As Integer = DefeatedPokemon.GiveEVAttack
gainAttackEV = gainAttackEV * EVfactor
gainAttackEV = CInt(MathHelper.Clamp(gainAttackEV, 0, 252 - Me.EVAttack))
Me.EVAttack += gainAttackEV
End If
If Me.EVDefense < 252 And DefeatedPokemon.GiveEVDefense > 0 Then
Dim gainDefenseEV As Integer = DefeatedPokemon.GiveEVDefense
gainDefenseEV = gainDefenseEV * EVfactor
gainDefenseEV = CInt(MathHelper.Clamp(gainDefenseEV, 0, 252 - Me.EVDefense))
Me.EVDefense += gainDefenseEV
End If
If Me.EVSpAttack < 252 And DefeatedPokemon.GiveEVSpAttack > 0 Then
Dim gainSpAttackEV As Integer = DefeatedPokemon.GiveEVSpAttack
gainSpAttackEV = gainSpAttackEV * EVfactor
gainSpAttackEV = CInt(MathHelper.Clamp(gainSpAttackEV, 0, 252 - Me.EVSpAttack))
Me.EVSpAttack += gainSpAttackEV
End If
If Me.EVSpDefense < 252 And DefeatedPokemon.GiveEVSpDefense > 0 Then
Dim gainSpDefenseEV As Integer = DefeatedPokemon.GiveEVSpDefense
gainSpDefenseEV = gainSpDefenseEV * EVfactor
gainSpDefenseEV = CInt(MathHelper.Clamp(gainSpDefenseEV, 0, 252 - Me.EVSpDefense))
Me.EVSpDefense += gainSpDefenseEV
End If
If Me.EVSpeed < 252 And DefeatedPokemon.GiveEVSpeed > 0 Then
Dim gainSpeedEV As Integer = DefeatedPokemon.GiveEVSpeed
gainSpeedEV = gainSpeedEV * EVfactor
gainSpeedEV = CInt(MathHelper.Clamp(gainSpeedEV, 0, 252 - Me.EVSpeed))
Me.EVSpeed += gainSpeedEV
End If
End If
End If
End Sub