Project1
标题:
有关于解释器战斗的程序问题
[打印本页]
作者:
kvkv97
时间:
2026-1-24 00:08
标题:
有关于解释器战斗的程序问题
本帖最后由 kvkv97 于 2026-1-24 00:10 编辑
class Interpreter
#--------------------------------------------------------------------------
# ● 战斗处理
#--------------------------------------------------------------------------
def command_301
# 如果不是无效的队伍
if $data_troops[@parameters[0]] != nil
# 设置中断战斗标志
$game_temp.battle_abort = true
# 设置战斗调用标志
$game_temp.battle_calling = true
$game_temp.battle_troop_id = @parameters[0]
$game_temp.battle_can_escape = @parameters[1]
$game_temp.battle_can_lose = @parameters[2]
# 设置返回调用
current_indent = @list[@index].indent
$game_temp.battle_proc = Proc.new { |n| @branch[current_indent] = n}
end
# 推进索引
@index += 1
# 结束
return false
end
#--------------------------------------------------------------------------
# ● 胜利的情况下
#--------------------------------------------------------------------------
def command_601
# 战斗结果为胜利的情况下
if @branch[@list[@index].indent] == 0
# 删除分支数据
@branch.delete(@list[@index].indent)
# 继续
return true
end
# 不符合条件的情况下 : 指令跳转
return command_skip
end
#--------------------------------------------------------------------------
# ● 逃跑的情况下
#--------------------------------------------------------------------------
def command_602
# 战斗结果为逃跑的情况下
if @branch[@list[@index].indent] == 1
# 删除分支数据
@branch.delete(@list[@index].indent)
# 继续
return true
end
# 不符合条件的情况下 : 指令跳转
return command_skip
end
设定的是队伍1,允许逃跑,没允许失败,这个的程序列表是:
# [#<R::EC:@p=[1,true,false],@i=0,c=301>,
# #<R::EC:@p=[],@i=0,c=601>,
# #<R::EC:@p=[],@i=1,c=0>
# #<R::EC:@p=[],@i=0,c=602>,
# #<R::EC:@p=[],@i=1,c=0>
# #<R::EC:@p=[],@i=0,c=604>,
# #<R::EC:@p=[],@i=0,c=0>]
上面是执行列表,1,执行@list[0].code ——>return command_301,里面有@index += 1和return false,中断循环,
2,场景转入战斗,胜利
3,执行@list[1].code ——>return command_601,里面有return true即是@index += 1,执行循环,执行@list[2].code ,那么这个是#<R::EC:@p=[],@i=1,c=0>
为什么这个跟P出来的结果不一样,P出来的是 执行#<R::EC:@p=[],@i=0,c=602>,而不是执行#<R::EC:@p=[],@i=1,c=0>,为什么?
作者:
灯笼菜刀王
时间:
2026-1-24 17:30
因为@i = 0 和 @i = 1 不在同一轴, 编辑器里表现上会往后缩一位 具体看F1
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1