Advertisement
FlacoBey

Untitled

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