From 35613b57fce993fc5d4fa8c538ab5620ae2cd28e Mon Sep 17 00:00:00 2001 From: CaptainSegis Date: Tue, 18 Oct 2016 02:16:14 -0500 Subject: [PATCH] Implemented ability activation upon Mega Evolution --- .../2.5DHero/Battle/BattleSystemV2/Battle.vb | 407 +++++++----------- .../BattleSystemV2/BattleCalculation.vb | 22 +- 2 files changed, 157 insertions(+), 272 deletions(-) diff --git a/2.5DHero/2.5DHero/Battle/BattleSystemV2/Battle.vb b/2.5DHero/2.5DHero/Battle/BattleSystemV2/Battle.vb index 0594d7014..2c0cc2ea6 100644 --- a/2.5DHero/2.5DHero/Battle/BattleSystemV2/Battle.vb +++ b/2.5DHero/2.5DHero/Battle/BattleSystemV2/Battle.vb @@ -430,9 +430,9 @@ Me.ChangeCameraAngel(1, own, BattleScreen) BattleScreen.BattleQuery.Add(New ToggleEntityQueryObject(own, ToggleEntityQueryObject.BattleEntities.OwnPokemon, PokemonForms.GetOverworldSpriteName(p), 0, 1, -1, -1)) BattleScreen.BattleQuery.Add(New TextQueryObject(_base & " has Mega Evolved!")) + TriggerAbilityEffect(BattleScreen, own) End If End Sub - 'Checks if any pokemon is mega evolving, order based on speed Sub MegaEvolCheck(ByVal BattleScreen As BattleScreen) If BattleCalculation.MovesFirst(BattleScreen) Then @@ -3700,6 +3700,149 @@ End If End Sub + Public Sub TriggerAbilityEffect(ByVal BattleScreen As BattleScreen, ByVal own As Boolean) + With BattleScreen + Dim p, op As Pokemon + If own Then + p = .OwnPokemon + op = .OppPokemon + Else + p = .OppPokemon + op = .OwnPokemon + End If + If BattleScreen.FieldEffects.CanUseAbility(own, BattleScreen, 1) = True Then + Select Case p.Ability.Name.ToLower() + Case "drizzle" + ChangeWeather(False, False, BattleWeather.WeatherTypes.Rain, 10000, BattleScreen, "Drizzle makes it rain!", "drizzle") + Case "cloud nine" + ChangeWeather(False, False, BattleWeather.WeatherTypes.Clear, 0, BattleScreen, "", "cloudnine") + Case "intimidate" + LowerStat(True, False, BattleScreen, "Attack", 1, p.GetDisplayName() & "'s Intimidate cuts " & op.GetDisplayName() & "'s attack!", "intimidate") + Case "trace" + If op.Ability.Name.ToLower() <> "multitype" And op.Ability.Name.ToLower() <> "illusion" Then + p.OriginalAbility = p.Ability + p.Ability = op.Ability + .BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " copied the ability " & op.Ability.Name & " from " & op.GetDisplayName() & "!")) + End If + Case "sand stream" + ChangeWeather(False, False, BattleWeather.WeatherTypes.Sandstorm, 10000, BattleScreen, "Sand Stream creates a sandstorm!", "sandstream") + Case "forecast" + ApplyForecast(BattleScreen) + Case "drought" + ChangeWeather(False, False, BattleWeather.WeatherTypes.Sunny, 10000, BattleScreen, "The sunlight turned harsh!", "drought") + Case "air lock" + ChangeWeather(False, False, BattleWeather.WeatherTypes.Clear, 0, BattleScreen, "", "airlock") + Case "download" + If op.Defense < op.SpDefense Then + RaiseStat(False, False, BattleScreen, "Attack", 1, "Download analyzed the foe!", "download") + Else + RaiseStat(False, False, BattleScreen, "Special Attack", 1, "Download analyzed the foe!", "download") + End If + Case "mold breaker" + .BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " breakes the mold!")) + Case "turbo blaze" + .BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " is radiating a blazing aura!")) + Case "teravolt" + .BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " is radiating a bursting aura!")) + Case "anticipation" + Dim doShudder As Boolean = False + 'Check every move if it is: super effective/1hitko/explosion/selfdestruct + If doShudder = True Then + .BattleQuery.Add(New TextQueryObject(op.GetDisplayName() & " makes " & p.GetDisplayName() & " shudder!")) + End If + Case "forewarn" + Dim moves As New List(Of Attack) + 'Add attacks with highest base power here + Dim move As Attack = Nothing + If moves.Count > 1 Then + move = moves(Core.Random.Next(0, moves.Count)) + ElseIf moves.Count = 1 Then + move = moves(0) + End If + If Not move Is Nothing Then + .BattleQuery.Add(New TextQueryObject(op.GetDisplayName() & " makes " & p.GetDisplayName() & " shudder!")) + End If + Case "snow warning" + ChangeWeather(False, False, BattleWeather.WeatherTypes.Hailstorm, 10000, BattleScreen, "Snow Warning summoned a hailstorm!", "snowwarning") + Case "frisk" + If Not op.Item Is Nothing Then + .BattleQuery.Add(New TextQueryObject(op.GetDisplayName() & " is holding " & op.Item.Name & ".")) + End If + Case "multitype" + p.OriginalType1 = p.Type1 + p.OriginalType2 = p.Type2 + + p.Type1 = New Element(Element.Types.Normal) + p.Type2 = New Element(Element.Types.Blank) + + If Not p.Item Is Nothing Then + Dim changeType As Boolean = False + Dim newType As Element = Nothing + + Select Case p.Item.Name.ToLower() + Case "draco plate" + changeType = True + newType = New Element(Element.Types.Dragon) + Case "dread plate" + changeType = True + newType = New Element(Element.Types.Dark) + Case "earth plate" + changeType = True + newType = New Element(Element.Types.Ground) + Case "fist plate" + changeType = True + newType = New Element(Element.Types.Fighting) + Case "flame plate" + changeType = True + newType = New Element(Element.Types.Fire) + Case "icicle plate" + changeType = True + newType = New Element(Element.Types.Ice) + Case "insect plate" + changeType = True + newType = New Element(Element.Types.Bug) + Case "iron plate" + changeType = True + newType = New Element(Element.Types.Steel) + Case "meadow plate" + changeType = True + newType = New Element(Element.Types.Grass) + Case "mind plate" + changeType = True + newType = New Element(Element.Types.Psychic) + Case "sky plate" + changeType = True + newType = New Element(Element.Types.Flying) + Case "splash plate" + changeType = True + newType = New Element(Element.Types.Water) + Case "spooky plate" + changeType = True + newType = New Element(Element.Types.Ghost) + Case "stone plate" + changeType = True + newType = New Element(Element.Types.Rock) + Case "toxic plate" + changeType = True + newType = New Element(Element.Types.Poison) + Case "zap plate" + changeType = True + newType = New Element(Element.Types.Electric) + End Select + + If changeType = True Then + p.Type1 = newType + p.Type2 = New Element(Element.Types.Blank) + End If + End If + + .BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & "'s type changed to " & p.Type1.ToString() & "!")) + Case "imposter" + 'Doing the ditto stuff! + End Select + End If + End With + End Sub Private Sub ApplyForecast(ByVal BattleScreen As BattleScreen) With BattleScreen Dim p As Pokemon = .OwnPokemon @@ -5720,137 +5863,7 @@ End If End If - If BattleScreen.FieldEffects.CanUseAbility(True, BattleScreen, 1) = True Then - Select Case p.Ability.Name.ToLower() - Case "drizzle" - ChangeWeather(True, True, BattleWeather.WeatherTypes.Rain, 10000, BattleScreen, "Drizzle makes it rain!", "drizzle") - Case "cloud nine" - ChangeWeather(True, True, BattleWeather.WeatherTypes.Clear, 0, BattleScreen, "", "cloudnine") - Case "intimidate" - LowerStat(False, True, BattleScreen, "Attack", 1, p.GetDisplayName() & "'s Intimidate cuts " & op.GetDisplayName() & "'s attack!", "intimidate") - Case "trace" - If op.Ability.Name.ToLower() <> "multitype" And op.Ability.Name.ToLower() <> "illusion" Then - p.OriginalAbility = p.Ability - p.Ability = op.Ability - .AddToQuery(InsertIndex, New TextQueryObject(p.GetDisplayName() & " copied the ability " & op.Ability.Name & " from " & op.GetDisplayName() & "!")) - End If - Case "sand stream" - ChangeWeather(True, True, BattleWeather.WeatherTypes.Sandstorm, 10000, BattleScreen, "Sand Stream creates a sandstorm!", "sandstream") - Case "forecast" - ApplyForecast(BattleScreen) - Case "drought" - ChangeWeather(True, True, BattleWeather.WeatherTypes.Sunny, 10000, BattleScreen, "The sunlight turned harsh!", "drought") - Case "air lock" - ChangeWeather(True, True, BattleWeather.WeatherTypes.Clear, 0, BattleScreen, "", "airlock") - Case "download" - If op.Defense < op.SpDefense Then - RaiseStat(True, True, BattleScreen, "Attack", 1, "Download analysed the foe!", "download") - Else - RaiseStat(True, True, BattleScreen, "Special Attack", 1, "Download analysed the foe!", "download") - End If - Case "mold breaker" - .AddToQuery(InsertIndex, New TextQueryObject(p.GetDisplayName() & " breakes the mold!")) - Case "turbo blaze" - .AddToQuery(InsertIndex, New TextQueryObject(p.GetDisplayName() & " is radiating a blazing aura!")) - Case "teravolt" - .AddToQuery(InsertIndex, New TextQueryObject(p.GetDisplayName() & " is radiating a bursting aura!")) - Case "anticipation" - Dim doShudder As Boolean = False - 'Check every move if it is: super effective/1hitko/explosion/selfdestruct - If doShudder = True Then - .AddToQuery(InsertIndex, New TextQueryObject(op.GetDisplayName() & " makes " & p.GetDisplayName() & " shudder!")) - End If - Case "forewarn" - Dim moves As New List(Of Attack) - 'Add attacks with highest base power here - Dim move As Attack = Nothing - If moves.Count > 1 Then - move = moves(Core.Random.Next(0, moves.Count)) - ElseIf moves.Count = 1 Then - move = moves(0) - End If - If Not move Is Nothing Then - .AddToQuery(InsertIndex, New TextQueryObject(op.GetDisplayName() & " makes " & p.GetDisplayName() & " shudder!")) - End If - Case "snow warning" - ChangeWeather(True, True, BattleWeather.WeatherTypes.Hailstorm, 10000, BattleScreen, "Snow Warning summoned a hailstorm!", "snowwarning") - Case "frisk" - If Not op.Item Is Nothing Then - .AddToQuery(InsertIndex, New TextQueryObject(op.GetDisplayName() & " is holding " & op.Item.Name & ".")) - End If - Case "multitype" - p.OriginalType1 = p.Type1 - p.OriginalType2 = p.Type2 - - p.Type1 = New Element(Element.Types.Normal) - p.Type2 = New Element(Element.Types.Blank) - - If Not p.Item Is Nothing Then - Dim changeType As Boolean = False - Dim newType As Element = Nothing - - Select Case p.Item.Name.ToLower() - Case "draco plate" - changeType = True - newType = New Element(Element.Types.Dragon) - Case "dread plate" - changeType = True - newType = New Element(Element.Types.Dark) - Case "earth plate" - changeType = True - newType = New Element(Element.Types.Ground) - Case "fist plate" - changeType = True - newType = New Element(Element.Types.Fighting) - Case "flame plate" - changeType = True - newType = New Element(Element.Types.Fire) - Case "icicle plate" - changeType = True - newType = New Element(Element.Types.Ice) - Case "insect plate" - changeType = True - newType = New Element(Element.Types.Bug) - Case "iron plate" - changeType = True - newType = New Element(Element.Types.Steel) - Case "meadow plate" - changeType = True - newType = New Element(Element.Types.Grass) - Case "mind plate" - changeType = True - newType = New Element(Element.Types.Psychic) - Case "sky plate" - changeType = True - newType = New Element(Element.Types.Flying) - Case "splash plate" - changeType = True - newType = New Element(Element.Types.Water) - Case "spooky plate" - changeType = True - newType = New Element(Element.Types.Ghost) - Case "stone plate" - changeType = True - newType = New Element(Element.Types.Rock) - Case "toxic plate" - changeType = True - newType = New Element(Element.Types.Poison) - Case "zap plate" - changeType = True - newType = New Element(Element.Types.Electric) - End Select - - If changeType = True Then - p.Type1 = newType - p.Type2 = New Element(Element.Types.Blank) - End If - End If - - .AddToQuery(InsertIndex, New TextQueryObject(p.GetDisplayName() & "'s type changed to " & p.Type1.ToString() & "!")) - Case "imposter" - 'Doing the ditto stuff! - End Select - End If + TriggerAbilityEffect(BattleScreen, True) If .OwnPokemon.Status = Pokemon.StatusProblems.Sleep Then .FieldEffects.OwnSleepTurns = Core.Random.Next(1, 4) @@ -6141,135 +6154,7 @@ End If End If - Select Case p.Ability.Name.ToLower() - Case "drizzle" - ChangeWeather(False, False, BattleWeather.WeatherTypes.Rain, 10000, BattleScreen, "Drizzle makes it rain!", "drizzle") - Case "cloud nine" - ChangeWeather(False, False, BattleWeather.WeatherTypes.Clear, 0, BattleScreen, "", "cloudnine") - Case "intimidate" - LowerStat(True, False, BattleScreen, "Attack", 1, p.GetDisplayName() & "'s Intimidate cuts " & op.GetDisplayName() & "'s attack!", "intimidate") - Case "trace" - If op.Ability.Name.ToLower() <> "multitype" And op.Ability.Name.ToLower() <> "illusion" Then - p.OriginalAbility = p.Ability - p.Ability = op.Ability - .BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " copied the ability " & op.Ability.Name & " from " & op.GetDisplayName() & "!")) - End If - Case "sand stream" - ChangeWeather(False, False, BattleWeather.WeatherTypes.Sandstorm, 10000, BattleScreen, "Sand Stream creates a sandstorm!", "sandstream") - Case "forecast" - ApplyForecast(BattleScreen) - Case "drought" - ChangeWeather(False, False, BattleWeather.WeatherTypes.Sunny, 10000, BattleScreen, "The sunlight turned harsh!", "drought") - Case "air lock" - ChangeWeather(False, False, BattleWeather.WeatherTypes.Clear, 0, BattleScreen, "", "airlock") - Case "download" - If op.Defense < op.SpDefense Then - RaiseStat(False, False, BattleScreen, "Attack", 1, "Download analysed the foe!", "download") - Else - RaiseStat(False, False, BattleScreen, "Special Attack", 1, "Download analysed the foe!", "download") - End If - Case "mold breaker" - .BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " breakes the mold!")) - Case "turbo blaze" - .BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " is radiating a blazing aura!")) - Case "teravolt" - .BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & " is radiating a bursting aura!")) - Case "anticipation" - Dim doShudder As Boolean = False - 'Check every move if it is: super effective/1hitko/explosion/selfdestruct - If doShudder = True Then - .BattleQuery.Add(New TextQueryObject(op.GetDisplayName() & " makes " & p.GetDisplayName() & " shudder!")) - End If - Case "forewarn" - Dim moves As New List(Of Attack) - 'Add attacks with highest base power here - Dim move As Attack = Nothing - If moves.Count > 1 Then - move = moves(Core.Random.Next(0, moves.Count)) - ElseIf moves.Count = 1 Then - move = moves(0) - End If - If Not move Is Nothing Then - .BattleQuery.Add(New TextQueryObject(op.GetDisplayName() & " makes " & p.GetDisplayName() & " shudder!")) - End If - Case "snow warning" - ChangeWeather(False, False, BattleWeather.WeatherTypes.Hailstorm, 10000, BattleScreen, "Snow Warning summoned a hailstorm!", "snowwarning") - Case "frisk" - If Not op.Item Is Nothing Then - .BattleQuery.Add(New TextQueryObject(op.GetDisplayName() & " is holding " & op.Item.Name & ".")) - End If - Case "multitype" - p.OriginalType1 = p.Type1 - p.OriginalType2 = p.Type2 - - p.Type1 = New Element(Element.Types.Normal) - p.Type2 = New Element(Element.Types.Blank) - - If Not p.Item Is Nothing Then - Dim changeType As Boolean = False - Dim newType As Element = Nothing - - Select Case p.Item.Name.ToLower() - Case "draco plate" - changeType = True - newType = New Element(Element.Types.Dragon) - Case "dread plate" - changeType = True - newType = New Element(Element.Types.Dark) - Case "earth plate" - changeType = True - newType = New Element(Element.Types.Ground) - Case "fist plate" - changeType = True - newType = New Element(Element.Types.Fighting) - Case "flame plate" - changeType = True - newType = New Element(Element.Types.Fire) - Case "icicle plate" - changeType = True - newType = New Element(Element.Types.Ice) - Case "insect plate" - changeType = True - newType = New Element(Element.Types.Bug) - Case "iron plate" - changeType = True - newType = New Element(Element.Types.Steel) - Case "meadow plate" - changeType = True - newType = New Element(Element.Types.Grass) - Case "mind plate" - changeType = True - newType = New Element(Element.Types.Psychic) - Case "sky plate" - changeType = True - newType = New Element(Element.Types.Flying) - Case "splash plate" - changeType = True - newType = New Element(Element.Types.Water) - Case "spooky plate" - changeType = True - newType = New Element(Element.Types.Ghost) - Case "stone plate" - changeType = True - newType = New Element(Element.Types.Rock) - Case "toxic plate" - changeType = True - newType = New Element(Element.Types.Poison) - Case "zap plate" - changeType = True - newType = New Element(Element.Types.Electric) - End Select - - If changeType = True Then - p.Type1 = newType - p.Type2 = New Element(Element.Types.Blank) - End If - End If - - .BattleQuery.Add(New TextQueryObject(p.GetDisplayName() & "'s type changed to " & p.Type1.ToString() & "!")) - Case "imposter" - 'Doing the ditto stuff! - End Select + TriggerAbilityEffect(BattleScreen, False) If .OppPokemon.Status = Pokemon.StatusProblems.Sleep Then .FieldEffects.OppSleepTurns = Core.Random.Next(1, 4) diff --git a/2.5DHero/2.5DHero/Battle/BattleSystemV2/BattleCalculation.vb b/2.5DHero/2.5DHero/Battle/BattleSystemV2/BattleCalculation.vb index 1f1e1572a..825a32612 100644 --- a/2.5DHero/2.5DHero/Battle/BattleSystemV2/BattleCalculation.vb +++ b/2.5DHero/2.5DHero/Battle/BattleSystemV2/BattleCalculation.vb @@ -182,11 +182,11 @@ Dim speed As Integer = CInt(p.Speed * GetMultiplierFromStat(p.StatSpeed)) 'Calculate the speed's basic value from the speed and the speed stat If own = True Then - If BattleScreen.IsPVPBattle = False Then - If Core.Player.Badges.Contains(3) = True Then + If BattleScreen.IsPVPBattle = False Then + If Core.Player.Badges.Contains(3) = True Then speed = CInt(speed + (speed * (1 / 8))) 'Add 1/8 of the speed if the player has the 3rd badge and it's not a PvP battle End If - End If + End If End If If p.Status = net.Pokemon3D.Game.Pokemon.StatusProblems.Paralyzed And p.Ability.Name.ToLower() <> "quick feet" Then @@ -538,7 +538,7 @@ If UsedAttack.ID = 524 Then Return True End If - + Return False End Function @@ -621,7 +621,7 @@ Dim effectiveness As Single = Type1 * Type2 'Freeze Dry - If move.ID = 573 Then + If move.ID = 573 Then If op.Type1.Type = Element.Types.Water Or op.Type2.Type = Element.Types.Water Then effectiveness *= 4 End If @@ -1172,7 +1172,7 @@ Case Else UA = 1.0F End Select - + 'FA (Foe ability) Select Case Op.Ability.Name.ToLower() Case "thick fat" @@ -1378,7 +1378,7 @@ End Select End If End If - + 'Critical hit interaction with attack stat change If ASM < 1.0F AndAlso Critical = True Then ASM = 1.0F @@ -1462,16 +1462,16 @@ End If End If End If - + If DSM > 1.0F AndAlso Critical = True Then DSM = 1.0F End If - + 'Sacred Sword ignores defense stat changes If Attack.ID = 533 Then DSM = 1.0F End If - + Def = CInt(Math.Floor(DStat * DSM * DMod * SX)) If Def <= 0 Then @@ -1861,7 +1861,7 @@ Return 1.0F End Select End Function - + Public Shared Function GetMultiplierFromAccEvasion(ByVal StatValue As Integer) As Single Select Case StatValue Case -6