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

View File

@ -281,6 +281,17 @@ Public Class OverworldScreen
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()
Level.RouteSign.Update()
@ -473,15 +484,6 @@ Public Class OverworldScreen
ActionScript.StartScript(AfterRoamingBattleScript, 0,,, "AfterRoamingBattleScript")
AfterRoamingBattleScript = ""
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
''' <summary>

View File

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

View File

@ -34,6 +34,9 @@ Public Class PokemonEncounter
With Me._levelReference
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:
If pokeFile = "" Then
pokeFile = .LevelFile.Remove(.LevelFile.Length - 4, 4) & ".poke"