SHARE
TWEET

BW Seasons Klein

Vendily Feb 10th, 2018 298 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #===============================================================================
  2. # € BW Seasons by KleinStudio
  3. #===============================================================================
  4.  
  5. #===============================================================================
  6. # € Months and seasons
  7. #===============================================================================
  8. #===============================================================================
  9. # * Variable number for fake season
  10. # * Enable or disable seasons
  11. # * Tilesets for seasons
  12. #    [Original tileset id, [Winter, Spring, Summer, Autumn]]
  13. #===============================================================================
  14. FAKESEASONVAR=26
  15. SEASONS=true
  16. SEASONSTILESETS = [
  17. [1, [2,3,4,5]] # Tileset id 1
  18. ]
  19.  
  20. JANUARY=1
  21. FEBRUARY=2
  22. MARCH=3
  23. APRIL=4
  24. MAY=5
  25. JUNE=6
  26. JULY=7
  27. AUGUST=8
  28. SEPTEMBER=9
  29. OCTOBER=10
  30. NOVEMBER=11
  31. DECEMBER=12
  32.  
  33. WINTER=1
  34. SPRING=2
  35. SUMMER=3
  36. AUTUMN=4
  37.  
  38. #===============================================================================
  39. # € Get current season
  40. #===============================================================================
  41. def pbGetSeason
  42.   if $game_variables[FAKESEASONVAR]!=0
  43.     @season=$game_variables[FAKESEASONVAR]
  44.   else
  45.    if Time.now.mon==DECEMBER or Time.now.mon==JANUARY or Time.now.mon==FEBRUARY
  46.     return WINTER
  47.    elsif Time.now.mon==MARCH or Time.now.mon==APRIL or Time.now.mon==MAY
  48.     return SPRING
  49.    elsif Time.now.mon==JUNE or Time.now.mon==JULY or Time.now.mon==AUGUST
  50.     return SUMMER
  51.    elsif Time.now.mon==SEPTEMBER or Time.now.mon==OCTOBER or Time.now.mon==NOVEMBER
  52.     return AUTUMN
  53.    end
  54.   end
  55. end
  56.  
  57. #===============================================================================
  58. # € Add season info to PokemonGlobal
  59. #===============================================================================
  60. class PokemonGlobalMetadata
  61.   attr_accessor :disablesplash
  62.   attr_accessor :season
  63.   attr_accessor :lastindoor
  64.   attr_accessor :lastseason
  65.  
  66.   def refreshSeason
  67.     oldseason=@season
  68.     @season=pbGetSeason
  69.   end
  70.    
  71.   def getSeason
  72.     @season=pbGetSeason if !@season
  73.     @lastseason=@season if @lastseason==nil
  74.     return @season if @season
  75.   end
  76.  
  77.   def getLastSeason
  78.     @lastseason=pbGetSeason if !@lastseason
  79.     return @lastseason if @lastseason
  80.   end
  81.  
  82.   def lastindoor?
  83.     return @lastindoor if @lastindoor
  84.   end
  85.  
  86. end
  87.  
  88. #===============================================================================
  89. # € Edit game_map
  90. #===============================================================================
  91. class Game_Map
  92.  
  93.   def setup(map_id)
  94.     @map_id = map_id
  95.     @map=load_data(sprintf("Data/Map%03d.%s", map_id,$RPGVX ? "rvdata" : "rxdata"))
  96.     pbRefreshSeason # Refresh actual season if needed
  97.     $lastmap=@map_id
  98.    
  99.     if SEASONS; for i in 0...SEASONSTILESETS.length
  100.       if SEASONSTILESETS[i][0]==@map.tileset_id
  101.        seasonsets=SEASONSTILESETS[i][1]
  102.        actualseason=$PokemonGlobal.getLastSeason
  103.        actualseason=$PokemonGlobal.getSeason if $PokemonGlobal.lastindoor?
  104.        actualseason=pbGetSeason if actualseason<1
  105.        echo("#{pbGetSeasonName(actualseason)}\n#{actualseason}")
  106.  
  107.        @map.tileset_id=seasonsets[actualseason-1]
  108.       end
  109.     end; end
  110.  
  111.     tileset = $data_tilesets[@map.tileset_id]
  112.     @tileset_name = tileset.tileset_name
  113.    
  114.     @autotile_names = tileset.autotile_names
  115.     @panorama_name = tileset.panorama_name
  116.     @panorama_hue = tileset.panorama_hue
  117.     @fog_name = tileset.fog_name
  118.     @fog_hue = tileset.fog_hue
  119.     @fog_opacity = tileset.fog_opacity
  120.     @fog_blend_type = tileset.fog_blend_type
  121.     @fog_zoom = tileset.fog_zoom
  122.     @fog_sx = tileset.fog_sx
  123.     @fog_sy = tileset.fog_sy
  124.     @battleback_name = tileset.battleback_name
  125.     @passages = tileset.passages
  126.     @priorities = tileset.priorities
  127.     @terrain_tags = tileset.terrain_tags
  128.     self.display_x = 0
  129.     self.display_y = 0
  130.     @need_refresh = false
  131.     Events.onMapCreate.trigger(self,map_id, @map, tileset)
  132.     @events = {}
  133.     for i in @map.events.keys
  134.       @events[i] = Game_Event.new(@map_id, @map.events[i],self)
  135.     end
  136.     @common_events = {}
  137.     for i in 1...$data_common_events.size
  138.       @common_events[i] = Game_CommonEvent.new(i)
  139.     end
  140.     @fog_ox = 0
  141.     @fog_oy = 0
  142.     @fog_tone = Tone.new(0, 0, 0, 0)
  143.     @fog_tone_target = Tone.new(0, 0, 0, 0)
  144.     @fog_tone_duration = 0
  145.     @fog_opacity_duration = 0
  146.     @fog_opacity_target = 0
  147.     @scroll_direction = 2
  148.     @scroll_rest = 0
  149.     @scroll_speed = 4
  150.    
  151.  
  152.   end
  153. end
  154.  
  155. #===============================================================================
  156. # € Internal functions
  157. #===============================================================================
  158.  
  159.    def pbShowSeasonSplash
  160.      return if !$Trainer or !$PokemonGlobal
  161.      return if $PokemonGlobal.disablesplash || !SEASONS
  162.      return if !$PokemonGlobal.lastindoor
  163.      return if $PokemonGlobal.lastseason==$PokemonGlobal.getSeason
  164.      current=pbGetSeasonName($PokemonGlobal.getSeason)
  165.      @black = Sprite.new
  166.      @black.bitmap = RPG::Cache.picture("blackscreen")
  167.      @black.z=9999999
  168.      @black.zoom_y=2.5
  169.      @season = Sprite.new
  170.      @season.bitmap = RPG::Cache.picture("season_"+current)
  171.      @season.opacity = 0
  172.      @season.z=9999999
  173.      Graphics.transition
  174.      20.times do
  175.      Graphics.update
  176.      @season.opacity+=25.5/2
  177.      end
  178.      Graphics.wait(60)
  179.      20.times do
  180.      Graphics.update
  181.      @season.opacity-=25.5/2
  182.      @black.opacity-=25.5/2
  183.      end
  184.      @black.dispose
  185.      @season.dispose
  186.      $PokemonGlobal.lastseason=$PokemonGlobal.getSeason
  187.      $PokemonGlobal.lastindoor=false
  188.    end
  189.    
  190.    def pbGetSeasonName(season)
  191.      case season
  192.      when 1
  193.      return "winter"
  194.      when 2
  195.      return "spring"
  196.      when 3
  197.      return "summer"
  198.      when 4
  199.      return "autumn"
  200.      end
  201.    end
  202.  
  203.    
  204.    def pbRefreshSeason # Only refresh when it's indoor
  205.      mapid=$lastmap ? $lastmap : $game_map.map_id
  206.      isoutdoor=pbGetMetadata(mapid,MetadataOutdoor)
  207.      if $game_map && (!isoutdoor or isoutdoor==false)
  208.        $PokemonGlobal.refreshSeason
  209.        $PokemonGlobal.lastindoor=true
  210.      end
  211.    end
  212.  
  213. #===============================================================================
  214. # € User functions
  215. #===============================================================================
  216.  
  217.    def pbDisableSeasonSplash # Disable season splash
  218.      $PokemonGlobal.disablesplash=true
  219.    end
  220.    
  221.    def pbEnableSeasonSplash # Enable seasons splash if disabled
  222.      $PokemonGlobal.disablesplash=false
  223.    end
  224.    
  225.    def makeWinter # Make winter
  226.      $game_variables[FAKESEASONVAR]=WINTER
  227.      $PokemonGlobal.refreshSeason
  228.    end
  229.    
  230.    def makeSpring # Make spring
  231.      $game_variables[FAKESEASONVAR]=SPRING
  232.      $PokemonGlobal.refreshSeason
  233.    end
  234.    
  235.    def makeSummer # Make summer
  236.      $game_variables[FAKESEASONVAR]=SUMMER
  237.      $PokemonGlobal.refreshSeason
  238.    end
  239.    
  240.    def makeAutumn # Make autumn
  241.      $game_variables[FAKESEASONVAR]=AUTUMN
  242.      $PokemonGlobal.refreshSeason
  243.    end
  244.    
  245.    def realSeason # Back to real season
  246.      $game_variables[FAKESEASONVAR]=0
  247.      $PokemonGlobal.refreshSeason
  248.    end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top