代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1 2九十八.养殖火鸡(用鸡蛋种会下蛋且不用圈养的火鸡) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/egg.lua文件,在inst.components.cookable.product = "bird_egg_cooked"的下一行插入以下内容: 5 6local function OnDeploy (inst, pt) 7 SpawnPrefab("perd").Transform:SetPosition(pt.x, pt.y, pt.z) 8 inst.components.stackable:Get():Remove() 9end 10 inst:AddComponent("deployable") 11 inst.components.deployable.ondeploy = OnDeploy 12 13 14 2.用MT管理器打开游戏目录/assets/scripts/prefabs/perd.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 15 16 inst:AddComponent("periodicspawner") 17 inst.components.periodicspawner:SetPrefab("bird_egg") 18 inst.components.periodicspawner:SetRandomTimes(360, 480) 19 inst.components.periodicspawner:Start() 20 21 22 3.用MT管理器打开游戏目录/assets/scripts/brains/perdbrain.lua文件,将下列内容: 23 24 WhileNode(function() return clock and not clock:IsDay() end, "IsNight", 25 DoAction(self.inst, GoHomeAction, "Go Home", true )), 26 DoAction(self.inst, EatFoodAction, "Eat Food"), 27 RunAway(self.inst, "scarytoprey", SEE_PLAYER_DIST, STOP_RUN_DIST), 28 DoAction(self.inst, PickBerriesAction, "Pick Berries", true), 29 Wander(self.inst, HomePos, MAX_WANDER_DIST), 30 31 替换为: 32 33 DoAction(self.inst, EatFoodAction, "Eat Food"), 34 RunAway(self.inst, "scarytoprey", SEE_PLAYER_DIST/2.5, STOP_RUN_DIST/3), 35 36 即可用鸡蛋种会下蛋且不用圈养的火鸡,火鸡不会乱跑,养在果树丛旁也不会消失,一天左右下一个蛋