代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。

原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html


 1
 2一六六.魔之双臂(狼牙棒左键抓来敌人并致死、右键抓地移动主角)
 3
 4	MT管理器打开游戏目录/assets/scripts/prefabs/tentaclespike.lua文件,将下列内容:
 5
 6	inst:AddComponent("weapon")
 7	inst.components.weapon:SetDamage(TUNING.SPIKE_DAMAGE)
 8	
 9	-------
10	
11	inst:AddComponent("finiteuses")
12	inst.components.finiteuses:SetMaxUses(TUNING.SPIKE_USES)
13	inst.components.finiteuses:SetUses(TUNING.SPIKE_USES)
14	
15	inst.components.finiteuses:SetOnFinished( onfinished )
16
17	替换为:
18
19local function onattack(inst, owner, target)
20	local pt = owner:GetPosition()
21	if target.components.health then
22	   target.Transform:SetPosition(pt.x+1, pt.y, pt.z)
23	end
24	inst:DoTaskInTime(0.1, function() 
25		target.components.health:DoDelta(-3000)
26	end)
27end
28	inst:AddComponent("weapon")
29	inst.components.weapon:SetDamage(0)
30	inst.components.weapon:SetRange(20, 25)
31	inst.components.weapon:SetOnAttack(onattack)
32	inst.components.weapon:SetProjectile("bishop_charge")
33	inst:AddComponent("blinkstaff")
34
35	即可在装备狼牙棒时,对敌人点左键将其抓过来并致死;对空地点右键,抓地移动主角,使狼牙棒既可杀伤敌人,又可有效闪避。用来抓鸟、兔、火鸡、大象等会逃跑的动物也很实用哦。狼牙棒靠打沼泽里的触手获得