Allowing to change maximum health/breath for players

User avatar
Wuzzy
Member
 
Posts: 3640
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Allowing to change maximum health/breath for players

by Wuzzy » Mon Oct 13, 2014 10:26

Hi!
This is a suggestion regarding the health and breath of players.

This is the main suggestion:
1. Allow to modify the maximum health of players (must be a positive number)
2. Allow to modify the maximum breath (bubbles) of players (must be a positive number)

This suggestion requires to modify the HUD, like this:

3. Modify the interface to handle large numbers:
If a player’s max health is greater than 10 hearts, display the health like this:
Code: Select all
<hearts>/<max. hearts> ♥


For example, for a health of 15 out of 30 hearts, show “15/30 ” instead of “♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥”. For 10.5 hearts, show “10.5/30 ”.
The heart symbol serves like a unit symbol here, as in “5 m”, “17 kg”, etc.

Do the same analog to bubbles.

4. If a player’s max health equals or is lower than 10 hearts, show the health in the traditional way.

If you’re sophisticated:
5. Use a new texture, “heart_background.png” used in the traditional display to show “empty hearts”. So for showing 2/10 hearts, display “♥♥♡♡♡♡♡♡♡♡” instead of “♥♥”. For 2/5 hearts, display “♥♥♡♡♡”. The texture is optional and no image should be drawn if it is not present.
 

User avatar
Neuromancer
Member
 
Posts: 795
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56
 

User avatar
Don
Member
 
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Allowing to change maximum health/breath for players

by Don » Sat Jan 09, 2016 21:11

@Wuzzy - I like the idea. It would be nice to be able to change health/air as needed by mods.

@Neuromancer - I saw your crystal hearts mod. It is an awesome idea. Hope this gets added so you can complete the mod.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
Neuromancer
Member
 
Posts: 795
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

Re: Allowing to change maximum health/breath for players

by Neuromancer » Sat Jan 09, 2016 21:50

Thanks much. I think it might make sense for them to add player:set_max_hp. There already is player:get_hp and player:set_hp
 

User avatar
Minetestforfun
Member
 
Posts: 936
Joined: Tue Aug 05, 2014 14:09
Location: On earth
GitHub: Darcidride
IRC: Darcidride + MinetestForFun
In-game: Darcidride + MinetestForFun

Re: Allowing to change maximum health/breath for players

by Minetestforfun » Tue Jan 12, 2016 16:03

Totally agree with Wuzzy, we need a way to be able to change the maximum health and bubble of players ! :)
 

KCoombes
Member
 
Posts: 412
Joined: Thu Jun 11, 2015 23:19
Location: SW Florida, USA
In-game: Knatt
 

User avatar
cd2
Member
 
Posts: 562
Joined: Mon Jun 01, 2015 06:30
Location: Linux
GitHub: cdqwertz
In-game: cd cd2
 

User avatar
kaadmy
Member
 
Posts: 706
Joined: Thu Aug 27, 2015 23:07
GitHub: kaadmy
IRC: KaadmY
In-game: KaadmY kaadmy NeD
 

User avatar
Nathan.S
Member
 
Posts: 923
Joined: Wed Sep 24, 2014 17:47
Location: Bigsby Texas
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Allowing to change maximum health/breath for players

by Nathan.S » Sat Jan 16, 2016 23:05

This would be an excellent addition.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course
 

User avatar
yyt16384
Member
 
Posts: 46
Joined: Mon Nov 03, 2014 12:16
Location: China
GitHub: yyt16384
IRC: yyt16384
In-game: yyt16384

Re: Allowing to change maximum health/breath for players

by yyt16384 » Mon Jan 18, 2016 15:24

Currently you can hack with register_on_player_hpchange, but this is really something that should be in the engine.
 

wilkgr76
Member
 
Posts: 831
Joined: Wed Feb 18, 2015 02:44
GitHub: wilkgr76
 

User avatar
azekill_DIABLO
Member
 
Posts: 7489
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO
 

User avatar
burli
Member
 
Posts: 1641
Joined: Fri Apr 10, 2015 13:18
 

User avatar
ErrorNull
Member
 
Posts: 201
Joined: Thu Mar 03, 2016 00:43

Re: Allowing to change maximum health/breath for players

by ErrorNull » Wed May 18, 2016 17:51

this would be awesome for a future release. for now I've created a mod that bypasses the engines hp and breath and uses my own hp and breath objects (thus can dictate any maximum) and displays them using the [hudbars] mod. but it's very hacky.
 

User avatar
davidthecreator
Member
 
Posts: 331
Joined: Mon Aug 18, 2014 19:48
Location: Lithuania
GitHub: daviddoesminetest
In-game: DavidDoesMinetest

Re: Allowing to change maximum health/breath for players

by davidthecreator » Sun Jun 19, 2016 00:35

Allways wanted to max hp up to 100 (then i would make mobs that deal 1dmg do 5dmg and wearing cheap armor wouldnt help to completely evade damage from that mob... realy wish this gets added...
 

KCoombes
Member
 
Posts: 412
Joined: Thu Jun 11, 2015 23:19
Location: SW Florida, USA
In-game: Knatt

Re: Allowing to change maximum health/breath for players

by KCoombes » Sun Jun 19, 2016 01:20

ErrorNull wrote:this would be awesome for a future release. for now I've created a mod that bypasses the engines hp and breath and uses my own hp and breath objects (thus can dictate any maximum) and displays them using the [hudbars] mod. but it's very hacky.


I'd love to see your mod
 

User avatar
ErrorNull
Member
 
Posts: 201
Joined: Thu Mar 03, 2016 00:43

Re: Allowing to change maximum health/breath for players

by ErrorNull » Sun Jun 19, 2016 15:58

I'm sure many have done similar, but here's my code snippet that does the main bypass of health limitation. Essentially my mod uses its own object to track the player's "true" health (thus can set any maximum) and reports that to the HUD and is also saved to file when player leaves the game. The mod check's the engine's HP value at each globalstep to see if it has gone down - due to falling damage, hunger or breath depletion, mob attacks, etc. If engine's HP has gone down, calculate the difference and deduct it from player's true health. Then reset engine's HP back to 20 while player's health object in my mod maintains the current/correct value.

Drawback: All health restoring items must call a function in my mod to increase the player's "real" health value and not the engine's HP value... since the engine's value will always be at 20.

When mod's health value reaches zero then the function rpg.showKnockedout(player) performs 'knocked out' sequence. This is because to the minetest engine, HP is still 20 and player is still alive.. but in-game, player is to be immobilized and on the ground. While knocked out, player can consume health restoring potions or players can cooperate to give health items to the downed player, who then can get up and move again.

But here's the twist... while player is in the knocked out state, the engine's HP mechanism operates normally and any damage the player receives deducts from the engine's HP value.. from 20 to zero... by which time the player TRULY DIES! And must respawn.

If player is knocked out, without any healing items, and no players to give help, and no mobs or dangers to kill off the player... then the player can give up and type /DIE command and player will die... in other words, engine's HP value set to zero.

*** If anyone has any suggestions on how to improve, please let me know as I welcome any critisizm and I'm still new at all this mintest modding and lua scripting! Thanks! *** I have also used the same principle to hack around the breath limitation. It's all so messy... but hopefully the devs can allow us to edit the engine's HP and Breath values soon.. then I can throw away all this code! LOL.

The code below runs inside globalstep function. Also...
- rpg.HEALTH_HARD_CODED_MAX = 20 // engine's limitation
- rpg[pname].health = player's 'real' health, reports to HUD
- rpg[pname].player_status = 1 when player 'alive'. When zero, entire code below is skipped at each globalstep

Code: Select all
-- check if Health values have changed since last globalstep
local hpLoss = rpg.HEALTH_HARD_CODED_MAX - player:get_hp()

-- player knocked out
if hpLoss >= rpg[pname].health then
   rpg[pname].health = 0
   rpg[pname].player_status = 0
   if rpg[pname].breath <= 0 then
      player:set_hp(0)
   end
   -- display onscreen hud stating knocked out
   rpg.showKnockedout(player)
   
-- health lost, but still 'alive'
elseif hpLoss > 0 then
   rpg[pname].health = rpg[pname].health - hpLoss
   player:set_hp(20)
   minetest.sound_play("damage", { to_player = pname,   gain = 2.0, })
end


function rpg.showKnockedout(player)
   local pname = player:get_player_name()
   
   -- drop player to the ground
   player:set_eye_offset({x=0, y=-13, z=0}, {x=0, y=0, z=0})
   default.player_attached[pname] = true
   default.player_set_animation(player, "lay", 0)
   
   -- play drop sound and save player position
   minetest.sound_play("knockedout", { to_player = pname,   gain = 2.0, })
   --rpg[pname].spawn_position = player:getpos()
   
   -- show 'knocked out' overlay on-screen
   rpg[pname]["hud_id_knockedout_effect"] = player:hud_add({
      hud_elem_type = "image",
      scale = { x = -100, y = -100 },
      position = { x = 0.5, y = 0.5 },
      text = "hud_knockedout.png",
      alignment = { x=0, y=0 },
      direction = 0             
   })
   rpg[pname]["hud_id_knockedout_text"] = player:hud_add({
      hud_elem_type = "text",
      position = {x=0.5,y=0.5},
      text = "** KNOCKED OUT **",
      number = 0xFFFFFF,
      alignment = {x=0,y=0},
      offset = {x=0, y=-15}
   })


end
 

User avatar
yyt16384
Member
 
Posts: 46
Joined: Mon Nov 03, 2014 12:16
Location: China
GitHub: yyt16384
IRC: yyt16384
In-game: yyt16384

Re: Allowing to change maximum health/breath for players

by yyt16384 » Mon Jun 20, 2016 15:58

ErrorNull wrote:The code below runs inside globalstep function. Also...
- rpg.HEALTH_HARD_CODED_MAX = 20 // engine's limitation
- rpg[pname].health = player's 'real' health, reports to HUD
- rpg[pname].player_status = 1 when player 'alive'. When zero, entire code below is skipped at each globalstep

Code: Select all
-- check if Health values have changed since last globalstep
local hpLoss = rpg.HEALTH_HARD_CODED_MAX - player:get_hp()

-- player knocked out
if hpLoss >= rpg[pname].health then
   rpg[pname].health = 0
   rpg[pname].player_status = 0
   if rpg[pname].breath <= 0 then
      player:set_hp(0)
   end
   -- display onscreen hud stating knocked out
   rpg.showKnockedout(player)
   
-- health lost, but still 'alive'
elseif hpLoss > 0 then
   rpg[pname].health = rpg[pname].health - hpLoss
   player:set_hp(20)
   minetest.sound_play("damage", { to_player = pname,   gain = 2.0, })
end


function rpg.showKnockedout(player)
   local pname = player:get_player_name()
   
   -- drop player to the ground
   player:set_eye_offset({x=0, y=-13, z=0}, {x=0, y=0, z=0})
   default.player_attached[pname] = true
   default.player_set_animation(player, "lay", 0)
   
   -- play drop sound and save player position
   minetest.sound_play("knockedout", { to_player = pname,   gain = 2.0, })
   --rpg[pname].spawn_position = player:getpos()
   
   -- show 'knocked out' overlay on-screen
   rpg[pname]["hud_id_knockedout_effect"] = player:hud_add({
      hud_elem_type = "image",
      scale = { x = -100, y = -100 },
      position = { x = 0.5, y = 0.5 },
      text = "hud_knockedout.png",
      alignment = { x=0, y=0 },
      direction = 0             
   })
   rpg[pname]["hud_id_knockedout_text"] = player:hud_add({
      hud_elem_type = "text",
      position = {x=0.5,y=0.5},
      text = "** KNOCKED OUT **",
      number = 0xFFFFFF,
      alignment = {x=0,y=0},
      offset = {x=0, y=-15}
   })


end


minetest.register_on_player_hpchange may be useful here...
 

User avatar
burli
Member
 
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Allowing to change maximum health/breath for players

by burli » Tue Jun 21, 2016 11:28

yyt16384 wrote:minetest.register_on_player_hpchange may be useful here...

You mean something like this?

http://dev.minetest.net/minetest.register_on_hpchange
 

User avatar
ErrorNull
Member
 
Posts: 201
Joined: Thu Mar 03, 2016 00:43

Re: Allowing to change maximum health/breath for players

by ErrorNull » Tue Jun 21, 2016 14:20

ah yes i forgot about this new register function. i will incorporate that asap. thanks for pointing that out!
 

User avatar
orwell
Member
 
Posts: 794
Joined: Wed Jun 24, 2015 18:45
Location: Raxacoricofallapatorius
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell

Re: Allowing to change maximum health/breath for players

by orwell » Tue Jun 21, 2016 14:45

Wuzzy wrote:This suggestion requires to modify the HUD, like this:

3. Modify the interface to handle large numbers:
If a player’s max health is greater than 10 hearts, display the health like this:
Code: Select all
<hearts>/<max. hearts> ♥


For example, for a health of 15 out of 30 hearts, show “15/30 ” instead of “♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥”. For 10.5 hearts, show “10.5/30 ”.
The heart symbol serves like a unit symbol here, as in “5 m”, “17 kg”, etc.

I think the mod that modifies the HP maximum should be responsible to handle this itself, either the way you suggested or using multiple lines, or just scaling the HP value down on 10 hearts. This is no problem since all HUD elements (even the one for HP) are managed by the server.
The problem of monsters (or other things) doing no damage at all can easily be cast away by just multiplying all damage and HP values by, let's say 10. So if a player has 200HP, the hand can do 5 damage and 2 hand-hits equal 1 HP in regular 20HP setup, which is not possible yet. Still, when updating the HUD, the HP value is divided by 10, so that 200HP are shown as the regular 10 hearts in the HUD.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
Wuzzy
Member
 
Posts: 3640
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Allowing to change maximum health/breath for players

by Wuzzy » Thu Jun 23, 2016 03:01

orwell: No. Minetest should at least have a sane default way to display health which just works out of the box. This includes modified max. health. I would hate to be required to add pointless boilerplate code only to change the max. health. Changing the max. health should really just involve a single function call and you're done.

But there is already the option to disable the default health display so you can add your own HUD elements to replace it.

The problem of monsters (or other things) doing no damage at all can easily be cast away by just multiplying all damage and HP values by, let's say 10. So if a player has 200HP, the hand can do 5 damage and 2 hand-hits equal 1 HP in regular 20HP setup, which is not possible yet. Still, when updating the HUD, the HP value is divided by 10, so that 200HP are shown as the regular 10 hearts in the HUD.

This is completely out of scope of this suggestion. It should be entirely up to the subgame to balance the damage values. It could be done in a way like you suggested, or differently.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 

User avatar
Linuxdirk
Member
 
Posts: 2212
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

Re: Allowing to change maximum health/breath for players

by Linuxdirk » Tue Jul 25, 2017 05:48

I'd say stick with 10 hearts in GUI (no need to change any texture packs or mods modifying the hearts display) but allow HPmax to be changed and then simply evenly distribute the HP value to the hearts so one heart always stands for HPmax/10.
 

User avatar
GreenDimond
Member
 
Posts: 1273
Joined: Wed Oct 28, 2015 01:26
Location: SCP-3008
GitHub: GreenXenith
IRC: GreenDimond
In-game: GreenDimond

Re: Allowing to change maximum health/breath for players

by GreenDimond » Tue Jul 25, 2017 06:23

I agree with Linuxdirk, though I would want it so I could add more HUD elements for hearts if I wanted to.
Y▹uTube | Mods | Patre●n | Twitter | Minetest Discord | GreenDimond#3232

Hey, you. You're finally awake.
You were trying to view their profile, right? Found the rest of their signature, same as us, and that guest over there.
 

User avatar
orwell
Member
 
Posts: 794
Joined: Wed Jun 24, 2015 18:45
Location: Raxacoricofallapatorius
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell

Re: Allowing to change maximum health/breath for players

by orwell » Fri Jul 28, 2017 15:12

Linuxdirk wrote:I'd say stick with 10 hearts in GUI (no need to change any texture packs or mods modifying the hearts display) but allow HPmax to be changed and then simply evenly distribute the HP value to the hearts so one heart always stands for HPmax/10.

This is exactly my opinion, although mods still should be able to modify the default display.
Maybe imagine an adventure map where you can find heart containers, just like Zelda :)
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

Next

Return to Feature Discussion



Who is online

Users browsing this forum: No registered users and 4 guests