Fix issue trainer and wild at same time...

When a wild and trainer encounter happen at the same time, they no longer cancel each other out (hopefully)
This commit is contained in:
JappaWakka 2025-01-31 13:13:45 +01:00
parent 1db6f81cb3
commit e9a8a89856
4 changed files with 30 additions and 16 deletions

View File

@ -347,7 +347,7 @@
End If End If
End Sub End Sub
Public Sub CheckInSight() Public Function CheckInSight() As Boolean
If Me.TrainerSight > -1 And Screen.Level.PokemonEncounterData.EncounteredPokemon = False And Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then If Me.TrainerSight > -1 And Screen.Level.PokemonEncounterData.EncounteredPokemon = False And Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
If CInt(Me.Position.Y) = CInt(Screen.Camera.Position.Y) And Screen.Camera.IsMoving() = False Then If CInt(Me.Position.Y) = CInt(Screen.Camera.Position.Y) And Screen.Camera.IsMoving() = False Then
If Moved = 0.0F And Me.CanBeRemoved = False Then If Moved = 0.0F And Me.CanBeRemoved = False Then
@ -434,7 +434,8 @@
If l.ToLower.StartsWith("@trainer:") = True Then If l.ToLower.StartsWith("@trainer:") = True Then
Dim trainerID As String = l.GetSplit(1, ":") Dim trainerID As String = l.GetSplit(1, ":")
If Trainer.IsBeaten(trainerID) = True Then If Trainer.IsBeaten(trainerID) = True Then
Exit Sub Return False
Exit Function
Else Else
Dim t As New Trainer(trainerID) Dim t As New Trainer(trainerID)
InSightMusic = t.GetInSightMusic() InSightMusic = t.GetInSightMusic()
@ -442,7 +443,8 @@
ElseIf l.ToLower.StartsWith("@battle.starttrainer(") = True Then ElseIf l.ToLower.StartsWith("@battle.starttrainer(") = True Then
Dim trainerID As String = l.Remove(l.Length - 1, 1).Remove(0, "@battle.starttrainer(".Length) Dim trainerID As String = l.Remove(l.Length - 1, 1).Remove(0, "@battle.starttrainer(".Length)
If Trainer.IsBeaten(trainerID) = True Then If Trainer.IsBeaten(trainerID) = True Then
Exit Sub Return False
Exit Function
Else Else
Dim t As New Trainer(trainerID) Dim t As New Trainer(trainerID)
InSightMusic = t.GetInSightMusic() InSightMusic = t.GetInSightMusic()
@ -507,6 +509,7 @@
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(s, 2,,, "NPCInSight") CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(s, 2,,, "NPCInSight")
ActionScript.IsInSightScript = True ActionScript.IsInSightScript = True
Return True
End If End If
End If End If
End If End If
@ -514,7 +517,9 @@
End If End If
End If End If
End If End If
End Sub Return False
End Function
Public Overrides Sub ClickFunction() Public Overrides Sub ClickFunction()
If Me.Movement = Movements.Straight Then If Me.Movement = Movements.Straight Then

View File

@ -281,6 +281,17 @@ Public Class OverworldScreen
End If End If
End If End If
If Core.Player.CheckForTrainersLater = True AndAlso Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen AndAlso CType(CurrentScreen, OverworldScreen).ActionScript.IsReady = True Then
Screen.Level.PokemonEncounterData.EncounteredPokemon = False
Screen.Level.CheckTrainerSights()
If CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
If CType(CurrentScreen, OverworldScreen).ActionScript.IsReady = False Then
Core.Player._stepEventStartedTrainer = True
End If
End If
Core.Player.CheckForTrainersLater = False
End If
SkyDome.Update() SkyDome.Update()
Level.RouteSign.Update() Level.RouteSign.Update()
@ -473,15 +484,6 @@ Public Class OverworldScreen
ActionScript.StartScript(AfterRoamingBattleScript, 0,,, "AfterRoamingBattleScript") ActionScript.StartScript(AfterRoamingBattleScript, 0,,, "AfterRoamingBattleScript")
AfterRoamingBattleScript = "" AfterRoamingBattleScript = ""
End If End If
If Core.Player.CheckForTrainersLater = True Then
Screen.Level.CheckTrainerSights()
If CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
If CType(CurrentScreen, OverworldScreen).ActionScript.IsReady = False Then
Core.Player._stepEventStartedTrainer = True
End If
End If
Core.Player.CheckForTrainersLater = False
End If
End Sub End Sub
''' <summary> ''' <summary>

View File

@ -1245,16 +1245,20 @@ Public Class Level
''' <summary> ''' <summary>
''' Checks all NPCs on the map for if the player is in their line of sight. ''' Checks all NPCs on the map for if the player is in their line of sight.
''' </summary> ''' </summary>
Public Sub CheckTrainerSights() Public Function CheckTrainerSights() As Boolean
Dim IsInSight = False
For Each Entity As Entity In Entities For Each Entity As Entity In Entities
If Entity.EntityID = "NPC" Then If Entity.EntityID = "NPC" Then
Dim NPC As NPC = CType(Entity, NPC) Dim NPC As NPC = CType(Entity, NPC)
If NPC.IsTrainer = True Then If NPC.IsTrainer = True Then
NPC.CheckInSight() If NPC.CheckInSight() = True Then
IsInSight = True
End If
End If End If
End If End If
Next Next
End Sub Return IsInSight
End Function
''' <summary> ''' <summary>
''' Determines whether the player can use Ride on this map. ''' Determines whether the player can use Ride on this map.

View File

@ -34,6 +34,9 @@ Public Class PokemonEncounter
With Me._levelReference With Me._levelReference
If .WalkedSteps > 3 Then ' Three Step Rule - Only after walking 3 steps, try to encounter a wild Pokémon: If .WalkedSteps > 3 Then ' Three Step Rule - Only after walking 3 steps, try to encounter a wild Pokémon:
If Screen.Level.CheckTrainerSights() = True Then
Exit Sub
End If
' Compose the correct .poke file from the levelfile, if the pokeFile parameter is empty: ' Compose the correct .poke file from the levelfile, if the pokeFile parameter is empty:
If pokeFile = "" Then If pokeFile = "" Then
pokeFile = .LevelFile.Remove(.LevelFile.Length - 4, 4) & ".poke" pokeFile = .LevelFile.Remove(.LevelFile.Length - 4, 4) & ".poke"