=begin
所谓的破限脚本一般都是这种思想,如何在有限中生成无限
指定几个公共事件,多个事件的内容都合入到这些事件中,
使用一定的方法将List分割,让他们能够“分裂”出多个额外的公共事件
使用方法
在事件内容前加上注释
<Add Event Name K01 N>
这个注释内容前面和后面可以任意增加字符标记方便自己查找之类的
Name就是事件的名称,
K+数字表示开关的ID(可以省略,省略时为0),
最后的是执行标记(可以省略,省略时默认为正常执行)
然后后面就是事件的内容了,一直到下一个这样的标记或者整个内容完结
而在事件中调用这些额外的公共事件的时候
使用脚本命令为
event_group_call(ID)
这里的ID是按顺序数出来的
同样也可以使用
event_group_ncall("name")
使用事件的名称来使用,所以事件的名称尽量不要重复
=end
module IISNOW_COMMONEVENT_SET_ADD
EVENT_GROUP_ID = [997] #事件组使用的公共事件ID数组
EVENT_GAP_CHAR_HEAD = "<" #额外事件标识头
EVENT_GAP_STR = "Add Event" #额外事件标记字符
EVENT_GAP_CHAR_BACK = ">" #额外事件标识尾
EVENT_GAP_TRIGGER_FLAG = "K" #额外事件触发开关标识
EVENT_TYPE_NORMAL = "N" #额外事件——正常执行标记
EVENT_TYPE_AUTO = "A" #额外事件——自动执行标记
EVENT_TYPE_CURRENT = "C" #额外事件——并行执行标记
#额外事件注释的正则表达式(不懂请不要随意修改)
EVENT_GAP_PATTERN = /#{EVENT_GAP_CHAR_HEAD}#{EVENT_GAP_STR}\s+(.+?)(\s+#{EVENT_GAP_TRIGGER_FLAG}(\d+))?(\s+(\w))?\s*#{EVENT_GAP_CHAR_BACK}/
end
module DataManager
include IISNOW_COMMONEVENT_SET_ADD
def self.load_database
if $BTEST
load_battle_test_database
else
load_normal_database
check_player_location
end
read_add_events
end
def self.read_add_events
$data_common_add_events = [nil];
normal_set = []
for id in EVENT_GROUP_ID
normal_set += $data_common_events[id].list
end
headFlag = true
addFlag = false
addEvent = RPG::CommonEvent.new
for list in normal_set do
getInfo = check_add_event(list)
if(headFlag)
headFlag = getInfo.nil?
if !headFlag
setCommandEvent(addEvent,getInfo)
end
elsif list.code !=0
if getInfo.nil?
addEvent.list << list
else
addEvent.list << RPG::EventCommand.new
$data_common_add_events << addEvent.clone
setCommandEvent(addEvent,getInfo)
end
else
addEvent.list << RPG::EventCommand.new
$data_common_add_events << addEvent.clone
end
end
end
def self.setCommandEvent(event,info)
event.id = $data_common_add_events.size
event.name = info[:name]
event.switch_id = info[:switch_id]
event.trigger = info[:trigger]
event.list = []
end
def self.check_add_event(list)
if list.code == 108
comstr = list.parameters[0]
return nil unless comstr =~ EVENT_GAP_PATTERN
name = $1
switch_id = 0
switch_id = $3.to_i unless $3.nil?
trigger = 0
case $5
when EVENT_TYPE_NORMAL
trigger = 0
when EVENT_TYPE_AUTO
trigger = 1
when EVENT_TYPE_CURRENT
trigger = 2
end
return {:name=>name,:switch_id =>switch_id,:trigger=>trigger}
end
return nil
end
end
class Game_Interpreter
def event_group_call(id)
event_get = $data_common_add_events[id]
if event_get
child = Game_Interpreter.new(@depth + 1)
child.setup(event_get.list, same_map? ? @event_id : 0)
child.run
end
end
def event_group_ncall(name)
event_get = $data_common_add_events.find do |event|
event && event.name == name
end
if event_get
child = Game_Interpreter.new(@depth + 1)
child.setup(event_get.list, same_map? ? @event_id : 0)
child.run
end
end
end
class Game_Add_CommonEvent < Game_CommonEvent
def initialize(common_event_id)
@event = $data_common_add_events[common_event_id]
refresh
end
end
class Game_Map
alias :iisnow_add_event_setup_autorun_common_event :setup_autorun_common_event
def setup_autorun_common_event
nevent = iisnow_add_event_setup_autorun_common_event
return nevent if nevent
event = $data_common_add_events.find do |event|
event && event.autorun? && $game_switches[event.switch_id]
end
@interpreter.setup(event.list) if event
event
end
alias :iisnow_add_event_setup_events :setup_events
def setup_events
iisnow_add_event_setup_events
@common_events += $data_common_add_events.select {|event| event && event.parallel? }.collect do |common_event|
Game_Add_CommonEvent.new(common_event.id)
end
end
end