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

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


 1
 2一七四.霸王枪(瓦丝格雷斯矛升级为霸王枪,鼠标左键远距离突刺并撤回,右键挑飞敌人,敌人会喷血)
 3
 4	MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/spear_wathgrithr.lua文件
 5
 6	1.local function onequip(inst, owner)的下一行插入以下内容:
 7
 8	inst.fire = SpawnPrefab( "campfirefire" )
 9	local follower = inst.fire.entity:AddFollower()
10	follower:FollowSymbol( owner.GUID, "swap_object", 20, -88, 1 )
11	inst.fire.AnimState:SetMultColour(255/255,0/255,0/255,1)
12	inst.fire.Transform:SetScale(0.8, 0.8, 0.8)
13	inst.fire:RemoveComponent("heater")
14	inst.fire.persists = false
15
16
17	2.local function onunequip(inst, owner)的下一行插入以下内容:
18
19	inst.fire:Remove()
20	inst.fire = nil
21
22
23	3.将下列内容:
24
25	inst:AddComponent("weapon")
26	inst.components.weapon:SetDamage(TUNING.WATHGRITHR_SPEAR_DAMAGE)
27	
28	-------
29	
30	inst:AddComponent("finiteuses")
31	inst.components.finiteuses:SetMaxUses(TUNING.WATHGRITHR_SPEAR_USES)
32	inst.components.finiteuses:SetUses(TUNING.WATHGRITHR_SPEAR_USES)
33	
34	inst.components.finiteuses:SetOnFinished( onfinished )
35
36	替换为:
37
38local function canattack(inst, target)
39	if TheInput:IsMouseDown(MOUSEBUTTON_RIGHT) then
40	   GetPlayer().AnimState:PlayAnimation("atk")
41	   SpawnPrefab("groundpoundring_fx").Transform:SetPosition(GetPlayer().Transform:GetWorldPosition())
42	   SpawnPrefab("explode_small").Transform:SetPosition(target.Transform:GetWorldPosition())
43	   GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground")
44	   local pt01 = GetPlayer():GetPosition()
45	   local pt02 = target:GetPosition()
46	   target.Transform:SetPosition((pt02.x-pt01.x)*0.5+pt02.x, 0, (pt02.z-pt01.z)*0.5+pt02.z)
47	   local blood = SpawnPrefab("splash")
48	   blood.Transform:SetPosition(target.Transform:GetWorldPosition())
49	   blood.AnimState:SetMultColour(255/255,0/255,0/255,1)
50	   blood.Transform:SetScale(2, 2, 2)
51	   if target.components.locomotor then target.components.locomotor:Stop() end
52	   if target.components.combat then target.components.combat:SetTarget(GetPlayer()) end
53	   if target.components.health then
54		  target.components.health:DoDelta(-100)
55		  if target.components.health:GetPercent() < 0.3 then
56			 target.AnimState:SetMultColour(255/255,0/255,0/255,1)
57		  end
58	   end
59	end
60	return true
61end
62local function onattack(inst, attacker, target)
63	local pt1 = attacker:GetPosition()
64	local pt2 = target:GetPosition()
65	GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground")
66	attacker:DoTaskInTime(0.01, function()
67		attacker.Transform:SetPosition(pt2.x, pt2.y, pt2.z)
68		SpawnPrefab("explode_small").Transform:SetPosition(target.Transform:GetWorldPosition())
69		SpawnPrefab("groundpoundring_fx").Transform:SetPosition(target.Transform:GetWorldPosition())
70		if target.components.locomotor then target.components.locomotor:Stop() end
71		attacker:StartThread(function()
72			for k = 1, 3 do
73				local blood = SpawnPrefab("splash")
74				blood.Transform:SetPosition(pt2.x, 1.5, pt2.z)
75				blood.AnimState:SetMultColour(255/255,0/255,0/255,1)
76				blood.Transform:SetScale(2, 2, 2)
77				Sleep(.1)
78			end
79		end )
80		if target.components.health and target.components.health:GetPercent() < 0.3 then
81		   target.AnimState:SetMultColour(255/255,0/255,0/255,1)
82		end
83	end )
84	attacker:DoTaskInTime(0.3, function()
85		attacker.Transform:SetPosition(pt1.x, pt1.y, pt1.z)
86	end )
87end
88	inst:AddComponent("weapon")
89	inst.components.weapon:SetDamage(300)
90	inst.components.weapon:SetRange(15, 20)
91	inst.components.weapon:SetOnAttack(onattack)
92	inst.components.weapon:SetCanAttack(canattack)
93
94	即可让瓦丝格雷斯矛升级为霸王枪,装备霸王枪,鼠标左键点敌人(按住可连续攻击),会远距离突刺敌人,刺中后迅速撤回原位,不给敌人还击的机会。鼠标右键点敌人,可将敌人挑飞,按住右键扫过一群敌人,可防止被围攻。使用霸王枪时,敌人会喷血,场面极其惨烈,如果你是儿童,请捂住眼睛使用。瓦丝格雷斯矛可修改“全人物可制造瓦丝格雷斯矛、瓦丝格雷斯帽”获得