Advertisement
FlacoBey

Untitled

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