Project1

标题: “为技能单独定义CP消耗”出现的NoMethodError错误 [打印本页]

作者: zing000    时间: 2007-7-8 19:22
标题: “为技能单独定义CP消耗”出现的NoMethodError错误
http://rpg.blue/web/htm/news550.htm
用了这个脚本后,出现了
NoMethodError
undefined method`userskill_cp_cost`for #<RPG::Skill:0x14f8760>
的错误,请问这个是什么原因?……


具体的问题阐述分割线----------------------------------------------

按他的说法我是这里出错了:
# スキル使用時の消費CP
@active_battler.cp -= $data_skills[@active_battler.current_action.skill_id].userskill_cp_cost if @phase4_act_continuation == 0

那个教程的步骤(http://rpg.blue/web/htm/news550.htm)

1:前面,添加如下代码:

module RPG
class Skill
def userskill_cp_cost
   name = @name.split(/,/)[1]
   return name != nil ? name.to_i.abs : 0
end
end
end

2:先把开头的CP_COST_SKILL_ACTION = 65535 # 技能删除。

3:然后找到
when 1
# スキル使用時の消費CP
@active_battler.cp -= CP_COST_SKILL_ACTION if @phase4_act_continuation == 0

很明显咯!开头就出现了@active_battler,并且后面紧接着出现了被我们删除的罪魁祸首

CP_COST_SKILL_ACTION

既然这里是@active_battler的地盘,那我们就可以放心大胆的用了。

将这一行的CP_COST_SKILL_ACTION 替换为

$data_skills[@active_battler.current_action.skill_id].userskill_cp_cost




之后进入战斗,只要一使用技能就会出错“NoMethodError
undefined method`userskill_cp_cost`for #<RPG::Skill:0x14f8760>
"……请教~
[LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: zing000    时间: 2007-7-8 19:22
标题: “为技能单独定义CP消耗”出现的NoMethodError错误
http://rpg.blue/web/htm/news550.htm
用了这个脚本后,出现了
NoMethodError
undefined method`userskill_cp_cost`for #<RPG::Skill:0x14f8760>
的错误,请问这个是什么原因?……


具体的问题阐述分割线----------------------------------------------

按他的说法我是这里出错了:
# スキル使用時の消費CP
@active_battler.cp -= $data_skills[@active_battler.current_action.skill_id].userskill_cp_cost if @phase4_act_continuation == 0

那个教程的步骤(http://rpg.blue/web/htm/news550.htm)

1:前面,添加如下代码:

module RPG
class Skill
def userskill_cp_cost
   name = @name.split(/,/)[1]
   return name != nil ? name.to_i.abs : 0
end
end
end

2:先把开头的CP_COST_SKILL_ACTION = 65535 # 技能删除。

3:然后找到
when 1
# スキル使用時の消費CP
@active_battler.cp -= CP_COST_SKILL_ACTION if @phase4_act_continuation == 0

很明显咯!开头就出现了@active_battler,并且后面紧接着出现了被我们删除的罪魁祸首

CP_COST_SKILL_ACTION

既然这里是@active_battler的地盘,那我们就可以放心大胆的用了。

将这一行的CP_COST_SKILL_ACTION 替换为

$data_skills[@active_battler.current_action.skill_id].userskill_cp_cost




之后进入战斗,只要一使用技能就会出错“NoMethodError
undefined method`userskill_cp_cost`for #<RPG::Skill:0x14f8760>
"……请教~
[LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: zing000    时间: 2007-7-9 02:00
之前地址连错了。。抱歉。。。
作者: zing000    时间: 2007-7-9 20:45
问题具体阐述了下。。希望能得到帮助
作者: 幻の飞鱼    时间: 2007-7-10 00:44
错误提示是

userskill_cp_cost未定义

教程里面说
添加如下代码:

module RPG
class Skill
def userskill_cp_cost
  name = @name.split(/,/)[1]
  return name != nil ? name.to_i.abs : 0
end
end
end

的目的就是定义userskill_cp_cost方法

看样子应该是这段脚本的位置没处理好 [LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: zing000    时间: 2007-7-10 20:05
谢谢,拜飞鱼大人~




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