FlacoBey

Untitled

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