Advertisement
DeathChaos25

Sequence Incap Crawl

Sep 4th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.72 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <l4d2tools>
  4.  
  5. public Plugin:myinfo =
  6. {
  7.     name = "[L4D2] Incap Crawling",
  8.     author = "DeathChaos25",
  9.     description = "",
  10.     version = "",
  11.     url = ""
  12. }
  13.  
  14. public OnPluginStart()
  15. {
  16.     SetConVarInt(FindConVar("survivor_allow_crawling"), 1);
  17.     SetConVarInt(FindConVar("survivor_crawl_speed"), 35);
  18. }
  19.  
  20. public Action:L4D2_OnSelectSequence(client, &sequence)
  21. {
  22.     if (IsSurvivor(client) && IsPlayerAlive(client) && !IsPlayerHeld(client)
  23.          && GetEntProp(client, Prop_Send, "m_isHangingFromLedge") != 1
  24.          && GetEntProp(client, Prop_Send, "m_reviveOwner") == -1 && IsIncapacitated(client))
  25.     {
  26.         new crawl = GetCrawlSequence(client);
  27.         new buttons = GetClientButtons(client);
  28.         if (crawl != -1 && buttons & IN_FORWARD)
  29.         {
  30.             sequence = crawl;
  31.             GotoThirdPerson(client);
  32.             SetEntPropVector(client, Prop_Send, "m_angRotation", Angles);
  33.             return Plugin_Handled;
  34.         }
  35.         else GotoFirstPerson(client);
  36.     }
  37.     else if (IsSurvivor(client) && IsPlayerAlive(client) && sequence != GetCrawlSequence(client))
  38.     {
  39.         GotoFirstPerson(client);
  40.     }
  41.     return Plugin_Continue;
  42. }
  43.  
  44. bool:IsSurvivor(client)
  45. {
  46.     return (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2);
  47. }
  48.  
  49. stock bool:IsPlayerHeld(client)
  50. {
  51.     new jockey = GetEntPropEnt(client, Prop_Send, "m_jockeyAttacker");
  52.     new charger = GetEntPropEnt(client, Prop_Send, "m_pummelAttacker");
  53.     new hunter = GetEntPropEnt(client, Prop_Send, "m_pounceAttacker");
  54.     new smoker = GetEntPropEnt(client, Prop_Send, "m_tongueOwner");
  55.     if (jockey > 0 || charger > 0 || hunter > 0 || smoker > 0)
  56.     {
  57.         return true;
  58.     }
  59.     return false;
  60. }
  61. stock bool:IsIncapacitated(client)
  62. {
  63.     if (GetEntProp(client, Prop_Send, "m_isIncapacitated", 1) > 0)
  64.         return true;
  65.     return false;
  66. }
  67.  
  68. GotoThirdPerson(client)
  69. {
  70.     SetEntPropFloat(client, Prop_Send, "m_TimeForceExternalView", 99999.3);
  71. }
  72.  
  73. GotoFirstPerson(client)
  74. {
  75.     SetEntPropFloat(client, Prop_Send, "m_TimeForceExternalView", 0.0);
  76. }
  77.  
  78. stock GetCrawlSequence(client)
  79. {
  80.     if (IsSurvivor(client))
  81.     {
  82.         decl String:model[64];
  83.         GetEntPropString(client, Prop_Data, "m_ModelName", model, sizeof(model));
  84.         if (StrContains(model, "gambler", false) != -1)
  85.         {
  86.             return 631;
  87.         }
  88.         else if (StrContains(model, "producer", false) != -1)
  89.         {
  90.             return 639;
  91.         }
  92.         else if (StrContains(model, "mechanic", false) != -1)
  93.         {
  94.             return 636;
  95.         }
  96.         else if (StrContains(model, "namvet", false) != -1)
  97.         {
  98.             return 539;
  99.         }
  100.         else if (StrContains(model, "teenangst", false) != -1)
  101.         {
  102.             return 529;
  103.         }
  104.         else if (StrContains(model, "biker", false) != -1)
  105.         {
  106.             return 542;
  107.         }
  108.         else if (StrContains(model, "manager", false) != -1)
  109.         {
  110.             return 539;
  111.         }
  112.     }
  113.     return -1;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement