From 250bc9899f68d834736a8d9cc91d02530ff65956 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Sun, 10 Dec 2023 14:27:47 +0100 Subject: [PATCH] Implement BasePower calc mods for GameModeMoves --- P3D/Pokemon/Attacks/Attack.vb | 7 +- P3D/Pokemon/Attacks/AttackSpecialBasePower.vb | 303 ++++++++++++++++++ P3D/Pokemon/Attacks/GameModeAttackLoader.vb | 7 + 3 files changed, 316 insertions(+), 1 deletion(-) create mode 100644 P3D/Pokemon/Attacks/AttackSpecialBasePower.vb diff --git a/P3D/Pokemon/Attacks/Attack.vb b/P3D/Pokemon/Attacks/Attack.vb index 8aae6332c..6192da781 100644 --- a/P3D/Pokemon/Attacks/Attack.vb +++ b/P3D/Pokemon/Attacks/Attack.vb @@ -181,6 +181,7 @@ Public IsDefaultMove As Boolean = False 'if Pound gets loaded instead of the correct move, this is true. Public GameModeFunction As String = "" 'A GameMode can specify a pre defined function for a move. + Public GameModeBasePower As String = "" 'A GameMode can specify a base power calculation for a move. Public IsGameModeMove As Boolean = False Public gmDeductPP As Boolean = True @@ -1954,7 +1955,11 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Function GetBasePower(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) As Integer - Return Me.Power + If Me.IsGameModeMove = False Then + Return Me.Power + Else + Return AttackSpecialBasePower.GetGameModeBasePower(Me, own, BattleScreen) + End If End Function ''' diff --git a/P3D/Pokemon/Attacks/AttackSpecialBasePower.vb b/P3D/Pokemon/Attacks/AttackSpecialBasePower.vb new file mode 100644 index 000000000..4e9938060 --- /dev/null +++ b/P3D/Pokemon/Attacks/AttackSpecialBasePower.vb @@ -0,0 +1,303 @@ +Namespace BattleSystem + + ''' + ''' A class to execute GameMode attack functions. + ''' + Public Class AttackSpecialBasePower + + ''' + ''' Executes the attack function(s). + ''' + ''' The move containing the attack function. + ''' Own toggle. + ''' Reference to the BattleScreen. + Public Shared Function GetGameModeBasePower(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen) As Integer + If Move.GameModeBasePower <> "" Then + Dim basePowerCalcs() As String = Move.GameModeBasePower.Split("|") + Dim applyMultiplier As Single = 1 + For i = 0 To basePowerCalcs.Count - 1 + Dim b As String = basePowerCalcs(i) + Dim bMain As String = b.Remove(b.IndexOf(",")) + Dim bSub As String = b.Remove(0, b.IndexOf(",") + 1) + + Select Case bMain.ToLower + Case "status" + Dim Target As Boolean = own + Dim Status As String = bSub.GetSplit(0, ",") + Dim Multiplier As Single = 1 + If bSub.Split(",").Count > 1 Then + Multiplier = CSng(bSub.GetSplit(1, ",").InsertDecSeparator) + If bSub.Split(",").Count > 2 Then + If own = True Then + Target = Not CBool(bSub.GetSplit(2, ",")) + Else + Target = CBool(bSub.GetSplit(2, ",")) + End If + + End If + End If + + Dim Success As Boolean = False + + Select Case Status.ToLower() + Case "confuse" + If Target = True Then + If BattleScreen.OppPokemon.HasVolatileStatus(Pokemon.VolatileStatus.Confusion) = True Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.HasVolatileStatus(Pokemon.VolatileStatus.Confusion) = True Then + Success = True + End If + End If + Case "burn" + If Target = True Then + If BattleScreen.OppPokemon.Status = Pokemon.StatusProblems.Burn Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status = Pokemon.StatusProblems.Burn Then + Success = True + End If + End If + Case "freeze" + If Target = True Then + If BattleScreen.OppPokemon.Status = Pokemon.StatusProblems.Freeze Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status = Pokemon.StatusProblems.Freeze Then + Success = True + End If + End If + Case "paralyze" + If Target = True Then + If BattleScreen.OppPokemon.Status = Pokemon.StatusProblems.Paralyzed Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status = Pokemon.StatusProblems.Paralyzed Then + Success = True + End If + End If + Case "poison" + If Target = True Then + If BattleScreen.OppPokemon.Status = Pokemon.StatusProblems.Poison Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status = Pokemon.StatusProblems.Poison Then + Success = True + End If + End If + Case "toxic", "badpoison" + If Target = True Then + If BattleScreen.OppPokemon.Status = Pokemon.StatusProblems.BadPoison Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status = Pokemon.StatusProblems.BadPoison Then + Success = True + End If + End If + Case "anypoison" + If Target = True Then + If BattleScreen.OppPokemon.Status = Pokemon.StatusProblems.Poison OrElse BattleScreen.OppPokemon.Status = Pokemon.StatusProblems.BadPoison Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status = Pokemon.StatusProblems.Poison OrElse BattleScreen.OwnPokemon.Status = Pokemon.StatusProblems.BadPoison Then + Success = True + End If + End If + Case "sleep" + If Target = True Then + If BattleScreen.OppPokemon.Status = Pokemon.StatusProblems.Sleep Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status = Pokemon.StatusProblems.Sleep Then + Success = True + End If + End If + Case "noconfuse" + If Target = True Then + If BattleScreen.OppPokemon.HasVolatileStatus(Pokemon.VolatileStatus.Confusion) = False Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.HasVolatileStatus(Pokemon.VolatileStatus.Confusion) = False Then + Success = True + End If + End If + Case "noburn" + If Target = True Then + If BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.Burn Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.Burn Then + Success = True + End If + End If + Case "nofreeze" + If Target = True Then + If BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.Freeze Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.Freeze Then + Success = True + End If + End If + Case "noparalyze" + If Target = True Then + If BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.Paralyzed Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.Paralyzed Then + Success = True + End If + End If + Case "nopoison" + If Target = True Then + If BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.Poison Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.Poison Then + Success = True + End If + End If + Case "notoxic", "nobadpoison" + If Target = True Then + If BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.BadPoison Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.BadPoison Then + Success = True + End If + End If + Case "nopoison" + If Target = True Then + If BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.Poison AndAlso BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.BadPoison Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.Poison AndAlso BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.BadPoison Then + Success = True + End If + End If + Case "nosleep" + If Target = True Then + If BattleScreen.OppPokemon.Status <> Pokemon.StatusProblems.Sleep Then + Success = True + End If + Else + If BattleScreen.OwnPokemon.Status <> Pokemon.StatusProblems.Sleep Then + Success = True + End If + End If + End Select + If Success = True Then + applyMultiplier *= Multiplier + End If + Case "underground" + Dim Target As Boolean = own + Dim Multiplier As Single = 1 + Dim Success As Boolean = False + If bSub.Split(",").Count > 0 Then + Multiplier = CSng(bSub.GetSplit(0, ",").InsertDecSeparator) + If bSub.Split(",").Count > 1 Then + If own = True Then + Target = Not CBool(bSub.GetSplit(1, ",")) + Else + Target = CBool(bSub.GetSplit(1, ",")) + End If + End If + End If + If Target = True Then + If BattleScreen.FieldEffects.OppDigCounter > 0 Then + Success = True + End If + Else + If BattleScreen.FieldEffects.OwnDigCounter > 0 Then + Success = True + End If + End If + If Success = True Then + applyMultiplier *= Multiplier + End If + Case "inmidair" + Dim Target As Boolean = own + Dim Multiplier As Single = 1 + Dim Success As Boolean = False + If bSub.Split(",").Count > 0 Then + Multiplier = CSng(bSub.GetSplit(0, ",").InsertDecSeparator) + If own = True Then + Target = Not CBool(bSub.GetSplit(1, ",")) + Else + Target = CBool(bSub.GetSplit(1, ",")) + End If + End If + If Target = True Then + If BattleScreen.FieldEffects.OppFlyCounter > 0 Then + Success = True + End If + If BattleScreen.FieldEffects.OppBounceCounter > 0 Then + Success = True + End If + If BattleScreen.FieldEffects.OppSkyDropCounter > 0 Then + Success = True + End If + Else + If BattleScreen.FieldEffects.OwnFlyCounter > 0 Then + Success = True + End If + If BattleScreen.FieldEffects.OwnBounceCounter > 0 Then + Success = True + End If + If BattleScreen.FieldEffects.OwnSkyDropCounter > 0 Then + Success = True + End If + End If + If Success = True Then + applyMultiplier *= Multiplier + End If + Case "underwater" + Dim Target As Boolean = own + Dim Multiplier As Single = 1 + Dim Success As Boolean = False + If bSub.Split(",").Count > 0 Then + Multiplier = CSng(bSub.GetSplit(0, ",").InsertDecSeparator) + If own = True Then + Target = Not CBool(bSub.GetSplit(1, ",")) + Else + Target = CBool(bSub.GetSplit(1, ",")) + End If + End If + If Target = True Then + If BattleScreen.FieldEffects.OppDiveCounter > 0 Then + Success = True + End If + Else + If BattleScreen.FieldEffects.OwnDiveCounter > 0 Then + Success = True + End If + End If + If Success = True Then + applyMultiplier *= Multiplier + End If + End Select + Next + Return CInt(Move.Power * applyMultiplier) + Else + Return Move.Power + End If + End Function + + End Class + +End Namespace \ No newline at end of file diff --git a/P3D/Pokemon/Attacks/GameModeAttackLoader.vb b/P3D/Pokemon/Attacks/GameModeAttackLoader.vb index e1cd93063..c8a82b86a 100644 --- a/P3D/Pokemon/Attacks/GameModeAttackLoader.vb +++ b/P3D/Pokemon/Attacks/GameModeAttackLoader.vb @@ -72,6 +72,13 @@ Dim OldFunctionList = move.GameModeFunction move.GameModeFunction = OldFunctionList & "|" & value End If + Case "basepower", "getbasepower" + If move.GameModeBasePower = "" Then + move.GameModeBasePower = value + Else + Dim OldBasePowerCalculationList = move.GameModeBasePower + move.GameModeBasePower = OldBasePowerCalculationList & "|" & value + End If Case "power", "basepower" move.Power = CInt(value) Case "accuracy", "acc"