代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2二九五.雇佣兵工厂(用大理石盔甲种兵工厂,打工赚黄金,购买机械雇佣兵)
3
4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/rook.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
5
6local function onsave(inst, data)
7 if inst:HasTag("retinue") then
8 data.retinue = true
9 end
10 if inst:HasTag("highretinue") then
11 data.highretinue = true
12 end
13 if inst:HasTag("letgo") then
14 data.letgo = true
15 end
16end
17local function onload(inst, data)
18 if data and data.retinue then
19 inst.components.health:SetMaxHealth(1000)
20 inst.components.combat:SetDefaultDamage(100)
21 inst:RemoveTag("monster")
22 inst:AddTag("retinue")
23 local minimap = inst.entity:AddMiniMapEntity()
24 minimap:SetIcon( "chessjunk.png" )
25 inst.components.locomotor:Stop()
26 inst:SetBrain(nil)
27 inst.components.follower:SetLeader(nil)
28 inst.components.inspectable.getstatus = function(inst)
29 if not inst:HasTag("letgo") then
30 local brain = require "brains/rookbrain"
31 inst:SetBrain(brain)
32 inst:RestartBrain()
33 inst.components.follower:SetLeader(GetPlayer())
34 inst:AddTag("letgo")
35 else
36 inst.components.locomotor:Stop()
37 inst:SetBrain(nil)
38 inst.components.follower:SetLeader(nil)
39 inst:RemoveTag("letgo")
40 end
41 end
42 inst:AddComponent("trader")
43 inst.components.trader:SetAcceptTest(function(inst, item)
44 if GetPlayer().components.inventory:Has("goldnugget", 50) then
45 if item.prefab == "goldnugget" then
46 return true
47 end
48 end
49 return false
50 end )
51 inst.components.trader.onaccept = function(inst, giver, item)
52 GetPlayer().components.inventory:ConsumeByName("goldnugget", 49)
53 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
54 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
55 inst.components.health:SetMaxHealth(2000)
56 inst.components.health:DoDelta(2000)
57 inst.components.combat:SetDefaultDamage(200)
58 inst:AddTag("highretinue")
59 inst.components.locomotor.walkspeed = 15
60 inst.components.locomotor.runspeed = 20
61 end
62 inst.Physics:SetCollisionCallback(function(inst, other)
63 if other and other.components.workable and other.components.workable.workleft > 0 then
64 SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
65 other.components.workable:Destroy(inst)
66 end
67 end)
68 inst.components.locomotor.walkspeed = 10
69 inst.components.locomotor.runspeed = 15
70 inst.components.combat:SetAttackPeriod( 1 )
71 inst.components.combat:SetRetargetFunction(3, function(inst)
72 if not inst.components.health:IsDead() then
73 return FindEntity(inst, 20, function(guy)
74 if guy.components.health and not guy.components.health:IsDead() then
75 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
76 end
77 end)
78 end
79 end )
80 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end )
81 if data and data.highretinue then
82 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
83 inst.components.health:SetMaxHealth(2000)
84 inst.components.combat:SetDefaultDamage(200)
85 inst:AddTag("highretinue")
86 inst.components.locomotor.walkspeed = 15
87 inst.components.locomotor.runspeed = 20
88 end
89 if data and data.letgo then
90 local brain = require "brains/rookbrain"
91 inst:SetBrain(brain)
92 inst:RestartBrain()
93 inst.components.follower:SetLeader(GetPlayer())
94 inst:AddTag("letgo")
95 end
96 end
97end
98 inst.OnSave = onsave
99 inst.OnLoad = onload
100
101
102 2.用MT管理器打开游戏目录/assets/scripts/prefabs/bishop.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
103
104local function onsave(inst, data)
105 if inst:HasTag("retinue") then
106 data.retinue = true
107 end
108 if inst:HasTag("highretinue") then
109 data.highretinue = true
110 end
111 if inst:HasTag("letgo") then
112 data.letgo = true
113 end
114end
115local function onload(inst, data)
116 if data and data.retinue then
117 inst.components.health:SetMaxHealth(500)
118 inst.components.combat:SetDefaultDamage(30)
119 inst:RemoveTag("monster")
120 inst:AddTag("retinue")
121 local minimap = inst.entity:AddMiniMapEntity()
122 minimap:SetIcon( "chessjunk.png" )
123 inst.components.locomotor:Stop()
124 inst:SetBrain(nil)
125 inst.components.follower:SetLeader(nil)
126 inst.components.inspectable.getstatus = function(inst)
127 if not inst:HasTag("letgo") then
128 local brain = require "brains/rookbrain"
129 inst:SetBrain(brain)
130 inst:RestartBrain()
131 inst.components.follower:SetLeader(GetPlayer())
132 inst:AddTag("letgo")
133 else
134 inst.components.locomotor:Stop()
135 inst:SetBrain(nil)
136 inst.components.follower:SetLeader(nil)
137 inst:RemoveTag("letgo")
138 end
139 end
140 inst:AddComponent("trader")
141 inst.components.trader:SetAcceptTest(function(inst, item)
142 if GetPlayer().components.inventory:Has("goldnugget", 30) then
143 if item.prefab == "goldnugget" then
144 return true
145 end
146 end
147 return false
148 end )
149 inst.components.trader.onaccept = function(inst, giver, item)
150 GetPlayer().components.inventory:ConsumeByName("goldnugget", 29)
151 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
152 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
153 inst.components.health:SetMaxHealth(1000)
154 inst.components.health:DoDelta(1000)
155 inst.components.combat:SetDefaultDamage(60)
156 inst:AddTag("highretinue")
157 inst.components.locomotor.walkspeed = 15
158 end
159 inst.components.locomotor.walkspeed = 10
160 inst.components.combat:SetAttackPeriod( 0.5 )
161 inst.components.combat:SetRetargetFunction(3, function(inst)
162 if not inst.components.health:IsDead() then
163 return FindEntity(inst, 20, function(guy)
164 if guy.components.health and not guy.components.health:IsDead() then
165 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
166 end
167 end)
168 end
169 end )
170 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end )
171 if data and data.highretinue then
172 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
173 inst.components.health:SetMaxHealth(1000)
174 inst.components.combat:SetDefaultDamage(60)
175 inst:AddTag("highretinue")
176 inst.components.locomotor.walkspeed = 15
177 end
178 if data and data.letgo then
179 local brain = require "brains/rookbrain"
180 inst:SetBrain(brain)
181 inst:RestartBrain()
182 inst.components.follower:SetLeader(GetPlayer())
183 inst:AddTag("letgo")
184 end
185 end
186end
187 inst.OnSave = onsave
188 inst.OnLoad = onload
189
190
191 3.用MT管理器打开游戏目录/assets/scripts/prefabs/knight.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
192
193local function onsave(inst, data)
194 if inst:HasTag("retinue") then
195 data.retinue = true
196 end
197 if inst:HasTag("highretinue") then
198 data.highretinue = true
199 end
200 if inst:HasTag("letgo") then
201 data.letgo = true
202 end
203end
204local function onload(inst, data)
205 if data and data.retinue then
206 inst.components.health:SetMaxHealth(500)
207 inst.components.combat:SetDefaultDamage(15)
208 inst:RemoveTag("monster")
209 inst:AddTag("retinue")
210 local minimap = inst.entity:AddMiniMapEntity()
211 minimap:SetIcon( "chessjunk.png" )
212 inst.components.locomotor:Stop()
213 inst:SetBrain(nil)
214 inst.components.follower:SetLeader(nil)
215 inst.components.inspectable.getstatus = function(inst)
216 if not inst:HasTag("letgo") then
217 local brain = require "brains/rookbrain"
218 inst:SetBrain(brain)
219 inst:RestartBrain()
220 inst.components.follower:SetLeader(GetPlayer())
221 inst:AddTag("letgo")
222 else
223 inst.components.locomotor:Stop()
224 inst:SetBrain(nil)
225 inst.components.follower:SetLeader(nil)
226 inst:RemoveTag("letgo")
227 end
228 end
229 inst:AddComponent("trader")
230 inst.components.trader:SetAcceptTest(function(inst, item)
231 if GetPlayer().components.inventory:Has("goldnugget", 15) then
232 if item.prefab == "goldnugget" then
233 return true
234 end
235 end
236 return false
237 end )
238 inst.components.trader.onaccept = function(inst, giver, item)
239 GetPlayer().components.inventory:ConsumeByName("goldnugget", 14)
240 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
241 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
242 inst.components.health:SetMaxHealth(1000)
243 inst.components.health:DoDelta(1000)
244 inst.components.combat:SetDefaultDamage(30)
245 inst:AddTag("highretinue")
246 inst.components.locomotor.walkspeed = 15
247 end
248 inst.components.locomotor.walkspeed = 10
249 inst.components.combat:SetAttackPeriod( 0.5 )
250 inst.components.combat:SetRetargetFunction(3, function(inst)
251 if not inst.components.health:IsDead() then
252 return FindEntity(inst, 20, function(guy)
253 if guy.components.health and not guy.components.health:IsDead() then
254 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
255 end
256 end)
257 end
258 end )
259 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end )
260 if data and data.highretinue then
261 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
262 inst.components.health:SetMaxHealth(1000)
263 inst.components.combat:SetDefaultDamage(30)
264 inst:AddTag("highretinue")
265 inst.components.locomotor.walkspeed = 15
266 end
267 if data and data.letgo then
268 local brain = require "brains/rookbrain"
269 inst:SetBrain(brain)
270 inst:RestartBrain()
271 inst.components.follower:SetLeader(GetPlayer())
272 inst:AddTag("letgo")
273 end
274 end
275end
276 inst.OnSave = onsave
277 inst.OnLoad = onload
278
279
280 4.用MT管理器打开游戏目录/assets/scripts/prefabs/armor_marble.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
281
282local function repairshop(inst)
283 local pt = inst:GetPosition()
284 local repairboss = SpawnPrefab("armormarble")
285 repairboss.Transform:SetPosition(pt.x, pt.y, pt.z)
286 repairboss.AnimState:SetBank("wilson")
287 repairboss.AnimState:SetBuild("wx78")
288 repairboss.AnimState:OverrideSymbol("swap_hat", "hat_top", "swap_hat")
289 repairboss.AnimState:Show("HAT")
290 repairboss.AnimState:Show("HAT_HAIR")
291 repairboss.AnimState:Hide("HAIR_NOHAT")
292 repairboss.AnimState:Hide("HAIR")
293 repairboss.AnimState:OverrideSymbol("swap_body", "armor_marble", "swap_body")
294 repairboss.AnimState:OverrideSymbol("swap_object", "swap_hammer", "swap_hammer")
295 repairboss.AnimState:Show("ARM_carry")
296 repairboss.AnimState:Hide("ARM_normal")
297 repairboss.Transform:SetFourFaced()
298 repairboss.AnimState:PlayAnimation("idle")
299 repairboss:AddTag("repairboss")
300 repairboss.components.inventoryitem.canbepickedup = false
301 local light = repairboss.entity:AddLight()
302 light:SetFalloff(1)
303 light:SetIntensity(.8)
304 light:SetRadius(10)
305 light:SetColour(180/255, 195/255, 50/255)
306 light:Enable(true)
307 repairboss:AddComponent("trader")
308 repairboss.components.trader:SetAcceptTest(function(repairboss, item)
309 if item.prefab == "goldnugget" then
310 return true
311 end
312 return false
313 end )
314 repairboss.components.trader.onaccept = function(repairboss, giver, item)
315 repairboss.AnimState:PlayAnimation("give")
316 SpawnPrefab("hammer").Transform:SetPosition(pt.x+0.5, 0, pt.z+0.5)
317 end
318 repairboss.components.inspectable.getstatus = function(repairboss)
319 repairboss.AnimState:PlayAnimation("give")
320 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_stone")
321 local chessjunk = SpawnPrefab("armormarble")
322 chessjunk.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1)
323 chessjunk.AnimState:SetBank("chessmonster_ruins")
324 chessjunk.AnimState:SetBuild("chessmonster_ruins")
325 chessjunk.AnimState:PlayAnimation("idle3")
326 chessjunk:AddTag("goodbye")
327 chessjunk.components.inventoryitem.canbepickedup = false
328 chessjunk:AddComponent("workable")
329 chessjunk.components.workable:SetWorkAction(ACTIONS.HAMMER)
330 chessjunk.components.workable:SetWorkLeft(30)
331 chessjunk.components.workable:SetOnWorkCallback(function(chessjunk, worker, workleft)
332 if chessjunk.components.workable.workleft <= 0 then
333 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/chessjunk_break")
334 chessjunk:Remove()
335 local goods = SpawnPrefab("armormarble")
336 goods.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1)
337 goods:AddTag("goodbye")
338 goods.components.inventoryitem.canbepickedup = false
339 if math.random()<.33 then
340 goods.AnimState:SetBank("rook")
341 goods.AnimState:SetBuild("rook_nightmare")
342 goods.AnimState:PlayAnimation("idle")
343 goods.Transform:SetScale(0.66, 0.66, 0.66)
344 elseif math.random()<.66 then
345 goods.AnimState:SetBank("bishop")
346 goods.AnimState:SetBuild("bishop_nightmare")
347 goods.AnimState:PlayAnimation("idle_loop", true)
348 else
349 goods.AnimState:SetBank("knight")
350 goods.AnimState:SetBuild("knight_nightmare")
351 goods.AnimState:PlayAnimation("idle_loop", true)
352 end
353 GetPlayer():DoTaskInTime(2, function()
354 repairboss.AnimState:PlayAnimation("give")
355 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold")
356 for k = 1, 3 do
357 SpawnPrefab("goldnugget").Transform:SetPosition(pt.x+0.5, 0, pt.z-0.5)
358 end
359 goods:Remove()
360 end )
361 else
362 if chessjunk.components.workable.workleft < 10 then
363 chessjunk.AnimState:PlayAnimation("idle1")
364 elseif chessjunk.components.workable.workleft < 20 then
365 chessjunk.AnimState:PlayAnimation("idle2")
366 else
367 chessjunk.AnimState:PlayAnimation("idle3")
368 end
369 end
370 end)
371 end
372 local chessjunk1 = SpawnPrefab("armormarble")
373 chessjunk1.Transform:SetPosition(pt.x-3, 0, pt.z-3)
374 chessjunk1.AnimState:SetBank("rook")
375 chessjunk1.AnimState:SetBuild("rook_nightmare")
376 chessjunk1.Transform:SetFourFaced()
377 chessjunk1.AnimState:PlayAnimation("idle")
378 chessjunk1.Transform:SetScale(0.66, 0.66, 0.66)
379 chessjunk1:AddTag("goodbye")
380 chessjunk1.components.inventoryitem.canbepickedup = false
381 chessjunk1:AddComponent("trader")
382 chessjunk1.components.trader:SetAcceptTest(function(chessjunk1, item)
383 if GetPlayer().components.inventory:Has("goldnugget", 50) then
384 if item.prefab == "goldnugget" then
385 return true
386 end
387 end
388 return false
389 end )
390 chessjunk1.components.trader.onaccept = function(chessjunk1, giver, item)
391 GetPlayer().components.inventory:ConsumeByName("goldnugget", 49)
392 repairboss.AnimState:PlayAnimation("give")
393 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available")
394 local retinue1 = SpawnPrefab("rook_nightmare")
395 retinue1.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1)
396 retinue1.components.follower:SetLeader(GetPlayer())
397 retinue1.components.health:SetMaxHealth(1000)
398 retinue1.components.combat:SetDefaultDamage(100)
399 retinue1:RemoveTag("monster")
400 retinue1:AddTag("retinue")
401 retinue1:AddTag("letgo")
402 local minimap = retinue1.entity:AddMiniMapEntity()
403 minimap:SetIcon( "chessjunk.png" )
404 retinue1.components.inspectable.getstatus = function(retinue1)
405 if not retinue1:HasTag("letgo") then
406 local brain = require "brains/rookbrain"
407 retinue1:SetBrain(brain)
408 retinue1:RestartBrain()
409 retinue1.components.follower:SetLeader(GetPlayer())
410 retinue1:AddTag("letgo")
411 else
412 retinue1.components.locomotor:Stop()
413 retinue1.components.follower:SetLeader(nil)
414 retinue1:SetBrain(nil)
415 retinue1:RemoveTag("letgo")
416 end
417 end
418 retinue1:AddComponent("trader")
419 retinue1.components.trader:SetAcceptTest(function(retinue1, item)
420 if GetPlayer().components.inventory:Has("goldnugget", 50) then
421 if item.prefab == "goldnugget" then
422 return true
423 end
424 end
425 return false
426 end )
427 retinue1.components.trader.onaccept = function(retinue1, giver, item)
428 GetPlayer().components.inventory:ConsumeByName("goldnugget", 49)
429 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
430 retinue1.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
431 retinue1.components.health:SetMaxHealth(2000)
432 retinue1.components.health:DoDelta(2000)
433 retinue1.components.combat:SetDefaultDamage(200)
434 retinue1:AddTag("highretinue")
435 retinue1.components.locomotor.walkspeed = 15
436 retinue1.components.locomotor.runspeed = 20
437 end
438 retinue1.Physics:SetCollisionCallback(function(retinue1, other)
439 if other and other.components.workable and other.components.workable.workleft > 0 then
440 SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
441 other.components.workable:Destroy(retinue1)
442 end
443 end)
444 retinue1.components.locomotor.walkspeed = 10
445 retinue1.components.locomotor.runspeed = 15
446 retinue1.components.combat:SetAttackPeriod( 1 )
447 retinue1.components.combat:SetRetargetFunction(3, function(retinue1)
448 if not retinue1.components.health:IsDead() then
449 return FindEntity(retinue1, 20, function(guy)
450 if guy.components.health and not guy.components.health:IsDead() then
451 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
452 end
453 end)
454 end
455 end )
456 retinue1.components.combat:SetKeepTargetFunction(function(retinue1, target) return target and target:IsValid() end )
457 end
458 local chessjunk2 = SpawnPrefab("armormarble")
459 chessjunk2.Transform:SetPosition(pt.x-3+2.3, 0, pt.z-3-2.3)
460 chessjunk2.AnimState:SetBank("bishop")
461 chessjunk2.AnimState:SetBuild("bishop_nightmare")
462 chessjunk2.Transform:SetFourFaced()
463 chessjunk2.AnimState:PlayAnimation("idle_loop", true)
464 chessjunk2:AddTag("goodbye")
465 chessjunk2.components.inventoryitem.canbepickedup = false
466 chessjunk2:AddComponent("trader")
467 chessjunk2.components.trader:SetAcceptTest(function(chessjunk2, item)
468 if GetPlayer().components.inventory:Has("goldnugget", 30) then
469 if item.prefab == "goldnugget" then
470 return true
471 end
472 end
473 return false
474 end )
475 chessjunk2.components.trader.onaccept = function(chessjunk2, giver, item)
476 GetPlayer().components.inventory:ConsumeByName("goldnugget", 29)
477 repairboss.AnimState:PlayAnimation("give")
478 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available")
479 local retinue2 = SpawnPrefab("bishop_nightmare")
480 retinue2.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1)
481 retinue2.components.follower:SetLeader(GetPlayer())
482 retinue2.components.health:SetMaxHealth(500)
483 retinue2.components.combat:SetDefaultDamage(30)
484 retinue2:RemoveTag("monster")
485 retinue2:AddTag("retinue")
486 retinue2:AddTag("letgo")
487 local minimap = retinue2.entity:AddMiniMapEntity()
488 minimap:SetIcon( "chessjunk.png" )
489 retinue2.components.inspectable.getstatus = function(retinue2)
490 if not retinue2:HasTag("letgo") then
491 local brain = require "brains/rookbrain"
492 retinue2:SetBrain(brain)
493 retinue2:RestartBrain()
494 retinue2.components.follower:SetLeader(GetPlayer())
495 retinue2:AddTag("letgo")
496 else
497 retinue2.components.locomotor:Stop()
498 retinue2.components.follower:SetLeader(nil)
499 retinue2:SetBrain(nil)
500 retinue2:RemoveTag("letgo")
501 end
502 end
503 retinue2:AddComponent("trader")
504 retinue2.components.trader:SetAcceptTest(function(retinue2, item)
505 if GetPlayer().components.inventory:Has("goldnugget", 30) then
506 if item.prefab == "goldnugget" then
507 return true
508 end
509 end
510 return false
511 end )
512 retinue2.components.trader.onaccept = function(retinue2, giver, item)
513 GetPlayer().components.inventory:ConsumeByName("goldnugget", 29)
514 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
515 retinue2.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
516 retinue2.components.health:SetMaxHealth(1000)
517 retinue2.components.health:DoDelta(1000)
518 retinue2.components.combat:SetDefaultDamage(60)
519 retinue2:AddTag("highretinue")
520 retinue2.components.locomotor.walkspeed = 15
521 end
522 retinue2.components.locomotor.walkspeed = 10
523 retinue2.components.combat:SetAttackPeriod( 0.5 )
524 retinue2.components.combat:SetRetargetFunction(3, function(retinue2)
525 if not retinue2.components.health:IsDead() then
526 return FindEntity(retinue2, 20, function(guy)
527 if guy.components.health and not guy.components.health:IsDead() then
528 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
529 end
530 end)
531 end
532 end )
533 retinue2.components.combat:SetKeepTargetFunction(function(retinue2, target) return target and target:IsValid() end )
534 end
535 local chessjunk3 = SpawnPrefab("armormarble")
536 chessjunk3.Transform:SetPosition(pt.x-3-2, 0, pt.z-3+2)
537 chessjunk3.AnimState:SetBank("knight")
538 chessjunk3.AnimState:SetBuild("knight_nightmare")
539 chessjunk3.Transform:SetFourFaced()
540 chessjunk3.AnimState:PlayAnimation("idle_loop", true)
541 chessjunk3:AddTag("goodbye")
542 chessjunk3.components.inventoryitem.canbepickedup = false
543 chessjunk3:AddComponent("trader")
544 chessjunk3.components.trader:SetAcceptTest(function(chessjunk3, item)
545 if GetPlayer().components.inventory:Has("goldnugget", 15) then
546 if item.prefab == "goldnugget" then
547 return true
548 end
549 end
550 return false
551 end )
552 chessjunk3.components.trader.onaccept = function(chessjunk3, giver, item)
553 GetPlayer().components.inventory:ConsumeByName("goldnugget", 14)
554 repairboss.AnimState:PlayAnimation("give")
555 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available")
556 local retinue3 = SpawnPrefab("knight_nightmare")
557 retinue3.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1)
558 retinue3.components.follower:SetLeader(GetPlayer())
559 retinue3.components.health:SetMaxHealth(500)
560 retinue3.components.combat:SetDefaultDamage(15)
561 retinue3:RemoveTag("monster")
562 retinue3:AddTag("retinue")
563 retinue3:AddTag("letgo")
564 local minimap = retinue3.entity:AddMiniMapEntity()
565 minimap:SetIcon( "chessjunk.png" )
566 retinue3.components.inspectable.getstatus = function(retinue3)
567 if not retinue3:HasTag("letgo") then
568 local brain = require "brains/rookbrain"
569 retinue3:SetBrain(brain)
570 retinue3:RestartBrain()
571 retinue3.components.follower:SetLeader(GetPlayer())
572 retinue3:AddTag("letgo")
573 else
574 retinue3.components.locomotor:Stop()
575 retinue3.components.follower:SetLeader(nil)
576 retinue3:SetBrain(nil)
577 retinue3:RemoveTag("letgo")
578 end
579 end
580 retinue3:AddComponent("trader")
581 retinue3.components.trader:SetAcceptTest(function(retinue3, item)
582 if GetPlayer().components.inventory:Has("goldnugget", 15) then
583 if item.prefab == "goldnugget" then
584 return true
585 end
586 end
587 return false
588 end )
589 retinue3.components.trader.onaccept = function(retinue3, giver, item)
590 GetPlayer().components.inventory:ConsumeByName("goldnugget", 14)
591 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
592 retinue3.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
593 retinue3.components.health:SetMaxHealth(1000)
594 retinue3.components.health:DoDelta(1000)
595 retinue3.components.combat:SetDefaultDamage(30)
596 retinue3:AddTag("highretinue")
597 retinue3.components.locomotor.walkspeed = 15
598 end
599 retinue3.components.locomotor.walkspeed = 10
600 retinue3.components.combat:SetAttackPeriod( 0.5 )
601 retinue3.components.combat:SetRetargetFunction(3, function(retinue3)
602 if not retinue3.components.health:IsDead() then
603 return FindEntity(retinue3, 20, function(guy)
604 if guy.components.health and not guy.components.health:IsDead() then
605 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
606 end
607 end)
608 end
609 end )
610 retinue3.components.combat:SetKeepTargetFunction(function(retinue3, target) return target and target:IsValid() end )
611 end
612 local garbage1 = SpawnPrefab("armormarble")
613 garbage1.Transform:SetPosition(pt.x+4-1, 0, pt.z-4-1)
614 garbage1.AnimState:SetBank("researchlab2")
615 garbage1.AnimState:SetBuild("researchlab2")
616 garbage1.AnimState:PlayAnimation("proximity_loop", true)
617 garbage1:AddTag("goodbye")
618 garbage1.components.inventoryitem.canbepickedup = false
619 local garbage2 = SpawnPrefab("armormarble")
620 garbage2.Transform:SetPosition(pt.x+4+1, 0, pt.z-4+1)
621 garbage2.AnimState:SetBank("researchlab2")
622 garbage2.AnimState:SetBuild("researchlab2")
623 garbage2.AnimState:PlayAnimation("proximity_loop", true)
624 garbage2:AddTag("goodbye")
625 garbage2.components.inventoryitem.canbepickedup = false
626 local garbage3 = SpawnPrefab("armormarble")
627 garbage3.Transform:SetPosition(pt.x+4+3, 0, pt.z-4+3)
628 garbage3.AnimState:SetBank("researchlab2")
629 garbage3.AnimState:SetBuild("researchlab2")
630 garbage3.AnimState:PlayAnimation("proximity_loop", true)
631 garbage3:AddTag("goodbye")
632 garbage3.components.inventoryitem.canbepickedup = false
633end
634local function OnDeploy (inst, pt)
635 repairshop(inst)
636 inst:Remove()
637end
638 inst:AddComponent("deployable")
639 inst.components.deployable.ondeploy = OnDeploy
640local function onsave(inst, data)
641 if inst:HasTag("repairboss") then
642 data.repairboss = true
643 end
644 if inst:HasTag("goodbye") then
645 data.goodbye = true
646 end
647end
648local function onload(inst, data)
649 if data and data.repairboss then
650 repairshop(inst)
651 inst:Remove()
652 end
653 if data and data.goodbye then
654 inst:Remove()
655 end
656end
657 inst.OnSave = onsave
658 inst.OnLoad = onload
659MakeLargeBurnable(inst)
660MakeLargePropagator(inst)
661
662 即可用大理石盔甲种雇佣兵工厂,鼠标左键点老板(机器人),他会拿出要你加工的零件,用锤子将零件砸成机械兵,即可获得3个黄金的工钱(老板会扔在地上)。可以向老板购买锤子(拿着黄金对老板点鼠标左键),每把1个黄金。拿着黄金对老板背后的机械兵点鼠标左键,可以购买相应品种的机械雇佣兵,其中机械犀牛每只50个黄金,机械主教每只30个黄金,机械马每只15个黄金,打造你的铁甲战团吧。鼠标左键点雇佣兵,可停止跟随,再次点击可继续跟随,点击时手中不要拿武器,以免误伤。忘记将雇佣军驻扎在何处时,可以打开小地图查找,将显示为机器零件的图标。拥有机械雇佣兵后,可以进一步为它们升级,拿着黄金对自己的机械兵点鼠标左键(同样犀牛50个黄金、主教30个黄金、马15个黄金),可将它们升级为超级机械雇佣兵(身上发亮),攻防及行军速度都将大幅提高。大战之后,给雇佣兵黄金(数量同上),可以将它们的血补满。不想要雇佣兵工厂时,烧掉即可。大理石盔甲在战斗选项(画着两把剑)下,用12块大理石、4条绳子制造