Project1

标题: 代码出错...求解! [打印本页]

作者: 负零    时间: 2013-4-25 23:31
标题: 代码出错...求解!
  1. class Game_Battler < Game_BattlerBase
  2.   alias get_actor_id_item_apply item_apply     
  3.   #--------------------------------------------------------------------------
  4.   # ● 应用技能/物品的效果
  5.   #--------------------------------------------------------------------------
  6.   def item_apply(user, item)
  7.     if actor?
  8.     get_actor_id_item_apply(user,item)
  9.     $game_variables[6] = @actor_id
  10.   else
  11.     $game_variables[6] = @index
  12.   end
  13. end
  14. end
复制代码
  1. class Scene_MagicAffect
  2.   #--------------------------------------------------------------------------
  3.   # ● 常量
  4.   #--------------------------------------------------------------------------
  5.    
  6.   #--------------------------------------------------------------------------
  7.   # ● 全局变量
  8.   #--------------------------------------------------------------------------
  9.   
  10.   #--------------------------------------------------------------------------
  11.   # ● 类变量
  12.   #--------------------------------------------------------------------------
  13.   def initialize
  14.   @target_id=$game_variables[6]
  15.   end
  16. def magic_mvsl
  17.     initialize
  18.     p @target_id
  19.     p  $game_troop[@target_id].state?(503)
  20.     if $game_troop[@target_id].state?(503)
  21.        $game_troop[@target_id].hp=100
  22.       $game_message.add("YES")
  23.     else
  24.       $game_message.add("10")
  25.    end
  26. end
复制代码
这代码的想法是获取敌人群组内的ID,如果该ID敌人包含设定的状态,则HP=100.
实在百思不得其解...请高手指点。
作者: 沙漠点灰    时间: 2013-4-25 23:44
$game_troop有属性members(和Game_Party差不多)
$game_troop.members[@target_id]

还有....代码缩进...强迫症伤不起= =
把硬编码换成常量 = =




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