HAM_OVERRIDE usage in Ham_TakeDamage event to change value
i heard HAM_OVERRIDE make call still be executed, but instead will change the return value. so i want to change value in ham_takedamage with HAM_OVERRIDE cuz there's a bug on my server so sometimes knife right attack can hit player in non-body-part and deal 195dmg (mb a generic hitzone or something like that), so i want make a check if dmg is 195 and weapon made this dmg is a knife and change 195 to 65 and let other plugins or this plugin extension take care of changed dmg, but i saw almost no HAM_OVERRIDE usage in plugins so i'm asking how to.
|
Re: HAM_OVERRIDE usage in Ham_TakeDamage event to change value
Hi,
To answer your original question, you could override the return value like this: Code:
In addition to SetHamReturnInteger, there is SetHamReturnFloat, SetHamReturnVector, SetHamReturnEntity, and SetHamReturnString, depending on the return type of the function. It seems that using HAM_OVERRIDE will let the original TakeDamage go through as usual, but instead of returning whatever it would normally return, it will return what you set. In comparison, using HAM_SUPERCEDE will stop the original TakeDamage function entirely, in addition to returning what you set. However, the catch here is that the return value for TakeDamage isn't the amount of damage done. The amount of damage is actually passed as a parameter. So you can either stop the original TakeDamage and do another with your new damage, or potentially change the value of the parameter. Here is how you would do the former: Code:
The latter method, which I've never tried but should work, would go like this: Code:
Again, there are several other SetHamParam* functions based on the paramater type. The first paramter for SetHamParamFloat is 4 because that is the parameter number for damage in TakeDamage (id would be parameter 1). I'm not sure if you actually need to use HAM_OVERRIDE for this case; you could try both with and without and see what works. The only other thing you should be careful of is to make sure that the knife damage done is really 195.0 exactly, not some other decimal value or a higher number that gets reduced because of armor. If it is something weird, you could probably just check to see if the damage is more than or equal to 195.0 and is not a headshot. Hopefully this helps you. Cheers, Ava |
Re: HAM_OVERRIDE usage in Ham_TakeDamage event to change value
why do you check for dmg_grenade? =\ can knife deal dmg with granade damagetype? =\
* thx, works fine ^_^ now players will be able to have fun at knife maps normally |
Re: HAM_OVERRIDE usage in Ham_TakeDamage event to change value
Quote:
|
Re: HAM_OVERRIDE usage in Ham_TakeDamage event to change value
Quote:
|
Re: HAM_OVERRIDE usage in Ham_TakeDamage event to change value
Quote:
|
Re: HAM_OVERRIDE usage in Ham_TakeDamage event to change value
HE CHECKS IF DAMAGE IS NOT FROM GRENADE BUT OTHER WEAPON!
Learn to read FFS... |
Re: HAM_OVERRIDE usage in Ham_TakeDamage event to change value
^^ forgot to read
but what for is that check needed anyway? ^^" |
Re: HAM_OVERRIDE usage in Ham_TakeDamage event to change value
Quote:
.Owyn.: You have it right. I check to make sure that the damage is not from a grenade, so that it won't count if they throw a grenade and then switch to the knife. I don't know if a grenade can actually deal 195.0 damage or not; I just put it there for safety. You can probably remove it and not have any problems if you'd like. |
Re: HAM_OVERRIDE usage in Ham_TakeDamage event to change value
I'm guessing CZ nades can deal that much, so it's not an useless check after all heh.
|
| All times are GMT -4. The time now is 17:07. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.