代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2二五六.小冰山(用铥矿碎片种小冰山,靠近可解暑,无限开采冰和永冻冰,吃了能降温)
3
4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/thulecite_pieces.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
5
6local function makeiceberg(inst)
7 local pt = inst:GetPosition()
8 local iceberg = SpawnPrefab("thulecite_pieces")
9 iceberg.Transform:SetPosition(pt.x, pt.y, pt.z)
10 iceberg.AnimState:SetBank("ice_boulder")
11 iceberg.AnimState:SetBuild("ice_boulder")
12 iceberg.AnimState:PlayAnimation("full")
13 iceberg.Transform:SetScale(2, 2, 2)
14 iceberg:AddComponent("named")
15 iceberg.components.named:SetName("Ice")
16 local minimap = iceberg.entity:AddMiniMapEntity()
17 minimap:SetIcon( "iceboulder.png" )
18 MakeObstaclePhysics(iceberg, 1)
19 MakeLargeBurnable(iceberg)
20 iceberg.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
21 iceberg.entity:AddLight()
22 iceberg.Light:SetFalloff(1)
23 iceberg.Light:SetIntensity(.8)
24 iceberg.Light:SetRadius(7)
25 iceberg.Light:SetColour(255/255,255/255,255/255)
26 iceberg.Light:Enable(true)
27 iceberg:RemoveComponent("edible")
28 iceberg:RemoveComponent("tradable")
29 iceberg:RemoveComponent("inventoryitem")
30 iceberg:RemoveComponent("stackable")
31 iceberg:RemoveComponent("bait")
32 iceberg:RemoveComponent("repairer")
33 iceberg:RemoveComponent("deployable")
34 iceberg:RemoveTag("molebait")
35 iceberg:AddComponent("heater")
36 iceberg.components.heater.iscooler = true
37 iceberg.components.heater.heatfn = function(iceberg) return -40 end
38 iceberg:AddComponent("workable")
39 iceberg.components.workable:SetWorkAction(ACTIONS.MINE)
40 iceberg.components.workable:SetWorkLeft(30)
41 iceberg.components.workable:SetOnWorkCallback(function(iceberg)
42 iceberg.components.workable:SetWorkLeft(30)
43 local pt1 = iceberg:GetPosition()
44 if math.random()<.2 then
45 local icecream = SpawnPrefab("thulecite_pieces")
46 icecream.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 3, pt1.z+(math.random(3)-math.random(3)))
47 icecream.AnimState:SetBank("ice")
48 icecream.AnimState:SetBuild("ice")
49 icecream.AnimState:PlayAnimation("f1")
50 icecream:RemoveComponent("edible")
51 icecream:RemoveComponent("tradable")
52 icecream:RemoveComponent("stackable")
53 icecream:RemoveComponent("bait")
54 icecream:RemoveComponent("repairer")
55 icecream:RemoveComponent("deployable")
56 icecream:RemoveTag("molebait")
57 icecream:AddComponent("named")
58 icecream.components.named:SetName("Ice")
59 icecream.components.inventoryitem.imagename = "ice"
60 icecream:AddComponent("edible")
61 icecream.components.edible.foodtype = "SEEDS"
62 icecream.components.edible.healthvalue = TUNING.HEALING_TINY/2
63 icecream.components.edible.hungervalue = TUNING.CALORIES_TINY/4
64 icecream.components.edible:SetOnEatenFn(function(icecream, eater)
65 if eater and eater.components.temperature then
66 local temp = eater.components.temperature:GetCurrent()
67 eater.components.temperature:SetTemperature(temp - 70)
68 end
69 end )
70 icecream.components.edible.degrades_with_spoilage = false
71 icecream:AddTag("icecream")
72 elseif math.random()<.4 then
73 local ice = SpawnPrefab("ice")
74 ice.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 3, pt1.z+(math.random(3)-math.random(3)))
75 end
76 end )
77 iceberg.components.workable:SetOnFinishCallback(function(iceberg)
78 SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(iceberg.Transform:GetWorldPosition())
79 iceberg:Remove()
80 end )
81 iceberg:AddTag("iceberg")
82end
83local function OnDeploy (inst, pt)
84 makeiceberg(inst)
85 inst.components.stackable:Get():Remove()
86end
87 inst:AddComponent("deployable")
88 inst.components.deployable.ondeploy = OnDeploy
89local function onsave(inst, data)
90 if inst:HasTag("iceberg") then
91 data.iceberg = true
92 end
93 if inst:HasTag("icecream") then
94 data.icecream = true
95 end
96end
97local function onload(inst, data)
98 if data and data.iceberg then
99 makeiceberg(inst)
100 inst:Remove()
101 end
102 if data and data.icecream then
103 inst.AnimState:SetBank("ice")
104 inst.AnimState:SetBuild("ice")
105 inst.AnimState:PlayAnimation("f1")
106 inst:RemoveComponent("edible")
107 inst:RemoveComponent("tradable")
108 inst:RemoveComponent("stackable")
109 inst:RemoveComponent("bait")
110 inst:RemoveComponent("repairer")
111 inst:RemoveComponent("deployable")
112 inst:RemoveTag("molebait")
113 inst:AddComponent("named")
114 inst.components.named:SetName("Ice")
115 inst.components.inventoryitem.imagename = "ice"
116 inst:AddComponent("edible")
117 inst.components.edible.foodtype = "SEEDS"
118 inst.components.edible.healthvalue = TUNING.HEALING_TINY/2
119 inst.components.edible.hungervalue = TUNING.CALORIES_TINY/4
120 inst.components.edible:SetOnEatenFn(function(inst, eater)
121 if eater and eater.components.temperature then
122 local temp = eater.components.temperature:GetCurrent()
123 eater.components.temperature:SetTemperature(temp - 70)
124 end
125 end )
126 inst.components.edible.degrades_with_spoilage = false
127 inst:AddTag("icecream")
128 end
129end
130 inst.OnSave = onsave
131 inst.OnLoad = onload
132
133 即可用铥矿碎片种小冰山(拿着1个铥矿碎片对地面点鼠标右键,如果拿着多个,则不会种出来),靠近可解暑。用锄头凿冰山,有一定概率获得冰和永冻冰(不会腐烂且不可堆叠的是永冻冰),永冻冰可食用,吃了能降温,如果没有中暑就不要吃,否则会冻伤。不想要小冰山了,烧掉即可。不要与“用铥矿碎片种猴子桶”一同修改