Raised This Month: $ Target: $400
 0% 

question on setting someones health on the damage event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kaddar
Member
Join Date: Jul 2004
Old 07-30-2004 , 21:08   question on setting someones health on the damage event
Reply With Quote #1

let's say I have a damage event, and I wish for the person to take half damage always, if someone deals, say, 10 damage to them, and they have 8 life.

Now, my code is something like this:


Code:
		new damage = read_data(2) 
		if(is_user_alive(id)==1)
		{
			damage = floatround(float(get_user_health(id)) + (float(damage) * 0.5))
 			set_user_health(id, damage)
   		}
Now, by this code, the example above, the player would die, so I was wondering if I did this without the if statement as so:


Code:
			damage = floatround(float(get_user_health(id)) + (float(damage) * 0.5))
 			set_user_health(id, damage)
Wouldn't this cause problems where the player dies and then comes back to life again? There seems to be no way to reduce ALL damage by one half, only most damage except for lethal damage. Is this correct?
kaddar is offline
liOVERLOADil
Junior Member
Join Date: Jul 2004
Old 07-31-2004 , 11:09  
Reply With Quote #2

The only way I could think of doing this is if you where to...

1 - block damage to player
2 - retrieve the damage
3 - calculate half-damage
4 - apply damage.

And I'm pretty sure that once a player dies, he is dead and cannot come
back to life unless he was respawned or something.
__________________
liOVERLOADil is offline
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 07-31-2004 , 13:07  
Reply With Quote #3

Capture the damage event, block it and substitue your own
Use code like this, btw use [ small] [ /small]
Code:
new damage = read_data(2) write_data(2,damage/2)
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull is offline
kaddar
Member
Join Date: Jul 2004
Old 07-31-2004 , 14:51  
Reply With Quote #4

Sounds pretty easy, basically:

Declare a damage event, then do this:



Code:
public damage_event(id) { new damage = read_data(2) write_data(2,damage/2) return PLUGIN_CONTINUE }

Thanks.
kaddar is offline
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 07-31-2004 , 15:55  
Reply With Quote #5

Yea, try that
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull is offline
Ingram
Veteran Member
Join Date: May 2004
Old 07-31-2004 , 17:25  
Reply With Quote #6

wouldn't it have to be PLUGIN_HANDLED, otherwise isn't he just telling it to continue with the damage?
Ingram is offline
Peli
Veteran Member
Join Date: Mar 2004
Location: San Diego, CA
Old 07-31-2004 , 17:37  
Reply With Quote #7

I think it should have plugin_CONTINUE so that it keeps dividing the damage by 2 that is done.
Peli is offline
Send a message via MSN to Peli
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 07:10.


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