AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   How to subtract health? (https://forums.alliedmods.net/showthread.php?t=78321)

retsam 10-01-2008 17:45

How to subtract health?
 
Hi. This is for TF2 RTD plugin, kinda been screwing around seeing if I could add some of my own skills to it. Im fairly new to SM scripting so... Im trying to figure out how one would subtract health.

What I tried didnt work. Like, this is the code for multiplying health.

Code:

SetEntityHealth(i, RoundToCeil(classHealth[GetEntProp(i, Prop_Send, "m_iClass")] * GetConVarFloat(c_Health))); // buff the health
Then above on pluginstart,
Code:

    c_Health    = CreateConVar("sm_rtd_health","1.5","Health multiplier.");
So how do you subtract health? I tried putting - where the * is, and then like "0.4" which would be 40% less. Thats clearly not correct. Is there supposed to be a minus sign in there for the cvar or what?

bl4nk 10-01-2008 19:50

Re: How to subtract health?
 
You want to take away 40% of their life? Multiply their current life by 0.6.

retsam 10-01-2008 22:37

Re: How to subtract health?
 
Ahhh really thats it. Damn ok. :P Way over thought that one lol.

Thanks bl4nk.

ThatGuy 10-01-2008 23:01

Re: How to subtract health?
 
What commands you adding? I Added ALOT for my server myself :)

retsam 10-02-2008 00:01

Re: How to subtract health?
 
Quote:

Originally Posted by ThatGuy (Post 693869)
What commands you adding? I Added ALOT for my server myself :)


Oh ya? Might be interested in checking that out.

So far, im still working on this health one, but this badhealth one will subtract 40-50%(or whatever value you specify) health from the entire team.

I added firebomb, and freezebomb as well for bad commands. Thats it so far. If you wouldnt mind sharing, id love to see what stuff you came up with. Im kinda new and still learning sm so... So far firebomb and freezebomb just use the cvars straight out of the funcommands.cfg, so like I still have to adjust radius, time, and team affected via that config. I wanna try and make those into the rtd plugin itself.

I was also screwing around and planning on fiddling with some of the other current skills. Like I thought beacon should just stay on until they die since its such a minor "bad" skill, instead of a time period. Possibly put a custom timer. I couldnt get that to work either though. I tried to set a 60 second timer for that so it doesnt utilize the cvar timelimit, but It wouldnt work.


This leads me to another question I have for bl4nk if you see this. How do you check their current health, instead of class health? I cant find what looks at their current health first before adding the % health.

Code:

SetEntityHealth(i, RoundToCeil(classHealth[GetEntProp(i, Prop_Send, "m_iClass")] * GetConVarFloat(c_Badhealth))); // subtract the health

Antithasys 10-02-2008 00:54

Re: How to subtract health?
 
Quote:

Originally Posted by bl4nk (Post 693824)
You want to take away 40% of their life? Multiply their current life by 0.6.

% of the whole is a concept what is very mis-understood. :shock:

retsam 10-02-2008 01:18

Re: How to subtract health?
 
I think I realize what I need to figure out for this. I need to get the code to get their CURRENT health, not the entire classes normal health. That is what it is currently doing correct? Its getting their full class health, not their current health. The author of that plugin should prolly do that as well. How do you get their current health?

Code:

public DiceBadhealth(client)
{
        new maxClients = GetClientCount();

        for(new i=0; i<=maxClients; i++)
        {
                if(!IsClientInGame(i) || !IsPlayerAlive(i))
                {
                        continue;
                }

                if(GetClientTeam(i) != GetClientTeam(client))
                {
                        continue;
                }

                SetEntityHealth(i, RoundToCeil(classHealth[GetEntProp(i, Prop_Send, "m_iClass")] * GetConVarFloat(c_Badhealth))); // subtract the health
        }


Right now what it does is, reduces health based on the cvar set. However, like lets say it reduces a heavy from 300 to 120 heath. If his health goes under that, if the skill gets rolled again, it actually raises their health back to 120.

Antithasys 10-02-2008 02:15

Re: How to subtract health?
 
So... You need to convert their health into a variable and compare it with a if statement before you set it. If it would take it to zero, then fire the death event and kill the player.

bl4nk 10-02-2008 02:43

Re: How to subtract health?
 
Code:

SetEntityHealth(i, RoundToCeil(GetEntProp(i, Prop_Send, "m_iHealth") * GetConVarFloat(c_Badhealth)));

retsam 10-02-2008 04:14

Re: How to subtract health?
 
Thanks bl4nk, you rock. That works perfectly.


All times are GMT -4. The time now is 08:11.

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