Added Step Script commands & constructs

@Player.SetScriptSteps(stepAmount,scriptPath)
Executes a script file after having moved the given amount of steps.

@Player.ClearScriptSteps
Clears the register created with @Player.SetScriptSteps, preventing the script from being executed.

<Player.ScriptSteps>
Returns the amount of steps before the script as defined by @Player.SetScriptSteps is executed.
This commit is contained in:
JappaWakka 2023-10-29 17:59:39 +01:00
parent c76ee70b08
commit dae406f887
4 changed files with 60 additions and 0 deletions

View File

@ -151,6 +151,15 @@
End Set End Set
End Property End Property
Public Property ScriptSteps() As Integer
Get
Return _scriptSteps
End Get
Set(value As Integer)
_scriptSteps = value
End Set
End Property
Public Property SaveCreated() As String Public Property SaveCreated() As String
Get Get
Return _saveCreated Return _saveCreated
@ -399,6 +408,7 @@
Private _lastSavePlace As String = "yourroom.dat" Private _lastSavePlace As String = "yourroom.dat"
Private _lastSavePlacePosition As String = "1,0.1,3" Private _lastSavePlacePosition As String = "1,0.1,3"
Private _repelSteps As Integer = 0 Private _repelSteps As Integer = 0
Private _scriptSteps As Integer = 0
Private _saveCreated As String = "Pre 0.21" Private _saveCreated As String = "Pre 0.21"
Private _daycareSteps As Integer = 0 Private _daycareSteps As Integer = 0
Private _poisonSteps As Integer = 0 Private _poisonSteps As Integer = 0
@ -849,6 +859,8 @@
End If End If
Case "repelsteps" Case "repelsteps"
RepelSteps = CInt(Value) RepelSteps = CInt(Value)
Case "scriptsteps"
ScriptSteps = CInt(Value)
Case "lastsaveplace" Case "lastsaveplace"
LastSavePlace = Value LastSavePlace = Value
Case "lastsaveplaceposition" Case "lastsaveplaceposition"
@ -1347,6 +1359,7 @@
"LastRestPlacePosition|" & LastRestPlacePosition & Environment.NewLine & "LastRestPlacePosition|" & LastRestPlacePosition & Environment.NewLine &
"DiagonalMovement|" & DiagonalMovement.ToNumberString() & Environment.NewLine & "DiagonalMovement|" & DiagonalMovement.ToNumberString() & Environment.NewLine &
"RepelSteps|" & RepelSteps.ToString() & Environment.NewLine & "RepelSteps|" & RepelSteps.ToString() & Environment.NewLine &
"ScriptSteps|" & ScriptSteps.ToString() & Environment.NewLine &
"LastSavePlace|" & LastSavePlace & Environment.NewLine & "LastSavePlace|" & LastSavePlace & Environment.NewLine &
"LastSavePlacePosition|" & LastSavePlacePosition & Environment.NewLine & "LastSavePlacePosition|" & LastSavePlacePosition & Environment.NewLine &
"Difficulty|" & DifficultyMode.ToString() & Environment.NewLine & "Difficulty|" & DifficultyMode.ToString() & Environment.NewLine &
@ -1779,6 +1792,7 @@
StepEventCheckTrainers() StepEventCheckTrainers()
StepEventCheckEggHatching(stepAmount) StepEventCheckEggHatching(stepAmount)
StepEventCheckRepel(stepAmount) StepEventCheckRepel(stepAmount)
StepEventCheckScript(stepAmount)
StepEventWildPokemon() StepEventWildPokemon()
StepEventPokegearCall() StepEventPokegearCall()
Else Else
@ -1872,6 +1886,35 @@
End If End If
End Sub End Sub
Private Sub StepEventCheckScript(ByVal stepAmount As Integer)
If ScriptSteps > 0 Then
ScriptSteps -= stepAmount
If ScriptSteps <= 0 Then
If CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
If CanFireStepEvent() = True Then
Dim registerContent() As Object = ActionScript.GetRegisterValue("SCRIPTSTEPS")
If registerContent(0) Is Nothing Or registerContent(1) Is Nothing Then
Logger.Log(Logger.LogTypes.Warning, "ScriptComparer.vb: No valid script has been set to be executed.")
ActionScript.UnregisterID("SCRIPTSTEPS", "str")
ActionScript.UnregisterID("SCRIPTSTEPS")
Exit Sub
End If
Dim lValue As String = CStr(registerContent(0))
CType(CurrentScreen, OverworldScreen).ActionScript.StartScript(lValue, 0, False)
ActionScript.UnregisterID("SCRIPTSTEPS", "str")
ActionScript.UnregisterID("SCRIPTSTEPS")
Else
ScriptSteps = 1
End If
End If
End If
End If
End Sub
Private Sub StepEventWildPokemon() Private Sub StepEventWildPokemon()
If CanFireStepEvent() = True Then If CanFireStepEvent() = True Then
If Screen.Level.WildPokemonFloor = True And Screen.Level.Surfing = False Then If Screen.Level.WildPokemonFloor = True And Screen.Level.Surfing = False Then

View File

@ -376,6 +376,18 @@
Dim newOpacity As Single = sng(argument.Replace("~", Screen.Level.OwnPlayer.Opacity.ToString().Replace(".", GameController.DecSeparator))) Dim newOpacity As Single = sng(argument.Replace("~", Screen.Level.OwnPlayer.Opacity.ToString().Replace(".", GameController.DecSeparator)))
Screen.Level.OwnPlayer.Opacity = newOpacity Screen.Level.OwnPlayer.Opacity = newOpacity
IsReady = True IsReady = True
Case "setscriptsteps"
If argument.Contains(",") = True Then
Dim args() As String = argument.Split(CChar(","))
Core.Player.ScriptSteps = CInt(args(0))
ActionScript.RegisterID("SCRIPTSTEPS", "str", args(1))
End If
IsReady = True
Case "clearscriptsteps"
ActionScript.UnregisterID("SCRIPTSTEPS", "str")
ActionScript.UnregisterID("SCRIPTSTEPS")
Core.Player.ScriptSteps = 0
IsReady = True
Case Else Case Else
IsReady = True IsReady = True
End Select End Select

View File

@ -127,6 +127,8 @@
ReturnBoolean(Core.Player.IsGameJoltSave = True AndAlso GameJolt.LogInScreen.UserBanned(GameJoltSave.GameJoltID) = False) ReturnBoolean(Core.Player.IsGameJoltSave = True AndAlso GameJolt.LogInScreen.UserBanned(GameJoltSave.GameJoltID) = False)
End If End If
Return ReturnBoolean(Core.Player.IsGameJoltSave) Return ReturnBoolean(Core.Player.IsGameJoltSave)
Case "scriptsteps"
Return Core.Player.ScriptSteps
End Select End Select
Return DEFAULTNULL Return DEFAULTNULL
End Function End Function

View File

@ -518,6 +518,8 @@ Namespace ScriptVersion2
r(New ScriptCommand("player", "setrivalname", {New ScriptArgument("name", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Sets the rival's name.")) r(New ScriptCommand("player", "setrivalname", {New ScriptArgument("name", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Sets the rival's name."))
r(New ScriptCommand("player", "setrivalskin", {New ScriptArgument("skin", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Sets the rival's skin.")) r(New ScriptCommand("player", "setrivalskin", {New ScriptArgument("skin", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Sets the rival's skin."))
r(New ScriptCommand("player", "setopacity", {New ScriptArgument("opacity", ScriptArgument.ArgumentTypes.Sng)}.ToList(), "Sets the player entity's opacity.")) r(New ScriptCommand("player", "setopacity", {New ScriptArgument("opacity", ScriptArgument.ArgumentTypes.Sng)}.ToList(), "Sets the player entity's opacity."))
r(New ScriptCommand("player", "setscriptsteps", {New ScriptArgument("stepAmount", ScriptArgument.ArgumentTypes.Int), New ScriptArgument("scriptPath", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Executes a script file after having moved the given amount of steps."))
r(New ScriptCommand("player", "clearscriptsteps", "Clears the register created with @player.setscriptsteps, preventing the script from being executed."))
' Constructs: ' Constructs:
r(New ScriptCommand("player", "position", "sngarr", {New ScriptArgument("coordinate", ScriptArgument.ArgumentTypes.StrArr, {"x", "y", "z"}, True, "")}.ToList(), "Returns the position of the player. The normal coordinate combination is ""X,Y,Z"".", ",", True)) r(New ScriptCommand("player", "position", "sngarr", {New ScriptArgument("coordinate", ScriptArgument.ArgumentTypes.StrArr, {"x", "y", "z"}, True, "")}.ToList(), "Returns the position of the player. The normal coordinate combination is ""X,Y,Z"".", ",", True))
@ -543,6 +545,7 @@ Namespace ScriptVersion2
r(New ScriptCommand("player", "gamejoltid", "str", "Returns the player's GameJolt ID.", ",", True)) r(New ScriptCommand("player", "gamejoltid", "str", "Returns the player's GameJolt ID.", ",", True))
r(New ScriptCommand("player", "haspokedex", "bool", "Returns if the player received the Pokédex.", ",", True)) r(New ScriptCommand("player", "haspokedex", "bool", "Returns if the player received the Pokédex.", ",", True))
r(New ScriptCommand("player", "haspokegear", "bool", "Returns if the player received the Pokégear.", ",", True)) r(New ScriptCommand("player", "haspokegear", "bool", "Returns if the player received the Pokégear.", ",", True))
r(New ScriptCommand("player", "scriptsteps", "int", "Returns the amount of steps before the script as defined by @player.setscriptsteps is executed.", ",", True))
End Sub End Sub
Private Shared Sub DoNPC() Private Shared Sub DoNPC()