Raised This Month: $59 Target: $400
 14% 

HP damage sound bug fix


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Gameplay        Approver:   ConnorMcLeod (74)
Simo123
Junior Member
Join Date: Feb 2009
Old 02-24-2012 , 14:27   HP damage sound bug fix
Reply With Quote #1

Description
This plugin fixes a bug when you fall/jump from a low height to the ground, where it will not apply/reduce the damage but it will still play the damage sound. This fix blocks/ignores the damage sound when you have fallen/jumped from that low height to the ground.

1.What actually happens is that the collision model is too late being with the real character/model itself (~4 units away).
2.The hp number conversion rounding is wrong in the hl engine which do e.g. round a number of 0.9 to 0 instead of 1.0 because of a wrong float to int conversion, so when the hp gets less than 1 damage it rounds it to 0 damage which will just play the sound and ignore the hp reduction.


Modules
-amxmodx
-hamsandwich

Credits
Arkshine - Explaination of how the bug occurs (see #13 post).
protoN - Told me that health isn't a float, about the collision model and found a good place to test the bug on (video below).
Bla^ - Told me the rounding bug.


Other info
From beginning I thought that health was a float and that you could jump 10 times and it then would reduce the hp, but that wasn't true, it was actually a bug as explained above.

I made a fast video where the bug is shown.
http://youtu.be/oA5Y24WrkNY

Tested with amxmodx 1.8.1 in Counter-Strike 1.6.
Attached Files
File Type: sma Get Plugin or Get Source (dmg_sound_bug_fix.sma - 2173 views - 395 Bytes)

Last edited by Simo123; 08-16-2015 at 14:37. Reason: Updated description.
Simo123 is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 02-24-2012 , 15:02   Re: HP damage sound bug fix
Reply With Quote #2

I hated that bug and the code looks pretty simple.

Good job.
__________________
Accepting paid work for clans and communities. !Plugins & Models!
Don't hesitate to contact me.
bibu is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 02-24-2012 , 15:34   Re: HP damage sound bug fix
Reply With Quote #3

Good job.

That's so easy but nobody has thought to this solution.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Old 02-25-2012, 14:10
echo_cs
This message has been deleted by xPaw. Reason: You are not helpful.
Old 02-25-2012, 14:20
echo_cs
This message has been deleted by xPaw. Reason: You are not helpful.
Old 02-25-2012, 14:36
Devil259
This message has been deleted by Devil259.
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 02-25-2012 , 14:44   Re: HP damage sound bug fix
Reply With Quote #4

Nice bugfix, though only one problem.
This damage can come also from a gun at a big distance so you need to check the damage type in order to be 100% sure that the damage is because of a fall.


The only problem that I see here is the situation where the damage comes from something else and can be multiplied. For example if someone shoots you with a glock pistol at a big distance and does 1 damage to you and hits your head the damage that you will receive will be 4. So you need to watch out for the hitgroup damage multiplication constants.

Check this out:

PHP Code:
#define OFFSET_LAST_HIT_GROUP      75 
#define EXTRAOFFSET_PL_LINUX        5 

new const Float:hitgroup_multi[] = 

    
1.0,  // HIT_GENERIC 
    
4.0,  // HIT_HEAD 
    
1.0,  // HIT_CHEST 
    
1.25// HIT_STOMACH 
    
1.0,  // HIT_LEFTARM 
    
1.0,  // HIT_RIGHTARM 
    
0.75// HIT_LEFTLEG 
    
0.75  // HIT_RIGHTLEG 
    
0.0   // HIT_SHIELD 
}

#include <amxmodx>
#include <hamsandwich>

public plugin_init( )
{
    
register_plugin"Dmg sound bug fix""1.0""Simo123" );

    
RegisterHamHam_TakeDamage"player""Forward_HamClientTakeDamage" );
}

public 
Forward_HamClientTakeDamageiClientiInflictoriAttackerFloat:fDamageiDamagebits )
{
    new 
hitgroup get_pdata_int(victimOFFSET_LAST_HIT_GROUPEXTRAOFFSET_PL_LINUX// Get the hitgroup so that we know if the damage is multiplied or not.
    
fDamage *= hitgroup_multi[hitgroup]; // This is how you obtain the real damage 
    
if ( fDamage 1.0 )
    {
        return 
HAM_SUPERCEDE;
    }

    return 
HAM_IGNORED;

__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 02-25-2012 at 15:04.
ot_207 is offline
Old 02-25-2012, 14:46
echo_cs
This message has been deleted by xPaw. Reason: Please stop posting, you are not contributing.
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 02-25-2012 , 14:48   Re: HP damage sound bug fix
Reply With Quote #5

@echo_cs: What is the logic behind that code?
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Old 02-25-2012, 14:54
echo_cs
This message has been deleted by xPaw. Reason: Please stop posting, you are not contributing.
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 02-25-2012 , 14:59   Re: HP damage sound bug fix
Reply With Quote #6

Quote:
Originally Posted by echo_cs View Post
If the damge is longer than 100.0 the demage will be 100.0
And? What help would that do? Since a player can have 1000000 health?
It's a bugfix plugin not a gravity feature plugin.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 02-25-2012 at 15:01.
ot_207 is offline
Old 02-25-2012, 15:13
echo_cs
This message has been deleted by xPaw. Reason: Please stop posting, you are not contributing.
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 02-25-2012 , 15:34   Re: HP damage sound bug fix
Reply With Quote #7

@ot_207, are you sure hitgroups are needed on fall damage? Wouldn't checking DMG_FALL be an easier solution?
__________________
xPaw is offline
echo_cs
Senior Member
Join Date: Dec 2011
Old 02-25-2012 , 15:48   Re: HP damage sound bug fix
Reply With Quote #8

Oook Xpaw

I Have A reply

The amxx is upproved for our life ?

No It's Unapproved, It's a games A bad Games
The players will be addicted and you olso

Go Out of your home And Play the real Games And save yourself from the prison
__________________
Pawn (5%)

C (80%)

C++ (20%)

SQL (5%)
echo_cs is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 02-25-2012 , 15:51   Re: HP damage sound bug fix
Reply With Quote #9

Quote:
Originally Posted by xPaw View Post
@ot_207, are you sure hitgroups are needed on fall damage? Wouldn't checking DMG_FALL be an easier solution?
In basically hit 2 birds with 1 stone.
You always block < 1.0 damage even from fall and bullets that basically do not damage. Also it depends if there are plugins that modify that hitgroup intentionally and it would be a good idea to check IMO.

If you check with DMG_FALL you basically limit everything to fall. The only problem is if a plugin alters the private data you basically stop damage that can be dealt in some situations.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
echo_cs
Senior Member
Join Date: Dec 2011
Old 02-25-2012 , 15:51   Re: HP damage sound bug fix
Reply With Quote #10

By By alliedmods I will Return One day

My Real age is 13

And I learned Pawn & C++ And Im Arabic And I have stady English 3 hear only
__________________
Pawn (5%)

C (80%)

C++ (20%)

SQL (5%)
echo_cs is offline
Reply


Thread Tools
Display Modes

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:41.


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