[Server] Custom health (Updated 6/21/17)

Author Topic: [Server] Custom health (Updated 6/21/17)  (Read 7500 times)

It's been attempted over the years (2012, Fed 2014, July 2014, 2016, 2017) to make a proper health system working.
Due to how packages prioritize in add-ons sometimes the health is affected even if there's a special armor system. Well, I found a new way.



How does it work?
I had to rewrite the armor function, I did remove the vehicle health events, but I don't think anyone was really using those anyway, so it's less work for me if no one plans to use them.

The origin of me making this was an inspiration of making RPGs, if anyone in 2012 remembers me and played my servers, you might know about "Level UP RPG", I integrated the health system but there were times it went very buggy and crashed my server. Over the years I gained experience on these functions and improve them.

The health system is very useful and I would like to share it for everyone for use. The only concern I still have with it is mods that use maxDamage (it's a static variable in player datablocks), which I am unable to get around that unless I edit the add-on.



Modding
If you want an add-on edited using health variables, you can PM me or post it here and I can fix it up, or if you want to edit it, go ahead and use these resource functions from here: Support_HealthDetection.cs
      object.getHealth() replaces object.getDatablock().maxDamage - object.getDamageLevel()
      object.getMaxHealth() replaces object.getDatablock().maxDamage



Download
As you can see the version (v9), it has been through a lot of revisions. As far as I know, there's no bugs, and this add-on should work even with armor add-ons.

There are events:
setMaxHealth - Sets their max health, of course
addMaxHealth - Adds max health to their current max health
setInvulnerbilityTime - They are immune to both damage and knockback for a certain amount of time
setFInvulnerbilityTime - They are immune from fall damage for a certain amount of time
setInvulnerbility - They are immune to both damage and knockback

There are a few additional client events setMaxHealth and saveHealth, you need to use saveHealth on the client for it to save when they leave, it will load what their health and max health is when they come back.
Setting max health on a client will save until they leave (unless you used the saveHealth event on a client (not the player))

Make sure $Pref::Server::MaxHealth_Enabled is set to 1 (or use /ToggleHealthSaver) for health save events to show up, it's off by default
If events still do not show, try /requestEventTables

Download (Google Drive): Support_NewHealth
« Last Edit: June 21, 2017, 05:25:35 PM by Kyuande »



Does setmaxhealth save that health for various lives, rejoining, etc? Or is it one life only.

Does setmaxhealth save that health for various lives, rejoining, etc? Or is it one life only.
Oh, yea, I forgot to mention this, my bad. Even I don't remember all of the features. Should be in the topic now
« Last Edit: June 15, 2017, 11:18:57 AM by Kyuande »

Would there be a way to add a pref to determine the max health that they can get? So something along the lines of they can only get up too 10000hp unless I increase the max health pref to 15000 or something along those lines. It could also have a message saying "you've reached the maximum amount of health"

Only reason I ask is for my RPG that I'm making, they can get more health based on what they do, but I would like to have a maximum amount they can reach just to control from people gaining too much health so they become OP

Ah very good then. Also great to see that health is automatically loaded and you don't need an output load.
Edit: Would a weapon damage modifier be a possibility as well?
Double Edit: There is no savehealth under client?
« Last Edit: June 15, 2017, 01:26:35 PM by Blockhead31735 »

can you simplify what this is for a brainlet like me


can you simplify what this is for a brainlet like me

This is a system that replaces most of Blockland's health-related functions and adds more functionality to it. Using this, you can change the max health of players individually (otherwise you'd have to change the max health of the player's playertype), make them invulnerable (spawn protection, for instance) and save health for loading later.

It's an updated version of Zzerver_NewHealth, in other words.

Double Edit: There is no savehealth under client?
There should be. Make sure $Pref::Server::MaxHealth_Enabled is set to 1 (or use /ToggleHealthSaver)
If events still do not show, try /requestEventTables
(added this to OP)

Edit: Would a weapon damage modifier be a possibility as well?
This doesn't fit under custom health mod, I can release this as something else though. I'll see what I can do.

This is really nice after I saw the invulnerability I thought about a mirror-type invulnerability? where it reflects all damage dealt back to the dealer?

This is a system that replaces most of Blockland's health-related functions and adds more functionality to it. Using this, you can change the max health of players individually (otherwise you'd have to change the max health of the player's playertype), make them invulnerable (spawn protection, for instance) and save health for loading later.

It's an updated version of Zzerver_NewHealth, in other words.
sick

Does modified max health work with Support_Persistence?

So for example if I had this mod and Support_Persistence enabled, And if I modified my max health, Left and then rejoined.
Would I still have my modified max health?

Also, Does this work with bot holes?

Does modified max health work with Support_Persistence?

So for example if I had this mod and Support_Persistence enabled, And if I modified my max health, Left and then rejoined.
Would I still have my modified max health?
Due to how things work, it will not work with Script_Player_Persistence, it would have to be remade for it to work properly. Which is why I made save/load health events here.

I am not sure if it may break with Script_Player_Persistence as I have not tested that. As soon as I get on Blockland I will test it right away.

Also, Does this work with bot holes?
Yes. It is designed for both Players and Bots. Vehicles are left out of the picture because I don't think anyone use the custom max health for vehicles at all anyway. Vehicles require a little more effort and I want to avoid that if no one even plans to use it.