2016-09-07 18:50:38 +02:00
Namespace BattleSystem
''' <summary>
''' Provides an interface to load additional GameMode moves.
''' </summary>
Public Class GameModeAttackLoader
'The default relative path to load moves from (Content folder).
Const PATH As String = " Data\Moves\ "
'List of loaded moves.
Shared LoadedMoves As New List ( Of Attack )
''' <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 ( )
LoadedMoves . Clear ( )
If GameModeManager . ActiveGameMode . IsDefaultGamemode = False Then
2021-08-30 19:46:39 +02:00
If System . IO . Directory . Exists ( GameController . GamePath & " \ " & GameModeManager . ActiveGameMode . ContentPath & " \ " & PATH ) = True Then
2022-03-26 11:47:07 +01:00
For Each file As String In System . IO . Directory . GetFiles ( GameController . GamePath & " \ " & GameModeManager . ActiveGameMode . ContentPath & PATH , " *.dat " )
2021-08-30 19:46:39 +02:00
LoadMove ( file )
Next
End If
2016-09-07 18:50:38 +02:00
End If
If LoadedMoves . Count > 0 Then
Logger . Debug ( " Loaded " & LoadedMoves . Count . ToString ( ) & " GameMode move(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 LoadMove ( ByVal file As String )
Dim move As New Attack ( ) 'Load the default Pound move.
move . IsGameModeMove = 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.
2023-07-07 12:05:57 +02:00
Dim nonCommentLines As Integer = 0
2016-09-07 18:50:38 +02:00
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
2023-07-07 12:05:57 +02:00
nonCommentLines += 1
2016-09-07 18:50:38 +02:00
key = l . Remove ( l . IndexOf ( " | " ) )
value = l . Remove ( 0 , l . IndexOf ( " | " ) + 1 )
Select Case key . ToLower ( )
Case " id "
move . ID = CInt ( value )
move . OriginalID = CInt ( value )
setID = True
Case " pp "
move . CurrentPP = CInt ( value )
move . MaxPP = CInt ( value )
move . OriginalPP = CInt ( value )
2022-02-22 22:25:49 +01:00
Case " function " , " movehits "
If move . GameModeFunction = " " Then
move . GameModeFunction = value
Else
2022-06-09 13:35:54 +02:00
Dim OldFunctionList = move . GameModeFunction
move . GameModeFunction = OldFunctionList & " | " & value
2022-02-22 22:25:49 +01:00
End If
2016-09-07 18:50:38 +02:00
Case " power " , " basepower "
move . Power = CInt ( value )
Case " accuracy " , " acc "
move . Accuracy = CInt ( value )
Case " type "
move . Type = New Element ( value )
Case " category "
Select Case value . ToLower ( )
Case " physical "
move . Category = Attack . Categories . Physical
Case " special "
move . Category = Attack . Categories . Special
Case " status "
move . Category = Attack . Categories . Status
End Select
Case " contestcategory "
Select Case value . ToLower ( )
Case " tough "
move . ContestCategory = Attack . ContestCategories . Tough
Case " smart "
move . ContestCategory = Attack . ContestCategories . Smart
Case " beauty "
move . ContestCategory = Attack . ContestCategories . Beauty
Case " cool "
move . ContestCategory = Attack . ContestCategories . Cool
Case " cute "
move . ContestCategory = Attack . ContestCategories . Cute
End Select
Case " name "
move . Name = value
Case " description "
move . Description = value
Case " criticalchance " , " critical "
move . CriticalChance = CInt ( value )
Case " hmmove " , " ishmmove "
move . IsHMMove = CBool ( value )
Case " priority "
move . Priority = CInt ( value )
Case " timestoattack " , " tta "
move . TimesToAttack = CInt ( value )
Case " makescontact " , " contact "
move . MakesContact = CBool ( value )
Case " protectaffected "
move . ProtectAffected = CBool ( value )
Case " magiccoataffected "
move . MagicCoatAffected = CBool ( value )
Case " snatchaffected "
move . SnatchAffected = CBool ( value )
Case " mirrormoveaffected "
move . MirrorMoveAffected = CBool ( value )
Case " kingsrockaffected "
move . KingsrockAffected = CBool ( value )
Case " counteraffected "
move . CounterAffected = CBool ( value )
Case " disabledduringgravity " , " disabledwhilegravity "
move . DisabledWhileGravity = CBool ( value )
Case " useeffectiveness "
move . UseEffectiveness = CBool ( value )
Case " ishealingmove "
move . IsHealingMove = CBool ( value )
2023-04-01 08:58:01 +02:00
Case " removesownfrozen " , " removesfrozen "
move . RemovesOwnFrozen = CBool ( value )
Case " removesoppfrozen "
move . RemovesOppFrozen = CBool ( value )
2016-09-07 18:50:38 +02:00
Case " isrecoilmove "
move . IsRecoilMove = CBool ( value )
Case " ispunchingmove "
move . IsPunchingMove = CBool ( value )
Case " immunityaffected "
move . ImmunityAffected = CBool ( value )
Case " isdamagingmove "
move . IsDamagingMove = CBool ( value )
Case " isprotectmove "
move . IsProtectMove = CBool ( value )
Case " issoundmove "
move . IsSoundMove = CBool ( value )
Case " isaffectedbysubstitute "
move . IsAffectedBySubstitute = CBool ( value )
Case " isonehitkomove "
move . IsOneHitKOMove = CBool ( value )
Case " iswonderguardaffected "
move . IsWonderGuardAffected = CBool ( value )
Case " useaccevasion "
move . UseAccEvasion = CBool ( value )
Case " canhitinmidair "
move . CanHitInMidAir = CBool ( value )
Case " canhitunderground "
move . CanHitUnderground = CBool ( value )
Case " canhitunderwater "
move . CanHitUnderwater = CBool ( value )
Case " canhitsleeping "
move . CanHitSleeping = CBool ( value )
Case " cangainstab "
move . CanGainSTAB = CBool ( value )
Case " ispowdermove "
move . IsPowderMove = CBool ( value )
Case " istrappingmove "
move . IsTrappingMove = CBool ( value )
Case " ispulsemove "
move . IsPulseMove = CBool ( value )
Case " isbulletmove "
move . IsBulletMove = CBool ( value )
Case " isjawmove "
move . IsJawMove = CBool ( value )
Case " useoppdefense "
move . UseOppDefense = CBool ( value )
Case " useoppevasion "
move . UseOppEvasion = CBool ( value )
Added a GameMode Move property and 2 functions
* Fixed an issue with GameMode Items in battles
* Updated the example files for GameMode Items and GameMode Moves
* Maybe fixed something audio volume related
* Made it possible to disable the reduction of PP using the DeductPP (bool) property for GameModeMoves
* Added the new functions "SetTrigger" and "RemoveTrigger" for GameModeMoves:
Function "SetTrigger" checks if a Pokémon does or does not have a certain Status and prevents functions after it from executing if the Pokémon does not have the desired Status.
The function is formatted like this: Function|SetTrigger,Target,Triggers
* "Target" determines which Pokémon's Status is checked and has to be either 0 or 1 (0 = check own Pokémon, 1 = check opponent's Pokémon)
* "Triggers" determines the status effect(s) that should or should not be on the target Pokémon. You can add multiple possible status effects to check for by separating them with a semicolon (;), the values can be: "burn", "freeze", "paralyze", "poison", "badpoison", "anypoison", "sleep", "noburn", "nofreeze", "noparalyze", "nopoison", "nobadpoison", "nopoison", "nosleep"
Function "RemoveTrigger" removes such a trigger so that functions after it are executed
2023-06-13 20:22:35 +02:00
Case " deductpp "
move . gmDeductPP = CBool ( value )
2016-09-07 18:50:38 +02:00
End Select
End If
Next
Catch ex As Exception
'If an error occurs loading a move, log the error.
Logger . Log ( Logger . LogTypes . ErrorMessage , " GameModeAttackLoader.vb: Error loading GameMode move from file "" " & file & " "" : " & ex . Message & " ; Last Key/Value pair successfully loaded: " & key & " | " & value )
End Try
2023-07-07 12:05:57 +02:00
If nonCommentLines > 0 Then
If setID = True Then
If move . ID >= 1000 Then
Dim testMove As Attack = Attack . GetAttackByID ( move . ID )
If testMove . IsDefaultMove = True Then
LoadedMoves . Add ( move ) 'Add the move.
Else
Logger . Log ( Logger . LogTypes . ErrorMessage , " GameModeAttackLoader.vb: User defined moves are not allowed to have an ID of an already existing move or an ID below 1000. The ID for the move loaded from "" " & file & " "" has the ID " & move . ID . ToString ( ) & " , which is the ID of an already existing move ( " & testMove . Name & " ). " )
End If
2016-09-07 18:50:38 +02:00
Else
2023-07-07 12:05:57 +02:00
Logger . Log ( Logger . LogTypes . ErrorMessage , " GameModeAttackLoader.vb: User defined moves are not allowed to have an ID of an already existing move or an ID below 1000. The ID for the move loaded from "" " & file & " "" has the ID " & move . ID . ToString ( ) & " , which is smaller than 1000. " )
2016-09-07 18:50:38 +02:00
End If
Else
2023-07-07 12:05:57 +02:00
Logger . Log ( Logger . LogTypes . ErrorMessage , " GameModeAttackLoader.vb: User defined moves must set their ID through the "" ID "" property, however the move loaded from "" " & file & " "" has no ID set so it will be ignored. " )
2016-09-07 18:50:38 +02:00
End If
Else
2023-07-07 12:05:57 +02:00
Debug . Print ( " GameModeAttackLoader.vb: The move loaded from "" " & file & " "" has no valid lines so it will be ignored. " )
2016-09-07 18:50:38 +02:00
End If
End Sub
''' <summary>
''' Returns a custom move based on its ID.
''' </summary>
''' <param name="ID">The ID of the custom move.</param>
''' <returns>Returns a move or nothing.</returns>
Public Shared Function GetAttackByID ( ByVal ID As Integer ) As Attack
For Each m As Attack In LoadedMoves
If m . ID = ID Then
Return m
End If
Next
Return Nothing
End Function
End Class
End Namespace