DeathChaos25

[L4D2] Fix L4D1 survivors collapse to incap animations

Sep 4th, 2015
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <l4d2tools>
  4.  
  5. static bool:incapped[MAXPLAYERS + 1] = false;
  6.  
  7. public Plugin:myinfo =
  8. {
  9.     name = "[L4D2] Fix L4D1 survivors collapse to incap animations",
  10.     author = "DeathChaos25",
  11.     description = "Fixes male L4D1 survivors having no animation when initially incapped",
  12.     version = "",
  13.     url = ""
  14. }
  15.  
  16. public void OnPluginStart()
  17. {
  18.     HookEvent("player_incapacitated", Event_Incap);
  19. }
  20. public Action:Event_Incap(Handle:event, const String:name[], bool:dontBroadcast)
  21. {
  22.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  23.     if (IsSurvivor(client))
  24.     {
  25.         incapped[client] = true;
  26.         CreateTimer(3.32, SETFALSE, client);
  27.     }
  28. }
  29.  
  30. public Action:SETFALSE(Handle:Timer, client)
  31. {
  32.     incapped[client] = false;
  33. }
  34.  
  35. public Action:L4D2_OnSelectSequence(client, &sequence)
  36. {
  37.     if (IsSurvivor(client) && IsPlayerAlive(client) && IsIncapacitated(client) && incapped[client] && !IsPlayerHeld(client))
  38.     {
  39.         new incap = GetIncapSequence(client);
  40.         if (incap != -1)
  41.         {
  42.             sequence = incap;
  43.             return Plugin_Handled;
  44.         }
  45.     }
  46.     return Plugin_Continue;
  47. }
  48.  
  49. bool:IsSurvivor(client)
  50. {
  51.     return (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2);
  52. }
  53.  
  54. stock bool:IsPlayerHeld(client)
  55. {
  56.     new jockey = GetEntPropEnt(client, Prop_Send, "m_jockeyAttacker");
  57.     new charger = GetEntPropEnt(client, Prop_Send, "m_pummelAttacker");
  58.     new hunter = GetEntPropEnt(client, Prop_Send, "m_pounceAttacker");
  59.     new smoker = GetEntPropEnt(client, Prop_Send, "m_tongueOwner");
  60.     if (jockey > 0 || charger > 0 || hunter > 0 || smoker > 0)
  61.     {
  62.         return true;
  63.     }
  64.     return false;
  65. }
  66. stock bool:IsIncapacitated(client)
  67. {
  68.     if (GetEntProp(client, Prop_Send, "m_isIncapacitated", 1) > 0)
  69.         return true;
  70.     return false;
  71. }
  72.  
  73. stock GetIncapSequence(client)
  74. {
  75.     if (IsSurvivor(client))
  76.     {
  77.         decl String:model[64];
  78.         GetEntPropString(client, Prop_Data, "m_ModelName", model, sizeof(model));
  79.         if (StrContains(model, "namvet", false) != -1)
  80.         {
  81.             return 518;
  82.         }
  83.         else if (StrContains(model, "biker", false) != -1)
  84.         {
  85.             return 521;
  86.         }
  87.         else if (StrContains(model, "manager", false) != -1)
  88.         {
  89.             return 518;
  90.         }
  91.     }
  92.     return -1;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment