YN256-小冰山(用铥矿碎片种小冰山,靠近可解暑,无限开采冰和永冻冰,吃了能降温)
代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二五六.小冰山(用铥矿碎片种小冰山,靠近可解暑,无限开采冰和永冻冰,吃了能降温) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/thulecite_pieces.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function makeiceberg(inst) local pt = inst:GetPosition() local iceberg = SpawnPrefab("thulecite_pieces") iceberg.Transform:SetPosition(pt.x, pt.y, pt.z) iceberg.AnimState:SetBank("ice_boulder") iceberg.AnimState:SetBuild("ice_boulder") iceberg.AnimState:PlayAnimation("full") iceberg.Transform:SetScale(2, 2, 2) iceberg:AddComponent("named") iceberg.components.named:SetName("Ice") local minimap = iceberg.entity:AddMiniMapEntity() minimap:SetIcon( "iceboulder.png" ) MakeObstaclePhysics(iceberg, 1) MakeLargeBurnable(iceberg) iceberg.AnimState:SetBloomEffectHandle("shaders/anim.ksh") iceberg.entity:AddLight() iceberg.Light:SetFalloff(1) iceberg.Light:SetIntensity(.8) iceberg.Light:SetRadius(7) iceberg.Light:SetColour(255/255,255/255,255/255) iceberg.Light:Enable(true) iceberg:RemoveComponent("edible") iceberg:RemoveComponent("tradable") iceberg:RemoveComponent("inventoryitem") iceberg:RemoveComponent("stackable") iceberg:RemoveComponent("bait") iceberg:RemoveComponent("repairer") iceberg:RemoveComponent("deployable") iceberg:RemoveTag("molebait") iceberg:AddComponent("heater") iceberg.components.heater.iscooler = true iceberg.components.heater.heatfn = function(iceberg) return -40 end iceberg:AddComponent("workable") iceberg.components.workable:SetWorkAction(ACTIONS.MINE) iceberg.components.workable:SetWorkLeft(30) iceberg.components.workable:SetOnWorkCallback(function(iceberg) iceberg.components.workable:SetWorkLeft(30) local pt1 = iceberg:GetPosition() if math.random()<.2 then local icecream = SpawnPrefab("thulecite_pieces") icecream.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 3, pt1.z+(math.random(3)-math.random(3))) icecream.AnimState:SetBank("ice") icecream.AnimState:SetBuild("ice") icecream.AnimState:PlayAnimation("f1") icecream:RemoveComponent("edible") icecream:RemoveComponent("tradable") icecream:RemoveComponent("stackable") icecream:RemoveComponent("bait") icecream:RemoveComponent("repairer") icecream:RemoveComponent("deployable") icecream:RemoveTag("molebait") icecream:AddComponent("named") icecream.components.named:SetName("Ice") icecream.components.inventoryitem.imagename = "ice" icecream:AddComponent("edible") icecream.components.edible.foodtype = "SEEDS" icecream.components.edible.healthvalue = TUNING.HEALING_TINY/2 icecream.components.edible.hungervalue = TUNING.CALORIES_TINY/4 icecream.components.edible:SetOnEatenFn(function(icecream, eater) if eater and eater.components.temperature then local temp = eater.components.temperature:GetCurrent() eater.components.temperature:SetTemperature(temp - 70) end end ) icecream.components.edible.degrades_with_spoilage = false icecream:AddTag("icecream") elseif math.random()<.4 then local ice = SpawnPrefab("ice") ice.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 3, pt1.z+(math.random(3)-math.random(3))) end end ) iceberg.components.workable:SetOnFinishCallback(function(iceberg) SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(iceberg.Transform:GetWorldPosition()) iceberg:Remove() end ) iceberg:AddTag("iceberg") end local function OnDeploy (inst, pt) makeiceberg(inst) inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("iceberg") then data.iceberg = true end if inst:HasTag("icecream") then data.icecream = true end end local function onload(inst, data) if data and data.iceberg then makeiceberg(inst) inst:Remove() end if data and data.icecream then inst.AnimState:SetBank("ice") inst.AnimState:SetBuild("ice") inst.AnimState:PlayAnimation("f1") inst:RemoveComponent("edible") inst:RemoveComponent("tradable") inst:RemoveComponent("stackable") inst:RemoveComponent("bait") inst:RemoveComponent("repairer") inst:RemoveComponent("deployable") inst:RemoveTag("molebait") inst:AddComponent("named") inst.components.named:SetName("Ice") inst.components.inventoryitem.imagename = "ice" inst:AddComponent("edible") inst.components.edible.foodtype = "SEEDS" inst.components.edible.healthvalue = TUNING.HEALING_TINY/2 inst.components.edible.hungervalue = TUNING.CALORIES_TINY/4 inst.components.edible:SetOnEatenFn(function(inst, eater) if eater and eater.components.temperature then local temp = eater.components.temperature:GetCurrent() eater.components.temperature:SetTemperature(temp - 70) end end ) inst.components.edible.degrades_with_spoilage = false inst:AddTag("icecream") end end inst.OnSave = onsave inst.OnLoad = onload 即可用铥矿碎片种小冰山(拿着1个铥矿碎片对地面点鼠标右键,如果拿着多个,则不会种出来),靠近可解暑。用锄头凿冰山,有一定概率获得冰和永冻冰(不会腐烂且不可堆叠的是永冻冰),永冻冰可食用,吃了能降温,如果没有中暑就不要吃,否则会冻伤。不想要小冰山了,烧掉即可。不要与“用铥矿碎片种猴子桶”一同修改