Raised This Month: $12 Target: $400
 3% 

[L4D2]How to get the hit group in SDKHook_OnTakDamage?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-16-2022 , 08:13   [L4D2]How to get the hit group in SDKHook_OnTakDamage?
Reply With Quote #1

I want to modify the damage base on the hit group, but it seem no way to get it except event "player_hurt".
As far as i know, event is too late to change the damage. Use SDKHook_TakeDamage looks not good because it cause the other damage of one shot.
LinLinLin is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 11-16-2022 , 08:30   Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
Reply With Quote #2

use SDKHook_TraceAttack

PHP Code:
// TraceAttack
function Action (int victimint &attackerint &inflictorfloat &damageint &damagetypeint &ammotypeint hitboxint hitgroup); 
It usually runs before TakeDamage
__________________
Marttt is offline
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-16-2022 , 09:47   Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
Reply With Quote #3

got it, i will try this hook tonight.
LinLinLin is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 11-16-2022 , 15:20   Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
Reply With Quote #4

You can use also the event player_hurt but is kinda the last event, if you need modify something then goes for TraceAttack/TakeDamage
__________________
Marttt is offline
NoroHime
Veteran Member
Join Date: Aug 2016
Location: bed
Old 11-17-2022 , 02:35   Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
Reply With Quote #5

before trigging OnTakeDamage, TraceAttack definitely trigger before.
you can check my [L4D & L4D2] Limb-Based Damage Modifier,
if you want modify on OnTakeDamageAlive (if you just want multiply use TraceAttack only ) just made global variable like https://forums.alliedmods.net/showthread.php?p=2777880
__________________

Last edited by NoroHime; 11-17-2022 at 02:38.
NoroHime is offline
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-17-2022 , 04:08   Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
Reply With Quote #6

thanks reply, i use TraceAttack and it works well.
By the way, do you know how to detect a player is shoved? I try to use l4d_OnStagger() but it not work.
Left4dhook has another way which use CTerrorWeapon::OnHIt , but it seems too expensive.
LinLinLin is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 11-17-2022 , 12:53   Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
Reply With Quote #7

Don't know for what use it is for, but you can try using the events below:
__________________

Last edited by Marttt; 11-17-2022 at 12:53.
Marttt is offline
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-17-2022 , 21:11   Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
Reply With Quote #8

yes, i just want to check it in this SDKHook to modify the damage...
PHP Code:
// by using z_show_swing and get distance, we know that a shove has 90 degree width(in static) and about 95.0 distance.
// we start to get the end point first.
float v_ang[3],v_pos[3],v_fwd[3],end_pos[3];
GetClientEyeAngles(victim,v_ang);GetClientEyePosition(victim,v_pos);
GetAngleVectors(v_ang,v_fwd,NULL_VECTOR,NULL_VECTOR);
NormalizeVector(v_fwd,v_fwd); // i don't know vector from ang has been normalize or not, so do it again.
ScaleVector(v_fwd,95.0); // scale base on the distance.
AddVectors(v_pos,v_fwd,end_pos); // now get the end point.

// actually it is not the best way to check a player is shoved. The range of shove is a secotr.
// if someone know the tracehull of the min and max size, please tell me.
Handle hTrace TR_TraceHullFilterEx(v_pos,end_pos,{0.0,0.0,0.0},{0.0,0.0,0.0},MASK_PLAYERSOLID,Filter_TraceRayPlayers,victim); 
if( 
hTrace != null && TR_DidHit(hTrace) )
{
    
int client TR_GetEntityIndex(hTrace);
    if( 
<= client <= MaxClients && attacker == client // now we sure that victim is aiming the attacker
    
{
        if( 
GetEntProp(victim_melee,Prop_Send,"m_bInMeleeSwing") ) // swing = 1, other = 0.
        
{
            
damage 0.0;
            
delete hTrace;
            return 
Plugin_Changed;
        }
        else if( 
M_IsPlayerShoving(victim) )
        {
            
damage 0.0;
            
delete hTrace;
            return 
Plugin_Changed;
        }
    }
}
delete hTrace
This is the way i want to try. It is not very well actually.
Do you have some suggestion?
LinLinLin is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 11-17-2022 , 21:37   Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
Reply With Quote #9

Maybe is better to check damagetype
AFAIK shove is always DMG_CLUB and a valid client index for inflictor.
unless you have some plugin or addon that changes that.
__________________

Last edited by Marttt; 11-17-2022 at 21:38.
Marttt is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 11-18-2022 , 02:24   Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
Reply With Quote #10

Quote:
Originally Posted by LinLinLin View Post
thanks reply, i use TraceAttack and it works well.
By the way, do you know how to detect a player is shoved? I try to use l4d_OnStagger() but it not work.
Left4dhook has another way which use CTerrorWeapon::OnHIt , but it seems too expensive.
Left4dhook
PHP Code:
/**
 * @brief Called whenever CTerrorWeapon::OnSwingStart(CTerrorWeapon *this) is invoked
 * @remarks Called when a Survivor shoves
 * @remarks Blocking has no effect so this function is void only
 *
 * @param client    the client that did the shoving
 * @param weapon    the weapon being held when shoving
 *
 * @noreturn
 */
forward void L4D_OnSwingStart(int clientint weapon);


/**
 * @brief Called whenever CTerrorPlayer::OnShovedBySurvivor(CTerrorPlayer, Vector&) is invoked
 * @remarks L4D2 only uses this on Special Infected
 * @remarks Blocks hunter dead stop
 *
 * @param client    the client that did the shoving
 * @param victim    the client that was shoved (CAUTION retrieved from function pointer, don't meddle with it)
 * @param vecDir    Vector Angle of Shoveforce
 *
 * @return            Plugin_Handled to block melee effect (staggering), Plugin_Continue otherwise.
 */
forward Action L4D_OnShovedBySurvivor(int clientint victim, const float vecDir[3]);


/**
 * @brief Called whenever CTerrorWeapon::OnHit(CGameTrace &, Vector const&, bool) is invoked
 * @remarks Called for every single shovable and even some of the unshovable entities in the game
 *
 * @param client    survivor who did the shoving
 * @param entity    entity that is about to get shoved
 * @param weapon    weapon that has been held while shoving
 * @param vecDir    stagger direction
 * @param bIsHighPounce        a boolean to determine if it was a pounce from a height or not; reliable to a certain degree and should only be considered for hunters
 * @param bIsHighPounce        sometimes reset to 0 when punched before the detour retrieves the information.
 *
 * @return            Plugin_Handled to block, Plugin_Continue otherwise
 */
forward Action L4D2_OnEntityShoved(int clientint entityint weaponfloat vecDir[3], bool bIsHighPounce); 
__________________
HarryPotter 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 03:46.


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