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

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



二四七.观赏秃鹫(用蛛丝种笼中的秃鹫,喂腐烂食物产种子,喂肉生高鸟蛋)

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


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

local function makecage(inst)
	local pt = inst:GetPosition()
	local cage = SpawnPrefab("silk")
	cage.Transform:SetPosition(pt.x, pt.y, pt.z)
	cage.AnimState:SetBank("birdcage")
	cage.AnimState:SetBuild("bird_cage")
	cage.AnimState:PlayAnimation("idle")
	cage.AnimState:SetMultColour(0/255,255/255,0/255,1)
	MakeObstaclePhysics(cage, .5 )
	cage:RemoveComponent("tradable")
	cage:RemoveComponent("stackable")
	cage:RemoveComponent("inventoryitem")
	cage:RemoveComponent("upgrader")
	cage:RemoveComponent("deployable")
	cage:RemoveTag("cattoy")
	cage:AddComponent("named")
	cage.components.named:SetName("Buzzard")
	cage:AddComponent("lootdropper")
	cage:AddComponent("workable")
	cage.components.workable:SetWorkAction(ACTIONS.HAMMER)
	cage.components.workable:SetWorkLeft(3)
	cage.components.workable:SetOnFinishCallback(function(cage, worker)
		SpawnPrefab("collapse_big").Transform:SetPosition(cage.Transform:GetWorldPosition())
		GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood")
		local pos = Vector3(cage.Transform:GetWorldPosition())
		local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 2)
		for k,v in pairs(ents) do
			if v:HasTag("cageanimal") then
			   v:Remove()
			end
		end
		cage:Remove()
	end )
	cage:AddComponent("trader")
	cage.components.trader:SetAcceptTest(function(cage, item) 
		if item.prefab == "spoiled_food" or item.prefab == "meat" or item.prefab == "smallmeat" then
		   return true
		end
		return false
	end )
	cage.components.trader.onaccept = function(cage, giver, item)
		GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/buzzard/taunt")
		if item.prefab == "spoiled_food" then
		   for k = 1, math.random(5) do
			   local names = {"carrot_seeds","corn_seeds","pumpkin_seeds","eggplant_seeds","durian_seeds","pomegranate_seeds","dragonfruit_seeds","watermelon_seeds","seeds"}
			   local name = names[math.random(#names)]
			   cage.components.lootdropper:SpawnLootPrefab(name)
		   end
		end
		if item.prefab == "meat" or item.prefab == "smallmeat" then
		   cage.components.lootdropper:SpawnLootPrefab("tallbirdegg")
		end
	end
	cage:AddTag("cages")
	local animal = SpawnPrefab("silk")
	animal.AnimState:SetBank("buzzard")
	animal.AnimState:SetBuild("buzzard_build")
	animal.AnimState:PlayAnimation("idle", true)
	animal.Transform:SetFourFaced()
	animal.Physics:SetActive(false)
	animal.entity:AddSoundEmitter()
	animal:AddTag("NOCLICK")
	animal:RemoveComponent("tradable")
	animal:RemoveComponent("stackable")
	animal:RemoveComponent("inventoryitem")
	animal:RemoveComponent("upgrader")
	animal:RemoveComponent("deployable")
	animal:RemoveTag("cattoy")
	local follower = animal.entity:AddFollower()
	follower:FollowSymbol( cage.GUID, "swap_object", -10, -220, -0.1 )
	animal:DoPeriodicTask(10, function(animal)
		animal.AnimState:PlayAnimation("caw")
		animal.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/buzzard/taunt")
		animal:DoTaskInTime(1.5, function() animal.AnimState:PlayAnimation("idle", true) end )
	end )
	animal:AddTag("cageanimal")
end
local function OnDeploy (inst, pt)
	makecage(inst)
	inst.components.stackable:Get():Remove()
end
	inst:AddComponent("deployable")
	inst.components.deployable.ondeploy = OnDeploy
local function onsave(inst, data)
	if inst:HasTag("cages") then
	   data.cages = true
	end
	if inst:HasTag("cageanimal") then
	   data.cageanimal = true
	end
end
local function onload(inst, data)
	if data and data.cages then
	   makecage(inst)
	   inst:Remove()
	end
	if data and data.cageanimal then
	   inst:Remove()
	end
end
	inst.OnSave = onsave
	inst.OnLoad = onload

	即可用蛛丝种关在笼中的秃鹫(拿着1个蛛丝对地面点鼠标右键,如果拿着多个,则不会种出来),喂它腐烂食物,会掉落随机品种的植物种子,喂大肉、小肉会生高鸟蛋。不想要观赏秃鹫了,用锤子砸掉即可