mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 22:24:58 +00:00
Merged Events and EncounterModifier into module EventHandlers
This commit is contained in:
@@ -205,22 +205,22 @@ end
|
||||
|
||||
|
||||
|
||||
Events.onSpritesetCreate += proc { |_sender, e|
|
||||
spriteset = e[0] # Spriteset being created
|
||||
viewport = e[1] # Viewport used for tilemap and characters
|
||||
map = spriteset.map # Map associated with the spriteset (not necessarily the current map)
|
||||
map.events.keys.each do |i|
|
||||
if map.events[i].name[/^outdoorlight\((\w+)\)$/i]
|
||||
filename = $~[1].to_s
|
||||
spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i], viewport, map, filename))
|
||||
elsif map.events[i].name[/^outdoorlight$/i]
|
||||
spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i], viewport, map))
|
||||
elsif map.events[i].name[/^light\((\w+)\)$/i]
|
||||
filename = $~[1].to_s
|
||||
spriteset.addUserSprite(LightEffect_Basic.new(map.events[i], viewport, map, filename))
|
||||
elsif map.events[i].name[/^light$/i]
|
||||
spriteset.addUserSprite(LightEffect_Basic.new(map.events[i], viewport, map))
|
||||
EventHandlers.add(:on_new_spriteset_map, :add_light_effects,
|
||||
proc { |spriteset, viewport|
|
||||
map = spriteset.map # Map associated with the spriteset (not necessarily the current map)
|
||||
map.events.keys.each do |i|
|
||||
if map.events[i].name[/^outdoorlight\((\w+)\)$/i]
|
||||
filename = $~[1].to_s
|
||||
spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i], viewport, map, filename))
|
||||
elsif map.events[i].name[/^outdoorlight$/i]
|
||||
spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i], viewport, map))
|
||||
elsif map.events[i].name[/^light\((\w+)\)$/i]
|
||||
filename = $~[1].to_s
|
||||
spriteset.addUserSprite(LightEffect_Basic.new(map.events[i], viewport, map, filename))
|
||||
elsif map.events[i].name[/^light$/i]
|
||||
spriteset.addUserSprite(LightEffect_Basic.new(map.events[i], viewport, map))
|
||||
end
|
||||
end
|
||||
end
|
||||
spriteset.addUserSprite(Particle_Engine.new(viewport, map))
|
||||
}
|
||||
spriteset.addUserSprite(Particle_Engine.new(viewport, map))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
# Constant checks
|
||||
#===============================================================================
|
||||
# Pokérus check
|
||||
Events.onMapUpdate += proc { |_sender, _e|
|
||||
next if !$player
|
||||
last = $PokemonGlobal.pokerusTime
|
||||
now = pbGetTimeNow
|
||||
if !last || last.year != now.year || last.month != now.month || last.day != now.day
|
||||
$player.pokemon_party.each do |i|
|
||||
i.lowerPokerusCount
|
||||
EventHandlers.add(:on_frame_update, :pokerus_counter,
|
||||
proc {
|
||||
next if !$player
|
||||
last = $PokemonGlobal.pokerusTime
|
||||
next if !last
|
||||
now = pbGetTimeNow
|
||||
if last.year != now.year || last.month != now.month || last.day != now.day
|
||||
$player.pokemon_party.each { |pkmn| pkmn.lowerPokerusCount }
|
||||
$PokemonGlobal.pokerusTime = now
|
||||
end
|
||||
$PokemonGlobal.pokerusTime = now
|
||||
end
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
# Returns whether the Poké Center should explain Pokérus to the player, if a
|
||||
# healed Pokémon has it.
|
||||
@@ -46,70 +47,74 @@ def pbBatteryLow?
|
||||
return false
|
||||
end
|
||||
|
||||
Events.onMapUpdate += proc { |_sender, _e|
|
||||
if !$game_temp.warned_low_battery && pbBatteryLow? &&
|
||||
!$game_temp.in_menu && !$game_temp.in_battle && !$game_player.move_route_forcing &&
|
||||
!$game_temp.message_window_showing && !pbMapInterpreterRunning? &&
|
||||
pbGetTimeNow.sec == 0
|
||||
pbMessage(_INTL("The game has detected that the battery is low. You should save soon to avoid losing your progress."))
|
||||
EventHandlers.add(:on_frame_update, :low_battery_warning,
|
||||
proc {
|
||||
next if $game_temp.warned_low_battery || !pbBatteryLow?
|
||||
next if $game_temp.in_menu || $game_temp.in_battle || $game_player.move_route_forcing ||
|
||||
$game_temp.message_window_showing || pbMapInterpreterRunning?
|
||||
next if pbGetTimeNow.sec != 0
|
||||
$game_temp.warned_low_battery = true
|
||||
end
|
||||
if $game_temp.cue_bgm_frame_delay
|
||||
pbMessage(_INTL("The game has detected that the battery is low. You should save soon to avoid losing your progress."))
|
||||
}
|
||||
)
|
||||
|
||||
EventHandlers.add(:on_frame_update, :cue_bgm_after_delay,
|
||||
proc {
|
||||
next if $game_temp.cue_bgm_frame_delay.nil?
|
||||
$game_temp.cue_bgm_frame_delay -= 1
|
||||
if $game_temp.cue_bgm_frame_delay <= 0
|
||||
$game_temp.cue_bgm_frame_delay = nil
|
||||
pbBGMPlay($game_temp.cue_bgm) if $game_system.getPlayingBGM.nil?
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
next if $game_temp.cue_bgm_frame_delay > 0
|
||||
$game_temp.cue_bgm_frame_delay = nil
|
||||
pbBGMPlay($game_temp.cue_bgm) if $game_system.getPlayingBGM.nil?
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# Checks per step
|
||||
#===============================================================================
|
||||
# Party Pokémon gain happiness from walking
|
||||
Events.onStepTaken += proc {
|
||||
$PokemonGlobal.happinessSteps = 0 if !$PokemonGlobal.happinessSteps
|
||||
$PokemonGlobal.happinessSteps += 1
|
||||
if $PokemonGlobal.happinessSteps >= 128
|
||||
EventHandlers.add(:on_player_step_taken, :gain_happiness,
|
||||
proc {
|
||||
$PokemonGlobal.happinessSteps = 0 if !$PokemonGlobal.happinessSteps
|
||||
$PokemonGlobal.happinessSteps += 1
|
||||
next if $PokemonGlobal.happinessSteps < 128
|
||||
$player.able_party.each do |pkmn|
|
||||
pkmn.changeHappiness("walking") if rand(2) == 0
|
||||
end
|
||||
$PokemonGlobal.happinessSteps = 0
|
||||
end
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
# Poison party Pokémon
|
||||
Events.onStepTakenTransferPossible += proc { |_sender, e|
|
||||
handled = e[0]
|
||||
next if handled[0]
|
||||
if $PokemonGlobal.stepcount % 4 == 0 && Settings::POISON_IN_FIELD
|
||||
EventHandlers.add(:on_player_step_taken_can_transfer, :poison_party,
|
||||
proc { |handled|
|
||||
# handled is an array: [nil]. If [true], a message has already been shown
|
||||
# because of this step, so don't do anything that might show another one
|
||||
next if handled[0]
|
||||
next if !Settings::POISON_IN_FIELD || $PokemonGlobal.stepcount % 4 != 0
|
||||
flashed = false
|
||||
$player.able_party.each do |i|
|
||||
if i.status == :POISON && !i.hasAbility?(:IMMUNITY)
|
||||
if !flashed
|
||||
pbFlash(Color.new(255, 0, 0, 128), 8)
|
||||
flashed = true
|
||||
end
|
||||
i.hp -= 1 if i.hp > 1 || Settings::POISON_FAINT_IN_FIELD
|
||||
if i.hp == 1 && !Settings::POISON_FAINT_IN_FIELD
|
||||
i.status = :NONE
|
||||
pbMessage(_INTL("{1} survived the poisoning.\\nThe poison faded away!\1", i.name))
|
||||
next
|
||||
elsif i.hp == 0
|
||||
i.changeHappiness("faint")
|
||||
i.status = :NONE
|
||||
pbMessage(_INTL("{1} fainted...", i.name))
|
||||
end
|
||||
if $player.able_pokemon_count == 0
|
||||
handled[0] = true
|
||||
pbCheckAllFainted
|
||||
end
|
||||
$player.able_party.each do |pkmn|
|
||||
next if pkmn.status != :POISON || pkmn.hasAbility?(:IMMUNITY)
|
||||
if !flashed
|
||||
pbFlash(Color.new(255, 0, 0, 128), 8)
|
||||
flashed = true
|
||||
end
|
||||
pkmn.hp -= 1 if pkmn.hp > 1 || Settings::POISON_FAINT_IN_FIELD
|
||||
if pkmn.hp == 1 && !Settings::POISON_FAINT_IN_FIELD
|
||||
pkmn.status = :NONE
|
||||
pbMessage(_INTL("{1} survived the poisoning.\\nThe poison faded away!\1", pkmn.name))
|
||||
next
|
||||
elsif pkmn.hp == 0
|
||||
pkmn.changeHappiness("faint")
|
||||
pkmn.status = :NONE
|
||||
pbMessage(_INTL("{1} fainted...", pkmn.name))
|
||||
end
|
||||
if $player.able_pokemon_count == 0
|
||||
handled[0] = true
|
||||
pbCheckAllFainted
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
def pbCheckAllFainted
|
||||
if $player.able_pokemon_count == 0
|
||||
@@ -122,67 +127,74 @@ def pbCheckAllFainted
|
||||
end
|
||||
|
||||
# Gather soot from soot grass
|
||||
Events.onStepTakenFieldMovement += proc { |_sender, e|
|
||||
event = e[0] # Get the event affected by field movement
|
||||
thistile = $map_factory.getRealTilePos(event.map.map_id, event.x, event.y)
|
||||
map = $map_factory.getMap(thistile[0])
|
||||
[2, 1, 0].each do |i|
|
||||
tile_id = map.data[thistile[1], thistile[2], i]
|
||||
next if tile_id.nil?
|
||||
next if GameData::TerrainTag.try_get(map.terrain_tags[tile_id]).id != :SootGrass
|
||||
if event == $game_player && $bag.has?(:SOOTSACK)
|
||||
old_soot = $player.soot
|
||||
$player.soot += 1
|
||||
$stats.soot_collected += $player.soot - old_soot if $player.soot > old_soot
|
||||
EventHandlers.add(:on_step_taken, :pick_up_soot,
|
||||
proc { |event|
|
||||
thistile = $map_factory.getRealTilePos(event.map.map_id, event.x, event.y)
|
||||
map = $map_factory.getMap(thistile[0])
|
||||
[2, 1, 0].each do |i|
|
||||
tile_id = map.data[thistile[1], thistile[2], i]
|
||||
next if tile_id.nil?
|
||||
next if GameData::TerrainTag.try_get(map.terrain_tags[tile_id]).id != :SootGrass
|
||||
if event == $game_player && $bag.has?(:SOOTSACK)
|
||||
old_soot = $player.soot
|
||||
$player.soot += 1
|
||||
$stats.soot_collected += $player.soot - old_soot if $player.soot > old_soot
|
||||
end
|
||||
map.erase_tile(thistile[1], thistile[2], i)
|
||||
break
|
||||
end
|
||||
map.erase_tile(thistile[1], thistile[2], i)
|
||||
break
|
||||
end
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
# Show grass rustle animation, and auto-move the player over waterfalls and ice
|
||||
Events.onStepTakenFieldMovement += proc { |_sender, e|
|
||||
event = e[0] # Get the event affected by field movement
|
||||
if $scene.is_a?(Scene_Map)
|
||||
# Show grass rustle animation
|
||||
EventHandlers.add(:on_step_taken, :grass_rustling,
|
||||
proc { |event|
|
||||
next if !$scene.is_a?(Scene_Map)
|
||||
event.each_occupied_tile do |x, y|
|
||||
if $map_factory.getTerrainTag(event.map.map_id, x, y, true).shows_grass_rustle
|
||||
$scene.spriteset.addUserAnimation(Settings::GRASS_ANIMATION_ID, x, y, true, 1)
|
||||
end
|
||||
next if !$map_factory.getTerrainTag(event.map.map_id, x, y, true).shows_grass_rustle
|
||||
$scene.spriteset.addUserAnimation(Settings::GRASS_ANIMATION_ID, x, y, true, 1)
|
||||
end
|
||||
if event == $game_player
|
||||
currentTag = $game_player.pbTerrainTag
|
||||
if currentTag.waterfall_crest
|
||||
pbDescendWaterfall
|
||||
elsif currentTag.ice && !$PokemonGlobal.sliding
|
||||
pbSlideOnIce
|
||||
end
|
||||
}
|
||||
)
|
||||
|
||||
# Auto-move the player over waterfalls and ice
|
||||
EventHandlers.add(:on_step_taken, :auto_move_player,
|
||||
proc { |event|
|
||||
next if !$scene.is_a?(Scene_Map)
|
||||
next if event != $game_player
|
||||
currentTag = $game_player.pbTerrainTag
|
||||
if currentTag.waterfall_crest
|
||||
pbDescendWaterfall
|
||||
elsif currentTag.ice && !$PokemonGlobal.sliding
|
||||
pbSlideOnIce
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
def pbOnStepTaken(eventTriggered)
|
||||
if $game_player.move_route_forcing || pbMapInterpreterRunning?
|
||||
Events.onStepTakenFieldMovement.trigger(nil, $game_player)
|
||||
EventHandlers.trigger(:on_step_taken, $game_player)
|
||||
return
|
||||
end
|
||||
$PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount
|
||||
$PokemonGlobal.stepcount += 1
|
||||
$PokemonGlobal.stepcount &= 0x7FFFFFFF
|
||||
repel_active = ($PokemonGlobal.repel > 0)
|
||||
Events.onStepTaken.trigger(nil)
|
||||
# Events.onStepTakenFieldMovement.trigger(nil,$game_player)
|
||||
EventHandlers.trigger(:on_player_step_taken)
|
||||
handled = [nil]
|
||||
Events.onStepTakenTransferPossible.trigger(nil, handled)
|
||||
EventHandlers.trigger(:on_player_step_taken_can_transfer, handled)
|
||||
return if handled[0]
|
||||
pbBattleOnStepTaken(repel_active) if !eventTriggered && !$game_temp.in_menu
|
||||
$game_temp.encounter_triggered = false # This info isn't needed here
|
||||
end
|
||||
|
||||
# Start wild encounters while turning on the spot
|
||||
Events.onChangeDirection += proc {
|
||||
repel_active = ($PokemonGlobal.repel > 0)
|
||||
pbBattleOnStepTaken(repel_active) if !$game_temp.in_menu
|
||||
}
|
||||
EventHandlers.add(:on_player_change_direction, :trigger_encounter,
|
||||
proc {
|
||||
repel_active = ($PokemonGlobal.repel > 0)
|
||||
pbBattleOnStepTaken(repel_active) if !$game_temp.in_menu
|
||||
}
|
||||
)
|
||||
|
||||
def pbBattleOnStepTaken(repel_active)
|
||||
return if $player.able_pokemon_count == 0
|
||||
@@ -192,11 +204,11 @@ def pbBattleOnStepTaken(repel_active)
|
||||
return if !$PokemonEncounters.encounter_triggered?(encounter_type, repel_active)
|
||||
$game_temp.encounter_type = encounter_type
|
||||
encounter = $PokemonEncounters.choose_wild_pokemon(encounter_type)
|
||||
encounter = EncounterModifier.trigger(encounter)
|
||||
EventHandlers.trigger(:on_wild_species_chosen, encounter)
|
||||
if $PokemonEncounters.allow_encounter?(encounter, repel_active)
|
||||
if $PokemonEncounters.have_double_wild_battle?
|
||||
encounter2 = $PokemonEncounters.choose_wild_pokemon(encounter_type)
|
||||
encounter2 = EncounterModifier.trigger(encounter2)
|
||||
EventHandlers.trigger(:on_wild_species_chosen, encounter2)
|
||||
pbDoubleWildBattle(encounter[0], encounter[1], encounter2[0], encounter2[1])
|
||||
else
|
||||
pbWildBattle(encounter[0], encounter[1])
|
||||
@@ -205,7 +217,6 @@ def pbBattleOnStepTaken(repel_active)
|
||||
$game_temp.encounter_triggered = true
|
||||
end
|
||||
$game_temp.force_single_battle = false
|
||||
EncounterModifier.triggerEncounterEnd
|
||||
end
|
||||
|
||||
|
||||
@@ -216,67 +227,94 @@ end
|
||||
# Clears the weather of the old map, if the old map has defined weather and the
|
||||
# new map either has the same name as the old map or doesn't have defined
|
||||
# weather.
|
||||
Events.onMapChanging += proc { |_sender, e|
|
||||
new_map_ID = e[0]
|
||||
next if new_map_ID == 0
|
||||
old_map_metadata = $game_map.metadata
|
||||
next if !old_map_metadata || !old_map_metadata.weather
|
||||
map_infos = pbLoadMapInfos
|
||||
if $game_map.name == map_infos[new_map_ID].name
|
||||
new_map_metadata = GameData::MapMetadata.try_get(new_map_ID)
|
||||
next if new_map_metadata&.weather
|
||||
end
|
||||
$game_screen.weather(:None, 0, 0)
|
||||
}
|
||||
EventHandlers.add(:on_leave_map, :end_weather,
|
||||
proc { |new_map_id, new_map|
|
||||
next if new_map_id == 0
|
||||
old_map_metadata = $game_map.metadata
|
||||
next if !old_map_metadata || !old_map_metadata.weather
|
||||
map_infos = pbLoadMapInfos
|
||||
if $game_map.name == map_infos[new_map_id].name
|
||||
new_map_metadata = GameData::MapMetadata.try_get(new_map_id)
|
||||
next if new_map_metadata&.weather
|
||||
end
|
||||
$game_screen.weather(:None, 0, 0)
|
||||
}
|
||||
)
|
||||
|
||||
# Set up various data related to the new map
|
||||
Events.onMapChange += proc { |_sender, e|
|
||||
old_map_ID = e[0] # previous map ID, is 0 if no map ID
|
||||
new_map_metadata = $game_map.metadata
|
||||
if new_map_metadata&.teleport_destination
|
||||
$PokemonGlobal.healingSpot = new_map_metadata.teleport_destination
|
||||
end
|
||||
$PokemonMap&.clear
|
||||
$PokemonEncounters&.setup($game_map.map_id)
|
||||
$PokemonGlobal.visitedMaps[$game_map.map_id] = true
|
||||
next if old_map_ID == 0 || old_map_ID == $game_map.map_id
|
||||
next if !new_map_metadata || !new_map_metadata.weather
|
||||
map_infos = pbLoadMapInfos
|
||||
if $game_map.name == map_infos[old_map_ID].name
|
||||
old_map_metadata = GameData::MapMetadata.try_get(old_map_ID)
|
||||
next if old_map_metadata&.weather
|
||||
end
|
||||
new_weather = new_map_metadata.weather
|
||||
$game_screen.weather(new_weather[0], 9, 0) if rand(100) < new_weather[1]
|
||||
}
|
||||
EventHandlers.add(:on_enter_map, :setup_new_map,
|
||||
proc { |old_map_id| # previous map ID, is 0 if no map ID
|
||||
# Record new Teleport destination
|
||||
new_map_metadata = $game_map.metadata
|
||||
if new_map_metadata&.teleport_destination
|
||||
$PokemonGlobal.healingSpot = new_map_metadata.teleport_destination
|
||||
end
|
||||
# End effects that apply only while on the map they were used
|
||||
$PokemonMap&.clear
|
||||
# Setup new wild encounter tables
|
||||
$PokemonEncounters&.setup($game_map.map_id)
|
||||
# Record the new map as having been visited
|
||||
$PokemonGlobal.visitedMaps[$game_map.map_id] = true
|
||||
# Set weather if new map has weather
|
||||
next if old_map_id == 0 || old_map_id == $game_map.map_id
|
||||
next if !new_map_metadata || !new_map_metadata.weather
|
||||
map_infos = pbLoadMapInfos
|
||||
if $game_map.name == map_infos[old_map_id].name
|
||||
old_map_metadata = GameData::MapMetadata.try_get(old_map_id)
|
||||
next if old_map_metadata&.weather
|
||||
end
|
||||
new_weather = new_map_metadata.weather
|
||||
$game_screen.weather(new_weather[0], 9, 0) if rand(100) < new_weather[1]
|
||||
}
|
||||
)
|
||||
|
||||
Events.onMapSceneChange += proc { |_sender, e|
|
||||
scene = e[0]
|
||||
mapChanged = e[1]
|
||||
next if !scene || !scene.spriteset
|
||||
# Update map trail
|
||||
if $game_map
|
||||
# Update trail of which maps the player has most recently visited.
|
||||
EventHandlers.add(:on_enter_map, :add_to_trail,
|
||||
proc { |_old_map_id|
|
||||
next if !$game_map
|
||||
$PokemonGlobal.mapTrail = [] if !$PokemonGlobal.mapTrail
|
||||
if $PokemonGlobal.mapTrail[0] != $game_map.map_id && $PokemonGlobal.mapTrail.length >= 4
|
||||
$PokemonGlobal.mapTrail.pop
|
||||
end
|
||||
$PokemonGlobal.mapTrail = [$game_map.map_id] + $PokemonGlobal.mapTrail
|
||||
end
|
||||
# Display darkness circle on dark maps
|
||||
map_metadata = $game_map.metadata
|
||||
if map_metadata&.dark_map
|
||||
$game_temp.darkness_sprite = DarknessSprite.new
|
||||
scene.spriteset.addUserSprite($game_temp.darkness_sprite)
|
||||
if $PokemonGlobal.flashUsed
|
||||
$game_temp.darkness_sprite.radius = $game_temp.darkness_sprite.radiusMax
|
||||
}
|
||||
)
|
||||
|
||||
# Force cycling/walking.
|
||||
EventHandlers.add(:on_enter_map, :force_cycling,
|
||||
proc { |_old_map_id|
|
||||
if $game_map.metadata&.always_bicycle
|
||||
pbMountBike
|
||||
elsif !pbCanUseBike?($game_map.map_id)
|
||||
pbDismountBike
|
||||
end
|
||||
else
|
||||
$PokemonGlobal.flashUsed = false
|
||||
$game_temp.darkness_sprite&.dispose
|
||||
$game_temp.darkness_sprite = nil
|
||||
end
|
||||
# Show location signpost
|
||||
if mapChanged && map_metadata && map_metadata.announce_location
|
||||
}
|
||||
)
|
||||
|
||||
# Display darkness circle on dark maps.
|
||||
EventHandlers.add(:on_map_or_spriteset_change, :show_darkness,
|
||||
proc { |scene, _map_changed|
|
||||
next if !scene || !scene.spriteset
|
||||
map_metadata = $game_map.metadata
|
||||
if map_metadata&.dark_map
|
||||
$game_temp.darkness_sprite = DarknessSprite.new
|
||||
scene.spriteset.addUserSprite($game_temp.darkness_sprite)
|
||||
if $PokemonGlobal.flashUsed
|
||||
$game_temp.darkness_sprite.radius = $game_temp.darkness_sprite.radiusMax
|
||||
end
|
||||
else
|
||||
$PokemonGlobal.flashUsed = false
|
||||
$game_temp.darkness_sprite&.dispose
|
||||
$game_temp.darkness_sprite = nil
|
||||
end
|
||||
}
|
||||
)
|
||||
|
||||
# Show location signpost.
|
||||
EventHandlers.add(:on_map_or_spriteset_change, :show_location_window,
|
||||
proc { |scene, map_changed|
|
||||
next if !scene || !scene.spriteset
|
||||
next if !map_changed || !$game_map.metadata&.announce_location
|
||||
nosignpost = false
|
||||
if $PokemonGlobal.mapTrail[1]
|
||||
(Settings::NO_SIGNPOSTS.length / 2).times do |i|
|
||||
@@ -291,14 +329,8 @@ Events.onMapSceneChange += proc { |_sender, e|
|
||||
nosignpost = true if $game_map.name == oldmapname
|
||||
end
|
||||
scene.spriteset.addUserSprite(LocationWindow.new($game_map.name)) if !nosignpost
|
||||
end
|
||||
# Force cycling/walking
|
||||
if map_metadata&.always_bicycle
|
||||
pbMountBike
|
||||
elsif !pbCanUseBike?($game_map.map_id)
|
||||
pbDismountBike
|
||||
end
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -683,7 +715,7 @@ def pbRegisterPartner(tr_type, tr_name, tr_id = 0)
|
||||
tr_type = GameData::TrainerType.get(tr_type).id
|
||||
pbCancelVehicles
|
||||
trainer = pbLoadTrainer(tr_type, tr_name, tr_id)
|
||||
Events.onTrainerPartyLoad.trigger(nil, trainer)
|
||||
EventHandlers.trigger(:on_trainer_load, trainer)
|
||||
trainer.party.each do |i|
|
||||
i.owner = Pokemon::Owner.new_from_trainer(trainer)
|
||||
i.calc_stats
|
||||
|
||||
@@ -188,18 +188,20 @@ def pbGetEnvironment
|
||||
return ret
|
||||
end
|
||||
|
||||
Events.onStartBattle += proc { |_sender|
|
||||
# Record current levels of Pokémon in party, to see if they gain a level
|
||||
# during battle and may need to evolve afterwards
|
||||
$game_temp.party_levels_before_battle = []
|
||||
$game_temp.party_critical_hits_dealt = []
|
||||
$game_temp.party_direct_damage_taken = []
|
||||
$player.party.each_with_index do |pkmn, i|
|
||||
$game_temp.party_levels_before_battle[i] = pkmn.level
|
||||
$game_temp.party_critical_hits_dealt[i] = 0
|
||||
$game_temp.party_direct_damage_taken[i] = 0
|
||||
end
|
||||
}
|
||||
# Record current levels of Pokémon in party, to see if they gain a level during
|
||||
# battle and may need to evolve afterwards
|
||||
EventHandlers.add(:on_start_battle, :record_party_status,
|
||||
proc {
|
||||
$game_temp.party_levels_before_battle = []
|
||||
$game_temp.party_critical_hits_dealt = []
|
||||
$game_temp.party_direct_damage_taken = []
|
||||
$player.party.each_with_index do |pkmn, i|
|
||||
$game_temp.party_levels_before_battle[i] = pkmn.level
|
||||
$game_temp.party_critical_hits_dealt[i] = 0
|
||||
$game_temp.party_direct_damage_taken[i] = 0
|
||||
end
|
||||
}
|
||||
)
|
||||
|
||||
def pbCanDoubleBattle?
|
||||
return $PokemonGlobal.partner || $player.able_pokemon_count >= 2
|
||||
@@ -230,7 +232,7 @@ def pbWildBattleCore(*args)
|
||||
end
|
||||
# Record information about party Pokémon to be used at the end of battle (e.g.
|
||||
# comparing levels for an evolution check)
|
||||
Events.onStartBattle.trigger(nil)
|
||||
EventHandlers.trigger(:on_start_battle)
|
||||
# Generate wild Pokémon based on the species and level
|
||||
foeParty = []
|
||||
sp = nil
|
||||
@@ -314,8 +316,8 @@ def pbWildBattle(species, level, outcomeVar = 1, canRun = true, canLose = false)
|
||||
# Potentially call a different pbWildBattle-type method instead (for roaming
|
||||
# Pokémon, Safari battles, Bug Contest battles)
|
||||
handled = [nil]
|
||||
Events.onWildBattleOverride.trigger(nil, species, level, handled)
|
||||
return handled[0] if handled[0] != nil
|
||||
EventHandlers.trigger(:on_calling_wild_battle, species, level, handled)
|
||||
return handled[0] if !handled[0].nil?
|
||||
# Set some battle rules
|
||||
setBattleRule("outcomeVar", outcomeVar) if outcomeVar != 1
|
||||
setBattleRule("cannotRun") if !canRun
|
||||
@@ -323,7 +325,7 @@ def pbWildBattle(species, level, outcomeVar = 1, canRun = true, canLose = false)
|
||||
# Perform the battle
|
||||
decision = pbWildBattleCore(species, level)
|
||||
# Used by the Poké Radar to update/break the chain
|
||||
Events.onWildBattleEnd.trigger(nil, species, level, decision)
|
||||
EventHandlers.trigger(:on_wild_battle_end, species, level, decision)
|
||||
# Return false if the player lost or drew the battle, and true if any other result
|
||||
return (decision != 2 && decision != 5)
|
||||
end
|
||||
@@ -375,7 +377,7 @@ def pbTrainerBattleCore(*args)
|
||||
end
|
||||
# Record information about party Pokémon to be used at the end of battle (e.g.
|
||||
# comparing levels for an evolution check)
|
||||
Events.onStartBattle.trigger(nil)
|
||||
EventHandlers.trigger(:on_start_battle)
|
||||
# Generate trainers and their parties based on the arguments given
|
||||
foeTrainers = []
|
||||
foeItems = []
|
||||
@@ -394,7 +396,7 @@ def pbTrainerBattleCore(*args)
|
||||
trainer = pbLoadTrainer(arg[0], arg[1], arg[2])
|
||||
pbMissingTrainer(arg[0], arg[1], arg[2]) if !trainer
|
||||
return 0 if !trainer
|
||||
Events.onTrainerPartyLoad.trigger(nil, trainer)
|
||||
EventHandlers.trigger(:on_trainer_load, trainer)
|
||||
foeTrainers.push(trainer)
|
||||
foePartyStarts.push(foeParty.length)
|
||||
trainer.party.each { |pkmn| foeParty.push(pkmn) }
|
||||
@@ -495,7 +497,7 @@ def pbTrainerBattle(trainerID, trainerName, endSpeech = nil,
|
||||
trainer = pbLoadTrainer(trainerID, trainerName, trainerPartyID)
|
||||
pbMissingTrainer(trainerID, trainerName, trainerPartyID) if !trainer
|
||||
return false if !trainer
|
||||
Events.onTrainerPartyLoad.trigger(nil, trainer)
|
||||
EventHandlers.trigger(:on_trainer_load, trainer)
|
||||
# If there is exactly 1 other triggered trainer event, and this trainer has
|
||||
# 6 or fewer Pokémon, record this trainer for a double battle caused by the
|
||||
# other triggered trainer event
|
||||
@@ -580,34 +582,34 @@ def pbAfterBattle(decision, canLose)
|
||||
$player.party.each { |pkmn| pkmn.heal }
|
||||
(Graphics.frame_rate / 4).times { Graphics.update }
|
||||
end
|
||||
Events.onEndBattle.trigger(nil, decision, canLose)
|
||||
EventHandlers.trigger(:on_end_battle, decision, canLose)
|
||||
$game_player.straighten
|
||||
end
|
||||
|
||||
Events.onEndBattle += proc { |_sender, e|
|
||||
decision = e[0]
|
||||
canLose = e[1]
|
||||
# Check for evolutions
|
||||
pbEvolutionCheck if Settings::CHECK_EVOLUTION_AFTER_ALL_BATTLES ||
|
||||
(decision != 2 && decision != 5) # not a loss or a draw
|
||||
$game_temp.party_levels_before_battle = nil
|
||||
$game_temp.party_critical_hits_dealt = nil
|
||||
$game_temp.party_direct_damage_taken = nil
|
||||
# Check for blacking out or gaining Pickup/Huney Gather items
|
||||
case decision
|
||||
when 1, 4 # Win, capture
|
||||
$player.pokemon_party.each do |pkmn|
|
||||
pbPickup(pkmn)
|
||||
pbHoneyGather(pkmn)
|
||||
EventHandlers.add(:on_end_battle, :evolve_and_black_out,
|
||||
proc { |decision, canLose|
|
||||
# Check for evolutions
|
||||
pbEvolutionCheck if Settings::CHECK_EVOLUTION_AFTER_ALL_BATTLES ||
|
||||
(decision != 2 && decision != 5) # not a loss or a draw
|
||||
$game_temp.party_levels_before_battle = nil
|
||||
$game_temp.party_critical_hits_dealt = nil
|
||||
$game_temp.party_direct_damage_taken = nil
|
||||
# Check for blacking out or gaining Pickup/Huney Gather items
|
||||
case decision
|
||||
when 1, 4 # Win, capture
|
||||
$player.pokemon_party.each do |pkmn|
|
||||
pbPickup(pkmn)
|
||||
pbHoneyGather(pkmn)
|
||||
end
|
||||
when 2, 5 # Lose, draw
|
||||
if !canLose
|
||||
$game_system.bgm_unpause
|
||||
$game_system.bgs_unpause
|
||||
pbStartOver
|
||||
end
|
||||
end
|
||||
when 2, 5 # Lose, draw
|
||||
if !canLose
|
||||
$game_system.bgm_unpause
|
||||
$game_system.bgs_unpause
|
||||
pbStartOver
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
def pbEvolutionCheck
|
||||
$player.party.each_with_index do |pkmn, i|
|
||||
|
||||
@@ -446,7 +446,7 @@ def pbGenerateWildPokemon(species, level, isRoamer = false)
|
||||
end
|
||||
end
|
||||
# Trigger events that may alter the generated Pokémon further
|
||||
Events.onWildPokemonCreate.trigger(nil, genwildpoke)
|
||||
EventHandlers.trigger(:on_wild_pokemon_created, genwildpoke)
|
||||
return genwildpoke
|
||||
end
|
||||
|
||||
@@ -455,11 +455,11 @@ end
|
||||
def pbEncounter(enc_type)
|
||||
$game_temp.encounter_type = enc_type
|
||||
encounter1 = $PokemonEncounters.choose_wild_pokemon(enc_type)
|
||||
encounter1 = EncounterModifier.trigger(encounter1)
|
||||
EventHandlers.trigger(:on_wild_species_chosen, encounter1)
|
||||
return false if !encounter1
|
||||
if $PokemonEncounters.have_double_wild_battle?
|
||||
encounter2 = $PokemonEncounters.choose_wild_pokemon(enc_type)
|
||||
encounter2 = EncounterModifier.trigger(encounter2)
|
||||
EventHandlers.trigger(:on_wild_species_chosen, encounter2)
|
||||
return false if !encounter2
|
||||
pbDoubleWildBattle(encounter1[0], encounter1[1], encounter2[0], encounter2[1])
|
||||
else
|
||||
@@ -467,6 +467,5 @@ def pbEncounter(enc_type)
|
||||
end
|
||||
$game_temp.encounter_type = nil
|
||||
$game_temp.force_single_battle = false
|
||||
EncounterModifier.triggerEncounterEnd
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -6,35 +6,36 @@
|
||||
################################################################################
|
||||
|
||||
# Make all wild Pokémon shiny while a certain Switch is ON (see Settings).
|
||||
Events.onWildPokemonCreate += proc { |_sender, e|
|
||||
pkmn = e[0]
|
||||
if $game_switches[Settings::SHINY_WILD_POKEMON_SWITCH]
|
||||
pkmn.shiny = true
|
||||
end
|
||||
}
|
||||
EventHandlers.add(:on_wild_pokemon_created, :make_shiny_switch,
|
||||
proc { |pkmn|
|
||||
pkmn.shiny = true if $game_switches[Settings::SHINY_WILD_POKEMON_SWITCH]
|
||||
}
|
||||
)
|
||||
|
||||
# Used in the random dungeon map. Makes the levels of all wild Pokémon in that
|
||||
# Used in the random dungeon map. Makes the levels of all wild Pokémon in that
|
||||
# map depend on the levels of Pokémon in the player's party.
|
||||
# This is a simple method, and can/should be modified to account for evolutions
|
||||
# and other such details. Of course, you don't HAVE to use this code.
|
||||
Events.onWildPokemonCreate += proc { |_sender, e|
|
||||
pkmn = e[0]
|
||||
if $game_map.map_id == 51
|
||||
EventHandlers.add(:on_wild_pokemon_created, :level_depends_on_party,
|
||||
proc { |pkmn|
|
||||
next if $game_map.map_id != 51
|
||||
new_level = pbBalancedLevel($player.party) - 4 + rand(5) # For variety
|
||||
new_level = new_level.clamp(1, GameData::GrowthRate.max_level)
|
||||
pkmn.level = new_level
|
||||
pkmn.calc_stats
|
||||
pkmn.reset_moves
|
||||
end
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
# This is the basis of a trainer modifier. It works both for trainers loaded
|
||||
# when you battle them, and for partner trainers when they are registered.
|
||||
# Note that you can only modify a partner trainer's Pokémon, and not the trainer
|
||||
# themselves nor their items this way, as those are generated from scratch
|
||||
# before each battle.
|
||||
#Events.onTrainerPartyLoad += proc { |_sender, trainer|
|
||||
# if trainer # An NPCTrainer object containing party/items/lose text, etc.
|
||||
# YOUR CODE HERE
|
||||
# end
|
||||
#}
|
||||
#EventHandlers.trigger(:on_trainer_load, :put_a_name_here,
|
||||
# proc { |trainer|
|
||||
# if trainer # An NPCTrainer object containing party/items/lose text, etc.
|
||||
# YOUR CODE HERE
|
||||
# end
|
||||
# }
|
||||
#)
|
||||
|
||||
@@ -93,16 +93,17 @@ end
|
||||
|
||||
# When the player moves to a new map (with a different name), make all roaming
|
||||
# Pokémon roam.
|
||||
Events.onMapChange += proc { |_sender, e|
|
||||
oldMapID = e[0]
|
||||
# Get and compare map names
|
||||
mapInfos = pbLoadMapInfos
|
||||
next if mapInfos && oldMapID > 0 && mapInfos[oldMapID] &&
|
||||
mapInfos[oldMapID].name && $game_map.name == mapInfos[oldMapID].name
|
||||
# Make roaming Pokémon roam
|
||||
pbRoamPokemon
|
||||
$PokemonGlobal.roamedAlready = false
|
||||
}
|
||||
EventHandlers.add(:on_enter_map, :move_roaming_pokemon,
|
||||
proc { |old_map_id|
|
||||
# Get and compare map names
|
||||
mapInfos = pbLoadMapInfos
|
||||
next if mapInfos && old_map_id > 0 && mapInfos[old_map_id] &&
|
||||
mapInfos[old_map_id].name && $game_map.name == mapInfos[old_map_id].name
|
||||
# Make roaming Pokémon roam
|
||||
pbRoamPokemon
|
||||
$PokemonGlobal.roamedAlready = false
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -135,64 +136,69 @@ def pbRoamingMethodAllowed(roamer_method)
|
||||
return false
|
||||
end
|
||||
|
||||
EncounterModifier.register(proc { |encounter|
|
||||
$game_temp.roamer_index_for_encounter = nil
|
||||
next nil if !encounter
|
||||
# Give the regular encounter if encountering a roaming Pokémon isn't possible
|
||||
next encounter if $PokemonGlobal.roamedAlready
|
||||
next encounter if $PokemonGlobal.partner
|
||||
next encounter if $game_temp.poke_radar_data
|
||||
next encounter if rand(100) < 75 # 25% chance of encountering a roaming Pokémon
|
||||
# Look at each roaming Pokémon in turn and decide whether it's possible to
|
||||
# encounter it
|
||||
currentRegion = pbGetCurrentRegion
|
||||
currentMapName = $game_map.name
|
||||
possible_roamers = []
|
||||
Settings::ROAMING_SPECIES.each_with_index do |data, i|
|
||||
# data = [species, level, Game Switch, roamer method, battle BGM, area maps hash]
|
||||
next if !GameData::Species.exists?(data[0])
|
||||
next if data[2] > 0 && !$game_switches[data[2]] # Isn't roaming
|
||||
next if $PokemonGlobal.roamPokemon[i] == true # Roaming Pokémon has been caught
|
||||
# Get the roamer's current map
|
||||
roamerMap = $PokemonGlobal.roamPosition[i]
|
||||
if !roamerMap
|
||||
mapIDs = pbRoamingAreas(i).keys # Hash of area patrolled by the roaming Pokémon
|
||||
next if !mapIDs || mapIDs.length == 0 # No roaming area defined somehow
|
||||
roamerMap = mapIDs[rand(mapIDs.length)]
|
||||
$PokemonGlobal.roamPosition[i] = roamerMap
|
||||
EventHandlers.add(:on_wild_species_chosen, :roaming_pokemon,
|
||||
proc { |encounter|
|
||||
$game_temp.roamer_index_for_encounter = nil
|
||||
next if !encounter
|
||||
# Give the regular encounter if encountering a roaming Pokémon isn't possible
|
||||
next if $PokemonGlobal.roamedAlready
|
||||
next if $PokemonGlobal.partner
|
||||
next if $game_temp.poke_radar_data
|
||||
next if rand(100) < 75 # 25% chance of encountering a roaming Pokémon
|
||||
# Look at each roaming Pokémon in turn and decide whether it's possible to
|
||||
# encounter it
|
||||
currentRegion = pbGetCurrentRegion
|
||||
currentMapName = $game_map.name
|
||||
possible_roamers = []
|
||||
Settings::ROAMING_SPECIES.each_with_index do |data, i|
|
||||
# data = [species, level, Game Switch, roamer method, battle BGM, area maps hash]
|
||||
next if !GameData::Species.exists?(data[0])
|
||||
next if data[2] > 0 && !$game_switches[data[2]] # Isn't roaming
|
||||
next if $PokemonGlobal.roamPokemon[i] == true # Roaming Pokémon has been caught
|
||||
# Get the roamer's current map
|
||||
roamerMap = $PokemonGlobal.roamPosition[i]
|
||||
if !roamerMap
|
||||
mapIDs = pbRoamingAreas(i).keys # Hash of area patrolled by the roaming Pokémon
|
||||
next if !mapIDs || mapIDs.length == 0 # No roaming area defined somehow
|
||||
roamerMap = mapIDs[rand(mapIDs.length)]
|
||||
$PokemonGlobal.roamPosition[i] = roamerMap
|
||||
end
|
||||
# If roamer isn't on the current map, check if it's on a map with the same
|
||||
# name and in the same region
|
||||
if roamerMap != $game_map.map_id
|
||||
map_metadata = GameData::MapMetadata.try_get(roamerMap)
|
||||
next if !map_metadata || !map_metadata.town_map_position ||
|
||||
map_metadata.town_map_position[0] != currentRegion
|
||||
next if pbGetMapNameFromId(roamerMap) != currentMapName
|
||||
end
|
||||
# Check whether the roamer's roamer method is currently possible
|
||||
next if !pbRoamingMethodAllowed(data[3])
|
||||
# Add this roaming Pokémon to the list of possible roaming Pokémon to encounter
|
||||
possible_roamers.push([i, data[0], data[1], data[4]]) # [i, species, level, BGM]
|
||||
end
|
||||
# If roamer isn't on the current map, check if it's on a map with the same
|
||||
# name and in the same region
|
||||
if roamerMap != $game_map.map_id
|
||||
map_metadata = GameData::MapMetadata.try_get(roamerMap)
|
||||
next if !map_metadata || !map_metadata.town_map_position ||
|
||||
map_metadata.town_map_position[0] != currentRegion
|
||||
next if pbGetMapNameFromId(roamerMap) != currentMapName
|
||||
end
|
||||
# Check whether the roamer's roamer method is currently possible
|
||||
next if !pbRoamingMethodAllowed(data[3])
|
||||
# Add this roaming Pokémon to the list of possible roaming Pokémon to encounter
|
||||
possible_roamers.push([i, data[0], data[1], data[4]]) # [i, species, level, BGM]
|
||||
end
|
||||
# No encounterable roaming Pokémon were found, just have the regular encounter
|
||||
next encounter if possible_roamers.length == 0
|
||||
# Pick a roaming Pokémon to encounter out of those available
|
||||
roamer = possible_roamers[rand(possible_roamers.length)]
|
||||
$PokemonGlobal.roamEncounter = roamer
|
||||
$game_temp.roamer_index_for_encounter = roamer[0]
|
||||
$PokemonGlobal.nextBattleBGM = roamer[3] if roamer[3] && !roamer[3].empty?
|
||||
$game_temp.force_single_battle = true
|
||||
next [roamer[1], roamer[2]] # Species, level
|
||||
})
|
||||
# No encounterable roaming Pokémon were found, just have the regular encounter
|
||||
next if possible_roamers.length == 0
|
||||
# Pick a roaming Pokémon to encounter out of those available
|
||||
roamer = possible_roamers.sample
|
||||
$PokemonGlobal.roamEncounter = roamer
|
||||
$game_temp.roamer_index_for_encounter = roamer[0]
|
||||
$PokemonGlobal.nextBattleBGM = roamer[3] if roamer[3] && !roamer[3].empty?
|
||||
$game_temp.force_single_battle = true
|
||||
encounter[0] = roamer[1] # Species
|
||||
encounter[1] = roamer[2] # Level
|
||||
}
|
||||
)
|
||||
|
||||
Events.onWildBattleOverride += proc { |_sender, e|
|
||||
species = e[0]
|
||||
level = e[1]
|
||||
handled = e[2]
|
||||
next if handled[0] != nil
|
||||
next if !$PokemonGlobal.roamEncounter || $game_temp.roamer_index_for_encounter.nil?
|
||||
handled[0] = pbRoamingPokemonBattle(species, level)
|
||||
}
|
||||
EventHandlers.add(:on_calling_wild_battle, :roaming_pokemon,
|
||||
proc { |species, level, handled|
|
||||
# handled is an array: [nil]. If [true] or [false], the battle has already
|
||||
# been overridden (the boolean is its outcome), so don't do anything that
|
||||
# would override it again
|
||||
next if !handled[0].nil?
|
||||
next if !$PokemonGlobal.roamEncounter || $game_temp.roamer_index_for_encounter.nil?
|
||||
handled[0] = pbRoamingPokemonBattle(species, level)
|
||||
}
|
||||
)
|
||||
|
||||
def pbRoamingPokemonBattle(species, level)
|
||||
# Get the roaming Pokémon to encounter; generate it based on the species and
|
||||
@@ -214,12 +220,9 @@ def pbRoamingPokemonBattle(species, level)
|
||||
end
|
||||
$PokemonGlobal.roamEncounter = nil
|
||||
$PokemonGlobal.roamedAlready = true
|
||||
$game_temp.roamer_index_for_encounter = nil
|
||||
# Used by the Poké Radar to update/break the chain
|
||||
Events.onWildBattleEnd.trigger(nil, species, level, decision)
|
||||
EventHandlers.trigger(:on_wild_battle_end, species, level, decision)
|
||||
# Return false if the player lost or drew the battle, and true if any other result
|
||||
return (decision != 2 && decision != 5)
|
||||
end
|
||||
|
||||
EncounterModifier.registerEncounterEnd(proc {
|
||||
$game_temp.roamer_index_for_encounter = nil
|
||||
})
|
||||
|
||||
@@ -49,7 +49,7 @@ end
|
||||
|
||||
# Unused
|
||||
def pbHiddenMoveEvent
|
||||
Events.onAction.trigger(nil)
|
||||
EventHandlers.trigger(:on_player_interact)
|
||||
end
|
||||
|
||||
def pbCheckHiddenMoveBadge(badge = -1, showmsg = true)
|
||||
@@ -383,22 +383,24 @@ def pbTransferUnderwater(mapid, x, y, direction = $game_player.direction)
|
||||
}
|
||||
end
|
||||
|
||||
Events.onAction += proc { |_sender, _e|
|
||||
if $PokemonGlobal.diving
|
||||
surface_map_id = nil
|
||||
GameData::MapMetadata.each do |map_data|
|
||||
next if !map_data.dive_map_id || map_data.dive_map_id != $game_map.map_id
|
||||
surface_map_id = map_data.id
|
||||
break
|
||||
EventHandlers.add(:on_player_interact, :diving,
|
||||
proc {
|
||||
if $PokemonGlobal.diving
|
||||
surface_map_id = nil
|
||||
GameData::MapMetadata.each do |map_data|
|
||||
next if !map_data.dive_map_id || map_data.dive_map_id != $game_map.map_id
|
||||
surface_map_id = map_data.id
|
||||
break
|
||||
end
|
||||
if surface_map_id &&
|
||||
$map_factory.getTerrainTag(surface_map_id, $game_player.x, $game_player.y).can_dive
|
||||
pbSurfacing
|
||||
end
|
||||
elsif $game_player.terrain_tag.can_dive
|
||||
pbDive
|
||||
end
|
||||
if surface_map_id &&
|
||||
$map_factory.getTerrainTag(surface_map_id, $game_player.x, $game_player.y).can_dive
|
||||
pbSurfacing
|
||||
end
|
||||
elsif $game_player.terrain_tag.can_dive
|
||||
pbDive
|
||||
end
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
HiddenMoveHandlers::CanUseMove.add(:DIVE, proc { |move, pkmn, showmsg|
|
||||
next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_DIVE, showmsg)
|
||||
@@ -703,10 +705,12 @@ def pbStrength
|
||||
return false
|
||||
end
|
||||
|
||||
Events.onAction += proc { |_sender, _e|
|
||||
facingEvent = $game_player.pbFacingEvent
|
||||
pbStrength if facingEvent && facingEvent.name[/strengthboulder/i]
|
||||
}
|
||||
EventHandlers.add(:on_player_interact, :strength_event,
|
||||
proc {
|
||||
facingEvent = $game_player.pbFacingEvent
|
||||
pbStrength if facingEvent && facingEvent.name[/strengthboulder/i]
|
||||
}
|
||||
)
|
||||
|
||||
HiddenMoveHandlers::CanUseMove.add(:STRENGTH, proc { |move, pkmn, showmsg|
|
||||
next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_STRENGTH, showmsg)
|
||||
@@ -796,13 +800,15 @@ def pbTransferSurfing(mapid, xcoord, ycoord, direction = $game_player.direction)
|
||||
}
|
||||
end
|
||||
|
||||
Events.onAction += proc { |_sender, _e|
|
||||
next if $PokemonGlobal.surfing
|
||||
next if $game_map.metadata&.always_bicycle
|
||||
next if !$game_player.pbFacingTerrainTag.can_surf_freely
|
||||
next if !$game_map.passable?($game_player.x, $game_player.y, $game_player.direction, $game_player)
|
||||
pbSurf
|
||||
}
|
||||
EventHandlers.add(:on_player_interact, :start_surfing,
|
||||
proc {
|
||||
next if $PokemonGlobal.surfing
|
||||
next if $game_map.metadata&.always_bicycle
|
||||
next if !$game_player.pbFacingTerrainTag.can_surf_freely
|
||||
next if !$game_map.passable?($game_player.x, $game_player.y, $game_player.direction, $game_player)
|
||||
pbSurf
|
||||
}
|
||||
)
|
||||
|
||||
HiddenMoveHandlers::CanUseMove.add(:SURF, proc { |move, pkmn, showmsg|
|
||||
next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_SURF, showmsg)
|
||||
@@ -1001,14 +1007,16 @@ def pbWaterfall
|
||||
return false
|
||||
end
|
||||
|
||||
Events.onAction += proc { |_sender, _e|
|
||||
terrain = $game_player.pbFacingTerrainTag
|
||||
if terrain.waterfall
|
||||
pbWaterfall
|
||||
elsif terrain.waterfall_crest
|
||||
pbMessage(_INTL("A wall of water is crashing down with a mighty roar."))
|
||||
end
|
||||
}
|
||||
EventHandlers.add(:on_player_interact, :waterfall,
|
||||
proc {
|
||||
terrain = $game_player.pbFacingTerrainTag
|
||||
if terrain.waterfall
|
||||
pbWaterfall
|
||||
elsif terrain.waterfall_crest
|
||||
pbMessage(_INTL("A wall of water is crashing down with a mighty roar."))
|
||||
end
|
||||
}
|
||||
)
|
||||
|
||||
HiddenMoveHandlers::CanUseMove.add(:WATERFALL, proc { |move, pkmn, showmsg|
|
||||
next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_WATERFALL, showmsg)
|
||||
|
||||
@@ -290,16 +290,16 @@ end
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
Events.onSpritesetCreate += proc { |_sender, e|
|
||||
spriteset = e[0]
|
||||
viewport = e[1]
|
||||
map = spriteset.map
|
||||
map.events.each do |event|
|
||||
next if !event[1].name[/berryplant/i]
|
||||
spriteset.addUserSprite(BerryPlantMoistureSprite.new(event[1], map, viewport))
|
||||
spriteset.addUserSprite(BerryPlantSprite.new(event[1], map, viewport))
|
||||
end
|
||||
}
|
||||
EventHandlers.add(:on_new_spriteset_map, :add_berry_plant_graphics,
|
||||
proc { |spriteset, viewport|
|
||||
map = spriteset.map
|
||||
map.events.each do |event|
|
||||
next if !event[1].name[/berryplant/i]
|
||||
spriteset.addUserSprite(BerryPlantMoistureSprite.new(event[1], map, viewport))
|
||||
spriteset.addUserSprite(BerryPlantSprite.new(event[1], map, viewport))
|
||||
end
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
|
||||
@@ -557,9 +557,11 @@ end
|
||||
# With each step taken, add Exp to Pokémon in the Day Care and try to generate
|
||||
# an egg.
|
||||
#===============================================================================
|
||||
Events.onStepTaken += proc { |_sender, _e|
|
||||
$PokemonGlobal.day_care.update_on_step_taken
|
||||
}
|
||||
EventHandlers.add(:on_player_step_taken, :update_day_care,
|
||||
proc {
|
||||
$PokemonGlobal.day_care.update_on_step_taken
|
||||
}
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# Deprecated methods
|
||||
|
||||
@@ -643,27 +643,27 @@ module RandomDungeonGenerator
|
||||
end
|
||||
end
|
||||
|
||||
Events.onMapCreate += proc { |_sender, e|
|
||||
mapID = e[0]
|
||||
map = e[1]
|
||||
next if !GameData::MapMetadata.try_get(mapID)&.random_dungeon
|
||||
# this map is a randomly generated dungeon
|
||||
dungeon = RandomDungeonGenerator::Dungeon.new(map.width, map.height)
|
||||
dungeon.generate
|
||||
dungeon.generateMapInPlace(map)
|
||||
roomtiles = []
|
||||
# Reposition events
|
||||
map.events.values.each do |event|
|
||||
EventHandlers.add(:on_game_map_setup, :random_dungeon,
|
||||
proc { |map_id, map, _tileset_data|
|
||||
next if !GameData::MapMetadata.try_get(map_id)&.random_dungeon
|
||||
# this map is a randomly generated dungeon
|
||||
dungeon = RandomDungeonGenerator::Dungeon.new(map.width, map.height)
|
||||
dungeon.generate
|
||||
dungeon.generateMapInPlace(map)
|
||||
roomtiles = []
|
||||
# Reposition events
|
||||
map.events.values.each do |event|
|
||||
tile = RandomDungeonGenerator.pbRandomRoomTile(dungeon, roomtiles)
|
||||
if tile
|
||||
event.x = tile[0]
|
||||
event.y = tile[1]
|
||||
end
|
||||
end
|
||||
# Override transfer X and Y
|
||||
tile = RandomDungeonGenerator.pbRandomRoomTile(dungeon, roomtiles)
|
||||
if tile
|
||||
event.x = tile[0]
|
||||
event.y = tile[1]
|
||||
$game_temp.player_new_x = tile[0]
|
||||
$game_temp.player_new_y = tile[1]
|
||||
end
|
||||
end
|
||||
# Override transfer X and Y
|
||||
tile = RandomDungeonGenerator.pbRandomRoomTile(dungeon, roomtiles)
|
||||
if tile
|
||||
$game_temp.player_new_x = tile[0]
|
||||
$game_temp.player_new_y = tile[1]
|
||||
end
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user