本帖最后由 fangyc 于 2013-9-20 13:19 编辑
这个是数据结构,在数据库中设定一个道具后,此道具的使用效果就用一个 RPG::UsableItem::Effect 的实例来储存
比如,物品增加500HP,那么他的效果应该以code的某个值保存,恢复量则保存在value1(固定值)或value2(百分比)里
code的值对应什么效果是工具里预先定义好的,它只是一个抽象的值,具体效果会在内置的脚本里体现出来
这个只能自己去内置脚本里找了
Game_Battler里有下面一段内容,意思就是如果code的值等于EFFECT_RECOVER_HP,那么就调用item_effect_recover_hp方法恢复HP,这样……
不知道楼主明白了没有…………
#-------------------------------------------------------------------------- # ● 应用使用效果 #-------------------------------------------------------------------------- def item_effect_apply(user, item, effect) method_table = { EFFECT_RECOVER_HP => :item_effect_recover_hp, EFFECT_RECOVER_MP => :item_effect_recover_mp, EFFECT_GAIN_TP => :item_effect_gain_tp, EFFECT_ADD_STATE => :item_effect_add_state, EFFECT_REMOVE_STATE => :item_effect_remove_state, EFFECT_ADD_BUFF => :item_effect_add_buff, EFFECT_ADD_DEBUFF => :item_effect_add_debuff, EFFECT_REMOVE_BUFF => :item_effect_remove_buff, EFFECT_REMOVE_DEBUFF => :item_effect_remove_debuff, EFFECT_SPECIAL => :item_effect_special, EFFECT_GROW => :item_effect_grow, EFFECT_LEARN_SKILL => :item_effect_learn_skill, EFFECT_COMMON_EVENT => :item_effect_common_event, } method_name = method_table[effect.code] send(method_name, user, item, effect) if method_name end
#--------------------------------------------------------------------------
# ● 应用使用效果
#--------------------------------------------------------------------------
def item_effect_apply(user, item, effect)
method_table = {
EFFECT_RECOVER_HP => :item_effect_recover_hp,
EFFECT_RECOVER_MP => :item_effect_recover_mp,
EFFECT_GAIN_TP => :item_effect_gain_tp,
EFFECT_ADD_STATE => :item_effect_add_state,
EFFECT_REMOVE_STATE => :item_effect_remove_state,
EFFECT_ADD_BUFF => :item_effect_add_buff,
EFFECT_ADD_DEBUFF => :item_effect_add_debuff,
EFFECT_REMOVE_BUFF => :item_effect_remove_buff,
EFFECT_REMOVE_DEBUFF => :item_effect_remove_debuff,
EFFECT_SPECIAL => :item_effect_special,
EFFECT_GROW => :item_effect_grow,
EFFECT_LEARN_SKILL => :item_effect_learn_skill,
EFFECT_COMMON_EVENT => :item_effect_common_event,
}
method_name = method_table[effect.code]
send(method_name, user, item, effect) if method_name
end
|