Merge pull request #156 from P3D-Legacy/custommoves

Custom Moves Functionality
This commit is contained in:
JappaWakka 2022-06-10 22:06:48 +02:00 committed by GitHub
commit a8bc9f972f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 191 additions and 51 deletions

View File

@ -3657,7 +3657,7 @@
End If
End Function
Public Function RaiseStat(ByVal own As Boolean, ByVal from As Boolean, ByVal BattleScreen As BattleScreen, ByVal Stat As String, ByVal val As Integer, ByVal message As String, ByVal cause As String) As Boolean
Public Function RaiseStat(ByVal own As Boolean, ByVal from As Boolean, ByVal BattleScreen As BattleScreen, ByVal Stat As String, ByVal val As Integer, ByVal message As String, ByVal cause As String, Optional IsGameModeMove As Boolean = False) As Boolean
Dim p As Pokemon = BattleScreen.OwnPokemon
Dim op As Pokemon = BattleScreen.OppPokemon
Dim pNPC As NPC = BattleScreen.OwnPokemonNPC
@ -3802,7 +3802,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -3817,7 +3819,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -3832,7 +3836,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -3847,7 +3853,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -3862,7 +3870,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -3877,7 +3887,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -3892,7 +3904,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -3902,7 +3916,7 @@
Return True
End Function
Public Function LowerStat(ByVal own As Boolean, ByVal from As Boolean, ByVal BattleScreen As BattleScreen, ByVal Stat As String, ByVal val As Integer, ByVal message As String, ByVal cause As String) As Boolean
Public Function LowerStat(ByVal own As Boolean, ByVal from As Boolean, ByVal BattleScreen As BattleScreen, ByVal Stat As String, ByVal val As Integer, ByVal message As String, ByVal cause As String, Optional IsGameModeMove As Boolean = False) As Boolean
Dim p As Pokemon = BattleScreen.OwnPokemon
Dim op As Pokemon = BattleScreen.OppPokemon
Dim pNPC As NPC = BattleScreen.OwnPokemonNPC
@ -4084,7 +4098,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -4099,7 +4115,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -4114,7 +4132,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -4129,7 +4149,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -4144,7 +4166,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -4159,7 +4183,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
Return True
@ -4174,7 +4200,9 @@
'Do nothing
Case Else 'Print message given in 'message'
BattleScreen.BattleQuery.Add(New TextQueryObject(message))
If IsGameModeMove = False Then
BattleScreen.BattleQuery.Add(New TextQueryObject(printMessage))
End If
End Select
If val > 0 Then

View File

@ -1951,7 +1951,7 @@
''' <param name="BattleScreen">Reference to the BattleScreen.</param>
Public Overridable Sub MoveHits(ByVal own As Boolean, ByVal BattleScreen As BattleScreen)
If Me.IsGameModeMove = True Then
AttackSpecialFunctions.ExecuteAttackFunction(Me, own, BattleScreen)
AttackSpecialFunctions.ExecuteMoveHitsFunction(Me, own, BattleScreen)
Else
'DO NOTHING HERE (will do secondary effect if moves overrides it)
End If

View File

@ -11,23 +11,132 @@
''' <param name="Move">The move containing the attack function.</param>
''' <param name="own">Own toggle.</param>
''' <param name="BattleScreen">Reference to the BattleScreen.</param>
Public Shared Sub ExecuteAttackFunction(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen)
Dim functions() As String = Move.GameModeFunction.Split(CChar(","))
Public Shared Sub ExecuteMoveHitsFunction(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen)
Dim functions() As String = Move.GameModeFunction.Split("|")
For i = 0 To functions.Count - 1
Dim f As String = functions(i)
Dim fMain As String = f
Dim fSub As String = ""
If f.Contains(",") = True Then
fMain = f.GetSplit(0, ",")
fSub = f.GetSplit(1, ",")
Select Case fMain.ToLower()
Case "cameraangle"
Dim Direction As Integer = CInt(fSub)
Select Case Direction
Case 0
BattleScreen.Battle.ChangeCameraAngle(0, own, BattleScreen)
Case 1
BattleScreen.Battle.ChangeCameraAngle(1, True, BattleScreen)
Case 2
BattleScreen.Battle.ChangeCameraAngle(2, True, BattleScreen)
End Select
Case "message", "text"
fSub = Localization.GetString(fSub, fSub)
BattleScreen.BattleQuery.Add(New TextQueryObject(fSub))
Case "raisestat", "increasestat"
Dim Stat As String = f.GetSplit(1, ",")
Dim Target As Boolean = own
Dim Message As String = ""
Dim RaiseAmount As Integer = 1
For Each f As String In functions
If f.Split(CChar(",")).Count > 2 Then
Target = CBool(f.GetSplit(2, ","))
If f.Split(CChar(",")).Count > 3 Then
Message = f.GetSplit(3, ",")
If f.Split(CChar(",")).Count > 4 Then
If CInt(f.GetSplit(4, ",")) > 0 Then
RaiseAmount = CInt(f.GetSplit(4, ","))
End If
End If
End If
End If
BattleScreen.Battle.RaiseStat(Target, own, BattleScreen, Stat, RaiseAmount, Message, "move:" & Move.Name, True)
Case "lowerstat", "decreasestat"
Dim Stat As String = f.GetSplit(1, ",")
Dim Message As String = ""
Dim Target As Boolean = own
Dim LowerAmount As Integer = 1
If f.Split(CChar(",")).Count > 2 Then
Target = CBool(f.GetSplit(2, ","))
If f.Split(CChar(",")).Count > 3 Then
Message = f.GetSplit(3, ",")
If f.Split(CChar(",")).Count > 4 Then
If CInt(f.GetSplit(4, ",")) > 0 Then
LowerAmount = CInt(f.GetSplit(4, ","))
End If
End If
End If
End If
BattleScreen.Battle.LowerStat(Target, own, BattleScreen, Stat, LowerAmount, Message, "move:" & Move.Name, True)
Case "reducehp", "drainhp", "damage"
Dim Target As Boolean = CBool(f.GetSplit(1, ","))
Dim HPAmount As Integer = 0
Dim Message As String = ""
If f.Split(CChar(",")).Count > 2 Then
HPAmount = CInt(f.GetSplit(2, ","))
If f.Split(CChar(",")).Count > 3 Then
Message = f.GetSplit(3, ",")
End If
End If
BattleScreen.Battle.ReduceHP(HPAmount, Target, own, BattleScreen, Message, Move.Name.ToLower)
Case "gainhp", "increasehp", "heal"
Dim Target As Boolean = CBool(f.GetSplit(1, ","))
Dim HPAmount As Integer = 0
Dim Message As String = ""
If f.Split(CChar(",")).Count > 2 Then
HPAmount = CInt(f.GetSplit(2, ","))
If f.Split(CChar(",")).Count > 3 Then
Message = f.GetSplit(3, ",")
End If
End If
BattleScreen.Battle.GainHP(HPAmount, Target, own, BattleScreen, Message, Move.Name.ToLower)
Case "endbattle"
Dim Blackout As Boolean = False
If f.Split(CChar(",")).Count > 2 Then
Blackout = CBool(fSub)
End If
BattleScreen.BattleQuery.Add(New EndBattleQueryObject(Blackout))
Case "faint"
Dim Target As Boolean = CBool(f.GetSplit(1, ","))
Dim Message As String = ""
If f.Split(CChar(",")).Count > 2 Then
Message = f.GetSplit(2, ",")
End If
BattleScreen.Battle.FaintPokemon(Not Target, BattleScreen, Message)
Case Else
fSub = CInt(f.GetSplit(1, ",")).Clamp(0, 100).ToString
End Select
Else
Select Case f.ToLower()
Case "paralyze"
Paralyze(Move, own, BattleScreen)
Case "poison"
Poison(Move, own, BattleScreen)
Case "toxic", "badpoison"
BadPoison(Move, own, BattleScreen)
Case "burn"
Burn(Move, own, BattleScreen)
Case "freeze"
Burn(Move, own, BattleScreen)
fSub = "15"
Case "poison"
fSub = "40"
Case "toxic", "badpoison"
fSub = "25"
Case Else
fSub = "30"
End Select
End If
Select Case fMain.ToLower()
Case "paralyze"
Paralyze(Move, own, BattleScreen, CInt(fSub))
Case "poison"
Poison(Move, own, BattleScreen, CInt(fSub))
Case "toxic", "badpoison"
BadPoison(Move, own, BattleScreen, CInt(fSub))
Case "burn"
Burn(Move, own, BattleScreen, CInt(fSub))
Case "freeze"
Freeze(Move, own, BattleScreen, CInt(fSub))
Case "sleep"
Sleep(Move, own, BattleScreen)
Sleep(Move, own, BattleScreen, CInt(fSub))
End Select
Next
End Sub
@ -36,52 +145,52 @@
If move.Category = Attack.Categories.Special Then
Return True
Else
Return Core.Random.Next(0, 100) < chance
Return Core.Random.Next(0, 100) <= chance
End If
End Function
Private Shared Sub Paralyze(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen)
If GetEffectChanceResult(Move, 30) = True Then
Private Shared Sub Paralyze(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen, Chance As Integer)
If GetEffectChanceResult(Move, Chance) = True Then
If BattleScreen.Battle.InflictParalysis(Not own, own, BattleScreen, "", "move:" & Move.Name.ToLower()) = False Then
If Move.Category = Attack.Categories.Status Then BattleScreen.BattleQuery.Add(New TextQueryObject(Move.Name & " failed!"))
End If
End If
End Sub
Private Shared Sub Burn(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen)
If GetEffectChanceResult(Move, 30) = True Then
Private Shared Sub Burn(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen, Chance As Integer)
If GetEffectChanceResult(Move, Chance) = True Then
If BattleScreen.Battle.InflictBurn(Not own, own, BattleScreen, "", "move:" & Move.Name.ToLower()) = False Then
If Move.Category = Attack.Categories.Status Then BattleScreen.BattleQuery.Add(New TextQueryObject(Move.Name & " failed!"))
End If
End If
End Sub
Private Shared Sub Sleep(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen)
If GetEffectChanceResult(Move, 30) = True Then
Private Shared Sub Sleep(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen, Chance As Integer)
If GetEffectChanceResult(Move, Chance) = True Then
If BattleScreen.Battle.InflictSleep(Not own, own, BattleScreen, -1, "", "move:" & Move.Name.ToLower()) = False Then
If Move.Category = Attack.Categories.Status Then BattleScreen.BattleQuery.Add(New TextQueryObject(Move.Name & " failed!"))
End If
End If
End Sub
Private Shared Sub Freeze(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen)
If GetEffectChanceResult(Move, 15) = True Then
Private Shared Sub Freeze(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen, Chance As Integer)
If GetEffectChanceResult(Move, Chance) = True Then
If BattleScreen.Battle.InflictFreeze(Not own, own, BattleScreen, "", "move:" & Move.Name.ToLower()) = False Then
If Move.Category = Attack.Categories.Status Then BattleScreen.BattleQuery.Add(New TextQueryObject(Move.Name & " failed!"))
End If
End If
End Sub
Private Shared Sub Poison(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen)
If GetEffectChanceResult(Move, 40) = True Then
Private Shared Sub Poison(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen, Chance As Integer)
If GetEffectChanceResult(Move, Chance) = True Then
If BattleScreen.Battle.InflictPoison(Not own, own, BattleScreen, False, "", "move:" & Move.Name.ToLower()) = False Then
If Move.Category = Attack.Categories.Status Then BattleScreen.BattleQuery.Add(New TextQueryObject(Move.Name & " failed!"))
End If
End If
End Sub
Private Shared Sub BadPoison(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen)
If GetEffectChanceResult(Move, 25) = True Then
Private Shared Sub BadPoison(ByVal Move As Attack, ByVal own As Boolean, ByVal BattleScreen As BattleScreen, Chance As Integer)
If GetEffectChanceResult(Move, Chance) = True Then
If BattleScreen.Battle.InflictPoison(Not own, own, BattleScreen, True, "", "move:" & Move.Name.ToLower()) = False Then
If Move.Category = Attack.Categories.Status Then BattleScreen.BattleQuery.Add(New TextQueryObject(Move.Name & " failed!"))
End If

View File

@ -20,7 +20,7 @@
If GameModeManager.ActiveGameMode.IsDefaultGamemode = False Then
If System.IO.Directory.Exists(GameController.GamePath & "\" & GameModeManager.ActiveGameMode.ContentPath & "\" & PATH) = True Then
For Each file As String In System.IO.Directory.GetFiles(GameController.GamePath & "\" & GameModeManager.ActiveGameMode.ContentPath & "\" & PATH, "*.dat")
For Each file As String In System.IO.Directory.GetFiles(GameController.GamePath & "\" & GameModeManager.ActiveGameMode.ContentPath & PATH, "*.dat")
LoadMove(file)
Next
End If
@ -63,8 +63,13 @@
move.CurrentPP = CInt(value)
move.MaxPP = CInt(value)
move.OriginalPP = CInt(value)
Case "function"
Case "function", "movehits"
If move.GameModeFunction = "" Then
move.GameModeFunction = value
Else
Dim OldFunctionList = move.GameModeFunction
move.GameModeFunction = OldFunctionList & "|" & value
End If
Case "power", "basepower"
move.Power = CInt(value)
Case "accuracy", "acc"
@ -105,7 +110,6 @@
move.Priority = CInt(value)
Case "timestoattack", "tta"
move.TimesToAttack = CInt(value)
Case "makescontact", "contact"
move.MakesContact = CBool(value)
Case "protectaffected"

View File

@ -17,7 +17,7 @@
PreScreen = currentScreen
CanBePaused = False
UpdateFadeOut = True
BattleSystem.GameModeAttackLoader.Load()
'Set up 3D environment variables (Effect, Camera, SkyDome and Level):
Effect = New BasicEffect(GraphicsDevice)

View File

@ -516,14 +516,14 @@
'Type:
SpriteBatch.DrawString(FontManager.MainFont, "Type:", New Vector2(DeltaX + 710, DeltaY + 80), New Color(255, 255, 255, CInt(220 * _interfaceFade * _pageFade * _moveFade)))
Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\Types"), New Rectangle(DeltaX + 824, DeltaY + 86, 48, 16), .Attacks(_moveIndex).Type.GetElementImage(), New Color(255, 255, 255, CInt(255 * _fadeIn * _pageFade * _moveFade)))
Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\Types"), New Rectangle(DeltaX + 840, DeltaY + 86, 48, 16), .Attacks(_moveIndex).Type.GetElementImage(), New Color(255, 255, 255, CInt(255 * _fadeIn * _pageFade * _moveFade)))
SpriteBatch.DrawString(FontManager.MainFont, "PP:", New Vector2(DeltaX + 710, DeltaY + 114), New Color(255, 255, 255, CInt(220 * _interfaceFade * _pageFade * _moveFade)))
SpriteBatch.DrawString(FontManager.MainFont, .Attacks(_moveIndex).CurrentPP & " / " & .Attacks(_moveIndex).MaxPP, New Vector2(DeltaX + 824, DeltaY + 114), New Color(255, 255, 255, CInt(220 * _fadeIn * _pageFade * _moveFade)))
SpriteBatch.DrawString(FontManager.MainFont, .Attacks(_moveIndex).CurrentPP & " / " & .Attacks(_moveIndex).MaxPP, New Vector2(DeltaX + 840, DeltaY + 114), New Color(255, 255, 255, CInt(220 * _fadeIn * _pageFade * _moveFade)))
'Stats:
SpriteBatch.DrawString(FontManager.MainFont, "Category:", New Vector2(DeltaX + 710, DeltaY + 144), New Color(255, 255, 255, CInt(220 * _interfaceFade * _pageFade * _moveFade)))
Core.SpriteBatch.Draw(.Attacks(_moveIndex).GetDamageCategoryImage(), New Rectangle(DeltaX + 824, DeltaY + 145, 48, 24), New Color(255, 255, 255, CInt(255 * _fadeIn * _pageFade * _moveFade)))
Core.SpriteBatch.Draw(.Attacks(_moveIndex).GetDamageCategoryImage(), New Rectangle(DeltaX + 840, DeltaY + 145, 48, 24), New Color(255, 255, 255, CInt(255 * _fadeIn * _pageFade * _moveFade)))
SpriteBatch.DrawString(FontManager.MainFont, "Power:", New Vector2(DeltaX + 710, DeltaY + 176), New Color(255, 255, 255, CInt(220 * _interfaceFade * _pageFade * _moveFade)))
@ -531,8 +531,7 @@
If .Attacks(_moveIndex).Power <= 0 Then
power = "-"
End If
SpriteBatch.DrawString(FontManager.MainFont, power, New Vector2(DeltaX + 824, DeltaY + 176), New Color(255, 255, 255, CInt(220 * _fadeIn * _pageFade * _moveFade)))
SpriteBatch.DrawString(FontManager.MainFont, power, New Vector2(DeltaX + 840, DeltaY + 176), New Color(255, 255, 255, CInt(220 * _fadeIn * _pageFade * _moveFade)))
Dim accuracy As String = .Attacks(_moveIndex).Accuracy.ToString()
If .Attacks(_moveIndex).Accuracy <= 0 Then
@ -540,7 +539,7 @@
End If
SpriteBatch.DrawString(FontManager.MainFont, "Accuracy:", New Vector2(DeltaX + 710, DeltaY + 208), New Color(255, 255, 255, CInt(220 * _interfaceFade * _pageFade * _moveFade)))
SpriteBatch.DrawString(FontManager.MainFont, accuracy, New Vector2(DeltaX + 824, DeltaY + 208), New Color(255, 255, 255, CInt(220 * _fadeIn * _pageFade * _moveFade)))
SpriteBatch.DrawString(FontManager.MainFont, accuracy, New Vector2(DeltaX + 840, DeltaY + 208), New Color(255, 255, 255, CInt(220 * _fadeIn * _pageFade * _moveFade)))
'Description:
SpriteBatch.DrawString(FontManager.MainFont, .Attacks(_moveIndex).Description.CropStringToWidth(FontManager.MainFont, 300), New Vector2(DeltaX + 720, DeltaY + 240), New Color(255, 255, 255, CInt(220 * _fadeIn * _pageFade * _moveFade)), 0.0F, New Vector2(0), 1.0F, SpriteEffects.None, 0.0F)