FlacoBey

Untitled

May 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.87 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. //Survivors
  5. int iDamageGrenadeLauncherS = 200000;
  6. float iPowerSFling = 1200.0;
  7. float iRadiusSdie = 100.0
  8. float iRadiusSFling = 900.0
  9. float iRadiusSDamage = 4000.0
  10.  
  11. //Survivors Pipe Bomb
  12. int iDamagePipeS = 600;
  13. float iPowerSFlingPipe = 550.0;
  14. float iRadiusSdiePipe = 200.0
  15. float iRadiusSFlingPipe = 700.0
  16. float iRadiusSDamagePipe = 900.0
  17.  
  18. //Tank
  19. int iDamageGrenadeLauncherT = 500;
  20. float iPowerTFling = 100.0
  21. float iRadiusTDamage = 700.0
  22. float iRadiusTFling = 700.0
  23.  
  24. //Tank Pipe
  25. int iDamagePipeT = 400
  26. float iPowerTFlingPipe = 10.0
  27. float iRadiusTDamagePipe = 700.0
  28. float iRadiusTFlingPipe = 700.0
  29.  
  30. //Charger
  31. int iDamageGrenadeLauncherC = 500
  32. float iPowerCFling = 300.0
  33. float iRadiusCDamage = 400.0
  34. float iRadiusCFling = 300.0
  35.  
  36. //Charger Pipe
  37. int iDamagePipeC = 400;
  38. float iPowerCFlingPipe = 300.0
  39. float iRadiusCDamagePipe = 400.0
  40. float iRadiusCFlingPipe = 300.0
  41.  
  42. //Other Inf
  43. int iDamageGrenadeLauncherI = 500
  44. float iPowerIFling = 150.0
  45. float iRadiusIDamage = 200.0
  46. float iRadiusIFling = 400.0
  47.  
  48. //Other Inf Pipe
  49. int iDamagePipeI = 500;
  50. float iPowerIFlingPipe = 150.0
  51. float iRadiusIDamagePipe = 200.0
  52. float iRadiusIFlingPipe = 400.0
  53.  
  54. Handle sdkCallPushPlayer;
  55.  
  56. public OnPluginStart()
  57. {
  58.     Handle GameConf = LoadGameConfigFile("gamedata_stager");   
  59.            
  60.     if(GameConf == INVALID_HANDLE)
  61.     {
  62.         SetFailState("Couldn't find the offsets and signatures file. Please, check that it is installed correctly.");
  63.     }
  64.        
  65.     StartPrepSDKCall(SDKCall_Player);
  66.     PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");
  67.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  68.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
  69.     PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  70.     PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  71.     sdkCallPushPlayer = EndPrepSDKCall();
  72. }
  73.  
  74. public OnEntityDestroyed(entity)
  75. {
  76.     if(IsValidEntity(entity)) CreateTimer(0.1, ValidExplosive, EntIndexToEntRef(entity));
  77. }
  78.  
  79. public Action ValidExplosive(Handle timer, ent)
  80. {
  81.     int entity = EntRefToEntIndex(ent)
  82.     if(IsValidEntity(entity))
  83.     {
  84.         char sCls[32]
  85.         GetEntityClassname(entity, sCls, sizeof(sCls))
  86.         if(StrEqual(sCls, "grenade_launcher_projectile"))
  87.         {
  88.             float vPos[3], vDamager[3];
  89.             GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vDamager);
  90.             for(int i = 1; i <= 32; ++i)
  91.             {
  92.                 if(!IsValidClient(i)) continue;
  93.                
  94.                 GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
  95.                 float fTargetDistance = GetVectorDistance(vDamager, vPos);
  96.                    
  97.                 if(GetClientTeam(i) == 3)
  98.                 {
  99.                     int vClass = GetEntProp(i, Prop_Send, "m_zombieClass");
  100.                     if (vClass == 8)
  101.                     {
  102.                         if (fTargetDistance < iRadiusTDamage)
  103.                         {
  104.                             float iDamage = iRadiusTDamage / fTargetDistance
  105.                             int iTotal = RoundToCeil(iDamageGrenadeLauncherT / (iDamage * iDamage))
  106.                             ForceDamageEntity(entity, iTotal, i)
  107.                         }
  108.                         if (fTargetDistance < iRadiusTFling)
  109.                         {
  110.                             Fly(entity, i, iPowerTFling)
  111.                         }
  112.                     }
  113.                     else if (vClass == 6)
  114.                     {
  115.                         if (fTargetDistance < iRadiusCDamage)
  116.                         {
  117.                             float iDamage = iRadiusCDamage / fTargetDistance
  118.                             int iTotal = RoundToCeil(iDamageGrenadeLauncherC / (iDamage * iDamage))
  119.                             ForceDamageEntity(entity, iTotal, i)
  120.                            
  121.                         }
  122.                         if (fTargetDistance < iRadiusCFling)
  123.                         {
  124.                             Fly(entity, i, iPowerCFling)
  125.                         }
  126.                     }
  127.                     else
  128.                     {
  129.                         if (fTargetDistance < iRadiusIDamage)
  130.                         {
  131.                             float iDamage = iRadiusIDamage / fTargetDistance
  132.                             int iTotal = RoundToCeil(iDamageGrenadeLauncherI / (iDamage * iDamage))
  133.                             ForceDamageEntity(entity, iTotal, i)
  134.                         }
  135.                         if (fTargetDistance > iRadiusIFling)
  136.                         {
  137.                             Fly(entity, i, iPowerIFling)
  138.                         }
  139.                     }
  140.                 }
  141.                 else
  142.                 {
  143.                     if (fTargetDistance < iRadiusSdie)
  144.                     {
  145.                         ForcePlayerSuicide(i)
  146.                     }
  147.                     if (fTargetDistance < iRadiusSFling)
  148.                     {
  149.                         Fly(entity, i, iPowerSFling)
  150.                     }
  151.                     if (fTargetDistance < iRadiusSDamage)
  152.                     {
  153.                         float iDamage = iRadiusSDamage / fTargetDistance
  154.                         int iTotal = RoundToCeil(iDamageGrenadeLauncherS / (iDamage * iDamage))
  155.                         ForceDamageEntity(entity, iTotal, i)
  156.                     }
  157.                 }
  158.             }
  159.         }
  160.         else if(StrEqual(sCls, "pipe_bomb_projectile"))
  161.         {
  162.             for(int i = 1; i <= MaxClients; ++i)
  163.             {
  164.                 if(IsValidClient(i))
  165.                 {
  166.                     float vPos[3], vDamager[3];
  167.                     GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vDamager);
  168.                     GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
  169.                     float fTargetDistance = GetVectorDistance(vDamager, vPos);
  170.                    
  171.                     if(GetClientTeam(i) == 3)
  172.                     {
  173.                         int vClass = GetEntProp(i, Prop_Send, "m_zombieClass");
  174.                         if (vClass == 8)
  175.                         {
  176.                         //  if (!IsVisibleTo(vDamager, vPos)) return;
  177.                             if (fTargetDistance < iRadiusTDamagePipe)
  178.                             {
  179.                                 float iDamage = iRadiusTDamagePipe / fTargetDistance
  180.                                 int iTotal = RoundToCeil(iDamagePipeT / (iDamage * iDamage))
  181.                                 ForceDamageEntity(entity, iTotal, i)
  182.                             }
  183.                             if (fTargetDistance < iRadiusTFlingPipe)
  184.                             {
  185.                                 Fly(entity, i, iPowerTFlingPipe)
  186.                             }
  187.                         }
  188.                         else if (vClass == 6)
  189.                         {
  190.                         //  if (!IsVisibleTo(vDamager, vPos)) return;
  191.                             if (fTargetDistance < iRadiusCDamagePipe)
  192.                             {
  193.                                 float iDamage = iRadiusCDamagePipe / fTargetDistance
  194.                                 int iTotal = RoundToCeil(iDamagePipeC / (iDamage * iDamage))
  195.                                 ForceDamageEntity(entity, iTotal, i)
  196.                             }
  197.                             if (fTargetDistance < iRadiusCFlingPipe)
  198.                             {
  199.                                 Fly(entity, i, iPowerCFlingPipe)
  200.                             }
  201.                         }
  202.                         else
  203.                         {
  204.                         //  if (!IsVisibleTo(vDamager, vPos)) return;
  205.                             if (fTargetDistance < iRadiusIDamagePipe)
  206.                             {
  207.                                 int iOwn = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity");
  208.                                 float iDamage = iRadiusIDamagePipe / fTargetDistance
  209.                                 int iTotal = RoundToCeil(iDamagePipeI / (iDamage * iDamage))
  210.                                 ForceDamageEntity(iOwn, iTotal, i)
  211.                             }
  212.                             if (fTargetDistance < iRadiusIFlingPipe)
  213.                             {
  214.                                 Fly(entity, i, iPowerIFlingPipe)
  215.                             }
  216.                         }
  217.                     }
  218.                     else
  219.                     {
  220.                     //  if (!IsVisibleTo(vDamager, vPos)) return;
  221.                         if (fTargetDistance < iRadiusSdiePipe)
  222.                         {
  223.                             ForcePlayerSuicide(i)
  224.                         }
  225.                         if (fTargetDistance < iRadiusSFlingPipe)
  226.                         {
  227.                             Fly(entity, i, iPowerSFlingPipe)
  228.                         }
  229.                         if (fTargetDistance < iRadiusSDamagePipe)
  230.                         {
  231.                             int iOwn = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity");
  232.                             float iDamage = iRadiusSDamagePipe / fTargetDistance
  233.                             int iTotal = RoundToCeil(iDamagePipeS / (iDamage * iDamage))
  234.                             ForceDamageEntity(iOwn, iTotal, i)
  235.                         }
  236.                     }
  237.                 }
  238.             }
  239.         }
  240.     }
  241. }
  242.  
  243. /*
  244. static bool IsVisibleTo(float position[3], float targetposition[3])
  245. {
  246.     float vAngles[3], vLookAt[3];
  247.    
  248.     MakeVectorFromPoints(position, targetposition, vLookAt); // compute vector from start to target
  249.     GetVectorAngles(vLookAt, vAngles); // get angles from vector for trace
  250.    
  251.     // execute Trace
  252.     Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);
  253.    
  254.     bool isVisible = false;
  255.     if (TR_DidHit(trace))
  256.     {
  257.         float vStart[3];
  258.         TR_GetEndPosition(vStart, trace); // retrieve our trace endpoint
  259.        
  260.         if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
  261.         {
  262.             isVisible = true; // if trace ray length plus tolerance equal or bigger absolute distance, you hit the target
  263.         }
  264.     }
  265.    
  266.     return isVisible;
  267. }
  268.  
  269. public bool _TraceFilter(int entity, int contentsMask)
  270. {
  271.     if (!entity || entity <= MaxClients || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit
  272.     {
  273.         return false;
  274.     }
  275.     return true;
  276. }
  277. */
  278. public Fly(explosion, int target, float power)
  279. {
  280.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  return;
  281.    
  282.     float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
  283.    
  284.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);      
  285.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  286.    
  287.     power = power - GetVectorDistance(targetPos,explosionPos);
  288.    
  289.     if(power < 1)
  290.         return;
  291.    
  292.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  293.     GetVectorAngles(traceVec, resultingFling);
  294.        
  295.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  296.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  297.     resultingFling[2] = power + (power * 0.5);
  298.  
  299.     if (GetClientTeam(target) == 2)
  300.     {
  301.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
  302.     }
  303.     else
  304.     {
  305.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);
  306.     }
  307.  
  308. }
  309.  
  310. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  311. {
  312.     float victim_origin[3];
  313.     char rupture[32];
  314.     char damage_victim[32];
  315.     IntToString(damage, rupture, sizeof(rupture));
  316.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  317.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  318.     int entity = CreateEntityByName("point_hurt");
  319.     DispatchKeyValue(victim, "targetname", damage_victim);
  320.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  321.     DispatchKeyValue(entity, "Damage", rupture);
  322.     DispatchSpawn(entity);
  323.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  324.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  325.     DispatchKeyValue(entity, "classname", "point_hurt");
  326.     DispatchKeyValue(victim, "targetname", "null");
  327.     AcceptEntityInput(entity, "Kill");
  328. }
  329.  
  330. stock bool IsValidClient(int client)
  331. {
  332.     if ( client < 1 || client > MaxClients ) return false;
  333.     if( !IsClientInGame(client)) return false;
  334.     if ( !IsPlayerAlive( client )) return false;
  335.     return true;
  336. }
Add Comment
Please, Sign In to add comment