-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
~~~Hunger.~~~ Stamina #855
Conversation
Note: I'm fully aware of a recent patch by @BlockMen to push hunger to core. I'm entirely neutral on that PR, but I strongly applaud the effort since it exposes what is currently missing to add these type of game mechanics to the game. I also know that people likely won't like that I used BlockMen's hunger mod and turned it upside down, but I am personally not interested currently in a hunger implementation that pulls in a full hud mod with lots of options. For several reasons I prefer to have a hunger implementation that is ... just that... a hunger mechanic. Ultimately this PR exists to demonstrate that a simple hunger mechanic can be implemented as a relatively clean single mod, one that is simple, clean and fun enough to be part of I've logged a bunch of hours playing with this code, and I find the initial challenge of playing with this code enabled refreshing and challenging, and a wholesome addition to vanilla minetest_game. |
===================== | ||
|
||
(C) 2015 - Auke Kok <[email protected]> | ||
(C) 2015 - BlockMen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other way round and 2016 for you...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, will update.
I don't see any profit from ripping hunger appart from hud. If we add new statbars we should improve current "shit" aswell. 👎 from me as is, mainly beccause of the hacky way of storing hunger value. |
👎 due to hacky way of storing hunger |
health_timer = health_timer + dtime | ||
action_timer = action_timer + dtime | ||
|
||
if action_timer > HUNGER_MOVE_TICK then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you use minetest.after
instead of a globalstep callback? I understand that there are multiple tick values taken in count here but the use of timers and globalstep callbacks called every server step have a cost.
(see this for more explanations)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function likely needs a full rewrite to optimize. However, I don't think I'll be able to remove the globalstep part entirely, mostly because the proper replacement using minetest.after
would cause lots of timers to fire per player, and you'd end up with more timer pressure from that.
Erm... But didn't you write it? Why not post an issue like "[Suggestion] Add a better player value storage method" I personally really don't care if it is a hack. Hacks can be replaced. |
This doesn't sound right.
Why? Whats the benefit from hiding high values? |
Could there be a function exposed for increasing exhaustion? In case a mod wants to add exhaustion to some of its actions. Or is it intended that mods just use hunger_players directly? |
I agree. I was thinking of renaming the stat to "stamina", which seems more intuitive.
This is what the original implementation did. The benefit is that if you eat a little bit over the max of 20, it's not immediately lost. I'm completely neutral on this, but I changed the mechanic to consume hunger when it's healing, and so the extra buffer may be nice. |
@raymoo I've thought about that as well, this function also has a poison mechanic, which would conflict with work that you're doing in your mods as well. I think we'll want a simple API to allow mods to manipulate hunger values, though. |
I've renamed the whole thing to stamina. I don't think in-game people will have a hard time understanding what the idea is, so we might as well choose a name for the stat that is logical (e.g. increased is better, whereas hunger is inverse). Updated (C) comment as well. Meanwhile I'm publishing the mod for those who want to use the codebase as mod here: |
Stamina sounds like a sprint/running thing |
At least higher values of it suggest that it's better for the player. |
|
||
About this mod: | ||
~~~~~~~~~~~~~~~ | ||
This mod adds a stamina, or "hunger" echanic to Minetest. Actions like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echanic
Well... Erm... Creative thinking on the idea! Although if it is stamina/energy, what about making sleep recharge half a point of stamina? |
Possibly, yes. I do want to force players to farm food, though, so it should not give much stamina back. Perhaps we can give it a point of stamina only if the stamina bar is less than half. I've also considered making stamina loss higher at night to make beds more appealing. |
I like that item_eat doesn't have to be overridden. That is important to me. |
A feature like this I would leave in the hands of a mod and not in the game engine since you get more control over the mod itself and what heals, hurts, satiates and poisons. |
@sofar I don't see how renaming it to "stamina" solves the mentioned problems. Still 👎 |
@BlockMen, you don't need to repeat that, I had no illusions that that would solve the issue. |
This code adds ~~~hunger~~~ stamina to minetest_game. This code is entirely derived from Blockmen's hunger+hud mod. Credits and copyright are preserved as they are compatible with minetest_game. gameplay: The player stat 'stamina' is added. The higher the value, the better. A value of 5 or higher causes the player to slowly get healed over time, at the cost of stamina. One can only be healed if the stamina value is higher than, or equal to the health value. Eating food causes 'stamina' to increase. The visual range of stamina is 0-20, but one can eat slightly over that. If the stamina is at max, items are not eaten anymore. At stamina 2 or lower, the player is damaged periodically, and will die if the stamina value isn't increased due to eating. If eating a food that has a negative hp_change value, such as red mushrooms, the player takes periodical damage to the amount of the hp_change value. During this time, the player is "poisoned". This poison damage can not kill the player. Added by me is code to add exhaustion on crafting, and on player combat. I also added extra exhaustion when the player is jumping code: This mod started as BlockMen's hunger+hud mod. I trimmed the entire hud mod away and placed the stamina bar on top of the hp hud element, which will make the relation between stamina and hp a bit more clear, and doesn't require moving the air hud element. The stamina mod was reduced to fit a single file. I trimmed some legacy code, revised all local/global usage. Renamed most internal variables, and generally did a lot of removals of needlessly complex code favoring simplicity. The food registration code is entirely removed. Instead we assume food just adds stamina or ticks damage as poison. Food eating callbacks are still called. Subsequently, this mod will likely not properly work with BlockMen's hud code anymore, nor is that intended to work. Food mods just have to call item_eat(). I've moved and credited authors for the used textures. I replaced the food sound of this mod with 3 different sounds. The code points out several issues with core: There's no decent place to store player stats. This mod solves it by creating a per player inventory purely for storing an integer value. Intercepting core.do_item_eat() also isn't the nicest way to make this work.
Internally it's called "Satiation" -- which is correct when full. |
|
@sofar Yeah, I was thinking something like that.
This will save many wasted apples. The next step is to make an eating animation. But maybe not now. |
@C1ffisme eating animation |
Eating food particles (it's not really an animation) shouldn't be part of an The food particles in the screenshot on the forum look terrible, but I suppose it can be cleaned up and it's certainly appropriate to add it to this mod, where it's entirely appropriate (I already added eating sounds, as well). |
@sofar, Yes, when I use the form of the third person, these particles are simply awful. |
@C1ffisme that's probably entirely doable in lua, actually. |
@sofar Ooooh... I'm not sure about the wielditem HUD movement, though. Is that possible yet? |
@sofar, really? I wait look your realisation :) |
@C1ffisme Yes, there are api to wield the speed change |
@MoNTE48 I'd create an entity with the texture of the thing beaing eaten, and embed an animation that shakes it up and down in front of the player's view. |
@sofar This will be done for each eat item? |
@MoNTE48 solving one problem at a time :) |
@sofar ok. You could put a famine after the health (as in Minecraft), instead of the above health? It look ugly. |
@MoNTE48 not without moving the breath bar. |
@sofar and moving breath bar too. That is as it is made in Minecraft (and the way made in BlockMen) - the most convenient and beautiful option, I think. |
I have no intention of moving it at this point. The argument that it should be like MC is moot. I like that stamina sits on top of health, it shows the relationship between them. |
But normally too many objects on the left and right quite empty. 👎 |
This PR isn't going to get merged any time soon (or possibly never), so the thumbs downs are unnecessary. |
Yes, but I really like it and I would use it in my subgame. |
I'd like this thread to focus on the lack of player metadata storage, instead (which is honestly the whole point of this PR). If you want to discuss the stamina implementation, let's do that here: https://github.com/minetest-mods/stamina/. We can take the stamina mod to a different level in that location anyway. |
@MoNTE48 since this is actually my hunger mod, what excactly is wrong for you with https://github.com/BlockMen/hunger ? Without any feedback how should things get improved... |
BlockMen, Your hunger is working very well, but there are some times when it works with a delay and requires optimization. In addition, I would like to see the food animation if this can be done sofar |
@MoNTE48 could you be a bit more precise? Maybe open an issue for that at https://github.com/BlockMen/hunger |
Should be added to core in my opinion. |
@davisonio Could you post your opinion here (luanti-org/luanti#3388) plz? That is the main PR for hunger and the engine is visted by far more ppl, so we get a much better view on what should be done concerning hunger. thx. |
I'm closing this for now. The original mods and my fork remain available and I am maintaining my simplified/combined hud/hunger mod for everyone to use. I'm not done with this idea, but not in this form, just now. |
This code adds ~~~hunger~~~ stamina to minetest_game.
This code is entirely derived from Blockmen's hunger+hud mod. Credits
and copyright are preserved as they are compatible with minetest_game.
gameplay:
The player stat 'stamina' is added. The higher the value, the better. A
value of 5 or higher causes the player to slowly get healed over time,
at the cost of stamina. One can only be healed if the stamina value is
higher than, or equal to the health value.
Eating food causes 'stamina' to increase. The visual range of stamina
is 0-20, but one can eat up to 30 stamina. If the stamina is at max,
items are not eaten anymore.
At stamina 2 or lower, the player is damaged periodically, and will
die if the stamina value isn't increased due to eating.
If eating a food that has a negative hp_change value, such as red
mushrooms, the player takes periodical damage to the amount of the
hp_change value. During this time, the player is "poisoned". This
poison damage can not kill the player.
Added by me is code to add stamina on crafting. I intend to add
stamina based on combat as well, at least pvp combat.
code:
This mod started as BlockMen's hunger+hud mod. I trimmed the entire
hud mod away and placed the stamina bar on top of the hp hud element,
which will make the relation between stamina and hp a bit more clear,
and doesn't require moving the air hud element.
The stamina mod was reduced to fit a single file. I trimmed some
legacy code, revised all local/global usage. Renamed most internal
variables, and generally did a lot of removals of needlessly complex
code favoring simplicity.
The food registration code is entirely removed. Instead we assume food
just adds stamina or ticks damage as poison. Food eating callbacks are
still called. Subsequently, this mod will likely not properly work
with BlockMen's hud code anymore, nor is that intended to work. Food
mods just have to call item_eat().
I've moved and credited authors for the used textures. I replaced
the food sound of this mod with 3 different sounds.
The code points out several issues with core: There's no decent
place to store player stats. This mod solves it by creating a per
player inventory purely for storing an integer value. Intercepting
core.do_item_eat() also isn't the nicest way to make this work.