Code: Select all
if ( SHARED_ValidPlayer( iAttacker ) && fDifference < 0.1 && fDifference > 0.0 )
Code: Select all
RegisterHam(Ham_TakeDamage, "player", "EVENT_TakeDamage");
new UserAiming[33];
// Called when a user looks somewhere
public TRIGGER_TraceLine( Float:v1[3], Float:v2[3], noMonsters, pentToSkip )
{
if ( !WC3_Check() )
{
return FMRES_IGNORED;
}
new iAttacker = pentToSkip;
new iVictim = get_tr(TR_pHit);
new iHitZone = (1 << get_tr(TR_iHitgroup));
// Make sure we have a valid victim
if ( SHARED_ValidPlayer( iVictim ) && p_data_b[iVictim][PB_ISCONNECTED] )
{
// We need to have a valid player!
if ( SHARED_ValidPlayer( iAttacker ) )
{
if ( iHitZone & (1 << 1) )
UserAiming[iVictim] = 1
else
UserAiming[iVictim] = 0
// This is a check for ultimates that need to "search" for a target
if ( p_data_b[iAttacker][PB_ISSEARCHING] )
{
// Now lets make sure the person he's looking at is in view and isn't on the same team
if ( get_user_team( iAttacker ) != get_user_team( iVictim ) ) //&& UTIL_EntInView( iAttacker, iVictim ) )
{
// Check to see if the user should block this ultimate!
if ( !g_EndRound && ULT_CanUserBlockUlt( iVictim ) )
{
ULT_RemoveCharge( iVictim, 0 );
ULT_Blocked( iAttacker );
}
// Then the user's ult should work!
else
{
// Well we do have a target so lets execute the user's ultimate!!
if ( SM_GetSkillLevel( iAttacker, ULTIMATE_CHAINLIGHTNING ) > 0 )
{
OR_ULT_ChainLightning( iAttacker, iVictim, iHitZone );
}
else if ( SM_GetSkillLevel( iAttacker, ULTIMATE_ENTANGLE ) > 0 )
{
NE_ULT_Entangle( iAttacker, iVictim );
}
else if ( SM_GetSkillLevel( iAttacker, ULTIMATE_IMMOLATE ) > 0 )
{
BM_ULT_Immolate( iAttacker, iVictim );
}
}
// No longer searching since we found a target
p_data_b[iAttacker][PB_ISSEARCHING] = false;
// Set up the user's ultimate delay
ULT_ResetCooldown( iAttacker, get_pcvar_num( CVAR_wc3_ult_cooldown ) );
}
}
// Check for Big Bad Voodoo's ultimate!
if ( p_data_b[iVictim][PB_GODMODE] )
{
new bool:bBlockDamage = true;
// Do we allow this person to be attacked by this player?
if ( p_data_b[iAttacker][PB_BIGBAD_ATTACKER] )
{
bBlockDamage = false;
}
// Check to see if immunity is available for the attacker
else if ( ULT_CanUserBlockUlt( iAttacker ) )
{
// Remove charge and display message to attacker
ULT_RemoveCharge( iAttacker, 1 );
// Display message about user's ultimate being blocked!
ULT_Blocked( iVictim );
// This user can attack someone with big bad voodoo!
p_data_b[iAttacker][PB_BIGBAD_ATTACKER] = true;
// Reset the attacker dmg
set_task( get_pcvar_float( CVAR_wc3_ult_cooldown ), "_SH_ResetBigBadAttacker", TASK_BIGBADATTACKER + iAttacker );
}
// Block the damage!
if ( bBlockDamage )
{
set_tr( TR_flFraction, 1.0 );
return FMRES_SUPERCEDE;
}
}
}
}
return FMRES_IGNORED;
}
public EVENT_TakeDamage( iVictim, inflictor, iAttacker, Float:iDamagee, damagetype )
{
if ( !WC3_Check() )
{
return HAM_IGNORED;
}
// Make sure we have a valid victim
if ( SHARED_ValidPlayer( iVictim ) && p_data_b[iVictim][PB_ISCONNECTED] )
{
// We need to have a valid player!
if ( SHARED_ValidPlayer( iAttacker ) && p_data_b[iAttacker][PB_ISCONNECTED])
{
if ( get_user_team( iAttacker ) == get_user_team( iVictim ) && !get_pcvar_num( CVAR_mp_friendlyfire ))
return HAM_SUPERCEDE;
new iHitPlace
new iWeapon
get_user_attacker( iVictim , iWeapon , iHitPlace )
if(IsGrenade ( inflictor ))
iWeapon = CSW_HEGRENADE;
// This is a nice check for Helm of Excellence
if ( ITEM_Has( iVictim, ITEM_HELM ) > ITEM_NONE )
{
// If its a headshot then we want to block it
if ( UserAiming[iVictim] )
{
Create_ScreenFade( iVictim, (1<<10), (1<<10), (1<<12), 0, 0, 255, 150 );
// Lets remove a charge from the helm!
ITEM_RemoveCharge( iVictim, ITEM_HELM );
return HAM_SUPERCEDE;
}
}
// Mole protectant
if ( p_data_b[iAttacker][PB_MOLE] && ITEM_Has( iVictim, ITEM_PROTECTANT ) > ITEM_NONE )
{
client_print( iVictim, print_chat, "%s %L", g_MODclient, iVictim, "SHOT_DEFLECTED" );
return HAM_SUPERCEDE;
}
static iSkillLevel;
new iDamage = floatround(iDamagee);
// Check to see if this user has night elf's evasion
if ( SM_GetSkillLevel( iVictim, SKILL_EVASION ) > 0 )
{
iSkillLevel = SM_GetSkillLevel( iVictim, SKILL_EVASION );
// Friendly fire is off! - This means we shouldn't evade since no damage will be done!
if ( !get_pcvar_num( CVAR_mp_friendlyfire ) )
if ( g_iPlayerTeam[iAttacker] == g_iPlayerTeam[iVictim] )
return HAM_SUPERCEDE;
// Then we should evade this shot!
if ( !p_data_b[iVictim][PB_HEXED] && random_float( 0.0, 1.0 ) <= p_evasion[iSkillLevel-1] )
{
new iGlowIntensity = random_num( 20, 50 );
// Head shot
if ( iHitPlace & HIT_HEAD )
iGlowIntensity += 250;
else
iGlowIntensity += 75;
// Make the user glow!
SHARED_Glow( iVictim, 0, 0, iGlowIntensity, 0 );
Create_ScreenFade( iVictim, (1<<10), (1<<10), (1<<12), 0, 0, 255, g_GlowLevel[iVictim][2] );
WC3_StatusText( iVictim, TXT_SKILL, "You have evaded a shot!" );
return HAM_SUPERCEDE;
}
}
g_iDamageDealt[iAttacker][iVictim] += iDamage;
// Bot should "auto" cast his/her ultimate on random
if ( SHARED_ValidPlayer( iAttacker ) && is_user_bot( iAttacker ) && random_num( 0, 100 ) <= ( BOT_CAST_ULT_CHANCE * 100 ) )
{
// Check for an actual ultimate is done in this function, why do it twice?
cmd_Ultimate( iAttacker );
}
// We need to make sure that we have a valid attacker and the user isn't hexed
if ( SHARED_ValidPlayer( iAttacker ) && !p_data_b[iAttacker][PB_HEXED] )
{
// Run the offensive spells
UD_SkillsOffensive( iAttacker, iDamage );
HU_SkillsOffensive( iAttacker, iVictim );
OR_SkillsOffensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
NE_SkillsOffensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
BM_SkillsOffensive( iAttacker, iVictim, iDamage );
SH_SkillsOffensive( iAttacker, iVictim );
WA_SkillsOffensive( iAttacker, iVictim, iHitPlace );
CL_SkillsOffensive( iAttacker, iVictim, iHitPlace );
OUR_TERROR( iAttacker, iVictim);
OUR_BLOODLUST(iAttacker, iVictim);
OUR_BERSERK(iAttacker, iVictim);
}
// Make sure we can run the defensive skills
if ( SHARED_ValidPlayer( iAttacker ) && !p_data_b[iVictim][PB_HEXED] )
{
//UD_SkillsDefensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
//HU_SkillsDefensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
//OR_SkillsDefensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
NE_SkillsDefensive( iAttacker, iVictim, iDamage, iHitPlace );
BM_SkillsDefensive( iAttacker, iVictim, iDamage );
SH_SkillsDefensive( iAttacker, iVictim );
//WA_SkillsDefensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
CL_SkillsDefensive( iAttacker, iVictim, iDamage, iHitPlace );
OUR_ICESHARDS(iVictim, iDamage, iAttacker);
}
// Item abilities
if ( SHARED_ValidPlayer( iAttacker ) )
ITEM_Offensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
}
}
return HAM_IGNORED;
}
bool:IsGrenade ( i_Inflictor ) {
static s_Classname[ 8 ];
pev ( i_Inflictor, pev_classname, s_Classname, charsmax ( s_Classname ) );
return equal ( s_Classname, "grenade" ) ? true : false;
}