AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   HP damage sound bug fix (https://forums.alliedmods.net/showthread.php?t=179009)

Simo123 02-24-2012 13:27

HP damage sound bug fix
 
1 Attachment(s)
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.

bibu 02-24-2012 14:02

Re: HP damage sound bug fix
 
I hated that bug and the code looks pretty simple.

Good job.

Devil259 02-24-2012 14:34

Re: HP damage sound bug fix
 
Good job.

That's so easy but nobody has thought to this solution. :mrgreen:

ot_207 02-25-2012 13:44

Re: HP damage sound bug fix
 
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;



ot_207 02-25-2012 13:48

Re: HP damage sound bug fix
 
@echo_cs: What is the logic behind that code?

ot_207 02-25-2012 13:59

Re: HP damage sound bug fix
 
Quote:

Originally Posted by echo_cs (Post 1657274)
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.

xPaw 02-25-2012 14:34

Re: HP damage sound bug fix
 
@ot_207, are you sure hitgroups are needed on fall damage? Wouldn't checking DMG_FALL be an easier solution?

echo_cs 02-25-2012 14:48

Re: HP damage sound bug fix
 
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

ot_207 02-25-2012 14:51

Re: HP damage sound bug fix
 
Quote:

Originally Posted by xPaw (Post 1657306)
@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.

echo_cs 02-25-2012 14:51

Re: HP damage sound bug fix
 
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


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

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