AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved How to get real damage before it has been dealt (https://forums.alliedmods.net/showthread.php?t=313802)

impossible_cc 01-23-2019 07:07

How to get real damage before it has been dealt
 
[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;



adma 01-23-2019 09:08

Re: How to get real damage before it has been dealt
 
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.

backwards 01-23-2019 10:27

Re: How to get real damage before it has been dealt
 
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

Indarello 01-23-2019 11:39

Re: How to get real damage before it has been dealt
 
Sdkhook ontakedamage_ALIVE

eyal282 01-23-2019 11:47

Re: How to get real damage before it has been dealt
 
SDKHook_OnTakeDamageAlive

impossible_cc 01-23-2019 12:46

Re: How to get real damage before it has been dealt
 
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 01-23-2019 12:47

Re: How to get real damage before it has been dealt
 
Quote:

Originally Posted by 1337norway (Post 2636193)
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

eyal282 01-23-2019 13:18

Re: How to get real damage before it has been dealt
 
Quote:

Originally Posted by impossible_cc (Post 2636234)
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?

Indarello 01-23-2019 13:36

Re: How to get real damage before it has been dealt
 
Quote:

Originally Posted by impossible_cc (Post 2636234)
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

Indarello 01-23-2019 13:47

Re: How to get real damage before it has been dealt
 
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



All times are GMT -4. The time now is 09:22.

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