先说一下游戏的大环境: 
 
力量、敏捷、速度、魔力(下简称四围)的升级曲线为一条直线(不随等级提升)。同时整合了手动加点脚本+装备修炼属性。所以四围的提升完全靠加点和锻炼实现。由于使用了装备修炼属性,理论上所有角色都可以把四围全部培养到999,这样会让角色失去自己的特性。因此我正在制作一个潜力系统。简化一下我目前的做法,思路是每个角色用4个变量来代替该角色的四围的培养上限。具体调用方式为: 
力量: $game_variables[@actor.id + (@actor.id - 1) * 3 + 100]  
敏捷: $game_variables[@actor.id + (@actor.id - 1) * 3 + 101]  
速度: $game_variables[@actor.id + (@actor.id - 1) * 3 + 102] 
魔力: $game_variables[@actor.id + (@actor.id - 1) * 3 + 103] 
 
用变量来代替上限的原因是我还做了一个别的养成系统来提升每个人物的四围培养上限(只能提升一定的量,远不会达到四围全999上限)。这个时候找到Game_Battler 1里定义四围的部分: 
 
以力量为例: 
 
def str     n = [[base_str + @str_plus, 1].max, 999].min     for i in @states       n *= $data_states[i].str_rate / 100.0     end     n = [[Integer(n), 1].max, 999].min     return n end 
 
 def str  
    n = [[base_str + @str_plus, 1].max, 999].min  
    for i in @states  
      n *= $data_states[i].str_rate / 100.0  
    end  
    n = [[Integer(n), 1].max, 999].min  
    return n  
end  
 
  
 
将之改为: 
def str     n_max = $game_variables[@actor.id + (@actor.id - 1) * 3 + 100]      n = [[base_str + @str_plus, 1].max, n_max].min       for i in @states         n *= $data_states[i].str_rate / 100.0       end       n = [[Integer(n), 1].max, n_max].min       return n end 
 
 def str  
    n_max = $game_variables[@actor.id + (@actor.id - 1) * 3 + 100]   
    n = [[base_str + @str_plus, 1].max, n_max].min  
      for i in @states  
        n *= $data_states[i].str_rate / 100.0  
      end  
      n = [[Integer(n), 1].max, n_max].min  
      return n  
end  
 
  
 
改完后在测试的时候却发现没有效果。我尝试过把n_max改为一个固定的变量(例如 $game_variables[101]),这样就一切ok。后来我想是不是还有鉴别enemy和actor的区别,所以我又加了一个条件: 
 
if self.is_a?(Game_Actor)   end 
 
 if self.is_a?(Game_Actor)  
   
end  
 
  
 
结果还是不行。不知道是不是因为Game_Actor < Game_Battler的缘故所以调用actor_id不成功呢?我的脚本功力很弱,所以只好到这里来寻求帮助了。请解疑,如何在Game_Battler 1里调用actor_id呢? |