Raised This Month: $51 Target: $400
 12% 

How to subtract health?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 10-01-2008 , 17:45   How to subtract health?
Reply With Quote #1

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?

Last edited by retsam; 10-01-2008 at 17:50.
retsam is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 10-01-2008 , 19:50   Re: How to subtract health?
Reply With Quote #2

You want to take away 40% of their life? Multiply their current life by 0.6.
bl4nk is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 10-01-2008 , 22:37   Re: How to subtract health?
Reply With Quote #3

Ahhh really thats it. Damn ok. Way over thought that one lol.

Thanks bl4nk.

Last edited by retsam; 10-01-2008 at 22:46.
retsam is offline
ThatGuy
Senior Member
Join Date: Nov 2007
Old 10-01-2008 , 23:01   Re: How to subtract health?
Reply With Quote #4

What commands you adding? I Added ALOT for my server myself
ThatGuy is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 10-02-2008 , 00:01   Re: How to subtract health?
Reply With Quote #5

Quote:
Originally Posted by ThatGuy View Post
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

Last edited by retsam; 10-02-2008 at 00:06.
retsam is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 10-02-2008 , 00:54   Re: How to subtract health?
Reply With Quote #6

Quote:
Originally Posted by bl4nk View Post
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.
Antithasys is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 10-02-2008 , 01:18   Re: How to subtract health?
Reply With Quote #7

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.

Last edited by retsam; 10-02-2008 at 01:25.
retsam is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 10-02-2008 , 02:15   Re: How to subtract health?
Reply With Quote #8

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.
Antithasys is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 10-02-2008 , 02:43   Re: How to subtract health?
Reply With Quote #9

Code:
SetEntityHealth(i, RoundToCeil(GetEntProp(i, Prop_Send, "m_iHealth") * GetConVarFloat(c_Badhealth)));
bl4nk is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 10-02-2008 , 04:14   Re: How to subtract health?
Reply With Quote #10

Thanks bl4nk, you rock. That works perfectly.
retsam is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:25.


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