代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2二五七.生物克隆机(用夜魔盔甲种克隆机,随身携带,大量克隆各种生物)
3
4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/armor_sanity.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
5
6local function itemtest(inst, item, slot)
7 if item.prefab == "silk" or item.prefab == "houndstooth" or item.prefab == "beefalowool" or item.prefab == "tentaclespots" or item.prefab == "froglegs" or item.prefab == "stinger" or item.prefab == "mosquitosack" or item.prefab == "tallbirdegg" or item.prefab == "walrus_tusk" or item.prefab == "livinglog" or item.prefab == "bird_egg" or item.prefab == "trunk_summer" or item.prefab == "trunk_winter" or item.prefab == "deerclops_eyeball" or item.prefab == "fish" or item.prefab == "plantmeat" or item.prefab == "rocks" or item.prefab == "cave_banana" or item.prefab == "slurper_pelt" or item.prefab == "minotaurhorn" or item.prefab == "wormlight" or item.prefab == "slurtle_shellpieces" or item.prefab == "slurtleslime" or item.prefab == "batwing" or item.prefab == "manrabbit_tail" or item.prefab == "pigskin" or item.prefab == "lightninggoathorn" or item.prefab == "dragon_scales" or item.prefab == "goose_feather" or item.prefab == "bearger_fur" then
8 return true
9 end
10 return false
11end
12local slotpos = { Vector3(0,-75,0)}
13local widgetbuttoninfo = {
14 text = "GO",
15 position = Vector3(0, -135, 0),
16 fn = function(inst)
17 if inst:HasTag("machines") then
18 if not inst.components.container:IsEmpty() then
19 for k,v in pairs(inst.components.container.slots) do
20 if v and v.prefab == "silk" then inst.weirdo = "spiderqueen" end
21 if v and v.prefab == "houndstooth" then inst.weirdo = "firehound" end
22 if v and v.prefab == "beefalowool" then inst.weirdo = "beefalo" end
23 if v and v.prefab == "tentaclespots" then inst.weirdo = "tentacle" end
24 if v and v.prefab == "froglegs" then inst.weirdo = "frog" end
25 if v and v.prefab == "stinger" then inst.weirdo = "killerbee" end
26 if v and v.prefab == "mosquitosack" then inst.weirdo = "mosquito" end
27 if v and v.prefab == "tallbirdegg" then inst.weirdo = "tallbird" end
28 if v and v.prefab == "walrus_tusk" then inst.weirdo = "walrus" end
29 if v and v.prefab == "livinglog" then inst.weirdo = "leif_sparse" end
30 if v and v.prefab == "bird_egg" then inst.weirdo = "perd" end
31 if v and v.prefab == "trunk_summer" then inst.weirdo = "koalefant_summer" end
32 if v and v.prefab == "trunk_winter" then inst.weirdo = "koalefant_winter" end
33 if v and v.prefab == "deerclops_eyeball" then inst.weirdo = "deerclops" end
34 if v and v.prefab == "fish" then inst.weirdo = "merm" end
35 if v and v.prefab == "plantmeat" then inst.weirdo = "lureplant" end
36 if v and v.prefab == "rocks" then inst.weirdo = "rocky" end
37 if v and v.prefab == "cave_banana" then inst.weirdo = "monkey" end
38 if v and v.prefab == "slurper_pelt" then inst.weirdo = "slurper" end
39 if v and v.prefab == "minotaurhorn" then inst.weirdo = "minotaur" end
40 if v and v.prefab == "wormlight" then inst.weirdo = "worm" end
41 if v and v.prefab == "slurtle_shellpieces" then inst.weirdo = "slurtle" end
42 if v and v.prefab == "slurtleslime" then inst.weirdo = "snurtle" end
43 if v and v.prefab == "batwing" then inst.weirdo = "bat" end
44 if v and v.prefab == "manrabbit_tail" then inst.weirdo = "bunnyman" end
45 if v and v.prefab == "pigskin" then inst.weirdo = "pigman" end
46 if v and v.prefab == "lightninggoathorn" then inst.weirdo = "lightninggoat" end
47 if v and v.prefab == "dragon_scales" then inst.weirdo = "dragonfly" end
48 if v and v.prefab == "goose_feather" then inst.weirdo = "moose" end
49 if v and v.prefab == "bearger_fur" then inst.weirdo = "bearger" end
50 v:Remove()
51 end
52 local pt0 = Vector3(GetPlayer().Transform:GetWorldPosition())
53 for k = 1, 20 do
54 local result_offset = FindValidPositionByFan(1 * 2 * PI, 10, 20, function(offset)
55 local x,y,z = (pt0 + offset):Get()
56 local ents = TheSim:FindEntities(x,y,z , 1)
57 return not next(ents)
58 end)
59 if result_offset then
60 local newweirdo = SpawnPrefab(inst.weirdo)
61 newweirdo.Transform:SetPosition((pt0 + result_offset):Get())
62 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40)
63 local fx = SpawnPrefab("collapse_small")
64 local pos = pt0 + result_offset
65 fx.Transform:SetPosition(pos.x, pos.y, pos.z)
66 end
67 end
68 end
69 end
70 end }
71local function OnDeploy (inst, pt)
72 local machine = SpawnPrefab("armor_sanity")
73 machine.Transform:SetPosition(pt.x, pt.y, pt.z)
74 machine.AnimState:SetBank("rain_meter")
75 machine.AnimState:SetBuild("rain_meter")
76 machine.AnimState:PlayAnimation("meter", 0)
77 machine.Transform:SetScale(0.5, 0.5, 0.5)
78 machine:RemoveTag("sanity")
79 machine:RemoveComponent("inventoryitem")
80 machine:RemoveComponent("armor")
81 machine:RemoveComponent("equippable")
82 machine:RemoveComponent("deployable")
83 machine.components.container.canbeopened = true
84 machine:AddComponent("inventoryitem")
85 machine.components.inventoryitem:ChangeImageName("rainometer")
86 machine:AddComponent("equippable")
87 machine.components.equippable.equipslot = EQUIPSLOTS.BODY
88 machine.components.equippable.walkspeedmult = TUNING.CANE_SPEED_MULT*2
89 machine.components.equippable:SetOnEquip( function(machine)
90 GetPlayer().components.inventory:SetOverflow(machine)
91 machine.components.container:Open(GetPlayer())
92 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_open", "open")
93 GetPlayer():Hide()
94 local shadow = GetPlayer().entity:AddDynamicShadow()
95 shadow:SetSize( 0, 0 )
96 end )
97 machine.components.equippable:SetOnUnequip( function(machine)
98 machine.components.container:Close(GetPlayer())
99 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_close", "open")
100 GetPlayer():Show()
101 local shadow = GetPlayer().entity:AddDynamicShadow()
102 shadow:SetSize( 1.3, .6 )
103 end )
104 machine:AddTag("machines")
105 inst:Remove()
106end
107 inst:AddComponent("deployable")
108 inst.components.deployable.ondeploy = OnDeploy
109local function onsave(inst, data)
110 if inst:HasTag("machines") then
111 data.machines = true
112 end
113end
114local function onload(inst, data)
115 if data and data.machines then
116 inst.AnimState:SetBank("rain_meter")
117 inst.AnimState:SetBuild("rain_meter")
118 inst.AnimState:PlayAnimation("meter", 0)
119 inst.Transform:SetScale(0.5, 0.5, 0.5)
120 inst:RemoveTag("sanity")
121 inst:RemoveComponent("inventoryitem")
122 inst:RemoveComponent("armor")
123 inst:RemoveComponent("equippable")
124 inst:RemoveComponent("deployable")
125 inst.components.container.canbeopened = true
126 inst:AddComponent("inventoryitem")
127 inst.components.inventoryitem:ChangeImageName("rainometer")
128 inst:AddComponent("equippable")
129 inst.components.equippable.equipslot = EQUIPSLOTS.BODY
130 inst.components.equippable.walkspeedmult = TUNING.CANE_SPEED_MULT*2
131 inst.components.equippable:SetOnEquip( function(inst)
132 GetPlayer().components.inventory:SetOverflow(inst)
133 inst.components.container:Open(GetPlayer())
134 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_open", "open")
135 GetPlayer():Hide()
136 local shadow = GetPlayer().entity:AddDynamicShadow()
137 shadow:SetSize( 0, 0 )
138 end )
139 inst.components.equippable:SetOnUnequip( function(inst)
140 inst.components.container:Close(GetPlayer())
141 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_close", "open")
142 GetPlayer():Show()
143 local shadow = GetPlayer().entity:AddDynamicShadow()
144 shadow:SetSize( 1.3, .6 )
145 end )
146 inst:AddTag("machines")
147 end
148end
149 inst.OnSave = onsave
150 inst.OnLoad = onload
151 inst:AddComponent("container")
152 inst.components.container:SetNumSlots(#slotpos)
153 inst.components.container.widgetslotpos = slotpos
154 inst.components.container.widgetpos = Vector3(-80,150,0)
155 inst.components.container.side_widget = true
156 inst.components.container.itemtestfn = itemtest
157 inst.components.container.widgetbuttoninfo = widgetbuttoninfo
158 inst.components.container.acceptsstacks = false
159 inst.components.container.canbeopened = false
160
161 即可用夜魔盔甲种克隆机,装备克隆机后主角隐身(以免遭怪物围攻),屏幕右侧会出现格子和按钮,在格子中放入1个生物掉落的物品,按GO按钮,就可以克隆20个该生物,具体为:蜘蛛丝克隆蜘蛛女王、犬牙克隆火狗、牛毛克隆牛、触手皮克隆触手、蛙腿克隆青蛙、蜂刺克隆杀人蜂、蚊子血囊克隆蚊子、高鸟蛋克隆大高鸟、海象牙克隆海象、活木头克隆树精、鸡蛋克隆火鸡、夏象鼻克隆夏象、冬象鼻克隆冬象、巨鹿眼球克隆巨鹿、鱼克隆鱼人、食人花肉克隆食人花、岩石克隆龙虾、香蕉克隆猴子、缀食者皮克隆缀食者、远古守护者角克隆远古守护者、虫子果克隆虫子、蜗牛龟壳片克隆蜗牛龟、蜗牛龟粘液克隆黏糊虫、蝙蝠翅膀克隆蝙蝠、兔人尾巴克隆兔人、猪皮克隆猪人、闪电羊角克隆闪电羊、蜻蜓鳞片克隆蜻蜓、熊皮克隆熊、鹿鸭羽毛克隆鹿鸭。卸载克隆机后主角现身。拥有克隆机,让你有无限的怪物可刷,也可用于以怪制怪,比如在牛群里制造触手,在蜘蛛群里释放杀人蜂等,创造一个生机勃勃的世界吧。夜魔盔甲在魔法选项(画着红骷髅)下用5个噩梦燃料、3张纸制造