FlacoBey

Untitled

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