Aw damn, yeah so far I like the updated food but am missing the changed degradation of this mod. Similarly a a mod used to change stealth to not cost stamina seems to have been deleted =|
If you want to use a similar mod in the meantime, google for a mod called "PreWorkout" (the author seems to have deleted the mod here). The mod is less elegant and disables the degradation alltogether. But its still better than nothing.
This is something I've been wanting, and some crazy junky went and uploaded it. If possible, a version where the degration is more of a curve (decreases slightly at first, and when it starts flashing is the turning point) then that would be better for me, but I do love me this version as well. The formula would fit a curve of 2x-x^2.
Will use this as is for now though, much better than the mod that has it be 100% efficient until the food runs out, or vanilla's linear degregation!
Yeah I feel you on having a preferred curve. I want it so you initially only get 50% of the food benefit, and over the first 1/4 of it's total duration, it linearly scales up to 100% benefit. Remain at 100% benefit for 1/2 of the total duration, then scale down to 0% benefit over the last 1/4 total duration. Then, if you consume new food while it's still over 50%, the curve of the new food starts where the old food left off. Bonus points if the static linear curve would still apply, so any extra time spent gets added to the 50% total duration of 100% effectiveness.
But more then anything, can we get a mod that adds timers next to the food already? lol I swear this game is going to get me into modding before the year is over.
Hey mate, if you can translate your formula into code, I'd be glad to upload a version with it, but I will admit being a bit too lazy to figure it out myself given my version was exactly what I wanted. Here's the original function that get called each tick to update you health/stamina
private void GetTotalFoodValue(out float hp, out float stamina) { hp = 25f; stamina = 75f; foreach (Player.Food mFood in this.m_foods) { hp = hp + mFood.m_health; stamina = stamina + mFood.m_stamina; } }
each food (mFood.m_health) at this point already have the decayed health amount stored, because it gets updated each tick in another function here's the part that update each food health amount each tick Player.Food mHealth = mFood; mHealth.m_health = mHealth.m_health - mFood.m_item.m_shared.m_food / mFood.m_item.m_shared.m_foodBurnTime;
And here's my updated GetTotalFoodValuefunction
hp = 25f; stamina = 75f; foreach (Player.Food mFood in ___m_foods) // for each food consumed by the player { //Debug.Log("food:" + mFood.m_name); //Debug.Log("hp before:" + hp);
float foodMaxHealth = mFood.m_item.m_shared.m_food; float foodPercentageLeft = mFood.m_health / foodMaxHealth; float foodOldDecayedHealth = foodMaxHealth - mFood.m_health; float foodDecayedHealth = (foodOldDecayedHealth - (foodMaxHealth / 2)) * 2; //decay twice as fast, but only starting from half time. //Debug.Log("foodMaxHealth:" + foodMaxHealth);
if (foodPercentageLeft >= 0.5f) // if less than half of the food time has been spent { hp = hp + foodMaxHealth; // give the max health of the food } else { hp = hp + (foodMaxHealth - foodDecayedHealth); //else give the calculated decayed amount } //Debug.Log("hp after:" + hp); // same for stamina
I think you would need to change the line after the else to
hp = hp + foodMaxHealth * ( 4 * foodPercentageLeft - 4 * foodPercentageLeft * foodPercentageLeft );
This way you have: 1. Health degrades in a quadratic curve (after foodPercentageLeft falls below 1/2). 2. Health is hp+foodMaxHealth if foodPercentageLeft is 1/2. 3. Health is hp if foodPercentageLeft is 0. 4. Health is a smooth function (differentiable even at foodPercentageLeft=1/2). You dont need foodDecayedHealth and foodOldDecayedHealth anymore, if you use this line.
Btw: thank you CrazyJunky for modding and posting your work here :-)
Is this client side only single player. Client side only Multiplayer. Server/Client required for multiplayer? Does everyone have to have the mod, or only those with the client version on a server with it enabled will this work?
Hey, didn't test it out multi yet, but given how much is handled client side, I'd expect this to work for every clients that installed it without affecting others / needing server. If someone could confirm that'd be great.
EDIT : played with some friend on their server, worked fine for me, didnt affect them
19 comments
^^^ Updated for H&H
Haven't tried it yet but all his other stuff works just fine.
Similarly a a mod used to change stealth to not cost stamina seems to have been deleted =|
Will use this as is for now though, much better than the mod that has it be 100% efficient until the food runs out, or vanilla's linear degregation!
But more then anything, can we get a mod that adds timers next to the food already? lol I swear this game is going to get me into modding before the year is over.
Here's the original function that get called each tick to update you health/stamina
private void GetTotalFoodValue(out float hp, out float stamina)
{
hp = 25f;
stamina = 75f;
foreach (Player.Food mFood in this.m_foods)
{
hp = hp + mFood.m_health;
stamina = stamina + mFood.m_stamina;
}
}
each food (mFood.m_health) at this point already have the decayed health amount stored, because it gets updated each tick in another function
here's the part that update each food health amount each tick
Player.Food mHealth = mFood;
mHealth.m_health = mHealth.m_health - mFood.m_item.m_shared.m_food / mFood.m_item.m_shared.m_foodBurnTime;
And here's my updated GetTotalFoodValuefunction
hp = 25f;
stamina = 75f;
foreach (Player.Food mFood in ___m_foods) // for each food consumed by the player
{
//Debug.Log("food:" + mFood.m_name);
//Debug.Log("hp before:" + hp);
float foodMaxHealth = mFood.m_item.m_shared.m_food;
float foodPercentageLeft = mFood.m_health / foodMaxHealth;
float foodOldDecayedHealth = foodMaxHealth - mFood.m_health;
float foodDecayedHealth = (foodOldDecayedHealth - (foodMaxHealth / 2)) * 2; //decay twice as fast, but only starting from half time.
//Debug.Log("foodMaxHealth:" + foodMaxHealth);
if (foodPercentageLeft >= 0.5f) // if less than half of the food time has been spent
{
hp = hp + foodMaxHealth; // give the max health of the food
}
else
{
hp = hp + (foodMaxHealth - foodDecayedHealth); //else give the calculated decayed amount
}
//Debug.Log("hp after:" + hp);
// same for stamina
hp = hp + foodMaxHealth * ( 4 * foodPercentageLeft - 4 * foodPercentageLeft * foodPercentageLeft );
This way you have:
1. Health degrades in a quadratic curve (after foodPercentageLeft falls below 1/2).
2. Health is hp+foodMaxHealth if foodPercentageLeft is 1/2.
3. Health is hp if foodPercentageLeft is 0.
4. Health is a smooth function (differentiable even at foodPercentageLeft=1/2).
You dont need foodDecayedHealth and foodOldDecayedHealth anymore, if you use this line.
Btw: thank you CrazyJunky for modding and posting your work here :-)
I believe the issue is with this mod, but I have posted there as well. I suspect this from examining the code you gave below.
If someone could confirm that'd be great.
EDIT : played with some friend on their server, worked fine for me, didnt affect them