Project1

标题: 求教一下,在战斗结束的时候根据结果不同给不同的变量... [打印本页]

作者: foot1982    时间: 2017-2-28 20:41
标题: 求教一下,在战斗结束的时候根据结果不同给不同的变量...
求教一下,在战斗结束的时候根据结果不同给不同的变量赋值

意思就是胜利的时候  变量1 +=1
逃跑的时候  变量2 += 1

我搜索到几个地方
一个是 加在这~
Game_Interpreter里面的
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● 胜利的时候
  3.   #--------------------------------------------------------------------------
  4.   def command_601
  5.     command_skip if @branch[@indent] != 0
  6. $game_variables[1] +=1 #这是我加的
  7.   end
  8.   #--------------------------------------------------------------------------
  9.   # ● 撤退的时候
  10.   #--------------------------------------------------------------------------
  11.   def command_602
  12.     command_skip if @branch[@indent] != 1
  13. $game_variables[2] +=1 #这是我加的
  14.   end

但是加在这里的话,在游戏里无论是胜利还是撤退,变量1和2都会同时+1
然后我又找了
BattleManager 加在这里
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● 战斗结束
  3.   #     result : 结果(0:胜利 1:撤退 2:全灭)
  4.   #--------------------------------------------------------------------------
  5.   def self.battle_end(result)
  6.     @phase = nil
  7.     @event_proc.call(result) if @event_proc
  8.     $game_party.on_battle_end
  9.     $game_troop.on_battle_end
  10.     SceneManager.exit if $BTEST
  11.     if self.battle_end(result) == 0 #我加的
  12.       $game_variables[1] += 1 #我加的
  13.     end
  14.     if self.battle_end(result) == 1 #我加的
  15.       $game_variables[2] += 1  #我加的
  16.     end        
  17.   end


然后加在这里会报错
发生systemstackerror.
   stack level too deep
这样- -
求脚下,怎么弄这个问题啊
作者: 魔法丶小肉包    时间: 2017-2-28 20:51
RUBY 代码复制
  1. class << BattleManager
  2.   def battle_end(result)
  3.     @phase = nil
  4.     @event_proc.call(result) if @event_proc
  5.     $game_party.on_battle_end
  6.     $game_troop.on_battle_end
  7.     SceneManager.exit if $BTEST
  8.     if result == 0
  9.       $game_variables[1] += 1
  10.     end
  11.     if result == 1
  12.       $game_variables[2] += 1
  13.     end        
  14.   end
  15. end

作者: guoxiaomi    时间: 2017-2-28 23:59
顶楼上,你在脚本里无限次递归调用了方法battle_end,所以报错了。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1