This script is designed to examine if one (or more) parallel processes are currently running in your game. It will search through both map events and common events, and only deliver information on the parallel processes that have been triggered and are currently running.
Unlike my more recent additions, this merely delivers a pop-up window that informs game developers of the needed data, and will only execute when the game developer presses the hotkey combination in debug mode.
Script
The Script
Code:
#==============================================================================
# ** Parellel Proccess Checker
#------------------------------------------------------------------------------
# version 1.0
# by DerVVulfman
# 10-15-2014
# RGSS and ReGaL Compliant
#==============================================================================
#
# INTRODUCTION:
#
# This script is designed to examine if one (or more) parallel processes are
# currently running in your game. It will search through both map events and
# common events, and only deliver information on the parallel processes that
# have been triggered and are currently running.
#
# Unlike my more recent additions, this merely delivers a pop-up window that
# informs game developers of the needed data, and will only execute when the
# game developer presses the hotkey combination in debug mode.
#
#
#------------------------------------------------------------------------------
#
# INSTRUCTIONS:
#
# * Insert below your scripts.
# * Set your hotkey combo in the config area (currently CTRL+Shift)
# * Run project.
# * Try the hotkey combo (popups only show if anything is active)
# * Read the popup
#
#------------------------------------------------------------------------------
#
# CREDITS:
#
# Thanks given to MechanicalPen who put forth the request. It was a fun
# exercise.
#
#
#------------------------------------------------------------------------------
#
# NOTE:
#
# It does contain allowances for Auto-Run processes, but usually those would
# force complete execution before returning control TO the player. While it
# may check for them, it is highly unlikely (unless the system is tampered)
# that any auto-run triggers will be returned.
#
#
#==============================================================================
#==============================================================================
# ** Parallel Process Checker Hotkeys
#------------------------------------------------------------------------------
# This is a simple config module used by the game developer to set his/her
# own hotkeys for the system.
#==============================================================================
module PPC_Keys
PRESS_KEY = Input::CTRL
TRIGGER_KEY = Input::A
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias waha update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if $DEBUG &&
Input.press?(PPC_Keys::PRESS_KEY) &&
Input.trigger?(PPC_Keys::TRIGGER_KEY)
# Perform checks (both common and map event
ParallelChecker.check_commons($game_switches)
ParallelChecker.check_events($game_switches, $game_variables,
$game_self_switches, $game_map.map_id)
end
waha
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias waha update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if $DEBUG &&
Input.press?(PPC_Keys::PRESS_KEY) &&
Input.trigger?(PPC_Keys::TRIGGER_KEY)
# Perform check on common events (no map events in battle)
ParallelChecker.check_commons($game_switches)
end
waha
end
end
#==============================================================================
# ** ParallelChecker
#------------------------------------------------------------------------------
# This is a module that examines if parallel process are running and delivers
# a popup message on any currently running events.
#==============================================================================
module ParallelChecker
#--------------------------------------------------------------------------
# * Creates module functions usable by command calls
#--------------------------------------------------------------------------
module_function
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def self.main
set_resource_database
end
#--------------------------------------------------------------------------
# * Project Database Values
#--------------------------------------------------------------------------
def self.set_resource_database
@common_list = load_data("Data/CommonEvents.rxdata")
end
#--------------------------------------------------------------------------
# * Check Common Event List
# switch_list : $game_switches object
#--------------------------------------------------------------------------
def check_commons(switch_list)
for common in @common_list
next if common.nil?
if common.trigger != 0
trigger_text = (common.trigger == 2) ? "[Parallel]" : "[Auto-Run]"
if switch_list[common.switch_id] == true
common_name = "<No Name>"
common_name = common.name if common.name != ""
text_msg = (common.id).to_s
text_msg = text_msg + ") " + common_name + ": "
text_msg = text_msg + trigger_text
text_msg = text_msg + " Switch ID: " + (common.switch_id).to_s
print "Common Event: \n" + text_msg
end
end
end
end
#--------------------------------------------------------------------------
# * Check Common Event List
# switch_list : $game_switches object
# variable_list : $game_variables object
# self_list : $game_selfswitch object
# map_id : current map ID ($game_map.map_id)
#--------------------------------------------------------------------------
def check_events(switch_list, variable_list, self_list, map_id)
# Get Individual Map Data
map_data = load_data(sprintf("Data/Map%03d.rxdata", map_id))
# Set map event data
events = {}
for i in map_data.events.keys
events[i] = map_data.events[i]
end
# Sorth through Event Array
for event in events
next if event.nil?
counter = 0
name_text = event[0].to_s + ") "+ event[1].name
for page in event[1].pages.reverse
counter += 1
next if page.trigger < 3
trigger_text = (page.trigger == 4) ? "[Parallel]" : "[Auto-Run]"
trig_set = page.condition
# Determine Switches for event switches, variables, etc
key = [map_id, event[0], trig_set.self_switch_ch]
switch1_set = valid_switch_1?(trig_set, switch_list)
switch2_set = valid_switch_2?(trig_set, switch_list)
switch3_set = valid_switch_3?(trig_set, variable_list)
switch4_set = valid_switch_4?(trig_set, self_list, key)
# Block/prevent if not active
next unless (switch1_set && switch2_set && switch3_set && switch4_set)
# SET UP EVENT NAME AND PAGE TEXT
text_msg = "Map Event: \n" +
name_text + " (Pg "+counter.to_s + ") " +
trigger_text + ":"
# ADD SWITCH DATA
key = [map_id, event[0], trig_set.self_switch_ch]
text_msg += text_sw(switch_list, trig_set.switch1_id, "\n Switch1-[")
text_msg += text_sw(switch_list, trig_set.switch2_id, "\n Switch2-[")
text_msg += text_var(trig_set, variable_list )
text_msg += text_selfsw(trig_set, self_list, key)
# Display Text
print text_msg
end
end
end
#--------------------------------------------------------------------------
# * Validity of Switch1 (Switch #1)
#--------------------------------------------------------------------------
def valid_switch_1?(trig_set, switch_list)
effective = false
effective = true if trig_set.switch1_valid == false
if trig_set.switch1_valid = true
effective = true if switch_list[trig_set.switch1_id] == true
end
return effective
end
#--------------------------------------------------------------------------
# * Validity of Switch2 (Switch #2)
#--------------------------------------------------------------------------
def valid_switch_2?(trig_set, switch_list)
effective = false
effective = true if trig_set.switch2_valid == false
if trig_set.switch2_valid = true
effective = true if switch_list[trig_set.switch2_id] == true
end
return effective
end
#--------------------------------------------------------------------------
# * Validity of Switch3 (Variable)
#--------------------------------------------------------------------------
def valid_switch_3?(trig_set, variable_list)
# Determine if Variable
effective = false
effective = true if trig_set.variable_valid == false
if trig_set.variable_valid == true
if variable_list[trig_set.variable_id] >= trig_set.variable_value
effective = true
end
end
return effective
end
#--------------------------------------------------------------------------
# * Validity of Switch4 (Self Switch)
#--------------------------------------------------------------------------
def valid_switch_3?(trig_set, self_list, key)
switch4_set = false
switch4_set = true if trig_set.self_switch_valid == false
if trig_set.self_switch_valid == true
switch4_set = true if self_list[key] == true
end
end
#--------------------------------------------------------------------------
# * Process Switch Text
#--------------------------------------------------------------------------
def text_sw(data_list, switch_id, txt)
return "" unless data_list[switch_id] == true
return txt + (switch_id).to_s + "] "
end
#--------------------------------------------------------------------------
# * Process Variable Text
#--------------------------------------------------------------------------
def text_var(trig_set, data_list)
return "" unless trig_set.variable_valid == true
return "" unless data_list[trig_set.variable_id] >= trig_set.variable_value
texts = "\n Variable-[" + (trig_set.variable_id).to_s
texts += "] equal or above " + (trig_set.variable_value).to_s
return texts
end
#--------------------------------------------------------------------------
# * Process Self-Switch Text
#--------------------------------------------------------------------------
def text_selfsw(trig_set, data_list, key)
return "" unless trig_set.self_switch_valid == true
return "" unless data_list[key] == true
texts = "\n SelfSwitch-[" + trig_set.self_switch_ch + "] "
return texts
end
end
(Sorry, was watching a Livestream in german and got mixed up in the language there for a second Xb)
RE: Parellel Proccess Checker - Kain Nobel - 10-18-2014
This is awesome!
The only thing I'd probably change is to have it read from $data_common_events directly instead of allocating the @common_list instance variable; both copies of data would exist throughout the game session. Essentially you could remove the set_resource_database method and replace it with the following...
Example:
Code:
def common_list
$data_common_events
end
Then just Replace-All the @common_list instance for common_list hook function and you should be good to go :)