• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • The Eevee Expo Game Jam has concluded! 🎉 Head on over to the game jam forum to play through the games.
    Don't forget to come back September 21st to vote for your favorites!
  • Reminder: AI-generated content is not allowed on the forums per the Rules and Regulations. Please contact us if you have any questions!
Resource icon

Resource [20.1+] Weather System 1.4.0

Hello, I am currently trying to create an event that involves the player sleeping. The idea behind the code is to check if the player has slept passed the time where the next weather change should be. I am using Unreal Time System in my game.

An example of this is the current time is 8:00AM with sunny weather and the next weather change is 9:00AM with rain. If the player were to sleep to 10:00AM, they would wake up to rain.

I am trying to use a conditional branch event that checks if the new time is greater than the Weather end time. If it is true, it would set Weather now to equal Weather next. This is what I have so far but it does not work. Also I am new to Ruby so sorry if there are incorrect structure grammar.


Script: UnrealTime.advance_to(10,0,0) //Sets the time to 10:00AM
Conditional Branch: Script: pbGetTimeNow >= $WeatherSystem.actualWeather[zone].endTime //checks if current time is greater than Weather end time
[imath]WeatherConfig.weather_names[[/imath]WeatherSystem.actualWeather[zone].mainWeather] => [imath]WeatherConfig.weather_names[[/imath]WeatherSystem.nextWeather[zone].mainWeather] //Sets Weather Now equal Weather Next
Else
Branch End
 
You don't need the conditional branch. Once you use the code to advance time, all you need to do is use pbUpdateWeather to update the weather of all zones or pbUpdateWeather(zone) to update the weather of a specific zone of your choice (just change "zone" with the zone number). That code already checks if the weather should be updated and does so if it's the case.
 
Sorry if this was already posted, I checked the thread but couldn't find it mentioned. When using Arcky's Region Map and clicking on any map tiles, I get this error:

[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: NoMethodError
Message: undefined method `has_key?' for nil:NilClass

Backtrace:
[Lin's Weather System] 01 - Main_Code.rb:24:in `block in pbGetMapZone'
[Lin's Weather System] 01 - Main_Code.rb:22:in `each'
[Lin's Weather System] 01 - Main_Code.rb:22:in `pbGetMapZone'
[Arcky's Region Map] 004_RegionMap_WeatherPreview.rb:39:in `showPreviewWeather'
[Arcky's Region Map] 004_RegionMap_WeatherPreview.rb:20:in `getPreviewWeather'
[Arcky's Region Map] 002_RegionMap_PreviewBox.rb:49:in `showPreviewBox'
[Arcky's Region Map] 000_RegionMap_Main.rb:1025:in `block in pbMapScene'
[Arcky's Region Map] 000_RegionMap_Main.rb:984:in `loop'
[Arcky's Region Map] 000_RegionMap_Main.rb:984:in `pbMapScene'
[Arcky's Region Map] 000_RegionMap_Main.rb:1535:in `pbStartScreen'

I'm also having a lot of trouble getting the weather to actually work on certain maps. It works for maps 8-9 but when entering map 11 the rain vanishes even though they're all in the same zone. And weather doesn't appy to zone 3 with map 18 at all.

Code:
Expand Collapse Copy
#===============================================================================
# * Weather System Configuration
#===============================================================================

module WeatherConfig
  # Set to false to use the Weather System.
  NO_WEATHER = false        # Default: false

  # Set to true to show the weather on the Town Map.
  SHOW_WEATHER_ON_MAP = true    # Default: true

  # Set to true to use the computer's time. Will not work without Unreal Time System.
  USE_REAL_TIME = false        # Default: true

  # Set to true to have the weather change at midnight.
  CHANGE_MIDNIGHT = true    # Default: true

  # Define the min and max amount of time (in hours) before the weather changes.
  # Set the same number to not randomize the amount of time before the weather changes.
  CHANGE_TIME_MIN = 1        # Default: 1
  CHANGE_TIME_MAX = 4        # Default: 4

  # Set to true to if you want to force the weather to change when interacting with certain events.
  # Use pbForceUpdateWeather in an event to update all zone weathers.
  # Use pbForceUpdateZoneWeather(zone) in an event to update the weather of a zone.
  FORCE_UPDATE = true        # Default: false

  # Set to true to have the outdoor maps change with seasons.
  # The map's appearance will update when leaving an indoor map.
  SEASON_CHANGE = false        # Default: false

  # Set to true if your game starts outdoors and want to show the season splash when going somewhere indoors.
  # Set to false if your game starts indoors and want to show the season splash when going somewhere outdoors.
  OUTDOOR = false        # Default: false

  # Array with the ID of outside tilesets that will change with seasons.
  OUTDOOR_TILESETS = [1, 2]

  # The difference between the ID of the tileset defined for an outdoor map and it's season version.
  # The difference has to be the same for any tileset defined in OUTDOOR_TILESETS.
  # Use the same season tileset as the default outdoor map tileset and define the diference for that season as 0.
  SUMMER_TILESET = 22
  AUTUMN_TILESET = 24
  WINTER_TILESET = 26
  SPRING_TILESET = 0

#===============================================================================
# * Weather Substitute
#===============================================================================
  # A hash with the ID of the maps that will have or not have certain weathers.
  # The ID of the weather has to be of the main one you want to change with WEATHER_SUBSTITUTE.
  # Use "exclude" to define a list of maps that will not use that weather when it's the main one.
  #     Any maps of a zone not added on the "exclude" list will use the main weather.
  # Use "include" to define a list of maps that will use that weather when it's the main one.
  #     Any maps of a zone not added on the "include" list will use the secondary weather.
  MAPS_SUBSTITUTE = {
    :Snow => ["include", 2, 4],
    :Rain => ["exclude", 2, 4]
  }

  # The ID of the weathers that will substitute the main when appropiate (conditions defined in MAPS_SUBSTITUTE).
  # There has to be a hash (defined between {}) for each defined zone with weather to substitute.
  # Any weather not defined in the hash for a zone will use the main weather instead.
  WEATHER_SUBSTITUTE = [
    {:None => :None, :Rain => :Rain, :Storm => :Storm, :Snow => :Rain, :Blizzard => :Storm, :Sandstorm => :None, :HeavyRain => :HeavyRain, :Sun => :Sun, :Fog => :Fog},
    {:Snow => :Rain, :Blizzard => :Storm, :Sandstorm => :None},
    {:Snow => :Rain, :Blizzard => :HeavyRain}
  ]

#===============================================================================
# * Weather Names
#===============================================================================
  # A hash that contains the ID of weather and the name to display for each one.
  # Using .downcase will make them lowercase.
  def self.weather_names
    return {
      :None            => _INTL("None"),
      :Rain            => _INTL("Rain"),
      :Storm        => _INTL("Storm"),
      :Snow            => _INTL("Snow"),
      :Blizzard        => _INTL("Blizzard"),
      :Sandstorm    => _INTL("Sandstorm"),
      :HeavyRain    => _INTL("Heavy rain"),
      :Sun            => _INTL("Sun"),
      :Fog            => _INTL("Fog")
    }
  end
#===============================================================================
# * Zones Configuration
#===============================================================================
  # Arrays of id of the maps of each zone. Each array within the main array is a zone.
  # The maps within each zone will have the same weather at the same time.
  # Each zone may have a different weather than the others.
  ZONE_MAPS = [
    [2, 4],
    [8, 9, 11, 12, 14, 17],
    [18]
  ]
#===============================================================================
# * Map Display
#===============================================================================
  # Array of hashes to get each map's position in the Town Map. Each hash corresponds to a zone in ZONE_MAPS.
  # In "Map Name" you have to put the name the Town Map displays for that point.
  # In Map ID you have to put the ID of the map the name corresponds to, like in ZONE_MAPS.
  MAPS_POSITIONS = [

  ]

  # A hash for the plugin to display the proper weather image on the map.
  # They have to be on Graphics/Pictures/Weather (in 20+) or Graphics/UI/Weather (in 21+).
  WEATHER_IMAGE = {
    :Rain => "mapRain",
    :Storm => "mapStorm",
    :Snow => "mapSnow",
    :Blizzard => "mapBlizzard",
    :Sandstorm => "mapSand",
    :HeavyRain => "mapRain",
    :Sun => "mapSun",
    :Fog => "mapFog"
  }
#===============================================================================
# * Season Probability Configuration
#===============================================================================
  # Arrays of probability of weather for each zone in the different seasons.
  # Each array within the main array corresponds to a zone in ZONE_MAPS.
  # Put 0 to weather you don't want if you define a probability after it.
  # If your game doesn't use seasons, edit the probabilities of one season and copy it to the others.

  # Probability of weather in summer.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_SUMMER = [
    [40, 0, 0, 0, 0, 0, 0, 5],
    [40, 50],
    [60]
  ]

  # Probability of weather in autumn.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_AUTUMN = [
    [40, 0, 0, 0, 0, 0, 0, 5],
    [40, 50],
    [60]
  ]

  # Probability of weather in winter.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_WINTER = [
    [40, 0, 0, 0, 0, 0, 0, 5],
    [40, 50],
    [60]
  ]

  # Probability of weather in spring.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_SPRING = [
    [40, 0, 0, 0, 0, 0, 0, 5],
    [40, 50],
    [60]
  ]
end
 
Have you added the MAP_POSITIONS for all the town map points on the configuration of my plugin? For what I understand of the error, my plugin can't find a key (the map's name) matching the name of the selected point of the town's map.
 
Have you added the MAP_POSITIONS for all the town map points on the configuration of my plugin? For what I understand of the error, my plugin can't find a key (the map's name) matching the name of the selected point of the town's map.
Thanks for the quick response! I hadn't, because I'd set the display weather on map setting to false. I guess I'll have to do it anyway?
 
Well, the code I did to display weather on the map shouldn't (and doesn't seem to) activate at all with Arcky's plugin installed, regardless of the SHOW_WEATHER_ON_MAP configuration. So Arcky's plugin is calling to code I did to retrieve data from the town map and that requires you to set it up on the configuration of my plugin. Maybe you should tell him to add a coment about the matter on his plugin's overview if he hasn't?

That said, looking that code again has me realize that the SHOW_WEATHER_ON_MAP would do nothing at all since it's never called on the actual code. Ups. I'll update soon with the fix, but you won't need to download it since that code shouldn't activate for you anyway.
 
Sorry for spamming your thread, but now I'm getting an error every time I try to start a new game.

Ruby:
Expand Collapse Copy
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: NoMethodError
Message: undefined method `length' for nil:NilClass

Backtrace:
[Lin's Weather System] 01 - Main.rb:121:in `block in pbInitializeWeather'
[Lin's Weather System] 01 - Main.rb:117:in `each'
[Lin's Weather System] 01 - Main.rb:117:in `pbInitializeWeather'
[Lin's Weather System] 03 - Handler.rb:8:in `block in <main>'
Event_Handlers:89:in `block in trigger'
Event_Handlers:89:in `each_value'
Event_Handlers:89:in `trigger'
Event_HandlerCollections:63:in `trigger'
Game_MapFactory:147:in `setMapChanged'
Game_MapFactory:26:in `setup'
 
I'm looking at the plugin, but the lines don't seem to match. Could you tell me what you have on lines 117 and 121 in 01 - Main? Since I have an "end" in line 117 (and not the pbInitializeWeather that the errorlog mentions), I'm not sure if the problem is the ZONE_WEATHER_AUTUMN that I have in line 121.
 
I'm looking at the plugin, but the lines don't seem to match. Could you tell me what you have on lines 117 and 121 in 01 - Main? Since I have an "end" in line 117 (and not the pbInitializeWeather that the errorlog mentions), I'm not sure if the problem is the ZONE_WEATHER_AUTUMN that I have in line 121.
Here's what I have:
error2.png
 
Don't know why your code is in different lines, must be an old version.

Anyway, the error is saying that zoneWeather either is empty or doesn't exist. That has two posible reasons:
1) The ZONE_WEATHER for the active season is empty. If that's the case, define them.
2) Your game doesn't have the code to check for seasons (the pbIsSummer and so). That can be fixed by either adding it back or comenting out the if pbIsSummer (you just need to add a # before that bit of text). That should make it so zoneWeather always picks the summer weather configuration and it would only be overwritten if any of the other three exist and are true.
 
Don't know why your code is in different lines, must be an old version.

Anyway, the error is saying that zoneWeather either is empty or doesn't exist. That has two posible reasons:
1) The ZONE_WEATHER for the active season is empty. If that's the case, define them.
2) Your game doesn't have the code to check for seasons (the pbIsSummer and so). That can be fixed by either adding it back or comenting out the if pbIsSummer (you just need to add a # before that bit of text). That should make it so zoneWeather always picks the summer weather configuration and it would only be overwritten if any of the other three exist and are true.
Commenting it out didn't seem to work... The zone_weather is all defined, and i reset it to default to make sure I didnt screw something up.

Code:
Expand Collapse Copy
#===============================================================================
# * Season Probability Configuration
#===============================================================================
  # Arrays of probability of weather for each zone in the different seasons.
  # Each array within the main array corresponds to a zone in ZONE_MAPS.
  # Put 0 to weather you don't want if you define a probability after it.
  # If your game doesn't use seasons, edit the probabilities of one season and copy it to the others.

  # Probability of weather in summer.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_SUMMER = [
    [50, 20, 3, 0, 0, 0, 5, 30],
    [40, 50],
    [60]
  ]

  # Probability of weather in autumn.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_AUTUMN = [
    [50, 20, 3, 0, 0, 0, 5, 30],
    [40, 50],
    [60]
  ]

  # Probability of weather in winter.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_WINTER = [
    [50, 20, 3, 0, 0, 0, 5, 30],
    [40, 50],
    [60]
  ]

  # Probability of weather in spring.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_SPRING = [
    [50, 20, 3, 0, 0, 0, 5, 30],
    [40, 50],
    [60]
  ]
end

Ruby:
Expand Collapse Copy
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: NoMethodError
Message: undefined method `length' for nil:NilClass

Backtrace:
[Lin's Weather System] 01 - Main.rb:121:in `block in pbInitializeWeather'
[Lin's Weather System] 01 - Main.rb:117:in `each'
[Lin's Weather System] 01 - Main.rb:117:in `pbInitializeWeather'
[Lin's Weather System] 03 - Handler.rb:8:in `block in <main>'
Event_Handlers:89:in `block in trigger'
Event_Handlers:89:in `each_value'
Event_Handlers:89:in `trigger'
Event_HandlerCollections:63:in `trigger'
Game_MapFactory:147:in `setMapChanged'
Game_MapFactory:26:in `setup'
 
Ah, I see the problem. You have to configure the weathers to have, at the very least, the same number of zones than in ZONE_MAPS (you can define more zones in the ZONE_WEATHER, but those zones will not be used). Otherwise, the plugin will throw an error since it is trying to find data in a zone that doesn't exist in the ZONE_WEATHER.

On another note, why are you still using an old version of my plugin? Is there any problem you have encountered with newer versions or you just don't want to go through the fuss of passing the data to the new configuration file?
 
Ah, I see the problem. You have to configure the weathers to have, at the very least, the same number of zones than in ZONE_MAPS (you can define more zones in the ZONE_WEATHER, but those zones will not be used). Otherwise, the plugin will throw an error since it is trying to find data in a zone that doesn't exist in the ZONE_WEATHER.

On another note, why are you still using an old version of my plugin? Is there any problem you have encountered with newer versions or you just don't want to go through the fuss of passing the data to the new configuration file?
I thought I was using the (second) latest version, but I guess it was older than I thought. I installed the newest version and that fixed the crashing problem.

I'm not entirely sure what the "the same number of zones than in ZONE_MAPS" means? I may just be dense though.
 
In the configuration, there is a ZONE_MAPS, that is an array of arrays. Each array inside the main one (the one directly after the "=") is a "zone", and there you define which maps (defined by their ID) are part of this zone and, as such, will have the same weather at the same moment (with exeptions on certain weathers that you can define somewhere else).

As a consecuence of the plugin revolving arround this idea of "zones", other things you configure have to have the same number of zones that this ZONE_MAP: WEATHER_SUBSTITUTE, MAPS_POSITIONS and the multiple ZONE_WEATHER.
 
Hi, I'm trying to overwrite the weather of a specific zone while a switch is on/off. I want to have a legendary pokemon in the map that is altering the weather, for example always harsh sun till you capture it, and then return the zone weather to what is defined in the config file. How could I achieve this?
 
You'll have to add an event that activates when the player enters the map and the switch is on/off (whatever you use to tell the game that there is a legendary pokemon there) and have it run this code:
$game_screen.weather(weather,power,duration) where "weather" is ":Harsh_Sun" (or whatever it's code is).

You have examples of this on pokemon essential's demo (the veteran on route 7, below the cave's entrance).
 
You'll have to add an event that activates when the player enters the map and the switch is on/off (whatever you use to tell the game that there is a legendary pokemon there) and have it run this code:
$game_screen.weather(weather,power,duration) where "weather" is ":Harsh_Sun" (or whatever it's code is).

You have examples of this on pokemon essential's demo (the veteran on route 7, below the cave's entrance).
Thank you so much! I thought I couldn't use that because of the plugin, but I guess it does not override that code
 
My plugin actually uses that code to set the weather. The thing is, it only does so when changing maps. So if you use it in an event, it will activate after my plugin and so it will be the event's weather the one that remains.
 
Hi Lin,
There's a strange incompatibility issue with the "Customizable Battle UI" plugin. When I try to compile, I get this error, and it can only be fixed by removing one of the two plugins.


https://eeveeexpo.com/resources/1312/
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: ArgumentError
Message: comparison of Integer with nil failed

Backtrace:
StartGame:29:in `set_up_system'
Main:31:in `mainFunctionDebug'
Main:18:in `block in mainFunction'
Errors:80:in `pbCriticalCode'
Main:18:in `mainFunction'
Main:45:in `block in <main>'
Main:44:in `loop'
Main:44:in `<main>'
-e:in `eval'

It's weird and I haven't found the problem in the code yet.

Thx in advance!
 
Last edited:
Back
Top