赞 | 2 |
VIP | 15 |
好人卡 | 41 |
积分 | 33 |
经验 | 128560 |
最后登录 | 2024-4-2 |
在线时间 | 1120 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 3298
- 在线时间
- 1120 小时
- 注册时间
- 2009-4-15
- 帖子
- 815
|
公孙少 发表于 2015-7-7 20:38 ![]()
你先把思路说一下吧……然后我就滚去学习脚本了……
思路其实蛮多的,看你需要哪种:
1.如果是受到物理攻击后,自身不受伤害,而是发动同样的技能来反击对方的话,全局搜索def invoke_item得到如下结果:- #--------------------------------------------------------------------------
- # ● 发动技能/物品
- #--------------------------------------------------------------------------
- def invoke_item(target, item)#target是受击方,@subject是发动方
- if rand < target.item_cnt(@subject, item)#如果触发反击
- invoke_counter_attack(target, item)#发动反击,可以通过修改invoke_counter_attack函数使得反击不是普通攻击而是受到的技能,具体可参照魔法反射
- elsif rand < target.item_mrf(@subject, item)#如果触发魔法反射
- invoke_magic_reflection(target, item)#发动魔法反射
- else#否者执行正常的使用技能效果
- apply_item_effects(apply_substitute(target, item), item)
- end
- @subject.last_target_index = target.index
- end
复制代码 你可以参照这个帖子:https://rpg.blue/thread-380462-1-1.html
2.上面的思路主要运用了反击这个系统自带的功能,第二个思路我们找def item_apply(user, item),解释如下:- #--------------------------------------------------------------------------
- # ● 应用技能/物品的效果
- #--------------------------------------------------------------------------
- def item_apply(user, item)#user代表技能发动者,self代表被伤害者
- @result.clear
- @result.used = item_test(user, item)
- @result.missed = (@result.used && rand >= item_hit(user, item))
- @result.evaded = ([email protected] && rand < item_eva(user, item))
- if @result.hit?#如果命中
- unless item.damage.none?
- @result.critical = (rand < item_cri(user, item))#是否暴击
- make_damage_value(user, item)#计算伤害
- execute_damage(user)#执行伤害,我们可以在这做文章,如果学会了xx技能、或者身上有xx状态,那么伤害是0,同时执行一次对敌伤害(既把受到的伤害返回给敌人)
- end
- item.effects.each {|effect| item_effect_apply(user, item, effect) }
- item_user_effect(user, item)
- end
- end
复制代码 具体代码你自己写吧~
以上,未测试 |
|