第218页:潘多拉魔盒
展开二一八.潘多拉魔盒(用硬骨头种潘多拉魔盒,每60秒有一批怪物来袭,展开塔防吧)
用记事本打开游戏目录\data\DLC0001\scripts\prefabs\boneshard.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function makemagicbox(inst)
local pt = inst:GetPosition()
local magicbox = SpawnPrefab("boneshard")
magicbox.Transform:SetPosition(pt.x, pt.y, pt.z)
magicbox.AnimState:SetBank("pandoras_chest")
magicbox.AnimState:SetBuild("pandoras_chest")
magicbox.AnimState:PlayAnimation("closed")
magicbox.AnimState:SetMultColour(255/255,0/255,0/255,1)
magicbox.Transform:SetScale(0.8, 0.8, 0.8)
magicbox.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
local minimap = magicbox.entity:AddMiniMapEntity()
minimap:SetIcon( "pandoras_chest.png" )
magicbox:RemoveComponent("inventoryitem")
magicbox:RemoveComponent("stackable")
magicbox:RemoveComponent("deployable")
magicbox:AddTag("magicbox")
magicbox:AddComponent("workable")
magicbox.components.workable:SetWorkAction(ACTIONS.HAMMER)
magicbox.components.workable:SetWorkLeft(3)
magicbox.components.workable:SetOnFinishCallback(function(magicbox)
local pos = Vector3(magicbox.Transform:GetWorldPosition())
local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000)
for k,v in pairs(ents) do
if v:HasTag("bogey") then
SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition())
v:Remove()
end
end
SpawnPrefab("collapse_big").Transform:SetPosition(magicbox.Transform:GetWorldPosition())
GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood")
magicbox:Remove()
end )
magicbox.components.inspectable.getstatus = function(magicbox)
if not magicbox:HasTag("makebogey") then
magicbox:AddTag("makebogey")
magicbox.AnimState:PlayAnimation("open")
magicbox:DoTaskInTime(0.5, function(magicbox)
SpawnPrefab("collapse_small").Transform:SetPosition(magicbox.Transform:GetWorldPosition())
GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo")
GetPlayer().components.playercontroller:ShakeCamera(magicbox, "FULL", 2.5, 0.03, 2, 30)
local pos = Vector3(magicbox.Transform:GetWorldPosition())
local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000)
for k,v in pairs(ents) do
if v:HasTag("bogey") then
SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition())
v:Remove()
end
end
local names = {"spiderqueen","hound","firehound","icehound","killerbee","walrus","leif","leif_sparse","koalefant_summer","koalefant_winter","deerclops","merm","knight","bishop","bat"}
magicbox.name = names[math.random(#names)]
for k = 1,math.random(10,30) do
local pt0 = magicbox:GetPosition()
local ground = GetWorld()
local x = pt0.x+(math.random(50)-math.random(50))
local z = pt0.z+(math.random(50)-math.random(50))
local tile = ground.Map:GetTileAtPoint(x,0, z)
if tile ~= GROUND.IMPASSABLE and tile ~= GROUND.INVALID then
local bogey = SpawnPrefab(magicbox.name)
bogey.Transform:SetPosition(x,0,z)
bogey:AddTag("bogey")
bogey.components.combat:SetRetargetFunction(1, function(bogey)
if not bogey.components.health:IsDead() then
return FindEntity(bogey, 100, function(guy)
if guy.components.health and not guy.components.health:IsDead() then
return guy:HasTag("player")
end
end )
end
end )
bogey.components.combat:SetKeepTargetFunction(function(bogey, target) return target and target:IsValid() end )
bogey:ListenForEvent("attacked", function(bogey, data)
bogey.components.combat:SetTarget(GetPlayer())
end )
end
end
end )
magicbox.task = magicbox:DoPeriodicTask(60, function(magicbox)
SpawnPrefab("collapse_small").Transform:SetPosition(magicbox.Transform:GetWorldPosition())
GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo")
GetPlayer().components.playercontroller:ShakeCamera(magicbox, "FULL", 2.5, 0.03, 2, 30)
local pos = Vector3(magicbox.Transform:GetWorldPosition())
local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000)
for k,v in pairs(ents) do
if v:HasTag("bogey") then
SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition())
v:Remove()
end
end
local names = {"spiderqueen","hound","firehound","icehound","killerbee","walrus","leif","leif_sparse","koalefant_summer","koalefant_winter","deerclops","merm","knight","bishop","bat"}
magicbox.name = names[math.random(#names)]
for k = 1,math.random(10,30) do
local pt0 = magicbox:GetPosition()
local ground = GetWorld()
local x = pt0.x+(math.random(50)-math.random(50))
local z = pt0.z+(math.random(50)-math.random(50))
local tile = ground.Map:GetTileAtPoint(x,0, z)
if tile ~= GROUND.IMPASSABLE and tile ~= GROUND.INVALID then
local bogey = SpawnPrefab(magicbox.name)
bogey.Transform:SetPosition(x,0,z)
bogey:AddTag("bogey")
bogey.components.combat:SetRetargetFunction(1, function(bogey)
if not bogey.components.health:IsDead() then
return FindEntity(bogey, 100, function(guy)
if guy.components.health and not guy.components.health:IsDead() then
return guy:HasTag("player")
end
end )
end
end )
bogey.components.combat:SetKeepTargetFunction(function(bogey, target) return target and target:IsValid() end )
bogey:ListenForEvent("attacked", function(bogey, data)
bogey.components.combat:SetTarget(GetPlayer())
end )
end
end
end )
else
magicbox:RemoveTag("makebogey")
magicbox.AnimState:PlayAnimation("close")
GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold")
if magicbox.task then magicbox.task:Cancel() magicbox.task = nil end
local pos = Vector3(magicbox.Transform:GetWorldPosition())
local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000)
for k,v in pairs(ents) do
if v:HasTag("bogey") then
SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition())
v:Remove()
end
end
end
end
end
local function OnDeploy (inst, pt)
makemagicbox(inst)
inst.components.stackable:Get():Remove()
end
inst:AddComponent("deployable")
inst.components.deployable.ondeploy = OnDeploy
local function onsave(inst, data)
if inst:HasTag("magicbox") then
data.magicbox = true
end
end
local function onload(inst, data)
if data and data.magicbox then
makemagicbox(inst)
inst:Remove()
end
end
inst.OnSave = onsave
inst.OnLoad = onload
即可用硬骨头种潘多拉魔盒,(拿着1个硬骨头对地面点鼠标右键,如果拿着多个,则不会种出来)。鼠标左键点魔盒,可打开盒子,每60秒将吹响一次号角,预示着新一批怪物来袭,且源源不绝,充分满足你求死不得的需要。鼠标左键再次点击魔盒,可让怪物回到盒中。建议围绕魔盒修建防御设施(如牙齿陷阱、眼睛炮塔等),否则你挺不过几个60秒的。潘多拉魔盒在小地图上显示为远古箱子图标,不想要潘多拉魔盒了,用锤子砸掉即可。硬骨头靠砸碎地图上的骨架获得
更多相关内容请关注:饥荒专区
责任编辑:Shy夏夏