Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #pragma newdecls required
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- #define GAMEDATA_FILE "staggersolver"
- #define TEAM_SURVIVOR 2
- #define TEAM_INFECTED 3
- #define ZC_SMOKER 1
- #define ZC_BOOMER 2
- #define ZC_HUNTER 3
- #define ZC_SPITTER 4
- #define ZC_JOCKEY 5
- #define ZC_CHARGER 6
- #define SKEET_POUNCING_AI (0x01)
- #define DEBUFF_CHARGING_AI (0x02)
- #define BLOCK_STUMBLE_SCRATCH (0x04)
- #define ALL_FEATURES (SKEET_POUNCING_AI | DEBUFF_CHARGING_AI | BLOCK_STUMBLE_SCRATCH)
- Handle hGameConf;
- Handle hIsStaggering;
- int iPounceInterrupt = 150;
- int iHunterSkeetDamage[MAXPLAYERS+1] = { 0, ... };
- public void OnPluginStart()
- {
- Handle hCvarPounceInterrupt = FindConVar("z_pounce_damage_interrupt");
- iPounceInterrupt = GetConVarInt(hCvarPounceInterrupt);
- HookEvent("ability_use", Event_AbilityUse, EventHookMode_Post);
- hGameConf = LoadGameConfigFile(GAMEDATA_FILE);
- if (hGameConf == INVALID_HANDLE)
- SetFailState("[aidmgfix] Could not load game config file (staggersolver.txt).");
- StartPrepSDKCall(SDKCall_Player);
- if (!PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "IsStaggering"))
- SetFailState("[aidmgfix] Could not find signature IsStaggering.");
- PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
- hIsStaggering = EndPrepSDKCall();
- if (hIsStaggering == INVALID_HANDLE)
- SetFailState("[aidmgfix] Failed to load signature IsStaggering");
- CloseHandle(hGameConf);
- }
- public void OnPounceInterruptChanged(Handle cvar, const char[] oldVal, const char[] newVal)
- {
- iPounceInterrupt = StringToInt(newVal);
- }
- public void OnClientPostAdminCheck(int client)
- {
- SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- iHunterSkeetDamage[client] = 0;
- }
- public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
- {
- if (IsClientAndInGame(victim) && IsClientAndInGame(attacker) && damage > 0.0 && GetClientTeam(victim) == TEAM_INFECTED && IsFakeClient(victim))
- {
- int zombieClass = GetEntProp(victim, Prop_Send, "m_zombieClass");
- if (zombieClass == ZC_HUNTER && GetEntProp(victim, Prop_Send, "m_isAttemptingToPounce"))
- {
- iHunterSkeetDamage[victim] += RoundToFloor(damage);
- if (iHunterSkeetDamage[victim] >= iPounceInterrupt)
- {
- iHunterSkeetDamage[victim] = 0;
- damage = float(GetClientHealth(victim));
- return Plugin_Changed;
- }
- }
- else if (zombieClass == ZC_CHARGER)
- {
- int abilityEnt = GetEntPropEnt(victim, Prop_Send, "m_customAbility");
- if (IsValidEntity(abilityEnt) && GetEntProp(abilityEnt, Prop_Send, "m_isCharging") > 0)
- {
- damage = (damage - FloatFraction(damage) + 1.0) * 3.0;
- return Plugin_Changed;
- }
- }
- }
- return Plugin_Continue;
- }
- public Action OnPlayerRunCmd(int client, int &buttons)
- {
- if ((BLOCK_STUMBLE_SCRATCH) && IsClientAndInGame(client) && GetClientTeam(client) == TEAM_INFECTED && IsFakeClient(client) && SDKCall(hIsStaggering, client))
- {
- buttons &= ~IN_ATTACK2;
- }
- return Plugin_Continue;
- }
- public Action Event_AbilityUse(Handle event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- char abilityName[64];
- if (!IsClientAndInGame(client) || GetClientTeam(client) != TEAM_INFECTED) { return; }
- GetEventString(event, "ability", abilityName, sizeof(abilityName));
- if (strcmp(abilityName, "ability_lunge", false) == 0)
- {
- iHunterSkeetDamage[client] = 0;
- }
- }
- bool IsClientAndInGame(int index)
- {
- return (index > 0 && index <= MaxClients && IsClientInGame(index));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement