变量添加工具
制作缘由(虽然和sizz123想的可能不太一样……):http://rpg.blue/viewthread.php?tid=35272
注意:
此脚本是我在得知政治考试选择只错了3个后RP爆发的产物,只通过简单测试……
故,出错不管!请慎重使用!
还有,没做文章显示和脚本的替换……
范例
#==============================================================================
# ■ 本脚本发自WWW.66RPG.COM,转载请注明!
#==============================================================================
=begin
说明:
此脚本偷懒用,可批量插入变量、开关且不影响原有设定
调用方式$ins.calll(mode,begin_id,num)
# mode : 模式(0,变量;1,开关)
# begin_id : 起始ID
# num : 加入数量
=end
class Ins_VS
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize
#p "初始化完成" # 无意义……
end
#--------------------------------------------------------------------------
# ● 调用对像
# mode : 模式(0,变量;1,开关)
# begin_id : 起始ID
# num : 加入数量
#--------------------------------------------------------------------------
def call(mode=0,begin_id=1,num=0)
return unless mode.is_a?(Integer) and begin_id.is_a?(Integer) and num.is_a?(Integer)
@mode = mode
@begin_id = begin_id
@num = num
make_step1
make_step2
make_step3
make_step4
make_step5
finish
end
#--------------------------------------------------------------------------
# ● 变量插入(伪)
#--------------------------------------------------------------------------
def make_step1
$data_system = load_data("Data/System.rxdata")
unless @mode == 0
@num.times do
$data_system.switches.insert(@begin_id, "")
end
else
@num.times do
$data_system.variables.insert(@begin_id, "")
end
end
save_data($data_system, "Data/System.rxdata")
make_step2
end
#--------------------------------------------------------------------------
# ● 公共事件处理
#--------------------------------------------------------------------------
def make_step2
$data_common_events = load_data("Data/CommonEvents.rxdata")
for commonevent in $data_common_events
next if commonevent == nil
if .include?(commonevent.trigger) and @mode == 1 and commonevent.switch_id >= @begin_id
commonevent.switch_id += @num
end
list = commonevent.list
make_list(list)
end
save_data($data_common_events, "Data/CommonEvents.rxdata")
end
#--------------------------------------------------------------------------
# ● 地图事件处理
#--------------------------------------------------------------------------
def make_step3
map_id = 1
loop do
break unless FileTest.exist?(sprintf("Data/Map%03d.rxdata", map_id))
map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
#读取事件
events = map.events
make_events(events)
save_data(map, sprintf("Data/Map%03d.rxdata", map_id))
map_id += 1
end
end
#--------------------------------------------------------------------------
# ● 队伍事件处理
#--------------------------------------------------------------------------
def make_step4
$data_troops = load_data("Data/Troops.rxdata")
for troop in $data_troops
next if troop == nil
@pages = troop.pages
for page in @pages
@page = page
condition = @page.condition
unless @mode == 0
if condition.switch_valid and condition.switch_id >= @begin_id
condition.switch_id += @num
end
end
list = @page.list
make_list(list)
end
end
save_data($data_troops,"Data/Troops.rxdata")
end
#--------------------------------------------------------------------------
# ● 敌人事件处理
#--------------------------------------------------------------------------
def make_step5
$data_enemies = load_data("Data/Enemies.rxdata")
for enemy in $data_enemies
#如果对变量操作,则跳出
break if @mode == 0
next if enemy== nil
for action in enemy.actions
if action.condition_switch_id >= @begin_id and action.condition_switch_id != 0
action.condition_switch_id += @num
end
end
end
save_data($data_enemies,"Data/Enemies.rxdata")
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def finish
p "Finish!"
exit
end
#--------------------------------------------------------------------------
# ● 事件处理
#--------------------------------------------------------------------------
def make_events(events)
@events = events
for event in @events
next if event == nil
#读取事件页
@pages = event.pages
for page in @pages
@page = page
#处理事件页条件
condition = @page.condition
unless @mode == 0
if condition.switch1_valid and condition.switch1_id >= @begin_id
condition.switch1_id += @num
end
if condition.switch2_valid and condition.switch2_id >= @begin_id
condition.switch2_id += @num
end
else
if condition.variable_valid and condition.variable_id >= @begin_id
#p condition.variable_id
condition.variable_id += @num
#p condition.variable_id
end
end
#处理事件内容
list = @page.list
make_list(list)
end
end
end
#--------------------------------------------------------------------------
# ● 事件处理
#--------------------------------------------------------------------------
def make_list(list)
@list = list
for eventcommand in @list
next if eventcommand == nil
make_eventcommand(eventcommand)
end
end
#--------------------------------------------------------------------------
# ● 事件处理
#--------------------------------------------------------------------------
def make_eventcommand(eventcommand)
@eventcommand = eventcommand
@parameters = @eventcommand.parameters
case @eventcommand.code
when 101# 文章的显示
#command_101
when 103# 处理数值输入
command_103
when 111# 条件分支
command_111
when 121# 操作开关
command_121
when 122# 操作变量
command_122
when 125# 增减金钱
command_125
when 126# 增减物品
command_126
when 127# 增减武器
command_127
when 128# 增减防具
command_128
when 201# 場所移動
command_201
when 202# 设置事件位置
command_202
when 311# 增减 HP
command_311
when 312# 增减 SP
command_312
when 331# 増減敌人的 HP
command_331
when 332# 増減敌人的 SP
command_332
end
end
#--------------------------------------------------------------------------
# ● 处理数值输入
#--------------------------------------------------------------------------
def command_103
return unless @mode == 0
@parameters += @num if @parameters >= @begin_id
end
#--------------------------------------------------------------------------
# ● 条件分支
#--------------------------------------------------------------------------
def command_111
# 条件判定
case @parameters
when 0# 开关
return if @mode == 0
@parameters += @num if @parameters >= @begin_id
when 1# 变量
return unless @mode == 0
@parameters += @num if @parameters >= @begin_id
unless @parameters == 0
@parameters += @num if @parameters >= @begin_id
end
end
end
#--------------------------------------------------------------------------
# ● 开关操作
#--------------------------------------------------------------------------
def command_121
#如果对变量操作,则跳出
return if @mode == 0
@parameters += @num if @parameters >= @begin_id
@parameters += @num if @parameters >= @begin_id
end
#--------------------------------------------------------------------------
# ● 变量操作
#--------------------------------------------------------------------------
def command_122
#如果对开关操作,则跳出
return unless @mode == 0
@parameters += @num if @parameters >= @begin_id
@parameters += @num if @parameters >= @begin_id
end
#--------------------------------------------------------------------------
# ● 增减金钱
#--------------------------------------------------------------------------
def command_125
return unless @mode == 0
return if @parameters == 0
@parameters += @num if @parameters >= @begin_id
end
#--------------------------------------------------------------------------
# ● 增减物品
#--------------------------------------------------------------------------
def command_126
return unless @mode == 0
return if @parameters == 0
@parameters += @num if @parameters >= @begin_id
end
#--------------------------------------------------------------------------
# ● 增减武器
#--------------------------------------------------------------------------
def command_127
command_126
end
#--------------------------------------------------------------------------
# ● 增减防具
#--------------------------------------------------------------------------
def command_128
command_126
end
#--------------------------------------------------------------------------
# ● 场所移动
#--------------------------------------------------------------------------
def command_201
#如果对开关操作,则跳出
return unless @mode == 0
if @parameters != 0
# 设置主角的移动目标
@parameters += @num if @parameters >= @begin_id
@parameters += @num if @parameters >= @begin_id
@parameters += @num if @parameters >= @begin_id
end
end
#--------------------------------------------------------------------------
# ● 设置事件位置
#--------------------------------------------------------------------------
def command_202
#如果对开关操作,则跳出
return unless @mode == 0
# 指定方法为 [直接指定] 的情况下
if @parameters == 1
@parameters += @num if @parameters >= @begin_id
@parameters += @num if @parameters >= @begin_id
end
end
#--------------------------------------------------------------------------
# ● 增减 HP
#--------------------------------------------------------------------------
def command_311
command_126
end
#--------------------------------------------------------------------------
# ● 增减 SP
#--------------------------------------------------------------------------
def command_312
command_126
end
#--------------------------------------------------------------------------
# ● 增减敌人的 HP
#--------------------------------------------------------------------------
def command_331
command_126
end
#--------------------------------------------------------------------------
# ● 增减敌人的 SP
#--------------------------------------------------------------------------
def command_332
command_126
end
end
$ins = Ins_VS.new
本帖来自P1论坛作者轮回者,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=35886若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页:
[1]