Fixed BGM bug when ending surfing and immediately triggering a trainer battle with an intro BGM, fixed events making all other events check if they trigger after the event moves, fixed Neutralizing Gas triggering twice upon fainting

This commit is contained in:
Maruno17
2023-11-05 15:42:15 +00:00
parent 092fbda34d
commit 156a6fca74
7 changed files with 53 additions and 20 deletions

View File

@@ -113,6 +113,8 @@ class Interpreter
end
@move_route_waiting = false
end
# Do nothing if the player is jumping out of surfing
return if $game_temp.ending_surf
# Do nothing while waiting
if @wait_count > 0
return if System.uptime - @wait_start < @wait_count
@@ -162,7 +164,7 @@ class Interpreter
# Assemble error message
err = "Script error in Interpreter\r\n"
if $game_map
map_name = ($game_map.name rescue nil) || "???"
map_name = (pbGetBasicMapNameFromId($game_map.map_id) rescue nil) || "???"
if event
err = "Script error in event #{event.id} (coords #{event.x},#{event.y}), map #{$game_map.map_id} (#{map_name})\r\n"
else

View File

@@ -817,7 +817,7 @@ class Game_Character
oldDirection = @direction
@direction = dir
@stop_count = 0
pbCheckEventTriggerAfterTurning if dir != oldDirection
check_event_trigger_after_turning if dir != oldDirection
end
def turn_down; turn_generic(2); end

View File

@@ -139,16 +139,6 @@ class Game_Event < Game_Character
return false
end
def pbCheckEventTriggerAfterTurning
return if $game_system.map_interpreter.running? || @starting
return if @trigger != 2 # Event touch
return if !@event.name[/(?:sight|trainer)\((\d+)\)/i]
distance = $~[1].to_i
return if !pbEventCanReachPlayer?(self, $game_player, distance)
return if jumping? || over_trigger?
start
end
def check_event_trigger_touch(dir)
return if $game_system.map_interpreter.running?
return if @trigger != 2 # Event touch
@@ -167,6 +157,32 @@ class Game_Event < Game_Character
start
end
def check_event_trigger_after_turning
return if $game_system.map_interpreter.running? || @starting
return if @trigger != 2 # Not Event Touch
return if !self.name[/(?:sight|trainer)\((\d+)\)/i]
distance = $~[1].to_i
return if !pbEventCanReachPlayer?(self, $game_player, distance)
return if jumping? || over_trigger?
start
end
def check_event_trigger_after_moving
return if $game_system.map_interpreter.running? || @starting
return if @trigger != 2 # Not Event Touch
if self.name[/(?:sight|trainer)\((\d+)\)/i]
distance = $~[1].to_i
return if !pbEventCanReachPlayer?(self, $game_player, distance)
elsif self.name[/counter\((\d+)\)/i]
distance = $~[1].to_i
return if !pbEventFacesPlayer?(self, $game_player, distance)
else
return
end
return if jumping? || over_trigger?
start
end
def check_event_trigger_auto
case @trigger
when 2 # Event touch
@@ -263,7 +279,7 @@ class Game_Event < Game_Character
@moveto_happened = false
last_moving = moving?
super
$game_player.pbCheckEventTriggerFromDistance([2]) if !moving? && last_moving
check_event_trigger_after_moving if !moving? && last_moving
if @need_refresh
@need_refresh = false
refresh

View File

@@ -313,7 +313,7 @@ class Game_Player < Game_Character
return result
end
def pbCheckEventTriggerAfterTurning; end
def check_event_trigger_after_turning; end
def pbCheckEventTriggerFromDistance(triggers)
events = pbTriggeredTrainerEvents(triggers)

View File

@@ -8,12 +8,21 @@ class Battle::Battler
end
# Reset form
@battle.peer.pbOnLeavingBattle(@battle, @pokemon, @battle.usedInBattle[idxOwnSide][@index / 2])
# Check for end of Neutralizing Gas/Unnerve
if hasActiveAbility?(:NEUTRALIZINGGAS)
# Treat self as fainted
@hp = 0
@fainted = true
pbAbilitiesOnNeutralizingGasEnding
elsif hasActiveAbility?([:UNNERVE, :ASONECHILLINGNEIGH, :ASONEGRIMNEIGH])
# Treat self as fainted
@hp = 0
@fainted = true
pbItemsOnUnnerveEnding
end
# Treat self as fainted
@hp = 0
@fainted = true
# Check for end of Neutralizing Gas/Unnerve
pbAbilitiesOnNeutralizingGasEnding if hasActiveAbility?(:NEUTRALIZINGGAS, true)
pbItemsOnUnnerveEnding if hasActiveAbility?([:UNNERVE, :ASONECHILLINGNEIGH, :ASONEGRIMNEIGH], true)
# Check for end of primordial weather
@battle.pbEndPrimordialWeather
end

View File

@@ -328,7 +328,7 @@ class PokemonPokedexInfo_Scene
map_metadata = GameData::MapMetadata.try_get(enc_data.map)
next if !map_metadata || map_metadata.has_flag?("HideEncountersInPokedex")
mappos = map_metadata.town_map_position
next if mappos[0] != @region # Map isn't in the region being shown
next if !mappos || mappos[0] != @region # Map isn't in the region being shown
# Get the size and shape of the map in the Town Map
map_size = map_metadata.town_map_size
map_width = 1

View File

@@ -65,8 +65,14 @@ def pbPlayTrainerIntroBGM(trainer_type)
return if nil_or_empty?(trainer_type_data.intro_BGM)
bgm = pbStringToAudioFile(trainer_type_data.intro_BGM)
if !$game_temp.memorized_bgm
$game_temp.memorized_bgm = $game_system.getPlayingBGM
$game_temp.memorized_bgm_position = (Audio.bgm_pos rescue 0)
if $game_temp.cue_bgm_delay
$game_temp.cue_bgm_delay = nil
$game_temp.memorized_bgm = $game_temp.cue_bgm
$game_temp.memorized_bgm_position = 0
else
$game_temp.memorized_bgm = $game_system.getPlayingBGM
$game_temp.memorized_bgm_position = (Audio.bgm_pos rescue 0)
end
end
pbBGMPlay(bgm)
end