Raised This Month: $ Target: $400
 0% 

Detecting Damage type by Bits?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 04-07-2008 , 12:13   Detecting Damage type by Bits?
Reply With Quote #1

I have written a plugin to stop fall damage, but the problem I have now, is by disabling damage from client 0, not only does fall damage stop, but all world damage, thus breaking trigger_hurts, etc. With the help of Pred and a few others, this is what I have come up with. According to Voogru though, he said it really needs to be done with the player_hurt damage bits instead of the clients. This isn't possible as the player_hurt doesn't have damage. He mentioned setting it to ignore the second call, but anyays here is the code. Any help would rock.

Code:
#include <sourcemod>
public OnPluginStart()
{
HookEvent("player_hurt",Event_PlayerHurt);
}
 
public Event_PlayerHurt(Handle:event,const String:name[],bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new offsDmgType = FindDataMapOffs(client, "m_bitsDamageType");
new newDmgType = GetEntData(client, offsDmgType);
if (newDmgType & 1<<5) {
PrintToChatAll("The Player Just Took Fall Damage");

SetEntData(client, offsDmgType, (newDmgType^=1<<5), 4, true); //remove the fall damage bits?
}
else {

PrintToChatAll("The Player Just Took Some other kind of damage");
}
}


Before I put the SetEntData line in there, you would rocket jump, it would say other type of damage. After you fell, which it recognized as fall damage, it would say all types of damage were fall damage. After putting the SetEntData line, now it detects WHEN you take fall damage, but then the next damage taken immediately after is also detected as fall damage, then it goes back to normal.
CrimsonGT is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 04-07-2008 , 15:25   Re: Detecting Damage type by Bits?
Reply With Quote #2

Why not just restore their health if it's detected as fall damage, and not restore it when it's detected as something else? That way you don't have to deal with stripping things from something so complex as that.
bl4nk is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 04-07-2008 , 18:10   Re: Detecting Damage type by Bits?
Reply With Quote #3

What im saying is if they fall, and its detected as fall damage, then it would restore health. But right now, the next damage they recieve, say from a rocket will also restore their health, then it would go back to normal until they recieve damage again.

If I get rid of the SetEntData line, then after they sustain fall damage, it will register all damage as fall damage until they die.
CrimsonGT is offline
toazron1
Senior Member
Join Date: Oct 2006
Old 04-08-2008 , 12:08   Re: Detecting Damage type by Bits?
Reply With Quote #4

assuming that HL2 works like HL1 did, if you returned an attacker ID on the person who took fall damage it would be client 0 (worldspawn)
__________________
toazron1 is offline
Send a message via AIM to toazron1
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 12:16.


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