代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2二六八.喷气虫座骑(用夏日背心种喷气虫座骑,左键点虫可骑乘,右键点主角可下来,给草让它原地等待)
3
4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/trunkvest.lua文件,在inst.AnimState:SetBuild("armor_trunkvest_summer")的下一行插入以下内容:
5
6local function OnDeploy (inst, pt)
7 local jet = SpawnPrefab("trunkvest_summer")
8 jet.Transform:SetPosition(pt.x, pt.y, pt.z)
9 jet.AnimState:SetBank("glommer")
10 jet.AnimState:SetBuild("glommer")
11 jet.AnimState:PlayAnimation("idle_loop")
12 jet.Transform:SetFourFaced()
13 jet.entity:AddSoundEmitter()
14 local shadow = jet.entity:AddDynamicShadow()
15 shadow:SetSize( 2, .75 )
16 local minimap = jet.entity:AddMiniMapEntity()
17 minimap:SetIcon("glommer.png")
18 jet:AddComponent("named")
19 jet.components.named:SetName("Glommer")
20 jet:RemoveComponent("inventoryitem")
21 jet:RemoveComponent("equippable")
22 jet:RemoveComponent("insulator")
23 jet:RemoveComponent("fueled")
24 jet:RemoveComponent("waterproofer")
25 jet:RemoveComponent("deployable")
26 jet:AddComponent("knownlocations")
27 jet:AddComponent("follower")
28 jet.components.follower:SetLeader(GetPlayer())
29 jet:AddComponent("lootdropper")
30 jet:AddComponent("health")
31 jet.components.health:SetMaxHealth(2000)
32 jet:AddComponent("combat")
33 jet:AddComponent("locomotor")
34 jet.components.locomotor.walkspeed = 15
35 jet:SetStateGraph("SGglommer")
36 local brain = require "brains/chesterbrain"
37 jet:SetBrain(brain)
38 jet:AddComponent("trader")
39 jet.components.trader:SetAcceptTest(function(jet, item)
40 if not jet:HasTag("driving") then
41 if item.prefab == "cutgrass" then
42 return true
43 end
44 end
45 return false
46 end )
47 jet.components.trader.onaccept = function(jet, giver, item)
48 jet.components.health:DoDelta(2000)
49 if not jet:HasTag("stophere") then
50 jet:AddTag("stophere")
51 jet.components.locomotor:Stop()
52 jet:SetBrain(nil)
53 jet.components.follower:SetLeader(nil)
54 else
55 jet:RemoveTag("stophere")
56 local brain = require "brains/chesterbrain"
57 jet:SetBrain(brain)
58 jet:RestartBrain()
59 jet.components.follower:SetLeader(GetPlayer())
60 end
61 end
62 jet.components.inspectable.getstatus = function()
63 if not jet:HasTag("driving") then
64 jet:AddTag("driving")
65 jet:RemoveTag("stophere")
66 jet.components.locomotor:Stop()
67 local shadow = jet.entity:AddDynamicShadow()
68 shadow:SetSize( 0, 0 )
69 jet.Physics:SetActive(false)
70 jet:SetStateGraph("SGshadowwaxwell")
71 jet:SetBrain(nil)
72 jet.components.follower:SetLeader(nil)
73 jet.AnimState:SetBank("wilson")
74 if GetPlayer().prefab == "wilson" then jet.AnimState:SetBuild("wilson") end
75 if GetPlayer().prefab == "wendy" then jet.AnimState:SetBuild("wendy") end
76 if GetPlayer().prefab == "wes" then jet.AnimState:SetBuild("wes") end
77 if GetPlayer().prefab == "wickerbottom" then jet.AnimState:SetBuild("wickerbottom") end
78 if GetPlayer().prefab == "willow" then jet.AnimState:SetBuild("willow") end
79 if GetPlayer().prefab == "wolfgang" then jet.AnimState:SetBuild("wolfgang") end
80 if GetPlayer().prefab == "wx78" then jet.AnimState:SetBuild("wx78") end
81 if GetPlayer().prefab == "woodie" then jet.AnimState:SetBuild("woodie") end
82 if GetPlayer().prefab == "waxwell" then jet.AnimState:SetBuild("waxwell") end
83 if GetPlayer().prefab == "wathgrithr" then jet.AnimState:SetBuild("wathgrithr") end
84 if GetPlayer().prefab == "webber" then jet.AnimState:SetBuild("webber") end
85 jet.AnimState:PlayAnimation("idle")
86 jet.AnimState:Hide("ARM_carry")
87 jet.AnimState:Show("ARM_normal")
88 jet.Transform:SetRotation( 0 )
89 jet.task = jet:DoPeriodicTask(0.05, function(jet)
90 local pt1 = GetPlayer():GetPosition()
91 jet.Transform:SetPosition(pt1.x, 3.5, pt1.z)
92 jet.Transform:SetRotation(GetPlayer().Transform:GetRotation())
93 end )
94 GetPlayer().AnimState:SetBank("glommer")
95 GetPlayer().AnimState:SetBuild("glommer")
96 GetPlayer().AnimState:PlayAnimation("idle_loop")
97 GetPlayer():SetStateGraph("SGglommer")
98 local shadow = GetPlayer().entity:AddDynamicShadow()
99 shadow:SetSize( 2, .75 )
100 GetPlayer().components.locomotor.walkspeed = 25
101 GetPlayer().components.locomotor.runspeed = 25
102 GetPlayer().components.health:SetInvincible(true)
103 GetPlayer().components.hunger:Pause()
104 GetPlayer().components.temperature:SetTemp(20)
105 GetPlayer().components.playeractionpicker.leftclickoverride = function(target_ent, pos)
106 if GetPlayer().components.combat:CanTarget(target_ent) then
107 return GetPlayer().components.playeractionpicker:SortActionList({ACTIONS.LOOKAT}, target_ent, nil)
108 end
109 end
110 else
111 jet:RemoveTag("driving")
112 local shadow = jet.entity:AddDynamicShadow()
113 shadow:SetSize( 2, .75 )
114 jet.Physics:SetActive(true)
115 jet.AnimState:SetBank("glommer")
116 jet.AnimState:SetBuild("glommer")
117 jet.AnimState:PlayAnimation("idle_loop")
118 jet:SetStateGraph("SGglommer")
119 local brain = require "brains/chesterbrain"
120 jet:SetBrain(brain)
121 jet:RestartBrain()
122 jet.components.follower:SetLeader(GetPlayer())
123 if jet.task then jet.task:Cancel() jet.task = nil end
124 local pt1 = GetPlayer():GetPosition()
125 jet.Transform:SetPosition(pt1.x, 0, pt1.z)
126 GetPlayer().AnimState:SetBank("wilson")
127 if GetPlayer().prefab == "wilson" then GetPlayer().AnimState:SetBuild("wilson") end
128 if GetPlayer().prefab == "wendy" then GetPlayer().AnimState:SetBuild("wendy") end
129 if GetPlayer().prefab == "wes" then GetPlayer().AnimState:SetBuild("wes") end
130 if GetPlayer().prefab == "wickerbottom" then GetPlayer().AnimState:SetBuild("wickerbottom") end
131 if GetPlayer().prefab == "willow" then GetPlayer().AnimState:SetBuild("willow") end
132 if GetPlayer().prefab == "wolfgang" then GetPlayer().AnimState:SetBuild("wolfgang") end
133 if GetPlayer().prefab == "wx78" then GetPlayer().AnimState:SetBuild("wx78") end
134 if GetPlayer().prefab == "woodie" then GetPlayer().AnimState:SetBuild("woodie") end
135 if GetPlayer().prefab == "waxwell" then GetPlayer().AnimState:SetBuild("waxwell") end
136 if GetPlayer().prefab == "wathgrithr" then GetPlayer().AnimState:SetBuild("wathgrithr") end
137 if GetPlayer().prefab == "webber" then GetPlayer().AnimState:SetBuild("webber") end
138 GetPlayer().AnimState:PlayAnimation("idle")
139 GetPlayer():SetStateGraph("SGwilson")
140 local shadow = GetPlayer().entity:AddDynamicShadow()
141 shadow:SetSize( 1.3, .6 )
142 GetPlayer().components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED
143 GetPlayer().components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED
144 GetPlayer().components.health:SetInvincible(false)
145 GetPlayer().components.hunger:Resume()
146 GetPlayer().components.temperature:SetTemp(nil)
147 GetPlayer().components.playeractionpicker.leftclickoverride = nil
148 end
149 end
150 jet:AddTag("jets")
151 inst:Remove()
152end
153 inst:AddComponent("deployable")
154 inst.components.deployable.ondeploy = OnDeploy
155local function onsave(inst, data)
156 if inst:HasTag("jets") then
157 data.jets = true
158 end
159 if inst:HasTag("stophere") then
160 data.stophere = true
161 end
162end
163local function onload(inst, data)
164 if data and data.jets then
165 inst.AnimState:SetBank("glommer")
166 inst.AnimState:SetBuild("glommer")
167 inst.AnimState:PlayAnimation("idle_loop")
168 inst.Transform:SetFourFaced()
169 inst.entity:AddSoundEmitter()
170 local shadow = inst.entity:AddDynamicShadow()
171 shadow:SetSize( 2, .75 )
172 local minimap = inst.entity:AddMiniMapEntity()
173 minimap:SetIcon("glommer.png")
174 inst:AddComponent("named")
175 inst.components.named:SetName("Glommer")
176 inst:RemoveComponent("inventoryitem")
177 inst:RemoveComponent("equippable")
178 inst:RemoveComponent("insulator")
179 inst:RemoveComponent("fueled")
180 inst:RemoveComponent("waterproofer")
181 inst:RemoveComponent("deployable")
182 inst:AddComponent("knownlocations")
183 inst:AddComponent("follower")
184 inst.components.follower:SetLeader(GetPlayer())
185 inst:AddComponent("lootdropper")
186 inst:AddComponent("health")
187 inst.components.health:SetMaxHealth(2000)
188 inst:AddComponent("combat")
189 inst:AddComponent("locomotor")
190 inst.components.locomotor.walkspeed = 15
191 inst:SetStateGraph("SGglommer")
192 local brain = require "brains/chesterbrain"
193 inst:SetBrain(brain)
194 inst:AddComponent("trader")
195 inst.components.trader:SetAcceptTest(function(inst, item)
196 if not inst:HasTag("driving") then
197 if item.prefab == "cutgrass" then
198 return true
199 end
200 end
201 return false
202 end )
203 inst.components.trader.onaccept = function(inst, giver, item)
204 inst.components.health:DoDelta(2000)
205 if not inst:HasTag("stophere") then
206 inst:AddTag("stophere")
207 inst.components.locomotor:Stop()
208 inst:SetBrain(nil)
209 inst.components.follower:SetLeader(nil)
210 else
211 inst:RemoveTag("stophere")
212 local brain = require "brains/chesterbrain"
213 inst:SetBrain(brain)
214 inst:RestartBrain()
215 inst.components.follower:SetLeader(GetPlayer())
216 end
217 end
218 inst.components.inspectable.getstatus = function()
219 if not inst:HasTag("driving") then
220 inst:AddTag("driving")
221 inst:RemoveTag("stophere")
222 inst.components.locomotor:Stop()
223 local shadow = inst.entity:AddDynamicShadow()
224 shadow:SetSize( 0, 0 )
225 inst.Physics:SetActive(false)
226 inst:SetStateGraph("SGshadowwaxwell")
227 inst:SetBrain(nil)
228 inst.components.follower:SetLeader(nil)
229 inst.AnimState:SetBank("wilson")
230 if GetPlayer().prefab == "wilson" then inst.AnimState:SetBuild("wilson") end
231 if GetPlayer().prefab == "wendy" then inst.AnimState:SetBuild("wendy") end
232 if GetPlayer().prefab == "wes" then inst.AnimState:SetBuild("wes") end
233 if GetPlayer().prefab == "wickerbottom" then inst.AnimState:SetBuild("wickerbottom") end
234 if GetPlayer().prefab == "willow" then inst.AnimState:SetBuild("willow") end
235 if GetPlayer().prefab == "wolfgang" then inst.AnimState:SetBuild("wolfgang") end
236 if GetPlayer().prefab == "wx78" then inst.AnimState:SetBuild("wx78") end
237 if GetPlayer().prefab == "woodie" then inst.AnimState:SetBuild("woodie") end
238 if GetPlayer().prefab == "waxwell" then inst.AnimState:SetBuild("waxwell") end
239 if GetPlayer().prefab == "wathgrithr" then inst.AnimState:SetBuild("wathgrithr") end
240 if GetPlayer().prefab == "webber" then inst.AnimState:SetBuild("webber") end
241 inst.AnimState:PlayAnimation("idle")
242 inst.AnimState:Hide("ARM_carry")
243 inst.AnimState:Show("ARM_normal")
244 inst.Transform:SetRotation( 0 )
245 inst.task = inst:DoPeriodicTask(0.05, function(inst)
246 local pt1 = GetPlayer():GetPosition()
247 inst.Transform:SetPosition(pt1.x, 3.5, pt1.z)
248 inst.Transform:SetRotation(GetPlayer().Transform:GetRotation())
249 end )
250 GetPlayer().AnimState:SetBank("glommer")
251 GetPlayer().AnimState:SetBuild("glommer")
252 GetPlayer().AnimState:PlayAnimation("idle_loop")
253 GetPlayer():SetStateGraph("SGglommer")
254 local shadow = GetPlayer().entity:AddDynamicShadow()
255 shadow:SetSize( 2, .75 )
256 GetPlayer().components.locomotor.walkspeed = 25
257 GetPlayer().components.locomotor.runspeed = 25
258 GetPlayer().components.health:SetInvincible(true)
259 GetPlayer().components.hunger:Pause()
260 GetPlayer().components.temperature:SetTemp(20)
261 GetPlayer().components.playeractionpicker.leftclickoverride = function(target_ent, pos)
262 if GetPlayer().components.combat:CanTarget(target_ent) then
263 return GetPlayer().components.playeractionpicker:SortActionList({ACTIONS.LOOKAT}, target_ent, nil)
264 end
265 end
266 else
267 inst:RemoveTag("driving")
268 local shadow = inst.entity:AddDynamicShadow()
269 shadow:SetSize( 2, .75 )
270 inst.Physics:SetActive(true)
271 inst.AnimState:SetBank("glommer")
272 inst.AnimState:SetBuild("glommer")
273 inst.AnimState:PlayAnimation("idle_loop")
274 inst:SetStateGraph("SGglommer")
275 local brain = require "brains/chesterbrain"
276 inst:SetBrain(brain)
277 inst:RestartBrain()
278 inst.components.follower:SetLeader(GetPlayer())
279 if inst.task then inst.task:Cancel() inst.task = nil end
280 local pt1 = GetPlayer():GetPosition()
281 inst.Transform:SetPosition(pt1.x, 0, pt1.z)
282 GetPlayer().AnimState:SetBank("wilson")
283 if GetPlayer().prefab == "wilson" then GetPlayer().AnimState:SetBuild("wilson") end
284 if GetPlayer().prefab == "wendy" then GetPlayer().AnimState:SetBuild("wendy") end
285 if GetPlayer().prefab == "wes" then GetPlayer().AnimState:SetBuild("wes") end
286 if GetPlayer().prefab == "wickerbottom" then GetPlayer().AnimState:SetBuild("wickerbottom") end
287 if GetPlayer().prefab == "willow" then GetPlayer().AnimState:SetBuild("willow") end
288 if GetPlayer().prefab == "wolfgang" then GetPlayer().AnimState:SetBuild("wolfgang") end
289 if GetPlayer().prefab == "wx78" then GetPlayer().AnimState:SetBuild("wx78") end
290 if GetPlayer().prefab == "woodie" then GetPlayer().AnimState:SetBuild("woodie") end
291 if GetPlayer().prefab == "waxwell" then GetPlayer().AnimState:SetBuild("waxwell") end
292 if GetPlayer().prefab == "wathgrithr" then GetPlayer().AnimState:SetBuild("wathgrithr") end
293 if GetPlayer().prefab == "webber" then GetPlayer().AnimState:SetBuild("webber") end
294 GetPlayer().AnimState:PlayAnimation("idle")
295 GetPlayer():SetStateGraph("SGwilson")
296 local shadow = GetPlayer().entity:AddDynamicShadow()
297 shadow:SetSize( 1.3, .6 )
298 GetPlayer().components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED
299 GetPlayer().components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED
300 GetPlayer().components.health:SetInvincible(false)
301 GetPlayer().components.hunger:Resume()
302 GetPlayer().components.temperature:SetTemp(nil)
303 GetPlayer().components.playeractionpicker.leftclickoverride = nil
304 end
305 end
306 inst:AddTag("jets")
307 end
308 if data and data.stophere then
309 inst.components.locomotor:Stop()
310 inst:SetBrain(nil)
311 inst.components.follower:SetLeader(nil)
312 inst:AddTag("stophere")
313 end
314end
315 inst.OnSave = onsave
316 inst.OnLoad = onload
317
318 即可用夏日背心种喷气虫座骑,对喷气虫点鼠标左键(手里不要拿武器)可骑乘,对主角按鼠标右键可下来。骑着喷气虫时无法战斗,但遭到攻击时不会受伤(敌人够不到你)。喷气虫会跟随你,喂它一根草(拿着草对它点鼠标左键)可让其停在原地,并同时补血,再给一根草可继续跟随。喷气虫座骑在小地图上显示为格罗门图标,不想要喷气虫座骑了,杀掉即可(按Ctrl + 鼠标左键攻击)。夏日背心在穿戴选项(画着帽子)下,用1个红色象鼻、8个蛛丝制造