IceDragon200

ISS007-EventUpgrade 1.3

Aug 1st, 2011
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.26 KB | None | 0 0
  1. #==============================================================================#
  2. # ** ISS - Event Upgrade
  3. #==============================================================================#
  4. # ** Date Created  : 04/28/2011
  5. # ** Date Modified : 07/31/2011
  6. # ** Created By    : IceDragon
  7. # ** For Game      : S.A.R.A
  8. # ** ID            : 007
  9. # ** Version       : 1.3
  10. # ** Requires      : ISS000 - Core 1.1 (or above)
  11. #==============================================================================#
  12. $imported ||= {}
  13. $imported["ISS-EventUpgrade"] = true
  14. #==============================================================================#
  15. # ** ISS
  16. #==============================================================================#
  17. module ISS
  18.   module EV_UPGRADE
  19.     RESET_TEMP_ON_PAGE = false
  20.     COPY_MAP = 39
  21.   end  
  22. end
  23.  
  24. #==============================================================================#
  25. # ** ISS::REGEXP::ISS007
  26. #==============================================================================#
  27. module ISS
  28.   module REGEXP
  29.     module ISS007
  30.       module EVENT
  31.         TEMP     = /<(TEMP_EVENT|TEMP EVENT|TEMPEVENT)>/i
  32.         COPY1    = /<(?:COPY_EVENT|COPY EVENT|COPYEVENT):[ ]*(\d+)[ ]*,[ ]*(\d+)>/i
  33.         COPY2    = /<(?:COPY_EVENT|COPY EVENT|COPYEVENT):[ ]*(\d+)>/i
  34.         SCREEN_Z = /<(?:SCREEN_Z|SCREEN Z|SCREENZ):[ ]*(\d+)>/i
  35.         WATER    = /<(?:WATER_MOVE|WATER MOVE|WATERMOVE)>/i
  36.       end  
  37.     end  
  38.   end
  39. end
  40.  
  41. #==============================================================================#
  42. # ** Game_System
  43. #==============================================================================#
  44. class Game_System
  45.  
  46.   #--------------------------------------------------------------------------#
  47.   # * Public Instance Variables
  48.   #--------------------------------------------------------------------------#
  49.   attr_accessor :reset_temp_on_page
  50.  
  51.   #--------------------------------------------------------------------------#
  52.   # * alias-method :initialize
  53.   #--------------------------------------------------------------------------#
  54.   alias :iss007_gsys_initialize :initialize unless $@
  55.   def initialize()
  56.     iss007_gsys_initialize()
  57.     @reset_temp_on_page = ::ISS::EV_UPGRADE::RESET_TEMP_ON_PAGE
  58.   end
  59.  
  60. end
  61.  
  62. #==============================================================================#
  63. # ** Game_Map
  64. #==============================================================================#
  65. class Game_Map
  66.  
  67.   #--------------------------------------------------------------------------#
  68.   # * new-method :get_event
  69.   #--------------------------------------------------------------------------#
  70.   def get_event( map_id, event_id )
  71.     return get_map(map_id).events[event_id] if $imported["IEO-BugFixesUpgrades"]  
  72.     return load_data( sprintf( "Data/Map%03d.rvdata", map_id ) ).events[event_id]
  73.   end
  74.  
  75. end
  76.  
  77. #==============================================================================#
  78. # ** Game_Event
  79. #==============================================================================#
  80. class Game_Event < Game_Character
  81.  
  82.   #--------------------------------------------------------------------------#
  83.   # * Public Instance Variables
  84.   #--------------------------------------------------------------------------#
  85.   attr_accessor :temp_event
  86.  
  87.   #--------------------------------------------------------------------------#
  88.   # * alias-method :initialize
  89.   #--------------------------------------------------------------------------#  
  90.   alias :iss007_ge_initialize :initialize unless $@
  91.   def initialize( map_id, event )
  92.     @temp_event = false
  93.     @reset_temp_on_page = $game_system.reset_temp_on_page
  94.     iss007_ge_initialize( map_id, event )
  95.     iss007_initcache()
  96.   end
  97.  
  98.   #--------------------------------------------------------------------------#
  99.   # * new-method :iss007_initcache
  100.   #--------------------------------------------------------------------------#  
  101.   def iss007_initcache()
  102.     @self_switches = {}
  103.     @self_switches["A"] = false
  104.     @self_switches["B"] = false
  105.     @self_switches["C"] = false
  106.     @self_switches["D"] = false
  107.   end
  108.  
  109.   #--------------------------------------------------------------------------#
  110.   # * new-method :set_self_switch
  111.   #--------------------------------------------------------------------------#
  112.   def set_self_switch( swi, bool )
  113.     if @temp_event # // Temp Event Internal Self Switch
  114.       @self_switches[ swi.upcase ] = bool
  115.     else  
  116.       key = [ @map_id, @event.id, swi.upcase ]
  117.       $game_self_switches[ key ] = bool
  118.     end  
  119.   end
  120.  
  121.   #--------------------------------------------------------------------------#
  122.   # * overwrite-method :conditions_met?
  123.   #--------------------------------------------------------------------------#
  124.   def conditions_met?( page )
  125.     c = page.condition
  126.     if c.switch1_valid      # Switch 1
  127.       return false if $game_switches[c.switch1_id] == false
  128.     end
  129.     if c.switch2_valid      # Switch 2
  130.       return false if $game_switches[c.switch2_id] == false
  131.     end
  132.     if c.variable_valid     # Variable
  133.       return false if $game_variables[c.variable_id] < c.variable_value
  134.     end
  135.     if @temp_event # // Temp Event Internal Self Switch
  136.       return false unless @self_switches[c.self_switch_ch]
  137.     else  
  138.       if c.self_switch_valid  # Self switch
  139.         key = [@map_id, @event.id, c.self_switch_ch]
  140.         return false if $game_self_switches[key] != true
  141.       end
  142.     end  
  143.     if c.item_valid         # Item
  144.       item = $data_items[c.item_id]
  145.       return false if $game_party.item_number(item) == 0
  146.     end
  147.     if c.actor_valid        # Actor
  148.       actor = $game_actors[c.actor_id]
  149.       return false unless $game_party.members.include?(actor)
  150.     end
  151.     return true   # Conditions met
  152.   end
  153.  
  154.   #--------------------------------------------------------------------------#
  155.   # * alias-method :setup
  156.   #--------------------------------------------------------------------------#
  157.   alias :iss007_ge_setup :setup unless $@
  158.   def setup( new_page )
  159.     iss007_ge_setup( new_page )
  160.     iss007_eventcache()
  161.   end
  162.  
  163.   #--------------------------------------------------------------------------#
  164.   # * new-method :iss007_eventcache
  165.   #--------------------------------------------------------------------------#
  166.   def iss007_eventcache()
  167.     @temp_event = false if @reset_temp_on_page
  168.     @water_event= false
  169.     return if @list == nil
  170.     for i in 0..@list.size
  171.       next if @list[i] == nil
  172.       if @list[i].code == 108
  173.         @list[i].parameters.to_s.split(/[\r\n]+/).each { |line|
  174.         case line
  175.         when ISS::REGEXP::ISS007::EVENT::WATER
  176.           @water_event= true
  177.         when ISS::REGEXP::ISS007::EVENT::TEMP
  178.           @temp_event = true
  179.         when ISS::REGEXP::ISS007::EVENT::COPY1
  180.           @event = $game_map.get_event( $1.to_i, $2.to_i ).clone
  181.           @event.id = @id
  182.           return refresh()
  183.         when ISS::REGEXP::ISS007::EVENT::COPY2
  184.           @event = $game_map.get_event( ISS::EV_UPGRADE::COPY_MAP, $1.to_i ).clone
  185.           @event.id = @id
  186.           return refresh()  
  187.         end
  188.         }
  189.       end
  190.     end
  191.   end
  192.  
  193.   #--------------------------------------------------------------------------#
  194.   # * overwrite-method :map_passable?
  195.   #--------------------------------------------------------------------------#
  196.   def map_passable?( x, y )
  197.     return $game_map.ship_passable?( x, y ) if @water_event
  198.     return super( x, y )
  199.   end
  200.  
  201. end  
  202.  
  203. #==============================================================================#
  204. # ** Game_Interpreter
  205. #==============================================================================#
  206. class Game_Interpreter
  207.  
  208.   #--------------------------------------------------------------------------#
  209.   # * overwrite-method :command_123
  210.   #--------------------------------------------------------------------------#
  211.   def command_123()
  212.     if @original_event_id > 0
  213.       ev = get_character(@original_event_id)
  214.       ev.set_self_switch( @params[0], @params[1] == 0 ) if ev.is_a?( Game_Event )
  215.     end
  216.     $game_map.need_refresh = true
  217.     return true
  218.   end
  219.  
  220. end
  221.  
  222. #=*==========================================================================*=#
  223. # ** END OF FILE
  224. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment