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

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



二九五.雇佣兵工厂(用大理石盔甲种兵工厂,打工赚黄金,购买机械雇佣兵)

	1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/rook.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:

local function onsave(inst, data)
	if inst:HasTag("retinue") then
		data.retinue = true
	end
	if inst:HasTag("highretinue") then
		data.highretinue = true
	end
	if inst:HasTag("letgo") then
		data.letgo = true
	end
end
local function onload(inst, data)
	if data and data.retinue then
	   inst.components.health:SetMaxHealth(1000)
	   inst.components.combat:SetDefaultDamage(100)
	   inst:RemoveTag("monster")
	   inst:AddTag("retinue")
	   local minimap = inst.entity:AddMiniMapEntity()
	   minimap:SetIcon( "chessjunk.png" )
	   inst.components.locomotor:Stop()
	   inst:SetBrain(nil)
	   inst.components.follower:SetLeader(nil)
	   inst.components.inspectable.getstatus = function(inst)
		   if not inst:HasTag("letgo") then
			  local brain = require "brains/rookbrain"
			  inst:SetBrain(brain)
			  inst:RestartBrain()
			  inst.components.follower:SetLeader(GetPlayer())
			  inst:AddTag("letgo")
		   else
			  inst.components.locomotor:Stop()
			  inst:SetBrain(nil)
			  inst.components.follower:SetLeader(nil)
			  inst:RemoveTag("letgo")
		   end
	   end
	   inst:AddComponent("trader")
	   inst.components.trader:SetAcceptTest(function(inst, item) 
		   if GetPlayer().components.inventory:Has("goldnugget", 50) then
			  if item.prefab == "goldnugget" then
				 return true
			  end
		   end
		   return false
	   end )
	   inst.components.trader.onaccept = function(inst, giver, item)
		   GetPlayer().components.inventory:ConsumeByName("goldnugget", 49)
		   GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
		   inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
		   inst.components.health:SetMaxHealth(2000)
		   inst.components.health:DoDelta(2000)
		   inst.components.combat:SetDefaultDamage(200)
		   inst:AddTag("highretinue")
		   inst.components.locomotor.walkspeed = 15
		   inst.components.locomotor.runspeed =  20
	   end
	   inst.Physics:SetCollisionCallback(function(inst, other)
		   if other and other.components.workable and other.components.workable.workleft > 0 then
			  SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
			  other.components.workable:Destroy(inst)
		   end
	   end)
	   inst.components.locomotor.walkspeed = 10
	   inst.components.locomotor.runspeed =  15
	   inst.components.combat:SetAttackPeriod( 1 )
	   inst.components.combat:SetRetargetFunction(3, function(inst)
		  if not inst.components.health:IsDead() then
			  return FindEntity(inst, 20, function(guy)
				  if guy.components.health and not guy.components.health:IsDead() then
					 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
				  end
			  end)
		  end
	  end )
	  inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end )
	  if data and data.highretinue then
		 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
		 inst.components.health:SetMaxHealth(2000)
		 inst.components.combat:SetDefaultDamage(200)
		 inst:AddTag("highretinue")
		 inst.components.locomotor.walkspeed = 15
		 inst.components.locomotor.runspeed =  20
	  end
	  if data and data.letgo then
		 local brain = require "brains/rookbrain"
		 inst:SetBrain(brain)
		 inst:RestartBrain()
		 inst.components.follower:SetLeader(GetPlayer())
		 inst:AddTag("letgo")
	  end
	end
end
	inst.OnSave = onsave
	inst.OnLoad = onload


	2.用MT管理器打开游戏目录/assets/scripts/prefabs/bishop.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:

local function onsave(inst, data)
	if inst:HasTag("retinue") then
		data.retinue = true
	end
	if inst:HasTag("highretinue") then
		data.highretinue = true
	end
	if inst:HasTag("letgo") then
		data.letgo = true
	end
end
local function onload(inst, data)
	if data and data.retinue then
	   inst.components.health:SetMaxHealth(500)
	   inst.components.combat:SetDefaultDamage(30)
	   inst:RemoveTag("monster")
	   inst:AddTag("retinue")
	   local minimap = inst.entity:AddMiniMapEntity()
	   minimap:SetIcon( "chessjunk.png" )
	   inst.components.locomotor:Stop()
	   inst:SetBrain(nil)
	   inst.components.follower:SetLeader(nil)
	   inst.components.inspectable.getstatus = function(inst)
		   if not inst:HasTag("letgo") then
			  local brain = require "brains/rookbrain"
			  inst:SetBrain(brain)
			  inst:RestartBrain()
			  inst.components.follower:SetLeader(GetPlayer())
			  inst:AddTag("letgo")
		   else
			  inst.components.locomotor:Stop()
			  inst:SetBrain(nil)
			  inst.components.follower:SetLeader(nil)
			  inst:RemoveTag("letgo")
		   end
	   end
	   inst:AddComponent("trader")
	   inst.components.trader:SetAcceptTest(function(inst, item) 
		   if GetPlayer().components.inventory:Has("goldnugget", 30) then
			  if item.prefab == "goldnugget" then
				 return true
			  end
		   end
		   return false
	   end )
	   inst.components.trader.onaccept = function(inst, giver, item)
		   GetPlayer().components.inventory:ConsumeByName("goldnugget", 29)
		   GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
		   inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
		   inst.components.health:SetMaxHealth(1000)
		   inst.components.health:DoDelta(1000)
		   inst.components.combat:SetDefaultDamage(60)
		   inst:AddTag("highretinue")
		   inst.components.locomotor.walkspeed = 15
	   end
	   inst.components.locomotor.walkspeed = 10
	   inst.components.combat:SetAttackPeriod( 0.5 )
	   inst.components.combat:SetRetargetFunction(3, function(inst)
		  if not inst.components.health:IsDead() then
			  return FindEntity(inst, 20, function(guy)
				  if guy.components.health and not guy.components.health:IsDead() then
					 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
				  end
			  end)
		  end
	  end )
	  inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end )
	  if data and data.highretinue then
		 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
		 inst.components.health:SetMaxHealth(1000)
		 inst.components.combat:SetDefaultDamage(60)
		 inst:AddTag("highretinue")
		 inst.components.locomotor.walkspeed = 15
	  end
	  if data and data.letgo then
		 local brain = require "brains/rookbrain"
		 inst:SetBrain(brain)
		 inst:RestartBrain()
		 inst.components.follower:SetLeader(GetPlayer())
		 inst:AddTag("letgo")
	  end
	end
end
	inst.OnSave = onsave
	inst.OnLoad = onload


	3.用MT管理器打开游戏目录/assets/scripts/prefabs/knight.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:

local function onsave(inst, data)
	if inst:HasTag("retinue") then
		data.retinue = true
	end
	if inst:HasTag("highretinue") then
		data.highretinue = true
	end
	if inst:HasTag("letgo") then
		data.letgo = true
	end
end
local function onload(inst, data)
	if data and data.retinue then
	   inst.components.health:SetMaxHealth(500)
	   inst.components.combat:SetDefaultDamage(15)
	   inst:RemoveTag("monster")
	   inst:AddTag("retinue")
	   local minimap = inst.entity:AddMiniMapEntity()
	   minimap:SetIcon( "chessjunk.png" )
	   inst.components.locomotor:Stop()
	   inst:SetBrain(nil)
	   inst.components.follower:SetLeader(nil)
	   inst.components.inspectable.getstatus = function(inst)
		   if not inst:HasTag("letgo") then
			  local brain = require "brains/rookbrain"
			  inst:SetBrain(brain)
			  inst:RestartBrain()
			  inst.components.follower:SetLeader(GetPlayer())
			  inst:AddTag("letgo")
		   else
			  inst.components.locomotor:Stop()
			  inst:SetBrain(nil)
			  inst.components.follower:SetLeader(nil)
			  inst:RemoveTag("letgo")
		   end
	   end
	   inst:AddComponent("trader")
	   inst.components.trader:SetAcceptTest(function(inst, item) 
		   if GetPlayer().components.inventory:Has("goldnugget", 15) then
			  if item.prefab == "goldnugget" then
				 return true
			  end
		   end
		   return false
	   end )
	   inst.components.trader.onaccept = function(inst, giver, item)
		   GetPlayer().components.inventory:ConsumeByName("goldnugget", 14)
		   GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
		   inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
		   inst.components.health:SetMaxHealth(1000)
		   inst.components.health:DoDelta(1000)
		   inst.components.combat:SetDefaultDamage(30)
		   inst:AddTag("highretinue")
		   inst.components.locomotor.walkspeed = 15
	   end
	   inst.components.locomotor.walkspeed = 10
	   inst.components.combat:SetAttackPeriod( 0.5 )
	   inst.components.combat:SetRetargetFunction(3, function(inst)
		  if not inst.components.health:IsDead() then
			  return FindEntity(inst, 20, function(guy)
				  if guy.components.health and not guy.components.health:IsDead() then
					 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
				  end
			  end)
		  end
	  end )
	  inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end )
	  if data and data.highretinue then
		 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
		 inst.components.health:SetMaxHealth(1000)
		 inst.components.combat:SetDefaultDamage(30)
		 inst:AddTag("highretinue")
		 inst.components.locomotor.walkspeed = 15
	  end
	  if data and data.letgo then
		 local brain = require "brains/rookbrain"
		 inst:SetBrain(brain)
		 inst:RestartBrain()
		 inst.components.follower:SetLeader(GetPlayer())
		 inst:AddTag("letgo")
	  end
	end
end
	inst.OnSave = onsave
	inst.OnLoad = onload


	4.用MT管理器打开游戏目录/assets/scripts/prefabs/armor_marble.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:

local function repairshop(inst)
	local pt = inst:GetPosition()
	local repairboss = SpawnPrefab("armormarble")
	repairboss.Transform:SetPosition(pt.x, pt.y, pt.z)
	repairboss.AnimState:SetBank("wilson")
	repairboss.AnimState:SetBuild("wx78")
	repairboss.AnimState:OverrideSymbol("swap_hat", "hat_top", "swap_hat")
	repairboss.AnimState:Show("HAT")
	repairboss.AnimState:Show("HAT_HAIR")
	repairboss.AnimState:Hide("HAIR_NOHAT")
	repairboss.AnimState:Hide("HAIR")
	repairboss.AnimState:OverrideSymbol("swap_body", "armor_marble", "swap_body")
	repairboss.AnimState:OverrideSymbol("swap_object", "swap_hammer", "swap_hammer")
	repairboss.AnimState:Show("ARM_carry") 
	repairboss.AnimState:Hide("ARM_normal") 
	repairboss.Transform:SetFourFaced()
	repairboss.AnimState:PlayAnimation("idle")
	repairboss:AddTag("repairboss")
	repairboss.components.inventoryitem.canbepickedup = false
	local light = repairboss.entity:AddLight()
	light:SetFalloff(1)
	light:SetIntensity(.8)
	light:SetRadius(10)
	light:SetColour(180/255, 195/255, 50/255)
	light:Enable(true)
	repairboss:AddComponent("trader")
	repairboss.components.trader:SetAcceptTest(function(repairboss, item) 
		if item.prefab == "goldnugget" then
		   return true
		end
		return false
	end )
	repairboss.components.trader.onaccept = function(repairboss, giver, item)
		repairboss.AnimState:PlayAnimation("give")
		SpawnPrefab("hammer").Transform:SetPosition(pt.x+0.5, 0, pt.z+0.5)
	end
	repairboss.components.inspectable.getstatus = function(repairboss)
		repairboss.AnimState:PlayAnimation("give")
		GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_stone")
		local chessjunk = SpawnPrefab("armormarble")
		chessjunk.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1)
		chessjunk.AnimState:SetBank("chessmonster_ruins")
		chessjunk.AnimState:SetBuild("chessmonster_ruins")
		chessjunk.AnimState:PlayAnimation("idle3")
		chessjunk:AddTag("goodbye")
		chessjunk.components.inventoryitem.canbepickedup = false
		chessjunk:AddComponent("workable")
		chessjunk.components.workable:SetWorkAction(ACTIONS.HAMMER)
		chessjunk.components.workable:SetWorkLeft(30)
		chessjunk.components.workable:SetOnWorkCallback(function(chessjunk, worker, workleft)
			if chessjunk.components.workable.workleft <= 0 then
			   GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/chessjunk_break")
			   chessjunk:Remove()
			   local goods = SpawnPrefab("armormarble")
			   goods.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1)
			   goods:AddTag("goodbye")
			   goods.components.inventoryitem.canbepickedup = false
			   if math.random()<.33 then
				  goods.AnimState:SetBank("rook")
				  goods.AnimState:SetBuild("rook_nightmare")
				  goods.AnimState:PlayAnimation("idle")
				  goods.Transform:SetScale(0.66, 0.66, 0.66)
			   elseif math.random()<.66 then
				  goods.AnimState:SetBank("bishop")
				  goods.AnimState:SetBuild("bishop_nightmare")
				  goods.AnimState:PlayAnimation("idle_loop", true)
			   else
				  goods.AnimState:SetBank("knight")
				  goods.AnimState:SetBuild("knight_nightmare")
				  goods.AnimState:PlayAnimation("idle_loop", true)
			   end
			   GetPlayer():DoTaskInTime(2, function()
				   repairboss.AnimState:PlayAnimation("give")
				   GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold")
				   for k = 1, 3 do
					   SpawnPrefab("goldnugget").Transform:SetPosition(pt.x+0.5, 0, pt.z-0.5)
				   end
				   goods:Remove()
			   end )
			else
			   if chessjunk.components.workable.workleft < 10 then
				  chessjunk.AnimState:PlayAnimation("idle1")
			   elseif chessjunk.components.workable.workleft < 20 then
				  chessjunk.AnimState:PlayAnimation("idle2")
			   else
				  chessjunk.AnimState:PlayAnimation("idle3")
			   end
			end
		end) 
	end
	local chessjunk1 = SpawnPrefab("armormarble")
	chessjunk1.Transform:SetPosition(pt.x-3, 0, pt.z-3)
	chessjunk1.AnimState:SetBank("rook")
	chessjunk1.AnimState:SetBuild("rook_nightmare")
	chessjunk1.Transform:SetFourFaced()
	chessjunk1.AnimState:PlayAnimation("idle")
	chessjunk1.Transform:SetScale(0.66, 0.66, 0.66)
	chessjunk1:AddTag("goodbye")
	chessjunk1.components.inventoryitem.canbepickedup = false
	chessjunk1:AddComponent("trader")
	chessjunk1.components.trader:SetAcceptTest(function(chessjunk1, item) 
		if GetPlayer().components.inventory:Has("goldnugget", 50) then
		   if item.prefab == "goldnugget" then
			  return true
		   end
		end
		return false
	end )
	chessjunk1.components.trader.onaccept = function(chessjunk1, giver, item)
		GetPlayer().components.inventory:ConsumeByName("goldnugget", 49)
		repairboss.AnimState:PlayAnimation("give")
		GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available")
		local retinue1 = SpawnPrefab("rook_nightmare")
		retinue1.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1)
		retinue1.components.follower:SetLeader(GetPlayer())
		retinue1.components.health:SetMaxHealth(1000)
		retinue1.components.combat:SetDefaultDamage(100)
		retinue1:RemoveTag("monster")
		retinue1:AddTag("retinue")
		retinue1:AddTag("letgo")
	local minimap = retinue1.entity:AddMiniMapEntity()
	minimap:SetIcon( "chessjunk.png" )
		retinue1.components.inspectable.getstatus = function(retinue1)
			if not retinue1:HasTag("letgo") then
			   local brain = require "brains/rookbrain"
			   retinue1:SetBrain(brain)
			   retinue1:RestartBrain()
			   retinue1.components.follower:SetLeader(GetPlayer())
			   retinue1:AddTag("letgo")
			else
			   retinue1.components.locomotor:Stop()
			   retinue1.components.follower:SetLeader(nil)
			   retinue1:SetBrain(nil)
			   retinue1:RemoveTag("letgo")
			end
		end
		retinue1:AddComponent("trader")
		retinue1.components.trader:SetAcceptTest(function(retinue1, item) 
			if GetPlayer().components.inventory:Has("goldnugget", 50) then
			   if item.prefab == "goldnugget" then
				  return true
			   end
			end
			return false
		end )
		retinue1.components.trader.onaccept = function(retinue1, giver, item)
			GetPlayer().components.inventory:ConsumeByName("goldnugget", 49)
			GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
			retinue1.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
			retinue1.components.health:SetMaxHealth(2000)
			retinue1.components.health:DoDelta(2000)
			retinue1.components.combat:SetDefaultDamage(200)
			retinue1:AddTag("highretinue")
			retinue1.components.locomotor.walkspeed = 15
			retinue1.components.locomotor.runspeed =  20
		end
		retinue1.Physics:SetCollisionCallback(function(retinue1, other)
			if other and other.components.workable and other.components.workable.workleft > 0 then
			   SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
			   other.components.workable:Destroy(retinue1)
			end
		end)
		retinue1.components.locomotor.walkspeed = 10
		retinue1.components.locomotor.runspeed =  15
		retinue1.components.combat:SetAttackPeriod( 1 )
		retinue1.components.combat:SetRetargetFunction(3, function(retinue1)
		   if not retinue1.components.health:IsDead() then
			   return FindEntity(retinue1, 20, function(guy)
				   if guy.components.health and not guy.components.health:IsDead() then
					  return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
				   end
			   end)
		   end
		end )
		retinue1.components.combat:SetKeepTargetFunction(function(retinue1, target) return target and target:IsValid() end )
	end
	local chessjunk2 = SpawnPrefab("armormarble")
	chessjunk2.Transform:SetPosition(pt.x-3+2.3, 0, pt.z-3-2.3)
	chessjunk2.AnimState:SetBank("bishop")
	chessjunk2.AnimState:SetBuild("bishop_nightmare")
	chessjunk2.Transform:SetFourFaced()
	chessjunk2.AnimState:PlayAnimation("idle_loop", true)
	chessjunk2:AddTag("goodbye")
	chessjunk2.components.inventoryitem.canbepickedup = false
	chessjunk2:AddComponent("trader")
	chessjunk2.components.trader:SetAcceptTest(function(chessjunk2, item) 
		if GetPlayer().components.inventory:Has("goldnugget", 30) then
		   if item.prefab == "goldnugget" then
			  return true
		   end
		end
		return false
	end )
	chessjunk2.components.trader.onaccept = function(chessjunk2, giver, item)
		GetPlayer().components.inventory:ConsumeByName("goldnugget", 29)
		repairboss.AnimState:PlayAnimation("give")
		GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available")
		local retinue2 = SpawnPrefab("bishop_nightmare")
		retinue2.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1)
		retinue2.components.follower:SetLeader(GetPlayer())
		retinue2.components.health:SetMaxHealth(500)
		retinue2.components.combat:SetDefaultDamage(30)
		retinue2:RemoveTag("monster")
		retinue2:AddTag("retinue")
		retinue2:AddTag("letgo")
	local minimap = retinue2.entity:AddMiniMapEntity()
	minimap:SetIcon( "chessjunk.png" )
		retinue2.components.inspectable.getstatus = function(retinue2)
			if not retinue2:HasTag("letgo") then
			   local brain = require "brains/rookbrain"
			   retinue2:SetBrain(brain)
			   retinue2:RestartBrain()
			   retinue2.components.follower:SetLeader(GetPlayer())
			   retinue2:AddTag("letgo")
			else
			   retinue2.components.locomotor:Stop()
			   retinue2.components.follower:SetLeader(nil)
			   retinue2:SetBrain(nil)
			   retinue2:RemoveTag("letgo")
			end
		end
		retinue2:AddComponent("trader")
		retinue2.components.trader:SetAcceptTest(function(retinue2, item) 
			if GetPlayer().components.inventory:Has("goldnugget", 30) then
			   if item.prefab == "goldnugget" then
				  return true
			   end
			end
			return false
		end )
		retinue2.components.trader.onaccept = function(retinue2, giver, item)
			GetPlayer().components.inventory:ConsumeByName("goldnugget", 29)
			GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
			retinue2.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
			retinue2.components.health:SetMaxHealth(1000)
			retinue2.components.health:DoDelta(1000)
			retinue2.components.combat:SetDefaultDamage(60)
			retinue2:AddTag("highretinue")
			retinue2.components.locomotor.walkspeed = 15
		end
		retinue2.components.locomotor.walkspeed = 10
		retinue2.components.combat:SetAttackPeriod( 0.5 )
		retinue2.components.combat:SetRetargetFunction(3, function(retinue2)
		   if not retinue2.components.health:IsDead() then
			   return FindEntity(retinue2, 20, function(guy)
				   if guy.components.health and not guy.components.health:IsDead() then
					  return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
				   end
			   end)
		   end
		end )
		retinue2.components.combat:SetKeepTargetFunction(function(retinue2, target) return target and target:IsValid() end )
	end
	local chessjunk3 = SpawnPrefab("armormarble")
	chessjunk3.Transform:SetPosition(pt.x-3-2, 0, pt.z-3+2)
	chessjunk3.AnimState:SetBank("knight")
	chessjunk3.AnimState:SetBuild("knight_nightmare")
	chessjunk3.Transform:SetFourFaced()
	chessjunk3.AnimState:PlayAnimation("idle_loop", true)
	chessjunk3:AddTag("goodbye")
	chessjunk3.components.inventoryitem.canbepickedup = false
	chessjunk3:AddComponent("trader")
	chessjunk3.components.trader:SetAcceptTest(function(chessjunk3, item) 
		if GetPlayer().components.inventory:Has("goldnugget", 15) then
		   if item.prefab == "goldnugget" then
			  return true
		   end
		end
		return false
	end )
	chessjunk3.components.trader.onaccept = function(chessjunk3, giver, item)
		GetPlayer().components.inventory:ConsumeByName("goldnugget", 14)
		repairboss.AnimState:PlayAnimation("give")
		GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available")
		local retinue3 = SpawnPrefab("knight_nightmare")
		retinue3.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1)
		retinue3.components.follower:SetLeader(GetPlayer())
		retinue3.components.health:SetMaxHealth(500)
		retinue3.components.combat:SetDefaultDamage(15)
		retinue3:RemoveTag("monster")
		retinue3:AddTag("retinue")
		retinue3:AddTag("letgo")
	local minimap = retinue3.entity:AddMiniMapEntity()
	minimap:SetIcon( "chessjunk.png" )
		retinue3.components.inspectable.getstatus = function(retinue3)
			if not retinue3:HasTag("letgo") then
			   local brain = require "brains/rookbrain"
			   retinue3:SetBrain(brain)
			   retinue3:RestartBrain()
			   retinue3.components.follower:SetLeader(GetPlayer())
			   retinue3:AddTag("letgo")
			else
			   retinue3.components.locomotor:Stop()
			   retinue3.components.follower:SetLeader(nil)
			   retinue3:SetBrain(nil)
			   retinue3:RemoveTag("letgo")
			end
		end
		retinue3:AddComponent("trader")
		retinue3.components.trader:SetAcceptTest(function(retinue3, item) 
			if GetPlayer().components.inventory:Has("goldnugget", 15) then
			   if item.prefab == "goldnugget" then
				  return true
			   end
			end
			return false
		end )
		retinue3.components.trader.onaccept = function(retinue3, giver, item)
			GetPlayer().components.inventory:ConsumeByName("goldnugget", 14)
			GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
			retinue3.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
			retinue3.components.health:SetMaxHealth(1000)
			retinue3.components.health:DoDelta(1000)
			retinue3.components.combat:SetDefaultDamage(30)
			retinue3:AddTag("highretinue")
			retinue3.components.locomotor.walkspeed = 15
		end
		retinue3.components.locomotor.walkspeed = 10
		retinue3.components.combat:SetAttackPeriod( 0.5 )
		retinue3.components.combat:SetRetargetFunction(3, function(retinue3)
		   if not retinue3.components.health:IsDead() then
			   return FindEntity(retinue3, 20, function(guy)
				   if guy.components.health and not guy.components.health:IsDead() then
					  return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster")
				   end
			   end)
		   end
	   end )
	   retinue3.components.combat:SetKeepTargetFunction(function(retinue3, target) return target and target:IsValid() end )
	end
	local garbage1 = SpawnPrefab("armormarble")
	garbage1.Transform:SetPosition(pt.x+4-1, 0, pt.z-4-1)
	garbage1.AnimState:SetBank("researchlab2")
	garbage1.AnimState:SetBuild("researchlab2")
	garbage1.AnimState:PlayAnimation("proximity_loop", true)
	garbage1:AddTag("goodbye")
	garbage1.components.inventoryitem.canbepickedup = false
	local garbage2 = SpawnPrefab("armormarble")
	garbage2.Transform:SetPosition(pt.x+4+1, 0, pt.z-4+1)
	garbage2.AnimState:SetBank("researchlab2")
	garbage2.AnimState:SetBuild("researchlab2")
	garbage2.AnimState:PlayAnimation("proximity_loop", true)
	garbage2:AddTag("goodbye")
	garbage2.components.inventoryitem.canbepickedup = false
	local garbage3 = SpawnPrefab("armormarble")
	garbage3.Transform:SetPosition(pt.x+4+3, 0, pt.z-4+3)
	garbage3.AnimState:SetBank("researchlab2")
	garbage3.AnimState:SetBuild("researchlab2")
	garbage3.AnimState:PlayAnimation("proximity_loop", true)
	garbage3:AddTag("goodbye")
	garbage3.components.inventoryitem.canbepickedup = false
end
local function OnDeploy (inst, pt)
	repairshop(inst)
	inst:Remove()
end
	inst:AddComponent("deployable")
	inst.components.deployable.ondeploy = OnDeploy
local function onsave(inst, data)
	if inst:HasTag("repairboss") then
		data.repairboss = true
	end
	if inst:HasTag("goodbye") then
		data.goodbye = true
	end
end
local function onload(inst, data)
	if data and data.repairboss then
	   repairshop(inst)
	   inst:Remove()
	end
	if data and data.goodbye then
	   inst:Remove()
	end
end
	inst.OnSave = onsave
	inst.OnLoad = onload
MakeLargeBurnable(inst)
MakeLargePropagator(inst)

	即可用大理石盔甲种雇佣兵工厂,鼠标左键点老板(机器人),他会拿出要你加工的零件,用锤子将零件砸成机械兵,即可获得3个黄金的工钱(老板会扔在地上)。可以向老板购买锤子(拿着黄金对老板点鼠标左键),每把1个黄金。拿着黄金对老板背后的机械兵点鼠标左键,可以购买相应品种的机械雇佣兵,其中机械犀牛每只50个黄金,机械主教每只30个黄金,机械马每只15个黄金,打造你的铁甲战团吧。鼠标左键点雇佣兵,可停止跟随,再次点击可继续跟随,点击时手中不要拿武器,以免误伤。忘记将雇佣军驻扎在何处时,可以打开小地图查找,将显示为机器零件的图标。拥有机械雇佣兵后,可以进一步为它们升级,拿着黄金对自己的机械兵点鼠标左键(同样犀牛50个黄金、主教30个黄金、马15个黄金),可将它们升级为超级机械雇佣兵(身上发亮),攻防及行军速度都将大幅提高。大战之后,给雇佣兵黄金(数量同上),可以将它们的血补满。不想要雇佣兵工厂时,烧掉即可。大理石盔甲在战斗选项(画着两把剑)下,用12块大理石、4条绳子制造