Doodle Monster Posted September 23, 2025 Share Posted September 23, 2025 Hi! So I've begun work on my character's skilltree! I've tried a few methods for changeing maxhealth after Wramp unlocks the life leech skill on his skilltree. none of them have worked so far Here's the function and the prefab file: local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), -- Other assets Asset("SCRIPT", "scripts/prefabs/skilltree_wramp.lua") } -- Custom starting inventory TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.WRAMP = { "nightmarefuel", "nightmarefuel", "nightmarefuel", "nightmarefuel", } local start_inv = {} for k, v in pairs(TUNING.GAMEMODE_STARTING_ITEMS) do start_inv[string.lower(k)] = v.WRAMP end local prefabs = FlattenTree(start_inv, true) TUNING.WRAMP_HUNGER = 300 TUNING.WRAMP_SANITY = 200 TUNING.WRAMP_HEALTH = 150 -- When the character is revived from human local function onbecamehuman(inst) -- Set speed when not a ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "wramp_speed_mod", 1) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "wramp_speed_mod") end --trying placement local function GetEquippableDapperness(owner, equippable) local dapperness = equippable:GetDapperness(owner, owner.components.sanity.no_moisture_penalty) return equippable.inst:HasTag("shadow_item") and dapperness * TUNING.WAXWELL_SHADOW_ITEM_RESISTANCE or dapperness end --[[inst:ListenForEvent("sanitydelta", function(inst, data) inst.components.health:SetMaxHealth(100+(inst.components.sanity.current)) inst.components.health:DoDelta(0)end)]] --[[WANDA DAMAGE SFX then local fx_prefab = inst.age_state == "old" and (weapon:HasTag("pocketwatch") and "wanda_attack_pocketwatch_old_fx" or "wanda_attack_shadowweapon_old_fx") or inst.age_state == "normal" and (weapon:HasTag("pocketwatch") and "wanda_attack_pocketwatch_normal_fx" or "wanda_attack_shadowweapon_normal_fx") or nil if fx_prefab ~= nil then local fx = SpawnPrefab(fx_prefab) local x, y, z = target.Transform:GetWorldPosition() local radius = target:GetPhysicsRadius(.5) local angle = (inst.Transform:GetRotation() - 90) * DEGREES fx.Transform:SetPosition(x + math.sin(angle) * radius, 0, z + math.cos(angle) * radius) end Sanity function inst:ListenForEvent("sanitydelta", function(inst, data) if inst.components.sanity.current >= 30 then inst.components.combat.damagemultiplier = 1.5 elseif inst.components.sanity.current <= 30 then inst.components.combat.damagemultiplier = 2 end end ]] --TEST -- Old --[[local function WrampShadowWeaponFx(inst, data) -- The rest of the function here if inst.components.sanity:GetPercent() <= .5 then -- Code if weapon ~= nil and target ~= nil and target:IsValid() and weapon:IsValid() then local fx_prefab = "wanda_attack_shadowweapon_normal_fx" and print("NORMAL FX") or nil if fx_prefab ~= nil then local fx = SpawnPrefab(fx_prefab) local x, y, z = target.Transform:GetWorldPosition() local radius = target:GetPhysicsRadius(.5) local angle = (inst.Transform:GetRotation() - 90) * DEGREES fx.Transform:SetPosition(x + math.sin(angle) * radius, 0, z + math.cos(angle) * radius) elseif inst.components.sanity:GetPercent() >= .3 then -- Code if weapon ~= nil and target ~= nil and target:IsValid() and weapon:IsValid() then local fx_prefab = "wanda_attack_shadowweapon_old_fx" and print("BIG FX") or nil if fx_prefab ~= nil then local fx = SpawnPrefab(fx_prefab) local x, y, z = target.Transform:GetWorldPosition() local radius = target:GetPhysicsRadius(.5) local angle = (inst.Transform:GetRotation() - 90) * DEGREES fx.Transform:SetPosition(x + math.sin(angle) * radius, 0, z + math.cos(angle) * radius) end end]]-- -- New local function WrampMaxHealth(inst) if inst:HasTag("wramp_skill_leech_1") then inst.components.health:SetMaxHealth(60) else inst.components.health:SetMaxHealth(150) end end local function WrampShadowWeaponFx(inst, target) if inst:HasTag("wramp_skill_leech_1") and target.components.combat ~= nil then inst.components.sanity:DoDelta(1) inst.components.health:DoDelta(1) else if target.components.combat ~= nil then inst.components.sanity:DoDelta(0.5) inst.components.health:DoDelta(0.3) end end if target ~= nil and target:IsValid() then local sanity_percent = inst.components.sanity:GetPercent() -- Setting it to a variable so its less to write out again and again -- The below works as a glorified If statement, setting fx_prefab to either old_fx, normal_fx, or nil depending on the given conditions local fx_prefab = sanity_percent <= .5 and sanity_percent > .3 and "shadow_merm_smacked_poof_fx" or sanity_percent <= .3 and "shadow_despawn" or nil print(fx_prefab) if fx_prefab ~= nil then local fx = SpawnPrefab(fx_prefab) local x, y, z = target.Transform:GetWorldPosition() local radius = target:GetPhysicsRadius(.5) local angle = (inst.Transform:GetRotation() - 90) * DEGREES fx.Transform:SetPosition(x + math.sin(angle) * radius, 0, z + math.cos(angle) * radius) end end end -- When loading or spawning the character local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end end -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "wramp.tex" ) inst:AddTag("playermonster") inst:AddTag("monster") inst:AddTag("wramp_crafter") if inst.components.skilltreeupdater:IsActivated("wramp_hattrick") then inst:AddComponent("magician")-- Do stuff here end end local function CalculateStrength(inst, data) inst.components.combat.damagemultiplier = Remap(1 - data.newpercent, 0, 1, 1, 2) end -- This initializes for the server only. Components are added here. local master_postinit = function(inst) -- Set starting inventory inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or start_inv.default -- choose which sounds this character will play inst.soundsname = "wramp" -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used --inst.talker_path_override = "dontstarve_DLC001/characters/" -- Your character's stats -- Stats inst.components.hunger:SetMax(TUNING.WRAMP_HUNGER) inst.components.sanity:SetMax(TUNING.WRAMP_SANITY) --[[ inst.components.health:SetMaxHealth(TUNING.WRAMP_HEALTH) ]] inst:ListenForEvent("sanitydelta", CalculateStrength) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1 -- Hunger rate (optional) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.components.builder.magic_bonus = 2 --sanity loss inst.components.sanity.dapperness = -0.1 inst.components.sanity.get_equippable_dappernessfn = GetEquippableDapperness inst.components.combat.onhitotherfn = WrampShadowWeaponFx if inst.components.eater ~= nil then inst.components.eater:SetAbsorptionModifiers(.65, .65, 1) end inst.components.foodaffinity:AddPrefabAffinity("pomegranate", TUNING.AFFINITY_15_CALORIES_TINY) inst.components.foodaffinity:AddPrefabAffinity("pomegranate_cooked", TUNING.AFFINITY_15_CALORIES_SMALL) inst.OnLoad = onload inst.OnNewSpawn = onload end return MakePlayerCharacter("wramp", prefabs, assets, common_postinit, master_postinit, prefabs) I've tried listening for the event, when the player spawns and seeing if they have the skill tag then reduceing max health. I'm haveing problems geting that working if anyone know a solution that would be really appreciated! inst:ListenForEvent("ms_newplayerspawned", function(inst, data) if inst:HasTag("wramp_skill_leech_1") then inst.components.health:SetMaxHealth(60) else inst.components.health:SetMaxHealth(150) end end) Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/ Share on other sites More sharing options...
FerniFrenito Posted September 23, 2025 Share Posted September 23, 2025 have you tried putting it in OnLoad? local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end if inst:HasTag("wramp_skill_leech_1") then inst.components.health:SetMaxHealth(60) else inst.components.health:SetMaxHealth(150) end end I don't know if the component is initialized at that point, but you can try. What you want to do is have the player spawn with their maximum health changed based on your skill tree, right? Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837092 Share on other sites More sharing options...
Doodle Monster Posted September 23, 2025 Author Share Posted September 23, 2025 yeah, that's the idea. I'll test it and see if it works! Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837093 Share on other sites More sharing options...
Doodle Monster Posted September 23, 2025 Author Share Posted September 23, 2025 putting it in the on load didn't work Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837095 Share on other sites More sharing options...
Doodle Monster Posted September 23, 2025 Author Share Posted September 23, 2025 Yeah, just checked again. I do have the skill enabled so Wramp has the tag on Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837096 Share on other sites More sharing options...
Doodle Monster Posted September 23, 2025 Author Share Posted September 23, 2025 I've also tried testing if the skill is enabled set the max health -- When loading or spawning the character local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end if inst.components.skilltreeupdater:IsActivated("wramp_leech_1") then inst.components.health:SetMaxHealth(60) else inst.components.health:SetMaxHealth(150) end end Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837099 Share on other sites More sharing options...
FerniFrenito Posted September 24, 2025 Share Posted September 24, 2025 local function onload(inst) print("onload") inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end local res = inst.components.skilltreeupdater:IsActivated("wramp_leech_1") print("wramp_leech_1 is activated") print(res) if res then inst.components.health:SetMaxHealth(60) print("Max health 60") else inst.components.health:SetMaxHealth(150) print("Max health 150") end end Try that, get into a game and then go to the logs, send me which print() were written and which were not. Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837103 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 Thanks for the help! testing now! Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837106 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 Hmm, the log says something about the skill not being active, but the tag is working so it must be. Here's the log Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837107 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 (edited) actualy I think that was something else, the log says the skill is active Edited September 24, 2025 by Doodle Monster Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837108 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 (edited) it printed wramp_leech_1 is active and maxhealth at 150, So I assume there's something wrong with the maxhealth change not being run Edited September 24, 2025 by Doodle Monster Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837109 Share on other sites More sharing options...
FerniFrenito Posted September 24, 2025 Share Posted September 24, 2025 11 minutes ago, Doodle Monster said: it printed wramp_leech_1 is active and maxhealth at 150, So I assume there's something wrong with the maxhealth change not being run In fact, "Is activated" will appear regardless of the value. The actual value is false. inst.components.skilltreeupdater:IsActivated("wramp_leech_1") returns false, so I assume "wramp_leech_1" isn't actually activated. Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837111 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 (edited) That's really odd, the lifesteal part of that skill is working. let me test without the skill Edited September 24, 2025 by Doodle Monster Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837112 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 (edited) The life leech is functioning like it's supposed to without the skill Edited September 24, 2025 by Doodle Monster Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837113 Share on other sites More sharing options...
FerniFrenito Posted September 24, 2025 Share Posted September 24, 2025 1 minute ago, Doodle Monster said: The life leech is functioning like it's supposed to without the skill What print() are being written to the console? Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837114 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 (edited) I restarted the server, I'll send you the log Edited September 24, 2025 by Doodle Monster Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837115 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 (edited) Edited September 24, 2025 by Doodle Monster Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837116 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 (edited) That might be wrong, I thought rollingback would reset the console Okay, rebooted the server from the menue i'll send what the console prints Edited September 24, 2025 by Doodle Monster Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837117 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 (edited) Edited September 24, 2025 by Doodle Monster Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837118 Share on other sites More sharing options...
FerniFrenito Posted September 24, 2025 Share Posted September 24, 2025 1 minute ago, Doodle Monster said: That might be wrong, I thought rollingback would reset the console Run this command in the console when everything is loaded print(AllPlayers[1].components.skilltreeupdater:IsActivated("wramp_leech_1")) and tell me what you get as a result Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837119 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 (edited) I changed it back to detecting the tag, I think that will mess with it I probably should have not changed it local function onload(inst) print("onload") inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end local res = inst:HasTag("wramp_skill_leech_1") print("wramp_leech_1 is activated") print(res) if res then inst.components.health:SetMaxHealth(60) print("Max health 60") else inst.components.health:SetMaxHealth(150) print("Max health 150") end end I keep getting bugged out the fourms like to keep repeat posting images lol @FerniFrenito It prints true, tried it twice to make sure Edited September 24, 2025 by Doodle Monster Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837120 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 (edited) I'll change it back one moment Edited September 24, 2025 by Doodle Monster Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837121 Share on other sites More sharing options...
FerniFrenito Posted September 24, 2025 Share Posted September 24, 2025 5 minutes ago, Doodle Monster said: @FerniFrenito It prints true, tried it twice to make sure With the HashTag or do you mean what I gave you to put in the console? Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837123 Share on other sites More sharing options...
Doodle Monster Posted September 24, 2025 Author Share Posted September 24, 2025 (edited) It prints true for the command you gave me in the console I changed it back to : local function onload(inst) print("onload") inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end local res = inst.components.skilltreeupdater:IsActivated("wramp_leech_1") print("wramp_leech_1 is activated") print(res) if res then inst.components.health:SetMaxHealth(60) print("Max health 60") else inst.components.health:SetMaxHealth(150) print("Max health 150") end end Edited September 24, 2025 by Doodle Monster Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837125 Share on other sites More sharing options...
FerniFrenito Posted September 24, 2025 Share Posted September 24, 2025 (edited) 16 minutes ago, Doodle Monster said: It prints true for the command you gave me in the console This means that by the time OnLoad is executed, the tree's ability is not yet activated, it is activated later. Wait, I'll see if you can run the code when the skill is set to true. Try this local function onload(inst) -- ... inst:ListenForEvent("onactivateskill_server", function(data) print("EVENT LISTENER :") print(data) if data then print(data.skill) end print("________") if data and data.skill == "wramp_leech_1" then inst.components.health:SetMaxHealth(60) else inst.components.health:SetMaxHealth(150) end end) end This should work, but what I don't know is what it returns in the data variable, so make the change and look for where "EVENT LISTENER :" is printed and send me a screenshot of that part. Edited September 24, 2025 by FerniFrenito Link to comment https://forums.kleientertainment.com/forums/topic/168152-how-to-change-maxhealth-after-applying-skilltree-skill/#findComment-1837126 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now