From b40dde89046ccd246120e03ec649e563c7ce117f Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Fri, 15 Dec 2023 18:21:24 +0100 Subject: [PATCH] Added CopyMove property for GM Moves --- P3D/Content/Data/Moves/example.dat | Bin 8008 -> 8500 bytes P3D/Pokemon/Attacks/Attack.vb | 118 ++++++++++++++++++-- P3D/Pokemon/Attacks/GameModeAttackLoader.vb | 69 ++++++++++++ 3 files changed, 178 insertions(+), 9 deletions(-) diff --git a/P3D/Content/Data/Moves/example.dat b/P3D/Content/Data/Moves/example.dat index 8ab58780cc0f18314182f86f1e091dc808fe52e1..6c486f674230bc4c083fd712c261425ef9c877bc 100644 GIT binary patch delta 405 zcmZXQu}Z^W6orol9O_tFU8EsX#ZnP;R6$)j_yCS+lG4<5aPb97UPP(0vy1o; zzDU3O*GNJB;hz88bMAlc|9SF$_WI%-Tq)DNd_@X1p^m9HNHh!;P&?>IME}H ze8m@n3sOep_0>kvB}W(hKfzRo+d87L>jXWwj0I+-g*&y;J|AJ>Vs*gFSUDQ|pplE- zr&}%H%Wea@cS>g8TjfWsSx&uCJ%Y0B$5gkyI`bcIZ)3-%2ET7qP5YD-X+Gbq9XA$O Chff3m delta 21 dcmdnubi!^!3-e?P)|Aa#Sk>4z|Khe11pr}n2nPTF diff --git a/P3D/Pokemon/Attacks/Attack.vb b/P3D/Pokemon/Attacks/Attack.vb index 34738b2fe..326055d6e 100644 --- a/P3D/Pokemon/Attacks/Attack.vb +++ b/P3D/Pokemon/Attacks/Attack.vb @@ -184,6 +184,7 @@ 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 + Public gmCopyMove As Integer = -1 Private _power As Integer = 40 Private _accuracy As Integer = 100 @@ -1906,9 +1907,14 @@ End Function Public Function GetEffectChance(ByVal i As Integer, ByVal own As Boolean, ByVal BattleScreen As BattleScreen) As Integer - Dim chance As Integer = Me.EffectChances(i) + Dim _attack As Attack = Me + If gmCopyMove <> -1 Then + _attack = GameModeAttackLoader.GetAttackByID(gmCopyMove) + End If - If Me.HasSecondaryEffect = True Then + Dim chance As Integer = _attack.EffectChances(i) + + If _attack.HasSecondaryEffect = True Then Dim p As Pokemon = BattleScreen.OwnPokemon If own = False Then p = BattleScreen.OppPokemon @@ -1938,6 +1944,9 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Sub PreAttack(ByVal Own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).PreAttack(Own, BattleScreen) + End If 'DO NOTHING HERE End Sub @@ -1947,6 +1956,9 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Function MoveFailBeforeAttack(ByVal Own As Boolean, ByVal BattleScreen As BattleScreen) As Boolean + If gmCopyMove <> -1 Then + Return GameModeAttackLoader.GetAttackByID(gmCopyMove).MoveFailBeforeAttack(Own, BattleScreen) + End If 'DO NOTHING HERE Return False End Function @@ -1960,7 +1972,16 @@ If Me.IsGameModeMove = False Then Return Me.Power Else - Return AttackSpecialBasePower.GetGameModeBasePower(Me, own, BattleScreen) + If gmCopyMove <> -1 Then + Dim _attack As Attack = GameModeAttackLoader.GetAttackByID(gmCopyMove) + If _attack.IsGameModeMove = False Then + Return _attack.GetBasePower(own, BattleScreen) + Else + Return AttackSpecialBasePower.GetGameModeBasePower(_attack, own, BattleScreen) + End If + Else + Return AttackSpecialBasePower.GetGameModeBasePower(Me, own, BattleScreen) + End If End If End Function @@ -1970,7 +1991,12 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Function GetDamage(ByVal Critical As Boolean, ByVal Own As Boolean, ByVal targetPokemon As Boolean, ByVal BattleScreen As BattleScreen, Optional ByVal ExtraParameter As String = "") As Integer - Return BattleCalculation.CalculateDamage(Me, Critical, Own, targetPokemon, BattleScreen, ExtraParameter) + If gmCopyMove <> -1 Then + Dim _attack As Attack = GameModeAttackLoader.GetAttackByID(gmCopyMove) + Return BattleCalculation.CalculateDamage(_attack, Critical, Own, targetPokemon, BattleScreen, ExtraParameter) + Else + Return BattleCalculation.CalculateDamage(Me, Critical, Own, targetPokemon, BattleScreen, ExtraParameter) + End If End Function ''' @@ -1982,10 +2008,23 @@ If Me.IsGameModeMove = False Then Return Me.TimesToAttack Else - If gmTimesToAttack.Contains("-") Then - Return Core.Random.Next(CInt(gmTimesToAttack.GetSplit(0, "-")), CInt(gmTimesToAttack.GetSplit(1, "-")) + 1) + If gmCopyMove <> -1 Then + Dim _attack As Attack = GameModeAttackLoader.GetAttackByID(gmCopyMove) + If _attack.IsGameModeMove = False Then + Return _attack.GetTimesToAttack(own, BattleScreen) + Else + If _attack.gmTimesToAttack.Contains("-") Then + Return Core.Random.Next(CInt(_attack.gmTimesToAttack.GetSplit(0, "-")), CInt(_attack.gmTimesToAttack.GetSplit(1, "-")) + 1) + Else + Return CInt(_attack.gmTimesToAttack) + End If + End If Else - Return CInt(gmTimesToAttack) + If gmTimesToAttack.Contains("-") Then + Return Core.Random.Next(CInt(gmTimesToAttack.GetSplit(0, "-")), CInt(gmTimesToAttack.GetSplit(1, "-")) + 1) + Else + Return CInt(gmTimesToAttack) + End If End If End If End Function @@ -1997,21 +2036,39 @@ ''' Reference to the BattleScreen. Public Overridable Sub MoveHits(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) If Me.IsGameModeMove = True Then - AttackSpecialFunctions.ExecuteMoveHitsFunction(Me, own, BattleScreen) + If gmCopyMove <> -1 Then + Dim _attack As Attack = GameModeAttackLoader.GetAttackByID(gmCopyMove) + If _attack.IsGameModeMove = False Then + _attack.MoveHits(own, BattleScreen) + Else + AttackSpecialFunctions.ExecuteMoveHitsFunction(_attack, own, BattleScreen) + End If + Else + AttackSpecialFunctions.ExecuteMoveHitsFunction(Me, own, BattleScreen) + End If Else 'DO NOTHING HERE (will do secondary effect if moves overrides it) End If End Sub Public Overridable Sub MoveRecoil(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).MoveRecoil(own, BattleScreen) + End If 'DO NOTHING HERE (will do recoil if moves overrides it) End Sub Public Overridable Sub MoveRecharge(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).MoveRecharge(own, BattleScreen) + End If 'DO NOTHING HERE (will do a one turn recharge if moves overrides it) End Sub Public Overridable Sub MoveMultiTurn(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).MoveMultiTurn(own, BattleScreen) + End If 'DO NOTHING HERE (will do the multi turn countdown if moves overrides it) End Sub @@ -2025,6 +2082,9 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Sub MoveMisses(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).MoveMisses(own, BattleScreen) + End If 'DO NOTHING HERE End Sub @@ -2034,6 +2094,9 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Sub MoveProtectedDetected(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).MoveProtectedDetected(own, BattleScreen) + End If 'DO NOTHING HERE End Sub @@ -2043,6 +2106,9 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Sub MoveHasNoEffect(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).MoveHasNoEffect(own, BattleScreen) + End If 'DO NOTHING HERE End Sub @@ -2092,7 +2158,16 @@ ''' Reference to the BattleScreen. Public Overridable Function DeductPP(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) As Boolean If Me.IsGameModeMove = True Then - Return gmDeductPP + If gmCopyMove <> -1 Then + Dim _attack As Attack = GameModeAttackLoader.GetAttackByID(gmCopyMove) + If _attack.IsGameModeMove = False Then + Return _attack.DeductPP(own, BattleScreen) + Else + Return _attack.gmDeductPP + End If + Else + Return gmDeductPP + End If Else Return True End If @@ -2113,6 +2188,10 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Sub MoveSelected(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).MoveSelected(own, BattleScreen) + End If + 'DO NOTHING End Sub @@ -2122,6 +2201,9 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Sub BeforeDealingDamage(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).BeforeDealingDamage(own, BattleScreen) + End If 'DO NOTHING End Sub @@ -2131,6 +2213,9 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Sub AbsorbedBySubstitute(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).AbsorbedBySubstitute(own, BattleScreen) + End If 'DO NOTHING End Sub @@ -2140,6 +2225,9 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Sub MoveFailsSoundproof(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).MoveFailsSoundproof(own, BattleScreen) + End If 'DO NOTHING End Sub @@ -2149,6 +2237,9 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Sub InflictedFlinch(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).InflictedFlinch(own, BattleScreen) + End If 'DO NOTHING End Sub @@ -2158,6 +2249,9 @@ ''' If the own Pokémon is confused. ''' Reference to the BattleScreen. Public Overridable Sub HurtItselfInConfusion(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).HurtItselfInConfusion(own, BattleScreen) + End If 'DO NOTHING End Sub @@ -2167,6 +2261,9 @@ ''' If the own Pokémon is in love. ''' Reference to the BattleScreen. Public Overridable Sub IsAttracted(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).IsAttracted(own, BattleScreen) + End If 'DO NOTHING End Sub @@ -2176,6 +2273,9 @@ ''' If the own Pokémon used the move. ''' Reference to the BattleScreen. Public Overridable Sub IsSleeping(ByVal own As Boolean, ByVal BattleScreen As BattleScreen) + If gmCopyMove <> -1 Then + GameModeAttackLoader.GetAttackByID(gmCopyMove).IsSleeping(own, BattleScreen) + End If 'DO NOTHING End Sub diff --git a/P3D/Pokemon/Attacks/GameModeAttackLoader.vb b/P3D/Pokemon/Attacks/GameModeAttackLoader.vb index c58c24011..caaa21882 100644 --- a/P3D/Pokemon/Attacks/GameModeAttackLoader.vb +++ b/P3D/Pokemon/Attacks/GameModeAttackLoader.vb @@ -57,6 +57,75 @@ value = l.Remove(0, l.IndexOf("|") + 1) Select Case key.ToLower() + Case "copymove" + If nonCommentLines = 1 Then + move.gmCopyMove = CInt(value) + + Dim _attack As Attack = GameModeAttackLoader.GetAttackByID(move.gmCopyMove) + move.Power = _attack.Power + move.Accuracy = _attack.Accuracy + move.Name = _attack.Name + move.OriginalPP = _attack.OriginalPP + move.CurrentPP = _attack.CurrentPP + move.MaxPP = _attack.MaxPP + move.Category = _attack.Category + move.ContestCategory = _attack.ContestCategory + move.Description = _attack.Description + move.CriticalChance = _attack.CriticalChance + move.IsHMMove = _attack.IsHMMove + move.Target = _attack.Target + move.Priority = _attack.Priority + move.TimesToAttack = _attack.TimesToAttack + move.EffectChances = _attack.EffectChances + move.MakesContact = _attack.MakesContact + move.HasSecondaryEffect = _attack.HasSecondaryEffect + move.IsHealingMove = _attack.IsHealingMove + move.IsDamagingMove = _attack.IsDamagingMove + move.IsProtectMove = _attack.IsProtectMove + move.IsOneHitKOMove = _attack.IsOneHitKOMove + move.IsRecoilMove = _attack.IsRecoilMove + move.IsTrappingMove = _attack.IsTrappingMove + move.RemovesOwnFrozen = _attack.RemovesOwnFrozen + move.RemovesOppFrozen = _attack.RemovesOppFrozen + move.SwapsOutOwnPokemon = _attack.SwapsOutOwnPokemon + move.SwapsOutOppPokemon = _attack.SwapsOutOppPokemon + move.ProtectAffected = _attack.ProtectAffected + move.MagicCoatAffected = _attack.MagicCoatAffected + move.SnatchAffected = _attack.SnatchAffected + move.MirrorMoveAffected = _attack.MirrorMoveAffected + move.KingsrockAffected = _attack.KingsrockAffected + move.CounterAffected = _attack.CounterAffected + move.IsAffectedBySubstitute = _attack.IsAffectedBySubstitute + move.ImmunityAffected = _attack.ImmunityAffected + move.IsWonderGuardAffected = _attack.IsWonderGuardAffected + move.DisabledWhileGravity = _attack.DisabledWhileGravity + move.UseEffectiveness = _attack.UseEffectiveness + move.UseAccEvasion = _attack.UseAccEvasion + move.CanHitInMidAir = _attack.CanHitInMidAir + move.CanHitUnderground = _attack.CanHitUnderground + move.CanHitUnderwater = _attack.CanHitUnderwater + move.CanHitSleeping = _attack.CanHitSleeping + move.CanGainSTAB = _attack.CanGainSTAB + move.UseOppDefense = _attack.UseOppDefense + move.UseOppEvasion = _attack.UseOppEvasion + move.IsPulseMove = _attack.IsPulseMove + move.IsBulletMove = _attack.IsBulletMove + move.IsJawMove = _attack.IsJawMove + move.IsDanceMove = _attack.IsDanceMove + move.IsExplosiveMove = _attack.IsExplosiveMove + move.IsPowderMove = _attack.IsPowderMove + move.IsPunchingMove = _attack.IsPunchingMove + move.IsSlicingMove = _attack.IsSlicingMove + move.IsSoundMove = _attack.IsSoundMove + move.IsWindMove = _attack.IsWindMove + move.FocusOppPokemon = _attack.FocusOppPokemon + move.Disabled = _attack.Disabled + move.AIField1 = _attack.AIField1 + move.AIField2 = _attack.AIField2 + move.AIField3 = _attack.AIField3 + Else + Logger.Log(Logger.LogTypes.ErrorMessage, "GameModeAttackLoader.vb: The CopyMove property should be the first property set in the move definition file. It is currently property number " & nonCommentLines.ToString & ".") + End If Case "id" move.ID = CInt(value) move.OriginalID = CInt(value)