代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2二四七.观赏秃鹫(用蛛丝种笼中的秃鹫,喂腐烂食物产种子,喂肉生高鸟蛋)
3
4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/spoiledfood.lua文件,在inst:AddComponent("inspectable")的下一行插入inst:AddComponent("tradable")
5
6
7 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/silk.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
8
9local function makecage(inst)
10 local pt = inst:GetPosition()
11 local cage = SpawnPrefab("silk")
12 cage.Transform:SetPosition(pt.x, pt.y, pt.z)
13 cage.AnimState:SetBank("birdcage")
14 cage.AnimState:SetBuild("bird_cage")
15 cage.AnimState:PlayAnimation("idle")
16 cage.AnimState:SetMultColour(0/255,255/255,0/255,1)
17 MakeObstaclePhysics(cage, .5 )
18 cage:RemoveComponent("tradable")
19 cage:RemoveComponent("stackable")
20 cage:RemoveComponent("inventoryitem")
21 cage:RemoveComponent("upgrader")
22 cage:RemoveComponent("deployable")
23 cage:RemoveTag("cattoy")
24 cage:AddComponent("named")
25 cage.components.named:SetName("Buzzard")
26 cage:AddComponent("lootdropper")
27 cage:AddComponent("workable")
28 cage.components.workable:SetWorkAction(ACTIONS.HAMMER)
29 cage.components.workable:SetWorkLeft(3)
30 cage.components.workable:SetOnFinishCallback(function(cage, worker)
31 SpawnPrefab("collapse_big").Transform:SetPosition(cage.Transform:GetWorldPosition())
32 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood")
33 local pos = Vector3(cage.Transform:GetWorldPosition())
34 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 2)
35 for k,v in pairs(ents) do
36 if v:HasTag("cageanimal") then
37 v:Remove()
38 end
39 end
40 cage:Remove()
41 end )
42 cage:AddComponent("trader")
43 cage.components.trader:SetAcceptTest(function(cage, item)
44 if item.prefab == "spoiled_food" or item.prefab == "meat" or item.prefab == "smallmeat" then
45 return true
46 end
47 return false
48 end )
49 cage.components.trader.onaccept = function(cage, giver, item)
50 GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/buzzard/taunt")
51 if item.prefab == "spoiled_food" then
52 for k = 1, math.random(5) do
53 local names = {"carrot_seeds","corn_seeds","pumpkin_seeds","eggplant_seeds","durian_seeds","pomegranate_seeds","dragonfruit_seeds","watermelon_seeds","seeds"}
54 local name = names[math.random(#names)]
55 cage.components.lootdropper:SpawnLootPrefab(name)
56 end
57 end
58 if item.prefab == "meat" or item.prefab == "smallmeat" then
59 cage.components.lootdropper:SpawnLootPrefab("tallbirdegg")
60 end
61 end
62 cage:AddTag("cages")
63 local animal = SpawnPrefab("silk")
64 animal.AnimState:SetBank("buzzard")
65 animal.AnimState:SetBuild("buzzard_build")
66 animal.AnimState:PlayAnimation("idle", true)
67 animal.Transform:SetFourFaced()
68 animal.Physics:SetActive(false)
69 animal.entity:AddSoundEmitter()
70 animal:AddTag("NOCLICK")
71 animal:RemoveComponent("tradable")
72 animal:RemoveComponent("stackable")
73 animal:RemoveComponent("inventoryitem")
74 animal:RemoveComponent("upgrader")
75 animal:RemoveComponent("deployable")
76 animal:RemoveTag("cattoy")
77 local follower = animal.entity:AddFollower()
78 follower:FollowSymbol( cage.GUID, "swap_object", -10, -220, -0.1 )
79 animal:DoPeriodicTask(10, function(animal)
80 animal.AnimState:PlayAnimation("caw")
81 animal.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/buzzard/taunt")
82 animal:DoTaskInTime(1.5, function() animal.AnimState:PlayAnimation("idle", true) end )
83 end )
84 animal:AddTag("cageanimal")
85end
86local function OnDeploy (inst, pt)
87 makecage(inst)
88 inst.components.stackable:Get():Remove()
89end
90 inst:AddComponent("deployable")
91 inst.components.deployable.ondeploy = OnDeploy
92local function onsave(inst, data)
93 if inst:HasTag("cages") then
94 data.cages = true
95 end
96 if inst:HasTag("cageanimal") then
97 data.cageanimal = true
98 end
99end
100local function onload(inst, data)
101 if data and data.cages then
102 makecage(inst)
103 inst:Remove()
104 end
105 if data and data.cageanimal then
106 inst:Remove()
107 end
108end
109 inst.OnSave = onsave
110 inst.OnLoad = onload
111
112 即可用蛛丝种关在笼中的秃鹫(拿着1个蛛丝对地面点鼠标右键,如果拿着多个,则不会种出来),喂它腐烂食物,会掉落随机品种的植物种子,喂大肉、小肉会生高鸟蛋。不想要观赏秃鹫了,用锤子砸掉即可