Raised This Month: $32 Target: $400
 8% 

Solved How to get real damage before it has been dealt


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 01-23-2019 , 07:07   How to get real damage before it has been dealt
Reply With Quote #1

[CSGO]
So, I want to prevent lethal damage once, but the problem is to get real damage, not theorical.
I tried to use SDK hooks on take damage, but it is not actually real. For example, if someone does headshot with m4 and enemy has helmet he shouldnt die, real damage is about 90, but on take damage shows over 100.
with ontake damage alive it sometimes shows too low damage, because I compare damage with player health and sometimes when health is enough, player anyways dies.

Is it possible to get exact real damage? Probably any extensions?
Thanks in advance

PHP Code:
public Action SDK_OnTakeDamage(int victimintattackerintinflictorfloatdamageAmountinttypeintweaponfloat damageForce[3], float damagepos[3])
{
    if(
ValidPlayer(victim))
    {    
        if(
damageAmount 1.0)
        {
            if(
ValidPlayer(attacker))
            {
                if(
GetClientTeam(victim)!=GetClientTeam(attacker))
                {
                    if(
/*some checks*/)
                    {
                        
int currhealth GetClientHealth(victim);
                        if(
/*more checks*/)
                        {
                            if(
currhealth<=damageAmount))
                            {
                                
damageAmount *= 0.0;
                                return 
Plugin_Changed;
                            }
                        }
                    }
                }
            }
        }
    }
    return 
Plugin_Continue;


Last edited by impossible_cc; 01-24-2019 at 10:34. Reason: solved
impossible_cc is offline
adma
Senior Member
Join Date: Oct 2015
Old 01-23-2019 , 09:08   Re: How to get real damage before it has been dealt
Reply With Quote #2

There is a player_hurt event which gives you info on hp damage and armour damage, but afaik this happens after the player takes damage. Perhaps you could try it in a pre-hook and then change the clients health using SetEntityHealth. Not sure if it'll work, most likely the player will die before health changes but you could give it a try.
adma is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 01-23-2019 , 10:27   Re: How to get real damage before it has been dealt
Reply With Quote #3

Just check if the player is getting hit in the head or chest and has helmet or kevlar.

Some of the math for a base source game:
https://github.com/ValveSoftware/sou...ayer.cpp#L1158

It may be slightly different in csgo
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
Indarello
Senior Member
Join Date: Nov 2015
Location: Russia
Old 01-23-2019 , 11:39   Re: How to get real damage before it has been dealt
Reply With Quote #4

Sdkhook ontakedamage_ALIVE
Indarello is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-23-2019 , 11:47   Re: How to get real damage before it has been dealt
Reply With Quote #5

SDKHook_OnTakeDamageAlive
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 01-23-2019 , 12:46   Re: How to get real damage before it has been dealt
Reply With Quote #6

I have tried SDK on take damage ALIVE but I find it unreliable, because, as I write in first post, actual ingame damage is more than it is supposed to be.
impossible_cc is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 01-23-2019 , 12:47   Re: How to get real damage before it has been dealt
Reply With Quote #7

Quote:
Originally Posted by 1337norway View Post
Just check if the player is getting hit in the head or chest and has helmet or kevlar.

Some of the math for a base source game:
https://github.com/ValveSoftware/sou...ayer.cpp#L1158

It may be slightly different in csgo
I work with mod, which has a lot of damage modifiers/multipliers, so that isnot possible in my case
impossible_cc is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-23-2019 , 13:18   Re: How to get real damage before it has been dealt
Reply With Quote #8

Quote:
Originally Posted by impossible_cc View Post
I work with mod, which has a lot of damage modifiers/multipliers, so that isnot possible in my case
Are you really ignoring the two correct answers we gave?
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Indarello
Senior Member
Join Date: Nov 2015
Location: Russia
Old 01-23-2019 , 13:36   Re: How to get real damage before it has been dealt
Reply With Quote #9

Quote:
Originally Posted by impossible_cc View Post
I work with mod, which has a lot of damage modifiers/multipliers, so that isnot possible in my case
I have warcraft server and I have 10+ damage modifires and 30+ other modifires in this hook and all works normaly as far as I tested

Last edited by Indarello; 01-23-2019 at 13:37.
Indarello is offline
Indarello
Senior Member
Join Date: Nov 2015
Location: Russia
Old 01-23-2019 , 13:47   Re: How to get real damage before it has been dealt
Reply With Quote #10

You use it like this:
Code:
SDKHook_OnTakeDamageAlive
...
bool changed;
if (haveskillarmor[victim])
{
  Damage *= 0.5;
  changed = true;
}
if (haveskilldamage[attacker])
{
  Damage *= 3.0;
  changed = true;
}

if(changed)
{
  Printtochat damage
  Return plugin_changed
}
Return plugin_continue
Indarello 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 22:45.


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