AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Required Code for Ham_TakeDamage to get proper Damage (https://forums.alliedmods.net/showthread.php?t=244783)

souvikdas95 07-23-2014 14:25

Required Code for Ham_TakeDamage to get proper Damage
 
Just like in Damage event, I want to use Ham_TakeDamage to get the damage done to the victim. However I have some problem with getting the correct damage. It's something related to offsets as it has been described here : https://forums.alliedmods.net/showpo...8&postcount=71

However, as a function, it's not giving the correct damage. I want to use it instead of Damage event as it's a little quicker than that. As Tested, it's 0.00845 seconds or 8ms faster which is quite a big difference.

So, please if any one could make the function similar to the Damage event function, It would be really grateful :)

Flick3rR 07-23-2014 14:28

Re: Required Code for Ham_TakeDamage to get proper Damage
 
Well, the fourth parameter of Ham_TakeDamage is the taken damage, but floated. You can use floatround() to get it as an integer, did you try it?

souvikdas95 07-23-2014 14:29

Re: Required Code for Ham_TakeDamage to get proper Damage
 
yes but it's giving OFF-CHART values than actual inflicted damage :(
Sometimes, it gives correct damage. Sometimes different damage.
eg. If I damage myself with an HE GRENADE, it gives correct damage... but den some does a HEADSHOT to me, and it gives double the damage...

Flick3rR 07-23-2014 14:34

Re: Required Code for Ham_TakeDamage to get proper Damage
 
Double, you mean like if it is HS with AK (the damage is 140), it shows 280? That's strange...
Well, if so, I guess I will stand next to you, trying to understand how to get most properly the damage taken.

Arkshine 07-23-2014 15:56

Re: Required Code for Ham_TakeDamage to get proper Damage
 
To get the real damage done (after calculation armor, weapon power, etc), you need to hook TakeDamage as post, and retrieve value of pev_dmg_take, which is used by Damage event after.

Please search before posting, already asked/answered many times, and stop with your weird request/assumptions each time. :/

Quote:

which is quite a big difference
Quite trivial.

souvikdas95 07-23-2014 16:17

Re: Required Code for Ham_TakeDamage to get proper Damage
 
@Arkshine - I searched. But I couldn't find the exact thing. Anyways, so you mean I should get the entity's value of pev_dmg_take inside TakeDamage Post Function and ignore Float:damage parameter?

PHP Code:

    static iDamage;
    
iDamage floatround entity_get_float victimEV_FL_dmg_take ), floatround_floor ); 


Arkshine 07-23-2014 17:58

Re: Required Code for Ham_TakeDamage to get proper Damage
 
Look at HLSDK, even if not CS code, this is the same kind of code, meaning, a base damage is passed, then, there are modifiers which will reduce (or increase) base damage (armor value, weapon ratio, teamate). After all that, final damage is set in pev_dmg_take.


All times are GMT -4. The time now is 13:03.

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