FlacoBey

Untitled

May 22nd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.89 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include sdkhooks
  4.  
  5. #pragma tabsize 0
  6.  
  7. float GrenadeDamage = 1000.0
  8. float PipeBombDamage = 1000.0
  9. float BarrelDamage = 1000.0
  10.  
  11. float GrenadeRadius = 500.0
  12. float PipeRadius = 500.0
  13. float BarrelRadius = 500.0
  14.  
  15. bool IsAllow = false;
  16.  
  17. public OnMapStart()
  18. {
  19.     IsAllow = false;
  20.     CreateTimer(3.0, allow)
  21. }
  22.  
  23. public Action allow(Handle timer)
  24. {
  25.     IsAllow = true;
  26. }
  27.  
  28. public void OnEntityDestroyed(int entity)
  29. {
  30.     if(!IsAllow) return;
  31.    
  32.     if (IsValidEntity(entity) && IsValidEdict(entity))
  33.     {
  34.         char classname[128];
  35.         GetEdictClassname(entity, classname, 128);
  36.         if (StrEqual(classname, "grenade_launcher_projectile", false))
  37.         {
  38.             GrenadeTouch(entity);
  39.         }
  40.         if (StrEqual(classname, "pipe_bomb_projectile", false))
  41.         {
  42.             BombTouch(entity);
  43.         }
  44.         if (StrEqual(classname, "prop_fuel_barrel", false))
  45.         {
  46.             BarrelTouch(entity);
  47.         }
  48.     }
  49. }
  50.  
  51. public int GrenadeTouch(int entity)
  52. {
  53.     float pos[3];
  54.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  55.     GranadeExplode(pos);
  56. }
  57.  
  58. public int BombTouch(int entity)
  59. {
  60.     float pos[3];
  61.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  62.     BombExplode(pos)
  63. }
  64.  
  65. public int BarrelTouch(int entity)
  66. {
  67.     float pos[3];
  68.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  69.     BarrelExplode(pos);
  70. }
  71.  
  72. int GranadeExplode(float pos[3])
  73. {
  74.     float fDistance = 0.0;
  75.     float pos2[3];
  76.     for( int i = 0; i < 32; i++ )
  77.     {
  78.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  79.         {
  80.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  81.             if(vClass == 6)
  82.             {
  83.                 GetClientAbsOrigin(i, pos2);
  84.                 fDistance = GetVectorDistance(pos, pos2);
  85.                 if(fDistance < GrenadeRadius)
  86.                 {
  87.                     float iOne = GrenadeRadius - fDistance
  88.                     float vForward = GrenadeRadius / iOne
  89.                     int iDamage = RoundToCeil(GrenadeDamage / (vForward * vForward))
  90.                     ForceDamageEntity(i, iDamage, i)
  91.                 }
  92.             }
  93.         }
  94.     }
  95. }
  96.  
  97. int BombExplode(float pos[3])
  98. {
  99.     float fDistance = 0.0;
  100.     float pos2[3];
  101.     for( int i = 0; i < 32; i++ )
  102.     {
  103.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  104.         {
  105.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  106.             if(vClass == 6)
  107.             {
  108.                 GetClientAbsOrigin(i, pos2);
  109.                 fDistance = GetVectorDistance(pos, pos2);
  110.                 if(fDistance < PipeRadius)
  111.                 {
  112.                     float iOne = PipeRadius - fDistance
  113.                     float vForward = PipeRadius / iOne
  114.                     int iDamage = RoundToCeil(PipeBombDamage / (vForward * vForward))
  115.                     ForceDamageEntity(i, iDamage, i)
  116.                 }
  117.                
  118.             }
  119.         }
  120.     }
  121. }
  122.  
  123. int BarrelExplode(float pos[3])
  124. {
  125.     float fDistance = 0.0;
  126.     float pos2[3];
  127.     for( int i = 0; i < 32; i++ )
  128.     {
  129.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  130.         {
  131.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  132.             if(vClass == 6)
  133.             {
  134.                 GetClientAbsOrigin(i, pos2);
  135.                 fDistance = GetVectorDistance(pos, pos2);
  136.                 if(fDistance < BarrelRadius)
  137.                 {
  138.                     float iOne = BarrelRadius - fDistance
  139.                     float vForward = BarrelRadius / iOne
  140.                     int iDamage = RoundToCeil(BarrelDamage / (vForward * vForward))
  141.                     ForceDamageEntity(i, iDamage, i)
  142.                 }
  143.             }
  144.         }
  145.     }
  146. }
  147.  
  148. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  149. {
  150.     float victim_origin[3];
  151.     char rupture[32];
  152.     char damage_victim[32];
  153.     IntToString(damage, rupture, sizeof(rupture));
  154.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  155.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  156.     int entity = CreateEntityByName("point_hurt");
  157.     DispatchKeyValue(victim, "targetname", damage_victim);
  158.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  159.     DispatchKeyValue(entity, "Damage", rupture);
  160.     DispatchSpawn(entity);
  161.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  162.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  163.     DispatchKeyValue(entity, "classname", "point_hurt");
  164.     DispatchKeyValue(victim, "targetname", "null");
  165.     AcceptEntityInput(entity, "Kill");
  166. }
  167.  
  168. stock bool:IsValidClient(client)
  169. {
  170.     if ( client < 1 || client > MaxClients ) return false;
  171.     if ( !IsClientConnected( client )) return false;
  172.     if ( !IsClientInGame( client )) return false;
  173.     if ( GetClientTeam( client ) != 3 ) return false;
  174.     return true;
  175. }
Advertisement
Add Comment
Please, Sign In to add comment