Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # ALUMNEA MAGIC ACADEMY - WEATHER SYSTEM ~
- # REQUIRE : AMA - Day Nite System
- # AUTHOR : TheoAllen
- # =============================================================================
- =begin
- Script ini ngebikin weather terjadi secara random.
- Note :
- Segala hal soal kompatibilitas, error, kerusakan edit, dan semacamnya
- ditanggung oleh pencomot script.
- =end
- # =============================================================================
- # ♫ Module AMA ~ ♫
- # =============================================================================
- module AMA
- module WEATHER
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # DEFAULT_CHANCE >> [1,24] kemungkinan hujan per jam adalah 1/24
- # WET_STATUS_ID >> Status ID yg bakal di-add kalo ujan
- # RANGE_MAX >> Maksimal ujannya berapa jam lamanya
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- DEFAULT_CHANCE = [1,24]
- WET_STATUS_ID = 4
- RANGE_MAX = 24
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Panggil dalam script call :
- # - AMA::WEATHER.chance(chance,dice) >> ganti kemungkinan
- # - AMA::WEATHER.range_max(max) >> ganti maksimal ujannya
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Setelah line ini kalo ada kerusakan edit tanggung sendiri :v
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- def self.chance(chance = 1,dice = 10)
- $game_system.weather_chance = chance
- $game_system.weather_dice = dice
- end
- def self.range_max(max = 24)
- $game_system.weather_range_max(max)
- end
- end
- end
- # =============================================================================
- # ♫ Game System ~ ♫
- # =============================================================================
- class Game_System
- attr_accessor :weather
- attr_accessor :weather_start
- attr_accessor :weather_chance
- attr_accessor :weather_range_max
- attr_accessor :weather_dice
- attr_reader :weather_range
- #--------------------------------------------------------------------------
- # ♫ Inisialisasi
- #--------------------------------------------------------------------------
- alias ama_weather_init initialize
- def initialize
- ama_weather_init
- @weather = :none
- @weather_range = 0
- @weather_start = 0
- @weather_chance = AMA::WEATHER::DEFAULT_CHANCE[0]
- @weather_dice = AMA::WEATHER::DEFAULT_CHANCE[1]
- @weather_range_max = AMA::WEATHER::RANGE_MAX
- end
- #--------------------------------------------------------------------------
- # ♫ Ngebersihin cuaca
- #--------------------------------------------------------------------------
- def clear_weather
- @weather = :none
- end
- #--------------------------------------------------------------------------
- # ♫ Ngecek cuaca per jam
- #--------------------------------------------------------------------------
- alias ama_weather_update update_hour
- def update_hour
- ama_weather_update
- chance = (rand * weather_dice).round
- if chance <= weather_chance
- update_weather unless weather_selected?
- end
- end
- #--------------------------------------------------------------------------
- # ♫ Ada ga cuacanya?
- #--------------------------------------------------------------------------
- def weather_selected?
- return self.weather != :none
- end
- #--------------------------------------------------------------------------
- # ♫ Ngeupdate cuaca
- #--------------------------------------------------------------------------
- def update_weather
- select_weather
- determine_range
- end
- #--------------------------------------------------------------------------
- # ♫ Milih cuaca
- #--------------------------------------------------------------------------
- def select_weather
- weather = rand.round
- if weather == 1
- @weather = :rain
- else
- @weather = :storm
- end
- end
- #--------------------------------------------------------------------------
- # ♫ Nentuin berapa lamanya
- #--------------------------------------------------------------------------
- def determine_range
- @weather_range = (rand * weather_range_max).round
- end
- #--------------------------------------------------------------------------
- # ♫ Nentuin kuat ngganya
- #--------------------------------------------------------------------------
- def weather_power
- return (rand * 9).round
- end
- end
- # =============================================================================
- # ♫ Scene Map ~ ♫
- # =============================================================================
- class Scene_Map < Scene_Base
- #--------------------------------------------------------------------------
- # ♫ Nyisipin update cuaca di update per frame
- #--------------------------------------------------------------------------
- alias ama_weather_update update
- def update
- ama_weather_update
- update_weather
- end
- #--------------------------------------------------------------------------
- # ♫ Ngambil game system
- #--------------------------------------------------------------------------
- def system
- $game_system
- end
- #--------------------------------------------------------------------------
- # ♫ Ngambil game party
- #--------------------------------------------------------------------------
- def party
- $game_party
- end
- #--------------------------------------------------------------------------
- # ♫ Update cuaca di map
- #--------------------------------------------------------------------------
- def update_weather
- if interior?
- screen.change_weather(:none,0,0) if screen.weather_type != :none
- return
- end
- apply_weather unless weather_set?
- update_weather_status
- clear_weather if weather_expired?
- end
- #--------------------------------------------------------------------------
- # ♫ Bersihin cuaca di map
- #--------------------------------------------------------------------------
- def clear_weather
- screen.clear_weather
- system.clear_weather
- Audio.bgs_fade(Graphics.frame_rate)
- end
- #--------------------------------------------------------------------------
- # ♫ Pasang cuaca di map
- #--------------------------------------------------------------------------
- def apply_weather
- return unless system.weather_selected?
- weather = system.weather
- power = system.weather_power
- system.weather_start = system.dns_hours + system.weather_range
- case weather
- when :rain
- Audio.bgs_play("Audio/BGS/Rain",power*10)
- when :storm
- Audio.bgs_play("Audio/BGS/Storm",power*10)
- end
- screen.change_weather(weather,power,60)
- end
- #--------------------------------------------------------------------------
- # ♫ Update status berdasar cuaca
- #--------------------------------------------------------------------------
- def update_weather_status
- if weather_set?
- apply_weather_status
- return
- end
- clear_weather_status
- end
- #--------------------------------------------------------------------------
- # ♫ Pasang status
- #--------------------------------------------------------------------------
- def apply_weather_status
- party.all_members.each do |actor|
- actor.add_state(AMA::WEATHER::WET_STATUS_ID)
- end
- end
- #--------------------------------------------------------------------------
- # ♫ Ilangin status
- #--------------------------------------------------------------------------
- def clear_weather_status
- party.all_members.each do |actor|
- actor.remove_state(AMA::WEATHER::WET_STATUS_ID)
- end
- end
- #--------------------------------------------------------------------------
- # ♫ Ngecek dah beres belom ujannya?
- #--------------------------------------------------------------------------
- def weather_expired?
- return system.weather_start <= system.dns_hours
- end
- #--------------------------------------------------------------------------
- # ♫ Cuacanya ada g di map?
- #--------------------------------------------------------------------------
- def weather_set?
- screen.weather_type != :none
- end
- end
- # =============================================================================
- #
- # ♫ End of Script ♫
- #
- # =============================================================================
Advertisement
Add Comment
Please, Sign In to add comment