Implement Custom Types

This commit is contained in:
JappaWakka 2023-12-10 20:19:14 +01:00
parent 705e0b9725
commit a5e68a153a
15 changed files with 1227 additions and 868 deletions

View File

@ -28766,6 +28766,7 @@
<Compile Include="Pokemon\Abilities\Galvanize.vb" />
<Compile Include="Pokemon\Abilities\SurgeSurfer.vb" />
<Compile Include="Pokemon\Abilities\ParentalBond.vb" />
<Compile Include="Pokemon\Attacks\AttackSpecialBasePower.vb" />
<Compile Include="Pokemon\Attacks\Bug\PollenPuff.vb" />
<Compile Include="Pokemon\Attacks\Bug\FirstImpression.vb" />
<Compile Include="Pokemon\Attacks\Bug\FellStinger.vb" />
@ -28920,6 +28921,7 @@
<Compile Include="Pokemon\Items\Standard\ExpertBelt.vb" />
<Compile Include="Pokemon\Items\Stones\IceStone.vb" />
<Compile Include="Pokemon\Items\Stones\BlackAurugite.vb" />
<Compile Include="Pokemon\Monster\GameModeElementLoader.vb" />
<Compile Include="Resources\Blur\BlurHandler.vb" />
<Content Include="Content\Data\Scripts\faraway\mewtwonite_y.dat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

View File

@ -543,6 +543,7 @@
End If
GameModeManager.SetGameModePointer(GameMode)
BattleSystem.GameModeElementLoader.Load()
BattleSystem.GameModeAttackLoader.Load()
GameModeItemLoader.Load()

View File

@ -84,7 +84,11 @@
Case "accuracy", "acc"
move.Accuracy = CInt(value)
Case "type"
move.Type = New Element(value)
If StringHelper.IsNumeric(value) = False Then
move.Type = GameModeElementLoader.GetElementByName(value)
Else
move.Type = GameModeElementLoader.GetElementByID(CInt(value))
End If
Case "category"
Select Case value.ToLower()
Case "physical"

View File

@ -90,7 +90,7 @@ Namespace BattleSystem.Moves.Normal
If Not p.Item Is Nothing Then
If p.Item.isBerry = True Then
Return New Element(CType(p.Item, Items.Berry).Type)
Return BattleSystem.GameModeElementLoader.GetElementByID(CType(p.Item, Items.Berry).Type)
End If
End If

View File

@ -31,7 +31,7 @@
Public SummerGrow As Integer = 2
Public FallGrow As Integer = 1
Public Type As Element.Types
Public Type As Integer
Public Power As Integer = 80
Public JuiceColor As String = "red"

View File

@ -197,45 +197,49 @@ Public Class GameModeItem
Public Sub SetTeachMoveTextureRectangle()
Dim r As New Rectangle(144, 168, 24, 24)
If gmTeachMove.Type.IsGameModeElement = False Then
Select Case gmTeachMove.Type.Type
Case Element.Types.Blank, Element.Types.Normal
r = New Rectangle(144, 168, 24, 24)
Case Element.Types.Bug
r = New Rectangle(24, 192, 24, 24)
Case Element.Types.Dark
r = New Rectangle(384, 168, 24, 24)
Case Element.Types.Dragon
r = New Rectangle(408, 168, 24, 24)
Case Element.Types.Electric
r = New Rectangle(288, 168, 24, 24)
Case Element.Types.Fairy
r = New Rectangle(72, 264, 24, 24)
Case Element.Types.Fighting
r = New Rectangle(168, 168, 24, 24)
Case Element.Types.Fire
r = New Rectangle(360, 168, 24, 24)
Case Element.Types.Flying
r = New Rectangle(0, 192, 24, 24)
Case Element.Types.Ghost
r = New Rectangle(480, 168, 24, 24)
Case Element.Types.Grass
r = New Rectangle(336, 168, 24, 24)
Case Element.Types.Ground
r = New Rectangle(456, 168, 24, 24)
Case Element.Types.Ice
r = New Rectangle(312, 168, 24, 24)
Case Element.Types.Poison
r = New Rectangle(264, 168, 24, 24)
Case Element.Types.Psychic
r = New Rectangle(216, 168, 24, 24)
Case Element.Types.Rock
r = New Rectangle(240, 168, 24, 24)
Case Element.Types.Steel
r = New Rectangle(432, 168, 24, 24)
Case Element.Types.Water
r = New Rectangle(192, 168, 24, 24)
End Select
Select Case gmTeachMove.Type.Type
Case Element.Types.Blank, Element.Types.Normal
r = New Rectangle(144, 168, 24, 24)
Case Element.Types.Bug
r = New Rectangle(24, 192, 24, 24)
Case Element.Types.Dark
r = New Rectangle(384, 168, 24, 24)
Case Element.Types.Dragon
r = New Rectangle(408, 168, 24, 24)
Case Element.Types.Electric
r = New Rectangle(288, 168, 24, 24)
Case Element.Types.Fairy
r = New Rectangle(72, 264, 24, 24)
Case Element.Types.Fighting
r = New Rectangle(168, 168, 24, 24)
Case Element.Types.Fire
r = New Rectangle(360, 168, 24, 24)
Case Element.Types.Flying
r = New Rectangle(0, 192, 24, 24)
Case Element.Types.Ghost
r = New Rectangle(480, 168, 24, 24)
Case Element.Types.Grass
r = New Rectangle(336, 168, 24, 24)
Case Element.Types.Ground
r = New Rectangle(456, 168, 24, 24)
Case Element.Types.Ice
r = New Rectangle(312, 168, 24, 24)
Case Element.Types.Poison
r = New Rectangle(264, 168, 24, 24)
Case Element.Types.Psychic
r = New Rectangle(216, 168, 24, 24)
Case Element.Types.Rock
r = New Rectangle(240, 168, 24, 24)
Case Element.Types.Steel
r = New Rectangle(432, 168, 24, 24)
Case Element.Types.Water
r = New Rectangle(192, 168, 24, 24)
End Select
Else
r = gmTeachMove.Type.gmMachineTextureRectangle
End If
gmTextureRectangle = r
End Sub

View File

@ -200,7 +200,12 @@ Public Class GameModeItemLoader
ElseIf item.gmName.StartsWith("HM") Then
item.gmSortValue = -100000 + CInt(item.gmName.Remove(0, 2))
End If
item.gmTextureSource = "Items\ItemSheet"
If item.gmTeachMove.Type.IsGameModeElement = False Then
item.gmTextureSource = "Items\ItemSheet"
Else
item.gmTextureSource = item.gmTeachMove.Type.gmMachineTextureSource
End If
item.SetTeachMoveTextureRectangle()
End If

File diff suppressed because it is too large Load Diff

View File

@ -207,7 +207,7 @@ Public Class EvolutionCondition
Case ConditionTypes.InPartyType
Dim isInParty As Boolean = False
For Each pokemon As Pokemon In Core.Player.Pokemons
If pokemon.IsType(New Element(c.Argument).Type) = True Then
If pokemon.IsType(BattleSystem.GameModeElementLoader.GetElementByName(c.Argument).Type) = True Then
isInParty = True
Exit For
End If

View File

@ -0,0 +1,291 @@
Namespace BattleSystem
''' <summary>
''' Provides an interface to load additional GameMode moves.
''' </summary>
Public Class GameModeElementLoader
'The default relative path to load moves from (Content folder).
Const PATH As String = "Data\Types\"
'List of loaded moves.
Shared LoadedElements As New List(Of Element)
''' <summary>
''' Load the attack list for the loaded GameMode.
''' </summary>
''' <remarks>The game won't try to load the list if the default GameMode is selected.</remarks>
Public Shared Sub Load()
LoadedElements.Clear()
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")
LoadElement(file)
Next
End If
End If
If LoadedElements.Count > 0 Then
For Each e As Element In LoadedElements
For Each id As Element In LoadedElements
If e.gmEffectivenessAttack.ContainsKey(id.Type) = False Then
e.gmEffectivenessAttack.Add(id.Type, 1.0F)
End If
If e.gmEffectivenessDefense.ContainsKey(id.Type) = False Then
e.gmEffectivenessDefense.Add(id.Type, 1.0F)
End If
Next
Next
Logger.Debug("Loaded " & LoadedElements.Count.ToString() & " GameMode type(s).")
End If
End Sub
''' <summary>
''' Loads a move from a file.
''' </summary>
''' <param name="file">The file to load the move from.</param>
Private Shared Sub LoadElement(ByVal file As String)
Dim element As New Element() 'Load a blank Element.
element.IsGameModeElement = True
Dim content() As String = System.IO.File.ReadAllLines(file)
Dim key As String = ""
Dim value As String = ""
Dim setID As Boolean = False 'Controls if the move sets its ID.
Dim nonCommentLines As Integer = 0
Try
'Go through lines of the file and set the properties depending on the content.
'Lines starting with # are comments.
For Each l As String In content
If l.Contains("|") = True And l.StartsWith("#") = False Then
nonCommentLines += 1
key = l.Remove(l.IndexOf("|"))
value = l.Remove(0, l.IndexOf("|") + 1)
Select Case key.ToLower()
Case "id"
element.Type = CInt(value)
setID = True
Case "name"
element.gmOriginalName = value
Case "typeimageoffset"
element.gmTypeRectangle = New Rectangle(CInt(value.GetSplit(0, ",")), CInt(value.GetSplit(1, ",")), 48, 16)
Case "itemtexturesource"
element.gmMachineTextureSource = value
Case "itemtextureoffset"
element.gmMachineTextureRectangle = New Rectangle(CInt(value.GetSplit(0, ",")), CInt(value.GetSplit(1, ",")), 24, 24)
Case "effectivenessattack"
Dim data() As String = value.Split(";")
For i = 0 To data.Count - 1
Dim typeID As Integer = -1
If StringHelper.IsNumeric(data(i).GetSplit(0, ",")) = True Then
typeID = CInt(data(i).GetSplit(0, ","))
Else
Select Case data(i).GetSplit(0, ",")
Case "normal"
typeID = element.Types.Normal
Case "fighting"
typeID = element.Types.Fighting
Case "flying"
typeID = element.Types.Flying
Case "poison"
typeID = element.Types.Poison
Case "ground"
typeID = element.Types.Ground
Case "rock"
typeID = element.Types.Rock
Case "bug"
typeID = element.Types.Bug
Case "ghost"
typeID = element.Types.Ghost
Case "steel"
typeID = element.Types.Steel
Case "fire"
typeID = element.Types.Fire
Case "water"
typeID = element.Types.Water
Case "grass"
typeID = element.Types.Grass
Case "electric"
typeID = element.Types.Electric
Case "psychic"
typeID = element.Types.Psychic
Case "ice"
typeID = element.Types.Ice
Case "dragon"
typeID = element.Types.Dragon
Case "dark"
typeID = element.Types.Dark
Case "fairy"
typeID = element.Types.Fairy
Case "shadow"
typeID = element.Types.Shadow
End Select
End If
element.gmEffectivenessAttack.Add(typeID, CSng(data(i).GetSplit(1, ",").InsertDecSeparator))
Next
Case "effectivenessdefense"
Dim data() As String = value.Split(";")
For i = 0 To data.Count - 1
Dim typeID As Integer = -1
If StringHelper.IsNumeric(data(i).GetSplit(0, ",")) = True Then
typeID = CInt(data(i).GetSplit(0, ","))
Else
Select Case data(i).GetSplit(0, ",")
Case "normal"
typeID = element.Types.Normal
Case "fighting"
typeID = element.Types.Fighting
Case "flying"
typeID = element.Types.Flying
Case "poison"
typeID = element.Types.Poison
Case "ground"
typeID = element.Types.Ground
Case "rock"
typeID = element.Types.Rock
Case "bug"
typeID = element.Types.Bug
Case "ghost"
typeID = element.Types.Ghost
Case "steel"
typeID = element.Types.Steel
Case "fire"
typeID = element.Types.Fire
Case "water"
typeID = element.Types.Water
Case "grass"
typeID = element.Types.Grass
Case "electric"
typeID = element.Types.Electric
Case "psychic"
typeID = element.Types.Psychic
Case "ice"
typeID = element.Types.Ice
Case "dragon"
typeID = element.Types.Dragon
Case "dark"
typeID = element.Types.Dark
Case "fairy"
typeID = element.Types.Fairy
Case "shadow"
typeID = element.Types.Shadow
End Select
End If
element.gmEffectivenessDefense.Add(typeID, CSng(data(i).GetSplit(1, ",").InsertDecSeparator))
Next
End Select
End If
Next
Catch ex As Exception
'If an error occurs loading a move, log the error.
Logger.Log(Logger.LogTypes.ErrorMessage, "GameModeElementLoader.vb: Error loading GameMode element from file """ & file & """: " & ex.Message & "; Last Key/Value pair successfully loaded: " & key & "|" & value)
End Try
If nonCommentLines > 0 Then
If setID = True Then
If element.Type >= 20 Then
If Localization.TokenExists("element_name_" & element.gmOriginalName.ToString) = True Then
element.gmName = Localization.GetString("move_name_" & element.gmOriginalName.ToString)
End If
For i = 0 To 18
If element.gmEffectivenessAttack.ContainsKey(i) = False Then
element.gmEffectivenessAttack.Add(i, 1.0F)
End If
If element.gmEffectivenessDefense.ContainsKey(i) = False Then
element.gmEffectivenessDefense.Add(i, 1.0F)
End If
Next
LoadedElements.Add(element) 'Add the element.
Else
Logger.Log(Logger.LogTypes.ErrorMessage, "GameModeElementLoader.vb: User defined types are not allowed to have an ID of an already existing type or an ID below 20. The ID for the type loaded from """ & file & """ has the ID " & element.Type.ToString() & ", which is smaller than 20.")
End If
Else
Logger.Log(Logger.LogTypes.ErrorMessage, "GameModeElementLoader.vb: User defined types must set their ID through the ""ID"" property, however the type loaded from """ & file & """ has no ID set so it will be ignored.")
End If
Else
Debug.Print("GameModeElementLoader.vb: The type loaded from """ & file & """ has no valid lines so it will be ignored.")
End If
End Sub
''' <summary>
''' Returns an element based on its ID.
''' </summary>
''' <param name="ID">The ID of the element.</param>
''' <returns>Returns an element or nothing.</returns>
Public Shared Function GetElementByID(ByVal ID As Integer) As Element
If ID <= 19 Then
Return New Element(ID)
Else
For Each e As Element In LoadedElements
If e.Type = ID Then
Return e
End If
Next
End If
Return Nothing
End Function
''' <summary>
''' Returns an element based on its name.
''' </summary>
''' <param name="Name">The name of the element.</param>
''' <returns>Returns an element or nothing.</returns>
Public Shared Function GetElementByName(ByVal Name As String) As Element
Select Case Name.ToLower
Case "normal"
Return New Element(Element.Types.Normal)
Case "fighting"
Return New Element(Element.Types.Fighting)
Case "flying"
Return New Element(Element.Types.Flying)
Case "poison"
Return New Element(Element.Types.Poison)
Case "ground"
Return New Element(Element.Types.Ground)
Case "rock"
Return New Element(Element.Types.Rock)
Case "bug"
Return New Element(Element.Types.Bug)
Case "ghost"
Return New Element(Element.Types.Ghost)
Case "steel"
Return New Element(Element.Types.Steel)
Case "fire"
Return New Element(Element.Types.Fire)
Case "water"
Return New Element(Element.Types.Water)
Case "grass"
Return New Element(Element.Types.Grass)
Case "electric"
Return New Element(Element.Types.Electric)
Case "psychic"
Return New Element(Element.Types.Psychic)
Case "ice"
Return New Element(Element.Types.Ice)
Case "dragon"
Return New Element(Element.Types.Dragon)
Case "dark"
Return New Element(Element.Types.Dark)
Case "fairy"
Return New Element(Element.Types.Fairy)
Case "shadow"
Return New Element(Element.Types.Shadow)
Case "blank"
Return New Element(Element.Types.Blank)
Case Else
For Each e As Element In LoadedElements
If e.ToString.ToLower = Name.ToLower Then
Return e
End If
Next
End Select
Return Nothing
End Function
End Class
End Namespace

View File

@ -2951,7 +2951,7 @@ Public Class Pokemon
''' Checks if the Pokémon is of a certain type.
''' </summary>
''' <param name="CheckType">The type to check.</param>
Public Function IsType(ByVal CheckType As Element.Types) As Boolean
Public Function IsType(ByVal CheckType As Integer) As Boolean
If Type1.Type = CheckType Or Type2.Type = CheckType Then
Return True
End If

View File

@ -721,7 +721,7 @@
Public Daytime As Integer = -1
Public Weather As Integer = -1
Public Season As Integer = -1
Public Types As New List(Of Element.Types)
Public Types As New List(Of Integer)
Public Probability As Integer = 100
Public Sub New(ByVal dataLine As String)
@ -758,7 +758,7 @@
If dataParts(5) <> "-1" Then
For Each typePart As String In dataParts(5).Split(CChar(","))
Me.Types.Add(New Element(typePart).Type)
Me.Types.Add(BattleSystem.GameModeElementLoader.GetElementByName(typePart).Type)
Next
End If
@ -856,7 +856,7 @@
End If
If Me.Types.Count > 0 Then
For Each t As Element.Types In Me.Types
For Each t As Integer In Me.Types
If p.IsType(t) = False Then
Return False
End If

View File

@ -80,48 +80,53 @@ Public Class PokemonForms
form.WildFormTriggers.Add(arguments(10))
End If
If arguments.Count >= 12 Then
Select Case arguments(11).ToLower
Case "normal"
form.TypeChange = Element.Types.Normal
Case "fighting"
form.TypeChange = Element.Types.Fighting
Case "flying"
form.TypeChange = Element.Types.Flying
Case "poison"
form.TypeChange = Element.Types.Poison
Case "ground"
form.TypeChange = Element.Types.Ground
Case "rock"
form.TypeChange = Element.Types.Rock
Case "bug"
form.TypeChange = Element.Types.Bug
Case "ghost"
form.TypeChange = Element.Types.Ghost
Case "steel"
form.TypeChange = Element.Types.Steel
Case "fire"
form.TypeChange = Element.Types.Fire
Case "water"
form.TypeChange = Element.Types.Water
Case "grass"
form.TypeChange = Element.Types.Grass
Case "electric"
form.TypeChange = Element.Types.Electric
Case "psychic"
form.TypeChange = Element.Types.Psychic
Case "ice"
form.TypeChange = Element.Types.Ice
Case "dragon"
form.TypeChange = Element.Types.Dragon
Case "dark"
form.TypeChange = Element.Types.Dark
Case "fairy"
form.TypeChange = Element.Types.Fairy
Case "shadow"
form.TypeChange = Element.Types.Shadow
Case Else
form.TypeChange = Element.Types.Blank
End Select
If StringHelper.IsNumeric(arguments(11)) = False Then
Select Case arguments(11).ToLower
Case "normal"
form.TypeChange = Element.Types.Normal
Case "fighting"
form.TypeChange = Element.Types.Fighting
Case "flying"
form.TypeChange = Element.Types.Flying
Case "poison"
form.TypeChange = Element.Types.Poison
Case "ground"
form.TypeChange = Element.Types.Ground
Case "rock"
form.TypeChange = Element.Types.Rock
Case "bug"
form.TypeChange = Element.Types.Bug
Case "ghost"
form.TypeChange = Element.Types.Ghost
Case "steel"
form.TypeChange = Element.Types.Steel
Case "fire"
form.TypeChange = Element.Types.Fire
Case "water"
form.TypeChange = Element.Types.Water
Case "grass"
form.TypeChange = Element.Types.Grass
Case "electric"
form.TypeChange = Element.Types.Electric
Case "psychic"
form.TypeChange = Element.Types.Psychic
Case "ice"
form.TypeChange = Element.Types.Ice
Case "dragon"
form.TypeChange = Element.Types.Dragon
Case "dark"
form.TypeChange = Element.Types.Dark
Case "fairy"
form.TypeChange = Element.Types.Fairy
Case "shadow"
form.TypeChange = Element.Types.Shadow
Case Else
form.TypeChange = Element.Types.Blank
End Select
Else
form.TypeChange = BattleSystem.GameModeElementLoader.GetElementByID(CInt(arguments(11))).Type
End If
If arguments.Count >= 13 Then
If arguments(12) <> "" Then
form.IncludeBaseFormInDexCount = CBool(arguments(12))
@ -562,7 +567,7 @@ Public Class PokemonForms
Public OverworldSpriteFileSuffix As String = ""
Public CryFileSuffix As String = ""
Public WildFormTriggers As New List(Of String)
Public TypeChange As Element.Types = Element.Types.Blank
Public TypeChange As Integer = Element.Types.Blank
Public IncludeBaseFormInDexCount As Boolean = False
Public Overridable Function GetInitialAdditionalData(ByVal P As Pokemon) As String
@ -587,13 +592,13 @@ Public Class PokemonForms
ElseIf trigger(0).ToLower = "gender" Then
If GetGenderFormMatch(P, True) = "match" Then
If TypeChange <> Element.Types.Blank Then
Return TypeChange.ToString
Return BattleSystem.GameModeElementLoader.GetElementByName(TypeChange).ToString
Else
Return AdditionalValue
End If
End If
ElseIf trigger(0).ToLower = "season" Then
If GetSeasonFormMatch(true) = "match" Then
If GetSeasonFormMatch(True) = "match" Then
If TypeChange <> Element.Types.Blank Then
Return TypeChange.ToString
Else

View File

@ -21,6 +21,7 @@
ContentPackManager.Load(GameController.GamePath & "\ContentPacks\" & s & "\exceptions.dat")
Next
BattleSystem.GameModeElementLoader.Load()
BattleSystem.GameModeAttackLoader.Load()
GameModeItemLoader.Load()

View File

@ -49,6 +49,7 @@
ContentPackManager.Load(GameController.GamePath & "\ContentPacks\" & s & "\exceptions.dat")
Next
BattleSystem.GameModeElementLoader.Load()
BattleSystem.GameModeAttackLoader.Load()
SmashRock.Load()