Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdkhooks>
- // Settings
- int PlayerKill = 2;
- int Skeet = 2;
- int SkeetHurt = 1;
- int SkeetMelee = 3;
- int BoomerPop = 1;
- int TongueCut = 1;
- int SmokerSelfClear = 1;
- int JockeySkeet = 2;
- int ChargerLevel = 3;
- int ChargerLevelHurt = 1;
- int TankRockSkeeted = 1;
- int WitchCrown = 3;
- int SpecialClearX = 4;
- int SpecialClearA = 3;
- int SpecialClearB = 2;
- int SpecialClearC = 1;
- int TankRockEaten = -1;
- int CarAlarmTriggered = -4;
- int CarAlarmTriggeredBoomer = -6;
- int PlayerKilled = -5;
- int InfectedKill = 10;
- int PillsUsed = -3;
- int MedKitUsed = -4;
- int PlayerGetup = 1;
- int EachSurvivorDamage = 1;
- int EachThatCommonsAmount = 10;
- int EachCommonsAmount = 1;
- int EachThatSurvivorDamageAmount = 500;
- int EachInfectedDamage = 1;
- int EachThatInfectedDamageAmount = 50;
- int InfectedIncap = 5;
- int HunterCap = 2;
- int JockeyCap = 3;
- int SmokerCap = 1;
- int ChargerCap = 3;
- int ChargerImpact = 1;
- int ChargerInstaKill = 5;
- int BommerVomit = 1;
- int TankPunch = 1;
- int SurvivorAssist = 1;
- int PlayerIncapacitated = -2;
- // Variables
- int Score[MAXPLAYERS + 1];
- int AcummulatedCommons[MAXPLAYERS +1];
- int TempAcummulatedCommons[MAXPLAYERS +1];
- int AcummulatedDamage[MAXPLAYERS + 1];
- int TempAcummulatedDamage[MAXPLAYERS + 1];
- int AcummulatedSurvivorKills[MAXPLAYERS +1];
- int AcummulatedInfectedKills[MAXPLAYERS +1];
- int DamageAssistTracker[MAXPLAYERS +1][MAXPLAYERS +1];
- int DamageJockeyTracker[MAXPLAYERS +1][MAXPLAYERS +1];
- float inflictedDamageToJockey[MAXPLAYERS +1][MAXPLAYERS +1];
- float JockeyDamageForSkeet;
- public void OnPluginStart()
- {
- HookEvent("player_death", OnPlayerDeath, EventHookMode_Post);
- HookEvent("pills_used", OnPillsUsed, EventHookMode_Post);
- HookEvent("heal_success", OnMedKitUsed, EventHookMode_Post);
- HookEvent("player_incapacitated", OnPlayerIncapacitated_Event, EventHookMode_Post);
- HookEvent("revive_success", OnPlayerGetup, EventHookMode_Post);
- HookEvent("player_hurt", OnPlayerDamage, EventHookMode_Post);
- HookEvent("tongue_grab", OnSmokerCap, EventHookMode_Post);
- HookEvent("charger_carry_start", OnChargerCap, EventHookMode_Post);
- HookEvent("charger_impact", OnChargerImpact, EventHookMode_Post);
- //HookEvent("round_end", OnRoundEnd, EventHookMode_Post);
- }
- public void OnConfigsExecuted()
- {
- char jockeySkeetPlugin[] = "l4d2_jockey_skeet.smx";
- if (FindPluginByFile(jockeySkeetPlugin) != INVALID_HANDLE)
- {
- JockeyDamageForSkeet = GetConVarFloat(FindConVar("z_leap_damage_interrupt"));
- }
- }
- public void OnClientPutInServer(int client)
- {
- SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- }
- public void OnClientDisconnect(int client)
- {
- SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- }
- /*public void OnRoundEnd(Event event, const char[] name, bool dontBroadcast)
- {
- for (int i = 0; i <= MAXPLAYERS; i++)
- {
- if (GetClientTeam(i) == 2)
- {
- char player[255];
- GetClientName(i, player, sizeof(player));
- PrintToChatAll("%s | kills: %i | damage: %i | score: %i", player, AcummulatedSurvivorKills[i], AcummulatedDamage[i], Score[i]);
- }
- }
- }
- */
- void UpdateScore(int client, int amount)
- {
- Score[client] += amount;
- }
- void UpdateSurvivorDamage(int survivor, int damage)
- {
- AcummulatedDamage[survivor] += damage;
- TempAcummulatedDamage[survivor] += damage;
- while (TempAcummulatedDamage[survivor] >= EachThatSurvivorDamageAmount)
- {
- UpdateScore(survivor, EachSurvivorDamage);
- TempAcummulatedDamage[survivor] -= EachThatSurvivorDamageAmount;
- }
- }
- void UpdateInfectedDamage(int infected, int damage)
- {
- AcummulatedDamage[infected] += damage;
- TempAcummulatedDamage[infected] += damage;
- while (TempAcummulatedDamage[infected] >= EachThatInfectedDamageAmount)
- {
- UpdateScore(infected, EachInfectedDamage);
- TempAcummulatedDamage[infected] -= EachThatInfectedDamageAmount;
- }
- }
- void UpdateAcummulatedCommons(int survivor)
- {
- AcummulatedCommons[survivor] += 1;
- TempAcummulatedCommons[survivor] += 1;
- while (TempAcummulatedCommons[survivor] >= EachThatCommonsAmount)
- {
- UpdateScore(survivor, EachCommonsAmount);
- TempAcummulatedCommons[survivor] -= EachThatCommonsAmount;
- }
- }
- public void OnPlayerIncapacitated_Event(Event event, const char[] name, bool dontBroadcast)
- {
- int survivorId = event.GetInt("userid");
- int survivor = GetClientOfUserId(survivorId);
- int attackerId = event.GetInt("attacker");
- int attacker = GetClientOfUserId(attackerId);
- if (GetClientTeam(survivor) == 2)
- {
- OnPlayerIncapacitated(survivor);
- }
- OnPlayerIncapacitatedByInfected(attacker, survivor);
- }
- public void OnPlayerDeath(Event event, const char[] name, bool dontBroadcast)
- {
- int victimId = event.GetInt("userid");
- int victim = GetClientOfUserId(victimId);
- int attackerId = event.GetInt("attacker");
- int attacker = GetClientOfUserId(attackerId);
- int entityId = event.GetInt("entityid");
- char Classname[64];
- GetEntityClassname(entityId, Classname, sizeof(Classname));
- char ClassnameCommon[] = "infected";
- if (victim <= MAXPLAYERS)
- {
- if (GetClientTeam(victim) == 3 && GetClientTeam(attacker) == 2)
- {
- AcummulatedSurvivorKills[attacker] += 1;
- OnSurvivorKill(attacker, victim);
- for (int i = 0; i <= MAXPLAYERS; i++)
- {
- DamageAssistTracker[i][victim] = 0;
- }
- }
- if (GetClientTeam(victim) == 2 && GetClientTeam(attacker) == 3)
- {
- AcummulatedInfectedKills[attacker] += 1;
- OnInfectedKill(attacker, victim);
- }
- if (GetClientTeam(victim) == 2)
- {
- OnSurvivorKilled(victim);
- }
- }
- else
- {
- if (GetClientTeam(attacker) == 2 && StrEqual(Classname, ClassnameCommon))
- {
- OnPlayerCommonKill(attacker);
- }
- }
- }
- public void OnPlayerDamage(Event event, const char[] name, bool dontBroadcast)
- {
- int victimId = event.GetInt("userid");
- int victim = GetClientOfUserId(victimId);
- int attackerId = event.GetInt("attacker");
- int attacker = GetClientOfUserId(attackerId);
- int damage = event.GetInt("dmg_health");
- if (GetClientTeam(attacker) == 2)
- {
- OnSurvivorDamage(attacker, damage, victim);
- DamageAssistTracker[attacker][victim] += damage;
- if (GetEntProp(victim, Prop_Send, "m_zombieClass") == 5)
- {
- DamageJockeyTracker[attacker][victim] += damage;
- }
- }
- else if (GetClientTeam(attacker) == 3)
- {
- OnInfectedDamage(attacker, damage, victim);
- }
- }
- public Action OnTakeDamage(victim, &attacker, &inflictor, float damage, &damageType, &weapon, float damageForce[3], float damagePosition[3])
- {
- char jockeySkeetPlugin[] = "l4d2_jockey_skeet.smx";
- if (FindPluginByFile(jockeySkeetPlugin) != INVALID_HANDLE)
- {
- OnJockeySkeet(victim, attacker, damage, weapon, JockeyDamageForSkeet);
- }
- }
- // *********************************************************** //
- // ************* || P L A Y E R C H E C K S || ************* //
- // *********************************************************** //
- bool IsValidSurvivor(int survivor)
- {
- return (survivor > 0
- && survivor <= MAXPLAYERS
- && IsClientInGame(survivor)
- && GetClientTeam(survivor) == 2
- && !IsFakeClient(survivor));
- }
- bool IsValidInfected(int infected)
- {
- return (infected > 0
- && infected <= MAXPLAYERS
- && IsClientInGame(infected)
- && GetClientTeam(infected) == 3
- && !IsFakeClient(infected));
- }
- // *********************************************************** //
- // *********** || S U R V I V O R S S K I L L || *********** //
- // *********************************************************** //
- //// [ KILL ] ////
- public Action OnSurvivorKill(int survivor, int infected)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(infected))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, PlayerKill);
- for (int i = 0; i <= MAXPLAYERS; i++)
- {
- if (DamageAssistTracker[i][infected] > 100)
- {
- OnSurvivorAssist(i, infected);
- }
- }
- }
- //// [ ASSIST ] ////
- public Action OnSurvivorAssist(int survivor, int infected)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(infected))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, SurvivorAssist);
- }
- //// [ HUNTER SKILL ] ////
- public void OnSkeet(int survivor, int hunter)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(hunter))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, Skeet);
- }
- public void OnSkeetHurt(int survivor, int hunter, int damage, bool isOverkill)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(hunter))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- if (isOverKill)
- {
- UpdateScore(survivor, Skeet);
- }
- else
- {
- UpdateScore(survivor, SkeetHurt);
- }
- }
- public void OnSkeetMelee(int survivor, int hunter)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(hunter))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, SkeetMelee);
- }
- public void OnSkeetMeleeHurt(int survivor, int hunter, int damage, bool isOverkill)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(hunter))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- if (isOverKill)
- {
- UpdateScore(survivor, SkeetMelee);
- }
- }
- //// [ BOOMER SKILL ] ////
- public void OnBoomerPop(int survivor, int boomer, int shoveCount, float timeAlive)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(boomer))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- if (shoveCount < 1 && timeAlive < 2.0)
- {
- UpdateScore(survivor, BoomerPop);
- }
- }
- //// [ SMOKER SKILL ] ////
- public void OnSmokerSelfClear(int survivor, int smoker, bool withShove)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(smoker))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, SmokerSelfClear);
- }
- public void OnTongueCut(int survivor, int smoker)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(smoker))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, TongueCut);
- }
- //// [ JOCKEY SKILL ] ////
- public Action OnJockeySkeet(int victim, int attacker, float damage, int weapon, float JockeyDamageForSkeet)
- {
- if (IsValidSurvivor(attacker)
- && IsValidInfected(victim)
- && GetEntProp(victim, Prop_Send, "m_zombieClass") == 5
- && GetEntProp(victim, Prop_Send, "m_isGhost") != 1)
- {
- if (!HasJockeyTarget(victim) && IsAttachable(victim) && IsShotgun(weapon))
- {
- inflictedDamageToJockey[victim][attacker] += damage;
- if (inflictedDamageToJockey[victim][attacker] >= JockeyDamageForSkeet)
- {
- UpdateScore(attacker, JockeySkeet);
- }
- CreateTimer(0.1, ResetDamageCounter, victim);
- }
- return Plugin_Continue;
- }
- return Plugin_Continue;
- }
- bool HasJockeyTarget(int infected)
- {
- int client = GetEntDataEnt2(infected, 16124);
- return (GetClientTeam(client) == 2 && IsPlayerAlive(client));
- }
- bool IsAttachable(int jockey)
- {
- return !(GetEntityFlags(jockey) & FL_ONGROUND);
- }
- bool IsShotgun(int weapon)
- {
- char weaponname[64];
- GetEdictClassname(weapon, weaponname, sizeof(weaponname));
- return (StrEqual(weaponname, "weapon_pumpshotgun") || StrEqual(weaponname, "weapon_shotgun_chrome"));
- }
- public Action ResetDamageCounter(Handle timer, int jockey)
- {
- for (int i = 1; i <= MAXPLAYERS; i++)
- {
- inflictedDamageToJockey[jockey][i] = 0.0;
- }
- }
- //// [ CHARGER SKILL ] ////
- public void OnChargerLevel(int survivor, int charger)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(charger))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, ChargerLevel);
- }
- public void OnChargerLevelHurt(int survivor, int charger, int damage)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(charger))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- if (damage >= 100)
- {
- UpdateScore(survivor, ChargerLevelHurt);
- }
- else
- {
- return;
- }
- }
- //// [ TANK SKILL ] ////
- public void OnTankRockSkeeted(int survivor, int tank)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(tank))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, TankRockSkeeted);
- }
- //// [ WITCH SKILL ] ////
- public void OnWitchCrown(int survivor, int damage)
- {
- if (!IsValidSurvivor(survivor))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- if (damage >= 1000)
- {
- UpdateScore(survivor, WitchCrown);
- }
- }
- //// [ TEAM SKILL ] ////
- public void OnSpecialClear(int clearer, int pinner, int pinvictim, int zombieClass, float timeA, float timeB, bool withShove)
- {
- if (!IsValidSurvivor(clearer) || !IsValidSurvivor(pinvictim) || !IsValidInfected(pinner))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- if (zombieClass == 6 || zombieClass == 1)
- {
- if (timeB != -1.0)
- {
- UpdateScore(clearer, SpecialClearX);
- }
- }
- else
- {
- if (0.0 <= timeA < 1.0)
- {
- UpdateScore(clearer, SpecialClearA);
- }
- else if (1.0 <= timeA < 2.0)
- {
- UpdateScore(clearer, SpecialClearB);
- }
- else if (2.0 <= timeA)
- {
- UpdateScore(clearer, SpecialClearC);
- }
- }
- }
- public void OnPlayerGetup(Event event, const char[] name, bool dontBroadcast)
- {
- int survivorId = event.GetInt("userid");
- int survivor = GetClientOfUserId(survivorId);
- int subjectId = event.GetInt("subject");
- int survivor2 = GetClientOfUserId(subjectId);
- if (!IsValidSurvivor(survivor) || !IsValidSurvivor(survivor2))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, PlayerGetup);
- }
- //// [ DAMAGE && COMMONS ] ////
- public Action OnSurvivorDamage(int attacker, int damage, int victim)
- {
- if (!IsValidSurvivor(attacker) || !IsValidInfected(victim))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateSurvivorDamage(attacker, damage);
- }
- public Action OnPlayerCommonKill(int survivor)
- {
- if (!IsValidSurvivor(survivor))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateAcummulatedCommons(survivor);
- }
- // *********************************************************** //
- // ******** || S U R V I V O R S F A I L U R E S || ******** //
- // *********************************************************** //
- //// [ INCAPACITATED ] ////
- public Action OnPlayerIncapacitated(int survivor)
- {
- if (!IsValidSurvivor(survivor))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, PlayerIncapacitated);
- }
- //// [ DIE ] ////
- public Action OnSurvivorKilled(int survivor)
- {
- if (!IsValidSurvivor(survivor))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, PlayerKilled);
- }
- //// [ ROCK HIT ] ////
- public void OnTankRockEaten(int tank, int survivor)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(tank))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, TankRockEaten);
- }
- //// [ USE MEDKIT ] ////
- public void OnMedKitUsed(Event event, const char[] name, bool dontBroadcast)
- {
- int survivorId = event.GetInt("userid");
- int survivor = GetClientOfUserId(survivorId);
- if (!IsValidSurvivor(survivor))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, MedKitUsed);
- }
- //// [ USE PILLS ] ////
- public void OnPillsUsed(Event event, const char[] name, bool dontBroadcast)
- {
- int survivorId = event.GetInt("userid");
- int survivor = GetClientOfUserId(survivorId);
- if (!IsValidSurvivor(survivor))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(survivor, PillsUsed);
- }
- //// [ CAR ALARM ] ////
- public void OnCarAlarmTriggered(int survivor, int infected, int reason)
- {
- if (!IsValidSurvivor(survivor))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- if (reason == 4)
- {
- UpdateScore(survivor, CarAlarmTriggeredBoomer);
- }
- else
- {
- UpdateScore(survivor, CarAlarmTriggered);
- }
- }
- // *********************************************************** //
- // ************ || I N F E C T E D S K I L L || ************ //
- // *********************************************************** //
- //// [ DAMAGE ] ////
- public Action OnInfectedDamage(int attacker, int damage, int victim)
- {
- if (!IsValidSurvivor(victim) || !IsValidInfected(attacker))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateInfectedDamage(attacker, damage);
- if (GetEntProp(attacker, Prop_Send, "m_zombieClass") == 8)
- {
- OnTankPunch(attacker, victim);
- }
- }
- //// [ KILLS ] ////
- public Action OnInfectedKill(int infected, int survivor)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(infected))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(infected, InfectedKill);
- }
- //// [ INCAP ] ////
- public Action OnPlayerIncapacitatedByInfected(int infected, int survivor)
- {
- if (!IsValidSurvivor(survivor) || !IsValidInfected(infected))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(infected, InfectedIncap);
- }
- //// [ HUNTER SKILL ] ////
- public void OnHunterHighPounce(int hunter, int victim, int actualDamage, float calculatedDamage, float height, bool bReportedHigh, bool bPlayerIncapped)
- {
- if (!IsValidSurvivor(victim) || !IsValidInfected(hunter))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(hunter, HunterCap);
- }
- //// [ JOCKEY SKILL ] ////
- public void OnJockeyHighPounce(int jockey, int victim, float height, bool bReportedHigh)
- {
- if (!IsValidSurvivor(victim) || !IsValidInfected(jockey))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(jockey, JockeyCap);
- }
- //// [ SMOKER SKILL ] ////
- public void OnSmokerCap(Event event, const char[] name, bool dontBroadcast)
- {
- int userId = event.GetInt("userid");
- int smoker = GetClientOfUserId(userId);
- int survivorId = event.GetInt("victim");
- int survivor = GetClientOfUserId(survivorId);
- if (!IsValidSurvivor(survivor) || !IsValidInfected(smoker))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(smoker, SmokerCap);
- }
- //// [ CHARGER SKILL ] ////
- public void OnChargerCap(Event event, const char[] name, bool dontBroadcast)
- {
- int userId = event.GetInt("userid");
- int charger = GetClientOfUserId(userId);
- int survivorId = event.GetInt("victim");
- int survivor = GetClientOfUserId(survivorId);
- if (!IsValidSurvivor(survivor) || !IsValidInfected(charger))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(charger, ChargerCap);
- }
- public void OnChargerImpact(Event event, const char[] name, bool dontBroadcast)
- {
- int userId = event.GetInt("userid");
- int charger = GetClientOfUserId(userId);
- int survivorId = event.GetInt("victim");
- int survivor = GetClientOfUserId(survivorId);
- if (!IsValidSurvivor(survivor) || !IsValidInfected(charger))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(charger, ChargerImpact);
- }
- public void OnDeathCharge(int charger, int victim, float height, float distance, int wasCarried)
- {
- if (!IsValidSurvivor(victim) || !IsValidInfected(charger))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(charger, ChargerInstaKill);
- }
- //// [ BOOMER SKILL ] ////
- public void OnBoomerVomitLanded(int boomer, int amount)
- {
- if (!IsValidInfected(boomer))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- for (int i = amount; i > 0; i--)
- {
- UpdateScore(boomer, BommerVomit);
- }
- }
- //// [ TANK SKILL ] ////
- public void OnTankPunch(int attacker, int victim)
- {
- if (!IsValidSurvivor(victim) || !IsValidInfected(attacker))
- {
- PrintToServer("BOT involved, skipping");
- return;
- }
- UpdateScore(attacker, TankPunch);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement