找手机游戏就上56游戏网 专业手游下载门户网站!

游戏更新 | 软件更新 | 文章更新 | 热门文章 | 推荐文章

饥荒代码怎样才能在夜晚生存?

时间:2024-05-06 02:32:14    编辑:admin

饥荒是一款经典的生存游戏,游戏中的夜晚会给玩家带来更大的挑战,因为在黑暗中玩家需要面对各种危险的生物,还要处理温度和饥饿的问题。如果你想在夜晚生存下来,那么本文将为你介绍一些有效的饥荒代码。

1. 保持温暖

在夜晚里,保持温暖是最重要的任务之一。如果你不能保持恰当的温度,就会失去生命值。因此,建立篝火是非常重要的。你可以创建一个简单的代码,以便在夜晚开启自动篝火:

local function OnNight(inst, isnight) if isnight then if not inst.components.burnable:IsBurning() then inst.components.burnable:Ignite() end end end AddPrefabPostInit("campfire", function(inst) inst:ListenForEvent("daytime", function() OnNight(inst, TheWorld.state.isnight) end, TheWorld) inst:ListenForEvent("dusktime", function() OnNight(inst, TheWorld.state.isnight) end, TheWorld) inst:ListenForEvent("nighttime", function() OnNight(inst, TheWorld.state.isnight) end, TheWorld) end)

饥荒代码怎样才能在夜晚生存?

2. 食物和水

在夜晚里,你需要确保有足够的食物和水来维持你的生命值。为此,你可以使用以下代码段创建一个简单的自动食品生产机器:

local function onDay(inst) inst.IsDay = true inst.AnimState:PlayAnimation("day_loop", true) inst.SoundEmitter:KillSound("night") end local function onNight(inst) inst.IsDay = false inst.AnimState:PlayAnimation("night_loop", true) inst.SoundEmitter:PlaySound("dontstarve/creatures/birds/chirp", "night") end local function oneat(inst) if not inst:IsAsleep() then inst.AnimState:PlayAnimation("spitfood") inst.AnimState:PushAnimation("idle", true) inst.SoundEmitter:PlaySound("dontstarve/creatures/quagmire/bat/spit") end end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.AnimState:SetBuild("kyno_quagmire_smobat") inst.AnimState:SetBank("bat") inst.AnimState:PlayAnimation("idle", true) inst:AddComponent("sleeper") inst:AddComponent("lootdropper") inst:AddComponent("inventory") inst:AddComponent("foodaffinity") inst:AddComponent("eater") inst.components.eater:SetCanLure(true) inst.components.eater:SetOnEatFn(oneat) MakeSmallBurnable(inst, TUNING.SMALL_BURNTIME) MakeSmallPropagator(inst) inst.IsDay = nil inst.OnEntitySleep = function(inst) if inst:IsAsleep() then inst.SoundEmitter:KillSound("night") end end inst.OnEntityWake = function(inst) if inst.IsDay then onDay(inst) else onNight(inst) end end inst:ListenForEvent("dusktime", function() onNight(inst) end, TheWorld) inst:ListenForEvent("daytime", function() onDay(inst) end, TheWorld) return inst end return Prefab("common/objects/kyno_quagmire_smobat", fn, )

饥荒代码怎样才能在夜晚生存?

3. 对抗敌人

在夜晚里,很多危险的生物会出现并威胁你的生命。为此,你需要做好准备来保护自己。你可以使用下面的代码段创建一个装备自动化的武器:

local function OnEquipment
相关游戏
最新游戏

玩家评论