• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Custom Feature Question] BW Season Script + Random Weather

  • 163
    Posts
    8
    Years
    • Seen Feb 15, 2025
    Hi everyone!

    I am trying to make the script of Kleinstudio's BW SEASON compatible with a Random Weather script (which corresponds to the seasons of the year).

    I'm not very good at scripting, but I'm trying to achieve it and so far I have been able to do it. The only problem is that I can't get the script to recognize if the maps are inside or outside to make it work. (If there is snow, there is inside and outside).

    If someone knows how to help me it would be a good option to perfect the script and share it with the community.

    This is what i've got so far...

    Code:
    #===============================================================================
    # € BW Seasons by KleinStudio
    #===============================================================================
     
    #===============================================================================
    # € Months and seasons
    #===============================================================================
    #===============================================================================
    # * Variable number for fake season
    # * Enable or disable seasons
    # * Tilesets for seasons
    #    [Original tileset id, [Winter, Spring, Summer, Autumn]]
    #===============================================================================
    FAKESEASONVAR=999
    SEASONS=true
    SEASONSTILESETS = [
    [6, [50,51,6,52]], # VERANO (INVIERNO, PRIMAVERA, VERANO, OTOÑO)
    [8, [61,60 ,8,62]], # VERANO (INVIERNO, PRIMAVERA, VERANO, OTOÑO)
    [63, [64,65,63,66]], # VERANO (INVIERNO, PRIMAVERA, VERANO, OTOÑO)
    
    ]
     
    JANUARY=1 #SPRING
    FEBRUARY=2 #SUMMER
    MARCH=3 #AUTUMN
    APRIL=4 #WINTER
    MAY=5 #SPRING
    JUNE=6 #SUMMER
    JULY=7 #AUTUMN
    AUGUST=8 #WINTER
    SEPTEMBER=9 #SPRING
    OCTOBER=10 #SUMMER
    NOVEMBER=11 #AUTUMN
    DECEMBER=12 #WINTER
     
    WINTER=1 
    SPRING=2
    SUMMER=3
    AUTUMN=4
    
    # The random Weather Chanche out of 100. 
    RANDOM_WEATHER_CHANCE= 5
    #===============================================================================
    # € Weather
    #===============================================================================
    
    
    def weatherNeedsChange?(weather)
      if !seasonsDefined
        p "For some reason the seasons are not defined. Make sure to create a new savefile after adding the seasons script."
        return false
      end
      if weather.is_a?(Array)
        weather=weather[0]
      end
      val=rand(101)
      case $PokemonGlobal.season[0]  
      when SPRING #"Spring" 
        chanche=[0,90,90,25,90,90,90,25] 
      when SUMMER #"Summer"
        chanche=[0,25,25,5,95,95,25,5]
      when AUTUMN #"Autumn"
        chanche=[0,90,90,25,90,90,90,25] 
      when WINTER #"Winter"
        chanche=[0,90,90,95,5,5,90,95]
      end
    
      return false if !chanche
      if weather
        if val>=chanche[weather]
          return true
        end
      end
      return true if (weather==nil && val<=RANDOM_WEATHER_CHANCE)
      return false
    end
    #===============================================================================
    # * Creating and returning random weather depending on season + location.
    #===============================================================================
    def randomWeather
      environment=pbGetEnvironment
      weather=[0,250,50,50,0,300,100,0] if SPRING || AUTUMN
      weather=[0,50,50,0,0,600,50,0] if SUMMER
      weather=[0,100,50,500,0,50,100,100] if WINTER
      # Changing weather chances depending on the environment.
      if environment==PBEnvironment::Grass || 
         environment==PBEnvironment::TallGrass ||
         environment==PBEnvironment::Rock
        weather[4]=0 
        weather[7]=0 
      elsif environment==PBEnvironment::MovingWater || 
            environment==PBEnvironment::StillWater
        weather[4]=0 
      elsif environment==PBEnvironment::Sand
        weather[1]/=4
        weather[2]/=4
        weather[3]/=4
        weather[4]+=750
        weather[5]+=250
        weather[6]/=4
        weather[7]/=4
      elsif environment==PBEnvironment::Underwater || 
            environment==PBEnvironment::Cave
        return nil
      end
      # Calculating the chances + returning weather depending on chance.
      rand_num=0
      for i in 0...weather.length
        rand_num+=weather[i]
      end
      randVal=rand(rand_num)
      minVal=0 ; maxVal=0
      for i in 0...weather.length
        weather[i].round
        maxVal+=weather[i]
        if randVal>minVal && randVal<maxVal
          return [i,100]
        else
          minVal+=weather[i]
        end
      end
      return nil
    
    end
     
    #===============================================================================
    # € Get current season
    #===============================================================================
    def pbGetSeason
      
     
      if $game_variables[FAKESEASONVAR]!=0
        @season=$game_variables[FAKESEASONVAR]
      else
       if pbGetTimeNow.mon==APRIL or pbGetTimeNow.mon==AUGUST or pbGetTimeNow.mon==DECEMBER
        return WINTER
       elsif pbGetTimeNow.mon==JANUARY or pbGetTimeNow.mon==MAY or pbGetTimeNow.mon==SEPTEMBER
        return SPRING
       elsif pbGetTimeNow.mon==FEBRUARY or pbGetTimeNow.mon==JUNE or pbGetTimeNow.mon==OCTOBER
        return SUMMER
       elsif pbGetTimeNow.mon==MARCH or pbGetTimeNow.mon==JULY or pbGetTimeNow.mon==NOVEMBER
        return AUTUMN
       end
      end
    end
    
     
    
    #===============================================================================
    # € Add season info to PokemonGlobal
    #===============================================================================
    class PokemonGlobalMetadata
      attr_accessor :disablesplash
      attr_accessor :season
      attr_accessor :lastindoor
      attr_accessor :lastseason
     
      def refreshSeason
        oldseason=@season
        @season=pbGetSeason
      end
       
      def getSeason
        @season=pbGetSeason if !@season
        @lastseason=@season if @lastseason==nil
        return @season if @season
      end
     
      def getLastSeason
        @lastseason=pbGetSeason if !@lastseason
        return @lastseason if @lastseason
      end
     
      def lastindoor?
        return @lastindoor if @lastindoor
      end
     
    end
     
    #===============================================================================
    # € Edit game_map
    #===============================================================================
    class Game_Map
     
      def setup(map_id)
        @map_id = map_id
        @map=load_data(sprintf("Data/Map%03d.%s", map_id,$RPGVX ? "rvdata" : "rxdata"))
        pbRefreshSeason # Refresh actual season if needed
        $lastmap=@map_id
       
        if SEASONS; for i in 0...SEASONSTILESETS.length
          if SEASONSTILESETS[i][0][email protected]_id
           seasonsets=SEASONSTILESETS[i][1]
           actualseason=$PokemonGlobal.getLastSeason
           actualseason=$PokemonGlobal.getSeason if $PokemonGlobal.lastindoor?
           actualseason=pbGetSeason if actualseason<1
           echo("#{pbGetSeasonName(actualseason)}\n#{actualseason}")
     
           @map.tileset_id=seasonsets[actualseason-1]
          end
        end; end
     
        tileset = $data_tilesets[@map.tileset_id]
        @tileset_name = tileset.tileset_name
       
        @autotile_names = tileset.autotile_names
        @panorama_name = tileset.panorama_name
        @panorama_hue = tileset.panorama_hue
        @fog_name = tileset.fog_name
        @fog_hue = tileset.fog_hue
        @fog_opacity = tileset.fog_opacity
        @fog_blend_type = tileset.fog_blend_type
        @fog_zoom = tileset.fog_zoom
        @fog_sx = tileset.fog_sx
        @fog_sy = tileset.fog_sy
        @battleback_name = tileset.battleback_name
        @passages = tileset.passages
        @priorities = tileset.priorities
        @terrain_tags = tileset.terrain_tags
        self.display_x = 0
        self.display_y = 0
        @need_refresh = false
        Events.onMapCreate.trigger(self,map_id, @map, tileset)
        @events = {}
        for i in @map.events.keys
          @events[i] = Game_Event.new(@map_id, @map.events[i],self)
        end
        @common_events = {}
        for i in 1...$data_common_events.size
          @common_events[i] = Game_CommonEvent.new(i)
        end
        @fog_ox = 0
        @fog_oy = 0
        @fog_tone = Tone.new(0, 0, 0, 0)
        @fog_tone_target = Tone.new(0, 0, 0, 0)
        @fog_tone_duration = 0
        @fog_opacity_duration = 0
        @fog_opacity_target = 0
        @scroll_direction = 2
        @scroll_rest = 0
        @scroll_speed = 4
       
     
      end
    end
     
    #===============================================================================
    # € Internal functions
    #===============================================================================
     
       def pbShowSeasonSplash
         return if !$Trainer or !$PokemonGlobal
         return if $PokemonGlobal.disablesplash || !SEASONS
         return if !$PokemonGlobal.lastindoor
         return if $PokemonGlobal.lastseason==$PokemonGlobal.getSeason
         current=pbGetSeasonName($PokemonGlobal.getSeason)
         @black = Sprite.new
         @black.bitmap = RPG::Cache.picture("blackscreen")
         @black.z=9999999
         @black.zoom_y=2.5
         @season = Sprite.new
         @season.bitmap = RPG::Cache.picture("season_"+current)
         @season.opacity = 0
         @season.z=9999999
         Graphics.transition
         20.times do
         Graphics.update
         @season.opacity+=25.5/2
         end
         Graphics.wait(60)
         20.times do
         Graphics.update
         @season.opacity-=25.5/2
         @black.opacity-=25.5/2
         end
         @black.dispose
         @season.dispose
         $PokemonGlobal.lastseason=$PokemonGlobal.getSeason
         $PokemonGlobal.lastindoor=false
       end
       
       def pbGetSeasonName(season)
         case season
         when 1
         return "winter"
         when 2
         return "spring"
         when 3
         return "summer"
         when 4
         return "autumn"
         end
       end
     
       
       def pbRefreshSeason # Only refresh when it's indoor
         mapid=$lastmap ? $lastmap : $game_map.map_id
         isoutdoor=pbGetMetadata(mapid,MetadataOutdoor)
         if $game_map && (!isoutdoor or isoutdoor==false)
           $PokemonGlobal.refreshSeason
           $PokemonGlobal.lastindoor=true
         end
       end
     
    #===============================================================================
    # € User functions
    #===============================================================================
     
       def pbDisableSeasonSplash # Disable season splash
         $PokemonGlobal.disablesplash=true
       end
       
       def pbEnableSeasonSplash # Enable seasons splash if disabled
         $PokemonGlobal.disablesplash=false
       end
       
       def makeWinter # Make winter
         $game_variables[FAKESEASONVAR]=WINTER
         $PokemonGlobal.refreshSeason
       end
       
       def makeSpring # Make spring
         $game_variables[FAKESEASONVAR]=SPRING
         $PokemonGlobal.refreshSeason
       end
       
       def makeSummer # Make summer
         $game_variables[FAKESEASONVAR]=SUMMER
         $PokemonGlobal.refreshSeason
       end
       
       def makeAutumn # Make autumn
         $game_variables[FAKESEASONVAR]=AUTUMN
         $PokemonGlobal.refreshSeason
       end
       
       def realSeason # Back to real season
         $game_variables[FAKESEASONVAR]=0
         $PokemonGlobal.refreshSeason
       end
       
       # Changing Weather depending on Season. (Requires BW2 Weather Script.)
    
    
      Events.onMapChange+=proc {|sender,e|
      oldid=e[0] # previous map ID, 0 if no map ID
      healing=pbGetMetadata($game_map.map_id,MetadataHealingSpot)
      $PokemonGlobal.healingSpot=healing if healing
      $PokemonMap.clear if $PokemonMap
      $PokemonEncounters.setup($game_map.map_id) if $PokemonEncounters
      $PokemonGlobal.visitedMaps[$game_map.map_id]=true
      if oldid!=0 && oldid!=$game_map.map_id
        mapinfos=$RPGVX ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
        weather=pbGetMetadata($game_map.map_id,MetadataWeather)
        # Changes the Weather
    
        if SEASONS 
          if weatherNeedsChange?(weather)
            weather=randomWeather
          end
        end
        if $game_map.name!=mapinfos[oldid].name
          $game_screen.weather(weather[0],rand(6),20) if weather && rand(100)<weather[1]
        else
          oldweather=pbGetMetadata(oldid,MetadataWeather)
          $game_screen.weather(weather[0],rand(6),20) if weather && !oldweather && rand(100)<weather[1]
        end
      end
    }
    
    
    
    # method to check whether the seasons are defined or not.
    def seasonsDefined
      return false if !defined?($PokemonGlobal)
      return false if !defined?($PokemonGlobal.season[0] ) 
      return false if !defined?($PokemonGlobal.season[0] ) 
      return true
    end
     
    Hello!

    To meet your request, here is a solution.
    Underneath "$PokemonGlobal.visitedMaps[$game_map.map_id]=true"I wrote "$game_screen.weather(0,0,0) if !$game_map || !pbGetMetadata($game_map.map_id,MetadataOutdoor)."
    On the other hand, I do not know how to do if I want to postpone the same time when it comes out of the map. (the script puts a random weather).

    (Sorry about my English).
     
    you'll want to check pbGetMetadata(mapid,MetadataOutdoor), as that pulls the "is an outdoor area?" metadata.
    I'm not too sure where you'd have to put this check, but that's half of it.

    Apparently I failed to do it with this method. Maybe I am too inexperienced.

    Hello!

    To meet your request, here is a solution.
    Underneath "$PokemonGlobal.visitedMaps[$game_map.map_id]=true"I wrote "$game_screen.weather(0,0,0) if !$game_map || !pbGetMetadata($game_map.map_id,MetadataOutdoor)."
    On the other hand, I do not know how to do if I want to postpone the same time when it comes out of the map. (the script puts a random weather).

    (Sorry about my English).

    This method did not work for me either and, yeah, in fact, using the CCOA climate script led me to generate random climates that did not correspond to the seasons of the year.

    The only method that I found was to do it with the SEASONS script by mixing it with common events and parallel processes to allow three times
    a day (one in the morning, one on the day and one in the afternoon) a variable that allows you to choose a random climate depending on the season of the year.

    I don't like so much this method considering that they are very few times a day when this variable is updated. I tried to do it with the character taking an X amount of steps, but
    I didn't know how to check it.

    Unfortunately, I think that the CCOA script does not work in EBS compatibility, so rain, for example, is not seen in combat.

    :C
     
    Back
    Top