Advertisement
FlacoBey

Untitled

May 24th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.74 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include sdkhooks
  4.  
  5. #pragma tabsize 0
  6.  
  7. float iGrenade = 1000.0
  8. float iPipe = 1000.0
  9. float iBarrel = 1000.0
  10.  
  11. float iRadiusG = 440.0
  12. float iRadiusP = 440.0
  13. float iRadiusB = 440.0
  14.  
  15.  
  16. public void OnEntityDestroyed(int entity)
  17. {
  18.     if (IsValidEntity(entity) && IsValidEdict(entity))
  19.     {
  20.         char classname[128];
  21.         GetEdictClassname(entity, classname, 128);
  22.         if (StrEqual(classname, "grenade_launcher_projectile", false))
  23.         {
  24.             float bPos[3]
  25.             GetEntPropVector(entity, Prop_Send, "m_vecOrigin", bPos);
  26.             for (new i = 33; i <= 2048; i++)
  27.             {
  28.                 if(IsWitch(i))
  29.                 {
  30.                     float vPos[3]
  31.                     GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
  32.                     if (!IsVisibleTo(bPos, vPos)) continue;
  33.                    
  34.                     int iCreator = GetEntPropEnt(entity, Prop_Send, "m_hThrower")
  35.                     float fTargetDistance = GetVectorDistance(bPos, vPos);
  36.                     if(fTargetDistance < iRadiusG)
  37.                     {
  38.                         float vTransit = iRadiusG - fTargetDistance
  39.                         float vForward =  iRadiusG / vTransit
  40.                         int iTotal = RoundToCeil(iGrenade / (vForward * vForward * vForward));
  41.                         ForceDamageEntity(iCreator, iTotal, i)
  42.                     }
  43.                 }
  44.             }
  45.         }
  46.         if (StrEqual(classname, "pipe_bomb_projectile", false))
  47.         {
  48.             float bPos[3]
  49.             GetEntPropVector(entity, Prop_Send, "m_vecOrigin", bPos);
  50.             for (new i = 33; i <= 2048; i++)
  51.             {
  52.                 if(IsWitch(i))
  53.                 {
  54.                     float vPos[3]
  55.                     GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
  56.                     if (!IsVisibleTo(bPos, vPos)) continue;
  57.                    
  58.                     int iOwner = GetEntPropEnt(entity, Prop_Send, "m_hThrower")
  59.                     float fTargetDistance = GetVectorDistance(bPos, vPos);
  60.                     if(fTargetDistance < iRadiusP)
  61.                     {
  62.                         float vTransit = iRadiusP - fTargetDistance
  63.                         float vForward =  iRadiusP / vTransit
  64.                         int iTotal = RoundToCeil(iPipe / (vForward * vForward * vForward));
  65.                         ForceDamageEntity(iOwner, iTotal, i)
  66.                     }
  67.                 }
  68.             }
  69.         }
  70.         if (StrEqual(classname, "prop_fuel_barrel", false))
  71.         {
  72.             float bPos[3]
  73.             GetEntPropVector(entity, Prop_Send, "m_vecOrigin", bPos);
  74.             for (new i = 33; i <= 2048; i++)
  75.             {
  76.                 if(IsWitch(i))
  77.                 {
  78.                     float vPos[3]
  79.                     GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
  80.                     if (!IsVisibleTo(bPos, vPos)) continue;
  81.                    
  82.                     float fTargetDistance = GetVectorDistance(bPos, vPos);
  83.                     if(fTargetDistance < iRadiusB)
  84.                     {
  85.                         float vTransit = iRadiusB - fTargetDistance
  86.                         float vForward =  iRadiusB / vTransit
  87.                         int iTotal = RoundToCeil(iBarrel / (vForward * vForward * vForward));
  88.                         ForceDamageEntity(i, iTotal, i)
  89.                     }
  90.                 }
  91.             }
  92.         }
  93.     }
  94. }
  95.  
  96. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  97. {
  98.     float victim_origin[3];
  99.     char rupture[32];
  100.     char damage_victim[32];
  101.     IntToString(damage, rupture, sizeof(rupture));
  102.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  103.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  104.     int entity = CreateEntityByName("point_hurt");
  105.     DispatchKeyValue(victim, "targetname", damage_victim);
  106.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  107.     DispatchKeyValue(entity, "Damage", rupture);
  108.     DispatchSpawn(entity);
  109.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  110.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  111.     DispatchKeyValue(entity, "classname", "point_hurt");
  112.     DispatchKeyValue(victim, "targetname", "null");
  113.     AcceptEntityInput(entity, "Kill");
  114. }
  115.  
  116. static bool IsVisibleTo(float position[3], float targetposition[3])
  117. {
  118.     float vAngles[3], vLookAt[3];
  119.    
  120.     MakeVectorFromPoints(position, targetposition, vLookAt); // compute vector from start to target
  121.     GetVectorAngles(vLookAt, vAngles); // get angles from vector for trace
  122.    
  123.     // execute Trace
  124.     Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);
  125.    
  126.     bool isVisible = false;
  127.     if (TR_DidHit(trace))
  128.     {
  129.         float vStart[3];
  130.         TR_GetEndPosition(vStart, trace); // retrieve our trace endpoint
  131.        
  132.         if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
  133.         {
  134.             isVisible = true; // if trace ray length plus tolerance equal or bigger absolute distance, you hit the target
  135.         }
  136.     }
  137.    
  138.     return isVisible;
  139. }
  140.  
  141. public bool _TraceFilter(int entity, int contentsMask)
  142. {
  143.     if (!entity || entity <= MaxClients || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit
  144.     {
  145.         return false;
  146.     }
  147.     return true;
  148. }
  149.  
  150. stock bool IsWitch(int entity)
  151. {
  152.     if (entity > 0 && IsValidEntity(entity) && IsValidEdict(entity))
  153.     {
  154.         char entType[64];
  155.         GetEdictClassname(entity, entType, sizeof(entType));
  156.         return StrEqual(entType, "witch");
  157.     }
  158.     return false;
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement