mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +00:00
Added class GameData::Weather
This commit is contained in:
@@ -81,7 +81,7 @@ class Game_Screen
|
||||
# duration : time
|
||||
#-----------------------------------------------------------------------------
|
||||
def weather(type, power, duration)
|
||||
@weather_type = type
|
||||
@weather_type = GameData::Weather.get(type).id
|
||||
@weather_max = (power + 1) * RPG::Weather::MAX_SPRITES / 10
|
||||
@weather_duration = duration # In 1/20ths of a seconds
|
||||
end
|
||||
|
||||
@@ -143,7 +143,7 @@ class Spriteset_Map
|
||||
sprite.update
|
||||
end
|
||||
if self.map!=$game_map
|
||||
@weather.fade_in(PBFieldWeather::None, 0, 20)
|
||||
@weather.fade_in(:None, 0, 20)
|
||||
else
|
||||
@weather.fade_in($game_screen.weather_type, $game_screen.weather_max, $game_screen.weather_duration)
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@ module GameData
|
||||
"Bicycle" => [3, "b"],
|
||||
"BicycleAlways" => [4, "b"],
|
||||
"HealingSpot" => [5, "vuu"],
|
||||
"Weather" => [6, "eu", :PBFieldWeather],
|
||||
"Weather" => [6, "eu", :Weather],
|
||||
"MapPosition" => [7, "uuu"],
|
||||
"DiveMap" => [8, "v"],
|
||||
"DarkMap" => [9, "b"],
|
||||
|
||||
@@ -1,20 +1,163 @@
|
||||
begin
|
||||
module PBFieldWeather
|
||||
None = 0 # None must be 0 (preset RMXP weather)
|
||||
Rain = 1 # Rain must be 1 (preset RMXP weather)
|
||||
Storm = 2 # Storm must be 2 (preset RMXP weather)
|
||||
Snow = 3 # Snow must be 3 (preset RMXP weather)
|
||||
Blizzard = 4
|
||||
Sandstorm = 5
|
||||
HeavyRain = 6
|
||||
Sun = Sunny = 7
|
||||
Fog = 8
|
||||
# Category has the following effects:
|
||||
# - Determines the in-battle weather.
|
||||
# - Some abilities reduce the encounter rate in certain categories of weather.
|
||||
# - Some evolution methods check the current weather's category.
|
||||
# - The :Rain category treats the last listed particle graphic as a water splash rather
|
||||
# than a raindrop, which behaves differently.
|
||||
# - :Rain auto-waters berry plants.
|
||||
# Delta values are per second.
|
||||
# For the tone_proc, strength goes from 0 to RPG::Weather::MAX_SPRITES (60) and
|
||||
# will typically be the maximum.
|
||||
module GameData
|
||||
class Weather
|
||||
attr_reader :id
|
||||
attr_reader :id_number
|
||||
attr_reader :real_name
|
||||
attr_reader :category # :None, :Rain, :Hail, :Sandstorm, :Sun, :Fog
|
||||
attr_reader :graphics # [[particle file names], [tile file names]]
|
||||
attr_reader :particle_delta_x
|
||||
attr_reader :particle_delta_y
|
||||
attr_reader :particle_delta_opacity
|
||||
attr_reader :tile_delta_x
|
||||
attr_reader :tile_delta_y
|
||||
attr_reader :tone_proc
|
||||
|
||||
def PBFieldWeather.maxValue; return 8; end
|
||||
DATA = {}
|
||||
|
||||
extend ClassMethods
|
||||
include InstanceMethods
|
||||
|
||||
def self.load; end
|
||||
def self.save; end
|
||||
|
||||
def initialize(hash)
|
||||
@id = hash[:id]
|
||||
@id_number = hash[:id_number]
|
||||
@real_name = hash[:id].to_s || "Unnamed"
|
||||
@category = hash[:category] || :None
|
||||
@particle_delta_x = hash[:particle_delta_x] || 0
|
||||
@particle_delta_y = hash[:particle_delta_y] || 0
|
||||
@particle_delta_opacity = hash[:particle_delta_opacity] || 0
|
||||
@tile_delta_x = hash[:tile_delta_x] || 0
|
||||
@tile_delta_y = hash[:tile_delta_y] || 0
|
||||
@graphics = hash[:graphics] || []
|
||||
@tone_proc = hash[:tone_proc]
|
||||
end
|
||||
|
||||
rescue Exception
|
||||
if $!.is_a?(SystemExit) || "#{$!.class}"=="Reset"
|
||||
raise $!
|
||||
def has_particles?
|
||||
return @graphics[0] && @graphics[0].length > 0
|
||||
end
|
||||
|
||||
def has_tiles?
|
||||
return @graphics[1] && @graphics[1].length > 0
|
||||
end
|
||||
|
||||
def tone(strength)
|
||||
return (@tone_proc) ? @tone_proc.call(strength) : Tone.new(0, 0, 0, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
|
||||
GameData::Weather.register({
|
||||
:id => :None,
|
||||
:id_number => 0 # Must be 0 (preset RMXP weather)
|
||||
})
|
||||
|
||||
GameData::Weather.register({
|
||||
:id => :Rain,
|
||||
:id_number => 1, # Must be 1 (preset RMXP weather)
|
||||
:category => :Rain,
|
||||
:graphics => [["rain_1", "rain_2", "rain_3", "rain_4"]], # Last is splash
|
||||
:particle_delta_x => -1200,
|
||||
:particle_delta_y => 4800,
|
||||
:tone_proc => proc { |strength|
|
||||
next Tone.new(-strength * 3 / 4, -strength * 3 / 4, -strength * 3 / 4, 10)
|
||||
}
|
||||
})
|
||||
|
||||
# NOTE: This randomly flashes the screen in RPG::Weather#update.
|
||||
GameData::Weather.register({
|
||||
:id => :Storm,
|
||||
:id_number => 2, # Must be 2 (preset RMXP weather)
|
||||
:category => :Rain,
|
||||
:graphics => [["storm_1", "storm_2", "storm_3", "storm_4"]], # Last is splash
|
||||
:particle_delta_x => -4800,
|
||||
:particle_delta_y => 4800,
|
||||
:tone_proc => proc { |strength|
|
||||
next Tone.new(-strength * 3 / 2, -strength * 3 / 2, -strength * 3 / 2, 20)
|
||||
}
|
||||
})
|
||||
|
||||
# NOTE: This alters the movement of snow particles in RPG::Weather#update_sprite_position.
|
||||
GameData::Weather.register({
|
||||
:id => :Snow,
|
||||
:id_number => 3, # Must be 3 (preset RMXP weather)
|
||||
:category => :Hail,
|
||||
:graphics => [["hail_1", "hail_2", "hail_3"]],
|
||||
:particle_delta_x => -240,
|
||||
:particle_delta_y => 240,
|
||||
:tone_proc => proc { |strength|
|
||||
next Tone.new(strength / 2, strength / 2, strength / 2, 0)
|
||||
}
|
||||
})
|
||||
|
||||
GameData::Weather.register({
|
||||
:id => :Blizzard,
|
||||
:id_number => 4,
|
||||
:category => :Hail,
|
||||
:graphics => [["blizzard_1", "blizzard_2", "blizzard_3", "blizzard_4"], ["blizzard_tile"]],
|
||||
:particle_delta_x => -960,
|
||||
:particle_delta_y => 240,
|
||||
:tile_delta_x => -1440,
|
||||
:tile_delta_y => 720,
|
||||
:tone_proc => proc { |strength|
|
||||
next Tone.new(strength * 3 / 4, strength * 3 / 4, strength * 3 / 4, 0)
|
||||
}
|
||||
})
|
||||
|
||||
GameData::Weather.register({
|
||||
:id => :Sandstorm,
|
||||
:id_number => 5,
|
||||
:category => :Sandstorm,
|
||||
:graphics => [["sandstorm_1", "sandstorm_2", "sandstorm_3", "sandstorm_4"], ["sandstorm_tile"]],
|
||||
:particle_delta_x => -1200,
|
||||
:particle_delta_y => 640,
|
||||
:tile_delta_x => -720,
|
||||
:tile_delta_y => 360,
|
||||
:tone_proc => proc { |strength|
|
||||
next Tone.new(strength / 2, 0, -strength / 2, 0)
|
||||
}
|
||||
})
|
||||
|
||||
GameData::Weather.register({
|
||||
:id => :HeavyRain,
|
||||
:id_number => 6,
|
||||
:category => :Rain,
|
||||
:graphics => [["storm_1", "storm_2", "storm_3", "storm_4"]], # Last is splash
|
||||
:particle_delta_x => -4800,
|
||||
:particle_delta_y => 4800,
|
||||
:tone_proc => proc { |strength|
|
||||
next Tone.new(-strength * 3 / 2, -strength * 3 / 2, -strength * 3 / 2, 20)
|
||||
}
|
||||
})
|
||||
|
||||
# NOTE: This alters the screen tone in RPG::Weather#update_screen_tone.
|
||||
GameData::Weather.register({
|
||||
:id => :Sun,
|
||||
:id_number => 7,
|
||||
:category => :Sun,
|
||||
:tone_proc => proc { |strength|
|
||||
next Tone.new(64, 64, 32, 0)
|
||||
}
|
||||
})
|
||||
|
||||
GameData::Weather.register({
|
||||
:id => :Fog,
|
||||
:category => :Fog,
|
||||
:id_number => 8,
|
||||
:tile_delta_x => -32,
|
||||
:tile_delta_y => 0,
|
||||
:graphics => [nil, ["fog_tile"]]
|
||||
})
|
||||
|
||||
@@ -121,7 +121,7 @@ GameData::Evolution.register({
|
||||
:parameter => Integer,
|
||||
:level_up_proc => proc { |pkmn, parameter|
|
||||
if pkmn.level >= parameter && $game_screen
|
||||
next $game_screen.weather_type == PBFieldWeather::None
|
||||
next $game_screen.weather_type == :None
|
||||
end
|
||||
}
|
||||
})
|
||||
@@ -131,7 +131,7 @@ GameData::Evolution.register({
|
||||
:parameter => Integer,
|
||||
:level_up_proc => proc { |pkmn, parameter|
|
||||
if pkmn.level >= parameter && $game_screen
|
||||
next $game_screen.weather_type == PBFieldWeather::Sun
|
||||
next GameData::Weather.get($game_screen.weather_type).category == :Sun
|
||||
end
|
||||
}
|
||||
})
|
||||
@@ -141,8 +141,7 @@ GameData::Evolution.register({
|
||||
:parameter => Integer,
|
||||
:level_up_proc => proc { |pkmn, parameter|
|
||||
if pkmn.level >= parameter && $game_screen
|
||||
next [PBFieldWeather::Rain, PBFieldWeather::HeavyRain,
|
||||
PBFieldWeather::Storm, PBFieldWeather::Fog].include?($game_screen.weather_type)
|
||||
next [:Rain, :Fog].include?(GameData::Weather.get($game_screen.weather_type).category)
|
||||
end
|
||||
}
|
||||
})
|
||||
@@ -152,7 +151,7 @@ GameData::Evolution.register({
|
||||
:parameter => Integer,
|
||||
:level_up_proc => proc { |pkmn, parameter|
|
||||
if pkmn.level >= parameter && $game_screen
|
||||
next [PBFieldWeather::Snow, PBFieldWeather::Blizzard].include?($game_screen.weather_type)
|
||||
next GameData::Weather.get($game_screen.weather_type).category == :Hail
|
||||
end
|
||||
}
|
||||
})
|
||||
@@ -162,7 +161,7 @@ GameData::Evolution.register({
|
||||
:parameter => Integer,
|
||||
:level_up_proc => proc { |pkmn, parameter|
|
||||
if pkmn.level >= parameter && $game_screen
|
||||
next $game_screen.weather_type == PBFieldWeather::Sandstorm
|
||||
next GameData::Weather.get($game_screen.weather_type).category == :Sandstorm
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
@@ -410,7 +410,7 @@ Events.onMapChanging += proc { |_sender, e|
|
||||
new_map_metadata = GameData::MapMetadata.try_get(new_map_ID)
|
||||
next if new_map_metadata && new_map_metadata.weather
|
||||
end
|
||||
$game_screen.weather(PBFieldWeather::None, 0, 0)
|
||||
$game_screen.weather(:None, 0, 0)
|
||||
}
|
||||
|
||||
# Set up various data related to the new map
|
||||
|
||||
@@ -28,17 +28,8 @@ module RPG
|
||||
# [array of particle bitmaps, array of tile bitmaps,
|
||||
# +x per second (particle), +y per second (particle), +opacity per second (particle),
|
||||
# +x per second (tile), +y per second (tile)]
|
||||
@weatherTypes = []
|
||||
@weatherTypes[PBFieldWeather::None] = nil
|
||||
@weatherTypes[PBFieldWeather::Rain] = [[], nil, -1200, 4800, 0]
|
||||
@weatherTypes[PBFieldWeather::HeavyRain] = [[], nil, -4800, 4800, 0]
|
||||
@weatherTypes[PBFieldWeather::Storm] = [[], nil, -4800, 4800, 0]
|
||||
@weatherTypes[PBFieldWeather::Snow] = [[], nil, -240, 240, 0]
|
||||
@weatherTypes[PBFieldWeather::Blizzard] = [[], [], -960, 256, 0, -1440, 720]
|
||||
@weatherTypes[PBFieldWeather::Sandstorm] = [[], [], -1200, 640, 0, -720, 360]
|
||||
@weatherTypes[PBFieldWeather::Sun] = nil
|
||||
@weatherTypes[PBFieldWeather::Fog] = [[], [], 0, 0, 0, -32, 0]
|
||||
@type = 0
|
||||
@weatherTypes = {}
|
||||
@type = :None
|
||||
@max = 0
|
||||
@ox = 0
|
||||
@oy = 0
|
||||
@@ -62,16 +53,17 @@ module RPG
|
||||
@new_sprites.each { |sprite| sprite.dispose if sprite }
|
||||
@tiles.each { |sprite| sprite.dispose if sprite }
|
||||
@viewport.dispose
|
||||
@weatherTypes.each do |weather|
|
||||
@weatherTypes.each_value do |weather|
|
||||
next if !weather
|
||||
weather[0].each { |bitmap| bitmap.dispose if bitmap }
|
||||
weather[1].each { |bitmap| bitmap.dispose if bitmap } if weather[1]
|
||||
weather[1].each { |bitmap| bitmap.dispose if bitmap }
|
||||
weather[2].each { |bitmap| bitmap.dispose if bitmap }
|
||||
end
|
||||
end
|
||||
|
||||
def fade_in(new_type, new_max, duration = 1)
|
||||
return if @fading
|
||||
new_max = 0 if new_type == PBFieldWeather::None
|
||||
new_type = GameData::Weather.get(new_type).id
|
||||
new_max = 0 if new_type == :None
|
||||
return if @type == new_type && @max == new_max
|
||||
if duration > 0
|
||||
@target_type = new_type
|
||||
@@ -84,9 +76,9 @@ module RPG
|
||||
@target_tone = get_weather_tone(@target_type, @target_max)
|
||||
@fade_time = 0.0
|
||||
@time_shift = 0
|
||||
if @type == PBFieldWeather::None
|
||||
if @type == :None
|
||||
@time_shift += 2 # No previous weather to fade out first
|
||||
elsif !@weatherTypes[@type] || !@weatherTypes[@type][1] || @weatherTypes[@type][1].length == 0
|
||||
elsif !GameData::Weather.get(@type).has_tiles?
|
||||
@time_shift += 1 # No previous tiles to fade out first
|
||||
end
|
||||
@fading = true
|
||||
@@ -101,6 +93,7 @@ module RPG
|
||||
end
|
||||
|
||||
def type=(type)
|
||||
type = GameData::Weather.get(type).id
|
||||
return if @type == type
|
||||
if @fading
|
||||
@max = @target_max
|
||||
@@ -108,9 +101,9 @@ module RPG
|
||||
end
|
||||
@type = type
|
||||
prepare_bitmaps(@type)
|
||||
if @weatherTypes[@type] && @weatherTypes[@type][1] && @weatherTypes[@type][1].length > 0
|
||||
w = @weatherTypes[@type][1][0].width
|
||||
h = @weatherTypes[@type][1][0].height
|
||||
if GameData::Weather.get(@type).has_tiles?
|
||||
w = @weatherTypes[@type][2][0].width
|
||||
h = @weatherTypes[@type][2][0].height
|
||||
@tiles_wide = (Graphics.width.to_f / w).ceil + 1
|
||||
@tiles_tall = (Graphics.height.to_f / h).ceil + 1
|
||||
else
|
||||
@@ -148,88 +141,24 @@ module RPG
|
||||
end
|
||||
|
||||
def get_weather_tone(weather_type, maximum)
|
||||
case weather_type
|
||||
when PBFieldWeather::Rain
|
||||
return Tone.new(-maximum * 3 / 4, -maximum * 3 / 4, -maximum * 3 / 4, 10)
|
||||
when PBFieldWeather::HeavyRain
|
||||
return Tone.new(-maximum * 6 / 4, -maximum * 6 / 4, -maximum * 6 / 4, 20)
|
||||
when PBFieldWeather::Storm
|
||||
return Tone.new(-maximum * 6 / 4, -maximum * 6 / 4, -maximum * 6 / 4, 20)
|
||||
when PBFieldWeather::Snow
|
||||
return Tone.new( maximum / 2, maximum / 2, maximum / 2, 0)
|
||||
when PBFieldWeather::Blizzard
|
||||
return Tone.new( maximum * 3 / 4, maximum * 3 / 4, maximum * 3 / 4, 0)
|
||||
when PBFieldWeather::Sandstorm
|
||||
return Tone.new( maximum / 2, 0, -maximum / 2, 0)
|
||||
when PBFieldWeather::Sun
|
||||
return Tone.new(64, 64, 32, 0)
|
||||
end
|
||||
return Tone.new(0, 0, 0, 0)
|
||||
return GameData::Weather.get(weather_type).tone(maximum)
|
||||
end
|
||||
|
||||
def prepare_bitmaps(new_type)
|
||||
case new_type
|
||||
when PBFieldWeather::Rain then prepareRainBitmaps
|
||||
when PBFieldWeather::HeavyRain, PBFieldWeather::Storm then prepareStormBitmaps
|
||||
when PBFieldWeather::Snow then prepareSnowBitmaps
|
||||
when PBFieldWeather::Blizzard then prepareBlizzardBitmaps
|
||||
when PBFieldWeather::Sandstorm then prepareSandstormBitmaps
|
||||
when PBFieldWeather::Fog then prepareFogBitmaps
|
||||
weather_data = GameData::Weather.get(new_type)
|
||||
bitmap_names = weather_data.graphics
|
||||
@weatherTypes[new_type] = [weather_data, [], []]
|
||||
for i in 0...2 # 0=particles, 1=tiles
|
||||
next if !bitmap_names[i]
|
||||
bitmap_names[i].each do |name|
|
||||
bitmap = RPG::Cache.load_bitmap("Graphics/Weather/", name)
|
||||
@weatherTypes[new_type][i + 1].push(bitmap)
|
||||
end
|
||||
end
|
||||
|
||||
def prepareRainBitmaps
|
||||
rain1 = RPG::Cache.load_bitmap("Graphics/Weather/", "rain_1")
|
||||
rain2 = RPG::Cache.load_bitmap("Graphics/Weather/", "rain_2")
|
||||
rain3 = RPG::Cache.load_bitmap("Graphics/Weather/", "rain_3")
|
||||
rain4 = RPG::Cache.load_bitmap("Graphics/Weather/", "rain_4") # Splash
|
||||
@weatherTypes[PBFieldWeather::Rain][0] = [rain1, rain2, rain3, rain4]
|
||||
end
|
||||
|
||||
def prepareStormBitmaps
|
||||
storm1 = RPG::Cache.load_bitmap("Graphics/Weather/", "storm_1")
|
||||
storm2 = RPG::Cache.load_bitmap("Graphics/Weather/", "storm_2")
|
||||
storm3 = RPG::Cache.load_bitmap("Graphics/Weather/", "storm_3")
|
||||
storm4 = RPG::Cache.load_bitmap("Graphics/Weather/", "storm_4") # Splash
|
||||
@weatherTypes[PBFieldWeather::HeavyRain][0] = [storm1, storm2, storm3, storm4]
|
||||
@weatherTypes[PBFieldWeather::Storm][0] = [storm1, storm2, storm3, storm4]
|
||||
end
|
||||
|
||||
def prepareSnowBitmaps
|
||||
hail1 = RPG::Cache.load_bitmap("Graphics/Weather/", "hail_1")
|
||||
hail2 = RPG::Cache.load_bitmap("Graphics/Weather/", "hail_2")
|
||||
hail3 = RPG::Cache.load_bitmap("Graphics/Weather/", "hail_3")
|
||||
@weatherTypes[PBFieldWeather::Snow][0] = [hail1, hail2, hail3]
|
||||
end
|
||||
|
||||
def prepareBlizzardBitmaps
|
||||
blizzard1 = RPG::Cache.load_bitmap("Graphics/Weather/", "blizzard_1")
|
||||
blizzard2 = RPG::Cache.load_bitmap("Graphics/Weather/", "blizzard_2")
|
||||
blizzard3 = RPG::Cache.load_bitmap("Graphics/Weather/", "blizzard_3")
|
||||
blizzard4 = RPG::Cache.load_bitmap("Graphics/Weather/", "blizzard_4")
|
||||
@weatherTypes[PBFieldWeather::Blizzard][0] = [blizzard1, blizzard2, blizzard3, blizzard4]
|
||||
blizzard_tile = RPG::Cache.load_bitmap("Graphics/Weather/", "blizzard_tile")
|
||||
@weatherTypes[PBFieldWeather::Blizzard][1] = [blizzard_tile]
|
||||
end
|
||||
|
||||
def prepareSandstormBitmaps
|
||||
sandstorm1 = RPG::Cache.load_bitmap("Graphics/Weather/", "sandstorm_1")
|
||||
sandstorm2 = RPG::Cache.load_bitmap("Graphics/Weather/", "sandstorm_2")
|
||||
sandstorm3 = RPG::Cache.load_bitmap("Graphics/Weather/", "sandstorm_3")
|
||||
sandstorm4 = RPG::Cache.load_bitmap("Graphics/Weather/", "sandstorm_4")
|
||||
@weatherTypes[PBFieldWeather::Sandstorm][0] = [sandstorm1, sandstorm2, sandstorm3, sandstorm4]
|
||||
sandstorm_tile = RPG::Cache.load_bitmap("Graphics/Weather/", "sandstorm_tile")
|
||||
@weatherTypes[PBFieldWeather::Sandstorm][1] = [sandstorm_tile]
|
||||
end
|
||||
|
||||
def prepareFogBitmaps
|
||||
fog_tile = RPG::Cache.load_bitmap("Graphics/Weather/", "fog_tile")
|
||||
@weatherTypes[PBFieldWeather::Fog][1] = [fog_tile]
|
||||
end
|
||||
|
||||
def ensureSprites
|
||||
if @sprites.length < MAX_SPRITES && @weatherTypes[@type] &&
|
||||
@weatherTypes[@type][0] && @weatherTypes[@type][0].length > 0
|
||||
if @sprites.length < MAX_SPRITES && @weatherTypes[@type] && @weatherTypes[@type][1].length > 0
|
||||
for i in 0...MAX_SPRITES
|
||||
if !@sprites[i]
|
||||
sprite = Sprite.new(@origViewport)
|
||||
@@ -244,7 +173,7 @@ module RPG
|
||||
end
|
||||
end
|
||||
if @fading && @new_sprites.length < MAX_SPRITES && @weatherTypes[@target_type] &&
|
||||
@weatherTypes[@target_type][0] && @weatherTypes[@target_type][0].length > 0
|
||||
@weatherTypes[@target_type][1].length > 0
|
||||
for i in 0...MAX_SPRITES
|
||||
if !@new_sprites[i]
|
||||
sprite = Sprite.new(@origViewport)
|
||||
@@ -277,14 +206,13 @@ module RPG
|
||||
|
||||
def set_sprite_bitmap(sprite, index, weather_type)
|
||||
return if !sprite
|
||||
weatherBitmaps = (@weatherTypes[weather_type]) ? @weatherTypes[weather_type][0] : nil
|
||||
weatherBitmaps = (@weatherTypes[weather_type]) ? @weatherTypes[weather_type][1] : nil
|
||||
if !weatherBitmaps || weatherBitmaps.length == 0
|
||||
sprite.bitmap = nil
|
||||
return
|
||||
end
|
||||
case weather_type
|
||||
when PBFieldWeather::Rain, PBFieldWeather::HeavyRain, PBFieldWeather::Storm
|
||||
last_index = weatherBitmaps.length - 1 # Last sprite is splash
|
||||
if @weatherTypes[weather_type][0].category == :Rain
|
||||
last_index = weatherBitmaps.length - 1 # Last sprite is a splash
|
||||
if (index % 2) == 0
|
||||
sprite.bitmap = weatherBitmaps[index % last_index]
|
||||
else
|
||||
@@ -297,7 +225,7 @@ module RPG
|
||||
|
||||
def set_tile_bitmap(sprite, index, weather_type)
|
||||
return if !sprite || !weather_type
|
||||
weatherBitmaps = (@weatherTypes[weather_type]) ? @weatherTypes[weather_type][1] : nil
|
||||
weatherBitmaps = (@weatherTypes[weather_type]) ? @weatherTypes[weather_type][2] : nil
|
||||
if weatherBitmaps && weatherBitmaps.length > 0
|
||||
sprite.bitmap = weatherBitmaps[index % weatherBitmaps.length]
|
||||
else
|
||||
@@ -315,25 +243,26 @@ module RPG
|
||||
lifetimes[index] = 0
|
||||
return
|
||||
end
|
||||
if [PBFieldWeather::Rain, PBFieldWeather::HeavyRain,
|
||||
PBFieldWeather::Storm].include?(weather_type) && (index % 2) != 0 # Splash
|
||||
if @weatherTypes[weather_type][0].category == :Rain && (index % 2) != 0 # Splash
|
||||
sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + sprite.bitmap.width * 2)
|
||||
sprite.y = @oy - sprite.bitmap.height + rand(Graphics.height + sprite.bitmap.height * 2)
|
||||
lifetimes[index] = (30 + rand(20)) * 0.01 # 0.3-0.5 seconds
|
||||
else
|
||||
gradient = @weatherTypes[weather_type][2].to_f / @weatherTypes[weather_type][3]
|
||||
x_speed = @weatherTypes[weather_type][0].particle_delta_x
|
||||
y_speed = @weatherTypes[weather_type][0].particle_delta_y
|
||||
gradient = x_speed.to_f / y_speed
|
||||
if gradient.abs >= 1
|
||||
# Position sprite to the right of the screen
|
||||
sprite.x = @ox + Graphics.width + rand(Graphics.width)
|
||||
sprite.y = @oy + Graphics.height - rand(Graphics.height + sprite.bitmap.height - Graphics.width / gradient)
|
||||
distance_to_cover = sprite.x - @ox - Graphics.width / 2 + sprite.bitmap.width + rand(Graphics.width * 8 / 5)
|
||||
lifetimes[index] = (distance_to_cover.to_f / @weatherTypes[weather_type][2]).abs
|
||||
lifetimes[index] = (distance_to_cover.to_f / x_speed).abs
|
||||
else
|
||||
# Position sprite to the top of the screen
|
||||
sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + sprite.bitmap.width - gradient * Graphics.height)
|
||||
sprite.y = @oy - sprite.bitmap.height - rand(Graphics.height)
|
||||
distance_to_cover = @oy - sprite.y + Graphics.height / 2 + rand(Graphics.height * 8 / 5)
|
||||
lifetimes[index] = (distance_to_cover.to_f / @weatherTypes[weather_type][3]).abs
|
||||
lifetimes[index] = (distance_to_cover.to_f / y_speed).abs
|
||||
end
|
||||
end
|
||||
sprite.opacity = 255
|
||||
@@ -353,20 +282,19 @@ module RPG
|
||||
# Determine which weather type this sprite is representing
|
||||
weather_type = (is_new_sprite) ? @target_type : @type
|
||||
# Update visibility/position/opacity of sprite
|
||||
if [PBFieldWeather::Rain, PBFieldWeather::HeavyRain,
|
||||
PBFieldWeather::Storm].include?(weather_type) && (index % 2) != 0 # Splash
|
||||
if @weatherTypes[weather_type][0].category == :Rain && (index % 2) != 0 # Splash
|
||||
sprite.opacity = (lifetimes[index] < 0.2) ? 255 : 0 # 0.2 seconds
|
||||
else
|
||||
dist_x = @weatherTypes[weather_type][2] * delta_t
|
||||
dist_y = @weatherTypes[weather_type][3] * delta_t
|
||||
dist_x = @weatherTypes[weather_type][0].particle_delta_x * delta_t
|
||||
dist_y = @weatherTypes[weather_type][0].particle_delta_y * delta_t
|
||||
sprite.x += dist_x
|
||||
sprite.y += dist_y
|
||||
if weather_type == PBFieldWeather::Snow
|
||||
if weather_type == :Snow
|
||||
sprite.x += dist_x * (sprite.y - @oy) / (Graphics.height * 3) # Faster when further down screen
|
||||
sprite.x += [2, 1, 0, -1][rand(4)] * dist_x / 8 # Random movement
|
||||
sprite.y += [2, 1, 1, 0, 0, -1][index % 6] * dist_y / 10 # Variety
|
||||
end
|
||||
sprite.opacity += @weatherTypes[weather_type][4] * delta_t
|
||||
sprite.opacity += @weatherTypes[weather_type][0].particle_delta_opacity * delta_t
|
||||
x = sprite.x - @ox
|
||||
y = sprite.y - @oy
|
||||
# Check if sprite is off-screen; if so, reset it
|
||||
@@ -382,13 +310,13 @@ module RPG
|
||||
if @fading && @fade_time >= [FADE_OLD_TONE_END - @time_shift, 0].max
|
||||
weather_type = @target_type
|
||||
end
|
||||
@tile_x += @weatherTypes[weather_type][5] * delta_t
|
||||
@tile_y += @weatherTypes[weather_type][6] * delta_t
|
||||
if @tile_x < -@tiles_wide * @weatherTypes[weather_type][1][0].width
|
||||
@tile_x += @tiles_wide * @weatherTypes[weather_type][1][0].width
|
||||
@tile_x += @weatherTypes[weather_type][0].tile_delta_x * delta_t
|
||||
@tile_y += @weatherTypes[weather_type][0].tile_delta_y * delta_t
|
||||
if @tile_x < -@tiles_wide * @weatherTypes[weather_type][2][0].width
|
||||
@tile_x += @tiles_wide * @weatherTypes[weather_type][2][0].width
|
||||
end
|
||||
if @tile_y > @tiles_tall * @weatherTypes[weather_type][1][0].height
|
||||
@tile_y -= @tiles_tall * @weatherTypes[weather_type][1][0].height
|
||||
if @tile_y > @tiles_tall * @weatherTypes[weather_type][2][0].height
|
||||
@tile_y -= @tiles_tall * @weatherTypes[weather_type][2][0].height
|
||||
end
|
||||
end
|
||||
|
||||
@@ -472,11 +400,11 @@ module RPG
|
||||
tone_gray = base_tone.gray
|
||||
end
|
||||
# Modify base tone
|
||||
if weather_type == PBFieldWeather::Sun
|
||||
if weather_type == :Sun
|
||||
@sun_magnitude = weather_max if @sun_magnitude != weather_max && @sun_magnitude != -weather_max
|
||||
@sun_magnitude *= -1 if (@sun_magnitude > 0 && @sun_strength > @sun_magnitude) ||
|
||||
(@sun_magnitude < 0 && @sun_strength < 0)
|
||||
@sun_strength += @sun_magnitude.to_f * Graphics.delta_s * 0.4 # 0.4 seconds
|
||||
@sun_strength += @sun_magnitude.to_f * Graphics.delta_s / 0.4 # 0.4 seconds per half flash
|
||||
tone_red += @sun_strength
|
||||
tone_green += @sun_strength
|
||||
tone_blue += @sun_strength / 2
|
||||
@@ -495,9 +423,9 @@ module RPG
|
||||
tile_change_threshold = [FADE_OLD_TONE_END - @time_shift, 0].max
|
||||
if old_fade_time <= tile_change_threshold && @fade_time > tile_change_threshold
|
||||
@tile_x = @tile_y = 0.0
|
||||
if @weatherTypes[@target_type] && @weatherTypes[@target_type][1] && @weatherTypes[@target_type][1].length > 0
|
||||
w = @weatherTypes[@target_type][1][0].width
|
||||
h = @weatherTypes[@target_type][1][0].height
|
||||
if @weatherTypes[@target_type] && @weatherTypes[@target_type][2].length > 0
|
||||
w = @weatherTypes[@target_type][2][0].width
|
||||
h = @weatherTypes[@target_type][2][0].height
|
||||
@tiles_wide = (Graphics.width.to_f / w).ceil + 1
|
||||
@tiles_tall = (Graphics.height.to_f / h).ceil + 1
|
||||
ensureTiles
|
||||
@@ -521,7 +449,7 @@ module RPG
|
||||
@new_sprites.each_with_index { |sprite, i| sprite.visible = (i < @new_max) if sprite }
|
||||
end
|
||||
# End fading
|
||||
if @fade_time >= ((@target_type == PBFieldWeather::None) ? FADE_OLD_PARTICLES_END : FADE_NEW_TILES_END) - @time_shift
|
||||
if @fade_time >= ((@target_type == :None) ? FADE_OLD_PARTICLES_END : FADE_NEW_TILES_END) - @time_shift
|
||||
if !@sprites.any? { |sprite| sprite.visible }
|
||||
@type = @target_type
|
||||
@max = @target_max
|
||||
@@ -547,7 +475,7 @@ module RPG
|
||||
update_fading
|
||||
update_screen_tone
|
||||
# Storm flashes
|
||||
if @type == PBFieldWeather::Storm && !@fading
|
||||
if @type == :Storm && !@fading
|
||||
if @time_until_flash > 0
|
||||
@time_until_flash -= Graphics.delta_s
|
||||
if @time_until_flash <= 0
|
||||
@@ -560,7 +488,7 @@ module RPG
|
||||
end
|
||||
@viewport.update
|
||||
# Update weather particles (raindrops, snowflakes, etc.)
|
||||
if @weatherTypes[@type] && @weatherTypes[@type][0] && @weatherTypes[@type][0].length > 0
|
||||
if @weatherTypes[@type] && @weatherTypes[@type][1].length > 0
|
||||
ensureSprites
|
||||
for i in 0...MAX_SPRITES
|
||||
update_sprite_position(@sprites[i], i, false)
|
||||
@@ -570,7 +498,7 @@ module RPG
|
||||
@sprites.clear
|
||||
end
|
||||
# Update new weather particles (while fading in only)
|
||||
if @fading && @weatherTypes[@target_type] && @weatherTypes[@target_type][0] && @weatherTypes[@target_type][0].length > 0
|
||||
if @fading && @weatherTypes[@target_type] && @weatherTypes[@target_type][1].length > 0
|
||||
ensureSprites
|
||||
for i in 0...MAX_SPRITES
|
||||
update_sprite_position(@new_sprites[i], i, true)
|
||||
|
||||
@@ -110,14 +110,14 @@ def pbPrepareBattle(battle)
|
||||
battle.defaultTerrain = battleRules["defaultTerrain"] if !battleRules["defaultTerrain"].nil?
|
||||
# Weather
|
||||
if battleRules["defaultWeather"].nil?
|
||||
case $game_screen.weather_type
|
||||
when PBFieldWeather::Rain, PBFieldWeather::HeavyRain, PBFieldWeather::Storm
|
||||
case GameData::Weather.get($game_screen.weather_type).category
|
||||
when :Rain
|
||||
battle.defaultWeather = :Rain
|
||||
when PBFieldWeather::Snow, PBFieldWeather::Blizzard
|
||||
when :Hail
|
||||
battle.defaultWeather = :Hail
|
||||
when PBFieldWeather::Sandstorm
|
||||
when :Sandstorm
|
||||
battle.defaultWeather = :Sandstorm
|
||||
when PBFieldWeather::Sun
|
||||
when :Sun
|
||||
battle.defaultWeather = :Sun
|
||||
end
|
||||
else
|
||||
|
||||
@@ -138,13 +138,12 @@ class PokemonEncounters
|
||||
encounter_chance /= 2
|
||||
min_steps_needed *= 2
|
||||
when :SNOWCLOAK
|
||||
if $game_screen.weather_type == PBFieldWeather::Snow ||
|
||||
$game_screen.weather_type == PBFieldWeather::Blizzard
|
||||
if GameData::Weather.get($game_screen.weather_type).category == :Hail
|
||||
encounter_chance /= 2
|
||||
min_steps_needed *= 2
|
||||
end
|
||||
when :SANDVEIL
|
||||
if $game_screen.weather_type == PBFieldWeather::Sandstorm
|
||||
if GameData::Weather.get($game_screen.weather_type).category == :Sandstorm
|
||||
encounter_chance /= 2
|
||||
min_steps_needed *= 2
|
||||
end
|
||||
|
||||
@@ -805,7 +805,7 @@ HiddenMoveHandlers::UseMove.add(:SURF,proc { |move,pokemon|
|
||||
# Sweet Scent
|
||||
#===============================================================================
|
||||
def pbSweetScent
|
||||
if $game_screen.weather_type!=PBFieldWeather::None
|
||||
if $game_screen.weather_type != :None
|
||||
pbMessage(_INTL("The sweet scent faded for some reason..."))
|
||||
return
|
||||
end
|
||||
|
||||
@@ -223,21 +223,15 @@ class BerryPlantSprite
|
||||
end
|
||||
end
|
||||
end
|
||||
# Check auto-watering
|
||||
if berryData[0]>0 && berryData[0]<5
|
||||
# Reset watering
|
||||
if $game_screen &&
|
||||
($game_screen.weather_type==PBFieldWeather::Rain ||
|
||||
$game_screen.weather_type==PBFieldWeather::HeavyRain ||
|
||||
$game_screen.weather_type==PBFieldWeather::Storm)
|
||||
# If raining, plant is already watered
|
||||
# If raining, automatically water the plant
|
||||
if berryData[0] > 0 && berryData[0] < 5 && $game_screen &&
|
||||
GameData::Weather.get($game_screen.weather_type).category == :Rain
|
||||
if berryData[2] == false
|
||||
berryData[2] = true
|
||||
berryData[4] += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return berryData
|
||||
end
|
||||
|
||||
|
||||
@@ -747,24 +747,26 @@ end
|
||||
|
||||
module WeatherEffectProperty
|
||||
def self.set(_settingname,oldsetting)
|
||||
oldsetting = [:None, 100] if !oldsetting
|
||||
options = []
|
||||
for i in 0..PBFieldWeather.maxValue
|
||||
options.push(getConstantName(PBFieldWeather,i) || "ERROR")
|
||||
ids = []
|
||||
default = 0
|
||||
GameData::Weather.each do |w|
|
||||
default = ids.length if w.id == oldsetting[0]
|
||||
options.push(w.real_name)
|
||||
ids.push(w.id)
|
||||
end
|
||||
cmd = pbMessage(_INTL("Choose a weather effect."),options,1)
|
||||
if cmd==0
|
||||
return nil
|
||||
else
|
||||
cmd = pbMessage(_INTL("Choose a weather effect."), options, -1, default)
|
||||
return nil if cmd < 0 || ids[cmd] == :None
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0, 100)
|
||||
params.setDefaultValue((oldsetting) ? oldsetting[1] : 100)
|
||||
params.setDefaultValue(oldsetting[1])
|
||||
number = pbMessageChooseNumber(_INTL("Set the probability of the weather."), params)
|
||||
return [cmd,number]
|
||||
end
|
||||
return [ids[cmd], number]
|
||||
end
|
||||
|
||||
def self.format(value)
|
||||
return (value) ? (getConstantName(PBFieldWeather,value[0]) || "ERROR")+",#{value[1]}" : "-"
|
||||
return (value) ? GameData::Weather.get(value[0]).real_name + ",#{value[1]}" : "-"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user