• Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Resource icon

Resource [20.1+] Weather System 1.3.4

REALMUGEN

Trainer
Member
Joined
Jan 23, 2020
Posts
69
Hello again. I have a small problem, which the truth is not so serious, but maybe it stems from a misunderstanding of mine when configuring the script or maybe to a feature that is not working properly. Let's say my zones are configured as follows:


ZONE_MAPS = [
[1],
[13,16,23],
[4, 5],
[6]
]

Let's focus on the second line. In my game, let's say that:
Currently on map 16 (first outside) it is raining. The character enters map 13 (interior) and from 13 exits to 23 (new outside in the same Zone).

With the current configuration I understand that when I go out to map 23 (new outside in the same Zone) it should still be raining. Right?

However it happens that while in 16 (first outside) it rains, in 23 (new outside in the same Zone) there is no weather, I go back to 16 and it is still raining.

Is it normal for it to behave like this?

Thank you for your support.
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
614
As you showed, yes it should still be raining. On all my tries the weather worked properly if I recall right. Have you put map 23 in weather exceptions for rain and set no weather as the alternative? Because that could be a reason why it doesn't rain although I doubt you did this.

As a side note, the example should look like this:
ZONE_MAPS = [
[1],
[13,16,23],
[4, 5],
[6]
]
With a comma at the end of the second array. If you have it like that in your configuration, check if adding the comma solves the problem.
 

REALMUGEN

Trainer
Member
Joined
Jan 23, 2020
Posts
69
As you showed, yes it should still be raining. On all my tries the weather worked properly if I recall right. Have you put map 23 in weather exceptions for rain and set no weather as the alternative? Because that could be a reason why it doesn't rain although I doubt you did this.

As a side note, the example should look like this:
ZONE_MAPS = [
[1],
[13,16,23],
[4, 5],
[6]
]
With a comma at the end of the second array. If you have it like that in your configuration, check if adding the comma solves the problem.

I noticed the comma problem, but it was just a typo mistake. The problem persists with or without it. I'm trying to see if something is causing the conflict, but it's strange. I don't have map 23 in any exception, and I tried with other maps but the same thing happens, it seems that the weather only stays in the same map.
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
614
Mmm... have you defined the maps you are having trouble with as outdoor maps? It's one of the conditions for the weather to display on the map. The plugin will consider them indoor if not.
 

REALMUGEN

Trainer
Member
Joined
Jan 23, 2020
Posts
69
Mmm... have you defined the maps you are having trouble with as outdoor maps? It's one of the conditions for the weather to display on the map. The plugin will consider them indoor if not.
Everything well defined in its respective metadata...

Ok, I think I have a clue....

My current configuration is as follows:

ZONE_MAPS = [
[5],
[13,16,23,25]
]

When I modify the zones in the configuration script, there are no changes, but if I do it in-game with the command $WeatherSystem.zoneMaps[0] = [13,16,23,25] going from map 16 (with rain) to map 13 and then to map 23, the rain remains... So, nice there...

If I do it through $WeatherSystem.zoneMaps[1] = [13,16,23,25] going from map 16 (with rain) to map 13 and then to map 23, gets:

Ruby:
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.5]
[EBDX v1.4.1 (E21)]

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

Backtrace:
[Lin's Weather System] 01 - Main.rb:169:in `pbUpdateWeather'
[Lin's Weather System] 03 - Handler.rb:17: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'
Scene_Map:92:in `transfer_player'
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
614
I can't replicate any of the errors you are having so I can't find the source of the problem. At this point, I have only two things you can try to see if it solves them:
  • Start a new game and see if the problem persists. That is probably the reason why editing the configuration file does nothing to you, since the ZONE_MAPS is only stored on $WeatherSystem.zoneMaps when initializing the variable.
  • Deleting the folder in the plugin folder, installing it again and starting a new game.
While you don't need to save the game in any of those cases, I would recommend doing so if it solves the problem. If you don't want to because of reasons, all I can think is using $WeatherSystem.zoneMaps = WeatherConfig::ZONE_MAPS on an event so the zones you configured are properly stored.
 

REALMUGEN

Trainer
Member
Joined
Jan 23, 2020
Posts
69
I can't replicate any of the errors you are having so I can't find the source of the problem. At this point, I have only two things you can try to see if it solves them:
  • Start a new game and see if the problem persists. That is probably the reason why editing the configuration file does nothing to you, since the ZONE_MAPS is only stored on $WeatherSystem.zoneMaps when initializing the variable.
  • Deleting the folder in the plugin folder, installing it again and starting a new game.
While you don't need to save the game in any of those cases, I would recommend doing so if it solves the problem. If you don't want to because of reasons, all I can think is using $WeatherSystem.zoneMaps = WeatherConfig::ZONE_MAPS on an event so the zones you configured are properly stored.
Understood! Thank you very much! :)
 

Blakeline

Novice
Member
Joined
Nov 25, 2023
Posts
10
Okay so this is kind of weird, and I'm not exactly sure what's causing it. The weather system just absolutely does not work, even after changing the configuration file to the maps I want the weather to be in. It just does nothing.

So, after a bit of testing, I think I know what the issue is : the $WeatherSystem never gets initialised. Ever.
I noticed this when trying to use the pbWeatherForecast function, and then the pbFindZone and pbInitializeWeather functions.

None of them worked, but the errors were all the same : each time they tried to access something from the $WeatherSystem, they couldn't because that's a nil class. Soo... is there a command to put at the beggining of the game to initialize the weather I somehow forgot ? I'm really clueless about this one...
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
614
The whole system should initialize on its own the first time the player changes maps. Even the map change from the Intro map to the player's map like in the vanilla Essentials should do. Have you tried it?
 

Blakeline

Novice
Member
Joined
Nov 25, 2023
Posts
10
I did, I started a new file and my character changed maps multiple time, even starting from the Intro map. My Intro map is not the same as the one from vanilla essentials though. I actually kept the whole vanilla essentials in my project, in case I need to test for things, just not using them and making the actual maps I need next to them. That does means I have both the intro map from vanilla (which I don't use) and my intro map. Maybe that's the problem ?
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
614
The maps aren't important. The code for the weather is called every time the player enters a map. I have been doing some tests and the code seems to initialize when the player enters an outdoor map. The code stops before the whole system initializes on maps that aren't marked as outdoor because that was the order I put it in but it should initialize on those.

If it doesn't work or you need the system to initialize before the player can go to an outdoor map, try to manually initialize it with pbInitializeWeather. Or go to "01 - Main Code/03 - Handler" and change the code to this:
Ruby:
EventHandlers.add(:on_enter_map, :change_weather,
  proc { |_old_map_id|
    next if !$game_map
    pbInitializeWeather if !$WeatherSystem.actualWeather || $WeatherSystem.actualWeather.length == 0
    $game_screen.weather(:None,0,0) unless $game_map.metadata&.outdoor_map
    $game_screen.weather(:None,0,0) if WeatherConfig::NO_WEATHER
    next unless $game_map.metadata&.outdoor_map
    next if WeatherConfig::NO_WEATHER
    pbFindZone
    i = $WeatherSystem.currentZone
    $game_screen.weather(:None,0,0) if $WeatherSystem.currentZone == nil
    next if $WeatherSystem.currentZone == nil
    pbUpdateWeather(i) if !WeatherConfig::FORCE_UPDATE
    weather = $WeatherSystem.actualWeather[i].mainWeather
    weather = pbCheckValidWeather(weather, i)
    weather = :None if PBDayNight.isNight? && weather == :Sun
    next if $game_screen.weather_type == weather
    power = (weather == :None) ? 0 : 9
    duration = 0
    $game_screen.weather(weather,power,duration)
  }
)

The code should be exactly the same as you have, except that the code to initialize the system is at the start, before the game checks if the player is on an outdoor map or not.
 

Blakeline

Novice
Member
Joined
Nov 25, 2023
Posts
10
I tried both methods but the issue remains. And it's the same problem too : the $WeatherSystem is never initialised. Here's the exact error if you need more details :

[2023-11-25 16:43:14 +0100]
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.5]

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'
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
614
At this point, I can only think of one thing. You aren't starting a new game. I can't see why you would have problems when I do not, no matter how many times I test it.
 

Blakeline

Novice
Member
Joined
Nov 25, 2023
Posts
10
I have a lot of plugins installed, maybe there's some conflict or smth... I'm gonna try and solve this by myself, but thank you for your help !
 
Last edited:

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
614
I don't see how another plugin would conflict with mine to the point of conflicting with a variable I created for this plugin but sure, try it out.

Looking at the error log you shared, the problem seems to be on the seasonal weather and not the variable. Could you share an image with the configuration for the seasons? It's at the end of the configuration file.
 

Blakeline

Novice
Member
Joined
Nov 25, 2023
Posts
10
Yeah I just noticed it too, all the errors so far have been about the variable not being initialised, this is the first time the problem comes from the configuration data lol. But anyways, here it is :


Ruby:
#===============================================================================
# * 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 = [
    [0, 100]
  ]

  # Probability of weather in autumn.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_AUTUMN = ZONE_WEATHER_SUMMER

  # Probability of weather in winter.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_WINTER = ZONE_WEATHER_SUMMER

  # Probability of weather in spring.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_SPRING = ZONE_WEATHER_SUMMER

For testing purposes, I decided to put it to 100% rain, so this way when it changes I know for sure.
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
614
Mmm... the problem is that nothing is being saved for autumn, winter and spring. I think that with this configuration, this error wouldn't appear if you were in one of the summer months. Change the code to WeatherConfig::ZONE_WEATHER_SUMMER. I'll update the instructions for this if it solves the problem.
 

Blakeline

Novice
Member
Joined
Nov 25, 2023
Posts
10
I updated the pbInitializeWeather function to this, I hope I understood that was what you wanted me to do :

Ruby:
def pbInitializeWeather
  zoneWeather = WeatherConfig::ZONE_WEATHER_SUMMER
  for i in 0...$WeatherSystem.zoneMaps.length
    chance = 0
    last = 0
    prob = []
    for j in 0...zoneWeather[i].length
      chance += zoneWeather[i][j]
      newprob = zoneWeather[i][j] + last
      prob.push(newprob)
      last = newprob
    end
    chance += 1
    for j in 0...prob.length
      prob[j] = 0 if zoneWeather[i][j] == 0
    end
    main = 0
    for j in 0...zoneWeather[i].length
      break if rand(chance) <= prob[j]
      main += 1
    end
    mainType = GameData::Weather.get(main).id
    secondType = pbValidSecondWeather(i, mainType)
    startTime = pbGetStartTime
    endTime = pbGetEndTime(startTime)
    newWeather = WeatherSystemData.new(startTime, endTime, mainType, secondType)
    $WeatherSystem.actualWeather.push(newWeather)
    main = 0
    for j in 0...zoneWeather[i].length
      break if rand(chance) <= prob[j]
      main += 1
    end
    mainType = GameData::Weather.get(main).id
    secondType = pbValidSecondWeather(i, mainType)
    newWeather = WeatherSystemData.new(startTime, endTime, mainType, secondType)
    $WeatherSystem.nextWeather.push(newWeather)
  end
end

The same error arises, so I don't think that was the issue... But now I'm pretty sure the error IS in the configuration file, I'll update you if I find what is going wrong.
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
614
I meant changing the lines in the configuration to
Ruby:
#===============================================================================
# * 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 = [
    [0, 100]
  ]

  # Probability of weather in autumn.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_AUTUMN = WeatherConfig::ZONE_WEATHER_SUMMER

  # Probability of weather in winter.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_WINTER = WeatherConfig::ZONE_WEATHER_SUMMER

  # Probability of weather in spring.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_SPRING = WeatherConfig::ZONE_WEATHER_SUMMER
But I have just tested it and using ZONE_WEATHER_SUMMER here works just fine.

Ok, with one more test, I got the same error only when there are less zones defined for the seasonal weathers than in the zone maps. As an example, if you have this configuration in the zone maps
1700931310146.png

the configuration for the seasonal weather has to have as many zones (3 in this case). It has to look something like this:
1700931514607.png

Change the numbers to whatever you want and add as many weather probabilities as you want, but you need the zones for both to match.
 

Blakeline

Novice
Member
Joined
Nov 25, 2023
Posts
10
Okay so I changed it and the error is still there. At this point I'm just going to give you my whole configuration file, maybe things will be a bit clearer that way ? (I also changed back the pbInitializeWeather to the way it originally was)


Configuration.rd:
#===============================================================================
# * Weather System Configuration
#===============================================================================

module WeatherConfig
  # Set to false to use the Weather System.
  NO_WEATHER = true        # 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 = false    # 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.
  MAPS_SUBSTITUTE = {
    :Snow => ["exclude", 1, 4],
    :Blizzard => ["exclude", 1, 4],
        :Sandstorm => ["include", 5]
  }

  # The ID of the weathers that will substitute the main when in one of the summer or sandstorm maps.
  # 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}
  ]

#===============================================================================
# * Weather Names
#===============================================================================
  # A hash that contains the ID of weather and the name to display for each one.
  # Using .downcase will make them lowercase.
  WEATHER_NAMES = {
    :None        => _INTL("Normal"),
    :Rain        => _INTL("Pluie"),
    :Storm        => _INTL("Tempête"),
    :Snow        => _INTL("Neige"),
    :Blizzard    => _INTL("Blizzard"),
    :Sandstorm    => _INTL("Tempête de sable"),
    :HeavyRain    => _INTL("Forte pluie"),
    :Sun        => _INTL("Soleil"),
    :Fog        => _INTL("Brouillard")
  }

#===============================================================================
# * 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 = [
    [32, 76, 78, 85]
  ]
#===============================================================================
# * 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 = [
    #{"Map Name" => Map ID},
    {"Tourneuve" => 32, "Route K1" => 76, "Agrumelle" => 78, "Lérucéa" => 85}
  ]

  # 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 = [
    [0, 100]
  ]

  # Probability of weather in autumn.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_AUTUMN = WeatherConfig::ZONE_WEATHER_SUMMER

  # Probability of weather in winter.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_WINTER = WeatherConfig::ZONE_WEATHER_SUMMER

  # Probability of weather in spring.
  # Order: None, Rain, Storm, Snow, Blizzard, Sandstorm, HeavyRain, Sun/Sunny, Fog
  ZONE_WEATHER_SPRING = WeatherConfig::ZONE_WEATHER_SUMMER
end
 
Back
Top