Don't Starve

Don't Starve

The Regenerating Mutant - Heather
lionhylra Feb 7, 2015 @ 8:28am
BUGS
Hi Patriarachnid
I found some bugs in your code.
In the function below:
local function onhealthchange(inst, data)

if inst.components.hunger.current < 2 then
inst.strength = "starving"
inst.components.talker:Say("My body lacks the energy to repair itself.")

elseif inst.strength == "minregen" then
if inst.components.health.currenthealth <= 90 then
inst.strength = "medregen"
inst.components.talker:Say("I should be back to normal in no time.")
end

elseif inst.strength == "medregen" then
if inst.components.health.currenthealth <= 60 then
inst.strength = "moreregen"
inst.components.talker:Say("Tissues are repairing incredibly fast now!")
end

elseif inst.strength == "maxregen" then
if inst.components.health.currenthealth >= 30 then
inst.strength = "moreregen"
inst.components.talker:Say("Tissue repair is beginning to slow.")
end

elseif inst.strength == "moreregen" then
if inst.components.health.currenthealth >= 60 then
inst.strength = "midregen"
inst.components.talker:Say("Cell reproductive rates down to manageable levels.")
end

elseif inst.components.health.currenthealth < 30 then
inst.strength = "maxregen"
inst.components.talker:Say("Metabolic rates have spiked!")

elseif inst.components.health.currenthealth > 90 then
inst.strength = "minregen"
inst.components.talker:Say("Cells replicating as normal.")

end
updatestats(inst)
end

1.This function is called all the time. So the updatestats will always be called. In the original health.lua, the Health:StartRegen cancels the task first then assign new task. Therefore your code will cause some disorder in setting periodic tasks.
2.There is a spelling mistake "midregen" in line 119.
3.The character will never enter "maxregen" and neither back to "minregen" from "medregen". Because when the health comes to 29 from 30, the strenth will still be "moreregen" and the code run this:

elseif inst.strength == "moreregen" then
if inst.components.health.currenthealth >= 60 then
inst.strength = "midregen"
inst.components.talker:Say("Cell reproductive rates down to manageable levels.")
end

which does no change to the regen rate.
The same to minregen.

4.When the health ==60, according to your code, the regen rate will swap between "medregen" and "moreregen" many times in 1 second until it goes >60 or <60.

So when playing "Heather", I found the behaviour of health is very schange. Sometimes it stop regenerating(because frequent calling Health:StartRegen(), it takes 2 seconds to regen 1 health at first, but you cancel it immediately in very short time, so the health will never goes up), and when its health goes below 30, the regen rate is very slow.

Now I give your version, it works perfectly.

==================================================================

local function onhealthchange(inst, data)
--inst.components.talker:Say("!!")
if inst.components.hunger.current < 2 then
inst.strength = "starving"
inst.components.talker:Say("My body lacks the energy to repair itself.")
updatestats(inst)

elseif inst.strength == "minregen" then
if inst.components.health.currenthealth < 90 then
inst.strength = "medregen"
-- inst.components.talker:Say("my strength is: "..inst.strength)
inst.components.talker:Say("I should be back to normal in no time.")
updatestats(inst)
end

elseif inst.strength == "medregen" then
if inst.components.health.currenthealth < 60 then
inst.strength = "moreregen"
-- inst.components.talker:Say("my strength is: "..inst.strength)
inst.components.talker:Say("Tissues are repairing incredibly fast now!")
updatestats(inst)
elseif inst.components.health.currenthealth >= 90 then
inst.strength = "minregen"
-- inst.components.talker:Say("my strength is: "..inst.strength)
inst.components.talker:Say("Cells replicating as normal.")
updatestats(inst)
end

elseif inst.strength == "maxregen" then
if inst.components.health.currenthealth >= 30 then
inst.strength = "moreregen"
-- inst.components.talker:Say("my strength is: "..inst.strength)
inst.components.talker:Say("Tissue repair is beginning to slow.")
updatestats(inst)
end

elseif inst.strength == "moreregen" then
if inst.components.health.currenthealth >= 60 then
inst.strength = "medregen"
-- inst.components.talker:Say("my strength is: "..inst.strength)
inst.components.talker:Say("Cell reproductive rates down to manageable levels.")
updatestats(inst)
elseif inst.components.health.currenthealth < 30 then
inst.strength = "maxregen"
-- inst.components.talker:Say("my strength is: "..inst.strength)
inst.components.talker:Say("Metabolic rates have spiked!")
updatestats(inst)
end
end

--updatestats(inst)
end

===================================================================
And in local fn = function(inst)

add one more line:

inst.components.health:StartRegen(.5, 1)

this makes Heather have a initial regen rate
Last edited by lionhylra; Feb 7, 2015 @ 8:30am
< >
Showing 1-4 of 4 comments
Dweaver  [developer] Feb 7, 2015 @ 10:26am 
Thanks much. I'll get to tweaking the code.

Forgive me for it having been a bit sloppy; this is my first Don't Starve mod, so I was just learning the ropes when making it
lionhylra Feb 7, 2015 @ 5:35pm 
Haha, no wories. I have never made a mod before, just started to play game for a while. Could you share some experience with me about how to make a mod? Is there any written tutorial that I can learn from? Thanks
Dweaver  [developer] Feb 7, 2015 @ 7:20pm 
http://forums.kleientertainment.com/forum/26-dont-starve-mods-and-tools/

It's mostly reading that forum, scouring through the source code, and Frankensteining bits of code from other mods that do similar things to what you want together.
Dill Doe Apr 17, 2015 @ 7:09pm 
Hi there!
First of all, congratz for this amazing mod!! i realllly love this character. The problem i found is, when you create a Meat Effigy for her, the hunger decrease like crazy, since the script keep forceing to regenerate health where M. Effigy took it...so the character is a bit umplayable after you setup first Effigy :( Can you fix this?
< >
Showing 1-4 of 4 comments
Per page: 1530 50