Compatibility: Rataime_Visual and Law's Custom Save System

Okay, I generally try for a couple of days to fix problems (including surfing boards for solutions) before I ask for help, but I cannot seem to find a solution to this problem either on my own, or with another's help. I am using Rataime_Visual (Shadows, Sun, Reflections, Mirrors, and Destruction Engine), along with Law's Custom Save System. Everything works fine when I play a New Game, do any of the visual effects, and even when I save a game. The moment I go to load a game, I get this error:

Script 'Sprite Shadow' line 304: NoMethodError occurred.

undefined method 'shadows' for nil:NilClass


If I remove the 'Sprite Shadow' Script, I get the same error for Sun, but with Line 239. If I remove Sun, it will work, but I effectively cannot have shadows in my game. It all points to the same 'line':

if character.is_a?(Game_Event) and $game_temp.shadow_spriteset.shadows != [] for Shadows

if character.is_a?(Game_Event) and $game_temp.sun_spriteset.sun != [] for Sun

I'm not a n00b with RGSS, but I'm no expert. I suspect that it's the way that the Custom Save System handles the sprites it imports into the 'screenshot'. I don't know how to fix this problem. Any help, even just pointing in the right direction, would be appreciated.

Here is Law's Save System, just in case:
Content Hidden Spoiler
  1. #------------------------------------------------------------------------------
  2. #==============================================================================
  3. #==============================================================================
  4. #======================*Law's Custom Save System*==============================
  5. #=========================Author: The Law G14==================================
  6. #============================Version 1.1=======================================
  7. #==============================================================================
  8. #------------------------------------------------------------------------------
  9.  
  10. #==============================================================================
  11. # ** Module_Customization
  12. #------------------------------------------------------------------------------
  13. #  This module contains all the customization for the script
  14. #==============================================================================
  15.  
  16. module Customization
  17.  
  18.   #----------------------------------------------------------------------------
  19.   # * Config Begin
  20.   #----------------------------------------------------------------------------
  21.  
  22.   # Here you can change the number of save slots that will be in your game
  23.   SLOTS = 8
  24.   # Here you can change the name of the text in the save slots
  25.   SLOT_NAME = "Slot"
  26.  
  27.   # Here you can change what icon will appear next to a filename that isn't empty
  28.   SLOT_ICON_SELECTED = "Keyblade1"
  29.   # Here you can change what icon will appear next to a filename that is empty
  30.   SLOT_ICON_UNSELECTED = "Keyblade2"
  31.  
  32.   # Draw Gold
  33.   DRAW_GOLD = true
  34.   # Draw Playtime
  35.   DRAW_PLAYTIME = true
  36.   # Draw location
  37.   DRAW_LOCATION = true
  38.   # Draw Actor's face
  39.   DRAW_FACE = true
  40.   # Draw Actor's name
  41.   DRAW_NAME = true
  42.    
  43.   # Text inside file info window when empty
  44.   EMPTY_SLOT_TEXT = "~EMPTY~"
  45.  
  46.   # Playtime Text
  47.   PLAYTIME_TEXT = "Play Time: "
  48.   # Gold Text
  49.   GOLD_TEXT = "Money: "
  50.   # Location Text
  51.   LOCATION_TEXT = "Location: "
  52.  
  53.   # Map image border color (R,G,B,Opacity)
  54.   MAP_BORDER = Color.new(0,0,0,200)
  55.  
  56.   # Text for help window when saving. Ex: "Which file would you like to save to?"
  57.   SAVE_TEXT = "Which file would you like to save to?"
  58.   # Text for help window when loading. Ex: "Which file would you like to load?"
  59.   LOAD_TEXT = "Which file would you like to load?"
  60.  
  61.   # All windows' opacity (Lowest 0 - 255 Highest)
  62.   # Use low opacity when having a background.
  63.   WINDOW_OPACITY = 200
  64.   # Background image file name, it must be in the pictures folder.
  65.   # Put '' if you don't want a background.
  66.   BACKGROUND_IMAGE = 'KingdomHeartsTitle'
  67.   # Opacity for background image
  68.   BACKGROUND_IMAGE_OPACITY = 255
  69.    
  70.   #----------------------------------------------------------------------------
  71.   # * Config End
  72.   #----------------------------------------------------------------------------
  73.  
  74. end
  75.  
  76.  
  77. #==============================================================================
  78. # ** Game_Map
  79. #------------------------------------------------------------------------------
  80. #  This class handles the map. It includes scrolling and passable determining
  81. #  functions. Refer to "$game_map" for the instance of this class.
  82. #==============================================================================
  83.  
  84. class Game_Map
  85.   #--------------------------------------------------------------------------
  86.   # * Public Instance Variables
  87.   #--------------------------------------------------------------------------
  88.   attr_reader   :name
  89.   #--------------------------------------------------------------------------
  90.   # * Alias Listing
  91.   #--------------------------------------------------------------------------
  92.   alias law_css_setup setup
  93.   #--------------------------------------------------------------------------
  94.   # * Setup
  95.   #     map_id : map ID
  96.   #--------------------------------------------------------------------------
  97.   def setup(*args)
  98.     # Run the original setup
  99.     law_css_setup(*args)
  100.     # Load the name of the map
  101.     @name = load_data("Data/MapInfos.rxdata")[@map_id].name
  102.   end
  103. end
  104.  
  105.  
  106.  
  107. #==============================================================================
  108. # ** Spriteset_Map_Loading_Preview
  109. #------------------------------------------------------------------------------
  110. #  This class brings together map screen sprites, tilemaps, etc for the
  111. #   loading screen's preview.
  112. #==============================================================================
  113.  
  114. class Spriteset_Map_Loading_Preview
  115.   #--------------------------------------------------------------------------
  116.   # * Invariables
  117.   #--------------------------------------------------------------------------
  118.   RES_WIDTH =  352  # Please insert a number divisible by 32
  119.   RES_HEIGHT = 160   # Please insert a number divisible by 32
  120.   TOP_CORNER_X = 201
  121.   TOP_CORNER_Y = 120
  122.   #--------------------------------------------------------------------------
  123.   # * Object Initialization
  124.   #--------------------------------------------------------------------------
  125.   def initialize
  126.     center
  127.     # Make viewports
  128.     @viewport1 = Viewport.new(TOP_CORNER_X, TOP_CORNER_Y, RES_WIDTH, RES_HEIGHT)
  129.     @viewport2 = Viewport.new(TOP_CORNER_X, TOP_CORNER_Y, RES_WIDTH, RES_HEIGHT)
  130.     @viewport3 = Viewport.new(TOP_CORNER_X, TOP_CORNER_Y, RES_WIDTH, RES_HEIGHT)
  131.     @viewport1.z = 9200
  132.     @viewport2.z = 9200
  133.     @viewport3.z = 95000
  134.     # Make tilemap
  135.     @tilemap = Tilemap.new(@viewport1)
  136.     @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
  137.     for i in 0..6
  138.       autotile_name = $game_map.autotile_names[i]
  139.       @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
  140.     end
  141.     @tilemap.map_data = $game_map.data
  142.     @tilemap.priorities = $game_map.priorities
  143.     # Make panorama plane
  144.     @panorama = Plane.new(@viewport1)
  145.     @panorama.z = -1000
  146.     # Make fog plane
  147.     @fog = Plane.new(@viewport1)
  148.     @fog.z = 3000
  149.     # Make character sprites
  150.     @character_sprites = []
  151.     for i in $game_map.events.keys.sort
  152.       sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
  153.       @character_sprites.push(sprite)
  154.     end
  155.     @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
  156.     # Make weather
  157.     @weather = RPG::Weather.new(@viewport1)
  158.     # Make picture sprites
  159.     @picture_sprites = []
  160.     for i in 1..50
  161.       @picture_sprites.push(Sprite_Picture.new(@viewport2,
  162.         $game_screen.pictures[i]))
  163.     end
  164.     # Make timer sprite
  165.     @timer_sprite = Sprite_Timer.new
  166.     # Frame update
  167.     update
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # * Dispose
  171.   #--------------------------------------------------------------------------
  172.   def dispose
  173.     # Dispose of tilemap
  174.     @tilemap.tileset.dispose
  175.     for i in 0..6
  176.       @tilemap.autotiles[i].dispose
  177.     end
  178.     @tilemap.dispose
  179.     # Dispose of panorama plane
  180.     @panorama.dispose
  181.     # Dispose of fog plane
  182.     @fog.dispose
  183.     # Dispose of character sprites
  184.     for sprite in @character_sprites
  185.       sprite.dispose
  186.     end
  187.     # Dispose of weather
  188.     @weather.dispose
  189.     # Dispose of picture sprites
  190.     for sprite in @picture_sprites
  191.       sprite.dispose
  192.     end
  193.     # Dispose of timer sprite
  194.     @timer_sprite.dispose
  195.     # Dispose of viewports
  196.     @viewport1.dispose
  197.     @viewport2.dispose
  198.     @viewport3.dispose
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # * Frame Update
  202.   #--------------------------------------------------------------------------
  203.   def update
  204.     center
  205.     # If panorama is different from current one
  206.     if @panorama_name != $game_map.panorama_name or
  207.        @panorama_hue != $game_map.panorama_hue
  208.       @panorama_name = $game_map.panorama_name
  209.       @panorama_hue = $game_map.panorama_hue
  210.       if @panorama.bitmap != nil
  211.         @panorama.bitmap.dispose
  212.         @panorama.bitmap = nil
  213.       end
  214.       if @panorama_name != ""
  215.         @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  216.       end
  217.       Graphics.frame_reset
  218.     end
  219.     # If fog is different than current fog
  220.     if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
  221.       @fog_name = $game_map.fog_name
  222.       @fog_hue = $game_map.fog_hue
  223.       if @fog.bitmap != nil
  224.         @fog.bitmap.dispose
  225.         @fog.bitmap = nil
  226.       end
  227.       if @fog_name != ""
  228.         @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  229.       end
  230.       Graphics.frame_reset
  231.     end
  232.     # Update tilemap
  233.     @tilemap.ox = $game_map.display_x / 4
  234.     @tilemap.oy =  $game_map.display_y / 4
  235.     @tilemap.update
  236.     # Update panorama plane
  237.     @panorama.ox =  $game_map.display_x / 8
  238.     @panorama.oy =  $game_map.display_y / 8
  239.     # Update fog plane
  240.     @fog.zoom_x = $game_map.fog_zoom / 100.0
  241.     @fog.zoom_y = $game_map.fog_zoom / 100.0
  242.     @fog.opacity = $game_map.fog_opacity
  243.     @fog.blend_type = $game_map.fog_blend_type
  244.     @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
  245.     @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
  246.     @fog.tone = $game_map.fog_tone
  247.     # Update character sprites
  248.     for sprite in @character_sprites
  249.       sprite.update
  250.     end
  251.     # Update weather graphic
  252.     @weather.type = $game_screen.weather_type
  253.     @weather.max = $game_screen.weather_max
  254.     @weather.ox = $game_map.display_x / 4
  255.     @weather.oy = $game_map.display_y / 4
  256.     @weather.update
  257.     # Update picture sprites
  258.     for sprite in @picture_sprites
  259.       sprite.update
  260.     end
  261.     # Update timer sprite
  262.     @timer_sprite.update
  263.     # Set screen color tone and shake position
  264.     @viewport1.tone = $game_screen.tone
  265.     @viewport1.ox = $game_screen.shake
  266.     # Set screen flash color
  267.     @viewport3.color = $game_screen.flash_color
  268.     # Update viewports
  269.     @viewport1.update
  270.     @viewport3.update
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # * Set Map Display Position to Center of Screen
  274.   #--------------------------------------------------------------------------
  275.   def center
  276.     x = $game_player.real_x
  277.     y = $game_player.real_y
  278.     max_x = [($game_map.width - RES_WIDTH / 32) * 128, RES_WIDTH].max
  279.     max_y = [($game_map.height - RES_HEIGHT / 32) * 128, RES_HEIGHT].max
  280.     center_x = (RES_WIDTH/2 - 16) * 4   # Center screen x-coordinate * 4
  281.     center_y = (RES_HEIGHT/2 - 16) * 4   # Center screen y-coordinate * 4
  282.     $game_map.display_x = [0, [x - center_x, max_x].min].max
  283.     $game_map.display_y = [0, [y - center_y, max_y].min].max
  284.     $game_map.refresh
  285.   end
  286. end
  287.  
  288.  
  289.  
  290. #==============================================================================
  291. # ** Window_SaveFile
  292. #------------------------------------------------------------------------------
  293. #  This window displays save files on the save and load screens.
  294. #==============================================================================
  295.  
  296. class Window_SaveFile < Window_Base
  297.   #--------------------------------------------------------------------------
  298.   # * Public Instance Variables
  299.   #--------------------------------------------------------------------------
  300.   attr_reader   :filename                 # file name
  301.   attr_reader   :selected                 # selected
  302.   #--------------------------------------------------------------------------
  303.   # * Object Initialization
  304.   #     file_index : save file index (0-3)
  305.   #     filename   : file name
  306.   #--------------------------------------------------------------------------
  307.   def initialize(file_index, filename, position)
  308.     super(0, 64 + position * 52, 115, 52)
  309.     self.contents = Bitmap.new(width - 32, height - 32)
  310.     @file_index = file_index
  311.     @filename = Customization::SLOT_NAME + "#{@file_index + 1}.rxdata"
  312.     @time_stamp = Time.at(0)
  313.     @file_exist = FileTest.exist?(@filename)
  314.     if @file_exist
  315.       file = File.open(@filename, "r")
  316.       @time_stamp = file.mtime
  317.       @characters = Marshal.load(file)
  318.       @frame_count = Marshal.load(file)
  319.       @game_system = Marshal.load(file)
  320.       @game_switches = Marshal.load(file)
  321.       @game_variables = Marshal.load(file)
  322.       @total_sec = @frame_count / Graphics.frame_rate
  323.       file.close
  324.     end
  325.     refresh
  326.     @selected = false
  327.   end
  328.   #--------------------------------------------------------------------------
  329.   # * Refresh
  330.   #--------------------------------------------------------------------------
  331.   def refresh
  332.     self.contents.clear
  333.     if @file_exist
  334.       # Draw file number
  335.       self.contents.font.color = normal_color
  336.       bitmap = RPG::Cache.icon(Customization::SLOT_ICON_SELECTED)
  337.       @opacity = 255
  338.     else
  339.       self.contents.font.color = disabled_color
  340.       bitmap = RPG::Cache.icon(Customization::SLOT_ICON_UNSELECTED)
  341.       @opacity = 100
  342.     end
  343.     name = Customization::SLOT_NAME + "#{@file_index + 1}"
  344.     self.contents.draw_text(20, -7, 600, 32, name)
  345.     @name_width = contents.text_size(name).width
  346.     self.contents.fill_rect(0, -2, 10, 32, Color.new(0, 0, 0, 0))
  347.     self.contents.blt(0, -2, bitmap, Rect.new(0, 0, 24, 24), opacity)
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # * Set Selected
  351.   #     selected : new selected (true = selected, false = unselected)
  352.   #--------------------------------------------------------------------------
  353.   def selected=(selected)
  354.     @selected = selected
  355.     update_cursor_rect
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # * Cursor Rectangle Update
  359.   #--------------------------------------------------------------------------
  360.   def update_cursor_rect
  361.     if @selected
  362.       self.cursor_rect.set(0, -7, @name_width + 38, 32)
  363.     else
  364.       self.cursor_rect.empty
  365.     end
  366.   end
  367. end
  368.  
  369.  
  370.  
  371. #==============================================================================
  372. # ** Window_FileInfo
  373. #------------------------------------------------------------------------------
  374. #  This window displays file information.
  375. #==============================================================================
  376.  
  377. class Window_FileInfo < Window_Base
  378.   #--------------------------------------------------------------------------
  379.   # * Alias Listing
  380.   #--------------------------------------------------------------------------
  381.   if @law_save_resume_done_before.nil?
  382.     alias nr_dispose dispose
  383.     @law_save_resume_done_before = true
  384.   end
  385.   #--------------------------------------------------------------------------
  386.   # * Object Initialization
  387.   #--------------------------------------------------------------------------
  388.   def initialize
  389.     super(115, 64, 525, 416)
  390.     self.contents = Bitmap.new(width - 32, height - 32)
  391.     refresh($game_temp.last_file_index)
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # * Refresh
  395.   #--------------------------------------------------------------------------
  396.   def refresh(file_index)
  397.     self.contents.clear
  398.     @spriteset.dispose unless @spriteset.nil?
  399.     @spriteset = nil
  400.     @file_index = file_index
  401.     @filename = Customization::SLOT_NAME + "#{@file_index + 1}.rxdata"
  402.     @file_exist = FileTest.exist?(@filename)
  403.     save_data = Customization::SLOTS
  404.     # If save file exists
  405.     if @file_exist
  406.       file = File.open(@filename, "rb")
  407.       $time_stamp =        file.mtime
  408.       $characters =        Marshal.load(file)
  409.       @frame_count =       Marshal.load(file)
  410.       $game_system = Marshal.load(file)
  411.       $game_switches = Marshal.load(file)
  412.       $game_variables = Marshal.load(file)
  413.       $game_self_switches =  Marshal.load(file)
  414.       $game_screen = Marshal.load(file)
  415.       $game_actors = Marshal.load(file)
  416.       $game_party = Marshal.load(file)
  417.       $game_troop = Marshal.load(file)
  418.       $game_map = Marshal.load(file)
  419.       $game_player = Marshal.load(file)
  420.       file.close
  421.       @total_sec = @frame_count / Graphics.frame_rate
  422.       # Draw Screenshot
  423.       begin
  424.         width = 352 + 4
  425.         height = 160 + 4
  426.         x = (self.width - 32 - width) / 2
  427.         y = 54 - 16
  428.         self.contents.fill_rect(x, y, width, height, Customization::MAP_BORDER)
  429.         @spriteset = Spriteset_Map_Loading_Preview.new
  430.       end
  431.       # Draw Gold
  432.       if Customization::DRAW_GOLD
  433.         cx = contents.text_size($data_system.words.gold).width
  434.         self.contents.font.color = normal_color
  435.         self.contents.font.size = 25
  436.         self.contents.draw_text(40, 0, 140, 32, $game_party.gold.to_s, 2)
  437.         self.contents.font.color = system_color
  438.         self.contents.draw_text(140, 0, 100, 32, $data_system.words.gold, 2)
  439.         self.contents.draw_text(-20, -1, 100, 32, Customization::GOLD_TEXT, 2)  
  440.       end
  441.       # Draw actor face
  442.       if Customization::DRAW_FACE
  443.         for i in 0...$game_party.actors.size
  444.           actor = $game_party.actors[i]
  445.           draw_actor_face_graphic(actor, i*129, 250)
  446.         end  
  447.       end
  448.       # Draw actor name
  449.       if Customization::DRAW_NAME
  450.         for i in 0...$game_party.actors.size
  451.           self.contents.font.color = system_color
  452.           self.contents.font.size = 25
  453.           actor = $game_party.actors[i]
  454.           draw_actor_name(actor, (i*130) + 25, 350)
  455.         end
  456.       end
  457.       # Draw play time
  458.       if Customization::DRAW_PLAYTIME
  459.         hour = @total_sec / 60 / 60
  460.         min = @total_sec / 60 % 60
  461.         sec = @total_sec % 60
  462.         time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  463.         self.contents.font.color = normal_color
  464.         self.contents.font.size = 25
  465.         self.contents.draw_text(380, 0, 100, 32, time_string, 2)
  466.         self.contents.font.color = system_color
  467.         time_string = Customization::PLAYTIME_TEXT
  468.         self.contents.draw_text(230, 0, 150, 32, time_string, 2)
  469.       end
  470.       # Draw Location
  471.       if Customization::DRAW_LOCATION
  472.         self.contents.font.color = system_color
  473.         self.contents.font.size = 25
  474.         self.contents.draw_text(4, 210, 120, 32, Customization::LOCATION_TEXT)
  475.         self.contents.font.color = normal_color
  476.         x = (Customization::LOCATION_TEXT.length * 10) + 5
  477.         self.contents.draw_text(x, 210, 120, 32, $game_map.name.to_s, 2)
  478.       end
  479.     else
  480.       self.contents.draw_text(-20, 50, self.contents.width, self.contents.height - 200, Customization::EMPTY_SLOT_TEXT, 1)
  481.     end
  482.   end
  483.   #--------------------------------------------------------------------------
  484.   # * Draw Actor Face Graphic
  485.   #--------------------------------------------------------------------------
  486.   def draw_actor_face_graphic(actor, x, y)
  487.     bitmap = RPG::Cache.picture(actor.id.to_s)
  488.     self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # * Dispose Window
  492.   #--------------------------------------------------------------------------
  493.   def dispose(*args)
  494.     nr_dispose(*args)
  495.     @spriteset.dispose unless @spriteset.nil?
  496.     @spriteset = nil
  497.   end
  498. end
  499.  
  500.  
  501.  
  502. #==============================================================================
  503. # ** Scene_File
  504. #------------------------------------------------------------------------------
  505. #  This is a superclass for the save screen and load screen.
  506. #==============================================================================
  507.  
  508. class Scene_File
  509.   #--------------------------------------------------------------------------
  510.   # * Invariables
  511.   #--------------------------------------------------------------------------
  512.   CENTER_X = (320 - 16) * 4   # Center screen x-coordinate * 4
  513.   CENTER_Y = (240 - 16) * 4   # Center screen y-coordinate * 4
  514.   #--------------------------------------------------------------------------
  515.   # * Object Initialization
  516.   #     help_text : text string shown in the help window
  517.   #--------------------------------------------------------------------------
  518.   def initialize(help_text)
  519.     @help_text = help_text
  520.   end
  521.   #--------------------------------------------------------------------------
  522.   # * Main Processing
  523.   #--------------------------------------------------------------------------
  524.   def main
  525.     @cursor_displace = 0
  526.     # Make help window
  527.     @help_window = Window_Help.new
  528.     @help_window.set_text(@help_text)
  529.     @help_window.opacity = Customization::WINDOW_OPACITY
  530.     # Make save file window
  531.     @savefile_windows = []
  532.     for i in 0..Customization::SLOTS - 1
  533.       @savefile_windows.push(Window_SaveFile.new(i, make_filename(i), i))
  534.     end
  535.     # Select last file to be operated
  536.     @file_index = $game_temp.last_file_index
  537.     @savefile_windows[@file_index].selected = true
  538.     for i in @savefile_windows
  539.       i.opacity = Customization::WINDOW_OPACITY
  540.     end
  541.     # Make FileInfo window
  542.     @fileinfo_window = Window_FileInfo.new
  543.     @fileinfo_window.opacity = Customization::WINDOW_OPACITY
  544.     # Make background
  545.     @sprite = Sprite.new
  546.     @sprite.bitmap = RPG::Cache.picture(Customization::BACKGROUND_IMAGE)
  547.     # Execute transition
  548.     Graphics.transition
  549.     # Main loop
  550.     loop do
  551.       # Update game screen
  552.       Graphics.update
  553.       # Update input information
  554.       Input.update
  555.       # Frame update
  556.       update
  557.       # Abort loop if screen is changed
  558.       if $scene != self
  559.         break
  560.       end
  561.     end
  562.     # Prepare for transition
  563.     Graphics.freeze
  564.     # Dispose of windows
  565.     @help_window.dispose
  566.     for i in @savefile_windows
  567.       i.dispose
  568.     end
  569.     @fileinfo_window.dispose
  570.     @sprite.dispose
  571.     @sprite.bitmap.dispose
  572.    # $game_player.center($game_player.x, $game_player.y)
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # * Frame Update
  576.   #--------------------------------------------------------------------------
  577.   def update
  578.     # Update windows
  579.     @help_window.update
  580.     @fileinfo_window.update
  581.     for i in @savefile_windows
  582.       i.update
  583.     end    
  584.     # If C button was pressed
  585.     if Input.trigger?(Input::C)
  586.       # Call method: on_decision (defined by the subclasses)
  587.       on_decision(make_filename(@file_index))
  588.       $game_temp.last_file_index = @file_index
  589.       @fileinfo_window.refresh(@file_index)
  590.       center
  591.       return
  592.     end
  593.     # If B button was pressed
  594.     if Input.trigger?(Input::B)
  595.       # Call method: on_cancel (defined by the subclasses)
  596.       on_cancel
  597.       return
  598.     end
  599.     # If the down directional button was pressed
  600.     if Input.repeat?(Input::DOWN)
  601.       if Input.trigger?(Input::DOWN) or @file_index < Customization::SLOTS - 1
  602.       if @file_index == Customization::SLOTS - 1
  603.         $game_system.se_play($data_system.buzzer_se)
  604.         return
  605.       end
  606.       @cursor_displace = @file_index
  607.       @cursor_displace += 1
  608.       if @cursor_displace == 8
  609.         @cursor_displace = 7
  610.         for i in @savefile_windows
  611.         i.dispose
  612.         end
  613.         @savefile_windows = []
  614.         for i in 0..Customization::SLOTS
  615.         f = i - 6 + @file_index
  616.         name = make_filename(f)
  617.         @savefile_windows.push(Window_SaveFile.new(f, name, i))
  618.         @savefile_windows[i].selected = false
  619.         end
  620.       end
  621.       $game_system.se_play($data_system.cursor_se)
  622.       @file_index = (@file_index + 1)
  623.       if @file_index == 8
  624.         @file_index = 7
  625.       end
  626.       for i in 0..Customization::SLOTS - 1
  627.         @savefile_windows[i].selected = false
  628.       end
  629.       @savefile_windows[@cursor_displace].selected = true
  630.       @fileinfo_window.refresh(@file_index)
  631.       return
  632.       end
  633.     end
  634.     # If the up directional button was pressed
  635.     if Input.repeat?(Input::UP)
  636.       if Input.trigger?(Input::UP) or @file_index > 0
  637.       if @file_index == 0
  638.         $game_system.se_play($data_system.buzzer_se)
  639.         return
  640.       end
  641.       @cursor_displace = @file_index
  642.       @cursor_displace -= 1
  643.       if @cursor_displace == -1
  644.         @cursor_displace = 0
  645.         for i in @savefile_windows
  646.         i.dispose
  647.         end
  648.         @savefile_windows = []
  649.         for i in 0..Customization::SLOTS
  650.         f = i - 1 + @file_index
  651.         name = make_filename(f)
  652.         @savefile_windows.push(Window_SaveFile.new(f, name, i))
  653.         @savefile_windows[i].selected = false
  654.         end
  655.       end
  656.       $game_system.se_play($data_system.cursor_se)
  657.       @file_index = (@file_index - 1)
  658.       if @file_index == -1
  659.         @file_index = 0
  660.       end
  661.       for i in 0..Customization::SLOTS - 1
  662.         @savefile_windows[i].selected = false
  663.       end
  664.       @savefile_windows[@cursor_displace].selected = true
  665.       @fileinfo_window.refresh(@file_index)
  666.       return
  667.       end
  668.     end
  669.   end
  670.   #--------------------------------------------------------------------------
  671.   # * Make File Name
  672.   #     file_index : save file index (0-3)
  673.   #--------------------------------------------------------------------------
  674.   def make_filename(file_index)
  675.     return Customization::SLOT_NAME + "#{file_index + 1}.rxdata"
  676.   end
  677.   #--------------------------------------------------------------------------
  678.   # * Backup Data
  679.   #--------------------------------------------------------------------------
  680.   def backup_data
  681.     @nr_game_system = $game_system.clone
  682.     @nr_game_switches = $game_switches.clone
  683.     @nr_game_variables = $game_variables.clone
  684.     @nr_game_self_switches = $game_self_switches.clone
  685.     @nr_game_screen = $game_screen.clone
  686.     @nr_game_actors = $game_actors.clone
  687.     @nr_game_party = $game_party.clone
  688.     @nr_game_troop = $game_troop.clone
  689.     @nr_game_map = $game_map.clone
  690.     @nr_game_player = $game_player.clone
  691.   end
  692.   #--------------------------------------------------------------------------
  693.   # * Load Backup Data
  694.   #--------------------------------------------------------------------------
  695.   def load_backup_data
  696.     $game_system = @nr_game_system.clone
  697.     $game_switches = @nr_game_switches.clone
  698.     $game_variables = @nr_game_variables.clone
  699.     $game_self_switches = @nr_game_self_switches.clone
  700.     $game_screen = @nr_game_screen.clone
  701.     $game_actors = @nr_game_actors.clone
  702.     $game_party = @nr_game_party.clone
  703.     $game_troop = @nr_game_troop.clone
  704.     $game_map = @nr_game_map.clone
  705.     $game_player = @nr_game_player.clone
  706.   end
  707.   #--------------------------------------------------------------------------
  708.   # * Set Map Display Position to Center of Screen
  709.   #--------------------------------------------------------------------------
  710.   def center
  711.     max_x = ($game_map.width - 20) * 128
  712.     max_y = ($game_map.height - 15) * 128
  713.     x = $game_player.x
  714.     y = $game_player.y
  715.     $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
  716.     $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
  717.   end
  718. end
  719.  
  720.  
  721.  
  722. #==============================================================================
  723. # ** Scene_Save
  724. #------------------------------------------------------------------------------
  725. #  This class performs save screen processing.
  726. #==============================================================================
  727.  
  728. class Scene_Save < Scene_File
  729.   #--------------------------------------------------------------------------
  730.   # * Alias Listing
  731.   #--------------------------------------------------------------------------
  732.   alias law_css_scene_save_initialize initialize
  733.   alias nr_css_scene_save_on_cancel on_cancel
  734.   alias nr_css_scene_save_on_desision on_decision
  735.   #--------------------------------------------------------------------------
  736.   # * Object Initialization
  737.   #--------------------------------------------------------------------------
  738.   def initialize(*args)
  739.     backup_data
  740.     law_css_scene_save_initialize(*args)
  741.     super(Customization::SAVE_TEXT)
  742.   end
  743.   #--------------------------------------------------------------------------
  744.   # * On Decision
  745.   #--------------------------------------------------------------------------
  746.   def on_decision(*args)
  747.     load_backup_data
  748.     nr_css_scene_save_on_desision(*args)
  749.     center
  750.   end
  751.   #--------------------------------------------------------------------------
  752.   # * On Decision
  753.   #--------------------------------------------------------------------------
  754.   def on_cancel(*args)
  755.     load_backup_data
  756.     nr_css_scene_save_on_cancel(*args)
  757.   end
  758. end
  759.  
  760.  
  761.  
  762. #==============================================================================
  763. # ** Scene_Load
  764. #------------------------------------------------------------------------------
  765. #  This class performs load screen processing.
  766. #==============================================================================
  767.  
  768. class Scene_Load < Scene_File
  769.  
  770.   #--------------------------------------------------------------------------
  771.   # * Alias Listing
  772.   #--------------------------------------------------------------------------
  773.   if @nr_css_done_before.nil?
  774.     alias law_css_scene_load_initialize initialize
  775.     @nr_css_done_before = true
  776.   end
  777.   #--------------------------------------------------------------------------
  778.   # * Object Initialization
  779.   #--------------------------------------------------------------------------
  780.   def initialize(*args)
  781.     law_css_scene_load_initialize(*args)
  782.     super(Customization::LOAD_TEXT)
  783.   end
  784. end
  785.  
  786.  
  787.  
  788. #==============================================================================
  789. # ** Scene_Title
  790. #------------------------------------------------------------------------------
  791. #  This class performs title screen processing.
  792. #==============================================================================
  793.  
  794. class Scene_Title
  795.   #--------------------------------------------------------------------------
  796.   # * Main Processing
  797.   #--------------------------------------------------------------------------
  798.   def main
  799.     # If battle test
  800.     if $BTEST
  801.       battle_test
  802.       return
  803.     end
  804.     # Load database
  805.     $data_actors        = load_data("Data/Actors.rxdata")
  806.     $data_classes       = load_data("Data/Classes.rxdata")
  807.     $data_skills        = load_data("Data/Skills.rxdata")
  808.     $data_items         = load_data("Data/Items.rxdata")
  809.     $data_weapons       = load_data("Data/Weapons.rxdata")
  810.     $data_armors        = load_data("Data/Armors.rxdata")
  811.     $data_enemies       = load_data("Data/Enemies.rxdata")
  812.     $data_troops        = load_data("Data/Troops.rxdata")
  813.     $data_states        = load_data("Data/States.rxdata")
  814.     $data_animations    = load_data("Data/Animations.rxdata")
  815.     $data_tilesets      = load_data("Data/Tilesets.rxdata")
  816.     $data_common_events = load_data("Data/CommonEvents.rxdata")
  817.     $data_system        = load_data("Data/System.rxdata")
  818.     # Make system object
  819.     $game_system = Game_System.new
  820.     # Make title graphic
  821.     @sprite = Sprite.new
  822.     @sprite.bitmap = RPG::Cache.title($data_system.title_name)
  823.     # Make command window
  824.     s1 = "New Game"
  825.     s2 = "Continue"
  826.     s3 = "Shutdown"
  827.     @command_window = Window_Command.new(192, [s1, s2, s3])
  828.     @command_window.back_opacity = 160
  829.     @command_window.x = 320 - @command_window.width / 2
  830.     @command_window.y = 288
  831.     # Continue enabled determinant
  832.     # Check if at least one save file exists
  833.     # If enabled, make @continue_enabled true; if disabled, make it false
  834.     @continue_enabled = false
  835.     for i in 0..Customization::SLOTS
  836.       if FileTest.exist?(Customization::SLOT_NAME + "#{i + 1}.rxdata")
  837.         @continue_enabled = true
  838.       end
  839.     end
  840.     # If continue is enabled, move cursor to "Continue"
  841.     # If disabled, display "Continue" text in gray
  842.     if @continue_enabled
  843.       @command_window.index = 1
  844.     else
  845.       @command_window.disable_item(1)
  846.     end
  847.     # Play title BGM
  848.     $game_system.bgm_play($data_system.title_bgm)
  849.     # Stop playing ME and BGS
  850.     Audio.me_stop
  851.     Audio.bgs_stop
  852.     # Execute transition
  853.     Graphics.transition
  854.     # Main loop
  855.     loop do
  856.       # Update game screen
  857.       Graphics.update
  858.       # Update input information
  859.       Input.update
  860.       # Frame update
  861.       update
  862.       # Abort loop if screen is changed
  863.       if $scene != self
  864.         break
  865.       end
  866.     end
  867.     # Prepare for transition
  868.     Graphics.freeze
  869.     # Dispose of command window
  870.     @command_window.dispose
  871.     # Dispose of title graphic
  872.     @sprite.bitmap.dispose
  873.     @sprite.dispose
  874.   end
  875. end
Expand to see the code.


Thanks in advance!
Following the rule and bumping after 72 hours. I'm still unable to solve this one on my own and it's a little on the frustrating side. Any help from anyone, even if it's just pointing me in a direction May not have looked at previously, would be great. Thanks!
*points you in the right direction.*

Before ANYONE can help you, you need to post BOTH scripts in here, not just one. Nobody's willing to go completely out of their way to help you by frantically searching the web for the missing script. Once you have done that, then I'll look at it.
My sincerest apologies. Here you go:

  1. #------------------------------------------------------------------------------
  2. #==============================================================================
  3. #==============================================================================
  4. #======================*Law's Custom Save System*==============================
  5. #=========================Author: The Law G14==================================
  6. #============================Version 1.1=======================================
  7. #==============================================================================
  8. #------------------------------------------------------------------------------
  9.  
  10. #==============================================================================
  11. # ** Module_Customization
  12. #------------------------------------------------------------------------------
  13. #  This module contains all the customization for the script
  14. #==============================================================================
  15.  
  16. module Customization
  17.  
  18.   #----------------------------------------------------------------------------
  19.   # * Config Begin
  20.   #----------------------------------------------------------------------------
  21.  
  22.   # Here you can change the number of save slots that will be in your game
  23.   SLOTS = 8
  24.   # Here you can change the name of the text in the save slots
  25.   SLOT_NAME = "Slot"
  26.  
  27.   # Here you can change what icon will appear next to a filename that isn't empty
  28.   SLOT_ICON_SELECTED = "Keyblade1"
  29.   # Here you can change what icon will appear next to a filename that is empty
  30.   SLOT_ICON_UNSELECTED = "Keyblade2"
  31.  
  32.   # Draw Gold
  33.   DRAW_GOLD = true
  34.   # Draw Playtime
  35.   DRAW_PLAYTIME = true
  36.   # Draw location
  37.   DRAW_LOCATION = true
  38.   # Draw Actor's face
  39.   DRAW_FACE = true
  40.   # Draw Actor's name
  41.   DRAW_NAME = true
  42.    
  43.   # Text inside file info window when empty
  44.   EMPTY_SLOT_TEXT = "~EMPTY~"
  45.  
  46.   # Playtime Text
  47.   PLAYTIME_TEXT = "Play Time: "
  48.   # Gold Text
  49.   GOLD_TEXT = "Money: "
  50.   # Location Text
  51.   LOCATION_TEXT = "Location: "
  52.  
  53.   # Map image border color (R,G,B,Opacity)
  54.   MAP_BORDER = Color.new(0,0,0,200)
  55.  
  56.   # Text for help window when saving. Ex: "Which file would you like to save to?"
  57.   SAVE_TEXT = "Which file would you like to save to?"
  58.   # Text for help window when loading. Ex: "Which file would you like to load?"
  59.   LOAD_TEXT = "Which file would you like to load?"
  60.  
  61.   # All windows' opacity (Lowest 0 - 255 Highest)
  62.   # Use low opacity when having a background.
  63.   WINDOW_OPACITY = 200
  64.   # Background image file name, it must be in the pictures folder.
  65.   # Put '' if you don't want a background.
  66.   BACKGROUND_IMAGE = 'KingdomHeartsTitle'
  67.   # Opacity for background image
  68.   BACKGROUND_IMAGE_OPACITY = 255
  69.    
  70.   #----------------------------------------------------------------------------
  71.   # * Config End
  72.   #----------------------------------------------------------------------------
  73.  
  74. end
  75.  
  76.  
  77. #==============================================================================
  78. # ** Game_Map
  79. #------------------------------------------------------------------------------
  80. #  This class handles the map. It includes scrolling and passable determining
  81. #  functions. Refer to "$game_map" for the instance of this class.
  82. #==============================================================================
  83.  
  84. class Game_Map
  85.   #--------------------------------------------------------------------------
  86.   # * Public Instance Variables
  87.   #--------------------------------------------------------------------------
  88.   attr_reader   :name
  89.   #--------------------------------------------------------------------------
  90.   # * Alias Listing
  91.   #--------------------------------------------------------------------------
  92.   alias law_css_setup setup
  93.   #--------------------------------------------------------------------------
  94.   # * Setup
  95.   #     map_id : map ID
  96.   #--------------------------------------------------------------------------
  97.   def setup(*args)
  98.     # Run the original setup
  99.     law_css_setup(*args)
  100.     # Load the name of the map
  101.     @name = load_data("Data/MapInfos.rxdata")[@map_id].name
  102.   end
  103. end
  104.  
  105.  
  106.  
  107. #==============================================================================
  108. # ** Spriteset_Map_Loading_Preview
  109. #------------------------------------------------------------------------------
  110. #  This class brings together map screen sprites, tilemaps, etc for the
  111. #   loading screen's preview.
  112. #==============================================================================
  113.  
  114. class Spriteset_Map_Loading_Preview
  115.   #--------------------------------------------------------------------------
  116.   # * Invariables
  117.   #--------------------------------------------------------------------------
  118.   RES_WIDTH =  352  # Please insert a number divisible by 32
  119.   RES_HEIGHT = 160   # Please insert a number divisible by 32
  120.   TOP_CORNER_X = 201
  121.   TOP_CORNER_Y = 120
  122.   #--------------------------------------------------------------------------
  123.   # * Object Initialization
  124.   #--------------------------------------------------------------------------
  125.   def initialize
  126.     center
  127.     # Make viewports
  128.     @viewport1 = Viewport.new(TOP_CORNER_X, TOP_CORNER_Y, RES_WIDTH, RES_HEIGHT)
  129.     @viewport2 = Viewport.new(TOP_CORNER_X, TOP_CORNER_Y, RES_WIDTH, RES_HEIGHT)
  130.     @viewport3 = Viewport.new(TOP_CORNER_X, TOP_CORNER_Y, RES_WIDTH, RES_HEIGHT)
  131.     @viewport1.z = 9200
  132.     @viewport2.z = 9200
  133.     @viewport3.z = 95000
  134.     # Make tilemap
  135.     @tilemap = Tilemap.new(@viewport1)
  136.     @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
  137.     for i in 0..6
  138.       autotile_name = $game_map.autotile_names[i]
  139.       @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
  140.     end
  141.     @tilemap.map_data = $game_map.data
  142.     @tilemap.priorities = $game_map.priorities
  143.     # Make panorama plane
  144.     @panorama = Plane.new(@viewport1)
  145.     @panorama.z = -1000
  146.     # Make fog plane
  147.     @fog = Plane.new(@viewport1)
  148.     @fog.z = 3000
  149.     # Make character sprites
  150.     @character_sprites = []
  151.     for i in $game_map.events.keys.sort
  152.       sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
  153.       @character_sprites.push(sprite)
  154.     end
  155.     @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
  156.     # Make weather
  157.     @weather = RPG::Weather.new(@viewport1)
  158.     # Make picture sprites
  159.     @picture_sprites = []
  160.     for i in 1..50
  161.       @picture_sprites.push(Sprite_Picture.new(@viewport2,
  162.         $game_screen.pictures[i]))
  163.     end
  164.     # Make timer sprite
  165.     @timer_sprite = Sprite_Timer.new
  166.     # Frame update
  167.     update
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # * Dispose
  171.   #--------------------------------------------------------------------------
  172.   def dispose
  173.     # Dispose of tilemap
  174.     @tilemap.tileset.dispose
  175.     for i in 0..6
  176.       @tilemap.autotiles[i].dispose
  177.     end
  178.     @tilemap.dispose
  179.     # Dispose of panorama plane
  180.     @panorama.dispose
  181.     # Dispose of fog plane
  182.     @fog.dispose
  183.     # Dispose of character sprites
  184.     for sprite in @character_sprites
  185.       sprite.dispose
  186.     end
  187.     # Dispose of weather
  188.     @weather.dispose
  189.     # Dispose of picture sprites
  190.     for sprite in @picture_sprites
  191.       sprite.dispose
  192.     end
  193.     # Dispose of timer sprite
  194.     @timer_sprite.dispose
  195.     # Dispose of viewports
  196.     @viewport1.dispose
  197.     @viewport2.dispose
  198.     @viewport3.dispose
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # * Frame Update
  202.   #--------------------------------------------------------------------------
  203.   def update
  204.     center
  205.     # If panorama is different from current one
  206.     if @panorama_name != $game_map.panorama_name or
  207.        @panorama_hue != $game_map.panorama_hue
  208.       @panorama_name = $game_map.panorama_name
  209.       @panorama_hue = $game_map.panorama_hue
  210.       if @panorama.bitmap != nil
  211.         @panorama.bitmap.dispose
  212.         @panorama.bitmap = nil
  213.       end
  214.       if @panorama_name != ""
  215.         @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  216.       end
  217.       Graphics.frame_reset
  218.     end
  219.     # If fog is different than current fog
  220.     if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
  221.       @fog_name = $game_map.fog_name
  222.       @fog_hue = $game_map.fog_hue
  223.       if @fog.bitmap != nil
  224.         @fog.bitmap.dispose
  225.         @fog.bitmap = nil
  226.       end
  227.       if @fog_name != ""
  228.         @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  229.       end
  230.       Graphics.frame_reset
  231.     end
  232.     # Update tilemap
  233.     @tilemap.ox = $game_map.display_x / 4
  234.     @tilemap.oy =  $game_map.display_y / 4
  235.     @tilemap.update
  236.     # Update panorama plane
  237.     @panorama.ox =  $game_map.display_x / 8
  238.     @panorama.oy =  $game_map.display_y / 8
  239.     # Update fog plane
  240.     @fog.zoom_x = $game_map.fog_zoom / 100.0
  241.     @fog.zoom_y = $game_map.fog_zoom / 100.0
  242.     @fog.opacity = $game_map.fog_opacity
  243.     @fog.blend_type = $game_map.fog_blend_type
  244.     @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
  245.     @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
  246.     @fog.tone = $game_map.fog_tone
  247.     # Update character sprites
  248.     for sprite in @character_sprites
  249.       sprite.update
  250.     end
  251.     # Update weather graphic
  252.     @weather.type = $game_screen.weather_type
  253.     @weather.max = $game_screen.weather_max
  254.     @weather.ox = $game_map.display_x / 4
  255.     @weather.oy = $game_map.display_y / 4
  256.     @weather.update
  257.     # Update picture sprites
  258.     for sprite in @picture_sprites
  259.       sprite.update
  260.     end
  261.     # Update timer sprite
  262.     @timer_sprite.update
  263.     # Set screen color tone and shake position
  264.     @viewport1.tone = $game_screen.tone
  265.     @viewport1.ox = $game_screen.shake
  266.     # Set screen flash color
  267.     @viewport3.color = $game_screen.flash_color
  268.     # Update viewports
  269.     @viewport1.update
  270.     @viewport3.update
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # * Set Map Display Position to Center of Screen
  274.   #--------------------------------------------------------------------------
  275.   def center
  276.     x = $game_player.real_x
  277.     y = $game_player.real_y
  278.     max_x = [($game_map.width - RES_WIDTH / 32) * 128, RES_WIDTH].max
  279.     max_y = [($game_map.height - RES_HEIGHT / 32) * 128, RES_HEIGHT].max
  280.     center_x = (RES_WIDTH/2 - 16) * 4   # Center screen x-coordinate * 4
  281.     center_y = (RES_HEIGHT/2 - 16) * 4   # Center screen y-coordinate * 4
  282.     $game_map.display_x = [0, [x - center_x, max_x].min].max
  283.     $game_map.display_y = [0, [y - center_y, max_y].min].max
  284.     $game_map.refresh
  285.   end
  286. end
  287.  
  288.  
  289.  
  290. #==============================================================================
  291. # ** Window_SaveFile
  292. #------------------------------------------------------------------------------
  293. #  This window displays save files on the save and load screens.
  294. #==============================================================================
  295.  
  296. class Window_SaveFile < Window_Base
  297.   #--------------------------------------------------------------------------
  298.   # * Public Instance Variables
  299.   #--------------------------------------------------------------------------
  300.   attr_reader   :filename                 # file name
  301.   attr_reader   :selected                 # selected
  302.   #--------------------------------------------------------------------------
  303.   # * Object Initialization
  304.   #     file_index : save file index (0-3)
  305.   #     filename   : file name
  306.   #--------------------------------------------------------------------------
  307.   def initialize(file_index, filename, position)
  308.     super(0, 64 + position * 52, 115, 52)
  309.     self.contents = Bitmap.new(width - 32, height - 32)
  310.     @file_index = file_index
  311.     @filename = Customization::SLOT_NAME + "#{@file_index + 1}.rxdata"
  312.     @time_stamp = Time.at(0)
  313.     @file_exist = FileTest.exist?(@filename)
  314.     if @file_exist
  315.       file = File.open(@filename, "r")
  316.       @time_stamp = file.mtime
  317.       @characters = Marshal.load(file)
  318.       @frame_count = Marshal.load(file)
  319.       @game_system = Marshal.load(file)
  320.       @game_switches = Marshal.load(file)
  321.       @game_variables = Marshal.load(file)
  322.       @total_sec = @frame_count / Graphics.frame_rate
  323.       file.close
  324.     end
  325.     refresh
  326.     @selected = false
  327.   end
  328.   #--------------------------------------------------------------------------
  329.   # * Refresh
  330.   #--------------------------------------------------------------------------
  331.   def refresh
  332.     self.contents.clear
  333.     if @file_exist
  334.       # Draw file number
  335.       self.contents.font.color = normal_color
  336.       bitmap = RPG::Cache.icon(Customization::SLOT_ICON_SELECTED)
  337.       @opacity = 255
  338.     else
  339.       self.contents.font.color = disabled_color
  340.       bitmap = RPG::Cache.icon(Customization::SLOT_ICON_UNSELECTED)
  341.       @opacity = 100
  342.     end
  343.     name = Customization::SLOT_NAME + "#{@file_index + 1}"
  344.     self.contents.draw_text(20, -7, 600, 32, name)
  345.     @name_width = contents.text_size(name).width
  346.     self.contents.fill_rect(0, -2, 10, 32, Color.new(0, 0, 0, 0))
  347.     self.contents.blt(0, -2, bitmap, Rect.new(0, 0, 24, 24), opacity)
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # * Set Selected
  351.   #     selected : new selected (true = selected, false = unselected)
  352.   #--------------------------------------------------------------------------
  353.   def selected=(selected)
  354.     @selected = selected
  355.     update_cursor_rect
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # * Cursor Rectangle Update
  359.   #--------------------------------------------------------------------------
  360.   def update_cursor_rect
  361.     if @selected
  362.       self.cursor_rect.set(0, -7, @name_width + 38, 32)
  363.     else
  364.       self.cursor_rect.empty
  365.     end
  366.   end
  367. end
  368.  
  369.  
  370.  
  371. #==============================================================================
  372. # ** Window_FileInfo
  373. #------------------------------------------------------------------------------
  374. #  This window displays file information.
  375. #==============================================================================
  376.  
  377. class Window_FileInfo < Window_Base
  378.   #--------------------------------------------------------------------------
  379.   # * Alias Listing
  380.   #--------------------------------------------------------------------------
  381.   if @law_save_resume_done_before.nil?
  382.     alias nr_dispose dispose
  383.     @law_save_resume_done_before = true
  384.   end
  385.   #--------------------------------------------------------------------------
  386.   # * Object Initialization
  387.   #--------------------------------------------------------------------------
  388.   def initialize
  389.     super(115, 64, 525, 416)
  390.     self.contents = Bitmap.new(width - 32, height - 32)
  391.     refresh($game_temp.last_file_index)
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # * Refresh
  395.   #--------------------------------------------------------------------------
  396.   def refresh(file_index)
  397.     self.contents.clear
  398.     @spriteset.dispose unless @spriteset.nil?
  399.     @spriteset = nil
  400.     @file_index = file_index
  401.     @filename = Customization::SLOT_NAME + "#{@file_index + 1}.rxdata"
  402.     @file_exist = FileTest.exist?(@filename)
  403.     save_data = Customization::SLOTS
  404.     # If save file exists
  405.     if @file_exist
  406.       file = File.open(@filename, "rb")
  407.       $time_stamp =        file.mtime
  408.       $characters =        Marshal.load(file)
  409.       @frame_count =       Marshal.load(file)
  410.       $game_system = Marshal.load(file)
  411.       $game_switches = Marshal.load(file)
  412.       $game_variables = Marshal.load(file)
  413.       $game_self_switches =  Marshal.load(file)
  414.       $game_screen = Marshal.load(file)
  415.       $game_actors = Marshal.load(file)
  416.       $game_party = Marshal.load(file)
  417.       $game_troop = Marshal.load(file)
  418.       $game_map = Marshal.load(file)
  419.       $game_player = Marshal.load(file)
  420.       file.close
  421.       @total_sec = @frame_count / Graphics.frame_rate
  422.       # Draw Screenshot
  423.       begin
  424.         width = 352 + 4
  425.         height = 160 + 4
  426.         x = (self.width - 32 - width) / 2
  427.         y = 54 - 16
  428.         self.contents.fill_rect(x, y, width, height, Customization::MAP_BORDER)
  429.         @spriteset = Spriteset_Map_Loading_Preview.new
  430.       end
  431.       # Draw Gold
  432.       if Customization::DRAW_GOLD
  433.         cx = contents.text_size($data_system.words.gold).width
  434.         self.contents.font.color = normal_color
  435.         self.contents.font.size = 25
  436.         self.contents.draw_text(40, 0, 140, 32, $game_party.gold.to_s, 2)
  437.         self.contents.font.color = system_color
  438.         self.contents.draw_text(140, 0, 100, 32, $data_system.words.gold, 2)
  439.         self.contents.draw_text(-20, -1, 100, 32, Customization::GOLD_TEXT, 2)  
  440.       end
  441.       # Draw actor face
  442.       if Customization::DRAW_FACE
  443.         for i in 0...$game_party.actors.size
  444.           actor = $game_party.actors[i]
  445.           draw_actor_face_graphic(actor, i*129, 250)
  446.         end  
  447.       end
  448.       # Draw actor name
  449.       if Customization::DRAW_NAME
  450.         for i in 0...$game_party.actors.size
  451.           self.contents.font.color = system_color
  452.           self.contents.font.size = 25
  453.           actor = $game_party.actors[i]
  454.           draw_actor_name(actor, (i*130) + 25, 350)
  455.         end
  456.       end
  457.       # Draw play time
  458.       if Customization::DRAW_PLAYTIME
  459.         hour = @total_sec / 60 / 60
  460.         min = @total_sec / 60 % 60
  461.         sec = @total_sec % 60
  462.         time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  463.         self.contents.font.color = normal_color
  464.         self.contents.font.size = 25
  465.         self.contents.draw_text(380, 0, 100, 32, time_string, 2)
  466.         self.contents.font.color = system_color
  467.         time_string = Customization::PLAYTIME_TEXT
  468.         self.contents.draw_text(230, 0, 150, 32, time_string, 2)
  469.       end
  470.       # Draw Location
  471.       if Customization::DRAW_LOCATION
  472.         self.contents.font.color = system_color
  473.         self.contents.font.size = 25
  474.         self.contents.draw_text(4, 210, 120, 32, Customization::LOCATION_TEXT)
  475.         self.contents.font.color = normal_color
  476.         x = (Customization::LOCATION_TEXT.length * 10) + 5
  477.         self.contents.draw_text(x, 210, 120, 32, $game_map.name.to_s, 2)
  478.       end
  479.     else
  480.       self.contents.draw_text(-20, 50, self.contents.width, self.contents.height - 200, Customization::EMPTY_SLOT_TEXT, 1)
  481.     end
  482.   end
  483.   #--------------------------------------------------------------------------
  484.   # * Draw Actor Face Graphic
  485.   #--------------------------------------------------------------------------
  486.   def draw_actor_face_graphic(actor, x, y)
  487.     bitmap = RPG::Cache.picture(actor.id.to_s)
  488.     self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # * Dispose Window
  492.   #--------------------------------------------------------------------------
  493.   def dispose(*args)
  494.     nr_dispose(*args)
  495.     @spriteset.dispose unless @spriteset.nil?
  496.     @spriteset = nil
  497.   end
  498. end
  499.  
  500.  
  501.  
  502. #==============================================================================
  503. # ** Scene_File
  504. #------------------------------------------------------------------------------
  505. #  This is a superclass for the save screen and load screen.
  506. #==============================================================================
  507.  
  508. class Scene_File
  509.   #--------------------------------------------------------------------------
  510.   # * Invariables
  511.   #--------------------------------------------------------------------------
  512.   CENTER_X = (320 - 16) * 4   # Center screen x-coordinate * 4
  513.   CENTER_Y = (240 - 16) * 4   # Center screen y-coordinate * 4
  514.   #--------------------------------------------------------------------------
  515.   # * Object Initialization
  516.   #     help_text : text string shown in the help window
  517.   #--------------------------------------------------------------------------
  518.   def initialize(help_text)
  519.     @help_text = help_text
  520.   end
  521.   #--------------------------------------------------------------------------
  522.   # * Main Processing
  523.   #--------------------------------------------------------------------------
  524.   def main
  525.     @cursor_displace = 0
  526.     # Make help window
  527.     @help_window = Window_Help.new
  528.     @help_window.set_text(@help_text)
  529.     @help_window.opacity = Customization::WINDOW_OPACITY
  530.     # Make save file window
  531.     @savefile_windows = []
  532.     for i in 0..Customization::SLOTS - 1
  533.       @savefile_windows.push(Window_SaveFile.new(i, make_filename(i), i))
  534.     end
  535.     # Select last file to be operated
  536.     @file_index = $game_temp.last_file_index
  537.     @savefile_windows[@file_index].selected = true
  538.     for i in @savefile_windows
  539.       i.opacity = Customization::WINDOW_OPACITY
  540.     end
  541.     # Make FileInfo window
  542.     @fileinfo_window = Window_FileInfo.new
  543.     @fileinfo_window.opacity = Customization::WINDOW_OPACITY
  544.     # Make background
  545.     @sprite = Sprite.new
  546.     @sprite.bitmap = RPG::Cache.picture(Customization::BACKGROUND_IMAGE)
  547.     # Execute transition
  548.     Graphics.transition
  549.     # Main loop
  550.     loop do
  551.       # Update game screen
  552.       Graphics.update
  553.       # Update input information
  554.       Input.update
  555.       # Frame update
  556.       update
  557.       # Abort loop if screen is changed
  558.       if $scene != self
  559.         break
  560.       end
  561.     end
  562.     # Prepare for transition
  563.     Graphics.freeze
  564.     # Dispose of windows
  565.     @help_window.dispose
  566.     for i in @savefile_windows
  567.       i.dispose
  568.     end
  569.     @fileinfo_window.dispose
  570.     @sprite.dispose
  571.     @sprite.bitmap.dispose
  572.    # $game_player.center($game_player.x, $game_player.y)
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # * Frame Update
  576.   #--------------------------------------------------------------------------
  577.   def update
  578.     # Update windows
  579.     @help_window.update
  580.     @fileinfo_window.update
  581.     for i in @savefile_windows
  582.       i.update
  583.     end    
  584.     # If C button was pressed
  585.     if Input.trigger?(Input::C)
  586.       # Call method: on_decision (defined by the subclasses)
  587.       on_decision(make_filename(@file_index))
  588.       $game_temp.last_file_index = @file_index
  589.       @fileinfo_window.refresh(@file_index)
  590.       center
  591.       return
  592.     end
  593.     # If B button was pressed
  594.     if Input.trigger?(Input::B)
  595.       # Call method: on_cancel (defined by the subclasses)
  596.       on_cancel
  597.       return
  598.     end
  599.     # If the down directional button was pressed
  600.     if Input.repeat?(Input::DOWN)
  601.       if Input.trigger?(Input::DOWN) or @file_index < Customization::SLOTS - 1
  602.       if @file_index == Customization::SLOTS - 1
  603.         $game_system.se_play($data_system.buzzer_se)
  604.         return
  605.       end
  606.       @cursor_displace = @file_index
  607.       @cursor_displace += 1
  608.       if @cursor_displace == 8
  609.         @cursor_displace = 7
  610.         for i in @savefile_windows
  611.         i.dispose
  612.         end
  613.         @savefile_windows = []
  614.         for i in 0..Customization::SLOTS
  615.         f = i - 6 + @file_index
  616.         name = make_filename(f)
  617.         @savefile_windows.push(Window_SaveFile.new(f, name, i))
  618.         @savefile_windows[i].selected = false
  619.         end
  620.       end
  621.       $game_system.se_play($data_system.cursor_se)
  622.       @file_index = (@file_index + 1)
  623.       if @file_index == 8
  624.         @file_index = 7
  625.       end
  626.       for i in 0..Customization::SLOTS - 1
  627.         @savefile_windows[i].selected = false
  628.       end
  629.       @savefile_windows[@cursor_displace].selected = true
  630.       @fileinfo_window.refresh(@file_index)
  631.       return
  632.       end
  633.     end
  634.     # If the up directional button was pressed
  635.     if Input.repeat?(Input::UP)
  636.       if Input.trigger?(Input::UP) or @file_index > 0
  637.       if @file_index == 0
  638.         $game_system.se_play($data_system.buzzer_se)
  639.         return
  640.       end
  641.       @cursor_displace = @file_index
  642.       @cursor_displace -= 1
  643.       if @cursor_displace == -1
  644.         @cursor_displace = 0
  645.         for i in @savefile_windows
  646.         i.dispose
  647.         end
  648.         @savefile_windows = []
  649.         for i in 0..Customization::SLOTS
  650.         f = i - 1 + @file_index
  651.         name = make_filename(f)
  652.         @savefile_windows.push(Window_SaveFile.new(f, name, i))
  653.         @savefile_windows[i].selected = false
  654.         end
  655.       end
  656.       $game_system.se_play($data_system.cursor_se)
  657.       @file_index = (@file_index - 1)
  658.       if @file_index == -1
  659.         @file_index = 0
  660.       end
  661.       for i in 0..Customization::SLOTS - 1
  662.         @savefile_windows[i].selected = false
  663.       end
  664.       @savefile_windows[@cursor_displace].selected = true
  665.       @fileinfo_window.refresh(@file_index)
  666.       return
  667.       end
  668.     end
  669.   end
  670.   #--------------------------------------------------------------------------
  671.   # * Make File Name
  672.   #     file_index : save file index (0-3)
  673.   #--------------------------------------------------------------------------
  674.   def make_filename(file_index)
  675.     return Customization::SLOT_NAME + "#{file_index + 1}.rxdata"
  676.   end
  677.   #--------------------------------------------------------------------------
  678.   # * Backup Data
  679.   #--------------------------------------------------------------------------
  680.   def backup_data
  681.     @nr_game_system = $game_system.clone
  682.     @nr_game_switches = $game_switches.clone
  683.     @nr_game_variables = $game_variables.clone
  684.     @nr_game_self_switches = $game_self_switches.clone
  685.     @nr_game_screen = $game_screen.clone
  686.     @nr_game_actors = $game_actors.clone
  687.     @nr_game_party = $game_party.clone
  688.     @nr_game_troop = $game_troop.clone
  689.     @nr_game_map = $game_map.clone
  690.     @nr_game_player = $game_player.clone
  691.   end
  692.   #--------------------------------------------------------------------------
  693.   # * Load Backup Data
  694.   #--------------------------------------------------------------------------
  695.   def load_backup_data
  696.     $game_system = @nr_game_system.clone
  697.     $game_switches = @nr_game_switches.clone
  698.     $game_variables = @nr_game_variables.clone
  699.     $game_self_switches = @nr_game_self_switches.clone
  700.     $game_screen = @nr_game_screen.clone
  701.     $game_actors = @nr_game_actors.clone
  702.     $game_party = @nr_game_party.clone
  703.     $game_troop = @nr_game_troop.clone
  704.     $game_map = @nr_game_map.clone
  705.     $game_player = @nr_game_player.clone
  706.   end
  707.   #--------------------------------------------------------------------------
  708.   # * Set Map Display Position to Center of Screen
  709.   #--------------------------------------------------------------------------
  710.   def center
  711.     max_x = ($game_map.width - 20) * 128
  712.     max_y = ($game_map.height - 15) * 128
  713.     x = $game_player.x
  714.     y = $game_player.y
  715.     $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
  716.     $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
  717.   end
  718. end
  719.  
  720.  
  721.  
  722. #==============================================================================
  723. # ** Scene_Save
  724. #------------------------------------------------------------------------------
  725. #  This class performs save screen processing.
  726. #==============================================================================
  727.  
  728. class Scene_Save < Scene_File
  729.   #--------------------------------------------------------------------------
  730.   # * Alias Listing
  731.   #--------------------------------------------------------------------------
  732.   alias law_css_scene_save_initialize initialize
  733.   alias nr_css_scene_save_on_cancel on_cancel
  734.   alias nr_css_scene_save_on_desision on_decision
  735.   #--------------------------------------------------------------------------
  736.   # * Object Initialization
  737.   #--------------------------------------------------------------------------
  738.   def initialize(*args)
  739.     backup_data
  740.     law_css_scene_save_initialize(*args)
  741.     super(Customization::SAVE_TEXT)
  742.   end
  743.   #--------------------------------------------------------------------------
  744.   # * On Decision
  745.   #--------------------------------------------------------------------------
  746.   def on_decision(*args)
  747.     load_backup_data
  748.     nr_css_scene_save_on_desision(*args)
  749.     center
  750.   end
  751.   #--------------------------------------------------------------------------
  752.   # * On Decision
  753.   #--------------------------------------------------------------------------
  754.   def on_cancel(*args)
  755.     load_backup_data
  756.     nr_css_scene_save_on_cancel(*args)
  757.   end
  758. end
  759.  
  760.  
  761.  
  762. #==============================================================================
  763. # ** Scene_Load
  764. #------------------------------------------------------------------------------
  765. #  This class performs load screen processing.
  766. #==============================================================================
  767.  
  768. class Scene_Load < Scene_File
  769.  
  770.   #--------------------------------------------------------------------------
  771.   # * Alias Listing
  772.   #--------------------------------------------------------------------------
  773.   if @nr_css_done_before.nil?
  774.     alias law_css_scene_load_initialize initialize
  775.     @nr_css_done_before = true
  776.   end
  777.   #--------------------------------------------------------------------------
  778.   # * Object Initialization
  779.   #--------------------------------------------------------------------------
  780.   def initialize(*args)
  781.     law_css_scene_load_initialize(*args)
  782.     super(Customization::LOAD_TEXT)
  783.   end
  784. end
  785.  
  786.  
  787.  
  788. #==============================================================================
  789. # ** Scene_Title
  790. #------------------------------------------------------------------------------
  791. #  This class performs title screen processing.
  792. #==============================================================================
  793.  
  794. class Scene_Title
  795.   #--------------------------------------------------------------------------
  796.   # * Main Processing
  797.   #--------------------------------------------------------------------------
  798.   def main
  799.     # If battle test
  800.     if $BTEST
  801.       battle_test
  802.       return
  803.     end
  804.     # Load database
  805.     $data_actors        = load_data("Data/Actors.rxdata")
  806.     $data_classes       = load_data("Data/Classes.rxdata")
  807.     $data_skills        = load_data("Data/Skills.rxdata")
  808.     $data_items         = load_data("Data/Items.rxdata")
  809.     $data_weapons       = load_data("Data/Weapons.rxdata")
  810.     $data_armors        = load_data("Data/Armors.rxdata")
  811.     $data_enemies       = load_data("Data/Enemies.rxdata")
  812.     $data_troops        = load_data("Data/Troops.rxdata")
  813.     $data_states        = load_data("Data/States.rxdata")
  814.     $data_animations    = load_data("Data/Animations.rxdata")
  815.     $data_tilesets      = load_data("Data/Tilesets.rxdata")
  816.     $data_common_events = load_data("Data/CommonEvents.rxdata")
  817.     $data_system        = load_data("Data/System.rxdata")
  818.     # Make system object
  819.     $game_system = Game_System.new
  820.     # Make title graphic
  821.     @sprite = Sprite.new
  822.     @sprite.bitmap = RPG::Cache.title($data_system.title_name)
  823.     # Make command window
  824.     s1 = "New Game"
  825.     s2 = "Continue"
  826.     s3 = "Shutdown"
  827.     @command_window = Window_Command.new(192, [s1, s2, s3])
  828.     @command_window.back_opacity = 160
  829.     @command_window.x = 320 - @command_window.width / 2
  830.     @command_window.y = 288
  831.     # Continue enabled determinant
  832.     # Check if at least one save file exists
  833.     # If enabled, make @continue_enabled true; if disabled, make it false
  834.     @continue_enabled = false
  835.     for i in 0..Customization::SLOTS
  836.       if FileTest.exist?(Customization::SLOT_NAME + "#{i + 1}.rxdata")
  837.         @continue_enabled = true
  838.       end
  839.     end
  840.     # If continue is enabled, move cursor to "Continue"
  841.     # If disabled, display "Continue" text in gray
  842.     if @continue_enabled
  843.       @command_window.index = 1
  844.     else
  845.       @command_window.disable_item(1)
  846.     end
  847.     # Play title BGM
  848.     $game_system.bgm_play($data_system.title_bgm)
  849.     # Stop playing ME and BGS
  850.     Audio.me_stop
  851.     Audio.bgs_stop
  852.     # Execute transition
  853.     Graphics.transition
  854.     # Main loop
  855.     loop do
  856.       # Update game screen
  857.       Graphics.update
  858.       # Update input information
  859.       Input.update
  860.       # Frame update
  861.       update
  862.       # Abort loop if screen is changed
  863.       if $scene != self
  864.         break
  865.       end
  866.     end
  867.     # Prepare for transition
  868.     Graphics.freeze
  869.     # Dispose of command window
  870.     @command_window.dispose
  871.     # Dispose of title graphic
  872.     @sprite.bitmap.dispose
  873.     @sprite.dispose
  874.   end
  875. end
Expand to see the code.


  1. #==============================================================================
  2. # ** Sprite Shadow (Sprite_Ombre )
  3. #------------------------------------------------------------------------------
  4. #    Based on Genzai Kawakami's shadows
  5. #    dynamisme & features by Rataime
  6. #    extra features Boushy
  7. #    New Edits by DerVVulfman
  8. #    February 24, 2008
  9. #
  10. #------------------------------------------------------------------------------
  11. #
  12. # Introduction:
  13. #
  14. #  This system allows you and all 'prepared' events to generate shadows while
  15. #  on the field map.   The player can move around  a 'light source' event and
  16. #  display a shadow.   Likewise,  events with a special comment  within their
  17. #  event list can also generate shadows.
  18. #
  19. #------------------------------------------------------------------------------
  20. #
  21. # Instructions:
  22. #
  23. #  -- The Light Source
  24. #     To create a light source, you need to create a map event that is to be
  25. #     used 'as' the light source.   Most of the time,  these could be events
  26. #     that sport 'torch' or 'lantern' charactersets.  Just examples :)
  27. #
  28. #     To make one of these events a light source,  you need  to insert a few
  29. #     things into that event's  "List of Event Commands".   These things are
  30. #     nothing more than comments.  
  31. #
  32. #     The first comment to add is "begin Shadow Source" (without quotes). It
  33. #     informs the system  that this event is a light source.   The remaining
  34. #     three values are optional and have default values in the configuration
  35. #     section  (only just added  into the script).   They too  are added  as
  36. #     comments.
  37. #
  38. #     anglemin 'number'     --- Starting position of a lightsource's arc.
  39. #     anglemax 'number'     --- Ending position of a lightsource's arc.
  40. #     distancemax 'number'  --- How far away from the 'source' you can go
  41. #     self_opacity 'number' --- How dark the shadow will grow.
  42. #
  43. #     After that, your characters can now move about and generate shadows.
  44. #
  45. #  -- Other Events
  46. #     Events do not know that they can generate shadows.   To let them gene-
  47. #     rate a shadow,  all you need to do is add a special comment into their
  48. #     "List of Event Commands".   This comment needed  is merely  the phrase
  49. #     'begin Shadow' (again, without quotes).
  50. #
  51. #
  52. #  -- Blocking Shadows
  53. #     To prevent shadows  from passing through  solid objects such as doors,
  54. #     walls, cabinets or other forms of furniture,  you will want to apply a
  55. #     priority flag of '1' or higher on these items.  Normally, walls in the
  56. #     default database do not have a priority flag as they merely block  the
  57. #     player from passing through.
  58. #    
  59. #
  60. #------------------------------------------------------------------------------
  61. #
  62. # Revisions to note:
  63. #
  64. #  1) Added formatted headers and comments throughout the script.
  65. #  2) Encapsulated a comment/parameter code in an XPML module.
  66. #  3) Set the shadow array into an instance value to lower resource costs.
  67. #  4) Compatability with Near Fantastica's Squad Movement systems.
  68. #  5) Compatability with Ccoa's Caterpillar system.
  69. #  6) Compatability with Trickster's Caterpillar system.
  70. #  7) Added default shadow settings into the configuration section.
  71. #
  72. #==============================================================================
  73.  
  74.  
  75.  
  76.    #========================================================================
  77.    #  **  C  O  N  F  I  G  U  R  A  T  I  O  N      S  Y  S  T  E  M  **  #
  78.    #========================================================================
  79.     # Caterpillar Systems
  80.     CATERPILLAR_COMPATIBLE      = true    # Toggle for Fukuyama's original  
  81.     SQUAD_MOVE_COMPATIBLE       = false   # Toggle for Near Fantastica's SBABS
  82.     CCOA_CATER_COMPATIBLE       = false   # Toggle for Ccoa's Caterpillar
  83.     TRICKSTER_CATER_COMPATIBLE  = false   # Toggle for Trickster's Caterpillar
  84.    
  85.     # Shadow Specific Systems
  86.     SHADOW_WARN                 = true    # Checks for older shadow system
  87.     SHADOW_MIN                  = 0       # Start setting of shadow arc *
  88.     SHADOW_MAX                  = 0       # Ending setting of shadow arc *
  89.     SHADOW_OPACITY              = 150     # Darkness level of shadow
  90.     SHADOW_DISTANCE             = 350     # Maximum range in pixels
  91.  
  92.     # * SHADOW ARC:  Set in degrees,  this controls whether a light source
  93.     #                can 'force' shadows in certain directions.  Useful if
  94.     #                a light source is hanging on a wall so it cannot make
  95.     #                a shadow THROUGH a wall.
  96.     #
  97.     #                It may take some practice  to set  the desired angles
  98.     #                as it recognizes 90°  being the  top most part  of an
  99.     #                arc,  180° being the leftmost side and so on...  pro-
  100.     #                ceeding in a counter-clockwise motion.
  101.    
  102.    #========================================================================
  103.    #  ****   E N D   O F   C O N F I G U R A T I O N   S Y S T E M   ****  #
  104.    #========================================================================
  105.    
  106.    
  107.  
  108. #==============================================================================
  109. # ** Game_Temp
  110. #------------------------------------------------------------------------------
  111. #  This class handles temporary data that is not included with save data.
  112. #  Refer to "$game_temp" for the instance of this class.
  113. #==============================================================================
  114.  
  115. class Game_Temp
  116.   #--------------------------------------------------------------------------
  117.   # * Public Instance Variables
  118.   #--------------------------------------------------------------------------
  119.   attr_accessor :shadow_spriteset         # holds shadow spritesets
  120. end
  121.  
  122.  
  123.  
  124. #==============================================================================
  125. # ** Game_Party
  126. #------------------------------------------------------------------------------
  127. #  This class handles the party. It includes information on amount of gold
  128. #  and items. Refer to "$game_party" for the instance of this class.
  129. #==============================================================================
  130.  
  131. class Game_Party
  132.   #--------------------------------------------------------------------------
  133.   # * Public Instance Variables
  134.   #--------------------------------------------------------------------------
  135.   attr_reader :characters
  136. end
  137.  
  138.  
  139.  
  140. #==============================================================================
  141. # ** Sprite_Shadow
  142. #------------------------------------------------------------------------------
  143. #  This sprite is used to display the character's shadow.  It observes the
  144. #  Game_Character class and automatically changes sprite conditions.
  145. #==============================================================================
  146. class Sprite_Shadow < RPG::Sprite
  147.   #--------------------------------------------------------------------------
  148.   # * Public Instance Variables
  149.   #--------------------------------------------------------------------------
  150.   attr_accessor :character
  151.   #--------------------------------------------------------------------------
  152.   # * Object Initialization
  153.   #     viewport  : viewport
  154.   #     character : character (Game_Character)
  155.   #     id        : id
  156.   #--------------------------------------------------------------------------
  157.   def initialize(viewport, character = nil, id = 0)
  158.     super(viewport)
  159.     params  = $game_temp.shadow_spriteset.shadows[id]
  160.     @source = params[0]
  161.     # Default settings
  162.     @anglemin     = SHADOW_MIN
  163.     @anglemax     = SHADOW_MAX
  164.     @self_opacity = SHADOW_OPACITY
  165.     @distancemax  = SHADOW_DISTANCE
  166.     # Settings changed by parameters
  167.     @anglemin     = params[1]   if params.size > 1
  168.     @anglemax     = params[2]   if params.size > 2
  169.     @distancemax  = params[3]   if params.size > 3
  170.     @self_opacity = params[4]   if params.size > 4
  171.     @character = character
  172.     update
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # * Frame Update
  176.   #--------------------------------------------------------------------------
  177.   def update
  178.     # If shadow not in range of light source
  179.     if !in_range?(@character, @source, @distancemax)
  180.       self.opacity = 0
  181.       return
  182.     end
  183.     super
  184.     # If tile ID, file name, or hue are different from current ones
  185.     if @tile_id != @character.tile_id or
  186.        @character_name != @character.character_name or
  187.        @character_hue != @character.character_hue
  188.       # Remember tile ID, file name, and hue
  189.       @tile_id = @character.tile_id
  190.       @character_name = @character.character_name
  191.       @character_hue = @character.character_hue
  192.       # If tile ID value is valid
  193.       if @tile_id >= 384
  194.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  195.           @tile_id, @character.character_hue)
  196.         self.src_rect.set(0, 0, 32, 32)
  197.         self.ox = 16
  198.         self.oy = 32
  199.       # If tile ID value is invalid        
  200.       else
  201.         self.bitmap = RPG::Cache.character(@character.character_name,
  202.           @character.character_hue)
  203.         @cw = bitmap.width / 4
  204.         @ch = bitmap.height / 4
  205.         self.ox = @cw / 2
  206.         self.oy = @ch
  207.       end
  208.     end
  209.     # Set visible situation
  210.     self.visible = (not @character.transparent)
  211.     # If graphic is character
  212.     if @tile_id == 0
  213.       # Set rectangular transfer
  214.       sx = @character.pattern * @cw
  215.       sy = (@character.direction - 2) / 2 * @ch
  216.       if self.angle > 90 or angle < -90
  217.         sy = ( 4 - 2) / 2 * @ch   if @character.direction == 6
  218.         sy = ( 6 - 2) / 2 * @ch   if @character.direction == 4
  219.         sy = ( 8 - 2) / 2 * @ch   if @character.direction == 2
  220.         sy = ( 2 - 2) / 2 * @ch   if @character.direction == 8
  221.       end
  222.       self.src_rect.set(sx, sy, @cw, @ch)
  223.     end
  224.     # Set sprite coordinates    
  225.     self.x = @character.screen_x
  226.     self.y = @character.screen_y-5
  227.     self.z = @character.screen_z(@ch)-1
  228.     # Set blend method and bush depth
  229.     self.blend_type = @character.blend_type
  230.     self.bush_depth = @character.bush_depth
  231.     # Animation
  232.     if @character.animation_id != 0
  233.       animation = $data_animations[@character.animation_id]
  234.       animation(animation, true)
  235.       @character.animation_id = 0
  236.     end
  237.     @deltax       = @source.screen_x - self.x
  238.     @deltay       = @source.screen_y - self.y
  239.     self.color    = Color.new(0, 0, 0)
  240.     @distance     = ((@deltax ** 2) + (@deltay ** 2))
  241.     # Set opacity level based on light source distance
  242.     self.opacity  = @self_opacity * 13000 /
  243.                       ((@distance * 370 / @distancemax) + 6000)
  244.     self.angle    = 57.3 * Math.atan2(@deltax, @deltay )
  245.     @angle_trigo  = self.angle+90
  246.     if @angle_trigo < 0
  247.         @angle_trigo = 360 + @angle_trigo
  248.      end
  249.     if @anglemin != 0 or @anglemax != 0
  250.        if (@angle_trigo < @anglemin or @angle_trigo > @anglemax) and
  251.           @anglemin < @anglemax
  252.          self.opacity = 0
  253.          return
  254.        end
  255.        if (@angle_trigo < @anglemin and @angle_trigo > @anglemax) and
  256.           @anglemin > @anglemax
  257.          self.opacity=0
  258.          return
  259.        end    
  260.      end
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # * In Range?  (From Near's Anti Lag Script, edited)
  264.   #     element     : element
  265.   #     object      : object
  266.   #     range       : range in tiles
  267.   #--------------------------------------------------------------------------  
  268.   def in_range?(element, object, range)
  269.     x = (element.screen_x - object.screen_x) * (element.screen_x - object.screen_x)
  270.     y = (element.screen_y - object.screen_y) * (element.screen_y - object.screen_y)
  271.     r = x + y
  272.     if r <= (range * range)
  273.        return true
  274.     else
  275.       return false
  276.     end
  277.   end
  278. end
  279.  
  280.  
  281.  
  282. #==============================================================================
  283. # ** Sprite_Character
  284. #------------------------------------------------------------------------------
  285. #  This sprite is used to display the character.It observes the Game_Character
  286. #  class and automatically changes sprite conditions.
  287. #==============================================================================
  288.  
  289. class Sprite_Character < RPG::Sprite
  290.   #--------------------------------------------------------------------------
  291.   # * Alias Listings
  292.   #--------------------------------------------------------------------------
  293.   alias shadow_initialize initialize
  294.   alias shadow_update update  
  295.   #--------------------------------------------------------------------------
  296.   # * Object Initialization
  297.   #     viewport  : viewport
  298.   #     character : character (Game_Character)
  299.   #--------------------------------------------------------------------------
  300.   def initialize(viewport, character = nil)
  301.     @character = character
  302.     super(viewport)
  303.     @ombrelist = []
  304.     if character.is_a?(Game_Event) and $game_temp.shadow_spriteset.shadows != []
  305.       params = XPML.XPML_read("Shadow", @character.id, 5)
  306.       if params != nil
  307.         for i in 0...$game_temp.shadow_spriteset.shadows.size
  308.           @ombrelist.push(Sprite_Shadow.new(viewport, @character,i))
  309.         end
  310.       end
  311.     end
  312.     if character.is_a?(Game_Player) and $game_temp.shadow_spriteset.shadows != []
  313.       for i in 0...$game_temp.shadow_spriteset.shadows.size
  314.         @ombrelist.push(Sprite_Shadow.new(viewport, $game_player,i))
  315.       end
  316.       #===================================================
  317.       # * Compatibility with Caterpillar Functions
  318.       #===================================================
  319.       if CATERPILLAR_COMPATIBLE and $game_party.characters != nil
  320.         for member in $game_party.characters
  321.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  322.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  323.           end
  324.         end
  325.       end
  326.       if SQUAD_MOVE_COMPATIBLE and $game_allies.values != nil
  327.         for member in $game_allies.values
  328.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  329.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  330.           end
  331.         end
  332.       end
  333.       if CCOA_CATER_COMPATIBLE and $game_train.actors != nil
  334.         for member in $game_train.actors
  335.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  336.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  337.           end
  338.         end
  339.       end
  340.       if TRICKSTER_CATER_COMPATIBLE and $game_party.followers != nil
  341.         for member in $game_party.followers
  342.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  343.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  344.           end
  345.         end
  346.       end
  347.       #===================================================
  348.       # ** End of the compatibility
  349.       #===================================================      
  350.     end
  351.     # Perform the original call
  352.     shadow_initialize(viewport, @character)
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # * Frame Update
  356.   #--------------------------------------------------------------------------
  357.   def update
  358.     shadow_update
  359.     if @ombrelist != []
  360.       for i in [email hidden]
  361.         @ombrelist[i].update
  362.       end
  363.     end
  364.   end  
  365. end
  366.  
  367.  
  368.  
  369. #==============================================================================
  370. # ** Game_Event
  371. #------------------------------------------------------------------------------
  372. #  This class deals with events. It handles functions including event page
  373. #  switching via condition determinants, and running parallel process events.
  374. #  It's used within the Game_Map class.
  375. #==============================================================================
  376.  
  377. class Game_Event < Game_Character
  378.   #--------------------------------------------------------------------------
  379.   # * Public Instance Variables
  380.   #--------------------------------------------------------------------------
  381.   attr_accessor :id
  382. end
  383.  
  384.  
  385.  
  386. #==============================================================================
  387. # ** Spriteset_Map
  388. #------------------------------------------------------------------------------
  389. #  This class brings together map screen sprites, tilemaps, etc.
  390. #  It's used within the Scene_Map class.
  391. #==============================================================================
  392.  
  393. class Spriteset_Map
  394.   #--------------------------------------------------------------------------
  395.   # * Public Instance Variables
  396.   #--------------------------------------------------------------------------  
  397.   attr_accessor :shadows
  398.   #--------------------------------------------------------------------------
  399.   # * Alias Listings
  400.   #--------------------------------------------------------------------------  
  401.   alias shadow_initialize initialize
  402.   #--------------------------------------------------------------------------
  403.   # * Object Initialization
  404.   #--------------------------------------------------------------------------  
  405.   def initialize
  406.     $game_temp.shadow_spriteset = self
  407.     @shadows = []
  408.     warn = false
  409.     for k in $game_map.events.keys.sort
  410.       if ($game_map.events[k].list != nil and
  411.             $game_map.events[k].list[0].code == 108 and
  412.             ($game_map.events[k].list[0].parameters == ["s"] or
  413.             $game_map.events[k].list[0].parameters == ["o"]))
  414.         warn = true        
  415.       end
  416.       params = XPML.XPML_read("Shadow Source", k, 5)
  417.       if params != nil
  418.         $game_temp.shadow_spriteset.shadows.push([$game_map.events[k]] + params)
  419.       end
  420.     end
  421.     if warn == true and SHADOW_WARN
  422.       p "Warning : At least one event on this map uses an obsolete way to add shadows"
  423.     end
  424.     # Perform the original call
  425.     shadow_initialize
  426.   end  
  427. end
  428.  
  429.  
  430.  
  431. #==============================================================================
  432. # ** module XPML
  433. #------------------------------------------------------------------------------
  434. #  This module handles the reading and passing of 'comment' parameters
  435. #
  436. #  The main XPML method is used to check and read event comments.
  437. #  * It returns 'nil' if the markup 'check' text isn't even present.
  438. #  * It returns [] if no parameters are passed
  439. #  * It returns a parameter list with "int" converted as int.
  440. #       eg :
  441. #       begin first
  442. #       begin second
  443. #       param1 1
  444. #       param2 two
  445. #       begin third
  446. #       anything 3
  447. #
  448. #   p XPML_read("first", event_id) -> []
  449. #   p XPML_read("second", event_id) -> [1,"two"]
  450. #   p XPML_read("third", event_id) -> [3]
  451. #   p XPML_read("forth", event_id) -> nil
  452. #===================================================
  453.  
  454. module XPML
  455.   module_function
  456.   #--------------------------------------------------------------------------
  457.   # * XPML_read
  458.   #     markup           : text in event comment to check
  459.   #     event_id         : event ID
  460.   #     max_param_number : maximum number of parameter/comments to load
  461.   #--------------------------------------------------------------------------  
  462.   def XPML_read(markup, event_id, max_param_number = 0)
  463.     parameter_list = nil
  464.     event = $game_map.events[event_id]
  465.     return if event.list == nil
  466.       for i in 0...event.list.size
  467.         if event.list[i].code == 108 and
  468.           event.list[i].parameters[0].downcase == "begin " + markup.downcase
  469.           parameter_list = [] if parameter_list == nil
  470.           for j in i + 1...event.list.size
  471.             if event.list[j].code == 108
  472.               parts = event.list[j].parameters[0].split
  473.               if parts.size != 1 and parts[0].downcase != "begin"
  474.                 if parts[1].to_i != 0 or parts[1] == "0"
  475.                   parameter_list.push(parts[1].to_i)
  476.                 else
  477.                   parameter_list.push(parts[1])
  478.                 end
  479.               else
  480.                 return parameter_list
  481.               end
  482.             else
  483.               return parameter_list
  484.             end
  485.             if max_param_number != 0 and j == i + max_param_number
  486.               return parameter_list
  487.             end
  488.           end
  489.         end
  490.       end
  491.     return parameter_list
  492.   end
  493. end
Expand to see the code.


  1. #==============================================================================
  2. # ** Sprite Sun
  3. #------------------------------------------------------------------------------
  4. #    Based on Sprite Shadow
  5. #    modified by Rataime
  6. #    New Edits by DerVVulfman
  7. #    February 12, 2008
  8. #------------------------------------------------------------------------------
  9. #
  10. # Introduction:
  11. #
  12. #  This system allows you and all 'prepared' events to generate shadows while
  13. #  on the field map. The player can move around while a programmed 'sun' will
  14. #  display a shadow.   Likewise,  events with a special comment  within their
  15. #  event list can also generate shadows.
  16. #
  17. #------------------------------------------------------------------------------
  18. #
  19. # Instructions:
  20. #
  21. #  -- The Sun
  22. #     To create a sun effect, you'll need to create a map event that's to be
  23. #     used 'as' the sun itself.   Under most circumstances,  this will be an
  24. #     event without a characterset graphic. You don't want to 'SEE' the sun,
  25. #     do you?
  26. #
  27. #     To make one of these events a 'sun,  you'll need to insert a couple of
  28. #     things into that event's  "List of Event Commands".   These things are
  29. #     nothing more than comments.  
  30. #
  31. #     The first comment  to add is "begin Sun" (without quotes).  It informs
  32. #     the system that this map  has a sun effect in use.   The remaining two
  33. #     values  are optional  and have  default values  in  the  configuration
  34. #     section  (only just added  into the script).   They too  are added  as
  35. #     comments.
  36. #
  37. #     self_angle  'number'  --- How much of an angle each shadow will have.
  38. #     self_opacity 'number' --- How dark the shadow will be.
  39. #
  40. #     After that, your characters can now move about and generate shadows.
  41. #
  42. #  -- Other Events
  43. #     Events do not know that they can generate shadows.   To let them gene-
  44. #     rate a shadow,  all you need to do is add a special comment into their
  45. #     "List of Event Commands".   This comment needed  is merely  the phrase
  46. #     'begin Shadow' (again, without quotes).
  47. #
  48. #
  49. #------------------------------------------------------------------------------
  50. #
  51. # Revisions to note:
  52. #
  53. #  1) Added formatted headers and comments throughout the script.
  54. #  2) Encapsulated a comment/parameter code in an XPML module.
  55. #  3) Set the sun shadow array into an instance value to lower resource costs.
  56. #  4) Compatability with Near Fantastica's Squad Movement systems.
  57. #  5) Compatability with Ccoa's Caterpillar system.
  58. #  6) Compatability with Trickster's Caterpillar system.
  59. #  7) Added default shadow settings into the configuration section.
  60. #
  61. #==============================================================================
  62.  
  63.  
  64.  
  65.    #========================================================================
  66.    #  **  C  O  N  F  I  G  U  R  A  T  I  O  N      S  Y  S  T  E  M  **  #
  67.    #========================================================================
  68.     # Caterpillar Systems
  69.     CATERPILLAR_COMPATIBLE      = true    # Toggle for Fukuyama's original  
  70.     SQUAD_MOVE_COMPATIBLE       = false   # Toggle for Near Fantastica's SBABS
  71.     CCOA_CATER_COMPATIBLE       = false   # Toggle for Ccoa's Caterpillar
  72.     TRICKSTER_CATER_COMPATIBLE  = false   # Toggle for Trickster's Caterpillar
  73.    
  74.     # Sun Specific Systems
  75.     SUN_WARN                    = true    # Checks for older sun systems
  76.     SUN_ANGLE                   = 45      # Angle for sun-generated shadow
  77.     SUN_OPACITY                 = 128     # Darkness setting for sun shadow
  78.  
  79.    
  80.    #========================================================================
  81.    #  ****   E N D   O F   C O N F I G U R A T I O N   S Y S T E M   ****  #
  82.    #========================================================================
  83.    
  84.    
  85.  
  86. #==============================================================================
  87. # ** Game_Temp
  88. #------------------------------------------------------------------------------
  89. #  This class handles temporary data that is not included with save data.
  90. #  Refer to "$game_temp" for the instance of this class.
  91. #==============================================================================
  92.  
  93. class Game_Temp
  94.   #--------------------------------------------------------------------------
  95.   # * Public Instance Variables
  96.   #--------------------------------------------------------------------------
  97.   attr_accessor :sun_spriteset            # holds spritesets for 'sun' shadows
  98. end
  99.  
  100.  
  101.  
  102. #==============================================================================
  103. # ** Game_Party
  104. #------------------------------------------------------------------------------
  105. #  This class handles the party. It includes information on amount of gold
  106. #  and items. Refer to "$game_party" for the instance of this class.
  107. #==============================================================================
  108.  
  109. class Game_Party
  110.   #--------------------------------------------------------------------------
  111.   # * Public Instance Variables
  112.   #--------------------------------------------------------------------------
  113.   attr_reader :characters
  114. end
  115.  
  116.  
  117.  
  118. #==============================================================================
  119. # ** Sprite_Sun
  120. #------------------------------------------------------------------------------
  121. #  This sprite is used to position character shadows relative to map position.
  122. #  It observes the Game_Character class and automatically changes sprite
  123. #  conditions.
  124. #==============================================================================
  125.  
  126. class Sprite_Sun < RPG::Sprite
  127.   #--------------------------------------------------------------------------
  128.   # * Public Instance Variables
  129.   #--------------------------------------------------------------------------
  130.   attr_accessor :character          
  131.   #--------------------------------------------------------------------------
  132.   # * Object Initialization
  133.   #     viewport  : viewport
  134.   #     character : character (Game_Character)
  135.   #     id        : id
  136.   #--------------------------------------------------------------------------
  137.   def initialize(viewport, character = nil, id=0)
  138.     super(viewport)
  139.     @character = character
  140.     params=$game_temp.sun_spriteset.sun[id]
  141.     self_angle    = SUN_ANGLE
  142.     self_opacity  = SUN_OPACITY
  143.     self_angle    = params[0]   if params.size > 0
  144.     self_opacity  = params[1]   if params.size > 1
  145.     @self_angle   = self_angle
  146.     @self_opacity = self_opacity
  147.     update
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # * Frame Update
  151.   #--------------------------------------------------------------------------  
  152.   def update
  153.     super
  154.     # If tile ID, file name, or hue are different from current ones
  155.     if @tile_id != @character.tile_id or
  156.        @character_name != @character.character_name or
  157.        @character_hue != @character.character_hue
  158.       # Remember tile ID, file name, and hue
  159.       @tile_id = @character.tile_id
  160.       @character_name = @character.character_name
  161.       @character_hue = @character.character_hue
  162.       # If tile ID value is valid      
  163.       if @tile_id >= 384
  164.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  165.           @tile_id, @character.character_hue)
  166.         self.src_rect.set(0, 0, 32, 32)
  167.         self.ox = 16
  168.         self.oy = 32
  169.       # If tile ID value is invalid        
  170.       else
  171.         self.bitmap = RPG::Cache.character(@character.character_name,
  172.           @character.character_hue)
  173.         @cw = bitmap.width / 4
  174.         @ch = bitmap.height / 4
  175.         self.ox = @cw / 2
  176.         self.oy = @ch
  177.       end
  178.     end
  179.     # Set visible situation
  180.     self.visible = (not @character.transparent)
  181.     # If graphic is character
  182.     if @tile_id == 0
  183.       # Set rectangular transfer    
  184.       sx = @character.pattern * @cw
  185.       @direct = @character.direction
  186.       if self.angle > 90 or angle < -90
  187.         sy = ( 4 - 2) / 2 * @ch                   if @direct == 6
  188.         sy = ( 6 - 2) / 2 * @ch                   if @direct == 4
  189.         sy = (@character.direction - 2) / 2 * @ch if @direct != 4 and @direct != 6
  190.       else
  191.         sy = (@character.direction - 2) / 2 * @ch
  192.       end
  193.       self.src_rect.set(sx, sy, @cw, @ch)
  194.     end
  195.     # Set sprite coordinates
  196.     self.x = @character.screen_x
  197.     self.y = @character.screen_y-5
  198.     self.z = @character.screen_z(@ch) - 1
  199.     # Set opacity level, blend method, and bush depth
  200.     self.opacity = @self_opacity
  201.     self.blend_type = @character.blend_type
  202.     self.bush_depth = @character.bush_depth
  203.     # Animation
  204.     if @character.animation_id != 0
  205.       animation = $data_animations[@character.animation_id]
  206.       animation(animation, true)
  207.       @character.animation_id = 0
  208.     end
  209.     self.angle = @self_angle.to_i - 90
  210.     self.color = Color.new(0, 0, 0)
  211.   end
  212. end
  213.  
  214.  
  215.  
  216. #==============================================================================
  217. # ** Sprite_Character
  218. #------------------------------------------------------------------------------
  219. #  This sprite is used to display the character.It observes the Game_Character
  220. #  class and automatically changes sprite conditions.
  221. #==============================================================================
  222.  
  223. class Sprite_Character < RPG::Sprite
  224.   #--------------------------------------------------------------------------
  225.   # * Alias Listings
  226.   #--------------------------------------------------------------------------  
  227.   alias sun_initialize initialize
  228.   alias sun_update update
  229.   #--------------------------------------------------------------------------
  230.   # * Object Initialization
  231.   #     viewport  : viewport
  232.   #     character : character (Game_Character)
  233.   #--------------------------------------------------------------------------
  234.   def initialize(viewport, character = nil)
  235.     @character = character
  236.     super(viewport)
  237.     @sunlist=[]
  238.     if character.is_a?(Game_Event) and $game_temp.sun_spriteset.sun != []
  239.       params = XPML.XPML_read("Shadow", @character.id, 2)
  240.       if params != nil
  241.         for i in 0...$game_temp.sun_spriteset.sun.size
  242.           @sunlist.push(Sprite_Sun.new(viewport, @character, i))
  243.         end
  244.       end
  245.     end
  246.     if character.is_a?(Game_Player) and $game_temp.sun_spriteset.sun != []
  247.       for i in 0...$game_temp.sun_spriteset.sun.size
  248.         @sunlist.push(Sprite_Sun.new(viewport, $game_player, i))
  249.       end
  250.       #===================================================
  251.       # * Compatibility with Caterpillar Functions
  252.       #===================================================
  253.       if CATERPILLAR_COMPATIBLE and $game_party.characters != nil
  254.         for member in $game_party.characters
  255.           for i in 0...$game_temp.sun_spriteset.sun.size
  256.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  257.           end
  258.         end
  259.       end
  260.       if SQUAD_MOVE_COMPATIBLE and $game_allies.values != nil
  261.         for member in $game_allies.values
  262.           for i in 0...$game_temp.sun_spriteset.sun.size
  263.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  264.           end
  265.         end
  266.       end
  267.       if CCOA_CATER_COMPATIBLE and $game_train.actors != nil
  268.         for member in $game_train.actors
  269.           for i in 0...$game_temp.sun_spriteset.sun.size
  270.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  271.           end
  272.         end
  273.       end
  274.       if TRICKSTER_CATER_COMPATIBLE and $game_party.followers != nil
  275.         for member in $game_party.followers
  276.           for i in 0...$game_temp.sun_spriteset.sun.size
  277.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  278.           end
  279.         end
  280.       end
  281.       #===================================================
  282.       # ** End of the compatibility
  283.       #===================================================      
  284.     end
  285.     # Perform the original call
  286.     sun_initialize(viewport, @character)
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # * Frame Update
  290.   #--------------------------------------------------------------------------  
  291.   def update
  292.     sun_update
  293.     if @sunlist != []
  294.       for i in [email hidden]
  295.         @sunlist[i].update
  296.       end
  297.     end
  298.   end  
  299. end
  300.  
  301.  
  302.  
  303. #==============================================================================
  304. # ** Game_Event
  305. #------------------------------------------------------------------------------
  306. #  This class deals with events. It handles functions including event page
  307. #  switching via condition determinants, and running parallel process events.
  308. #  It's used within the Game_Map class.
  309. #==============================================================================
  310.  
  311. class Game_Event < Game_Character
  312.   #--------------------------------------------------------------------------
  313.   # * Public Instance Variables
  314.   #--------------------------------------------------------------------------
  315.   attr_accessor :id
  316. end
  317.  
  318.  
  319.  
  320. #==============================================================================
  321. # ** Spriteset_Map
  322. #------------------------------------------------------------------------------
  323. #  This class brings together map screen sprites, tilemaps, etc.
  324. #  It's used within the Scene_Map class.
  325. #==============================================================================
  326.  
  327. class Spriteset_Map
  328.   #--------------------------------------------------------------------------
  329.   # * Public Instance Variables
  330.   #--------------------------------------------------------------------------  
  331.   attr_accessor :sun
  332.   #--------------------------------------------------------------------------
  333.   # * Alias Listings
  334.   #--------------------------------------------------------------------------  
  335.   alias sun_initialize initialize
  336.   #--------------------------------------------------------------------------
  337.   # * Object Initialization
  338.   #--------------------------------------------------------------------------    
  339.   def initialize
  340.     @sun = []
  341.     $game_temp.sun_spriteset = self
  342.     warn = false
  343.     for k in $game_map.events.keys.sort
  344.       if ($game_map.events[k].list != nil and
  345.           $game_map.events[k].list[0].code == 108 and
  346.           ($game_map.events[k].list[0].parameters == ["sun"] or
  347.           $game_map.events[k].list[0].parameters == ["o"]))
  348.         warn = true
  349.       end
  350.       params = XPML.XPML_read("Sun", k, 2)
  351.       $game_temp.sun_spriteset.sun.push(params) if params != nil
  352.     end
  353.     if warn == true and SUN_WARN
  354.       p "Warning : At least one event on this map uses an obsolete way to add a sun effect"
  355.     end
  356.     # Perform the original call
  357.     sun_initialize
  358.   end  
  359. end
  360.  
  361.  
  362. #==============================================================================
  363. # ** module XPML
  364. #------------------------------------------------------------------------------
  365. #  This module handles the reading and passing of 'comment' parameters
  366. #
  367. #  The main XPML method is used to check and read event comments.
  368. #  * It returns 'nil' if the markup 'check' text isn't even present.
  369. #  * It returns [] if no parameters are passed
  370. #  * It returns a parameter list with "int" converted as int.
  371. #       eg :
  372. #       begin first
  373. #       begin second
  374. #       param1 1
  375. #       param2 two
  376. #       begin third
  377. #       anything 3
  378. #
  379. #   p XPML_read("first", event_id) -> []
  380. #   p XPML_read("second", event_id) -> [1,"two"]
  381. #   p XPML_read("third", event_id) -> [3]
  382. #   p XPML_read("forth", event_id) -> nil
  383. #===================================================
  384.  
  385. module XPML
  386.   module_function
  387.   #--------------------------------------------------------------------------
  388.   # * XPML_read
  389.   #     markup           : text in event comment to check
  390.   #     event_id         : event ID
  391.   #     max_param_number : maximum number of parameter/comments to load
  392.   #--------------------------------------------------------------------------  
  393.   def XPML_read(markup, event_id, max_param_number = 0)
  394.     parameter_list = nil
  395.     event = $game_map.events[event_id]
  396.     return if event.list == nil
  397.       for i in 0...event.list.size
  398.         if event.list[i].code == 108 and
  399.           event.list[i].parameters[0].downcase == "begin " + markup.downcase
  400.           parameter_list = [] if parameter_list == nil
  401.           for j in i + 1...event.list.size
  402.             if event.list[j].code == 108
  403.               parts = event.list[j].parameters[0].split
  404.               if parts.size != 1 and parts[0].downcase != "begin"
  405.                 if parts[1].to_i != 0 or parts[1] == "0"
  406.                   parameter_list.push(parts[1].to_i)
  407.                 else
  408.                   parameter_list.push(parts[1])
  409.                 end
  410.               else
  411.                 return parameter_list
  412.               end
  413.             else
  414.               return parameter_list
  415.             end
  416.             if max_param_number != 0 and j == i + max_param_number
  417.               return parameter_list
  418.             end
  419.           end
  420.         end
  421.       end
  422.     return parameter_list
  423.   end
  424. end
Expand to see the code.


EDIT: Please let me know if I have left out something that you require. I will be more than happy to post it. Thank you!
  1. #==============================================================================
  2. # ** Sprite Shadow (Sprite_Ombre )
  3. #------------------------------------------------------------------------------
  4. #    Based on Genzai Kawakami's shadows
  5. #    dynamisme & features by Rataime
  6. #    extra features Boushy
  7. #    New Edits by DerVVulfman
  8. #    February 24, 2008
  9. #
  10. #------------------------------------------------------------------------------
  11. #
  12. # Introduction:
  13. #
  14. #  This system allows you and all 'prepared' events to generate shadows while
  15. #  on the field map.   The player can move around  a 'light source' event and
  16. #  display a shadow.   Likewise,  events with a special comment  within their
  17. #  event list can also generate shadows.
  18. #
  19. #------------------------------------------------------------------------------
  20. #
  21. # Instructions:
  22. #
  23. #  -- The Light Source
  24. #     To create a light source, you need to create a map event that is to be
  25. #     used 'as' the light source.   Most of the time,  these could be events
  26. #     that sport 'torch' or 'lantern' charactersets.  Just examples :)
  27. #
  28. #     To make one of these events a light source,  you need  to insert a few
  29. #     things into that event's  "List of Event Commands".   These things are
  30. #     nothing more than comments.  
  31. #
  32. #     The first comment to add is "begin Shadow Source" (without quotes). It
  33. #     informs the system  that this event is a light source.   The remaining
  34. #     three values are optional and have default values in the configuration
  35. #     section  (only just added  into the script).   They too  are added  as
  36. #     comments.
  37. #
  38. #     anglemin 'number'     --- Starting position of a lightsource's arc.
  39. #     anglemax 'number'     --- Ending position of a lightsource's arc.
  40. #     distancemax 'number'  --- How far away from the 'source' you can go
  41. #     self_opacity 'number' --- How dark the shadow will grow.
  42. #
  43. #     After that, your characters can now move about and generate shadows.
  44. #
  45. #  -- Other Events
  46. #     Events do not know that they can generate shadows.   To let them gene-
  47. #     rate a shadow,  all you need to do is add a special comment into their
  48. #     "List of Event Commands".   This comment needed  is merely  the phrase
  49. #     'begin Shadow' (again, without quotes).
  50. #
  51. #
  52. #  -- Blocking Shadows
  53. #     To prevent shadows  from passing through  solid objects such as doors,
  54. #     walls, cabinets or other forms of furniture,  you will want to apply a
  55. #     priority flag of '1' or higher on these items.  Normally, walls in the
  56. #     default database do not have a priority flag as they merely block  the
  57. #     player from passing through.
  58. #    
  59. #
  60. #------------------------------------------------------------------------------
  61. #
  62. # Revisions to note:
  63. #
  64. #  1) Added formatted headers and comments throughout the script.
  65. #  2) Encapsulated a comment/parameter code in an XPML module.
  66. #  3) Set the shadow array into an instance value to lower resource costs.
  67. #  4) Compatability with Near Fantastica's Squad Movement systems.
  68. #  5) Compatability with Ccoa's Caterpillar system.
  69. #  6) Compatability with Trickster's Caterpillar system.
  70. #  7) Added default shadow settings into the configuration section.
  71. #
  72. #==============================================================================
  73.  
  74.  
  75.  
  76.    #========================================================================
  77.    #  **  C  O  N  F  I  G  U  R  A  T  I  O  N      S  Y  S  T  E  M  **  #
  78.    #========================================================================
  79.     # Caterpillar Systems
  80.     CATERPILLAR_COMPATIBLE      = true    # Toggle for Fukuyama's original  
  81.     SQUAD_MOVE_COMPATIBLE       = false   # Toggle for Near Fantastica's SBABS
  82.     CCOA_CATER_COMPATIBLE       = false   # Toggle for Ccoa's Caterpillar
  83.     TRICKSTER_CATER_COMPATIBLE  = false   # Toggle for Trickster's Caterpillar
  84.    
  85.     # Shadow Specific Systems
  86.     SHADOW_WARN                 = true    # Checks for older shadow system
  87.     SHADOW_MIN                  = 0       # Start setting of shadow arc *
  88.     SHADOW_MAX                  = 0       # Ending setting of shadow arc *
  89.     SHADOW_OPACITY              = 150     # Darkness level of shadow
  90.     SHADOW_DISTANCE             = 350     # Maximum range in pixels
  91.  
  92.     # * SHADOW ARC:  Set in degrees,  this controls whether a light source
  93.     #                can 'force' shadows in certain directions.  Useful if
  94.     #                a light source is hanging on a wall so it cannot make
  95.     #                a shadow THROUGH a wall.
  96.     #
  97.     #                It may take some practice  to set  the desired angles
  98.     #                as it recognizes 90°  being the  top most part  of an
  99.     #                arc,  180° being the leftmost side and so on...  pro-
  100.     #                ceeding in a counter-clockwise motion.
  101.    
  102.    #========================================================================
  103.    #  ****   E N D   O F   C O N F I G U R A T I O N   S Y S T E M   ****  #
  104.    #========================================================================
  105.    
  106.    
  107.  
  108. #==============================================================================
  109. # ** Game_Temp
  110. #------------------------------------------------------------------------------
  111. #  This class handles temporary data that is not included with save data.
  112. #  Refer to "$game_temp" for the instance of this class.
  113. #==============================================================================
  114.  
  115. class Game_Temp
  116.   #--------------------------------------------------------------------------
  117.   # * Public Instance Variables
  118.   #--------------------------------------------------------------------------
  119.   attr_accessor :shadow_spriteset         # holds shadow spritesets
  120. end
  121.  
  122.  
  123.  
  124. #==============================================================================
  125. # ** Game_Party
  126. #------------------------------------------------------------------------------
  127. #  This class handles the party. It includes information on amount of gold
  128. #  and items. Refer to "$game_party" for the instance of this class.
  129. #==============================================================================
  130.  
  131. class Game_Party
  132.   #--------------------------------------------------------------------------
  133.   # * Public Instance Variables
  134.   #--------------------------------------------------------------------------
  135.   attr_reader :characters
  136. end
  137.  
  138.  
  139.  
  140. #==============================================================================
  141. # ** Sprite_Shadow
  142. #------------------------------------------------------------------------------
  143. #  This sprite is used to display the character's shadow.  It observes the
  144. #  Game_Character class and automatically changes sprite conditions.
  145. #==============================================================================
  146. class Sprite_Shadow < RPG::Sprite
  147.   #--------------------------------------------------------------------------
  148.   # * Public Instance Variables
  149.   #--------------------------------------------------------------------------
  150.   attr_accessor :character
  151.   #--------------------------------------------------------------------------
  152.   # * Object Initialization
  153.   #     viewport  : viewport
  154.   #     character : character (Game_Character)
  155.   #     id        : id
  156.   #--------------------------------------------------------------------------
  157.   def initialize(viewport, character = nil, id = 0)
  158.     super(viewport)
  159.     params  = $game_temp.shadow_spriteset.shadows[id]
  160.     @source = params[0]
  161.     # Default settings
  162.     @anglemin     = SHADOW_MIN
  163.     @anglemax     = SHADOW_MAX
  164.     @self_opacity = SHADOW_OPACITY
  165.     @distancemax  = SHADOW_DISTANCE
  166.     # Settings changed by parameters
  167.     @anglemin     = params[1]   if params.size > 1
  168.     @anglemax     = params[2]   if params.size > 2
  169.     @distancemax  = params[3]   if params.size > 3
  170.     @self_opacity = params[4]   if params.size > 4
  171.     @character = character
  172.     update
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # * Frame Update
  176.   #--------------------------------------------------------------------------
  177.   def update
  178.     # If shadow not in range of light source
  179.     if !in_range?(@character, @source, @distancemax)
  180.       self.opacity = 0
  181.       return
  182.     end
  183.     super
  184.     # If tile ID, file name, or hue are different from current ones
  185.     if @tile_id != @character.tile_id or
  186.        @character_name != @character.character_name or
  187.        @character_hue != @character.character_hue
  188.       # Remember tile ID, file name, and hue
  189.       @tile_id = @character.tile_id
  190.       @character_name = @character.character_name
  191.       @character_hue = @character.character_hue
  192.       # If tile ID value is valid
  193.       if @tile_id >= 384
  194.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  195.           @tile_id, @character.character_hue)
  196.         self.src_rect.set(0, 0, 32, 32)
  197.         self.ox = 16
  198.         self.oy = 32
  199.       # If tile ID value is invalid        
  200.       else
  201.         self.bitmap = RPG::Cache.character(@character.character_name,
  202.           @character.character_hue)
  203.         @cw = bitmap.width / 4
  204.         @ch = bitmap.height / 4
  205.         self.ox = @cw / 2
  206.         self.oy = @ch
  207.       end
  208.     end
  209.     # Set visible situation
  210.     self.visible = (not @character.transparent)
  211.     # If graphic is character
  212.     if @tile_id == 0
  213.       # Set rectangular transfer
  214.       sx = @character.pattern * @cw
  215.       sy = (@character.direction - 2) / 2 * @ch
  216.       if self.angle > 90 or angle < -90
  217.         sy = ( 4 - 2) / 2 * @ch   if @character.direction == 6
  218.         sy = ( 6 - 2) / 2 * @ch   if @character.direction == 4
  219.         sy = ( 8 - 2) / 2 * @ch   if @character.direction == 2
  220.         sy = ( 2 - 2) / 2 * @ch   if @character.direction == 8
  221.       end
  222.       self.src_rect.set(sx, sy, @cw, @ch)
  223.     end
  224.     # Set sprite coordinates    
  225.     self.x = @character.screen_x
  226.     self.y = @character.screen_y-5
  227.     self.z = @character.screen_z(@ch)-1
  228.     # Set blend method and bush depth
  229.     self.blend_type = @character.blend_type
  230.     self.bush_depth = @character.bush_depth
  231.     # Animation
  232.     if @character.animation_id != 0
  233.       animation = $data_animations[@character.animation_id]
  234.       animation(animation, true)
  235.       @character.animation_id = 0
  236.     end
  237.     @deltax       = @source.screen_x - self.x
  238.     @deltay       = @source.screen_y - self.y
  239.     self.color    = Color.new(0, 0, 0)
  240.     @distance     = ((@deltax ** 2) + (@deltay ** 2))
  241.     # Set opacity level based on light source distance
  242.     self.opacity  = @self_opacity * 13000 /
  243.                       ((@distance * 370 / @distancemax) + 6000)
  244.     self.angle    = 57.3 * Math.atan2(@deltax, @deltay )
  245.     @angle_trigo  = self.angle+90
  246.     if @angle_trigo < 0
  247.         @angle_trigo = 360 + @angle_trigo
  248.      end
  249.     if @anglemin != 0 or @anglemax != 0
  250.        if (@angle_trigo < @anglemin or @angle_trigo > @anglemax) and
  251.           @anglemin < @anglemax
  252.          self.opacity = 0
  253.          return
  254.        end
  255.        if (@angle_trigo < @anglemin and @angle_trigo > @anglemax) and
  256.           @anglemin > @anglemax
  257.          self.opacity=0
  258.          return
  259.        end    
  260.      end
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # * In Range?  (From Near's Anti Lag Script, edited)
  264.   #     element     : element
  265.   #     object      : object
  266.   #     range       : range in tiles
  267.   #--------------------------------------------------------------------------  
  268.   def in_range?(element, object, range)
  269.     x = (element.screen_x - object.screen_x) * (element.screen_x - object.screen_x)
  270.     y = (element.screen_y - object.screen_y) * (element.screen_y - object.screen_y)
  271.     r = x + y
  272.     if r <= (range * range)
  273.        return true
  274.     else
  275.       return false
  276.     end
  277.   end
  278. end
  279.  
  280.  
  281.  
  282. #==============================================================================
  283. # ** Sprite_Character
  284. #------------------------------------------------------------------------------
  285. #  This sprite is used to display the character.It observes the Game_Character
  286. #  class and automatically changes sprite conditions.
  287. #==============================================================================
  288.  
  289. class Sprite_Character < RPG::Sprite
  290.   #--------------------------------------------------------------------------
  291.   # * Alias Listings
  292.   #--------------------------------------------------------------------------
  293.   alias shadow_initialize initialize
  294.   alias shadow_update update  
  295.   #--------------------------------------------------------------------------
  296.   # * Object Initialization
  297.   #     viewport  : viewport
  298.   #     character : character (Game_Character)
  299.   #--------------------------------------------------------------------------
  300.   def initialize(viewport, character = nil)
  301.     @character = character
  302.     super(viewport)
  303.     @ombrelist = []
  304.     if character.is_a?(Game_Event) and $game_temp.shadow_spriteset.shadows != []
  305.       params = XPML.XPML_read("Shadow", @character.id, 5)
  306.       if params != nil
  307.         for i in 0...$game_temp.shadow_spriteset.shadows.size
  308.           @ombrelist.push(Sprite_Shadow.new(viewport, @character,i))
  309.         end
  310.       end
  311.     end
  312.     if $scene == Scene_Map.new
  313.     if character.is_a?(Game_Player) and $game_temp.shadow_spriteset.shadows != []
  314.       for i in 0...$game_temp.shadow_spriteset.shadows.size
  315.         @ombrelist.push(Sprite_Shadow.new(viewport, $game_player,i))
  316.       end
  317.       end
  318.       #===================================================
  319.       # * Compatibility with Caterpillar Functions
  320.       #===================================================
  321.       if CATERPILLAR_COMPATIBLE and $game_party.characters != nil
  322.         for member in $game_party.characters
  323.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  324.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  325.           end
  326.         end
  327.       end
  328.       if SQUAD_MOVE_COMPATIBLE and $game_allies.values != nil
  329.         for member in $game_allies.values
  330.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  331.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  332.           end
  333.         end
  334.       end
  335.       if CCOA_CATER_COMPATIBLE and $game_train.actors != nil
  336.         for member in $game_train.actors
  337.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  338.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  339.           end
  340.         end
  341.       end
  342.       if TRICKSTER_CATER_COMPATIBLE and $game_party.followers != nil
  343.         for member in $game_party.followers
  344.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  345.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  346.           end
  347.         end
  348.       end
  349.       #===================================================
  350.       # ** End of the compatibility
  351.       #===================================================      
  352.     end
  353.     # Perform the original call
  354.     shadow_initialize(viewport, @character)
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # * Frame Update
  358.   #--------------------------------------------------------------------------
  359.   def update
  360.     shadow_update
  361.     if @ombrelist != []
  362.       for i in [email hidden]
  363.         @ombrelist[i].update
  364.       end
  365.     end
  366.   end  
  367. end
  368.  
  369.  
  370.  
  371. #==============================================================================
  372. # ** Game_Event
  373. #------------------------------------------------------------------------------
  374. #  This class deals with events. It handles functions including event page
  375. #  switching via condition determinants, and running parallel process events.
  376. #  It's used within the Game_Map class.
  377. #==============================================================================
  378.  
  379. class Game_Event < Game_Character
  380.   #--------------------------------------------------------------------------
  381.   # * Public Instance Variables
  382.   #--------------------------------------------------------------------------
  383.   attr_accessor :id
  384. end
  385.  
  386.  
  387.  
  388. #==============================================================================
  389. # ** Spriteset_Map
  390. #------------------------------------------------------------------------------
  391. #  This class brings together map screen sprites, tilemaps, etc.
  392. #  It's used within the Scene_Map class.
  393. #==============================================================================
  394.  
  395. class Spriteset_Map
  396.   #--------------------------------------------------------------------------
  397.   # * Public Instance Variables
  398.   #--------------------------------------------------------------------------  
  399.   attr_accessor :shadows
  400.   #--------------------------------------------------------------------------
  401.   # * Alias Listings
  402.   #--------------------------------------------------------------------------  
  403.   alias shadow_initialize initialize
  404.   #--------------------------------------------------------------------------
  405.   # * Object Initialization
  406.   #--------------------------------------------------------------------------  
  407.   def initialize
  408.     $game_temp.shadow_spriteset = self
  409.     @shadows = []
  410.     warn = false
  411.     for k in $game_map.events.keys.sort
  412.       if ($game_map.events[k].list != nil and
  413.             $game_map.events[k].list[0].code == 108 and
  414.             ($game_map.events[k].list[0].parameters == ["s"] or
  415.             $game_map.events[k].list[0].parameters == ["o"]))
  416.         warn = true        
  417.       end
  418.       params = XPML.XPML_read("Shadow Source", k, 5)
  419.       if params != nil
  420.         $game_temp.shadow_spriteset.shadows.push([$game_map.events[k]] + params)
  421.       end
  422.     end
  423.     if warn == true and SHADOW_WARN
  424.       p "Warning : At least one event on this map uses an obsolete way to add shadows"
  425.     end
  426.     # Perform the original call
  427.     shadow_initialize
  428.   end  
  429. end
  430.  
  431.  
  432.  
  433. #==============================================================================
  434. # ** module XPML
  435. #------------------------------------------------------------------------------
  436. #  This module handles the reading and passing of 'comment' parameters
  437. #
  438. #  The main XPML method is used to check and read event comments.
  439. #  * It returns 'nil' if the markup 'check' text isn't even present.
  440. #  * It returns [] if no parameters are passed
  441. #  * It returns a parameter list with "int" converted as int.
  442. #       eg :
  443. #       begin first
  444. #       begin second
  445. #       param1 1
  446. #       param2 two
  447. #       begin third
  448. #       anything 3
  449. #
  450. #   p XPML_read("first", event_id) -> []
  451. #   p XPML_read("second", event_id) -> [1,"two"]
  452. #   p XPML_read("third", event_id) -> [3]
  453. #   p XPML_read("forth", event_id) -> nil
  454. #===================================================
  455.  
  456. module XPML
  457.   module_function
  458.   #--------------------------------------------------------------------------
  459.   # * XPML_read
  460.   #     markup           : text in event comment to check
  461.   #     event_id         : event ID
  462.   #     max_param_number : maximum number of parameter/comments to load
  463.   #--------------------------------------------------------------------------  
  464.   def XPML_read(markup, event_id, max_param_number = 0)
  465.     parameter_list = nil
  466.     event = $game_map.events[event_id]
  467.     return if event.list == nil
  468.       for i in 0...event.list.size
  469.         if event.list[i].code == 108 and
  470.           event.list[i].parameters[0].downcase == "begin " + markup.downcase
  471.           parameter_list = [] if parameter_list == nil
  472.           for j in i + 1...event.list.size
  473.             if event.list[j].code == 108
  474.               parts = event.list[j].parameters[0].split
  475.               if parts.size != 1 and parts[0].downcase != "begin"
  476.                 if parts[1].to_i != 0 or parts[1] == "0"
  477.                   parameter_list.push(parts[1].to_i)
  478.                 else
  479.                   parameter_list.push(parts[1])
  480.                 end
  481.               else
  482.                 return parameter_list
  483.               end
  484.             else
  485.               return parameter_list
  486.             end
  487.             if max_param_number != 0 and j == i + max_param_number
  488.               return parameter_list
  489.             end
  490.           end
  491.         end
  492.       end
  493.     return parameter_list
  494.   end
  495. end
Expand to see the code.


  1. #==============================================================================
  2. # ** Sprite Sun
  3. #------------------------------------------------------------------------------
  4. #    Based on Sprite Shadow
  5. #    modified by Rataime
  6. #    New Edits by DerVVulfman
  7. #    February 12, 2008
  8. #------------------------------------------------------------------------------
  9. #
  10. # Introduction:
  11. #
  12. #  This system allows you and all 'prepared' events to generate shadows while
  13. #  on the field map. The player can move around while a programmed 'sun' will
  14. #  display a shadow.   Likewise,  events with a special comment  within their
  15. #  event list can also generate shadows.
  16. #
  17. #------------------------------------------------------------------------------
  18. #
  19. # Instructions:
  20. #
  21. #  -- The Sun
  22. #     To create a sun effect, you'll need to create a map event that's to be
  23. #     used 'as' the sun itself.   Under most circumstances,  this will be an
  24. #     event without a characterset graphic. You don't want to 'SEE' the sun,
  25. #     do you?
  26. #
  27. #     To make one of these events a 'sun,  you'll need to insert a couple of
  28. #     things into that event's  "List of Event Commands".   These things are
  29. #     nothing more than comments.  
  30. #
  31. #     The first comment  to add is "begin Sun" (without quotes).  It informs
  32. #     the system that this map  has a sun effect in use.   The remaining two
  33. #     values  are optional  and have  default values  in  the  configuration
  34. #     section  (only just added  into the script).   They too  are added  as
  35. #     comments.
  36. #
  37. #     self_angle  'number'  --- How much of an angle each shadow will have.
  38. #     self_opacity 'number' --- How dark the shadow will be.
  39. #
  40. #     After that, your characters can now move about and generate shadows.
  41. #
  42. #  -- Other Events
  43. #     Events do not know that they can generate shadows.   To let them gene-
  44. #     rate a shadow,  all you need to do is add a special comment into their
  45. #     "List of Event Commands".   This comment needed  is merely  the phrase
  46. #     'begin Shadow' (again, without quotes).
  47. #
  48. #
  49. #------------------------------------------------------------------------------
  50. #
  51. # Revisions to note:
  52. #
  53. #  1) Added formatted headers and comments throughout the script.
  54. #  2) Encapsulated a comment/parameter code in an XPML module.
  55. #  3) Set the sun shadow array into an instance value to lower resource costs.
  56. #  4) Compatability with Near Fantastica's Squad Movement systems.
  57. #  5) Compatability with Ccoa's Caterpillar system.
  58. #  6) Compatability with Trickster's Caterpillar system.
  59. #  7) Added default shadow settings into the configuration section.
  60. #
  61. #==============================================================================
  62.  
  63.  
  64.  
  65.    #========================================================================
  66.    #  **  C  O  N  F  I  G  U  R  A  T  I  O  N      S  Y  S  T  E  M  **  #
  67.    #========================================================================
  68.     # Caterpillar Systems
  69.     CATERPILLAR_COMPATIBLE      = true    # Toggle for Fukuyama's original  
  70.     SQUAD_MOVE_COMPATIBLE       = false   # Toggle for Near Fantastica's SBABS
  71.     CCOA_CATER_COMPATIBLE       = false   # Toggle for Ccoa's Caterpillar
  72.     TRICKSTER_CATER_COMPATIBLE  = false   # Toggle for Trickster's Caterpillar
  73.    
  74.     # Sun Specific Systems
  75.     SUN_WARN                    = true    # Checks for older sun systems
  76.     SUN_ANGLE                   = 45      # Angle for sun-generated shadow
  77.     SUN_OPACITY                 = 128     # Darkness setting for sun shadow
  78.  
  79.    
  80.    #========================================================================
  81.    #  ****   E N D   O F   C O N F I G U R A T I O N   S Y S T E M   ****  #
  82.    #========================================================================
  83.    
  84.    
  85.  
  86. #==============================================================================
  87. # ** Game_Temp
  88. #------------------------------------------------------------------------------
  89. #  This class handles temporary data that is not included with save data.
  90. #  Refer to "$game_temp" for the instance of this class.
  91. #==============================================================================
  92.  
  93. class Game_Temp
  94.   #--------------------------------------------------------------------------
  95.   # * Public Instance Variables
  96.   #--------------------------------------------------------------------------
  97.   attr_accessor :sun_spriteset            # holds spritesets for 'sun' shadows
  98. end
  99.  
  100.  
  101.  
  102. #==============================================================================
  103. # ** Game_Party
  104. #------------------------------------------------------------------------------
  105. #  This class handles the party. It includes information on amount of gold
  106. #  and items. Refer to "$game_party" for the instance of this class.
  107. #==============================================================================
  108.  
  109. class Game_Party
  110.   #--------------------------------------------------------------------------
  111.   # * Public Instance Variables
  112.   #--------------------------------------------------------------------------
  113.   attr_reader :characters
  114. end
  115.  
  116.  
  117.  
  118. #==============================================================================
  119. # ** Sprite_Sun
  120. #------------------------------------------------------------------------------
  121. #  This sprite is used to position character shadows relative to map position.
  122. #  It observes the Game_Character class and automatically changes sprite
  123. #  conditions.
  124. #==============================================================================
  125.  
  126. class Sprite_Sun < RPG::Sprite
  127.   #--------------------------------------------------------------------------
  128.   # * Public Instance Variables
  129.   #--------------------------------------------------------------------------
  130.   attr_accessor :character          
  131.   #--------------------------------------------------------------------------
  132.   # * Object Initialization
  133.   #     viewport  : viewport
  134.   #     character : character (Game_Character)
  135.   #     id        : id
  136.   #--------------------------------------------------------------------------
  137.   def initialize(viewport, character = nil, id=0)
  138.     super(viewport)
  139.     @character = character
  140.     params=$game_temp.sun_spriteset.sun[id]
  141.     self_angle    = SUN_ANGLE
  142.     self_opacity  = SUN_OPACITY
  143.     self_angle    = params[0]   if params.size > 0
  144.     self_opacity  = params[1]   if params.size > 1
  145.     @self_angle   = self_angle
  146.     @self_opacity = self_opacity
  147.     update
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # * Frame Update
  151.   #--------------------------------------------------------------------------  
  152.   def update
  153.     super
  154.     # If tile ID, file name, or hue are different from current ones
  155.     if @tile_id != @character.tile_id or
  156.        @character_name != @character.character_name or
  157.        @character_hue != @character.character_hue
  158.       # Remember tile ID, file name, and hue
  159.       @tile_id = @character.tile_id
  160.       @character_name = @character.character_name
  161.       @character_hue = @character.character_hue
  162.       # If tile ID value is valid      
  163.       if @tile_id >= 384
  164.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  165.           @tile_id, @character.character_hue)
  166.         self.src_rect.set(0, 0, 32, 32)
  167.         self.ox = 16
  168.         self.oy = 32
  169.       # If tile ID value is invalid        
  170.       else
  171.         self.bitmap = RPG::Cache.character(@character.character_name,
  172.           @character.character_hue)
  173.         @cw = bitmap.width / 4
  174.         @ch = bitmap.height / 4
  175.         self.ox = @cw / 2
  176.         self.oy = @ch
  177.       end
  178.     end
  179.     # Set visible situation
  180.     self.visible = (not @character.transparent)
  181.     # If graphic is character
  182.     if @tile_id == 0
  183.       # Set rectangular transfer    
  184.       sx = @character.pattern * @cw
  185.       @direct = @character.direction
  186.       if self.angle > 90 or angle < -90
  187.         sy = ( 4 - 2) / 2 * @ch                   if @direct == 6
  188.         sy = ( 6 - 2) / 2 * @ch                   if @direct == 4
  189.         sy = (@character.direction - 2) / 2 * @ch if @direct != 4 and @direct != 6
  190.       else
  191.         sy = (@character.direction - 2) / 2 * @ch
  192.       end
  193.       self.src_rect.set(sx, sy, @cw, @ch)
  194.     end
  195.     # Set sprite coordinates
  196.     self.x = @character.screen_x
  197.     self.y = @character.screen_y-5
  198.     self.z = @character.screen_z(@ch) - 1
  199.     # Set opacity level, blend method, and bush depth
  200.     self.opacity = @self_opacity
  201.     self.blend_type = @character.blend_type
  202.     self.bush_depth = @character.bush_depth
  203.     # Animation
  204.     if @character.animation_id != 0
  205.       animation = $data_animations[@character.animation_id]
  206.       animation(animation, true)
  207.       @character.animation_id = 0
  208.     end
  209.     self.angle = @self_angle.to_i - 90
  210.     self.color = Color.new(0, 0, 0)
  211.   end
  212. end
  213.  
  214.  
  215.  
  216. #==============================================================================
  217. # ** Sprite_Character
  218. #------------------------------------------------------------------------------
  219. #  This sprite is used to display the character.It observes the Game_Character
  220. #  class and automatically changes sprite conditions.
  221. #==============================================================================
  222.  
  223. class Sprite_Character < RPG::Sprite
  224.   #--------------------------------------------------------------------------
  225.   # * Alias Listings
  226.   #--------------------------------------------------------------------------  
  227.   alias sun_initialize initialize
  228.   alias sun_update update
  229.   #--------------------------------------------------------------------------
  230.   # * Object Initialization
  231.   #     viewport  : viewport
  232.   #     character : character (Game_Character)
  233.   #--------------------------------------------------------------------------
  234.   def initialize(viewport, character = nil)
  235.     @character = character
  236.     super(viewport)
  237.     @sunlist=[]
  238.     if character.is_a?(Game_Event) and $game_temp.sun_spriteset.sun != []
  239.       params = XPML.XPML_read("Shadow", @character.id, 2)
  240.       if params != nil
  241.         for i in 0...$game_temp.sun_spriteset.sun.size
  242.           @sunlist.push(Sprite_Sun.new(viewport, @character, i))
  243.         end
  244.       end
  245.     end
  246.     if $scene == Scene_Map.new
  247.       if character.is_a?(Game_Player) and $game_temp.sun_spriteset.sun != []
  248.       for i in 0...$game_temp.sun_spriteset.sun.size
  249.         @sunlist.push(Sprite_Sun.new(viewport, $game_player, i))
  250.       end
  251.       end
  252.       #===================================================
  253.       # * Compatibility with Caterpillar Functions
  254.       #===================================================
  255.       if CATERPILLAR_COMPATIBLE and $game_party.characters != nil
  256.         for member in $game_party.characters
  257.           for i in 0...$game_temp.sun_spriteset.sun.size
  258.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  259.           end
  260.         end
  261.       end
  262.       if SQUAD_MOVE_COMPATIBLE and $game_allies.values != nil
  263.         for member in $game_allies.values
  264.           for i in 0...$game_temp.sun_spriteset.sun.size
  265.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  266.           end
  267.         end
  268.       end
  269.       if CCOA_CATER_COMPATIBLE and $game_train.actors != nil
  270.         for member in $game_train.actors
  271.           for i in 0...$game_temp.sun_spriteset.sun.size
  272.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  273.           end
  274.         end
  275.       end
  276.       if TRICKSTER_CATER_COMPATIBLE and $game_party.followers != nil
  277.         for member in $game_party.followers
  278.           for i in 0...$game_temp.sun_spriteset.sun.size
  279.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  280.           end
  281.         end
  282.       end
  283.       #===================================================
  284.       # ** End of the compatibility
  285.       #===================================================      
  286.     end
  287.     # Perform the original call
  288.     sun_initialize(viewport, @character)
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # * Frame Update
  292.   #--------------------------------------------------------------------------  
  293.   def update
  294.     sun_update
  295.     if @sunlist != []
  296.       for i in [email hidden]
  297.         @sunlist[i].update
  298.       end
  299.     end
  300.   end  
  301. end
  302.  
  303.  
  304.  
  305. #==============================================================================
  306. # ** Game_Event
  307. #------------------------------------------------------------------------------
  308. #  This class deals with events. It handles functions including event page
  309. #  switching via condition determinants, and running parallel process events.
  310. #  It's used within the Game_Map class.
  311. #==============================================================================
  312.  
  313. class Game_Event < Game_Character
  314.   #--------------------------------------------------------------------------
  315.   # * Public Instance Variables
  316.   #--------------------------------------------------------------------------
  317.   attr_accessor :id
  318. end
  319.  
  320.  
  321.  
  322. #==============================================================================
  323. # ** Spriteset_Map
  324. #------------------------------------------------------------------------------
  325. #  This class brings together map screen sprites, tilemaps, etc.
  326. #  It's used within the Scene_Map class.
  327. #==============================================================================
  328.  
  329. class Spriteset_Map
  330.   #--------------------------------------------------------------------------
  331.   # * Public Instance Variables
  332.   #--------------------------------------------------------------------------  
  333.   attr_accessor :sun
  334.   #--------------------------------------------------------------------------
  335.   # * Alias Listings
  336.   #--------------------------------------------------------------------------  
  337.   alias sun_initialize initialize
  338.   #--------------------------------------------------------------------------
  339.   # * Object Initialization
  340.   #--------------------------------------------------------------------------    
  341.   def initialize
  342.     @sun = []
  343.     $game_temp.sun_spriteset = self
  344.     warn = false
  345.     for k in $game_map.events.keys.sort
  346.       if ($game_map.events[k].list != nil and
  347.           $game_map.events[k].list[0].code == 108 and
  348.           ($game_map.events[k].list[0].parameters == ["sun"] or
  349.           $game_map.events[k].list[0].parameters == ["o"]))
  350.         warn = true
  351.       end
  352.       params = XPML.XPML_read("Sun", k, 2)
  353.       $game_temp.sun_spriteset.sun.push(params) if params != nil
  354.     end
  355.     if warn == true and SUN_WARN
  356.       p "Warning : At least one event on this map uses an obsolete way to add a sun effect"
  357.     end
  358.     # Perform the original call
  359.     sun_initialize
  360.   end  
  361. end
  362.  
  363.  
  364. #==============================================================================
  365. # ** module XPML
  366. #------------------------------------------------------------------------------
  367. #  This module handles the reading and passing of 'comment' parameters
  368. #
  369. #  The main XPML method is used to check and read event comments.
  370. #  * It returns 'nil' if the markup 'check' text isn't even present.
  371. #  * It returns [] if no parameters are passed
  372. #  * It returns a parameter list with "int" converted as int.
  373. #       eg :
  374. #       begin first
  375. #       begin second
  376. #       param1 1
  377. #       param2 two
  378. #       begin third
  379. #       anything 3
  380. #
  381. #   p XPML_read("first", event_id) -> []
  382. #   p XPML_read("second", event_id) -> [1,"two"]
  383. #   p XPML_read("third", event_id) -> [3]
  384. #   p XPML_read("forth", event_id) -> nil
  385. #===================================================
  386.  
  387. module XPML
  388.   module_function
  389.   #--------------------------------------------------------------------------
  390.   # * XPML_read
  391.   #     markup           : text in event comment to check
  392.   #     event_id         : event ID
  393.   #     max_param_number : maximum number of parameter/comments to load
  394.   #--------------------------------------------------------------------------  
  395.   def XPML_read(markup, event_id, max_param_number = 0)
  396.     parameter_list = nil
  397.     event = $game_map.events[event_id]
  398.     return if event.list == nil
  399.       for i in 0...event.list.size
  400.         if event.list[i].code == 108 and
  401.           event.list[i].parameters[0].downcase == "begin " + markup.downcase
  402.           parameter_list = [] if parameter_list == nil
  403.           for j in i + 1...event.list.size
  404.             if event.list[j].code == 108
  405.               parts = event.list[j].parameters[0].split
  406.               if parts.size != 1 and parts[0].downcase != "begin"
  407.                 if parts[1].to_i != 0 or parts[1] == "0"
  408.                   parameter_list.push(parts[1].to_i)
  409.                 else
  410.                   parameter_list.push(parts[1])
  411.                 end
  412.               else
  413.                 return parameter_list
  414.               end
  415.             else
  416.               return parameter_list
  417.             end
  418.             if max_param_number != 0 and j == i + max_param_number
  419.               return parameter_list
  420.             end
  421.           end
  422.         end
  423.       end
  424.     return parameter_list
  425.   end
  426. end
Expand to see the code.


I just added if $scene == Scene_Map.new
if character.is_a?(Game_Player) and $game_temp.sun_spriteset.sun != []
for i in 0...$game_temp.sun_spriteset.sun.size
@sunlist.push(Sprite_Sun.new(viewport, $game_player, i))
end
end

same thing with the shadow. it was conflicting with Game Temp or something. I actually didn't see a sun, but I got no more conflicts after that, Does this work for you?
Unfortunately, same error as before, only this time the line number is different. Here are the two scripts as I have them, after your modification:

  1. #==============================================================================
  2. # ** Sprite Shadow (Sprite_Ombre )
  3. #------------------------------------------------------------------------------
  4. #    Based on Genzai Kawakami's shadows
  5. #    dynamisme & features by Rataime
  6. #    extra features Boushy
  7. #    New Edits by DerVVulfman
  8. #    February 24, 2008
  9. #
  10. #------------------------------------------------------------------------------
  11. #
  12. # Introduction:
  13. #
  14. #  This system allows you and all 'prepared' events to generate shadows while
  15. #  on the field map.   The player can move around  a 'light source' event and
  16. #  display a shadow.   Likewise,  events with a special comment  within their
  17. #  event list can also generate shadows.
  18. #
  19. #------------------------------------------------------------------------------
  20. #
  21. # Instructions:
  22. #
  23. #  -- The Light Source
  24. #     To create a light source, you need to create a map event that is to be
  25. #     used 'as' the light source.   Most of the time,  these could be events
  26. #     that sport 'torch' or 'lantern' charactersets.  Just examples :)
  27. #
  28. #     To make one of these events a light source,  you need  to insert a few
  29. #     things into that event's  "List of Event Commands".   These things are
  30. #     nothing more than comments.  
  31. #
  32. #     The first comment to add is "begin Shadow Source" (without quotes). It
  33. #     informs the system  that this event is a light source.   The remaining
  34. #     three values are optional and have default values in the configuration
  35. #     section  (only just added  into the script).   They too  are added  as
  36. #     comments.
  37. #
  38. #     anglemin 'number'     --- Starting position of a lightsource's arc.
  39. #     anglemax 'number'     --- Ending position of a lightsource's arc.
  40. #     distancemax 'number'  --- How far away from the 'source' you can go
  41. #     self_opacity 'number' --- How dark the shadow will grow.
  42. #
  43. #     After that, your characters can now move about and generate shadows.
  44. #
  45. #  -- Other Events
  46. #     Events do not know that they can generate shadows.   To let them gene-
  47. #     rate a shadow,  all you need to do is add a special comment into their
  48. #     "List of Event Commands".   This comment needed  is merely  the phrase
  49. #     'begin Shadow' (again, without quotes).
  50. #
  51. #
  52. #  -- Blocking Shadows
  53. #     To prevent shadows  from passing through  solid objects such as doors,
  54. #     walls, cabinets or other forms of furniture,  you will want to apply a
  55. #     priority flag of '1' or higher on these items.  Normally, walls in the
  56. #     default database do not have a priority flag as they merely block  the
  57. #     player from passing through.
  58. #    
  59. #
  60. #------------------------------------------------------------------------------
  61. #
  62. # Revisions to note:
  63. #
  64. #  1) Added formatted headers and comments throughout the script.
  65. #  2) Encapsulated a comment/parameter code in an XPML module.
  66. #  3) Set the shadow array into an instance value to lower resource costs.
  67. #  4) Compatability with Near Fantastica's Squad Movement systems.
  68. #  5) Compatability with Ccoa's Caterpillar system.
  69. #  6) Compatability with Trickster's Caterpillar system.
  70. #  7) Added default shadow settings into the configuration section.
  71. #
  72. #==============================================================================
  73.  
  74.  
  75.  
  76.    #========================================================================
  77.    #  **  C  O  N  F  I  G  U  R  A  T  I  O  N      S  Y  S  T  E  M  **  #
  78.    #========================================================================
  79.     # Caterpillar Systems
  80.     CATERPILLAR_COMPATIBLE      = true    # Toggle for Fukuyama's original  
  81.     SQUAD_MOVE_COMPATIBLE       = false   # Toggle for Near Fantastica's SBABS
  82.     CCOA_CATER_COMPATIBLE       = false   # Toggle for Ccoa's Caterpillar
  83.     TRICKSTER_CATER_COMPATIBLE  = false   # Toggle for Trickster's Caterpillar
  84.    
  85.     # Shadow Specific Systems
  86.     SHADOW_WARN                 = true    # Checks for older shadow system
  87.     SHADOW_MIN                  = 0       # Start setting of shadow arc *
  88.     SHADOW_MAX                  = 0       # Ending setting of shadow arc *
  89.     SHADOW_OPACITY              = 150     # Darkness level of shadow
  90.     SHADOW_DISTANCE             = 350     # Maximum range in pixels
  91.  
  92.     # * SHADOW ARC:  Set in degrees,  this controls whether a light source
  93.     #                can 'force' shadows in certain directions.  Useful if
  94.     #                a light source is hanging on a wall so it cannot make
  95.     #                a shadow THROUGH a wall.
  96.     #
  97.     #                It may take some practice  to set  the desired angles
  98.     #                as it recognizes 90°  being the  top most part  of an
  99.     #                arc,  180° being the leftmost side and so on...  pro-
  100.     #                ceeding in a counter-clockwise motion.
  101.    
  102.    #========================================================================
  103.    #  ****   E N D   O F   C O N F I G U R A T I O N   S Y S T E M   ****  #
  104.    #========================================================================
  105.    
  106.    
  107.  
  108. #==============================================================================
  109. # ** Game_Temp
  110. #------------------------------------------------------------------------------
  111. #  This class handles temporary data that is not included with save data.
  112. #  Refer to "$game_temp" for the instance of this class.
  113. #==============================================================================
  114.  
  115. class Game_Temp
  116.   #--------------------------------------------------------------------------
  117.   # * Public Instance Variables
  118.   #--------------------------------------------------------------------------
  119.   attr_accessor :shadow_spriteset         # holds shadow spritesets
  120. end
  121.  
  122.  
  123.  
  124. #==============================================================================
  125. # ** Game_Party
  126. #------------------------------------------------------------------------------
  127. #  This class handles the party. It includes information on amount of gold
  128. #  and items. Refer to "$game_party" for the instance of this class.
  129. #==============================================================================
  130.  
  131. class Game_Party
  132.   #--------------------------------------------------------------------------
  133.   # * Public Instance Variables
  134.   #--------------------------------------------------------------------------
  135.   attr_reader :characters
  136. end
  137.  
  138.  
  139.  
  140. #==============================================================================
  141. # ** Sprite_Shadow
  142. #------------------------------------------------------------------------------
  143. #  This sprite is used to display the character's shadow.  It observes the
  144. #  Game_Character class and automatically changes sprite conditions.
  145. #==============================================================================
  146. class Sprite_Shadow < RPG::Sprite
  147.   #--------------------------------------------------------------------------
  148.   # * Public Instance Variables
  149.   #--------------------------------------------------------------------------
  150.   attr_accessor :character
  151.   #--------------------------------------------------------------------------
  152.   # * Object Initialization
  153.   #     viewport  : viewport
  154.   #     character : character (Game_Character)
  155.   #     id        : id
  156.   #--------------------------------------------------------------------------
  157.   def initialize(viewport, character = nil, id = 0)
  158.     super(viewport)
  159.     params  = $game_temp.shadow_spriteset.shadows[id]
  160.     @source = params[0]
  161.     # Default settings
  162.     @anglemin     = SHADOW_MIN
  163.     @anglemax     = SHADOW_MAX
  164.     @self_opacity = SHADOW_OPACITY
  165.     @distancemax  = SHADOW_DISTANCE
  166.     # Settings changed by parameters
  167.     @anglemin     = params[1]   if params.size > 1
  168.     @anglemax     = params[2]   if params.size > 2
  169.     @distancemax  = params[3]   if params.size > 3
  170.     @self_opacity = params[4]   if params.size > 4
  171.     @character = character
  172.     update
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # * Frame Update
  176.   #--------------------------------------------------------------------------
  177.   def update
  178.     # If shadow not in range of light source
  179.     if !in_range?(@character, @source, @distancemax)
  180.       self.opacity = 0
  181.       return
  182.     end
  183.     super
  184.     # If tile ID, file name, or hue are different from current ones
  185.     if @tile_id != @character.tile_id or
  186.        @character_name != @character.character_name or
  187.        @character_hue != @character.character_hue
  188.       # Remember tile ID, file name, and hue
  189.       @tile_id = @character.tile_id
  190.       @character_name = @character.character_name
  191.       @character_hue = @character.character_hue
  192.       # If tile ID value is valid
  193.       if @tile_id >= 384
  194.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  195.           @tile_id, @character.character_hue)
  196.         self.src_rect.set(0, 0, 32, 32)
  197.         self.ox = 16
  198.         self.oy = 32
  199.       # If tile ID value is invalid        
  200.       else
  201.         self.bitmap = RPG::Cache.character(@character.character_name,
  202.           @character.character_hue)
  203.         @cw = bitmap.width / 4
  204.         @ch = bitmap.height / 4
  205.         self.ox = @cw / 2
  206.         self.oy = @ch
  207.       end
  208.     end
  209.     # Set visible situation
  210.     self.visible = (not @character.transparent)
  211.     # If graphic is character
  212.     if @tile_id == 0
  213.       # Set rectangular transfer
  214.       sx = @character.pattern * @cw
  215.       sy = (@character.direction - 2) / 2 * @ch
  216.       if self.angle > 90 or angle < -90
  217.         sy = ( 4 - 2) / 2 * @ch   if @character.direction == 6
  218.         sy = ( 6 - 2) / 2 * @ch   if @character.direction == 4
  219.         sy = ( 8 - 2) / 2 * @ch   if @character.direction == 2
  220.         sy = ( 2 - 2) / 2 * @ch   if @character.direction == 8
  221.       end
  222.       self.src_rect.set(sx, sy, @cw, @ch)
  223.     end
  224.     # Set sprite coordinates    
  225.     self.x = @character.screen_x
  226.     self.y = @character.screen_y-5
  227.     self.z = @character.screen_z(@ch)-1
  228.     # Set blend method and bush depth
  229.     self.blend_type = @character.blend_type
  230.     self.bush_depth = @character.bush_depth
  231.     # Animation
  232.     if @character.animation_id != 0
  233.       animation = $data_animations[@character.animation_id]
  234.       animation(animation, true)
  235.       @character.animation_id = 0
  236.     end
  237.     @deltax       = @source.screen_x - self.x
  238.     @deltay       = @source.screen_y - self.y
  239.     self.color    = Color.new(0, 0, 0)
  240.     @distance     = ((@deltax ** 2) + (@deltay ** 2))
  241.     # Set opacity level based on light source distance
  242.     self.opacity  = @self_opacity * 13000 /
  243.                       ((@distance * 370 / @distancemax) + 6000)
  244.     self.angle    = 57.3 * Math.atan2(@deltax, @deltay )
  245.     @angle_trigo  = self.angle+90
  246.     if @angle_trigo < 0
  247.         @angle_trigo = 360 + @angle_trigo
  248.      end
  249.     if @anglemin != 0 or @anglemax != 0
  250.        if (@angle_trigo < @anglemin or @angle_trigo > @anglemax) and
  251.           @anglemin < @anglemax
  252.          self.opacity = 0
  253.          return
  254.        end
  255.        if (@angle_trigo < @anglemin and @angle_trigo > @anglemax) and
  256.           @anglemin > @anglemax
  257.          self.opacity=0
  258.          return
  259.        end    
  260.      end
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # * In Range?  (From Near's Anti Lag Script, edited)
  264.   #     element     : element
  265.   #     object      : object
  266.   #     range       : range in tiles
  267.   #--------------------------------------------------------------------------  
  268.   def in_range?(element, object, range)
  269.     x = (element.screen_x - object.screen_x) * (element.screen_x - object.screen_x)
  270.     y = (element.screen_y - object.screen_y) * (element.screen_y - object.screen_y)
  271.     r = x + y
  272.     if r <= (range * range)
  273.        return true
  274.     else
  275.       return false
  276.     end
  277.   end
  278. end
  279.  
  280.  
  281.  
  282. #==============================================================================
  283. # ** Sprite_Character
  284. #------------------------------------------------------------------------------
  285. #  This sprite is used to display the character.It observes the Game_Character
  286. #  class and automatically changes sprite conditions.
  287. #==============================================================================
  288.  
  289. class Sprite_Character < RPG::Sprite
  290.   #--------------------------------------------------------------------------
  291.   # * Alias Listings
  292.   #--------------------------------------------------------------------------
  293.   alias shadow_initialize initialize
  294.   alias shadow_update update  
  295.   #--------------------------------------------------------------------------
  296.   # * Object Initialization
  297.   #     viewport  : viewport
  298.   #     character : character (Game_Character)
  299.   #--------------------------------------------------------------------------
  300.   def initialize(viewport, character = nil)
  301.     @character = character
  302.     super(viewport)
  303.     @ombrelist = []
  304.     if character.is_a?(Game_Event) and $game_temp.shadow_spriteset.shadows != []
  305.       params = XPML.XPML_read("Shadow", @character.id, 5)
  306.       if params != nil
  307.         for i in 0...$game_temp.shadow_spriteset.shadows.size
  308.           @ombrelist.push(Sprite_Shadow.new(viewport, @character,i))
  309.         end
  310.       end
  311.     end
  312.     if $scene == Scene_Map.new
  313.     if character.is_a?(Game_Player) and $game_temp.shadow_spriteset.shadows != []
  314.       for i in 0...$game_temp.shadow_spriteset.shadows.size
  315.         @ombrelist.push(Sprite_Shadow.new(viewport, $game_player,i))
  316.       end
  317.       end
  318.       #===================================================
  319.       # * Compatibility with Caterpillar Functions
  320.       #===================================================
  321.       if CATERPILLAR_COMPATIBLE and $game_party.characters != nil
  322.         for member in $game_party.characters
  323.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  324.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  325.           end
  326.         end
  327.       end
  328.       if SQUAD_MOVE_COMPATIBLE and $game_allies.values != nil
  329.         for member in $game_allies.values
  330.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  331.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  332.           end
  333.         end
  334.       end
  335.       if CCOA_CATER_COMPATIBLE and $game_train.actors != nil
  336.         for member in $game_train.actors
  337.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  338.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  339.           end
  340.         end
  341.       end
  342.       if TRICKSTER_CATER_COMPATIBLE and $game_party.followers != nil
  343.         for member in $game_party.followers
  344.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  345.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  346.           end
  347.         end
  348.       end
  349.       #===================================================
  350.       # ** End of the compatibility
  351.       #===================================================      
  352.     end
  353.     # Perform the original call
  354.     shadow_initialize(viewport, @character)
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # * Frame Update
  358.   #--------------------------------------------------------------------------
  359.   def update
  360.     shadow_update
  361.     if @ombrelist != []
  362.       for i in [email hidden]
  363.         @ombrelist[i].update
  364.       end
  365.     end
  366.   end  
  367. end
  368.  
  369.  
  370.  
  371. #==============================================================================
  372. # ** Game_Event
  373. #------------------------------------------------------------------------------
  374. #  This class deals with events. It handles functions including event page
  375. #  switching via condition determinants, and running parallel process events.
  376. #  It's used within the Game_Map class.
  377. #==============================================================================
  378.  
  379. class Game_Event < Game_Character
  380.   #--------------------------------------------------------------------------
  381.   # * Public Instance Variables
  382.   #--------------------------------------------------------------------------
  383.   attr_accessor :id
  384. end
  385.  
  386.  
  387.  
  388. #==============================================================================
  389. # ** Spriteset_Map
  390. #------------------------------------------------------------------------------
  391. #  This class brings together map screen sprites, tilemaps, etc.
  392. #  It's used within the Scene_Map class.
  393. #==============================================================================
  394.  
  395. class Spriteset_Map
  396.   #--------------------------------------------------------------------------
  397.   # * Public Instance Variables
  398.   #--------------------------------------------------------------------------  
  399.   attr_accessor :shadows
  400.   #--------------------------------------------------------------------------
  401.   # * Alias Listings
  402.   #--------------------------------------------------------------------------  
  403.   alias shadow_initialize initialize
  404.   #--------------------------------------------------------------------------
  405.   # * Object Initialization
  406.   #--------------------------------------------------------------------------  
  407.   def initialize
  408.     $game_temp.shadow_spriteset = self
  409.     @shadows = []
  410.     warn = false
  411.     for k in $game_map.events.keys.sort
  412.       if ($game_map.events[k].list != nil and
  413.             $game_map.events[k].list[0].code == 108 and
  414.             ($game_map.events[k].list[0].parameters == ["s"] or
  415.             $game_map.events[k].list[0].parameters == ["o"]))
  416.         warn = true        
  417.       end
  418.       params = XPML.XPML_read("Shadow Source", k, 5)
  419.       if params != nil
  420.         $game_temp.shadow_spriteset.shadows.push([$game_map.events[k]] + params)
  421.       end
  422.     end
  423.     if warn == true and SHADOW_WARN
  424.       p "Warning : At least one event on this map uses an obsolete way to add shadows"
  425.     end
  426.     # Perform the original call
  427.     shadow_initialize
  428.   end  
  429. end
  430.  
  431.  
  432.  
  433. #==============================================================================
  434. # ** module XPML
  435. #------------------------------------------------------------------------------
  436. #  This module handles the reading and passing of 'comment' parameters
  437. #
  438. #  The main XPML method is used to check and read event comments.
  439. #  * It returns 'nil' if the markup 'check' text isn't even present.
  440. #  * It returns [] if no parameters are passed
  441. #  * It returns a parameter list with "int" converted as int.
  442. #       eg :
  443. #       begin first
  444. #       begin second
  445. #       param1 1
  446. #       param2 two
  447. #       begin third
  448. #       anything 3
  449. #
  450. #   p XPML_read("first", event_id) -> []
  451. #   p XPML_read("second", event_id) -> [1,"two"]
  452. #   p XPML_read("third", event_id) -> [3]
  453. #   p XPML_read("forth", event_id) -> nil
  454. #===================================================
  455.  
  456. module XPML
  457.   module_function
  458.   #--------------------------------------------------------------------------
  459.   # * XPML_read
  460.   #     markup           : text in event comment to check
  461.   #     event_id         : event ID
  462.   #     max_param_number : maximum number of parameter/comments to load
  463.   #--------------------------------------------------------------------------  
  464.   def XPML_read(markup, event_id, max_param_number = 0)
  465.     parameter_list = nil
  466.     event = $game_map.events[event_id]
  467.     return if event.list == nil
  468.       for i in 0...event.list.size
  469.         if event.list[i].code == 108 and
  470.           event.list[i].parameters[0].downcase == "begin " + markup.downcase
  471.           parameter_list = [] if parameter_list == nil
  472.           for j in i + 1...event.list.size
  473.             if event.list[j].code == 108
  474.               parts = event.list[j].parameters[0].split
  475.               if parts.size != 1 and parts[0].downcase != "begin"
  476.                 if parts[1].to_i != 0 or parts[1] == "0"
  477.                   parameter_list.push(parts[1].to_i)
  478.                 else
  479.                   parameter_list.push(parts[1])
  480.                 end
  481.               else
  482.                 return parameter_list
  483.               end
  484.             else
  485.               return parameter_list
  486.             end
  487.             if max_param_number != 0 and j == i + max_param_number
  488.               return parameter_list
  489.             end
  490.           end
  491.         end
  492.       end
  493.     return parameter_list
  494.   end
  495. end
Expand to see the code.


  1. #==============================================================================
  2. # ** Sprite Sun
  3. #------------------------------------------------------------------------------
  4. #    Based on Sprite Shadow
  5. #    modified by Rataime
  6. #    New Edits by DerVVulfman
  7. #    February 12, 2008
  8. #------------------------------------------------------------------------------
  9. #
  10. # Introduction:
  11. #
  12. #  This system allows you and all 'prepared' events to generate shadows while
  13. #  on the field map. The player can move around while a programmed 'sun' will
  14. #  display a shadow.   Likewise,  events with a special comment  within their
  15. #  event list can also generate shadows.
  16. #
  17. #------------------------------------------------------------------------------
  18. #
  19. # Instructions:
  20. #
  21. #  -- The Sun
  22. #     To create a sun effect, you'll need to create a map event that's to be
  23. #     used 'as' the sun itself.   Under most circumstances,  this will be an
  24. #     event without a characterset graphic. You don't want to 'SEE' the sun,
  25. #     do you?
  26. #
  27. #     To make one of these events a 'sun,  you'll need to insert a couple of
  28. #     things into that event's  "List of Event Commands".   These things are
  29. #     nothing more than comments.  
  30. #
  31. #     The first comment  to add is "begin Sun" (without quotes).  It informs
  32. #     the system that this map  has a sun effect in use.   The remaining two
  33. #     values  are optional  and have  default values  in  the  configuration
  34. #     section  (only just added  into the script).   They too  are added  as
  35. #     comments.
  36. #
  37. #     self_angle  'number'  --- How much of an angle each shadow will have.
  38. #     self_opacity 'number' --- How dark the shadow will be.
  39. #
  40. #     After that, your characters can now move about and generate shadows.
  41. #
  42. #  -- Other Events
  43. #     Events do not know that they can generate shadows.   To let them gene-
  44. #     rate a shadow,  all you need to do is add a special comment into their
  45. #     "List of Event Commands".   This comment needed  is merely  the phrase
  46. #     'begin Shadow' (again, without quotes).
  47. #
  48. #
  49. #------------------------------------------------------------------------------
  50. #
  51. # Revisions to note:
  52. #
  53. #  1) Added formatted headers and comments throughout the script.
  54. #  2) Encapsulated a comment/parameter code in an XPML module.
  55. #  3) Set the sun shadow array into an instance value to lower resource costs.
  56. #  4) Compatability with Near Fantastica's Squad Movement systems.
  57. #  5) Compatability with Ccoa's Caterpillar system.
  58. #  6) Compatability with Trickster's Caterpillar system.
  59. #  7) Added default shadow settings into the configuration section.
  60. #
  61. #==============================================================================
  62.  
  63.  
  64.  
  65.    #========================================================================
  66.    #  **  C  O  N  F  I  G  U  R  A  T  I  O  N      S  Y  S  T  E  M  **  #
  67.    #========================================================================
  68.     # Caterpillar Systems
  69.     CATERPILLAR_COMPATIBLE      = true    # Toggle for Fukuyama's original  
  70.     SQUAD_MOVE_COMPATIBLE       = false   # Toggle for Near Fantastica's SBABS
  71.     CCOA_CATER_COMPATIBLE       = false   # Toggle for Ccoa's Caterpillar
  72.     TRICKSTER_CATER_COMPATIBLE  = false   # Toggle for Trickster's Caterpillar
  73.    
  74.     # Sun Specific Systems
  75.     SUN_WARN                    = true    # Checks for older sun systems
  76.     SUN_ANGLE                   = 45      # Angle for sun-generated shadow
  77.     SUN_OPACITY                 = 128     # Darkness setting for sun shadow
  78.  
  79.    
  80.    #========================================================================
  81.    #  ****   E N D   O F   C O N F I G U R A T I O N   S Y S T E M   ****  #
  82.    #========================================================================
  83.    
  84.    
  85.  
  86. #==============================================================================
  87. # ** Game_Temp
  88. #------------------------------------------------------------------------------
  89. #  This class handles temporary data that is not included with save data.
  90. #  Refer to "$game_temp" for the instance of this class.
  91. #==============================================================================
  92.  
  93. class Game_Temp
  94.   #--------------------------------------------------------------------------
  95.   # * Public Instance Variables
  96.   #--------------------------------------------------------------------------
  97.   attr_accessor :sun_spriteset            # holds spritesets for 'sun' shadows
  98. end
  99.  
  100.  
  101.  
  102. #==============================================================================
  103. # ** Game_Party
  104. #------------------------------------------------------------------------------
  105. #  This class handles the party. It includes information on amount of gold
  106. #  and items. Refer to "$game_party" for the instance of this class.
  107. #==============================================================================
  108.  
  109. class Game_Party
  110.   #--------------------------------------------------------------------------
  111.   # * Public Instance Variables
  112.   #--------------------------------------------------------------------------
  113.   attr_reader :characters
  114. end
  115.  
  116.  
  117.  
  118. #==============================================================================
  119. # ** Sprite_Sun
  120. #------------------------------------------------------------------------------
  121. #  This sprite is used to position character shadows relative to map position.
  122. #  It observes the Game_Character class and automatically changes sprite
  123. #  conditions.
  124. #==============================================================================
  125.  
  126. class Sprite_Sun < RPG::Sprite
  127.   #--------------------------------------------------------------------------
  128.   # * Public Instance Variables
  129.   #--------------------------------------------------------------------------
  130.   attr_accessor :character          
  131.   #--------------------------------------------------------------------------
  132.   # * Object Initialization
  133.   #     viewport  : viewport
  134.   #     character : character (Game_Character)
  135.   #     id        : id
  136.   #--------------------------------------------------------------------------
  137.   def initialize(viewport, character = nil, id=0)
  138.     super(viewport)
  139.     @character = character
  140.     params=$game_temp.sun_spriteset.sun[id]
  141.     self_angle    = SUN_ANGLE
  142.     self_opacity  = SUN_OPACITY
  143.     self_angle    = params[0]   if params.size > 0
  144.     self_opacity  = params[1]   if params.size > 1
  145.     @self_angle   = self_angle
  146.     @self_opacity = self_opacity
  147.     update
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # * Frame Update
  151.   #--------------------------------------------------------------------------  
  152.   def update
  153.     super
  154.     # If tile ID, file name, or hue are different from current ones
  155.     if @tile_id != @character.tile_id or
  156.        @character_name != @character.character_name or
  157.        @character_hue != @character.character_hue
  158.       # Remember tile ID, file name, and hue
  159.       @tile_id = @character.tile_id
  160.       @character_name = @character.character_name
  161.       @character_hue = @character.character_hue
  162.       # If tile ID value is valid      
  163.       if @tile_id >= 384
  164.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  165.           @tile_id, @character.character_hue)
  166.         self.src_rect.set(0, 0, 32, 32)
  167.         self.ox = 16
  168.         self.oy = 32
  169.       # If tile ID value is invalid        
  170.       else
  171.         self.bitmap = RPG::Cache.character(@character.character_name,
  172.           @character.character_hue)
  173.         @cw = bitmap.width / 4
  174.         @ch = bitmap.height / 4
  175.         self.ox = @cw / 2
  176.         self.oy = @ch
  177.       end
  178.     end
  179.     # Set visible situation
  180.     self.visible = (not @character.transparent)
  181.     # If graphic is character
  182.     if @tile_id == 0
  183.       # Set rectangular transfer    
  184.       sx = @character.pattern * @cw
  185.       @direct = @character.direction
  186.       if self.angle > 90 or angle < -90
  187.         sy = ( 4 - 2) / 2 * @ch                   if @direct == 6
  188.         sy = ( 6 - 2) / 2 * @ch                   if @direct == 4
  189.         sy = (@character.direction - 2) / 2 * @ch if @direct != 4 and @direct != 6
  190.       else
  191.         sy = (@character.direction - 2) / 2 * @ch
  192.       end
  193.       self.src_rect.set(sx, sy, @cw, @ch)
  194.     end
  195.     # Set sprite coordinates
  196.     self.x = @character.screen_x
  197.     self.y = @character.screen_y-5
  198.     self.z = @character.screen_z(@ch) - 1
  199.     # Set opacity level, blend method, and bush depth
  200.     self.opacity = @self_opacity
  201.     self.blend_type = @character.blend_type
  202.     self.bush_depth = @character.bush_depth
  203.     # Animation
  204.     if @character.animation_id != 0
  205.       animation = $data_animations[@character.animation_id]
  206.       animation(animation, true)
  207.       @character.animation_id = 0
  208.     end
  209.     self.angle = @self_angle.to_i - 90
  210.     self.color = Color.new(0, 0, 0)
  211.   end
  212. end
  213.  
  214.  
  215.  
  216. #==============================================================================
  217. # ** Sprite_Character
  218. #------------------------------------------------------------------------------
  219. #  This sprite is used to display the character.It observes the Game_Character
  220. #  class and automatically changes sprite conditions.
  221. #==============================================================================
  222.  
  223. class Sprite_Character < RPG::Sprite
  224.   #--------------------------------------------------------------------------
  225.   # * Alias Listings
  226.   #--------------------------------------------------------------------------  
  227.   alias sun_initialize initialize
  228.   alias sun_update update
  229.   #--------------------------------------------------------------------------
  230.   # * Object Initialization
  231.   #     viewport  : viewport
  232.   #     character : character (Game_Character)
  233.   #--------------------------------------------------------------------------
  234.   def initialize(viewport, character = nil)
  235.     @character = character
  236.     super(viewport)
  237.     @sunlist=[]
  238.     if character.is_a?(Game_Event) and $game_temp.sun_spriteset.sun != []
  239.       params = XPML.XPML_read("Shadow", @character.id, 2)
  240.       if params != nil
  241.         for i in 0...$game_temp.sun_spriteset.sun.size
  242.           @sunlist.push(Sprite_Sun.new(viewport, @character, i))
  243.         end
  244.       end
  245.     end
  246.     if $scene == Scene_Map.new
  247.       if character.is_a?(Game_Player) and $game_temp.sun_spriteset.sun != []
  248.       for i in 0...$game_temp.sun_spriteset.sun.size
  249.         @sunlist.push(Sprite_Sun.new(viewport, $game_player, i))
  250.       end
  251.       end
  252.       #===================================================
  253.       # * Compatibility with Caterpillar Functions
  254.       #===================================================
  255.       if CATERPILLAR_COMPATIBLE and $game_party.characters != nil
  256.         for member in $game_party.characters
  257.           for i in 0...$game_temp.sun_spriteset.sun.size
  258.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  259.           end
  260.         end
  261.       end
  262.       if SQUAD_MOVE_COMPATIBLE and $game_allies.values != nil
  263.         for member in $game_allies.values
  264.           for i in 0...$game_temp.sun_spriteset.sun.size
  265.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  266.           end
  267.         end
  268.       end
  269.       if CCOA_CATER_COMPATIBLE and $game_train.actors != nil
  270.         for member in $game_train.actors
  271.           for i in 0...$game_temp.sun_spriteset.sun.size
  272.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  273.           end
  274.         end
  275.       end
  276.       if TRICKSTER_CATER_COMPATIBLE and $game_party.followers != nil
  277.         for member in $game_party.followers
  278.           for i in 0...$game_temp.sun_spriteset.sun.size
  279.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  280.           end
  281.         end
  282.       end
  283.       #===================================================
  284.       # ** End of the compatibility
  285.       #===================================================      
  286.     end
  287.     # Perform the original call
  288.     sun_initialize(viewport, @character)
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # * Frame Update
  292.   #--------------------------------------------------------------------------  
  293.   def update
  294.     sun_update
  295.     if @sunlist != []
  296.       for i in [email hidden]
  297.         @sunlist[i].update
  298.       end
  299.     end
  300.   end  
  301. end
  302.  
  303.  
  304.  
  305. #==============================================================================
  306. # ** Game_Event
  307. #------------------------------------------------------------------------------
  308. #  This class deals with events. It handles functions including event page
  309. #  switching via condition determinants, and running parallel process events.
  310. #  It's used within the Game_Map class.
  311. #==============================================================================
  312.  
  313. class Game_Event < Game_Character
  314.   #--------------------------------------------------------------------------
  315.   # * Public Instance Variables
  316.   #--------------------------------------------------------------------------
  317.   attr_accessor :id
  318. end
  319.  
  320.  
  321.  
  322. #==============================================================================
  323. # ** Spriteset_Map
  324. #------------------------------------------------------------------------------
  325. #  This class brings together map screen sprites, tilemaps, etc.
  326. #  It's used within the Scene_Map class.
  327. #==============================================================================
  328.  
  329. class Spriteset_Map
  330.   #--------------------------------------------------------------------------
  331.   # * Public Instance Variables
  332.   #--------------------------------------------------------------------------  
  333.   attr_accessor :sun
  334.   #--------------------------------------------------------------------------
  335.   # * Alias Listings
  336.   #--------------------------------------------------------------------------  
  337.   alias sun_initialize initialize
  338.   #--------------------------------------------------------------------------
  339.   # * Object Initialization
  340.   #--------------------------------------------------------------------------    
  341.   def initialize
  342.     @sun = []
  343.     $game_temp.sun_spriteset = self
  344.     warn = false
  345.     for k in $game_map.events.keys.sort
  346.       if ($game_map.events[k].list != nil and
  347.           $game_map.events[k].list[0].code == 108 and
  348.           ($game_map.events[k].list[0].parameters == ["sun"] or
  349.           $game_map.events[k].list[0].parameters == ["o"]))
  350.         warn = true
  351.       end
  352.       params = XPML.XPML_read("Sun", k, 2)
  353.       $game_temp.sun_spriteset.sun.push(params) if params != nil
  354.     end
  355.     if warn == true and SUN_WARN
  356.       p "Warning : At least one event on this map uses an obsolete way to add a sun effect"
  357.     end
  358.     # Perform the original call
  359.     sun_initialize
  360.   end  
  361. end
  362.  
  363.  
  364. #==============================================================================
  365. # ** module XPML
  366. #------------------------------------------------------------------------------
  367. #  This module handles the reading and passing of 'comment' parameters
  368. #
  369. #  The main XPML method is used to check and read event comments.
  370. #  * It returns 'nil' if the markup 'check' text isn't even present.
  371. #  * It returns [] if no parameters are passed
  372. #  * It returns a parameter list with "int" converted as int.
  373. #       eg :
  374. #       begin first
  375. #       begin second
  376. #       param1 1
  377. #       param2 two
  378. #       begin third
  379. #       anything 3
  380. #
  381. #   p XPML_read("first", event_id) -> []
  382. #   p XPML_read("second", event_id) -> [1,"two"]
  383. #   p XPML_read("third", event_id) -> [3]
  384. #   p XPML_read("forth", event_id) -> nil
  385. #===================================================
  386.  
  387. module XPML
  388.   module_function
  389.   #--------------------------------------------------------------------------
  390.   # * XPML_read
  391.   #     markup           : text in event comment to check
  392.   #     event_id         : event ID
  393.   #     max_param_number : maximum number of parameter/comments to load
  394.   #--------------------------------------------------------------------------  
  395.   def XPML_read(markup, event_id, max_param_number = 0)
  396.     parameter_list = nil
  397.     event = $game_map.events[event_id]
  398.     return if event.list == nil
  399.       for i in 0...event.list.size
  400.         if event.list[i].code == 108 and
  401.           event.list[i].parameters[0].downcase == "begin " + markup.downcase
  402.           parameter_list = [] if parameter_list == nil
  403.           for j in i + 1...event.list.size
  404.             if event.list[j].code == 108
  405.               parts = event.list[j].parameters[0].split
  406.               if parts.size != 1 and parts[0].downcase != "begin"
  407.                 if parts[1].to_i != 0 or parts[1] == "0"
  408.                   parameter_list.push(parts[1].to_i)
  409.                 else
  410.                   parameter_list.push(parts[1])
  411.                 end
  412.               else
  413.                 return parameter_list
  414.               end
  415.             else
  416.               return parameter_list
  417.             end
  418.             if max_param_number != 0 and j == i + max_param_number
  419.               return parameter_list
  420.             end
  421.           end
  422.         end
  423.       end
  424.     return parameter_list
  425.   end
  426. end
Expand to see the code.


These are the two lines that keep glitching. First from Sprite Sun:

  1. 238.    if character.is_a?(Game_Event) and $game_temp.sun_spriteset.sun != []
Expand to see the code.


And then from Sprite Shadow:

  1. 304.    if character.is_a?(Game_Event) and $game_temp.shadow_spriteset.shadows != []
Expand to see the code.


Those two lines seem to be what is messing everything up. I agree that somehow the save menu is conflicting with the game_temp, but I can't figure out how. Also, I have noticed that if I go to the save menu to save, the save menu's 'map' shows up just fine. So I'm totally lost as to what to do.
  1. #==============================================================================
  2. # ** Sprite Sun
  3. #------------------------------------------------------------------------------
  4. #    Based on Sprite Shadow
  5. #    modified by Rataime
  6. #    New Edits by DerVVulfman
  7. #    February 12, 2008
  8. #------------------------------------------------------------------------------
  9. #
  10. # Introduction:
  11. #
  12. #  This system allows you and all 'prepared' events to generate shadows while
  13. #  on the field map. The player can move around while a programmed 'sun' will
  14. #  display a shadow.   Likewise,  events with a special comment  within their
  15. #  event list can also generate shadows.
  16. #
  17. #------------------------------------------------------------------------------
  18. #
  19. # Instructions:
  20. #
  21. #  -- The Sun
  22. #     To create a sun effect, you'll need to create a map event that's to be
  23. #     used 'as' the sun itself.   Under most circumstances,  this will be an
  24. #     event without a characterset graphic. You don't want to 'SEE' the sun,
  25. #     do you?
  26. #
  27. #     To make one of these events a 'sun,  you'll need to insert a couple of
  28. #     things into that event's  "List of Event Commands".   These things are
  29. #     nothing more than comments.  
  30. #
  31. #     The first comment  to add is "begin Sun" (without quotes).  It informs
  32. #     the system that this map  has a sun effect in use.   The remaining two
  33. #     values  are optional  and have  default values  in  the  configuration
  34. #     section  (only just added  into the script).   They too  are added  as
  35. #     comments.
  36. #
  37. #     self_angle  'number'  --- How much of an angle each shadow will have.
  38. #     self_opacity 'number' --- How dark the shadow will be.
  39. #
  40. #     After that, your characters can now move about and generate shadows.
  41. #
  42. #  -- Other Events
  43. #     Events do not know that they can generate shadows.   To let them gene-
  44. #     rate a shadow,  all you need to do is add a special comment into their
  45. #     "List of Event Commands".   This comment needed  is merely  the phrase
  46. #     'begin Shadow' (again, without quotes).
  47. #
  48. #
  49. #------------------------------------------------------------------------------
  50. #
  51. # Revisions to note:
  52. #
  53. #  1) Added formatted headers and comments throughout the script.
  54. #  2) Encapsulated a comment/parameter code in an XPML module.
  55. #  3) Set the sun shadow array into an instance value to lower resource costs.
  56. #  4) Compatability with Near Fantastica's Squad Movement systems.
  57. #  5) Compatability with Ccoa's Caterpillar system.
  58. #  6) Compatability with Trickster's Caterpillar system.
  59. #  7) Added default shadow settings into the configuration section.
  60. #
  61. #==============================================================================
  62.  
  63.  
  64.  
  65.    #========================================================================
  66.    #  **  C  O  N  F  I  G  U  R  A  T  I  O  N      S  Y  S  T  E  M  **  #
  67.    #========================================================================
  68.     # Caterpillar Systems
  69.     CATERPILLAR_COMPATIBLE      = true    # Toggle for Fukuyama's original  
  70.     SQUAD_MOVE_COMPATIBLE       = false   # Toggle for Near Fantastica's SBABS
  71.     CCOA_CATER_COMPATIBLE       = false   # Toggle for Ccoa's Caterpillar
  72.     TRICKSTER_CATER_COMPATIBLE  = false   # Toggle for Trickster's Caterpillar
  73.    
  74.     # Sun Specific Systems
  75.     SUN_WARN                    = true    # Checks for older sun systems
  76.     SUN_ANGLE                   = 45      # Angle for sun-generated shadow
  77.     SUN_OPACITY                 = 128     # Darkness setting for sun shadow
  78.  
  79.    
  80.    #========================================================================
  81.    #  ****   E N D   O F   C O N F I G U R A T I O N   S Y S T E M   ****  #
  82.    #========================================================================
  83.    
  84.    
  85.  
  86. #==============================================================================
  87. # ** Game_Temp
  88. #------------------------------------------------------------------------------
  89. #  This class handles temporary data that is not included with save data.
  90. #  Refer to "$game_temp" for the instance of this class.
  91. #==============================================================================
  92.  
  93. class Game_Temp
  94.   #--------------------------------------------------------------------------
  95.   # * Public Instance Variables
  96.   #--------------------------------------------------------------------------
  97.   attr_accessor :sun_spriteset            # holds spritesets for 'sun' shadows
  98. end
  99.  
  100.  
  101.  
  102. #==============================================================================
  103. # ** Game_Party
  104. #------------------------------------------------------------------------------
  105. #  This class handles the party. It includes information on amount of gold
  106. #  and items. Refer to "$game_party" for the instance of this class.
  107. #==============================================================================
  108.  
  109. class Game_Party
  110.   #--------------------------------------------------------------------------
  111.   # * Public Instance Variables
  112.   #--------------------------------------------------------------------------
  113.   attr_reader :characters
  114. end
  115.  
  116.  
  117.  
  118. #==============================================================================
  119. # ** Sprite_Sun
  120. #------------------------------------------------------------------------------
  121. #  This sprite is used to position character shadows relative to map position.
  122. #  It observes the Game_Character class and automatically changes sprite
  123. #  conditions.
  124. #==============================================================================
  125.  
  126. class Sprite_Sun < RPG::Sprite
  127.   #--------------------------------------------------------------------------
  128.   # * Public Instance Variables
  129.   #--------------------------------------------------------------------------
  130.   attr_accessor :character          
  131.   #--------------------------------------------------------------------------
  132.   # * Object Initialization
  133.   #     viewport  : viewport
  134.   #     character : character (Game_Character)
  135.   #     id        : id
  136.   #--------------------------------------------------------------------------
  137.   def initialize(viewport, character = nil, id=0)
  138.     super(viewport)
  139.     @character = character
  140.     params=$game_temp.sun_spriteset.sun[id]
  141.     self_angle    = SUN_ANGLE
  142.     self_opacity  = SUN_OPACITY
  143.     self_angle    = params[0]   if params.size > 0
  144.     self_opacity  = params[1]   if params.size > 1
  145.     @self_angle   = self_angle
  146.     @self_opacity = self_opacity
  147.     update
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # * Frame Update
  151.   #--------------------------------------------------------------------------  
  152.   def update
  153.     super
  154.     # If tile ID, file name, or hue are different from current ones
  155.     if @tile_id != @character.tile_id or
  156.        @character_name != @character.character_name or
  157.        @character_hue != @character.character_hue
  158.       # Remember tile ID, file name, and hue
  159.       @tile_id = @character.tile_id
  160.       @character_name = @character.character_name
  161.       @character_hue = @character.character_hue
  162.       # If tile ID value is valid      
  163.       if @tile_id >= 384
  164.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  165.           @tile_id, @character.character_hue)
  166.         self.src_rect.set(0, 0, 32, 32)
  167.         self.ox = 16
  168.         self.oy = 32
  169.       # If tile ID value is invalid        
  170.       else
  171.         self.bitmap = RPG::Cache.character(@character.character_name,
  172.           @character.character_hue)
  173.         @cw = bitmap.width / 4
  174.         @ch = bitmap.height / 4
  175.         self.ox = @cw / 2
  176.         self.oy = @ch
  177.       end
  178.     end
  179.     # Set visible situation
  180.     self.visible = (not @character.transparent)
  181.     # If graphic is character
  182.     if @tile_id == 0
  183.       # Set rectangular transfer    
  184.       sx = @character.pattern * @cw
  185.       @direct = @character.direction
  186.       if self.angle > 90 or angle < -90
  187.         sy = ( 4 - 2) / 2 * @ch                   if @direct == 6
  188.         sy = ( 6 - 2) / 2 * @ch                   if @direct == 4
  189.         sy = (@character.direction - 2) / 2 * @ch if @direct != 4 and @direct != 6
  190.       else
  191.         sy = (@character.direction - 2) / 2 * @ch
  192.       end
  193.       self.src_rect.set(sx, sy, @cw, @ch)
  194.     end
  195.     # Set sprite coordinates
  196.     self.x = @character.screen_x
  197.     self.y = @character.screen_y-5
  198.     self.z = @character.screen_z(@ch) - 1
  199.     # Set opacity level, blend method, and bush depth
  200.     self.opacity = @self_opacity
  201.     self.blend_type = @character.blend_type
  202.     self.bush_depth = @character.bush_depth
  203.     # Animation
  204.     if @character.animation_id != 0
  205.       animation = $data_animations[@character.animation_id]
  206.       animation(animation, true)
  207.       @character.animation_id = 0
  208.     end
  209.     self.angle = @self_angle.to_i - 90
  210.     self.color = Color.new(0, 0, 0)
  211.   end
  212. end
  213.  
  214.  
  215.  
  216. #==============================================================================
  217. # ** Sprite_Character
  218. #------------------------------------------------------------------------------
  219. #  This sprite is used to display the character.It observes the Game_Character
  220. #  class and automatically changes sprite conditions.
  221. #==============================================================================
  222.  
  223. class Sprite_Character < RPG::Sprite
  224.   #--------------------------------------------------------------------------
  225.   # * Alias Listings
  226.   #--------------------------------------------------------------------------  
  227.   alias sun_initialize initialize
  228.   alias sun_update update
  229.   #--------------------------------------------------------------------------
  230.   # * Object Initialization
  231.   #     viewport  : viewport
  232.   #     character : character (Game_Character)
  233.   #--------------------------------------------------------------------------
  234.   def initialize(viewport, character = nil)
  235.     @character = character
  236.     super(viewport)
  237.     @sunlist=[]
  238.  if $scene = Scene_Map.new
  239.     if character.is_a?(Game_Event) and $game_temp.sun_spriteset.sun != []
  240.       params = XPML.XPML_read("Shadow", @character.id, 2)
  241.       if params != nil
  242.         for i in 0...$game_temp.sun_spriteset.sun.size
  243.           @sunlist.push(Sprite_Sun.new(viewport, @character, i))
  244.         end
  245.       end
  246.     end
  247. end
  248.     if $scene == Scene_Map.new
  249.       if character.is_a?(Game_Player) and $game_temp.sun_spriteset.sun != []
  250.       for i in 0...$game_temp.sun_spriteset.sun.size
  251.         @sunlist.push(Sprite_Sun.new(viewport, $game_player, i))
  252.       end
  253.       end
  254.       #===================================================
  255.       # * Compatibility with Caterpillar Functions
  256.       #===================================================
  257.       if CATERPILLAR_COMPATIBLE and $game_party.characters != nil
  258.         for member in $game_party.characters
  259.           for i in 0...$game_temp.sun_spriteset.sun.size
  260.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  261.           end
  262.         end
  263.       end
  264.       if SQUAD_MOVE_COMPATIBLE and $game_allies.values != nil
  265.         for member in $game_allies.values
  266.           for i in 0...$game_temp.sun_spriteset.sun.size
  267.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  268.           end
  269.         end
  270.       end
  271.       if CCOA_CATER_COMPATIBLE and $game_train.actors != nil
  272.         for member in $game_train.actors
  273.           for i in 0...$game_temp.sun_spriteset.sun.size
  274.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  275.           end
  276.         end
  277.       end
  278.       if TRICKSTER_CATER_COMPATIBLE and $game_party.followers != nil
  279.         for member in $game_party.followers
  280.           for i in 0...$game_temp.sun_spriteset.sun.size
  281.             @sunlist.push(Sprite_Sun.new(viewport, member, i))
  282.           end
  283.         end
  284.       end
  285.       #===================================================
  286.       # ** End of the compatibility
  287.       #===================================================      
  288.     end
  289.     # Perform the original call
  290.     sun_initialize(viewport, @character)
  291.   end
  292.   #--------------------------------------------------------------------------
  293.   # * Frame Update
  294.   #--------------------------------------------------------------------------  
  295.   def update
  296.     sun_update
  297.     if @sunlist != []
  298.       for i in [email hidden]
  299.         @sunlist[i].update
  300.       end
  301.     end
  302.   end  
  303. end
  304.  
  305.  
  306.  
  307. #==============================================================================
  308. # ** Game_Event
  309. #------------------------------------------------------------------------------
  310. #  This class deals with events. It handles functions including event page
  311. #  switching via condition determinants, and running parallel process events.
  312. #  It's used within the Game_Map class.
  313. #==============================================================================
  314.  
  315. class Game_Event < Game_Character
  316.   #--------------------------------------------------------------------------
  317.   # * Public Instance Variables
  318.   #--------------------------------------------------------------------------
  319.   attr_accessor :id
  320. end
  321.  
  322.  
  323.  
  324. #==============================================================================
  325. # ** Spriteset_Map
  326. #------------------------------------------------------------------------------
  327. #  This class brings together map screen sprites, tilemaps, etc.
  328. #  It's used within the Scene_Map class.
  329. #==============================================================================
  330.  
  331. class Spriteset_Map
  332.   #--------------------------------------------------------------------------
  333.   # * Public Instance Variables
  334.   #--------------------------------------------------------------------------  
  335.   attr_accessor :sun
  336.   #--------------------------------------------------------------------------
  337.   # * Alias Listings
  338.   #--------------------------------------------------------------------------  
  339.   alias sun_initialize initialize
  340.   #--------------------------------------------------------------------------
  341.   # * Object Initialization
  342.   #--------------------------------------------------------------------------    
  343.   def initialize
  344.     @sun = []
  345.     $game_temp.sun_spriteset = self
  346.     warn = false
  347.     for k in $game_map.events.keys.sort
  348.       if ($game_map.events[k].list != nil and
  349.           $game_map.events[k].list[0].code == 108 and
  350.           ($game_map.events[k].list[0].parameters == ["sun"] or
  351.           $game_map.events[k].list[0].parameters == ["o"]))
  352.         warn = true
  353.       end
  354.       params = XPML.XPML_read("Sun", k, 2)
  355.       $game_temp.sun_spriteset.sun.push(params) if params != nil
  356.     end
  357.     if warn == true and SUN_WARN
  358.       p "Warning : At least one event on this map uses an obsolete way to add a sun effect"
  359.     end
  360.     # Perform the original call
  361.     sun_initialize
  362.   end  
  363. end
  364.  
  365.  
  366. #==============================================================================
  367. # ** module XPML
  368. #------------------------------------------------------------------------------
  369. #  This module handles the reading and passing of 'comment' parameters
  370. #
  371. #  The main XPML method is used to check and read event comments.
  372. #  * It returns 'nil' if the markup 'check' text isn't even present.
  373. #  * It returns [] if no parameters are passed
  374. #  * It returns a parameter list with "int" converted as int.
  375. #       eg :
  376. #       begin first
  377. #       begin second
  378. #       param1 1
  379. #       param2 two
  380. #       begin third
  381. #       anything 3
  382. #
  383. #   p XPML_read("first", event_id) -> []
  384. #   p XPML_read("second", event_id) -> [1,"two"]
  385. #   p XPML_read("third", event_id) -> [3]
  386. #   p XPML_read("forth", event_id) -> nil
  387. #===================================================
  388.  
  389. module XPML
  390.   module_function
  391.   #--------------------------------------------------------------------------
  392.   # * XPML_read
  393.   #     markup           : text in event comment to check
  394.   #     event_id         : event ID
  395.   #     max_param_number : maximum number of parameter/comments to load
  396.   #--------------------------------------------------------------------------  
  397.   def XPML_read(markup, event_id, max_param_number = 0)
  398.     parameter_list = nil
  399.     event = $game_map.events[event_id]
  400.     return if event.list == nil
  401.       for i in 0...event.list.size
  402.         if event.list[i].code == 108 and
  403.           event.list[i].parameters[0].downcase == "begin " + markup.downcase
  404.           parameter_list = [] if parameter_list == nil
  405.           for j in i + 1...event.list.size
  406.             if event.list[j].code == 108
  407.               parts = event.list[j].parameters[0].split
  408.               if parts.size != 1 and parts[0].downcase != "begin"
  409.                 if parts[1].to_i != 0 or parts[1] == "0"
  410.                   parameter_list.push(parts[1].to_i)
  411.                 else
  412.                   parameter_list.push(parts[1])
  413.                 end
  414.               else
  415.                 return parameter_list
  416.               end
  417.             else
  418.               return parameter_list
  419.             end
  420.             if max_param_number != 0 and j == i + max_param_number
  421.               return parameter_list
  422.             end
  423.           end
  424.         end
  425.       end
  426.     return parameter_list
  427.   end
  428. end
Expand to see the code.


  1. #==============================================================================
  2. # ** Sprite Shadow (Sprite_Ombre )
  3. #------------------------------------------------------------------------------
  4. #    Based on Genzai Kawakami's shadows
  5. #    dynamisme & features by Rataime
  6. #    extra features Boushy
  7. #    New Edits by DerVVulfman
  8. #    February 24, 2008
  9. #
  10. #------------------------------------------------------------------------------
  11. #
  12. # Introduction:
  13. #
  14. #  This system allows you and all 'prepared' events to generate shadows while
  15. #  on the field map.   The player can move around  a 'light source' event and
  16. #  display a shadow.   Likewise,  events with a special comment  within their
  17. #  event list can also generate shadows.
  18. #
  19. #------------------------------------------------------------------------------
  20. #
  21. # Instructions:
  22. #
  23. #  -- The Light Source
  24. #     To create a light source, you need to create a map event that is to be
  25. #     used 'as' the light source.   Most of the time,  these could be events
  26. #     that sport 'torch' or 'lantern' charactersets.  Just examples :)
  27. #
  28. #     To make one of these events a light source,  you need  to insert a few
  29. #     things into that event's  "List of Event Commands".   These things are
  30. #     nothing more than comments.  
  31. #
  32. #     The first comment to add is "begin Shadow Source" (without quotes). It
  33. #     informs the system  that this event is a light source.   The remaining
  34. #     three values are optional and have default values in the configuration
  35. #     section  (only just added  into the script).   They too  are added  as
  36. #     comments.
  37. #
  38. #     anglemin 'number'     --- Starting position of a lightsource's arc.
  39. #     anglemax 'number'     --- Ending position of a lightsource's arc.
  40. #     distancemax 'number'  --- How far away from the 'source' you can go
  41. #     self_opacity 'number' --- How dark the shadow will grow.
  42. #
  43. #     After that, your characters can now move about and generate shadows.
  44. #
  45. #  -- Other Events
  46. #     Events do not know that they can generate shadows.   To let them gene-
  47. #     rate a shadow,  all you need to do is add a special comment into their
  48. #     "List of Event Commands".   This comment needed  is merely  the phrase
  49. #     'begin Shadow' (again, without quotes).
  50. #
  51. #
  52. #  -- Blocking Shadows
  53. #     To prevent shadows  from passing through  solid objects such as doors,
  54. #     walls, cabinets or other forms of furniture,  you will want to apply a
  55. #     priority flag of '1' or higher on these items.  Normally, walls in the
  56. #     default database do not have a priority flag as they merely block  the
  57. #     player from passing through.
  58. #    
  59. #
  60. #------------------------------------------------------------------------------
  61. #
  62. # Revisions to note:
  63. #
  64. #  1) Added formatted headers and comments throughout the script.
  65. #  2) Encapsulated a comment/parameter code in an XPML module.
  66. #  3) Set the shadow array into an instance value to lower resource costs.
  67. #  4) Compatability with Near Fantastica's Squad Movement systems.
  68. #  5) Compatability with Ccoa's Caterpillar system.
  69. #  6) Compatability with Trickster's Caterpillar system.
  70. #  7) Added default shadow settings into the configuration section.
  71. #
  72. #==============================================================================
  73.  
  74.  
  75.  
  76.    #========================================================================
  77.    #  **  C  O  N  F  I  G  U  R  A  T  I  O  N      S  Y  S  T  E  M  **  #
  78.    #========================================================================
  79.     # Caterpillar Systems
  80.     CATERPILLAR_COMPATIBLE      = true    # Toggle for Fukuyama's original  
  81.     SQUAD_MOVE_COMPATIBLE       = false   # Toggle for Near Fantastica's SBABS
  82.     CCOA_CATER_COMPATIBLE       = false   # Toggle for Ccoa's Caterpillar
  83.     TRICKSTER_CATER_COMPATIBLE  = false   # Toggle for Trickster's Caterpillar
  84.    
  85.     # Shadow Specific Systems
  86.     SHADOW_WARN                 = true    # Checks for older shadow system
  87.     SHADOW_MIN                  = 0       # Start setting of shadow arc *
  88.     SHADOW_MAX                  = 0       # Ending setting of shadow arc *
  89.     SHADOW_OPACITY              = 150     # Darkness level of shadow
  90.     SHADOW_DISTANCE             = 350     # Maximum range in pixels
  91.  
  92.     # * SHADOW ARC:  Set in degrees,  this controls whether a light source
  93.     #                can 'force' shadows in certain directions.  Useful if
  94.     #                a light source is hanging on a wall so it cannot make
  95.     #                a shadow THROUGH a wall.
  96.     #
  97.     #                It may take some practice  to set  the desired angles
  98.     #                as it recognizes 90°  being the  top most part  of an
  99.     #                arc,  180° being the leftmost side and so on...  pro-
  100.     #                ceeding in a counter-clockwise motion.
  101.    
  102.    #========================================================================
  103.    #  ****   E N D   O F   C O N F I G U R A T I O N   S Y S T E M   ****  #
  104.    #========================================================================
  105.    
  106.    
  107.  
  108. #==============================================================================
  109. # ** Game_Temp
  110. #------------------------------------------------------------------------------
  111. #  This class handles temporary data that is not included with save data.
  112. #  Refer to "$game_temp" for the instance of this class.
  113. #==============================================================================
  114.  
  115. class Game_Temp
  116.   #--------------------------------------------------------------------------
  117.   # * Public Instance Variables
  118.   #--------------------------------------------------------------------------
  119.   attr_accessor :shadow_spriteset         # holds shadow spritesets
  120. end
  121.  
  122.  
  123.  
  124. #==============================================================================
  125. # ** Game_Party
  126. #------------------------------------------------------------------------------
  127. #  This class handles the party. It includes information on amount of gold
  128. #  and items. Refer to "$game_party" for the instance of this class.
  129. #==============================================================================
  130.  
  131. class Game_Party
  132.   #--------------------------------------------------------------------------
  133.   # * Public Instance Variables
  134.   #--------------------------------------------------------------------------
  135.   attr_reader :characters
  136. end
  137.  
  138.  
  139.  
  140. #==============================================================================
  141. # ** Sprite_Shadow
  142. #------------------------------------------------------------------------------
  143. #  This sprite is used to display the character's shadow.  It observes the
  144. #  Game_Character class and automatically changes sprite conditions.
  145. #==============================================================================
  146. class Sprite_Shadow < RPG::Sprite
  147.   #--------------------------------------------------------------------------
  148.   # * Public Instance Variables
  149.   #--------------------------------------------------------------------------
  150.   attr_accessor :character
  151.   #--------------------------------------------------------------------------
  152.   # * Object Initialization
  153.   #     viewport  : viewport
  154.   #     character : character (Game_Character)
  155.   #     id        : id
  156.   #--------------------------------------------------------------------------
  157.   def initialize(viewport, character = nil, id = 0)
  158.     super(viewport)
  159.     params  = $game_temp.shadow_spriteset.shadows[id]
  160.     @source = params[0]
  161.     # Default settings
  162.     @anglemin     = SHADOW_MIN
  163.     @anglemax     = SHADOW_MAX
  164.     @self_opacity = SHADOW_OPACITY
  165.     @distancemax  = SHADOW_DISTANCE
  166.     # Settings changed by parameters
  167.     @anglemin     = params[1]   if params.size > 1
  168.     @anglemax     = params[2]   if params.size > 2
  169.     @distancemax  = params[3]   if params.size > 3
  170.     @self_opacity = params[4]   if params.size > 4
  171.     @character = character
  172.     update
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # * Frame Update
  176.   #--------------------------------------------------------------------------
  177.   def update
  178.     # If shadow not in range of light source
  179.     if !in_range?(@character, @source, @distancemax)
  180.       self.opacity = 0
  181.       return
  182.     end
  183.     super
  184.     # If tile ID, file name, or hue are different from current ones
  185.     if @tile_id != @character.tile_id or
  186.        @character_name != @character.character_name or
  187.        @character_hue != @character.character_hue
  188.       # Remember tile ID, file name, and hue
  189.       @tile_id = @character.tile_id
  190.       @character_name = @character.character_name
  191.       @character_hue = @character.character_hue
  192.       # If tile ID value is valid
  193.       if @tile_id >= 384
  194.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  195.           @tile_id, @character.character_hue)
  196.         self.src_rect.set(0, 0, 32, 32)
  197.         self.ox = 16
  198.         self.oy = 32
  199.       # If tile ID value is invalid        
  200.       else
  201.         self.bitmap = RPG::Cache.character(@character.character_name,
  202.           @character.character_hue)
  203.         @cw = bitmap.width / 4
  204.         @ch = bitmap.height / 4
  205.         self.ox = @cw / 2
  206.         self.oy = @ch
  207.       end
  208.     end
  209.     # Set visible situation
  210.     self.visible = (not @character.transparent)
  211.     # If graphic is character
  212.     if @tile_id == 0
  213.       # Set rectangular transfer
  214.       sx = @character.pattern * @cw
  215.       sy = (@character.direction - 2) / 2 * @ch
  216.       if self.angle > 90 or angle < -90
  217.         sy = ( 4 - 2) / 2 * @ch   if @character.direction == 6
  218.         sy = ( 6 - 2) / 2 * @ch   if @character.direction == 4
  219.         sy = ( 8 - 2) / 2 * @ch   if @character.direction == 2
  220.         sy = ( 2 - 2) / 2 * @ch   if @character.direction == 8
  221.       end
  222.       self.src_rect.set(sx, sy, @cw, @ch)
  223.     end
  224.     # Set sprite coordinates    
  225.     self.x = @character.screen_x
  226.     self.y = @character.screen_y-5
  227.     self.z = @character.screen_z(@ch)-1
  228.     # Set blend method and bush depth
  229.     self.blend_type = @character.blend_type
  230.     self.bush_depth = @character.bush_depth
  231.     # Animation
  232.     if @character.animation_id != 0
  233.       animation = $data_animations[@character.animation_id]
  234.       animation(animation, true)
  235.       @character.animation_id = 0
  236.     end
  237.     @deltax       = @source.screen_x - self.x
  238.     @deltay       = @source.screen_y - self.y
  239.     self.color    = Color.new(0, 0, 0)
  240.     @distance     = ((@deltax ** 2) + (@deltay ** 2))
  241.     # Set opacity level based on light source distance
  242.     self.opacity  = @self_opacity * 13000 /
  243.                       ((@distance * 370 / @distancemax) + 6000)
  244.     self.angle    = 57.3 * Math.atan2(@deltax, @deltay )
  245.     @angle_trigo  = self.angle+90
  246.     if @angle_trigo < 0
  247.         @angle_trigo = 360 + @angle_trigo
  248.      end
  249.     if @anglemin != 0 or @anglemax != 0
  250.        if (@angle_trigo < @anglemin or @angle_trigo > @anglemax) and
  251.           @anglemin < @anglemax
  252.          self.opacity = 0
  253.          return
  254.        end
  255.        if (@angle_trigo < @anglemin and @angle_trigo > @anglemax) and
  256.           @anglemin > @anglemax
  257.          self.opacity=0
  258.          return
  259.        end    
  260.      end
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # * In Range?  (From Near's Anti Lag Script, edited)
  264.   #     element     : element
  265.   #     object      : object
  266.   #     range       : range in tiles
  267.   #--------------------------------------------------------------------------  
  268.   def in_range?(element, object, range)
  269.     x = (element.screen_x - object.screen_x) * (element.screen_x - object.screen_x)
  270.     y = (element.screen_y - object.screen_y) * (element.screen_y - object.screen_y)
  271.     r = x + y
  272.     if r <= (range * range)
  273.        return true
  274.     else
  275.       return false
  276.     end
  277.   end
  278. end
  279.  
  280.  
  281.  
  282. #==============================================================================
  283. # ** Sprite_Character
  284. #------------------------------------------------------------------------------
  285. #  This sprite is used to display the character.It observes the Game_Character
  286. #  class and automatically changes sprite conditions.
  287. #==============================================================================
  288.  
  289. class Sprite_Character < RPG::Sprite
  290.   #--------------------------------------------------------------------------
  291.   # * Alias Listings
  292.   #--------------------------------------------------------------------------
  293.   alias shadow_initialize initialize
  294.   alias shadow_update update  
  295.   #--------------------------------------------------------------------------
  296.   # * Object Initialization
  297.   #     viewport  : viewport
  298.   #     character : character (Game_Character)
  299.   #--------------------------------------------------------------------------
  300.   def initialize(viewport, character = nil)
  301.     @character = character
  302.     super(viewport)
  303.     @ombrelist = []
  304. if $scene = Scene_Map.new
  305.     if character.is_a?(Game_Event) and $game_temp.shadow_spriteset.shadows != []
  306.       params = XPML.XPML_read("Shadow", @character.id, 5)
  307.       if params != nil
  308.         for i in 0...$game_temp.shadow_spriteset.shadows.size
  309.           @ombrelist.push(Sprite_Shadow.new(viewport, @character,i))
  310.         end
  311.       end
  312.     end
  313. end
  314.     if $scene == Scene_Map.new
  315.     if character.is_a?(Game_Player) and $game_temp.shadow_spriteset.shadows != []
  316.       for i in 0...$game_temp.shadow_spriteset.shadows.size
  317.         @ombrelist.push(Sprite_Shadow.new(viewport, $game_player,i))
  318.       end
  319.       end
  320.       #===================================================
  321.       # * Compatibility with Caterpillar Functions
  322.       #===================================================
  323.       if CATERPILLAR_COMPATIBLE and $game_party.characters != nil
  324.         for member in $game_party.characters
  325.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  326.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  327.           end
  328.         end
  329.       end
  330.       if SQUAD_MOVE_COMPATIBLE and $game_allies.values != nil
  331.         for member in $game_allies.values
  332.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  333.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  334.           end
  335.         end
  336.       end
  337.       if CCOA_CATER_COMPATIBLE and $game_train.actors != nil
  338.         for member in $game_train.actors
  339.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  340.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  341.           end
  342.         end
  343.       end
  344.       if TRICKSTER_CATER_COMPATIBLE and $game_party.followers != nil
  345.         for member in $game_party.followers
  346.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  347.             @ombrelist.push(Sprite_Shadow.new(viewport, member, i))
  348.           end
  349.         end
  350.       end
  351.       #===================================================
  352.       # ** End of the compatibility
  353.       #===================================================      
  354.     end
  355.     # Perform the original call
  356.     shadow_initialize(viewport, @character)
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # * Frame Update
  360.   #--------------------------------------------------------------------------
  361.   def update
  362.     shadow_update
  363.     if @ombrelist != []
  364.       for i in [email hidden]
  365.         @ombrelist[i].update
  366.       end
  367.     end
  368.   end  
  369. end
  370.  
  371.  
  372.  
  373. #==============================================================================
  374. # ** Game_Event
  375. #------------------------------------------------------------------------------
  376. #  This class deals with events. It handles functions including event page
  377. #  switching via condition determinants, and running parallel process events.
  378. #  It's used within the Game_Map class.
  379. #==============================================================================
  380.  
  381. class Game_Event < Game_Character
  382.   #--------------------------------------------------------------------------
  383.   # * Public Instance Variables
  384.   #--------------------------------------------------------------------------
  385.   attr_accessor :id
  386. end
  387.  
  388.  
  389.  
  390. #==============================================================================
  391. # ** Spriteset_Map
  392. #------------------------------------------------------------------------------
  393. #  This class brings together map screen sprites, tilemaps, etc.
  394. #  It's used within the Scene_Map class.
  395. #==============================================================================
  396.  
  397. class Spriteset_Map
  398.   #--------------------------------------------------------------------------
  399.   # * Public Instance Variables
  400.   #--------------------------------------------------------------------------  
  401.   attr_accessor :shadows
  402.   #--------------------------------------------------------------------------
  403.   # * Alias Listings
  404.   #--------------------------------------------------------------------------  
  405.   alias shadow_initialize initialize
  406.   #--------------------------------------------------------------------------
  407.   # * Object Initialization
  408.   #--------------------------------------------------------------------------  
  409.   def initialize
  410.     $game_temp.shadow_spriteset = self
  411.     @shadows = []
  412.     warn = false
  413.     for k in $game_map.events.keys.sort
  414.       if ($game_map.events[k].list != nil and
  415.             $game_map.events[k].list[0].code == 108 and
  416.             ($game_map.events[k].list[0].parameters == ["s"] or
  417.             $game_map.events[k].list[0].parameters == ["o"]))
  418.         warn = true        
  419.       end
  420.       params = XPML.XPML_read("Shadow Source", k, 5)
  421.       if params != nil
  422.         $game_temp.shadow_spriteset.shadows.push([$game_map.events[k]] + params)
  423.       end
  424.     end
  425.     if warn == true and SHADOW_WARN
  426.       p "Warning : At least one event on this map uses an obsolete way to add shadows"
  427.     end
  428.     # Perform the original call
  429.     shadow_initialize
  430.   end  
  431. end
  432.  
  433.  
  434.  
  435. #==============================================================================
  436. # ** module XPML
  437. #------------------------------------------------------------------------------
  438. #  This module handles the reading and passing of 'comment' parameters
  439. #
  440. #  The main XPML method is used to check and read event comments.
  441. #  * It returns 'nil' if the markup 'check' text isn't even present.
  442. #  * It returns [] if no parameters are passed
  443. #  * It returns a parameter list with "int" converted as int.
  444. #       eg :
  445. #       begin first
  446. #       begin second
  447. #       param1 1
  448. #       param2 two
  449. #       begin third
  450. #       anything 3
  451. #
  452. #   p XPML_read("first", event_id) -> []
  453. #   p XPML_read("second", event_id) -> [1,"two"]
  454. #   p XPML_read("third", event_id) -> [3]
  455. #   p XPML_read("forth", event_id) -> nil
  456. #===================================================
  457.  
  458. module XPML
  459.   module_function
  460.   #--------------------------------------------------------------------------
  461.   # * XPML_read
  462.   #     markup           : text in event comment to check
  463.   #     event_id         : event ID
  464.   #     max_param_number : maximum number of parameter/comments to load
  465.   #--------------------------------------------------------------------------  
  466.   def XPML_read(markup, event_id, max_param_number = 0)
  467.     parameter_list = nil
  468.     event = $game_map.events[event_id]
  469.     return if event.list == nil
  470.       for i in 0...event.list.size
  471.         if event.list[i].code == 108 and
  472.           event.list[i].parameters[0].downcase == "begin " + markup.downcase
  473.           parameter_list = [] if parameter_list == nil
  474.           for j in i + 1...event.list.size
  475.             if event.list[j].code == 108
  476.               parts = event.list[j].parameters[0].split
  477.               if parts.size != 1 and parts[0].downcase != "begin"
  478.                 if parts[1].to_i != 0 or parts[1] == "0"
  479.                   parameter_list.push(parts[1].to_i)
  480.                 else
  481.                   parameter_list.push(parts[1])
  482.                 end
  483.               else
  484.                 return parameter_list
  485.               end
  486.             else
  487.               return parameter_list
  488.             end
  489.             if max_param_number != 0 and j == i + max_param_number
  490.               return parameter_list
  491.             end
  492.           end
  493.         end
  494.       end
  495.     return parameter_list
  496.   end
  497. end
Expand to see the code.


How about now?
I'd think the most straightforward solution would be to move :shadow_spriteset to something other than Game_Temp, like Game_System. That would deal with it not existing on load, and would even allow saving whatever data it stores.
BwdYeti wrote:
I'd think the most straightforward solution would be to move :shadow_spriteset to something other than Game_Temp, like Game_System. That would deal with it not existing on load, and would even allow saving whatever data it stores.

Right, but also it not being accessed during Scene's that are the map was just the easiest solution for me at the time. Both ways work. One just seemed easier than the other
@Star
The latest fix you offered does not fix the problem. In fact, it makes it so that I cannot start a New Game (somehow, it now clashes with my Particle System). When I go to continue, however, it gives me the same errors as before.

@BwdYeti
I do know exactly HOW to do this, but to try it, I went and changed all instances of Game_Temp and $game_temp to Game_System and $game_system. It still failed on Continue with the same error, and gave another error entirely when attempting to start a New Game.

@To Both
I apologize for the delay in replying, but I've had out of town company. I am thankful for both of you attempting to help me.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=71271