AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [L4D2]How to get the hit group in SDKHook_OnTakDamage? (https://forums.alliedmods.net/showthread.php?t=340408)

LinLinLin 11-16-2022 08:13

[L4D2]How to get the hit group in SDKHook_OnTakDamage?
 
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.

Marttt 11-16-2022 08:30

Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
 
use SDKHook_TraceAttack

PHP Code:

// TraceAttack
function Action (int victimint &attackerint &inflictorfloat &damageint &damagetypeint &ammotypeint hitboxint hitgroup); 

It usually runs before TakeDamage

LinLinLin 11-16-2022 09:47

Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
 
got it, i will try this hook tonight.

Marttt 11-16-2022 15:20

Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
 
You can use also the event player_hurt but is kinda the last event, if you need modify something then goes for TraceAttack/TakeDamage

NoroHime 11-17-2022 02:35

Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
 
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

LinLinLin 11-17-2022 04:08

Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
 
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.

Marttt 11-17-2022 12:53

Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
 
Don't know for what use it is for, but you can try using the events below:

LinLinLin 11-17-2022 21:11

Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
 
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?

Marttt 11-17-2022 21:37

Re: [L4D2]How to get the hit group in SDKHook_OnTakDamage?
 
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.

HarryPotter 11-18-2022 02:24

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

Originally Posted by LinLinLin (Post 2792999)
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); 



All times are GMT -4. The time now is 00:08.

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