IceDragon200

ISS - SEE

Jul 16th, 2011
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.38 KB | None | 0 0
  1. # // 07/16/2011
  2. # // 07/16/2011
  3. # // Sub-Event Engine
  4. # <see: event_id>
  5. #  Will copy event (event_id) from the SEE map and use it as the Subevent
  6. # <see: event_id, map_id>
  7. #  Will copy event (event_id) from the map (map_id) and use it as the Subevent
  8. #==============================================================================#
  9. # ** ISS::SEE
  10. #==============================================================================#
  11. module ISS
  12.   module SEE
  13.     # // Sub Event Map
  14.     SEE_MAP_ID = 11
  15.     # // If the parent event is erased, should the subevent follow?
  16.     ERASE_SUBEVENT = true
  17.    
  18.   end
  19. end
  20.  
  21. #==============================================================================#
  22. # ** ISS::REGEXP::ISS014
  23. #==============================================================================#
  24. module ISS
  25.   module REGEXP
  26.     module ISS014
  27.       module EVENT
  28.         SEE2     = /<SEE:[ ]*(\d+),[ ](\d+)>/i
  29.         SEE1     = /<SEE:[ ]*(\d+)>/i
  30.       end  
  31.     end  
  32.   end
  33. end
  34.  
  35. #==============================================================================#
  36. # ** Game_Interpreter
  37. #==============================================================================#
  38. class Game_Interpreter
  39.  
  40.   #--------------------------------------------------------------------------#
  41.   # * Public Instance Variables
  42.   #--------------------------------------------------------------------------#  
  43.   attr_accessor :parent_event
  44.  
  45.   #--------------------------------------------------------------------------#
  46.   # * alias-method :get_character
  47.   #--------------------------------------------------------------------------#
  48.   alias :iss014_gi_get_character :get_character unless $@
  49.   def get_character( *args, &block )
  50.     ev = self.parent_event.nil?() ? $game_map.events[@event_id] : self.parent_event()
  51.     return iss014_gi_get_character( ev.refocus_id ) unless ev.refocus_id.nil?() unless ev.nil?()
  52.     iss014_gi_get_character( *args )
  53.   end
  54.  
  55. end
  56.  
  57. #==============================================================================#
  58. # ** Game_Map
  59. #==============================================================================#
  60. class Game_Map
  61.  
  62.   #--------------------------------------------------------------------------#
  63.   # * new-method :get_event
  64.   #--------------------------------------------------------------------------#
  65.   def get_event( map_id, event_id )
  66.     if $imported["IEO-BugFixesUpgrades"]
  67.       if IEO::UPGRADE::USE_MAP_CACHE
  68.         if @map_cache[map_id].nil?()
  69.           temp_map = load_data( sprintf( "Data/Map%03d.rvdata", map_id ) )
  70.           @map_cache[map_id] = temp_map
  71.         end  
  72.         return @map_cache[map_id].events[event_id]
  73.       end  
  74.     end  
  75.     temp_map = load_data( sprintf( "Data/Map%03d.rvdata", map_id ) )
  76.     return temp_map.events[event_id]
  77.   end unless method_defined? :get_event
  78.  
  79. end
  80.  
  81. #==============================================================================#
  82. # ** Game_Event
  83. #==============================================================================#
  84. class Game_Event < Game_Character
  85.  
  86.   #--------------------------------------------------------------------------#
  87.   # * Constants
  88.   #--------------------------------------------------------------------------#  
  89.   ERASE_SUBEVENT = ISS::SEE::ERASE_SUBEVENT
  90.  
  91.   #--------------------------------------------------------------------------#
  92.   # * Public Instance Variables
  93.   #--------------------------------------------------------------------------#  
  94.   attr_accessor :sub_event
  95.   attr_accessor :disable_subevent
  96.   attr_accessor :refocus_id
  97.   attr_accessor :is_subevent
  98.  
  99.   #--------------------------------------------------------------------------#
  100.   # * new-method :is_a_subsevent?
  101.   #--------------------------------------------------------------------------#
  102.   def is_a_subsevent?()
  103.     return self.is_subevent()
  104.   end  
  105.  
  106.   #--------------------------------------------------------------------------#
  107.   # * alias-method :setup
  108.   #--------------------------------------------------------------------------#
  109.   alias :iss014_ge_setup :setup unless $@
  110.   def setup( *args, &block )
  111.     iss014_ge_setup( *args, &block )
  112.     iss014_eventcache()
  113.     @interpreter.parent_event = self if self.is_a_subsevent?() unless @interpreter.nil?()
  114.   end
  115.  
  116.   #--------------------------------------------------------------------------#
  117.   # * new-method :setup_sub_event
  118.   #--------------------------------------------------------------------------#  
  119.   def setup_sub_event( ev_id, mp_id )
  120.     ev = $game_map.get_event( mp_id, ev_id ).deep_clone
  121.     ev.pages.each { |p| p.trigger = 4 } # // Forced to Parallel
  122.     @sub_event = Game_Event.new( @map_id, ev )
  123.     @sub_event.disable_subevent = true
  124.     @sub_event.is_subevent = true
  125.   end
  126.  
  127.   #--------------------------------------------------------------------------#
  128.   # * new-method :iss014_eventcache
  129.   #--------------------------------------------------------------------------#
  130.   def iss014_eventcache()
  131.     @sub_event = nil
  132.     return if @list.nil?()
  133.     for i in 0...@list.size
  134.       if @list[i].code == 108
  135.         @list[i].parameters.to_s.split(/[\r\n]+/).each { |line|
  136.         case line
  137.         when ISS::REGEXP::ISS014::EVENT::SEE2
  138.           setup_sub_event( $1.to_i, $2.to_i )
  139.         when ISS::REGEXP::ISS014::EVENT::SEE1
  140.           setup_sub_event( $1.to_i, ISS::SEE::SEE_MAP_ID )
  141.         end
  142.         }
  143.       end
  144.     end
  145.   end
  146.  
  147.   #--------------------------------------------------------------------------#
  148.   # * alias-method :erase
  149.   #--------------------------------------------------------------------------#
  150.   alias :iss014_ge_erase :erase unless $@  
  151.   def erase( *args, &block )
  152.     iss014_ge_erase( *args, &block )
  153.     @sub_event.erase() unless @sub_event.nil?() unless self.disable_subevent() if ERASE_SUBEVENT
  154.   end
  155.  
  156.   #--------------------------------------------------------------------------#
  157.   # * alias-method :update
  158.   #--------------------------------------------------------------------------#
  159.   alias :iss014_ge_update :update unless $@
  160.   def update( *args, &block )
  161.     iss014_ge_update( *args, &block )
  162.     @sub_event.update() unless self.sub_event().nil?() unless self.disable_subevent()
  163.   end
  164.  
  165. end
  166.  
  167. #=*==========================================================================*=#
  168. # ** END OF FILE
  169. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment