nirasa Posted March 31, 2023 Share Posted March 31, 2023 In 2015, I created a snowman character named Wilan. Now I want to improve his features and customize the DLC Shipwrecked and Hamlet. I want to change his size with the season change and add or subtract sanity, hunger and health. Everything works in the base game DS, in RoG and in Hamlet. It doesn't work in Shipwrecked because only the base options from DS are in that game. Please check the code and advise what I'm doing wrong. I've been agonizing over this problem for a week now, but I can't find a solution. I have attached wilan.lua and modmain.lua. Sorry for my English, because I don't speak English. (translator Deepl) Thank You. modmain.lua Spoiler GetPlayer = GLOBAL.GetPlayer GetWorld = GLOBAL.GetWorld local ACTIONS = GLOBAL.ACTIONS local STRINGS = GLOBAL.STRINGS local require = GLOBAL.require local Ingredient = GLOBAL.Ingredient local RECIPETABS = GLOBAL.RECIPETABS local TECH = GLOBAL.TECH --local TUNING = GLOBAL.TUNING -- The character select screen lines STRINGS.CHARACTER_TITLES.wilan = "Wilan - The Snowman" STRINGS.CHARACTER_NAMES.wilan = "I am beautiful a snowman" STRINGS.CHARACTER_DESCRIPTIONS.wilan = "*Loves the cold and hates any heat\n*Low health/sanity heals ice\n*Is immune to eat from monsters" STRINGS.CHARACTER_QUOTES.wilan = "\"I love Winter\"" --povoluje debug nástroje, CTRL+R skočí ze hry do hlavního menu a znovu načte všechny skripty; pravý Shift skočí z hlavní nabídky přímo do hry, která je v prvním slotu; místo toho můžete použít '0', abyste skočili do jeskyní; T - na mapě přemístí okamžitě postavu na místo kde je šipka. --GLOBAL.CHEATS_ENABLED = true --GLOBAL.require( 'debugkeys' ) PrefabFiles = { "wilan", "vlocka", } Assets = { Asset( "IMAGE", "images/saveslot_portraits/wilan.tex" ), Asset( "ATLAS", "images/saveslot_portraits/wilan.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/wilan.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/wilan.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/wilan_silho.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/wilan_silho.xml" ), Asset( "IMAGE", "bigportraits/wilan.tex" ), Asset( "ATLAS", "bigportraits/wilan.xml" ), Asset( "IMAGE", "images/map_icons/wilan.tex" ), Asset( "ATLAS", "images/map_icons/wilan.xml" ), Asset( "IMAGE", "images/map_icons/vlocka.tex" ), Asset( "ATLAS", "images/map_icons/vlocka.xml" ), Asset( "SOUNDPACKAGE", "sound/wilan.fev" ), Asset( "SOUND", "sound/wilan.fsb" ), } -- Let the game know character is male, female, or robot table.insert(GLOBAL.CHARACTER_GENDERS.ROBOT, "wilan") function AddMap(inst) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( inst.prefab .. ".tex" ) end AddPrefabPostInit("vlocka", AddMap) AddMinimapAtlas("images/map_icons/wilan.xml") AddMinimapAtlas("images/map_icons/vlocka.xml") AddModCharacter("wilan") RemapSoundEvent( "dontstarve/characters/wilan/death_voice", "wilan/sound/death_voice" ) RemapSoundEvent( "dontstarve/characters/wilan/hurt", "wilan/sound/hurt" ) RemapSoundEvent( "dontstarve/characters/wilan/talk_LP", "wilan/sound/talk_LP" ) local default_inv = {""} local function setStarterInventory(inst, custom_inv) local st_inv = inst.components.inventory.starting_inventory if (st_inv) then for k,v in pairs(default_inv) do table.insert(st_inv, v) end else inst.components.inventory.starting_inventory = default_inv end if (custom_inv) then for k,v in pairs(custom_inv) do table.insert(inst.components.inventory.starting_inventory, v) end end end local function makePostInit(custom_inv) return function (inst) setStarterInventory(inst, custom_inv) end end AddPrefabPostInit("ice", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 25 inst.components.edible.hungervalue = 25 inst.components.edible.sanityvalue = 50 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("icecream", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 25 inst.components.edible.hungervalue = 25 inst.components.edible.sanityvalue = 50 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("watermelonicle", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 3 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 20 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("watermelon", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 3 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 7.5 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("watermelon_cooked", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 3 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 7.5 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("bananapop", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 20 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 33 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("jellyopop", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 20 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 6 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("frozenbananadaiquiri", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 30 inst.components.edible.hungervalue = 18.75 inst.components.edible.sanityvalue = 15 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("ceviche", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 20 inst.components.edible.hungervalue = 25 inst.components.edible.sanityvalue = 5 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("gazpacho", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 3 inst.components.edible.hungervalue = 25 inst.components.edible.sanityvalue = 10 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("icedtea", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 3 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 33 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("fruitmedley", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 20 inst.components.edible.hungervalue = 25 inst.components.edible.sanityvalue = 5 inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP inst.components.edible.temperatureduration = TUNING.FOOD_TEMP_BRIEF * 8 end end) AddPrefabPostInit("red_cap", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("red_cap_cooked", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 1 inst.components.edible.hungervalue = 1 inst.components.edible.sanityvalue = 5 end end) AddPrefabPostInit("green_cap", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("green_cap_cooked", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = 15 end end) AddPrefabPostInit("blue_cap", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 20 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("blue_cap_cooked", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = 10 end end) AddPrefabPostInit("glommerfuel", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 40 inst.components.edible.hungervalue = 9.375 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("monsterlasagna", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 37.5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("monstermeat", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 18.75 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("cookedmonstermeat", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 18.75 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("coral_brain", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 10 inst.components.edible.sanityvalue = 50 end end) AddPrefabPostInit("drumstick", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("smallmeat", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("meat", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 25 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("pepper", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 9.375 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("pepper_cooked", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 9.375 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("mysterymeat", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("moon_cap_coocked", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 10 end end) AddPrefabPostInit("rottenegg", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("milkywhites", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 8 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("spoiled_food", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("mussel", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("limpets", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("phlegm", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 12.5 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("shark_fin", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 20 inst.components.edible.hungervalue = 25 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("deerclops_eyerball", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 60 inst.components.edible.hungervalue = 75 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("tigereye", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 60 inst.components.edible.hungervalue = 75 inst.components.edible.sanityvalue = 0 end end) AddPrefabPostInit("minotaurhorn", function(inst) if GetPlayer().prefab == "wilan" then print "caneatice" inst:AddComponent("edible") inst.components.edible.healthvalue = 60 inst.components.edible.hungervalue = 75 inst.components.edible.sanityvalue = 0 end end) local function itemtest(inst, item, slot) --imunní na skažené a jedovaté potraviny return (item.components.edible and item.components.perishable) or item.prefab == "spoiled_food" or item.prefab == "rottenegg" or item.prefab == "heatrock" or item:HasTag("frozen") or item:HasTag("icebox_valid") end function WilanPostInit(wilan) local vlocka = Recipe("vlocka", {Ingredient("ice", 4),Ingredient("silk", 2)}, RECIPETABS.WAR, TECH.NONE) vlocka.atlas=GLOBAL.resolvefilepath("images/inventoryimages/vlocka.xml") vlocka.image="vlocka.tex" end AddSimPostInit(function(inst) if inst.prefab == "wilan" then WilanPostInit(inst) end end) AddPrefabPostInit("Wilan", function(inst) if inst.components.freezable then inst:RemoveComponent("freezable") end end) local wilan_inv = {"blueamulet"} AddPrefabPostInit("wilan", makePostInit(wilan_inv) ) wilan.lua Spoiler local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), -- Vlastni charakter Asset( "ANIM", "anim/wilan.zip" ), Asset( "ANIM", "anim/wilan_mighty.zip" ), Asset( "ANIM", "anim/wilan_skinny.zip" ), Asset( "ANIM", "anim/swap_vlocka.zip" ), Asset( "ANIM", "anim/vlocka.zip" ), } local prefabs = { } local start_inv = { -- Custom starting items "vlocka", "ice", "ice", "ice", "ice", "ice", "ice", "ice", "ice", "ice", "ice", } local function updatestats(inst) local health_percent = inst.components.health:GetPercent() if GetSeasonManager():IsWinter() or GetSeasonManager():IsHurricaneStorm() or GetSeasonManager():IsHumidSeason() then inst.Transform:SetScale(1.2, 1.2, 1.2) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2) inst.components.health:SetMaxHealth(230) inst.components.hunger:SetMax(200) inst.components.sanity:SetMax(230) inst.components.sanity.dapperness = 0.4 inst.components.health:StartRegen(1, 5) inst.components.hunger.hungerrate = -1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = 1.2 inst.AnimState:SetBuild( "wilan_mighty" ) elseif GetSeasonManager():IsSummer() or GetSeasonManager():IsDrySeason() or GetSeasonManager():IsLushSeason() then inst.Transform:SetScale(.9, .9, .9) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1) inst.components.health:SetMaxHealth(170) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(170) inst.components.sanity.dapperness = -0.4 inst.components.health:StartRegen(-1, 5) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = .9 inst.AnimState:SetBuild( "wilan_skinny" ) else inst.Transform:SetScale(1., 1., 1.) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1) inst.components.health:SetMaxHealth(200) inst.components.hunger:SetMax(170) inst.components.sanity:SetMax(200) inst.components.combat.damagemultiplier = 1 inst.AnimState:SetBuild( "wilan" ) end end local function updatestats1(inst) local health_percent = inst.components.health:GetPercent() if GetSeasonManager():IsWinter() then inst.Transform:SetScale(1.1, 1.1, 1.1) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.1) inst.components.health:SetMaxHealth(230) inst.components.hunger:SetMax(200) inst.components.sanity:SetMax(230) inst.components.sanity.dapperness = 0.4 inst.components.health:StartRegen(1, 5) inst.components.hunger.hungerrate = -1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = 1.3 inst.AnimState:SetBuild( "wilan_mighty" ) elseif GetSeasonManager():IsSummer() then inst.Transform:SetScale(.9, .9, .9) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1) inst.components.health:SetMaxHealth(170) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(170) inst.components.sanity.dapperness = -0.4 inst.components.health:StartRegen(-1, 5) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = .9 inst.AnimState:SetBuild( "wilan_skinny" ) end end local fn = function(inst) inst.soundsname = "wilan" inst.MiniMapEntity:SetIcon( "wilan.tex" ) inst.components.talker.colour = Vector3(110/255, 167/255, 255/255, 0) inst.components.health.fire_damage_scale = 4 inst.components.health.canheal = false inst.components.sanity.neg_aura_mult = 1.1 --multiplikátor snížení sanity odčehokoli inst.components.sanity.night_drain_mult = 1.2 --multiplikátor snížení sanity kvůli noci inst:RemoveTag("poisonable") --imunní vůči jedu inst.components.health.poison_damage_scale = 0 inst.components.sanity.poison_damage_scale = 0 inst.components.hunger.poison_damage_scale = 0 inst:AddComponent("eater") --lze jíst zkažené jídlo inst.components.eater.ignoresspoilage = true inst.components.eater.strongstomach = true inst.components.eater.monsterimmune = true inst.components.eater:SetCanEatHorrible() inst.components.locomotor.enablegroundspeedmultiplier = true inst.components.combat.attackrange = 4 inst.components.combat.hitrange = 3 inst.components.combat.min_attack_period = 0.05 inst.components.temperature.maxtemp = 69 -- prrehraati je prri 70°C inst.components.temperature.mintemp = 20 -- minimum je -25°C, pri 15˚C zacne mrznout -- inst.components.temperature.inherentinsulation = 500 -- inst.components.freezable:SetResistance(6) -- inst.components.temperature.freezetemp = -15 if inst.components.freezable then inst:RemoveComponent("freezable")end --imunní vůči zmrznutí inst:AddTag("seeds") inst:AddTag("fridge") --funkce lednice, 1.5x --inst:AddTag("lowcool") --nízké chlazení - podle snow chester, 2x local function CheckMoisture(inst) --při jaké vlhkosti začne regenerace if inst.components.moisture then local m = inst.components.moisture if m:GetMoisture() > 5 and not inst:HasTag("moisty") then inst:AddTag("moisty") inst.components.sanity.dapperness = 0.3 inst.components.health:StartRegen(1, 5) inst.components.hunger.hungerrate = -0.4 * TUNING.WILSON_HUNGER_RATE end if m:GetMoisture() < 5 and inst:HasTag("moisty") then inst:RemoveTag("moisty") inst.components.sanity.dapperness = 0 inst.components.health:StartRegen(0, 0) inst.components.hunger.hungerrate = TUNING.WILSON_HUNGER_RATE end end end inst:DoPeriodicTask( 0.0, function(inst) CheckMoisture(inst) end) if IsDLCEnabled(REIGN_OF_GIANTS) or IsDLCEnabled(CAPY_DLC) or IsDLCEnabled(PORKLAND_DLC) then inst:ListenForEvent( "seasonChange", function() updatestats(inst) end , GetWorld()) updatestats(inst) else inst:ListenForEvent( "seasonChange", function() updatestats1(inst) end , GetWorld()) updatestats1(inst) end end return MakePlayerCharacter("wilan", prefabs, assets, fn, start_inv) Link to comment Share on other sites More sharing options...
nirasa Posted April 8, 2023 Author Share Posted April 8, 2023 The Snowman is already changing properly according to the seasons. He doesn't turn into a big character only in the Shipwrecked DLC in the hurricane season.. But I hope nobody minds. I changed the code in the file. Maybe there's still a bug. I don't know. Spoiler local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), -- Vlastni charakter Asset( "ANIM", "anim/wilan.zip" ), Asset( "ANIM", "anim/wilan_mighty.zip" ), Asset( "ANIM", "anim/wilan_skinny.zip" ), Asset( "ANIM", "anim/swap_vlocka.zip" ), Asset( "ANIM", "anim/vlocka.zip" ), } local prefabs = { } local start_inv = { -- Custom starting items "vlocka", "ice", "ice", "ice", "ice", "ice", "ice", "ice", "ice", "ice", "ice", } local fn = function(inst) inst.soundsname = "wilan" inst.MiniMapEntity:SetIcon( "wilan.tex" ) inst.components.talker.colour = Vector3(110/255, 167/255, 255/255, 0) inst.components.health.fire_damage_scale = 4 inst.components.health.canheal = false inst.components.sanity.neg_aura_mult = 0.1 --multiplikátor snížení sanity odčehokoli inst.components.sanity.night_drain_mult = 0.2 --multiplikátor snížení sanity kvůli noci inst:RemoveTag("poisonable") --imunní vůči jedu inst.components.health.poison_damage_scale = 0 inst.components.sanity.poison_damage_scale = 0 inst.components.hunger.poison_damage_scale = 0 inst:AddComponent("eater") --lze jíst zkažené jídlo inst.components.eater.ignoresspoilage = true inst.components.eater.strongstomach = true inst.components.eater.monsterimmune = true inst.components.eater:SetCanEatHorrible() inst.components.locomotor.enablegroundspeedmultiplier = true inst.components.combat.attackrange = 4 inst.components.combat.hitrange = 3 inst.components.combat.min_attack_period = 0.05 -- inst.components.temperature.maxtemp = 80 -- prrehraati je prri 70°C inst.components.temperature.mintemp = 20 -- minimum je -25°C, pri 15˚C zacne mrznout -- inst.components.temperature.inherentinsulation = 500 -- inst.components.freezable:SetResistance(6) -- inst.components.temperature.freezetemp = -15 if inst.components.freezable then inst:RemoveComponent("freezable")end --imunní vůči zmrznutí inst:AddTag("seeds") inst:AddTag("fridge") --funkce lednice, 1.5x inst:DoTaskInTime( 0.1, function(inst) --při vlhkosti pomalu obnovuje rozum,hlad,zdraví if inst.components.moisture then local m = inst.components.moisture if m:GetMoisture() then TUNING.MOISTURE_SANITY_PENALTY_MAX = 0.3 end end end) inst:ListenForEvent("seasonChange", function(it, data) --sezonní změna postavy if data.season == SEASONS.WINTER then inst.Transform:SetScale(1.2, 1.2, 1.2) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2) inst.components.health:SetMaxHealth(230) inst.components.hunger:SetMax(200) inst.components.sanity:SetMax(230) inst.components.sanity.dapperness = 0.4 inst.components.health:StartRegen(1, 5) inst.components.hunger.hungerrate = -1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = 1.2 inst.AnimState:SetBuild( "wilan_mighty" ) elseif data.season == SEASONS.WET then --opraveno z HURRICANE na spráné WET inst.Transform:SetScale(1.2, 1.2, 1.2) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2) inst.components.health:SetMaxHealth(230) inst.components.hunger:SetMax(200) inst.components.sanity:SetMax(230) inst.components.sanity.dapperness = 0.4 inst.components.health:StartRegen(1, 5) inst.components.hunger.hungerrate = -1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = 1.2 inst.AnimState:SetBuild( "wilan_mighty" ) elseif data.season == SEASONS.HUMID then inst.Transform:SetScale(1.2, 1.2, 1.2) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2) inst.components.health:SetMaxHealth(230) inst.components.hunger:SetMax(200) inst.components.sanity:SetMax(230) inst.components.sanity.dapperness = 0.4 inst.components.health:StartRegen(1, 5) inst.components.hunger.hungerrate = -1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = 1.2 inst.AnimState:SetBuild( "wilan_mighty" ) elseif data.season == SEASONS.SUMMER then inst.Transform:SetScale(.9, .9, .9) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1) inst.components.health:SetMaxHealth(170) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(170) inst.components.sanity.dapperness = -0.4 inst.components.health:StartRegen(-1, 5) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = .9 inst.AnimState:SetBuild( "wilan_skinny" ) elseif data.season == SEASONS.DRY then inst.Transform:SetScale(.9, .9, .9) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1) inst.components.health:SetMaxHealth(170) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(170) inst.components.sanity.dapperness = -0.4 inst.components.health:StartRegen(-1, 5) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = .9 inst.AnimState:SetBuild( "wilan_skinny" ) elseif data.season == SEASONS.LUSH then inst.Transform:SetScale(.9, .9, .9) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1) inst.components.health:SetMaxHealth(170) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(170) inst.components.sanity.dapperness = -0.4 inst.components.health:StartRegen(-1, 5) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = .9 inst.AnimState:SetBuild( "wilan_skinny" ) else inst.Transform:SetScale(1., 1., 1.) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1) inst.components.health:SetMaxHealth(200) inst.components.hunger:SetMax(170) inst.components.sanity:SetMax(200) inst.components.combat.damagemultiplier = 1 inst.AnimState:SetBuild( "wilan" ) end end, GetWorld()) inst:PushEvent("seasonChange") end local function Update(inst, dt) if inst.components.perishable then local seasonmanager = GetSeasonManager() local modifier = 1 local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner or nil if owner then if owner:HasTag("fridge") then if inst:HasTag("frozen") and not owner:HasTag("nocool") and not owner:HasTag("lowcool") then modifier = TUNING.PERISH_COLD_FROZEN_MULT else modifier = TUNING.PERISH_COLD_FROZEN_MULT end elseif owner:HasTag("spoiler") and owner:HasTag("poison") then modifier = TUNING.PERISH_POISON_MULT elseif owner:HasTag("spoiler") then modifier = TUNING.PERISH_GROUND_MULT end else modifier = TUNING.PERISH_GROUND_MULT end -- Cool off hot foods over time (faster if in a fridge) if inst.components.edible and inst.components.edible.temperaturedelta and inst.components.edible.temperaturedelta > 0 then if owner and owner:HasTag("fridge") then if not owner:HasTag("nocool") then inst.components.edible.temperatureduration = inst.components.edible.temperatureduration - 1 end elseif seasonmanager and seasonmanager:GetCurrentTemperature() < TUNING.OVERHEAT_TEMP - 5 then inst.components.edible.temperatureduration = inst.components.edible.temperatureduration - .25 end if inst.components.edible.temperatureduration < 0 then inst.components.edible.temperatureduration = 0 end end local mm = GetWorld().components.moisturemanager if mm:IsEntityWet(inst) then modifier = modifier * TUNING.PERISH_WET_MULT end if seasonmanager and seasonmanager:GetCurrentTemperature() < 0 then if inst:HasTag("frozen") and not inst.components.perishable.frozenfiremult then modifier = TUNING.PERISH_COLD_FROZEN_MULT else modifier = modifier * TUNING.PERISH_WINTER_MULT end end if inst.components.perishable.frozenfiremult then modifier = modifier * TUNING.PERISH_FROZEN_FIRE_MULT end if seasonmanager and seasonmanager:GetCurrentTemperature() > TUNING.OVERHEAT_TEMP then modifier = modifier * TUNING.PERISH_SUMMER_MULT end local aporkalypse = GetAporkalypse() if aporkalypse and aporkalypse:IsActive() then modifier = modifier * TUNING.PERISH_APORKALYPSE_MULT end modifier = modifier * TUNING.PERISH_GLOBAL_MULT local old_val = inst.components.perishable.perishremainingtime local delta = dt or (10 + math.random()*FRAMES*8) inst.components.perishable.perishremainingtime = inst.components.perishable.perishremainingtime - delta*modifier if math.floor(old_val*100) ~= math.floor(inst.components.perishable.perishremainingtime*100) then inst:PushEvent("perishchange", {percent = inst.components.perishable:GetPercent()}) end --trigger the next callback if inst.components.perishable.perishremainingtime <= 0 then inst.components.perishable:Perish() end end end return MakePlayerCharacter("wilan", prefabs, assets, fn, start_inv) Edit: I know where the problem is with hurricane season. Why isn't this season called "Hurricane", it's called "Wet"? Link to comment Share on other sites More sharing options...
KXWl1 Posted April 10, 2023 Share Posted April 10, 2023 On 4/8/2023 at 8:19 PM, nirasa said: The Snowman is already changing properly according to the seasons. He doesn't turn into a big character only in the Shipwrecked DLC in the hurricane season.. But I hope nobody minds. I changed the code in the file. Maybe there's still a bug. I don't know. Reveal hidden contents local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), -- Vlastni charakter Asset( "ANIM", "anim/wilan.zip" ), Asset( "ANIM", "anim/wilan_mighty.zip" ), Asset( "ANIM", "anim/wilan_skinny.zip" ), Asset( "ANIM", "anim/swap_vlocka.zip" ), Asset( "ANIM", "anim/vlocka.zip" ), } local prefabs = { } local start_inv = { -- Custom starting items "vlocka", "ice", "ice", "ice", "ice", "ice", "ice", "ice", "ice", "ice", "ice", } local fn = function(inst) inst.soundsname = "wilan" inst.MiniMapEntity:SetIcon( "wilan.tex" ) inst.components.talker.colour = Vector3(110/255, 167/255, 255/255, 0) inst.components.health.fire_damage_scale = 4 inst.components.health.canheal = false inst.components.sanity.neg_aura_mult = 0.1 --multiplikátor snížení sanity odčehokoli inst.components.sanity.night_drain_mult = 0.2 --multiplikátor snížení sanity kvůli noci inst:RemoveTag("poisonable") --imunní vůči jedu inst.components.health.poison_damage_scale = 0 inst.components.sanity.poison_damage_scale = 0 inst.components.hunger.poison_damage_scale = 0 inst:AddComponent("eater") --lze jíst zkažené jídlo inst.components.eater.ignoresspoilage = true inst.components.eater.strongstomach = true inst.components.eater.monsterimmune = true inst.components.eater:SetCanEatHorrible() inst.components.locomotor.enablegroundspeedmultiplier = true inst.components.combat.attackrange = 4 inst.components.combat.hitrange = 3 inst.components.combat.min_attack_period = 0.05 -- inst.components.temperature.maxtemp = 80 -- prrehraati je prri 70°C inst.components.temperature.mintemp = 20 -- minimum je -25°C, pri 15˚C zacne mrznout -- inst.components.temperature.inherentinsulation = 500 -- inst.components.freezable:SetResistance(6) -- inst.components.temperature.freezetemp = -15 if inst.components.freezable then inst:RemoveComponent("freezable")end --imunní vůči zmrznutí inst:AddTag("seeds") inst:AddTag("fridge") --funkce lednice, 1.5x inst:DoTaskInTime( 0.1, function(inst) --při vlhkosti pomalu obnovuje rozum,hlad,zdraví if inst.components.moisture then local m = inst.components.moisture if m:GetMoisture() then TUNING.MOISTURE_SANITY_PENALTY_MAX = 0.3 end end end) inst:ListenForEvent("seasonChange", function(it, data) --sezonní změna postavy if data.season == SEASONS.WINTER then inst.Transform:SetScale(1.2, 1.2, 1.2) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2) inst.components.health:SetMaxHealth(230) inst.components.hunger:SetMax(200) inst.components.sanity:SetMax(230) inst.components.sanity.dapperness = 0.4 inst.components.health:StartRegen(1, 5) inst.components.hunger.hungerrate = -1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = 1.2 inst.AnimState:SetBuild( "wilan_mighty" ) elseif data.season == SEASONS.WET then --opraveno z HURRICANE na spráné WET inst.Transform:SetScale(1.2, 1.2, 1.2) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2) inst.components.health:SetMaxHealth(230) inst.components.hunger:SetMax(200) inst.components.sanity:SetMax(230) inst.components.sanity.dapperness = 0.4 inst.components.health:StartRegen(1, 5) inst.components.hunger.hungerrate = -1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = 1.2 inst.AnimState:SetBuild( "wilan_mighty" ) elseif data.season == SEASONS.HUMID then inst.Transform:SetScale(1.2, 1.2, 1.2) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2) inst.components.health:SetMaxHealth(230) inst.components.hunger:SetMax(200) inst.components.sanity:SetMax(230) inst.components.sanity.dapperness = 0.4 inst.components.health:StartRegen(1, 5) inst.components.hunger.hungerrate = -1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = 1.2 inst.AnimState:SetBuild( "wilan_mighty" ) elseif data.season == SEASONS.SUMMER then inst.Transform:SetScale(.9, .9, .9) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1) inst.components.health:SetMaxHealth(170) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(170) inst.components.sanity.dapperness = -0.4 inst.components.health:StartRegen(-1, 5) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = .9 inst.AnimState:SetBuild( "wilan_skinny" ) elseif data.season == SEASONS.DRY then inst.Transform:SetScale(.9, .9, .9) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1) inst.components.health:SetMaxHealth(170) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(170) inst.components.sanity.dapperness = -0.4 inst.components.health:StartRegen(-1, 5) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = .9 inst.AnimState:SetBuild( "wilan_skinny" ) elseif data.season == SEASONS.LUSH then inst.Transform:SetScale(.9, .9, .9) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1) inst.components.health:SetMaxHealth(170) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(170) inst.components.sanity.dapperness = -0.4 inst.components.health:StartRegen(-1, 5) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = .9 inst.AnimState:SetBuild( "wilan_skinny" ) else inst.Transform:SetScale(1., 1., 1.) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1) inst.components.health:SetMaxHealth(200) inst.components.hunger:SetMax(170) inst.components.sanity:SetMax(200) inst.components.combat.damagemultiplier = 1 inst.AnimState:SetBuild( "wilan" ) end end, GetWorld()) inst:PushEvent("seasonChange") end local function Update(inst, dt) if inst.components.perishable then local seasonmanager = GetSeasonManager() local modifier = 1 local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner or nil if owner then if owner:HasTag("fridge") then if inst:HasTag("frozen") and not owner:HasTag("nocool") and not owner:HasTag("lowcool") then modifier = TUNING.PERISH_COLD_FROZEN_MULT else modifier = TUNING.PERISH_COLD_FROZEN_MULT end elseif owner:HasTag("spoiler") and owner:HasTag("poison") then modifier = TUNING.PERISH_POISON_MULT elseif owner:HasTag("spoiler") then modifier = TUNING.PERISH_GROUND_MULT end else modifier = TUNING.PERISH_GROUND_MULT end -- Cool off hot foods over time (faster if in a fridge) if inst.components.edible and inst.components.edible.temperaturedelta and inst.components.edible.temperaturedelta > 0 then if owner and owner:HasTag("fridge") then if not owner:HasTag("nocool") then inst.components.edible.temperatureduration = inst.components.edible.temperatureduration - 1 end elseif seasonmanager and seasonmanager:GetCurrentTemperature() < TUNING.OVERHEAT_TEMP - 5 then inst.components.edible.temperatureduration = inst.components.edible.temperatureduration - .25 end if inst.components.edible.temperatureduration < 0 then inst.components.edible.temperatureduration = 0 end end local mm = GetWorld().components.moisturemanager if mm:IsEntityWet(inst) then modifier = modifier * TUNING.PERISH_WET_MULT end if seasonmanager and seasonmanager:GetCurrentTemperature() < 0 then if inst:HasTag("frozen") and not inst.components.perishable.frozenfiremult then modifier = TUNING.PERISH_COLD_FROZEN_MULT else modifier = modifier * TUNING.PERISH_WINTER_MULT end end if inst.components.perishable.frozenfiremult then modifier = modifier * TUNING.PERISH_FROZEN_FIRE_MULT end if seasonmanager and seasonmanager:GetCurrentTemperature() > TUNING.OVERHEAT_TEMP then modifier = modifier * TUNING.PERISH_SUMMER_MULT end local aporkalypse = GetAporkalypse() if aporkalypse and aporkalypse:IsActive() then modifier = modifier * TUNING.PERISH_APORKALYPSE_MULT end modifier = modifier * TUNING.PERISH_GLOBAL_MULT local old_val = inst.components.perishable.perishremainingtime local delta = dt or (10 + math.random()*FRAMES*8) inst.components.perishable.perishremainingtime = inst.components.perishable.perishremainingtime - delta*modifier if math.floor(old_val*100) ~= math.floor(inst.components.perishable.perishremainingtime*100) then inst:PushEvent("perishchange", {percent = inst.components.perishable:GetPercent()}) end --trigger the next callback if inst.components.perishable.perishremainingtime <= 0 then inst.components.perishable:Perish() end end end return MakePlayerCharacter("wilan", prefabs, assets, fn, start_inv) Edit: I know where the problem is with hurricane season. Why isn't this season called "Hurricane", it's called "Wet"? In the game there are many things that their code names are different from their actual names. It is very normal. Link to comment Share on other sites More sharing options...
nirasa Posted April 10, 2023 Author Share Posted April 10, 2023 On 4/10/2023 at 10:36 AM, KXWl1 said: In the game there are many things that their code names are different from their actual names. It is very normal. Aha - ok. I'm not a programmer, so I don't know these codes well. Thank you for the explanation. Edit: The code still had errors, but I fixed them. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.