FlacoBey

Untitled

May 22nd, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.49 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. float RadiusStumbleGrenade = 500.0
  16. float RadiusStublePipe = 500.0
  17. float RadiusStumbleBarrel = 500.0
  18.  
  19. bool IsAllow = false;
  20.  
  21. public OnMapStart()
  22. {
  23.     IsAllow = false;
  24.     CreateTimer(5.5, allow)
  25. }
  26.  
  27. public Action allow(Handle timer)
  28. {
  29.     IsAllow = true;
  30. }
  31.  
  32. public void OnEntityDestroyed(int entity)
  33. {
  34.     if(!IsAllow) return;
  35.    
  36.     if (IsValidEntity(entity) && IsValidEdict(entity))
  37.     {
  38.         char classname[128];
  39.         GetEdictClassname(entity, classname, 128);
  40.         if (StrEqual(classname, "grenade_launcher_projectile", false))
  41.         {
  42.             GrenadeTouch(entity);
  43.         }
  44.         if (StrEqual(classname, "pipe_bomb_projectile", false))
  45.         {
  46.             BombTouch(entity);
  47.         }
  48.         if (StrEqual(classname, "prop_fuel_barrel", false))
  49.         {
  50.             BarrelTouch(entity);
  51.         }
  52.     }
  53. }
  54.  
  55. public int GrenadeTouch(int entity)
  56. {
  57.     float pos[3];
  58.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  59.     GranadeExplode(pos);
  60. }
  61.  
  62. public int BombTouch(int entity)
  63. {
  64.     float pos[3];
  65.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  66.     BombExplode(pos)
  67. }
  68.  
  69. public int BarrelTouch(int entity)
  70. {
  71.     float pos[3];
  72.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  73.     BarrelExplode(pos);
  74. }
  75.  
  76. int GranadeExplode(float pos[3])
  77. {
  78.     float fDistance = 0.0;
  79.     float pos2[3];
  80.     for( int i = 0; i < 32; i++ )
  81.     {
  82.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  83.         {
  84.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  85.             if(vClass == 8)
  86.             {
  87.                 GetClientAbsOrigin(i, pos2);
  88.                 fDistance = GetVectorDistance(pos, pos2);
  89.                 if(fDistance < RadiusStumbleGrenade)
  90.                 {
  91.                     StaggerClient(i, pos)
  92.                 }
  93.                 if(fDistance < GrenadeRadius)
  94.                 {
  95.                     float iOne = GrenadeRadius - fDistance
  96.                     float vForward = GrenadeRadius / iOne
  97.                     int iDamage = RoundToCeil(GrenadeDamage / (vForward * vForward))
  98.                     ForceDamageEntity(i, iDamage, i)
  99.                 }
  100.             }
  101.         }
  102.     }
  103. }
  104.  
  105. int BombExplode(float pos[3])
  106. {
  107.     float fDistance = 0.0;
  108.     float pos2[3];
  109.     for( int i = 0; i < 32; i++ )
  110.     {
  111.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  112.         {
  113.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  114.             if(vClass == 8)
  115.             {
  116.                 GetClientAbsOrigin(i, pos2);
  117.                 fDistance = GetVectorDistance(pos, pos2);
  118.                 if(fDistance < RadiusStublePipe)
  119.                 {
  120.                     StaggerClient(i, pos)
  121.                 }
  122.                 if(fDistance < PipeRadius)
  123.                 {
  124.                     float iOne = PipeRadius - fDistance
  125.                     float vForward = PipeRadius / iOne
  126.                     int iDamage = RoundToCeil(PipeBombDamage / (vForward * vForward))
  127.                     ForceDamageEntity(i, iDamage, i)
  128.                 }
  129.                
  130.             }
  131.         }
  132.     }
  133. }
  134.  
  135. int BarrelExplode(float pos[3])
  136. {
  137.     float fDistance = 0.0;
  138.     float pos2[3];
  139.     for( int i = 0; i < 32; i++ )
  140.     {
  141.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  142.         {
  143.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  144.             if(vClass == 8)
  145.             {
  146.                 GetClientAbsOrigin(i, pos2);
  147.                 fDistance = GetVectorDistance(pos, pos2);
  148.                 if(fDistance < RadiusStumbleBarrel)
  149.                 {
  150.                     StaggerClient(i, pos)
  151.                 }
  152.                 if(fDistance < BarrelRadius)
  153.                 {
  154.                     float iOne = BarrelRadius - fDistance
  155.                     float vForward = BarrelRadius / iOne
  156.                     int iDamage = RoundToCeil(BarrelDamage / (vForward * vForward))
  157.                     ForceDamageEntity(i, iDamage, i)
  158.                 }
  159.             }
  160.         }
  161.     }
  162. }
  163.  
  164. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  165. {
  166.     float victim_origin[3];
  167.     char rupture[32];
  168.     char damage_victim[32];
  169.     IntToString(damage, rupture, sizeof(rupture));
  170.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  171.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  172.     int entity = CreateEntityByName("point_hurt");
  173.     DispatchKeyValue(victim, "targetname", damage_victim);
  174.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  175.     DispatchKeyValue(entity, "Damage", rupture);
  176.     DispatchSpawn(entity);
  177.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  178.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  179.     DispatchKeyValue(entity, "classname", "point_hurt");
  180.     DispatchKeyValue(victim, "targetname", "null");
  181.     AcceptEntityInput(entity, "Kill");
  182. }
  183.  
  184. void StaggerClient(int iUserID, const float fPos[3])
  185. {
  186.     static int iScriptLogic = INVALID_ENT_REFERENCE;
  187.     if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  188.     {
  189.         iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
  190.         if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  191.             LogError("Could not create 'logic_script");
  192.  
  193.         DispatchSpawn(iScriptLogic);
  194.     }
  195.  
  196.     char sBuffer[96];
  197.     Format(sBuffer, sizeof(sBuffer), "GetPlayerFromUserID(%d).Stagger(Vector(%d,%d,%d))", iUserID, RoundFloat(fPos[0]), RoundFloat(fPos[1]), RoundFloat(fPos[2]));
  198.     SetVariantString(sBuffer);
  199.     AcceptEntityInput(iScriptLogic, "RunScriptCode");
  200.     AcceptEntityInput(iScriptLogic, "Kill");
  201. }
  202.  
  203. stock bool IsValidClient(int client)
  204. {
  205.     if ( client < 1 || client > MaxClients ) return false;
  206.     if( !IsClientInGame(client)) return false;
  207.     if ( !IsPlayerAlive(client)) return false;
  208.     if ( GetClientTeam(client) != 3) return false;
  209.     return true;
  210. }
  211.  
  212. public void ScreenShake(int target, float power)
  213. {
  214.     Handle msg;
  215.     msg = StartMessageOne("Shake", target);
  216.     BfWriteByte(msg, 0);
  217.     BfWriteFloat(msg, power);
  218.     BfWriteFloat(msg, 10.0);
  219.     BfWriteFloat(msg, 3.0);
  220.     EndMessage();
  221. }
Advertisement
Add Comment
Please, Sign In to add comment