mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-07-22 15:47:00 +00:00
Update 6.8
This commit is contained in:
@@ -4,25 +4,26 @@ class PokemonEncounters
|
||||
WEATHER_ENCOUNTER_BASE_CHANCE = 8 #/100 (for weather intensity of 0)
|
||||
alias pokemonEssentials_PokemonEncounter_choose_wild_pokemon choose_wild_pokemon
|
||||
ANIMATION_WEATHER_ENCOUNTER = 3
|
||||
|
||||
def choose_wild_pokemon(enc_type, *args)
|
||||
return pokemonEssentials_PokemonEncounter_choose_wild_pokemon(enc_type, *args) if !$game_weather
|
||||
current_weather_type = $game_weather.get_map_weather_type($game_map.map_id)
|
||||
current_weather_intensity = $game_weather.get_map_weather_intensity($game_map.map_id)
|
||||
if can_substitute_for_weather_encounter(enc_type, current_weather_type)
|
||||
#Chance to replace the chosen by one in from the weather pool
|
||||
# Chance to replace the chosen by one in from the weather pool
|
||||
if roll_for_weather_encounter(current_weather_intensity)
|
||||
weather_encounter_type = get_weather_encounter_type(enc_type,current_weather_type)
|
||||
weather_encounter_type = get_weather_encounter_type(enc_type, current_weather_type)
|
||||
echoln "weather encounter!"
|
||||
echoln weather_encounter_type
|
||||
return pokemonEssentials_PokemonEncounter_choose_wild_pokemon(weather_encounter_type) if(weather_encounter_type)
|
||||
$PokemonTemp.pokemon_is_weather_encounter = true
|
||||
return pokemonEssentials_PokemonEncounter_choose_wild_pokemon(weather_encounter_type) if (weather_encounter_type)
|
||||
end
|
||||
end
|
||||
return pokemonEssentials_PokemonEncounter_choose_wild_pokemon(enc_type, *args)
|
||||
end
|
||||
|
||||
SUBSTITUTABLE_ENCOUNTER_TYPES = [:LandDay, :LandNight, :LandMorning, :Land, :Land1, :Land2, :Land3, :TallGrass, :Water]
|
||||
|
||||
SUBSTITUTABLE_ENCOUNTER_TYPES = [:Land, :Land1, :Land2, :Land3, :Water]
|
||||
def can_substitute_for_weather_encounter(encounter_type,current_weather)
|
||||
def can_substitute_for_weather_encounter(encounter_type, current_weather)
|
||||
return false if Settings::GAME_ID != :IF_HOENN
|
||||
return false if !SUBSTITUTABLE_ENCOUNTER_TYPES.include?(encounter_type)
|
||||
return false if current_weather.nil? || current_weather == :None
|
||||
@@ -30,13 +31,21 @@ class PokemonEncounters
|
||||
end
|
||||
|
||||
def get_weather_encounter_type(normal_encounter_type, current_weather_type)
|
||||
base_encounter_type = normal_encounter_type == :Water ? :Water : :Land
|
||||
surf_encounters = [:Water, :WaterNight, :WaterMorning, :WaterDay]
|
||||
|
||||
base_encounter_type = surf_encounters.include?(normal_encounter_type) ? :Water : :Land
|
||||
weather_encounter_type = "#{base_encounter_type}#{current_weather_type}".to_sym
|
||||
return weather_encounter_type if GameData::EncounterType.exists?(weather_encounter_type)
|
||||
return nil
|
||||
end
|
||||
|
||||
#out of 100
|
||||
def weather_encounter_chance(weather_intensity)
|
||||
return (WEATHER_ENCOUNTER_BASE_CHANCE * weather_intensity) + WEATHER_ENCOUNTER_BASE_CHANCE
|
||||
end
|
||||
|
||||
def roll_for_weather_encounter(weather_intensity)
|
||||
weather_encounter_chance = (WEATHER_ENCOUNTER_BASE_CHANCE * weather_intensity)+WEATHER_ENCOUNTER_BASE_CHANCE
|
||||
weather_encounter_chance = weather_encounter_chance(weather_intensity)
|
||||
return rand(100) < weather_encounter_chance
|
||||
end
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ GameData::EncounterType.register({
|
||||
})
|
||||
|
||||
|
||||
|
||||
GameData::EncounterType.register({
|
||||
:id => :WaterStorm,
|
||||
:type => :none,
|
||||
@@ -72,5 +71,12 @@ GameData::EncounterType.register({
|
||||
:old_slots => [30,30,10,15,5,10],
|
||||
})
|
||||
|
||||
GameData::EncounterType.register({
|
||||
:id => :TallGrass,
|
||||
:type => :land,
|
||||
:old_slots => [30,30,10,15,5,10],
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
Events.onMapChange+= proc { |_old_map_id|
|
||||
next if !$game_weather || !$game_weather.current_weather || !$game_weather.last_update_time
|
||||
next if !$game_map
|
||||
new_map_id = $game_map.map_id
|
||||
mapMetadata = GameData::MapMetadata.try_get(new_map_id)
|
||||
if mapMetadata.nil? || !mapMetadata.outdoor_map
|
||||
next clear_current_map_weather
|
||||
end
|
||||
update_overworld_weather($game_map.map_id)
|
||||
next if $game_weather.last_update_time.to_i + GameWeather::TIME_BETWEEN_WEATHER_UPDATES > pbGetTimeNow.to_i
|
||||
echoln "- Updating the weather -"
|
||||
@@ -12,11 +17,17 @@ Events.onMapChange+= proc { |_old_map_id|
|
||||
$game_screen.weather(:None,0,0) if !mapMetadata.outdoor_map
|
||||
next unless mapMetadata.outdoor_map
|
||||
$game_weather.update_weather
|
||||
$game_map.refresh
|
||||
}
|
||||
|
||||
def clear_current_map_weather
|
||||
$game_screen.weather(:None,0,0)
|
||||
end
|
||||
|
||||
def update_overworld_weather(current_map)
|
||||
return if current_map.nil?
|
||||
return if !$game_weather.current_weather
|
||||
|
||||
current_weather_array = $game_weather.current_weather[current_map]
|
||||
return if current_weather_array.nil?
|
||||
current_weather_type = current_weather_array[0]
|
||||
@@ -24,5 +35,6 @@ def update_overworld_weather(current_map)
|
||||
current_weather_type = :None if !current_weather_type
|
||||
current_weather_intensity=0 if !current_weather_intensity
|
||||
current_weather_type = :None if PBDayNight.isNight? && current_weather_type == :Sunny
|
||||
|
||||
$game_screen.weather(current_weather_type,current_weather_intensity,0)
|
||||
end
|
||||
@@ -1,132 +0,0 @@
|
||||
class BetterRegionMap
|
||||
DEBUG_WEATHER = $DEBUG
|
||||
def update_weather_icon(location)
|
||||
return
|
||||
return nil if !location
|
||||
map_id = location[4]
|
||||
return nil if !map_id
|
||||
|
||||
weather_at_location = $game_weather.current_weather[map_id]
|
||||
return nil if weather_at_location.nil?
|
||||
|
||||
weather_type = weather_at_location[0]
|
||||
weather_intensity = weather_at_location[1]
|
||||
|
||||
icon = get_weather_icon(weather_type,weather_intensity)
|
||||
return nil if icon.nil?
|
||||
icon_path = "Graphics/Pictures/Weather/Cursor/" + icon
|
||||
|
||||
# @sprites["weather"].visible=true
|
||||
@sprites["cursor"].bmp(icon_path)
|
||||
@sprites["cursor"].src_rect.width = @sprites["cursor"].bmp.height
|
||||
return weather_type
|
||||
|
||||
end
|
||||
|
||||
|
||||
def draw_all_weather
|
||||
processed_locations =[]
|
||||
n=0
|
||||
for x in 0...(@window["map"].bmp.width / TileWidth)
|
||||
for y in 0...(@window["map"].bmp.height / TileHeight)
|
||||
|
||||
for location in @data[2]
|
||||
if location[0] == x && location[1] == y
|
||||
|
||||
map_id = location[4]
|
||||
|
||||
next if !map_id
|
||||
next if processed_locations.include?(map_id)
|
||||
|
||||
weather_at_location = $game_weather.current_weather[map_id]
|
||||
next if weather_at_location.nil?
|
||||
|
||||
weather_type = weather_at_location[0]
|
||||
weather_intensity = weather_at_location[1]
|
||||
|
||||
weather_icon = get_full_weather_icon_name(weather_type,weather_intensity)
|
||||
next if weather_icon.nil?
|
||||
weather_icon_path = "Graphics/Pictures/Weather/" + weather_icon
|
||||
@weatherIcons["weather#{n}"] = Sprite.new(@mapvp)
|
||||
@weatherIcons["weather#{n}"].bmp(weather_icon_path)
|
||||
@weatherIcons["weather#{n}"].src_rect.width = @weatherIcons["weather#{n}"].bmp.height
|
||||
@weatherIcons["weather#{n}"].x = TileWidth * x + (TileWidth / 2)
|
||||
@weatherIcons["weather#{n}"].y = TileHeight * y + (TileHeight / 2)
|
||||
@weatherIcons["weather#{n}"].oy = @weatherIcons["weather#{n}"].bmp.height / 2.0
|
||||
@weatherIcons["weather#{n}"].ox = @weatherIcons["weather#{n}"].oy
|
||||
|
||||
processed_locations << map_id
|
||||
n= n+1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def new_weather_cycle
|
||||
return if !$game_weather
|
||||
@weatherIcons.dispose
|
||||
@weatherIcons = SpriteHash.new
|
||||
$game_weather.update_weather
|
||||
draw_all_weather
|
||||
end
|
||||
|
||||
end
|
||||
def get_current_map_weather_icon
|
||||
return if !$game_weather
|
||||
current_weather= $game_weather.current_weather[$game_map.map_id]
|
||||
return if !current_weather
|
||||
weather_type = current_weather[0]
|
||||
weather_intensity = current_weather[1]
|
||||
icon = get_full_weather_icon_name(weather_type,weather_intensity)
|
||||
return "Graphics/Pictures/Weather/" +icon if icon
|
||||
return nil
|
||||
end
|
||||
|
||||
def get_weather_icon(weather_type,intensity)
|
||||
case weather_type
|
||||
when :Sunny #&& !PBDayNight.isNight?
|
||||
icon_name = "mapSun"
|
||||
when :Rain
|
||||
icon_name = "mapRain"
|
||||
when :Fog
|
||||
icon_name = "mapFog"
|
||||
when :Wind
|
||||
icon_name = "mapWind"
|
||||
when :Storm
|
||||
icon_name = "mapStorm"
|
||||
when :Sandstorm
|
||||
icon_name = "mapSand"
|
||||
when :Snow
|
||||
icon_name = "mapSnow"
|
||||
when :HeavyRain
|
||||
icon_name = "mapHeavyRain"
|
||||
when :StrongWinds
|
||||
icon_name = "mapStrongWinds"
|
||||
when :HarshSun
|
||||
icon_name = "mapHarshSun"
|
||||
else
|
||||
icon_name = nil
|
||||
end
|
||||
return icon_name
|
||||
end
|
||||
def get_full_weather_icon_name(weather_type,intensity)
|
||||
return nil if !weather_type
|
||||
return nil if !intensity
|
||||
same_intensity_weather_types = [:Sandstorm,:Snow,:StrongWinds,:HeavyRain,:HarshSun]
|
||||
|
||||
base_weather_icon_name = get_weather_icon(weather_type,intensity)
|
||||
icon_name = base_weather_icon_name
|
||||
return nil if !icon_name
|
||||
return icon_name if same_intensity_weather_types.include?(weather_type)
|
||||
if intensity <= 2
|
||||
icon_name += "_light"
|
||||
elsif intensity <=4
|
||||
icon_name += "_medium"
|
||||
else
|
||||
icon_name += "_heavy"
|
||||
end
|
||||
return icon_name
|
||||
end
|
||||
|
||||
@@ -6,27 +6,33 @@ def isRaining?()
|
||||
end
|
||||
|
||||
def isWeatherRain?()
|
||||
return true if GameData::Weather.get($game_screen.weather_type).category == :Rain
|
||||
return $game_weather.get_map_weather_type($game_map.map_id) == :Rain || $game_weather.get_map_weather_type($game_map.map_id) == :HeavyRain
|
||||
end
|
||||
|
||||
def isWeatherSunny?()
|
||||
return true if GameData::Weather.get($game_screen.weather_type).category == :Sunny
|
||||
return $game_weather.get_map_weather_type($game_map.map_id) == :Sunny || $game_weather.get_map_weather_type($game_map.map_id) == :HarshSun
|
||||
end
|
||||
|
||||
def isWeatherStorm?()
|
||||
return true if GameData::Weather.get($game_screen.weather_type).category == :Storm
|
||||
return $game_weather.get_map_weather_type($game_map.map_id) == :Storm
|
||||
end
|
||||
|
||||
def isWeatherWind?()
|
||||
return true if GameData::Weather.get($game_screen.weather_type).category == :Wind
|
||||
return $game_weather.get_map_weather_type($game_map.map_id) == :Wind || $game_weather.get_map_weather_type($game_map.map_id) == :StrongWinds
|
||||
end
|
||||
|
||||
def isWeatherFog?()
|
||||
return true if GameData::Weather.get($game_screen.weather_type).category == :Fog
|
||||
return $game_weather.get_map_weather_type($game_map.map_id) == :Fog
|
||||
end
|
||||
|
||||
def isWeatherSnow?()
|
||||
return $game_weather.get_map_weather_type($game_map.map_id) == :Fog
|
||||
return true if GameData::Weather.get($game_screen.weather_type).category == :Snow
|
||||
return $game_weather.get_map_weather_type($game_map.map_id) == :Snow
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class GameWeather
|
||||
CHANCE_OF_FOG = 30 #/100 Only possible in the morning, otherwise, when rain and sun combine
|
||||
|
||||
MAX_INTENSITY_ON_NEW_WEATHER = 4
|
||||
|
||||
MAX_WEATHER_INTENSITY = 10
|
||||
|
||||
CHANCES_OF_INTENSITY_INCREASE = 30 # /100
|
||||
CHANCES_OF_INTENSITY_DECREASE = 20 # /100
|
||||
@@ -40,13 +40,21 @@ class GameWeather
|
||||
BASE_CHANCES_OF_WEATHER_MOVE = 10
|
||||
DEBUG_PROPAGATION = false
|
||||
|
||||
COLD_MAPS = [444] # Rain is snow on that map (shoal cave)
|
||||
SNOW_LIMITS = [965,951] # Route 121, Pacifidlog - Snow turns to rain if it reaches these maps
|
||||
COLD_MAPS = [MAP_SHOAL_CAVE] # Rain is snow on that map (shoal cave)
|
||||
SNOW_LIMITS = [MAP_ROUTE_121,MAP_PACIFIDLOG] #Snow turns to rain if it reaches these maps
|
||||
SOOT_LIMITS = [MAP_ROUTE_113,MAP_FALLARBOR, MAP_ROUTE_111] #Can't let it propagate too much because then the grass would have to be covered in soot in those maps too....
|
||||
|
||||
SANDSTORM_MAPS = [MAP_DESERT] # Always sandstorm, doesn't spread
|
||||
NO_WIND_MAPS = [MAP_SOOTOPOLIS]
|
||||
NO_RAIN_MAPS = [MAP_MT_CHIMNEY,MAP_DESERT]
|
||||
|
||||
SANDSTORM_MAPS = [555] # Always sandstorm, doesn't spread
|
||||
SOOT_MAPS = [] # Always soot, doesn't spread
|
||||
NO_WIND_MAPS = [989] # Sootopolis, Petalburg Forest
|
||||
FREQUENT_WEATHER = [MAP_ROUTE_113,MAP_ROUTE_120] #More likely to spawn a new weather
|
||||
WINDY_MAPS = [MAP_MT_CHIMNEY,MAP_MT_PYRE] #More likely to be windy
|
||||
RAINY_MAPS = [MAP_ROUTE_113,MAP_ROUTE_119,MAP_ROUTE_120] #More likely to be raining,
|
||||
# 113 is in there because rain turns into soot there
|
||||
|
||||
SOOT_MAPS = [MAP_ROUTE_113]
|
||||
SOOT_CAUSES_MAPS = [MAP_MT_CHIMNEY] # When it's windy on Mt. Chimney, causes soot on soot maps
|
||||
|
||||
def set_weather(map_id, weather_type, intensity)
|
||||
@current_weather[map_id] = [weather_type, intensity]
|
||||
@@ -69,7 +77,7 @@ class GameWeather
|
||||
def initialize_weather
|
||||
weather = {}
|
||||
@neighbors_maps.keys.each { |map_id|
|
||||
weather[map_id] = select_new_weather_spawn
|
||||
weather[map_id] = select_new_weather_spawn(CHANCE_OF_NEW_WEATHER, map_id)
|
||||
}
|
||||
@current_weather = weather
|
||||
end
|
||||
@@ -78,6 +86,11 @@ class GameWeather
|
||||
@current_weather[map_id] = [weather_type,intensity]
|
||||
end
|
||||
|
||||
def get_current_map_weather
|
||||
map_id = $game_map.map_id
|
||||
return @current_weather[map_id]
|
||||
end
|
||||
|
||||
def get_map_weather_type(map_id)
|
||||
if !@current_weather[map_id]
|
||||
@current_weather[map_id] = [:None,0]
|
||||
@@ -109,13 +122,13 @@ class GameWeather
|
||||
new_weather = @current_weather.dup
|
||||
new_weather.each do |map_id, (type, intensity)|
|
||||
try_end_weather(map_id,type, get_map_weather_intensity(map_id))
|
||||
try_spawn_new_weather(map_id,type, intensity)
|
||||
try_spawn_new_weather(map_id,type)
|
||||
try_propagate_weather_to_neighbors(map_id,type, intensity)
|
||||
echoln @current_weather[954] if @debug_you
|
||||
try_move_weather_to_neighbors(map_id,type, intensity)
|
||||
try_weather_intensity_decrease(map_id,type, intensity)
|
||||
try_weather_intensity_increase(map_id,type, intensity)
|
||||
end
|
||||
apply_special_weather_interactions
|
||||
update_overworld_weather($game_map.map_id)
|
||||
@last_update_time = pbGetTimeNow
|
||||
end
|
||||
@@ -139,9 +152,11 @@ class GameWeather
|
||||
end
|
||||
end
|
||||
|
||||
def try_spawn_new_weather(map_id,map_weather_type,weather_intensity)
|
||||
def try_spawn_new_weather(map_id,map_weather_type,spawn_chance=nil)
|
||||
return if map_weather_type != :None
|
||||
new_weather = select_new_weather_spawn
|
||||
spawn_chance = CHANCE_OF_NEW_WEATHER unless spawn_chance
|
||||
spawn_chance*=2 if FREQUENT_WEATHER.include?(map_id)
|
||||
new_weather = select_new_weather_spawn(spawn_chance, map_id)
|
||||
@current_weather[map_id] = adjust_weather_for_map(new_weather,map_id)
|
||||
end
|
||||
|
||||
@@ -162,7 +177,7 @@ class GameWeather
|
||||
result_weather_type = resolve_weather_interaction(map_weather_type, neighbor_weather_type, weather_intensity, neighbor_weather_intensity)
|
||||
result_weather_intensity = weather_intensity
|
||||
new_weather = [result_weather_type,result_weather_intensity]
|
||||
@current_weather[neighbor_id] = adjust_weather_for_map(new_weather,map_id)
|
||||
@current_weather[neighbor_id] = adjust_weather_for_map(new_weather,neighbor_id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -178,7 +193,9 @@ class GameWeather
|
||||
return unless can_weather_increase(map_weather_type)
|
||||
should_change_intensity = roll_for_weather_increase(map_weather_type)
|
||||
return if !should_change_intensity
|
||||
new_weather = [map_weather_type,weather_intensity+1]
|
||||
new_intensity = [weather_intensity + 1, MAX_WEATHER_INTENSITY].min
|
||||
new_weather = [map_weather_type, new_intensity]
|
||||
|
||||
@current_weather[map_id] = adjust_weather_for_map(new_weather,map_id)
|
||||
end
|
||||
|
||||
@@ -196,6 +213,18 @@ class GameWeather
|
||||
@current_weather[map_id] = adjust_weather_for_map(new_weather,map_id)
|
||||
end
|
||||
|
||||
def apply_special_weather_interactions
|
||||
# Soot: wind on SOOT_CAUSES_MAPS blows ash onto SOOT_MAPS
|
||||
soot_wind_active = SOOT_CAUSES_MAPS.any? do |map_id|
|
||||
get_map_weather_type(map_id) == :Wind
|
||||
end
|
||||
if soot_wind_active
|
||||
SOOT_MAPS.each do |map_id|
|
||||
intensity = get_map_weather_intensity(map_id)
|
||||
@current_weather[map_id] = [:Ash, [1,intensity].max]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def adjust_weather_for_map(map_current_weather,map_id)
|
||||
type = map_current_weather[0]
|
||||
@@ -204,22 +233,29 @@ class GameWeather
|
||||
end
|
||||
|
||||
def get_updated_weather(type, intensity, map_id)
|
||||
if COLD_MAPS.include?(map_id)
|
||||
if COLD_MAPS.include?(map_id) || Settings::SNOW_DAY
|
||||
type = :Snow if type == :Rain
|
||||
type = :Blizzard if type == :Storm
|
||||
type = :None if type == :Sunny
|
||||
end
|
||||
if SNOW_LIMITS.include?(map_id)
|
||||
type = :Rain if type == :Snow
|
||||
type = :Wind if type == :Ash
|
||||
end
|
||||
|
||||
if SOOT_LIMITS.include?(map_id)
|
||||
type = :Rain if type == :Ash
|
||||
end
|
||||
|
||||
if SOOT_MAPS.include?(map_id)
|
||||
type = :SootRain if type == :Rain
|
||||
type = :Ash if type == :Rain
|
||||
end
|
||||
if NO_WIND_MAPS.include?(map_id)
|
||||
type = :None if type == :Wind
|
||||
end
|
||||
|
||||
if NO_RAIN_MAPS.include?(map_id)
|
||||
type = :None if type == :Rain
|
||||
end
|
||||
|
||||
if SANDSTORM_MAPS.include?(map_id)
|
||||
type = :Sandstorm
|
||||
intensity = 9
|
||||
@@ -228,6 +264,7 @@ class GameWeather
|
||||
type = :None
|
||||
intensity = 0
|
||||
end
|
||||
intensity = [intensity, MAX_WEATHER_INTENSITY].min
|
||||
return [type, intensity]
|
||||
end
|
||||
|
||||
@@ -337,7 +374,7 @@ class GameWeather
|
||||
end
|
||||
|
||||
def roll_for_weather_increase(type)
|
||||
return false if !can_weather_decrease(type)
|
||||
return false if !can_weather_increase(type)
|
||||
return rand(100) <= CHANCES_OF_INTENSITY_INCREASE
|
||||
end
|
||||
|
||||
@@ -346,16 +383,23 @@ class GameWeather
|
||||
return rand(100) <= CHANCES_OF_INTENSITY_DECREASE
|
||||
end
|
||||
|
||||
def select_new_weather_spawn
|
||||
return [:None, 0] if rand(100) >= CHANCE_OF_NEW_WEATHER
|
||||
|
||||
def select_new_weather_spawn(spawn_chance, map_id)
|
||||
return [:None, 0] if rand(100) >= spawn_chance
|
||||
base_intensity = rand(MAX_INTENSITY_ON_NEW_WEATHER) + 1
|
||||
|
||||
rain_chance = CHANCE_OF_RAIN
|
||||
sunny_chance = CHANCE_OF_SUNNY
|
||||
wind_chance = CHANCE_OF_WINDY
|
||||
fog_chance = CHANCE_OF_FOG
|
||||
|
||||
wind_chance*=3 if WINDY_MAPS.include?(map_id)
|
||||
rain_chance*=3 if RAINY_MAPS.include?(map_id)
|
||||
|
||||
weights = []
|
||||
weights << [:Rain, CHANCE_OF_RAIN]
|
||||
weights << [:Sunny, CHANCE_OF_SUNNY]
|
||||
weights << [:Wind, CHANCE_OF_WINDY]
|
||||
weights << [:Fog, CHANCE_OF_FOG] if PBDayNight.isMorning?
|
||||
weights << [:Rain, rain_chance]
|
||||
weights << [:Sunny, sunny_chance]
|
||||
weights << [:Wind, wind_chance]
|
||||
weights << [:Fog, fog_chance] if PBDayNight.isMorning?
|
||||
|
||||
total = weights.sum { |w| w[1] }
|
||||
roll = rand(total)
|
||||
|
||||
@@ -0,0 +1,309 @@
|
||||
class BetterRegionMap
|
||||
DEBUG_WEATHER = $DEBUG
|
||||
|
||||
def update_weather_text(location)
|
||||
return unless location
|
||||
selected_map = location[4]
|
||||
weather_at_location = $game_weather.current_weather[selected_map]
|
||||
if weather_at_location.nil?
|
||||
Kernel.pbClearText
|
||||
return
|
||||
end
|
||||
weather_type = weather_at_location[0]
|
||||
weather_intensity = weather_at_location[1]
|
||||
|
||||
weather_caption = get_weather_caption(weather_type,weather_intensity)
|
||||
intensity_text = get_weather_intensity_text(weather_type,weather_intensity,selected_map)
|
||||
|
||||
if weather_caption && intensity_text
|
||||
Kernel.pbClearText
|
||||
Kernel.pbDisplayText(weather_caption, 400,25,9999999, pbColor(:LIGHT_TEXT_MAIN_COLOR), pbColor(:LIGHT_TEXT_SHADOW_COLOR))
|
||||
Kernel.pbDisplayText(intensity_text, 400,50,9999999,pbColor(:LIGHT_TEXT_MAIN_COLOR), pbColor(:LIGHT_TEXT_SHADOW_COLOR))
|
||||
end
|
||||
echoln selected_map
|
||||
end
|
||||
|
||||
|
||||
#Captions need to be enumerated like this to allow for proper translations
|
||||
def get_weather_caption(weather_type, intensity)
|
||||
|
||||
case weather_type
|
||||
when :Sandstorm
|
||||
return _INTL("Sandstorm")
|
||||
when :Snow
|
||||
case intensity
|
||||
when -1..2
|
||||
return _INTL("Light Snow")
|
||||
when 3..4
|
||||
return _INTL("Heavy Snow")
|
||||
when 7..8
|
||||
return _INTL("Snowstorm")
|
||||
else # 9–10
|
||||
return _INTL("Blizzard")
|
||||
end
|
||||
when :StrongWinds
|
||||
return _INTL("Heavy Winds")
|
||||
when :HeavyRain
|
||||
return _INTL("Heavy Rain")
|
||||
when :HarshSun
|
||||
return _INTL("Drought")
|
||||
when :Sunny
|
||||
case intensity
|
||||
when -1..2
|
||||
return _INTL("Mild sunshine")
|
||||
when 3..4
|
||||
return _INTL("Warm sunshine")
|
||||
when 5..6
|
||||
return _INTL("Bright sunshine")
|
||||
when 7..8
|
||||
return _INTL("Hot sunshine")
|
||||
else # 9–10
|
||||
return _INTL("Scorching sun")
|
||||
end
|
||||
when :Rain
|
||||
case intensity
|
||||
when -1..2
|
||||
return _INTL("Light rain")
|
||||
when 3..4
|
||||
return _INTL("Moderate rain")
|
||||
when 5..6
|
||||
return _INTL("Heavy rain")
|
||||
when 7..8
|
||||
return _INTL("Severe rain")
|
||||
else # 9–10
|
||||
return _INTL("Extreme rain")
|
||||
end
|
||||
when :Fog
|
||||
case intensity
|
||||
when -1..2
|
||||
return _INTL("Thin fog")
|
||||
when 3..4
|
||||
return _INTL("Moderate fog")
|
||||
when 5..6
|
||||
return _INTL("Thick fog")
|
||||
when 7..8
|
||||
return _INTL("Dense fog")
|
||||
else # 9–10
|
||||
return _INTL("Very dense fog")
|
||||
end
|
||||
when :Wind
|
||||
case intensity
|
||||
when -1..2
|
||||
return _INTL("Light wind")
|
||||
when 3..4
|
||||
return _INTL("Moderate wind")
|
||||
when 5..6
|
||||
return _INTL("Strong wind")
|
||||
when 7..8
|
||||
return _INTL("High wind")
|
||||
else # 9–10
|
||||
return _INTL("Extreme wind")
|
||||
end
|
||||
when :Storm
|
||||
case intensity
|
||||
when -1..2
|
||||
return _INTL("Light thunderstorm")
|
||||
when 3..4
|
||||
return _INTL("Moderate thunderstorm")
|
||||
when 5..6
|
||||
return _INTL("Heavy thunderstorm")
|
||||
when 7..8
|
||||
return _INTL("Severe thunderstorm")
|
||||
else # 9–10
|
||||
return _INTL("Extreme thunderstorm")
|
||||
end
|
||||
when :Ash
|
||||
return _INTL("Volcanic Ash")
|
||||
end
|
||||
end
|
||||
|
||||
def get_weather_intensity_text(weather_type, weather_intensity,map_id)
|
||||
i = weather_intensity.clamp(1, 10)
|
||||
case weather_type
|
||||
when :Sandstorm
|
||||
value = 8 * i + 15
|
||||
return _INTL("{1} km/h", value)
|
||||
|
||||
when :Snow
|
||||
value = (0.5 * i).round(1)
|
||||
return _INTL("{1} cm/h", value)
|
||||
|
||||
when :StrongWinds
|
||||
value = 10 * i + 40
|
||||
return _INTL("{1} km/h", value)
|
||||
|
||||
when :HeavyRain
|
||||
value = 5 * i + 5
|
||||
return _INTL("{1} mm/h", value)
|
||||
|
||||
when :HarshSun
|
||||
value = 34 + (i * 1.4).round
|
||||
value -= 10 if GameWeather::COLD_MAPS.include?(map_id)
|
||||
value -= 10 if Settings::SNOW_DAY
|
||||
return _INTL("{1} °C", value)
|
||||
|
||||
when :Sunny
|
||||
value = 21 + (i * 1.4).round
|
||||
value -= 10 if GameWeather::COLD_MAPS.include?(map_id)
|
||||
value -= 10 if Settings::SNOW_DAY
|
||||
return _INTL("{1} °C", value)
|
||||
|
||||
when :Rain
|
||||
value = 2 * i
|
||||
return _INTL("{1} mm/h", value)
|
||||
|
||||
when :Ash
|
||||
value = (0.5 * i).round(1)
|
||||
return _INTL("{1} cm/h", value)
|
||||
|
||||
when :Fog
|
||||
value = 1100 - i * 100
|
||||
return _INTL("{1} m visibility", value)
|
||||
|
||||
when :Wind
|
||||
value = 7 * i + 8
|
||||
return _INTL("{1} km/h", value)
|
||||
|
||||
when :Storm
|
||||
value = 2 * i
|
||||
return _INTL("{1} mm/h", value)
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def weather_intensity_adjective(i, weather_type)
|
||||
case i
|
||||
when -1..2
|
||||
return _INTL("Mild") if weather_type == :Sunny
|
||||
return _INTL("Thin") if weather_type == :Fog
|
||||
return _INTL("Light")
|
||||
when 3..4
|
||||
return _INTL("Warm") if weather_type == :Sunny
|
||||
return _INTL("Moderate")
|
||||
when 5..6
|
||||
return _INTL("Bright") if weather_type == :Sunny
|
||||
return _INTL("Thick") if weather_type == :Fog
|
||||
return _INTL("Heavy")
|
||||
when 7..8
|
||||
return _INTL("Hot") if weather_type == :Sunny
|
||||
return _INTL("Dense") if weather_type == :Fog
|
||||
return _INTL("Severe")
|
||||
else # 9–10
|
||||
return _INTL("Scorching") if weather_type == :Sunny
|
||||
return _INTL("Very dense") if weather_type == :Fog
|
||||
return _INTL("Extreme")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def draw_all_weather
|
||||
processed_locations = []
|
||||
n = 0
|
||||
for x in 0...(@window["map"].bmp.width / TileWidth)
|
||||
for y in 0...(@window["map"].bmp.height / TileHeight)
|
||||
|
||||
for location in @data[2]
|
||||
if location[0] == x && location[1] == y
|
||||
|
||||
map_id = location[4]
|
||||
|
||||
next if !map_id
|
||||
next if processed_locations.include?(map_id)
|
||||
|
||||
weather_at_location = $game_weather.current_weather[map_id]
|
||||
next if weather_at_location.nil?
|
||||
|
||||
weather_type = weather_at_location[0]
|
||||
weather_intensity = weather_at_location[1]
|
||||
|
||||
weather_icon = get_full_weather_icon_name(weather_type, weather_intensity)
|
||||
next if weather_icon.nil?
|
||||
weather_icon_path = "Graphics/Pictures/Weather/" + weather_icon
|
||||
@weatherIcons["weather#{n}"] = Sprite.new(@mapvp)
|
||||
@weatherIcons["weather#{n}"].bmp(weather_icon_path)
|
||||
@weatherIcons["weather#{n}"].src_rect.width = @weatherIcons["weather#{n}"].bmp.height
|
||||
@weatherIcons["weather#{n}"].x = TileWidth * x + (TileWidth / 2)
|
||||
@weatherIcons["weather#{n}"].y = TileHeight * y + (TileHeight / 2)
|
||||
@weatherIcons["weather#{n}"].oy = @weatherIcons["weather#{n}"].bmp.height / 2.0
|
||||
@weatherIcons["weather#{n}"].ox = @weatherIcons["weather#{n}"].oy
|
||||
|
||||
processed_locations << map_id
|
||||
n = n + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new_weather_cycle
|
||||
return if !$game_weather
|
||||
@weatherIcons.dispose
|
||||
@weatherIcons = SpriteHash.new
|
||||
$game_weather.update_weather
|
||||
draw_all_weather
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def get_current_map_weather_icon
|
||||
return if !$game_weather
|
||||
current_weather = $game_weather.current_weather[$game_map.map_id]
|
||||
return if !current_weather
|
||||
weather_type = current_weather[0]
|
||||
weather_intensity = current_weather[1]
|
||||
icon = get_full_weather_icon_name(weather_type, weather_intensity)
|
||||
return "Graphics/Pictures/Weather/" + icon if icon
|
||||
return nil
|
||||
end
|
||||
|
||||
def get_weather_icon(weather_type, intensity)
|
||||
case weather_type
|
||||
when :Sunny #&& !PBDayNight.isNight?
|
||||
icon_name = "mapSun"
|
||||
when :Rain
|
||||
icon_name = "mapRain"
|
||||
when :Fog
|
||||
icon_name = "mapFog"
|
||||
when :Wind
|
||||
icon_name = "mapWind"
|
||||
when :Storm
|
||||
icon_name = "mapStorm"
|
||||
when :Sandstorm
|
||||
icon_name = "mapSand"
|
||||
when :Snow
|
||||
icon_name = "mapSnow"
|
||||
when :HeavyRain
|
||||
icon_name = "mapHeavyRain"
|
||||
when :StrongWinds
|
||||
icon_name = "mapStrongWinds"
|
||||
when :HarshSun
|
||||
icon_name = "mapHarshSun"
|
||||
when :Ash
|
||||
icon_name = "mapAsh"
|
||||
else
|
||||
icon_name = nil
|
||||
end
|
||||
return icon_name
|
||||
end
|
||||
|
||||
def get_full_weather_icon_name(weather_type, intensity)
|
||||
return nil if !weather_type
|
||||
return nil if !intensity
|
||||
same_intensity_weather_types = [:Sandstorm, :Snow, :StrongWinds, :HeavyRain, :HarshSun, :Ash]
|
||||
|
||||
base_weather_icon_name = get_weather_icon(weather_type, intensity)
|
||||
icon_name = base_weather_icon_name
|
||||
return nil if !icon_name
|
||||
return icon_name if same_intensity_weather_types.include?(weather_type)
|
||||
if intensity <= 2
|
||||
icon_name += "_light"
|
||||
elsif intensity <= 4
|
||||
icon_name += "_medium"
|
||||
else
|
||||
icon_name += "_heavy"
|
||||
end
|
||||
return icon_name
|
||||
end
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
class WeatherIcon
|
||||
def initialize
|
||||
@icon_path = get_current_weather_icon
|
||||
return if !@icon_path || !pbResolveBitmap(@icon_path)
|
||||
|
||||
@sprite = Sprite.new
|
||||
@sprite.bitmap = Bitmap.new(@icon_path)
|
||||
@sprite.x = Graphics.width - @sprite.bitmap.width - 12 # Right side of screen
|
||||
@sprite.y = -@sprite.bitmap.height # Start off-screen above
|
||||
@sprite.z = 99999
|
||||
@currentmap = $game_map.map_id
|
||||
@frames = 0
|
||||
end
|
||||
|
||||
def disposed?
|
||||
@sprite.nil? || @sprite.disposed?
|
||||
end
|
||||
|
||||
def dispose
|
||||
@sprite&.dispose
|
||||
end
|
||||
|
||||
def update
|
||||
return if disposed?
|
||||
if $game_temp.message_window_showing || @currentmap != $game_map.map_id
|
||||
dispose
|
||||
return
|
||||
end
|
||||
|
||||
# Slide down for 2 seconds, then slide back up
|
||||
if @frames > Graphics.frame_rate * 2
|
||||
@sprite.y -= 4
|
||||
dispose if @sprite.y + @sprite.bitmap.height < 0
|
||||
else
|
||||
@sprite.y += 4 if @sprite.y < 0
|
||||
@frames += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_current_weather_icon
|
||||
return if !$game_weather
|
||||
current_weather = $game_weather.current_weather[$game_map.map_id]
|
||||
return if !current_weather
|
||||
weather_type = current_weather[0]
|
||||
weather_intensity = current_weather[1]
|
||||
icon = get_full_weather_icon_name(weather_type, weather_intensity)
|
||||
return nil if !icon
|
||||
return "Graphics/Pictures/Weather/" + icon
|
||||
end
|
||||
Reference in New Issue
Block a user