Advertisement
FlacoBey

Untitled

Jun 15th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.99 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sourcemod>
  5. #include <sdktools>
  6. #include <sdkhooks>
  7.  
  8. #define GAMEDATA_FILE           "staggersolver"
  9.  
  10. #define TEAM_SURVIVOR           2
  11. #define TEAM_INFECTED           3
  12.  
  13. #define ZC_SMOKER               1
  14. #define ZC_BOOMER               2
  15. #define ZC_HUNTER               3
  16. #define ZC_SPITTER              4
  17. #define ZC_JOCKEY               5
  18. #define ZC_CHARGER              6
  19.  
  20. #define SKEET_POUNCING_AI       (0x01)
  21. #define DEBUFF_CHARGING_AI      (0x02)
  22. #define BLOCK_STUMBLE_SCRATCH   (0x04)
  23. #define ALL_FEATURES            (SKEET_POUNCING_AI | DEBUFF_CHARGING_AI | BLOCK_STUMBLE_SCRATCH)
  24.  
  25. Handle hGameConf;
  26. Handle hIsStaggering;
  27.  
  28. int iPounceInterrupt                    = 150;
  29. int iHunterSkeetDamage[MAXPLAYERS+1]    = { 0, ... };
  30.  
  31. public void OnPluginStart()
  32. {
  33.     Handle hCvarPounceInterrupt = FindConVar("z_pounce_damage_interrupt");
  34.  
  35.     iPounceInterrupt = GetConVarInt(hCvarPounceInterrupt);
  36.     HookEvent("ability_use", Event_AbilityUse, EventHookMode_Post);
  37.     hGameConf = LoadGameConfigFile(GAMEDATA_FILE);
  38.     if (hGameConf == INVALID_HANDLE)
  39.     SetFailState("[aidmgfix] Could not load game config file (staggersolver.txt).");
  40.  
  41.     StartPrepSDKCall(SDKCall_Player);
  42.  
  43.     if (!PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "IsStaggering"))
  44.     SetFailState("[aidmgfix] Could not find signature IsStaggering.");
  45.     PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
  46.     hIsStaggering = EndPrepSDKCall();
  47.     if (hIsStaggering == INVALID_HANDLE)
  48.     SetFailState("[aidmgfix] Failed to load signature IsStaggering");
  49.  
  50.     CloseHandle(hGameConf);
  51. }
  52.  
  53.  
  54. public void OnPounceInterruptChanged(Handle cvar, const char[] oldVal, const char[] newVal)
  55. {
  56.     iPounceInterrupt = StringToInt(newVal);
  57. }
  58.  
  59.  
  60. public void OnClientPostAdminCheck(int client)
  61. {
  62.     SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  63.     iHunterSkeetDamage[client] = 0;
  64. }
  65.  
  66. public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
  67. {
  68.  
  69.     if (IsClientAndInGame(victim) && IsClientAndInGame(attacker) && damage > 0.0 && GetClientTeam(victim) == TEAM_INFECTED && IsFakeClient(victim))
  70.     {
  71.         int zombieClass = GetEntProp(victim, Prop_Send, "m_zombieClass");
  72.         if (zombieClass == ZC_HUNTER && GetEntProp(victim, Prop_Send, "m_isAttemptingToPounce"))
  73.         {
  74.             iHunterSkeetDamage[victim] += RoundToFloor(damage);
  75.             if (iHunterSkeetDamage[victim] >= iPounceInterrupt)
  76.             {
  77.                 iHunterSkeetDamage[victim] = 0;
  78.                 damage = float(GetClientHealth(victim));
  79.                 return Plugin_Changed;
  80.             }
  81.         }
  82.         else if (zombieClass == ZC_CHARGER)
  83.         {
  84.             int abilityEnt = GetEntPropEnt(victim, Prop_Send, "m_customAbility");
  85.             if (IsValidEntity(abilityEnt) && GetEntProp(abilityEnt, Prop_Send, "m_isCharging") > 0)
  86.             {
  87.                 damage = (damage - FloatFraction(damage) + 1.0) * 3.0;
  88.                 return Plugin_Changed;
  89.             }
  90.         }
  91.     }
  92.    
  93.     return Plugin_Continue;
  94. }
  95.  
  96. public Action OnPlayerRunCmd(int client, int &buttons)
  97. {
  98.     if ((BLOCK_STUMBLE_SCRATCH) && IsClientAndInGame(client) && GetClientTeam(client) == TEAM_INFECTED && IsFakeClient(client) && SDKCall(hIsStaggering, client))
  99.     {
  100.         buttons &= ~IN_ATTACK2;
  101.     }
  102.    
  103.     return Plugin_Continue;
  104. }
  105.  
  106. public Action Event_AbilityUse(Handle event, const char[] name, bool dontBroadcast)
  107. {
  108.     int client = GetClientOfUserId(GetEventInt(event, "userid"));
  109.     char abilityName[64];
  110.    
  111.     if (!IsClientAndInGame(client) || GetClientTeam(client) != TEAM_INFECTED) { return; }
  112.    
  113.     GetEventString(event, "ability", abilityName, sizeof(abilityName));
  114.    
  115.     if (strcmp(abilityName, "ability_lunge", false) == 0)
  116.     {
  117.         iHunterSkeetDamage[client] = 0;
  118.     }
  119. }
  120.  
  121. bool IsClientAndInGame(int index)
  122. {
  123.     return (index > 0 && index <= MaxClients && IsClientInGame(index));
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement