Advertisement
FlacoBey

Untitled

Jul 18th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.63 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.     delete ConfigFile;
  29.     HookEvent("player_death", EventHook);
  30. }
  31.  
  32. public Action EventHook(Event event, const char[] name, bool dontBroadcast)
  33. {
  34.     int client = GetClientOfUserId(event.GetInt("userid"));
  35.     if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetEntProp(client, Prop_Send, "m_zombieClass") == 2)
  36.     {
  37.         SetVomit(client);
  38.     }
  39. }
  40.  
  41. public void OnEntityDestroyed(int entity)
  42. {
  43.     if (IsValidEntity(entity))
  44.     {
  45.         char sTypeEx[56];
  46.         GetEntityClassname(entity, sTypeEx, sizeof sTypeEx);
  47.         if (strcmp(sTypeEx, "vomitjar_projectile") == 0)
  48.         {
  49.             SetVomit(entity);
  50.         }
  51.     }
  52. }
  53.  
  54. stock void SetVomit(int client)
  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 <= MaxClients; i++)
  63.     {
  64.         if (IsClientInGame(i) && IsPlayerAlive(i) && IsValidEntity(i) && i == client)
  65.         {
  66.             GetClientAbsOrigin(i, vTargetPos);
  67.             fDistance = GetVectorDistance(vPos, vTargetPos);
  68.             if(fDistance < 150 && IsVisibleTo(vTargetPos, vPos))
  69.             {
  70.                 switch( GetClientTeam(i) )
  71.                 {
  72.                     case 2: SDKCall(sdkCallBileJarPlayer, i, client, true);
  73.                     case 3: SDKCall(sdkCallVomitOnPlayer, i, client, true);
  74.                 }
  75.             }
  76.         }
  77.     }
  78.     for (int i = MaxClients; i <= 2048; i++)
  79.     {
  80.         if(IsValidEntity(i))
  81.         {
  82.             GetEdictClassname(i, entType, sizeof(entType));
  83.             if(strcmp(entType, "witch") == 0 || strcmp(entType, "infected") == 0)
  84.             {
  85.                 GetEntityAbsOrigin(i, vTargetPos);
  86.                 fDistance = GetVectorDistance(vPos, vTargetPos);
  87.                 if (fDistance < 150 && IsVisibleTo(vTargetPos, vPos))
  88.                 {
  89.                     SDKCall(sdkCallBileJarInfected, i, client);
  90.                 }
  91.             }
  92.         }
  93.     }
  94. }
  95.  
  96. stock bool bIsSurvivor(int client)
  97. {
  98.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  99. }
  100.  
  101. static bool IsVisibleTo(float position[3], float targetposition[3])
  102. {
  103.     float vAngles[3], vLookAt[3];
  104.    
  105.     MakeVectorFromPoints(position, targetposition, vLookAt);
  106.     GetVectorAngles(vLookAt, vAngles);
  107.  
  108.     Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);
  109.    
  110.     bool isVisible = false;
  111.     if (TR_DidHit(trace))
  112.     {
  113.         float vStart[3];
  114.         TR_GetEndPosition(vStart, trace);
  115.        
  116.         if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
  117.         {
  118.             isVisible = true;
  119.         }
  120.     }
  121.  
  122.     delete trace;
  123.     return isVisible;
  124. }
  125.  
  126. public bool _TraceFilter(int entity, int contentsMask)
  127. {
  128.     if (IsValidEntity(entity))
  129.     {
  130.         return false;
  131.     }
  132.     return true;
  133. }
  134.  
  135. stock void GetEntityAbsOrigin(int entity, float origin[3])
  136. {
  137.     if (entity && IsValidEntity(entity)
  138.     && (GetEntSendPropOffs(entity, "m_vecOrigin") != -1)
  139.     && (GetEntSendPropOffs(entity, "m_vecMins") != -1)
  140.     && (GetEntSendPropOffs(entity, "m_vecMaxs") != -1))
  141.     {
  142.         float mins[3], maxs[3];
  143.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", origin);
  144.         GetEntPropVector(entity, Prop_Send, "m_vecMins", mins);
  145.         GetEntPropVector(entity, Prop_Send, "m_vecMaxs", maxs);
  146.        
  147.         origin[0] += (mins[0] + maxs[0]) * 0.5;
  148.         origin[1] += (mins[1] + maxs[1]) * 0.5;
  149.         origin[2] += (mins[2] + maxs[2]) * 0.5;
  150.     }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement