IceDragon200

[VXA]Switchless Common Events (Ace Port)

May 6th, 2012
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.45 KB | None | 0 0
  1. =begin
  2.  
  3.  Switchless Common Events
  4.  by PK8
  5.  Created: 5/6/2012
  6.  Modified: -
  7.  Ace Port By IceDragon (06/05/2012 to 06/05/2012)
  8.  ──────────────────────────────────────────────────────────────────────────────
  9.  ■ Table of Contents
  10.    o Author's Notes                                - Line 15-17
  11.    o Introduction                                  - Line 19-25
  12.    o Features                                      - Line 27-30
  13.    o Methods Aliased                               - Line 32-35
  14.    o Changelog                                     - Line 37-39
  15.  ──────────────────────────────────────────────────────────────────────────────
  16.  ■ Author's Notes
  17.    This was a fairly quick script I wrote. It was an idea I had in my head
  18.    for a little while.
  19.  ──────────────────────────────────────────────────────────────────────────────
  20.  ■ Introduction
  21.    Remember how in RPG Maker 2000 and 2003, you didn't need to rely on switches
  22.    in order for your common events to run on parallel process and autorun? Well,
  23.    it's back. This script lets you set which common events are going to run in
  24.    either parallel processing or automatically, without the use of conditional
  25.    switches. You can even set up your own if conditional on how they should be
  26.    activated.
  27.  ──────────────────────────────────────────────────────────────────────────────
  28.  ■ Features
  29.    o Set which common events are going to use autorun or parallel process
  30.      triggering without a conditional switch.
  31.    o Create a custom conditional for your common event.
  32.  ──────────────────────────────────────────────────────────────────────────────
  33.  ■ Methods Aliased
  34.    Scene_Title.command_new_game
  35.    Game_Interpreter.setup_starting_event
  36.    Game_CommonEvent.refresh
  37.  ──────────────────────────────────────────────────────────────────────────────
  38.  ■ Changelog
  39.    v1   (5/6/2012) - Initial Release
  40.  
  41. =end
  42.  
  43. #==============================================================================
  44. # ** Configuration
  45. #==============================================================================
  46.  
  47. module PK8
  48.   class Switchless_CommonEvents
  49.     #--------------------------------------------------------------------------
  50.     # * Do not modify
  51.     #--------------------------------------------------------------------------
  52.     Autorun  = {}
  53.     Parallel = {}
  54.    
  55.     #--------------------------------------------------------------------------
  56.     # * Decide which common events would autorun without a switch.
  57.     # (Autorun or Parallel)[Common Event ID] = true               # => Boolean
  58.     # (Autorun or Parallel)[Common Event ID] = "Condition"        # => Boolean
  59.     # (Autorun or Parallel)[Common Event ID] = proc { Condition } # => Boolean
  60.     #--------------------------------------------------------------------------
  61.     #Autorun[0]  = true
  62.     #Parallel[1] = proc { $game_variables[18] > 24 and $game_switches[2] }
  63.     #Autorun[1]  = "[1,2,18].include?($game_map.map_id)"
  64.     Parallel[1] = true
  65.     #Autorun[2] = proc { Graphics.frame_count % 240 == 0 }
  66.     #--------------------------------------------------------------------------
  67.     # * Do not modify
  68.     #--------------------------------------------------------------------------
  69.     #for i in Autorun.keys
  70.     #  Autorun[i] = eval("proc {#{Autorun[i].to_s}}") unless Autorun[i].respond_to?(:call)
  71.     #end
  72.     for i in Parallel.keys
  73.       Parallel[i] = eval("proc {#{Parallel[i].to_s}}") unless Parallel[i].respond_to?(:call)
  74.     end
  75.   end
  76. end
  77. =begin
  78. #==============================================================================#
  79. # ** Game_Map
  80. #==============================================================================#
  81. class Game_Map
  82.   #--------------------------------------------------------------------------
  83.   # * Alias Listings
  84.   #--------------------------------------------------------------------------
  85.   unless method_defined?(:pk8_switchlesscommonev_setup_autorun_common_event)
  86.     alias :pk8_switchlesscommonev_setup_autorun_common_event :setup_autorun_common_event
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # * Starting Event Setup
  90.   #--------------------------------------------------------------------------
  91.   def setup_autorun_common_event
  92.     # Loop (common events)
  93.     for common_event in $data_common_events.compact
  94.       ppce_c = PK8::Switchless_CommonEvents::Autorun[common_event.id]
  95.       # If Proc exists then check the condition else use default
  96.       return common_event if instance_exec(&ppce_c) if ppce_c
  97.     end
  98.     pk8_switchlesscommonev_setup_autorun_common_event
  99.   end
  100. end
  101. =end
  102. #==============================================================================#
  103. # ** Game_CommonEvent
  104. #==============================================================================#
  105. class Game_CommonEvent
  106.   #--------------------------------------------------------------------------
  107.   # * Alias Listings
  108.   #--------------------------------------------------------------------------
  109.   unless method_defined?(:pk8_switchlesscommonev_active?)
  110.     alias :pk8_switchlesscommonev_active? :active?
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # * Refresh
  114.   #--------------------------------------------------------------------------
  115.   def active?
  116.     ppce_c = PK8::Switchless_CommonEvents::Parallel[@event.id]
  117.     # If Proc exists then check the condition else use default
  118.     ppce_c ? instance_exec(&ppce_c) : pk8_switchlesscommonev_active?
  119.   end
  120. end
  121. #==============================================================================#
  122. # ** DataManager
  123. #==============================================================================#
  124. class << DataManager
  125.   #--------------------------------------------------------------------------
  126.   # * Alias Listings
  127.   #--------------------------------------------------------------------------
  128.   unless method_defined?(:pk8_switchlesscommonev_load_normal_database)
  129.     alias :pk8_switchlesscommonev_load_normal_database :load_normal_database
  130.   end
  131.   #--------------------------------------------------------------------------
  132.   # * Load Database : Normal
  133.   #--------------------------------------------------------------------------
  134.   def load_normal_database
  135.     pk8_switchlesscommonev_load_normal_database
  136.     PK8::Switchless_CommonEvents::Autorun.keys.each do |i|
  137.       cmev = $data_common_events[i] ; cmev.trigger = 1; cmev.switch_id = 0
  138.     end  
  139.     PK8::Switchless_CommonEvents::Parallel.keys.each do |i|
  140.       cmev = $data_common_events[i] ; cmev.trigger = 2; cmev.switch_id = 0
  141.     end
  142.   end
  143. end
Advertisement
Add Comment
Please, Sign In to add comment