Project1
标题: 求教一下,在战斗结束的时候根据结果不同给不同的变量... [打印本页]
作者: foot1982 时间: 2017-2-28 20:41
标题: 求教一下,在战斗结束的时候根据结果不同给不同的变量...
求教一下,在战斗结束的时候根据结果不同给不同的变量赋值
意思就是胜利的时候 变量1 +=1
逃跑的时候 变量2 += 1
我搜索到几个地方
一个是 加在这~
Game_Interpreter里面的
#--------------------------------------------------------------------------
# ● 胜利的时候
#--------------------------------------------------------------------------
def command_601
command_skip if @branch[@indent] != 0
$game_variables[1] +=1 #这是我加的
end
#--------------------------------------------------------------------------
# ● 撤退的时候
#--------------------------------------------------------------------------
def command_602
command_skip if @branch[@indent] != 1
$game_variables[2] +=1 #这是我加的
end
#--------------------------------------------------------------------------
# ● 胜利的时候
#--------------------------------------------------------------------------
def command_601
command_skip if @branch[@indent] != 0
$game_variables[1] +=1 #这是我加的
end
#--------------------------------------------------------------------------
# ● 撤退的时候
#--------------------------------------------------------------------------
def command_602
command_skip if @branch[@indent] != 1
$game_variables[2] +=1 #这是我加的
end
但是加在这里的话,在游戏里无论是胜利还是撤退,变量1和2都会同时+1
然后我又找了
BattleManager 加在这里
#--------------------------------------------------------------------------
# ● 战斗结束
# result : 结果(0:胜利 1:撤退 2:全灭)
#--------------------------------------------------------------------------
def self.battle_end(result)
@phase = nil
@event_proc.call(result) if @event_proc
$game_party.on_battle_end
$game_troop.on_battle_end
SceneManager.exit if $BTEST
if self.battle_end(result) == 0 #我加的
$game_variables[1] += 1 #我加的
end
if self.battle_end(result) == 1 #我加的
$game_variables[2] += 1 #我加的
end
end
#--------------------------------------------------------------------------
# ● 战斗结束
# result : 结果(0:胜利 1:撤退 2:全灭)
#--------------------------------------------------------------------------
def self.battle_end(result)
@phase = nil
@event_proc.call(result) if @event_proc
$game_party.on_battle_end
$game_troop.on_battle_end
SceneManager.exit if $BTEST
if self.battle_end(result) == 0 #我加的
$game_variables[1] += 1 #我加的
end
if self.battle_end(result) == 1 #我加的
$game_variables[2] += 1 #我加的
end
end
然后加在这里会报错
发生systemstackerror.
stack level too deep
这样- -
求脚下,怎么弄这个问题啊
作者: 魔法丶小肉包 时间: 2017-2-28 20:51
class << BattleManager
def battle_end(result)
@phase = nil
@event_proc.call(result) if @event_proc
$game_party.on_battle_end
$game_troop.on_battle_end
SceneManager.exit if $BTEST
if result == 0
$game_variables[1] += 1
end
if result == 1
$game_variables[2] += 1
end
end
end
class << BattleManager
def battle_end(result)
@phase = nil
@event_proc.call(result) if @event_proc
$game_party.on_battle_end
$game_troop.on_battle_end
SceneManager.exit if $BTEST
if result == 0
$game_variables[1] += 1
end
if result == 1
$game_variables[2] += 1
end
end
end
作者: guoxiaomi 时间: 2017-2-28 23:59
顶楼上,你在脚本里无限次递归调用了方法battle_end,所以报错了。
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |