AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting users health mod independant (https://forums.alliedmods.net/showthread.php?t=51455)

Isobold 02-18-2007 09:39

Setting users health mod independant
 
Hi,

again one of my stupid questions. I wrote a plugin called HP Balance : http://forums.alliedmods.net/showthread.php?t=50285

It's working fine, but I need some help to improve it. Right now I set users health to some value at round start. In some mods, users may regenerate some how. How can I restrict/expand their regeneration to another health value than 100?

This needs to be mod independant!

Thx in advance, of course you will get credit and karma for your relevant help ...

XxAvalanchexX 02-18-2007 13:49

Re: Setting users health mod independant
 
Try checking their maximum HP.

Fakemeta:
Code:
new Float:maxhealth; pev(id,pev_max_health,maxhealth);

Engine:
Code:
new Float:maxhealth = entity_get_float(id,EV_FL_max_health);

Isobold 02-18-2007 14:21

Re: Setting users health mod independant
 
I do not need to know it, I need to set it to another value until next respawn ...

XxAvalanchexX 02-18-2007 17:30

Re: Setting users health mod independant
 
Uh, okay...

Fakemeta:
Code:
set_pev(id,pev_max_health,123.0);

Engine:
Code:
entity_set_float(id,EV_FL_max_health,123.0);

Lord_Destros 02-18-2007 20:55

Re: Setting users health mod independant
 
@Avalanche, he wasn't asking that.

@Isobold, I don't think thats possible without making it mod specific (j/w what mod are you talking about).

XxAvalanchexX 02-18-2007 22:01

Re: Setting users health mod independant
 
Lord_Destros: Then what was he asking?

Lord_Destros 02-19-2007 01:57

Re: Setting users health mod independant
 
Quote:

Originally Posted by XxAvalanchexX (Post 442286)
Lord_Destros: Then what was he asking?

From what I understood he's saying in some mods people automatically regain health (i.e. if shot down to 60 health from 100, they will slowly heal back up to 100). He was trying to make it so that after setting a users health if they were hurt they would auto regenerate if the mod allowed them to do so.

If I said it was impossible earlier I somewhat lied. Heres the only method I can think of:

To (re/de)generate their health:

1. Simply make a loop that gives players health every X seconds if their HP is greater than 100 UP TO whatever you initially used in set_pev.
2. To degenerate their health (they specify a value less than 100 in set_pev)
Simply make a loop that removes players health every X seconds if their HP is greater than what you initially used in set_pev.

To detect if the mod supports regeneration:

1. Check once every second to see if a players health has increased. If it has then measure the amount it has increased and over what period of time.

Downsides to this method. It will not work if they were hurt but the damage they received was not enough to trigger regeneration and if someone increases a users health via a medical kit or admin command then that will confuse the plugin.

If you want it to be mod independent I suggest just creating 2 cvars with examples shown below
sv_regeneration "<0/1>"
sv_regenerationRate "<Regeneration rate as a float in seconds>"

Isobold 02-19-2007 03:38

Re: Setting users health mod independant
 
That would not solve my problem, as I was asked to solve an issue, where people would use an health kit and regain their health up to 100 health no matter to which health amount they were set at round start (instead of regenerating to the value they got asigned at round start).

What I need is to allow health to be regenerated (by what ever event) to a value calculated at round start, so that one would not be able to have more than 67 health, while another player would be able to have 133 hp. My plugin already gives them this health at round start, and I could manage to survey that the first player would not get more than 67 hp, but how could I manage to let player two regain his 133 health by picking up a health kit? If he is at 101 health for example, he would not even pick up the health kit, so no event would follow?!?

Your idea to use a fix regeneration would not be a god idea, as wc3 for cs for example has regeneration for some characters only, others only regenerate if a healer is somewhere around.

Is there really now way to set some kind of max-health-value? HLČ makes exentsive use of this, was it only introduced there?

Lord_Destros 02-19-2007 18:39

Re: Setting users health mod independant
 
My idea isn't that good since it has far too many problems but unless you specify the recover rate by cvar (and the amount to heal) then it should be impossible as far as I know to do it well.

About your wc3 comment you would be able to check if they are within range of someone else and are the correct 'race' with correct ability before giving them the HP.

XxAvalanchexX 02-19-2007 19:18

Re: Setting users health mod independant
 
Quote:

Originally Posted by Isobold (Post 442353)
Is there really now way to set some kind of max-health-value? HLČ makes exentsive use of this, was it only introduced there?

I already posted how to do this.

Mods that give players their own health regeneration certainly use max_health. Health chargers and medkit pickups check to make sure they don't go over max_health. So, change max_health, as I showed you already.


All times are GMT -4. The time now is 00:39.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.