mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-06-07 06:06:10 -04:00
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.
45 lines
1.4 KiB
Text
45 lines
1.4 KiB
Text
Minetest mod "Stamina"
|
|
=====================
|
|
|
|
(C) 2015 - BlockMen
|
|
(C) 2016 - Auke Kok <sofar@foo-projects.org>
|
|
|
|
|
|
About this mod:
|
|
---------------
|
|
This mod adds a stamina, or "hunger" mechanic to Minetest. Actions like
|
|
crafting, walking, digging or fighting make the player exhausted. When
|
|
enough exhaustion has been accumulated, the player gets more hungry,
|
|
and loses stamina.
|
|
|
|
If a player is low on stamina, they start taking periodical damage,
|
|
and ultimately will die if they do not eat food.
|
|
|
|
Eating food no longer heals the player. Instead, it increases the
|
|
stamina of the player. The stamina bar shows how well fed the player
|
|
is. More bread pieces means more stamina.
|
|
|
|
|
|
For Modders:
|
|
------------
|
|
This mod intercepts minetest.item_eat(), and applies the hp_change
|
|
as stamina change. The value can be positive (increase stamina) or
|
|
negative (periodically damage the player by 1 hp).
|
|
|
|
Callbacks that are registered via minetest.register_on_item_eat()
|
|
are called after this mod, so the itemstack will have changed already
|
|
when callbacks are called. You can get the original itemstack as 6th
|
|
parameter of your function then.
|
|
|
|
|
|
License:
|
|
--------
|
|
Code:
|
|
- all code LGPL-2.1+
|
|
Textures:
|
|
- stamina_hud_poison.png - BlockMen (CC-BY 3.0)
|
|
- stamina_hud_fg.png - PilzAdam (WTFPL), modified by BlockMen
|
|
- stamina_hud_bg.png - PilzAdam (WTFPL), modified by BlockMen
|
|
Sounds:
|
|
- stamina_eat.*.ogg - http://www.freesound.org/people/sonictechtonic/sounds/242215/ CC-BY-3.0
|
|
|