FlacoBey

Untitled

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