Permalink
Browse files

Add TTT_OnTakeDamage

I added this a few weeks ago(!), but not released until now.
  • Loading branch information...
Bara committed Nov 12, 2018
1 parent 6aa4526 commit 20fc8cc6fdf9c1e7f3b8527be06bbd02e2e32a2d
@@ -143,6 +143,17 @@ forward void TTT_OnRoundEnd(int winner, Handle array);
*/
forward void TTT_OnClientGetRole(int client, int role);
/**
* Called when a client take damage
*
* @param victim Person who take damage.
* @param attacker Attacker.
* @param damage How much damage
* @param weapon Weapon index
* @param badAction If damage was a bad action (example: Innocent damaged Detective)
*/
forward void TTT_OnTakeDamage(int victim, int attacker, float damage, int weapon, bool badAction);
/**
* Called when a client dies, after Karma process
*
@@ -101,6 +101,7 @@ Handle g_hOnRoundStart = null;
Handle g_hOnRoundStartFailed = null;
Handle g_hOnRoundEnd = null;
Handle g_hOnClientGetRole = null;
Handle g_hOnTakeDamage = null;
Handle g_hOnClientDeath = null;
Handle g_hOnClientDeathPre = null;
Handle g_hOnBodyFound = null;
@@ -5,6 +5,7 @@ void InitForwards()
g_hOnRoundStartFailed = CreateGlobalForward("TTT_OnRoundStartFailed", ET_Ignore, Param_Cell, Param_Cell);
g_hOnRoundEnd = CreateGlobalForward("TTT_OnRoundEnd", ET_Ignore, Param_Cell, Param_Cell);
g_hOnClientGetRole = CreateGlobalForward("TTT_OnClientGetRole", ET_Ignore, Param_Cell, Param_Cell);
g_hOnTakeDamage = CreateGlobalForward("TTT_OnTakeDamage", ET_Ignore, Param_Cell, Param_Cell, Param_Float, Param_Cell, Param_Cell);
g_hOnClientDeath = CreateGlobalForward("TTT_OnClientDeath", ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
g_hOnClientDeathPre = CreateGlobalForward("TTT_OnClientDeathPre", ET_Event, Param_Cell, Param_Cell);
g_hOnBodyFound = CreateGlobalForward("TTT_OnBodyFound", ET_Ignore, Param_Cell, Param_Cell, Param_String, Param_Cell);
@@ -1838,11 +1838,15 @@ public Action OnTakeDamageAlive(int iVictim, int &iAttacker, int &inflictor, flo
}
}
bool badAction = false;
if (g_iRole[iAttacker] == TTT_TEAM_INNOCENT && g_iRole[iVictim] == TTT_TEAM_INNOCENT)
{
Format(iItem, sizeof(iItem), "-> [%N%s (Innocent) damaged %N%s (Innocent) for %.0f damage with %s] - BAD ACTION", iAttacker, sAttackerID, iVictim, sClientID, fDamage, sWeapon);
addArrayTime(iItem);
badAction = true;
if (g_cEnableDamageKarma.BoolValue)
{
subtractKarma(iAttacker, g_cDamageKarmaII.IntValue, false);
@@ -1863,6 +1867,8 @@ public Action OnTakeDamageAlive(int iVictim, int &iAttacker, int &inflictor, flo
Format(iItem, sizeof(iItem), "-> [%N%s (Innocent) damaged %N%s (Detective) for %.0f damage with %s] - BAD ACTION", iAttacker, sAttackerID, iVictim, sClientID, fDamage, sWeapon);
addArrayTime(iItem);
badAction = true;
if (g_cEnableDamageKarma.BoolValue)
{
subtractKarma(iAttacker, g_cDamageKarmaID.IntValue, false);
@@ -1884,6 +1890,8 @@ public Action OnTakeDamageAlive(int iVictim, int &iAttacker, int &inflictor, flo
Format(iItem, sizeof(iItem), "-> [%N%s (Traitor) damaged %N%s (Traitor) for %.0f damage with %s] - BAD ACTION", iAttacker, sAttackerID, iVictim, sClientID, fDamage, sWeapon);
addArrayTime(iItem);
badAction = true;
if (g_cEnableDamageKarma.BoolValue)
{
subtractKarma(iAttacker, g_cDamageKarmaTT.IntValue, false);
@@ -1905,6 +1913,8 @@ public Action OnTakeDamageAlive(int iVictim, int &iAttacker, int &inflictor, flo
Format(iItem, sizeof(iItem), "-> [%N%s (Detective) damaged %N%s (Innocent) for %.0f damage with %s] - BAD ACTION", iAttacker, sAttackerID, iVictim, sClientID, fDamage, sWeapon);
addArrayTime(iItem);
badAction = true;
if (g_cEnableDamageKarma.BoolValue)
{
subtractKarma(iAttacker, g_cDamageKarmaDI.IntValue, false);
@@ -1926,19 +1936,31 @@ public Action OnTakeDamageAlive(int iVictim, int &iAttacker, int &inflictor, flo
Format(iItem, sizeof(iItem), "-> [%N%s (Detective) damaged %N%s (Detective) for %.0f damage with %s] - BAD ACTION", iAttacker, sAttackerID, iVictim, sClientID, fDamage, sWeapon);
addArrayTime(iItem);
badAction = true;
if (g_cEnableDamageKarma.BoolValue)
{
subtractKarma(iAttacker, g_cDamageKarmaDD.IntValue, false);
}
}
Action action = Plugin_Continue;
if (fDamage != damage)
{
damage = fDamage;
return Plugin_Changed;
action = Plugin_Changed;
}
return Plugin_Continue;
Call_StartForward(g_hOnTakeDamage);
Call_PushCell(iVictim);
Call_PushCell(iAttacker);
Call_PushCell(view_as<int>(fDamage));
Call_PushCell(iWeapon);
Call_PushCell(view_as<int>(badAction));
Call_Finish();
return action;
}
bool IsDamageForbidden()

0 comments on commit 20fc8cc

Please sign in to comment.