Raised This Month: $ Target: $400
 0% 

Solved Ham_TakeDamage duplicates event when shooting at the top of the hull


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 11-09-2023 , 20:50   Ham_TakeDamage duplicates event when shooting at the top of the hull
Reply With Quote #1

I found strange bug when you are at the top of enemy hull and are hitting the enemy, ham fires 2 events.
PHP Code:
public plugin_init()
{
    
RegisterHam(Ham_TakeDamage"player""ham_takedamage"1);
}

public 
ham_takedamage(victiminflictorattackerFloat:f_damagedamage_bits)
{
    
server_print("[%f] attacker: %d, victim: %d, inflictor: %d, \
        weapon: %d, damage: %d, hp_left: %d"
,
        
get_gametime(), attackervictiminflictorweapondamage,
        
get_user_health(victim));

I got these messages in the terminal:
PHP Code:
  [30.316444attacker2victim4inflictor2weapon26damage39hp_left61
  
[30.316444attacker2victim4inflictor2weapon26damage67hp_left33 
When I am shooting at front of the enemy like we do in usual, all works as expected. Is there any workaround I can use to eliminate this bug? The only idea that comes to my mind is delay this message for the next frame, but unfortunately I need this code in a library that I will use in my plugins and wrong timing (i.e. frame) may be undesirable.
Attached Thumbnails
Click image for larger version

Name:	2023-11-10_03:32:52.jpg
Views:	34
Size:	85.3 KB
ID:	202167  

Last edited by damage220; 11-09-2023 at 22:56.
damage220 is offline
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 11-09-2023 , 22:54   Re: Ham_TakeDamage duplicates event when shooting at the top of the hull
Reply With Quote #2

Oh, my... This is not a bug but double hit. I realized this when I added hitzone to log message. The bullet first hits chest, then it hits leg. The only confusing part here is that the damage done is cumulative for both hits rather than to be separate. This is because I use
PHP Code:
damage floatround(entity_get_float(victimEV_FL_dmg_take)); 
to get damage, since f_damage provided by the forward does not respect player's armor.
In this case I can separate these hits with simple subtraction.

Last edited by damage220; 11-09-2023 at 22:59.
damage220 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 05:28.


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