MurderingMason Posted September 12, 2015 Share Posted September 12, 2015 I'm wanting to put Wigfrids ability to take health and sanity from her enemies and put it on my custom character I don't know how to go about doing this. Link to comment Share on other sites More sharing options...
MurderingMason Posted September 13, 2015 Author Share Posted September 13, 2015 bump? Link to comment Share on other sites More sharing options...
Doctor Donna Posted September 13, 2015 Share Posted September 13, 2015 (edited) bump? Mhm... maybe this?you can search for it in the wigfrid.lua/wathgrithr.lua local function onkilled(inst, data) local victim = data.victim if IsValidVictim(victim) then -- local delta = victim.components.combat.defaultdamage * 0.25 -- inst.components.health:DoDelta(delta, false, "battleborn") -- inst.components.sanity:DoDelta(delta) if not victim.components.health.nofadeout and (victim:HasTag("epic") or math.random() < .1) then local time = victim.components.health.destroytime or 2 local x, y, z = victim.Transform:GetWorldPosition() local scale = (victim:HasTag("smallcreature") and smallScale) or (victim:HasTag("largecreature") and largeScale) or medScale inst:DoTaskInTime(time, spawnspirit, x, y, z, scale) end endendlocal BATTLEBORN_STORE_TIME = 3local BATTLEBORN_DECAY_TIME = 5local BATTLEBORN_TRIGGER_THRESHOLD = 1local function onattack(inst, data) local victim = data.target if not inst.components.health:IsDead() and IsValidVictim(victim) then local total_health = victim.components.health:GetMaxWithPenalty() local damage = data.weapon ~= nil and data.weapon.components.weapon.damage or inst.components.combat.defaultdamage local percent = (damage <= 0 and 0) or (total_health <= 0 and math.huge) or damage / total_health --math and clamp does account for 0 and infinite cases local delta = math.clamp(victim.components.combat.defaultdamage * .25 * percent, .33, 2) --decay stored battleborn if inst.battleborn > 0 then local dt = GetTime() - inst.battleborn_time - BATTLEBORN_STORE_TIME if dt >= BATTLEBORN_DECAY_TIME then inst.battleborn = 0 elseif dt > 0 then local k = dt / BATTLEBORN_DECAY_TIME inst.battleborn = Lerp(inst.battleborn, 0, k * k) end end --store new battleborn inst.battleborn = inst.battleborn + delta inst.battleborn_time = GetTime() --consume battleborn if enough has been stored if inst.battleborn > BATTLEBORN_TRIGGER_THRESHOLD then inst.components.health:DoDelta(inst.battleborn, false, "battleborn") inst.components.sanity:DoDelta(inst.battleborn) inst.battleborn = 0 end endendlocal function ondeath(inst) inst.battleborn = 0end wathgrithr.lua Edited September 13, 2015 by EulenMarie Link to comment Share on other sites More sharing options...
MurderingMason Posted September 13, 2015 Author Share Posted September 13, 2015 Yeah ive tried this and have had so many crashes and problems it just isn't working so I took to the forums... Also worth noting I want my character to sap health and hunger instead of hunger and sanity! D: problems Link to comment Share on other sites More sharing options...
MurderingMason Posted September 13, 2015 Author Share Posted September 13, 2015 Yeah ive tried this and have had so many crashes and problems it just isn't working so I took to the forums... Also worth noting I want my character to sap health and hunger instead of hunger and sanity! D: problemsUpdate: added Wigfrids code to my character and launched it without errors or crashing but doens't seem to be working... added file for character. Link to comment Share on other sites More sharing options...
Doctor Donna Posted September 13, 2015 Share Posted September 13, 2015 (edited) Update: added Wigfrids code to my character and launched it without errors or crashing but doens't seem to be working... added file for character. I'm not god @coding but, pls make screenshots if the games crashed.Do you haven't a crash, send the log.txt documents>klei>dont starve together>log.txt then the people with knowledge can see whats going wrong ^^ Edited September 13, 2015 by EulenMarie Link to comment Share on other sites More sharing options...
MurderingMason Posted September 13, 2015 Author Share Posted September 13, 2015 I'm not god @coding but, pls make screenshots if the games crashed.Do you haven't a crash, send the log.txt documents>klei>dont starve together>log.txt then the people with knowledge can see whats going wrong ^^This is a non-crash log. Not sure if anyone needs but yeah, Wigfrid's code is going in fine and starting up without crashes it just isn't working with my character like he isn't sapping health or anything.log.txt Link to comment Share on other sites More sharing options...
MurderingMason Posted September 14, 2015 Author Share Posted September 14, 2015 Bump? :c Link to comment Share on other sites More sharing options...
DrSmugleaf Posted September 18, 2015 Share Posted September 18, 2015 (edited) That would be because your onkilled and onattack functions are doing nothing. You need to attach them to the events "killed" and "onattackother" by putting these lines in the master_postinit:inst:ListenForEvent("killed", onkilled)inst:ListenForEvent("onattackother", onattack)inst:ListenForEvent("death", ondeath)Also the ondeath function.And it's just a me thing but I preffer putting common_postinit and master_postinit in the bottom next to each other.Changed it so it saps health and hunger instead of health and sanity. Try it:wilber.lua Edited September 18, 2015 by DrSmugleaf Link to comment 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