代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2一七五.霸王斧(用蜻蜓鳞片种霸王斧,攻击敌人时震开并伤害周围敌人,可吸敌人的血)
3
4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/dragon_scales.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
5
6local function OnDeploy (inst, pt)
7 local bigaxe = SpawnPrefab("dragon_scales")
8 bigaxe.Transform:SetPosition(pt.x, pt.y, pt.z)
9 bigaxe.AnimState:SetBank("Lucy_axe")
10 bigaxe.AnimState:SetBuild("Lucy_axe")
11 bigaxe.AnimState:PlayAnimation("idle")
12 bigaxe.components.inventoryitem:ChangeImageName("lucy")
13 bigaxe:AddComponent("named")
14 bigaxe.components.named:SetName("Poleaxe")
15 bigaxe:RemoveComponent("stackable")
16 bigaxe:RemoveComponent("deployable")
17 bigaxe:AddComponent("equippable")
18 bigaxe.components.equippable.equipslot = EQUIPSLOTS.HANDS
19 bigaxe.components.equippable:SetOnEquip(function(bigaxe, owner)
20 owner.AnimState:OverrideSymbol("swap_object", "swap_lucy_axe", "swap_lucy_axe")
21 owner.AnimState:Show("ARM_carry")
22 owner.AnimState:Hide("ARM_normal")
23 bigaxe.fire = SpawnPrefab( "campfirefire" )
24 local follower = bigaxe.fire.entity:AddFollower()
25 follower:FollowSymbol( owner.GUID, "swap_object", -2, -135, 1 )
26 bigaxe.fire.AnimState:SetMultColour(255/255,0/255,0/255,1)
27 bigaxe.fire:RemoveComponent("heater")
28 bigaxe.fire.persists = false
29 end )
30 bigaxe.components.equippable:SetOnUnequip(function(bigaxe, owner)
31 owner.AnimState:Hide("ARM_carry")
32 owner.AnimState:Show("ARM_normal")
33 bigaxe.fire:Remove()
34 bigaxe.fire = nil
35 end )
36 bigaxe:AddComponent("weapon")
37 bigaxe.components.weapon:SetDamage(500)
38 bigaxe.components.weapon:SetOnAttack(function(bigaxe, attacker, target)
39 GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground")
40 SpawnPrefab("groundpoundring_fx").Transform:SetPosition(attacker.Transform:GetWorldPosition())
41 GetPlayer().components.playercontroller:ShakeCamera(attacker, "FULL", 0.5, 0.05, 2, 40)
42 if target.components.locomotor then target.components.locomotor:Stop() end
43 if target.components.health:GetPercent() < 0.3 then
44 target.AnimState:SetMultColour(255/255,0/255,0/255,1)
45 end
46 attacker.components.health:DoDelta(150)
47 attacker:StartThread(function()
48 for k = 1, 3 do
49 local blood = SpawnPrefab("splash")
50 blood.Transform:SetPosition(target.Transform:GetWorldPosition())
51 blood.AnimState:SetMultColour(255/255,0/255,0/255,1)
52 blood.Transform:SetScale(2, 2, 2)
53 Sleep(.1)
54 end
55 end )
56 target:AddTag("nomove")
57 target:DoTaskInTime(0.4, function() target:RemoveTag("nomove") end )
58 local pos = Vector3(attacker.Transform:GetWorldPosition())
59 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 8)
60 for k,v in pairs(ents) do
61 if v.components.health and v.components.combat and not v.components.health:IsDead() and not v:HasTag("nomove") then
62 if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v:HasTag("monster") then
63 SpawnPrefab("explode_small").Transform:SetPosition(v.Transform:GetWorldPosition())
64 v.components.health:DoDelta(-300)
65 local pt01 = attacker:GetPosition()
66 local pt02 = v:GetPosition()
67 v.Transform:SetPosition((pt02.x-pt01.x)*1.5+pt02.x, 0, (pt02.z-pt01.z)*1.5+pt02.z)
68 if v.components.locomotor then v.components.locomotor:Stop() end
69 if v.components.health:GetPercent() < 0.3 then
70 v.AnimState:SetMultColour(255/255,0/255,0/255,1)
71 end
72 end
73 end
74 end
75 end )
76 bigaxe:AddComponent("tool")
77 bigaxe.components.tool:SetAction(ACTIONS.CHOP, 15)
78 bigaxe:AddTag("bigaxes")
79 inst.components.stackable:Get():Remove()
80end
81 inst:AddComponent("deployable")
82 inst.components.deployable.ondeploy = OnDeploy
83local function onsave(inst, data)
84 if inst:HasTag("bigaxes") then
85 data.bigaxes = true
86 end
87end
88local function onload(inst, data)
89 if data and data.bigaxes then
90 inst.AnimState:SetBank("Lucy_axe")
91 inst.AnimState:SetBuild("Lucy_axe")
92 inst.AnimState:PlayAnimation("idle")
93 inst.components.inventoryitem:ChangeImageName("lucy")
94 inst:AddComponent("named")
95 inst.components.named:SetName("Poleaxe")
96 inst:RemoveComponent("stackable")
97 inst:RemoveComponent("deployable")
98 inst:AddComponent("equippable")
99 inst.components.equippable.equipslot = EQUIPSLOTS.HANDS
100 inst.components.equippable:SetOnEquip(function(inst, owner)
101 owner.AnimState:OverrideSymbol("swap_object", "swap_lucy_axe", "swap_lucy_axe")
102 owner.AnimState:Show("ARM_carry")
103 owner.AnimState:Hide("ARM_normal")
104 inst.fire = SpawnPrefab( "campfirefire" )
105 local follower = inst.fire.entity:AddFollower()
106 follower:FollowSymbol( owner.GUID, "swap_object", -2, -135, 1 )
107 inst.fire.AnimState:SetMultColour(255/255,0/255,0/255,1)
108 inst.fire:RemoveComponent("heater")
109 inst.fire.persists = false
110 end )
111 inst.components.equippable:SetOnUnequip(function(inst, owner)
112 owner.AnimState:Hide("ARM_carry")
113 owner.AnimState:Show("ARM_normal")
114 inst.fire:Remove()
115 inst.fire = nil
116 end )
117 inst:AddComponent("weapon")
118 inst.components.weapon:SetDamage(500)
119 inst.components.weapon:SetOnAttack(function(inst, attacker, target)
120 GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground")
121 SpawnPrefab("groundpoundring_fx").Transform:SetPosition(attacker.Transform:GetWorldPosition())
122 GetPlayer().components.playercontroller:ShakeCamera(attacker, "FULL", 0.5, 0.05, 2, 40)
123 if target.components.locomotor then target.components.locomotor:Stop() end
124 if target.components.health:GetPercent() < 0.3 then
125 target.AnimState:SetMultColour(255/255,0/255,0/255,1)
126 end
127 attacker.components.health:DoDelta(150)
128 attacker:StartThread(function()
129 for k = 1, 3 do
130 local blood = SpawnPrefab("splash")
131 blood.Transform:SetPosition(target.Transform:GetWorldPosition())
132 blood.AnimState:SetMultColour(255/255,0/255,0/255,1)
133 blood.Transform:SetScale(2, 2, 2)
134 Sleep(.1)
135 end
136 end )
137 target:AddTag("nomove")
138 target:DoTaskInTime(0.4, function() target:RemoveTag("nomove") end )
139 local pos = Vector3(attacker.Transform:GetWorldPosition())
140 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 8)
141 for k,v in pairs(ents) do
142 if v.components.health and v.components.combat and not v.components.health:IsDead() and not v:HasTag("nomove") then
143 if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v:HasTag("monster") then
144 SpawnPrefab("explode_small").Transform:SetPosition(v.Transform:GetWorldPosition())
145 v.components.health:DoDelta(-300)
146 local pt01 = attacker:GetPosition()
147 local pt02 = v:GetPosition()
148 v.Transform:SetPosition((pt02.x-pt01.x)*1.5+pt02.x, 0, (pt02.z-pt01.z)*1.5+pt02.z)
149 if v.components.locomotor then v.components.locomotor:Stop() end
150 if v.components.health:GetPercent() < 0.3 then
151 v.AnimState:SetMultColour(255/255,0/255,0/255,1)
152 end
153 end
154 end
155 end
156 end )
157 inst:AddComponent("tool")
158 inst.components.tool:SetAction(ACTIONS.CHOP, 15)
159 inst:AddTag("bigaxes")
160 end
161end
162 inst.OnSave = onsave
163 inst.OnLoad = onload
164
165 即可用蜻蜓鳞片种霸王斧,装备霸王斧攻击时,自动会吸取敌人的血,补充主角生命值,同时震开并伤害周围的敌人(区域攻击),减少你被围殴的机会。霸王斧用来砍树也极其锋利,一斧便可砍倒一棵。蜻蜓鳞片靠打蜻蜓获得,也可在“巨型超市”花9-11个黄金购得