第212页:许愿池
展开二一二.许愿池(给池塘黄金消顽皮值,天上有机会下黄金雨,接到就是你的)
用记事本打开游戏目录\data\scripts\prefabs\pond.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function ShouldAcceptItem(inst, item)
if item.prefab == "goldnugget" then
return true
end
return false
end
local function OnGetItemFromPlayer(inst, giver, item)
if GetPlayer().components.kramped and GetPlayer().components.kramped.threshold > 0 then
GetPlayer().components.kramped.threshold = GetPlayer().components.kramped.threshold -1
GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/krampus/beenbad_lvl3")
end
if math.random()<.1 then
GetPlayer().SoundEmitter:PlaySound("dontstarve/music/music_hoedown", "beavermusic")
inst:StartThread(function()
for k = 1, 50 do
local pt = Vector3(giver.Transform:GetWorldPosition())
local gold = SpawnPrefab("goldnugget")
gold.Transform:SetPosition(pt.x+(math.random(5)-math.random(5)), 20, pt.z+(math.random(5)-math.random(5)))
gold.components.inventoryitem.canbepickedup = false
inst:DoTaskInTime(1.8, function()
local pos = Vector3(gold.Transform:GetWorldPosition())
local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 2)
for k,v in pairs(ents) do
if v:HasTag("player") then
v.components.inventory:GiveItem(gold)
end
end
end)
inst:DoTaskInTime(2, function()
local pt2 = gold:GetPosition()
if not gold.components.inventoryitem:IsHeld() then
GetPlayer().SoundEmitter:PlaySound("dontstarve/common/stone_drop")
SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(pt2.x, 0, pt2.z)
gold:Remove()
else
gold.components.inventoryitem.canbepickedup = true
end
end)
Sleep(1)
end
GetPlayer().SoundEmitter:KillSound("beavermusic")
end)
end
end
inst:AddComponent("trader")
inst.components.trader.onaccept = OnGetItemFromPlayer
inst.components.trader:SetAcceptTest(ShouldAcceptItem)
即可拿着黄金对池塘点左键,每次消减一点顽皮值(杀小动物的惩罚点数),并发出喘息声,如果没有喘息声,表示你的顽皮值已经为零,罪已经赎清了。许愿的过程中,天上有一定概率下起黄金雨(50个黄金),黄金落地弹起的刹那,如果你接到就归你了(跑到黄金掉落位置),否则会摔碎,试试你的反应能力吧
更多相关内容请关注:饥荒专区
责任编辑:Shy夏夏