饥荒mod制作吧 关注:2,778贴子:11,854
  • 3回复贴,共1

饥荒人物mod提问

只看楼主收藏回复

一个饥荒联机版人物的mod,yuki,她的作者设定她只能吃素,问题来了,用了海难体验mod后,中毒,吃不了解毒剂,有大神能教教我怎么改代码吗?


1楼2020-01-08 19:19回复
    代码如下
    -- This initializes for the server only. Components are added here.
    local master_postinit = function(inst)
    -- choose which sounds this character will play
    inst.soundsname = "tecolin"
    -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
    --inst.talker_path_override = "dontstarve_DLC001/characters/"
    -- Stats
    inst.components.health:SetMaxHealth(150)
    inst.components.hunger:SetMax(150)
    inst.components.sanity:SetMax(200)
    inst.components.temperature.mintemp = 5
    inst.components.freezable:SetResistance(300)
    inst.components.eater:SetDiet({FOODGROUP.OMNI}, {FOODTYPE.VEGGIE, FOODTYPE.SEEDS, FOODTYPE.GENERIC})
    inst:AddComponent("heater")
    inst.components.heater.heatfn = function() return -15 end
    inst.components.heater:SetThermics(false, true)
    inst.components.health.fire_damage_scale = 1.5
    inst.components.temperature.overheattemp = 50
    inst.components.combat.damagemultiplier = TUNING.WENDY_DAMAGE_MULT
    inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE
    inst.OnLoad = onload
    inst.OnNewSpawn = onload
    inst.components.sanity.custom_rate_fn = sanityfn
    local refreshTime = 1/5
    inst:DoPeriodicTask(refreshTime, function() runner(inst, refreshTime) end)
    inst:WatchWorldState("season", WatchSeason )
    WatchSeason( inst, TheWorld.state.season )
    inst:WatchWorldState("isfullmoon", OnIsFullmoon)
    OnIsFullmoon(inst, TheWorld.state.isfullmoon)
    inst:ListenForEvent("killed", onkilled)
    inst.components.eater:SetOnEatFn(oneat)


    2楼2020-01-08 19:20
    回复
      ps:最好是由只能吃素这个设定改为不吃肉的设定


      3楼2020-01-08 19:22
      回复
        要让这个yuki角色可以吃解毒剂,你需要在代码这里加一个代码段: inst.components.eater:SetOnEatFn(function(inst, food) if 网页链接 == "antivenom" then --如果物为解毒剂 inst.components.poisonable:Cure() --使用poisonable组件中的"Cure"方法治愈中毒 inst.SoundEmitter:PlaySound("dontstarve/common/balloon") --播放一个音效表示治愈了中毒 return true --返回真表示吃了解毒剂成功 else return inst.components.eater:Oneat(food) --否则按照原有的吃食物的规则处理 end end) 这个代码会覆盖之前的oneat函数,当玩家吃解毒剂时会自动触发解毒操作。


        IP属地:四川来自Android客户端6楼2023-08-30 11:46
        回复