Guest User

Untitled

a guest
Jul 18th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sdktools>
  5.  
  6. Handle sdkCallVomitOnPlayer, sdkCallBileJarPlayer, sdkCallBileJarInfected;
  7.  
  8. public void OnPluginStart()
  9. {
  10. Handle ConfigFile = LoadGameConfigFile("added_vomit");
  11.  
  12. StartPrepSDKCall(SDKCall_Player);
  13. PrepSDKCall_SetFromConf(ConfigFile, SDKConf_Signature, "CTerrorPlayer_OnVomitedUpon");
  14. PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  15. PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
  16. sdkCallVomitOnPlayer = EndPrepSDKCall();
  17.  
  18. StartPrepSDKCall(SDKCall_Player);
  19. PrepSDKCall_SetFromConf(ConfigFile, SDKConf_Signature, "CTerrorPlayer_OnHitByVomitJar");
  20. PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
  21. sdkCallBileJarPlayer = EndPrepSDKCall();
  22.  
  23. StartPrepSDKCall(SDKCall_Entity);
  24. PrepSDKCall_SetFromConf(ConfigFile, SDKConf_Signature, "Infected_OnHitByVomitJar");
  25. PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
  26. sdkCallBileJarInfected = EndPrepSDKCall();
  27.  
  28. HookEvent("player_death", EventHook);
  29. }
  30.  
  31. public Action EventHook(Event event, const char[] name, bool dontBroadcast)
  32. {
  33. int client = GetClientOfUserId(event.GetInt("userid"));
  34. if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetEntProp(client, Prop_Send, "m_zombieClass") == 2)
  35. {
  36. SetVomit(client);
  37. }
  38. }
  39.  
  40. public void OnEntityDestroyed(int entity)
  41. {
  42. if (IsValidEntity(entity))
  43. {
  44. char sTypeEx[56];
  45. GetEntityClassname(entity, sTypeEx, sizeof sTypeEx);
  46. if (strcmp(sTypeEx, "vomitjar_projectile") == 0)
  47. {
  48. SetVomit(entity);
  49. }
  50. }
  51. }
  52.  
  53. stock void SetVomit(int client)
  54. {
  55.  
  56. float fDistance;
  57. char entType[64];
  58. float vPos[3], vTargetPos[3];
  59. GetEntPropVector(client, Prop_Send, "m_vecOrigin", vPos);
  60. vPos[2] += 60;
  61.  
  62. for (int i = 1; i <= 2048; i++)
  63. {
  64. if (!IsValidEntity(i) || i == client) continue;
  65. if (i <= MaxClients && IsClientInGame(i) && IsPlayerAlive(i))
  66. {
  67. GetClientAbsOrigin(i, vTargetPos);
  68. fDistance = GetVectorDistance(vPos, vTargetPos);
  69. if(fDistance < 150 && IsVisibleTo(vTargetPos, vPos))
  70. {
  71. switch( GetClientTeam(i) )
  72. {
  73. case 2: SDKCall(sdkCallBileJarPlayer, i, client, true);
  74. case 3: SDKCall(sdkCallVomitOnPlayer, i, client, true);
  75. }
  76. }
  77. }
  78. else
  79. {
  80. GetEdictClassname(i, entType, sizeof(entType));
  81. if(strcmp(entType, "witch") == 0 || strcmp(entType, "infected") == 0)
  82. {
  83. GetEntityAbsOrigin(i, vTargetPos);
  84. fDistance = GetVectorDistance(vPos, vTargetPos);
  85. if (fDistance < 150 && IsVisibleTo(vTargetPos, vPos))
  86. {
  87. SDKCall(sdkCallBileJarInfected, i, client);
  88. }
  89. }
  90. }
  91. }
  92. }
  93.  
  94. stock bool bIsSurvivor(int client)
  95. {
  96. return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  97. }
  98.  
  99. static bool IsVisibleTo(float position[3], float targetposition[3])
  100. {
  101. float vAngles[3], vLookAt[3];
  102.  
  103. MakeVectorFromPoints(position, targetposition, vLookAt);
  104. GetVectorAngles(vLookAt, vAngles);
  105.  
  106. Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);
  107.  
  108. bool isVisible = false;
  109. if (TR_DidHit(trace))
  110. {
  111. float vStart[3];
  112. TR_GetEndPosition(vStart, trace);
  113.  
  114. if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
  115. {
  116. isVisible = true;
  117. }
  118. }
  119.  
  120. delete trace;
  121. return isVisible;
  122. }
  123.  
  124. public bool _TraceFilter(int entity, int contentsMask)
  125. {
  126. if (IsValidEntity(entity))
  127. {
  128. return false;
  129. }
  130. return true;
  131. }
  132.  
  133. stock void GetEntityAbsOrigin(int entity, float origin[3])
  134. {
  135. if (entity && IsValidEntity(entity)
  136. && (GetEntSendPropOffs(entity, "m_vecOrigin") != -1)
  137. && (GetEntSendPropOffs(entity, "m_vecMins") != -1)
  138. && (GetEntSendPropOffs(entity, "m_vecMaxs") != -1))
  139. {
  140. float mins[3], maxs[3];
  141. GetEntPropVector(entity, Prop_Send, "m_vecOrigin", origin);
  142. GetEntPropVector(entity, Prop_Send, "m_vecMins", mins);
  143. GetEntPropVector(entity, Prop_Send, "m_vecMaxs", maxs);
  144.  
  145. origin[0] += (mins[0] + maxs[0]) * 0.5;
  146. origin[1] += (mins[1] + maxs[1]) * 0.5;
  147. origin[2] += (mins[2] + maxs[2]) * 0.5;
  148. }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment