FlacoBey

Untitled

May 22nd, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.98 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include sdkhooks
  4.  
  5. #pragma tabsize 0
  6.  
  7. //Survivors
  8. float iDamageGrenadeLauncherS = 2000.0;
  9. float iPowerSFling = 600.0;
  10. float iRadiusSdie = 200.0
  11. float iRadiusSFling = 900.0
  12. float iRadiusSDamage = 400.0
  13. float iPowerShake = 600.0
  14. float iRadiusShake = 900.0
  15.  
  16. //Survivors Pipe Bomb
  17. float iDamagePipeS = 600.0;
  18. float iPowerSFlingPipe = 550.0;
  19. float iRadiusSdiePipe = 200.0
  20. float iRadiusSFlingPipe = 700.0
  21. float iRadiusSDamagePipe = 900.0
  22. float iPowerShakePipe = 600.0
  23. float iRadiusShakePipe = 900.0
  24.  
  25. //Barrel
  26. float iDamageB = 600.0;
  27. float iPowerBFling = 550.0;
  28. float iRadiusBdie = 200.0
  29. float iRadiusBFling = 700.0
  30. float iRadiusBDamage = 900.0
  31. float iPowerShakeB = 600.0
  32. float iRadiusShakeB = 900.0
  33.  
  34. //Tank
  35. float iRadiusTFling = 700.0
  36.  
  37. //Tank Pipe
  38. float iRadiusTFlingPipe = 700.0
  39.  
  40. //BarrelT
  41. float iRadiusBTFling = 700.0
  42.  
  43. //Charger
  44. float iRadiusCFling = 300.0
  45.  
  46. //Charger Pipe
  47. float iRadiusCFlingPipe = 300.0
  48.  
  49. //BarrelC
  50. float iRadiusBCFling = 700.0
  51.  
  52. //Other Inf
  53. float iRadiusIFling = 400.0
  54.  
  55. //Other Inf Pipe
  56. float iRadiusIFlingPipe = 400.0
  57.  
  58. //BarrelI
  59. float iRadiusBIFling = 700.0
  60.  
  61. Handle sdkCallPushPlayer;
  62.  
  63. public OnPluginStart()
  64. {
  65.     Handle GameConf = LoadGameConfigFile("gamedata_stager");  
  66.            
  67.     if(GameConf == INVALID_HANDLE)
  68.     {
  69.         SetFailState("Couldn't find the offsets and signatures file. Please, check that it is installed correctly.");
  70.     }
  71.        
  72.     StartPrepSDKCall(SDKCall_Player);
  73.     PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");
  74.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  75.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
  76.     PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  77.     PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  78.     sdkCallPushPlayer = EndPrepSDKCall();
  79. }
  80.  
  81. public void OnEntityDestroyed(int entity)
  82. {
  83.     if (IsValidEntity(entity) && IsValidEdict(entity))
  84.     {
  85.         char classname[128];
  86.         GetEdictClassname(entity, classname, 128);
  87.         if (StrEqual(classname, "grenade_launcher_projectile", false))
  88.         {
  89.             GrenadeTouch(entity);
  90.         }
  91.         if (StrEqual(classname, "pipe_bomb_projectile", false))
  92.         {
  93.             BombTouch(entity);
  94.         }
  95.         if (StrEqual(classname, "prop_fuel_barrel", false))
  96.         {
  97.             BarrelTouch(entity);
  98.         }
  99.     }
  100. }
  101.  
  102. public int GrenadeTouch(int entity)
  103. {
  104.     float pos[3];
  105.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  106.     GranadeExplode(entity, pos, iRadiusSDamage, iDamageGrenadeLauncherS);
  107. }
  108.  
  109. public int BombTouch(int entity)
  110. {
  111.     float pos[3];
  112.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  113.     BombExplode(entity, pos, iRadiusSDamagePipe, iDamagePipeS)
  114. }
  115.  
  116. public int BarrelTouch(int entity)
  117. {
  118.     float pos[3];
  119.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  120.     BarrelExplode(entity, pos, iRadiusBDamage, iDamageB);
  121. }
  122.  
  123. int GranadeExplode(int entity, float pos[3], float radius, float damage)
  124. {
  125.     int explosion = CreateEntityByName("env_explosion", -1);
  126.     DispatchKeyValue(explosion, "spawnflags", "64");
  127.     DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  128.     DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  129.     DispatchSpawn(explosion);
  130.     TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  131.     AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  132.     AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  133.    
  134.     float fDistance = 0.0;
  135.     float pos2[3];
  136.     for( int i = 0; i < 32; i++ )
  137.     {
  138.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  139.         {
  140.             GetClientAbsOrigin(i, pos2);
  141.             fDistance = GetVectorDistance(pos, pos2);
  142.             if(fDistance < iRadiusSFling)
  143.             {
  144.                 Fly(entity, i, iPowerSFling)
  145.             }
  146.             if(fDistance < iRadiusSdie)
  147.             {
  148.                 ForcePlayerSuicide(i)
  149.             }
  150.             if(fDistance < iRadiusShake)
  151.             {
  152.                 float vPowerShake = iPowerShake - iRadiusShake;
  153.                 if(iPowerShake > 0)
  154.                 {
  155.                     ScreenShake(i, vPowerShake)
  156.                 }
  157.             }
  158.         }
  159.         if(GetClientTeam(i) == 3 && IsValidClient(i))
  160.         {
  161.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  162.             if(vClass == 6)
  163.             {
  164.                 GetClientAbsOrigin(i, pos2);
  165.                 fDistance = GetVectorDistance(pos, pos2);
  166.                 if(fDistance < iRadiusCFling)
  167.                 {
  168.                     StaggerClient(i, pos)
  169.                 }
  170.             }
  171.             else if(vClass == 8)
  172.             {
  173.                 GetClientAbsOrigin(i, pos2);
  174.                 fDistance = GetVectorDistance(pos, pos2);
  175.                 if(fDistance < iRadiusTFling)
  176.                 {
  177.                     StaggerClient(i, pos)
  178.                 }
  179.             }
  180.             else
  181.             {
  182.                 GetClientAbsOrigin(i, pos2);
  183.                 fDistance = GetVectorDistance(pos, pos2);
  184.                 if(fDistance < iRadiusIFling)
  185.                 {
  186.                     StaggerClient(i, pos)
  187.                 }
  188.             }
  189.         }
  190.     }
  191. }
  192.  
  193. int BombExplode(int entity, float pos[3], float radius, float damage)
  194. {
  195.     int explosion = CreateEntityByName("env_explosion", -1);
  196.     DispatchKeyValue(explosion, "spawnflags", "1916");
  197.     DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  198.     DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  199.     DispatchSpawn(explosion);
  200.     TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  201.     AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  202.     AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  203.    
  204.     float fDistance = 0.0;
  205.     float pos2[3];
  206.     for( int i = 0; i < 32; i++ )
  207.     {
  208.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  209.         {
  210.             GetClientAbsOrigin(i, pos2);
  211.             fDistance = GetVectorDistance(pos, pos2);
  212.             if(fDistance < iRadiusSFlingPipe)
  213.             {
  214.                 Fly(entity, i, iPowerSFlingPipe)
  215.             }
  216.             if(fDistance < iRadiusSdiePipe)
  217.             {
  218.                 ForcePlayerSuicide(i)
  219.             }
  220.             if(fDistance < iRadiusShakePipe)
  221.             {
  222.                 float vPowerShake = iPowerShakePipe - iRadiusShakePipe;
  223.                 if(iPowerShake > 0)
  224.                 {
  225.                     ScreenShake(i, vPowerShake)
  226.                 }
  227.             }
  228.         }
  229.         if(GetClientTeam(i) == 3 && IsValidClient(i))
  230.         {
  231.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  232.             if(vClass == 6)
  233.             {
  234.                 GetClientAbsOrigin(i, pos2);
  235.                 fDistance = GetVectorDistance(pos, pos2);
  236.                 if(fDistance < iRadiusCFlingPipe)
  237.                 {
  238.                     StaggerClient(i, pos)
  239.                 }
  240.             }
  241.             else if(vClass == 8)
  242.             {
  243.                 GetClientAbsOrigin(i, pos2);
  244.                 fDistance = GetVectorDistance(pos, pos2);
  245.                 if(fDistance < iRadiusTFlingPipe)
  246.                 {
  247.                     StaggerClient(i, pos)
  248.                 }
  249.             }
  250.             else
  251.             {
  252.                 GetClientAbsOrigin(i, pos2);
  253.                 fDistance = GetVectorDistance(pos, pos2);
  254.                 if(fDistance < iRadiusIFlingPipe)
  255.                 {
  256.                     StaggerClient(i, pos)
  257.                 }
  258.             }
  259.         }
  260.     }
  261. }
  262.  
  263. int BarrelExplode(int entity, float pos[3], float radius, float damage)
  264. {
  265.     int explosion = CreateEntityByName("env_explosion", -1);
  266.     DispatchKeyValue(explosion, "spawnflags", "1916");
  267.     DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  268.     DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  269.     DispatchSpawn(explosion);
  270.     TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  271.     AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  272.     AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  273.    
  274.     float fDistance = 0.0;
  275.     float pos2[3];
  276.     for( int i = 0; i < 32; i++ )
  277.     {
  278.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  279.         {
  280.             GetClientAbsOrigin(i, pos2);
  281.             fDistance = GetVectorDistance(pos, pos2);
  282.             if(fDistance < iRadiusBFling)
  283.             {
  284.                 Fly(entity, i, iPowerBFling)
  285.             }
  286.             if(fDistance < iRadiusBdie)
  287.             {
  288.                 ForcePlayerSuicide(i)
  289.             }
  290.             if(fDistance < iRadiusShakeB)
  291.             {
  292.                 float vPowerShake = iPowerShakeB - iRadiusShakeB;
  293.                 if(iPowerShake > 0)
  294.                 {
  295.                     ScreenShake(i, vPowerShake)
  296.                 }
  297.             }
  298.         }
  299.         if(GetClientTeam(i) == 3 && IsValidClient(i))
  300.         {
  301.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  302.             if(vClass == 6)
  303.             {
  304.                 GetClientAbsOrigin(i, pos2);
  305.                 fDistance = GetVectorDistance(pos, pos2);
  306.                 if(fDistance < iRadiusBCFling)
  307.                 {
  308.                     StaggerClient(i, pos)
  309.                 }
  310.             }
  311.             else if(vClass == 8)
  312.             {
  313.                 GetClientAbsOrigin(i, pos2);
  314.                 fDistance = GetVectorDistance(pos, pos2);
  315.                 if(fDistance < iRadiusBTFling)
  316.                 {
  317.                     StaggerClient(i, pos)
  318.                 }
  319.             }
  320.             else
  321.             {
  322.                 GetClientAbsOrigin(i, pos2);
  323.                 fDistance = GetVectorDistance(pos, pos2);
  324.                 if(fDistance < iRadiusBIFling)
  325.                 {
  326.                     StaggerClient(i, pos)
  327.                 }
  328.             }
  329.         }
  330.     }
  331. }
  332.  
  333. public Fly(explosion, int target, float power)
  334. {
  335.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  return;
  336.    
  337.     float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
  338.    
  339.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);      
  340.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  341.    
  342.     if(power < 1)
  343.         return;
  344.    
  345.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  346.     GetVectorAngles(traceVec, resultingFling);
  347.        
  348.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  349.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  350.     resultingFling[2] = power + (power * 0.5);
  351.     if (GetClientTeam(target) == 2)
  352.     {
  353.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
  354.     }
  355.     else
  356.     {
  357.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);
  358.     }
  359. }
  360.  
  361. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  362. {
  363.     float victim_origin[3];
  364.     char rupture[32];
  365.     char damage_victim[32];
  366.     IntToString(damage, rupture, sizeof(rupture));
  367.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  368.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  369.     int entity = CreateEntityByName("point_hurt");
  370.     DispatchKeyValue(victim, "targetname", damage_victim);
  371.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  372.     DispatchKeyValue(entity, "Damage", rupture);
  373.     DispatchSpawn(entity);
  374.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  375.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  376.     DispatchKeyValue(entity, "classname", "point_hurt");
  377.     DispatchKeyValue(victim, "targetname", "null");
  378.     AcceptEntityInput(entity, "Kill");
  379. }
  380.  
  381. void StaggerClient(int iUserID, const float fPos[3])
  382. {
  383.     static int iScriptLogic = INVALID_ENT_REFERENCE;
  384.     if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  385.     {
  386.         iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
  387.         if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  388.             LogError("Could not create 'logic_script");
  389.  
  390.         DispatchSpawn(iScriptLogic);
  391.     }
  392.  
  393.     char sBuffer[96];
  394.     Format(sBuffer, sizeof(sBuffer), "GetPlayerFromUserID(%d).Stagger(Vector(%d,%d,%d))", iUserID, RoundFloat(fPos[0]), RoundFloat(fPos[1]), RoundFloat(fPos[2]));
  395.     SetVariantString(sBuffer);
  396.     AcceptEntityInput(iScriptLogic, "RunScriptCode");
  397.     AcceptEntityInput(iScriptLogic, "Kill");
  398. }
  399.  
  400. stock bool IsValidClient(int client)
  401. {
  402.     if ( client < 1 || client > MaxClients ) return false;
  403.     if( !IsClientInGame(client)) return false;
  404.     if ( !IsPlayerAlive( client )) return false;
  405.     return true;
  406. }
  407.  
  408. public void ScreenShake(int target, float power)
  409. {
  410.     Handle msg;
  411.     msg = StartMessageOne("Shake", target);
  412.     BfWriteByte(msg, 0);
  413.     BfWriteFloat(msg, power);
  414.     BfWriteFloat(msg, 10.0);
  415.     BfWriteFloat(msg, 3.0);
  416.     EndMessage();
  417. }
  418.  
  419. public void ScreenFade(int target, int red, int green, int blue, int alpha, int duration, int type)
  420. {
  421.     Handle msg = StartMessageOne("Fade", target);
  422.     BfWriteShort(msg, 500);
  423.     BfWriteShort(msg, duration);
  424.     if (type == 0)
  425.     {
  426.         BfWriteShort(msg, (0x0002 | 0x0008));
  427.     }
  428.     else
  429.     {
  430.         BfWriteShort(msg, (0x0001 | 0x0010));
  431.     }
  432.     BfWriteByte(msg, red);
  433.     BfWriteByte(msg, green);
  434.     BfWriteByte(msg, blue);
  435.     BfWriteByte(msg, alpha);
  436.     EndMessage();
  437. }
Advertisement
Add Comment
Please, Sign In to add comment