yeelp / Scaling-Feast

A simple, balanced way to increase your maximum hunger in Minecraft over the course of a world.
MIT License
0 stars 1 forks source link

A way to make starvation occur faster when you lose food points while at zero #52

Closed James103 closed 4 years ago

James103 commented 4 years ago

I don't know if this isn't needed or in the scope of the mod, but what if there was an option that made it so if you lost food points while you were already at zero, you instead take starvation damage proportional to the amount of food points lost? For example, If you are at zero hunger, but then lost 6 food points in one second (either from sprinting or from a mob attacking you), you will lose 6 HP and 2 food points will be deducted from your maximum, instead of 1 HP and 1/3 of a food point.

This could be combined with #17 to make mobs that normally drain your hunger instead drain both your health (faster) and also your max hunger, if they attack you while you're already at zero hunger.

In an extreme case, a creeper that deals 47 HP of damage to you that is not blacklisted from the hunger-draining damage could cause you to die (having taken 94 HP of damage) and respawn unable to even sprint.

Still, losing 2 food points in 4 seconds while at zero will cause you to take 3 HP of damage and a penalty of 1 to your max hunger, due to the standard starvation damage.

yeelp commented 4 years ago

This could be interesting, however the way starvation is handled in Scaling Feast and Minecraft doesn't lend itself well to this idea of essentially changing the rate and potency of starvation on the fly, in my opinion. I'll look into the feasibility of this a little more, but I wouldn't hold your breath.

James103 commented 4 years ago

Remember those "pay as you go" models where you pay monthly, but your bill depends on how much you use the product? A similar system could be possible, where it tracks how many food points you lose while you are at zero. Every 4 seconds (80 ticks), if your food points are at zero, you are damaged by (1 + X) health points where X is the aforementioned counter (which gets reset for next cycle), and with your max hunger going down accordingly ((1 + X) / 3 by default).

yeelp commented 4 years ago

That will work, I'll just need a new capability to store what you've called 'X', X can either track the total number of hunger lost or the total amount of exhaustion lost then multiply the floor of that by the player's max exhaustion (which should result in the same outcome), whichever is easier to track (probably exhaustion, AppleCore has some nice events for that). then, use AppleCore again to increase starvation damage for the next tick, reset it back to normal on starvation, decrease max hunger appropriately, then reset this counter.

If I get time, I can release this in 1.4.0, else it'll have to wait until after.

James103 commented 4 years ago

use AppleCore again to increase starvation damage for the next tick, reset it back to normal on starvation

Do you mean the following workflow?

  1. Get the current starvation damage per damage tick, and store it in a variable Y.
  2. Store the quantity (Y + X†) as the starvation damage per damage tick.
  3. Wait until the starvation damage occurs.
  4. Store the variable Y as the starvation damage per damage tick.
  5. Do stuff with X and Y (decrease max hunger, etc.)
  6. Reset X (required) and Y (optional).

Where: X is the total exhaustion gained whilst at zero hunger and Y is the regular starvation damage per damage tick, unmodified by Scaling Feast (default 1, but can still be changed). †X may be multiplied by a value in the config to determine how much HP damage you take for every food point you lose while at zero.

yeelp commented 4 years ago

Technically yes. I'll subscribe to AppleCore's StarvationEvent.Starve in the FoodHandler class, which it is already subscribed to anyway.

Pseudocode looks like this (before I said I multiply by max exhaustion. This is incorrect, I should divide by it).

void onStarve(StarvationEvent.Starve evt)
{
    //before Starvation Tracker is ticked
    player = evt.player
    bonusDamage = modifier*floor(ScalingFeastAPI.accessor.getExhaustionSinceStarve(player)/AppleCoreAPI.accessor.getMaxExhaustion(player))
    evt.starveDamage += bonusDamage
    //tick tracker bonusDamage times
    for(i in [0, bonusDamage))
    {
        ScalingFeastAPI.accessor.getTracker(player).tick()
        doUsualChecksForTracker()
    }
    //continue with routine, which ticks tracker once to account for this starvation, leading to tracker being ticked bonusDamage+1 times.
}