Advertisement
FlacoBey

Untitled

May 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.14 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. bool IsAllow = false;
  82.  
  83. public OnMapStart()
  84. {
  85.     CreateTimer(3.0, allow)
  86. }
  87.  
  88. public Action allow(Handle timer)
  89. {
  90.     IsAllow = true;
  91. }
  92.  
  93. public void OnEntityDestroyed(int entity)
  94. {
  95.     if(!IsAllow) return;
  96.    
  97.     if (IsValidEntity(entity) && IsValidEdict(entity))
  98.     {
  99.         char classname[128];
  100.         GetEdictClassname(entity, classname, 128);
  101.         if (StrEqual(classname, "grenade_launcher_projectile", false))
  102.         {
  103.             GrenadeTouch(entity);
  104.         }
  105.         if (StrEqual(classname, "pipe_bomb_projectile", false))
  106.         {
  107.             BombTouch(entity);
  108.         }
  109.         if (StrEqual(classname, "prop_fuel_barrel", false))
  110.         {
  111.             BarrelTouch(entity);
  112.         }
  113.     }
  114. }
  115.  
  116. public int GrenadeTouch(int entity)
  117. {
  118.     float pos[3];
  119.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  120.     GranadeExplode(entity, pos, iRadiusSDamage, iDamageGrenadeLauncherS);
  121. }
  122.  
  123. public int BombTouch(int entity)
  124. {
  125.     float pos[3];
  126.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  127.     BombExplode(entity, pos, iRadiusSDamagePipe, iDamagePipeS)
  128. }
  129.  
  130. public int BarrelTouch(int entity)
  131. {
  132.     float pos[3];
  133.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  134.     BarrelExplode(entity, pos, iRadiusBDamage, iDamageB);
  135. }
  136.  
  137. int GranadeExplode(int entity, float pos[3], float radius, float damage)
  138. {
  139.     int explosion = CreateEntityByName("env_explosion", -1);
  140.     DispatchKeyValue(explosion, "spawnflags", "64");
  141.     DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  142.     DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  143.     DispatchSpawn(explosion);
  144.     TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  145.     AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  146.     AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  147.    
  148.     float fDistance = 0.0;
  149.     float pos2[3];
  150.     for( int i = 0; i < 32; i++ )
  151.     {
  152.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  153.         {
  154.             GetClientAbsOrigin(i, pos2);
  155.             fDistance = GetVectorDistance(pos, pos2);
  156.             if(fDistance < iRadiusSFling)
  157.             {
  158.                 Fly(entity, i, iPowerSFling)
  159.             }
  160.             if(fDistance < iRadiusSdie)
  161.             {
  162.                 ForcePlayerSuicide(i)
  163.             }
  164.             if(fDistance < iRadiusShake)
  165.             {
  166.                 float vPowerShake = iPowerShake - iRadiusShake;
  167.                 if(iPowerShake > 0)
  168.                 {
  169.                     ScreenShake(i, vPowerShake)
  170.                 }
  171.             }
  172.         }
  173.         if(GetClientTeam(i) == 3 && IsValidClient(i))
  174.         {
  175.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  176.             if(vClass == 6)
  177.             {
  178.                 GetClientAbsOrigin(i, pos2);
  179.                 fDistance = GetVectorDistance(pos, pos2);
  180.                 if(fDistance < iRadiusCFling)
  181.                 {
  182.                     StaggerClient(i, pos)
  183.                 }
  184.             }
  185.             else if(vClass == 8)
  186.             {
  187.                 GetClientAbsOrigin(i, pos2);
  188.                 fDistance = GetVectorDistance(pos, pos2);
  189.                 if(fDistance < iRadiusTFling)
  190.                 {
  191.                     StaggerClient(i, pos)
  192.                 }
  193.             }
  194.             else
  195.             {
  196.                 GetClientAbsOrigin(i, pos2);
  197.                 fDistance = GetVectorDistance(pos, pos2);
  198.                 if(fDistance < iRadiusIFling)
  199.                 {
  200.                     StaggerClient(i, pos)
  201.                 }
  202.             }
  203.         }
  204.     }
  205. }
  206.  
  207. int BombExplode(int entity, float pos[3], float radius, float damage)
  208. {
  209.     int explosion = CreateEntityByName("env_explosion", -1);
  210.     DispatchKeyValue(explosion, "spawnflags", "1916");
  211.     DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  212.     DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  213.     DispatchSpawn(explosion);
  214.     TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  215.     AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  216.     AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  217.    
  218.     float fDistance = 0.0;
  219.     float pos2[3];
  220.     for( int i = 0; i < 32; i++ )
  221.     {
  222.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  223.         {
  224.             GetClientAbsOrigin(i, pos2);
  225.             fDistance = GetVectorDistance(pos, pos2);
  226.             if(fDistance < iRadiusSFlingPipe)
  227.             {
  228.                 Fly(entity, i, iPowerSFlingPipe)
  229.             }
  230.             if(fDistance < iRadiusSdiePipe)
  231.             {
  232.                 ForcePlayerSuicide(i)
  233.             }
  234.             if(fDistance < iRadiusShakePipe)
  235.             {
  236.                 float vPowerShake = iPowerShakePipe - iRadiusShakePipe;
  237.                 if(iPowerShake > 0)
  238.                 {
  239.                     ScreenShake(i, vPowerShake)
  240.                 }
  241.             }
  242.         }
  243.         if(GetClientTeam(i) == 3 && IsValidClient(i))
  244.         {
  245.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  246.             if(vClass == 6)
  247.             {
  248.                 GetClientAbsOrigin(i, pos2);
  249.                 fDistance = GetVectorDistance(pos, pos2);
  250.                 if(fDistance < iRadiusCFlingPipe)
  251.                 {
  252.                     StaggerClient(i, pos)
  253.                 }
  254.             }
  255.             else if(vClass == 8)
  256.             {
  257.                 GetClientAbsOrigin(i, pos2);
  258.                 fDistance = GetVectorDistance(pos, pos2);
  259.                 if(fDistance < iRadiusTFlingPipe)
  260.                 {
  261.                     StaggerClient(i, pos)
  262.                 }
  263.             }
  264.             else
  265.             {
  266.                 GetClientAbsOrigin(i, pos2);
  267.                 fDistance = GetVectorDistance(pos, pos2);
  268.                 if(fDistance < iRadiusIFlingPipe)
  269.                 {
  270.                     StaggerClient(i, pos)
  271.                 }
  272.             }
  273.         }
  274.     }
  275. }
  276.  
  277. int BarrelExplode(int entity, float pos[3], float radius, float damage)
  278. {
  279.     int explosion = CreateEntityByName("env_explosion", -1);
  280.     DispatchKeyValue(explosion, "spawnflags", "1916");
  281.     DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  282.     DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  283.     DispatchSpawn(explosion);
  284.     TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  285.     AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  286.     AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  287.    
  288.     float fDistance = 0.0;
  289.     float pos2[3];
  290.     for( int i = 0; i < 32; i++ )
  291.     {
  292.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  293.         {
  294.             GetClientAbsOrigin(i, pos2);
  295.             fDistance = GetVectorDistance(pos, pos2);
  296.             if(fDistance < iRadiusBFling)
  297.             {
  298.                 Fly(entity, i, iPowerBFling)
  299.             }
  300.             if(fDistance < iRadiusBdie)
  301.             {
  302.                 ForcePlayerSuicide(i)
  303.             }
  304.             if(fDistance < iRadiusShakeB)
  305.             {
  306.                 float vPowerShake = iPowerShakeB - iRadiusShakeB;
  307.                 if(iPowerShake > 0)
  308.                 {
  309.                     ScreenShake(i, vPowerShake)
  310.                 }
  311.             }
  312.         }
  313.         if(GetClientTeam(i) == 3 && IsValidClient(i))
  314.         {
  315.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  316.             if(vClass == 6)
  317.             {
  318.                 GetClientAbsOrigin(i, pos2);
  319.                 fDistance = GetVectorDistance(pos, pos2);
  320.                 if(fDistance < iRadiusBCFling)
  321.                 {
  322.                     StaggerClient(i, pos)
  323.                 }
  324.             }
  325.             else if(vClass == 8)
  326.             {
  327.                 GetClientAbsOrigin(i, pos2);
  328.                 fDistance = GetVectorDistance(pos, pos2);
  329.                 if(fDistance < iRadiusBTFling)
  330.                 {
  331.                     StaggerClient(i, pos)
  332.                 }
  333.             }
  334.             else
  335.             {
  336.                 GetClientAbsOrigin(i, pos2);
  337.                 fDistance = GetVectorDistance(pos, pos2);
  338.                 if(fDistance < iRadiusBIFling)
  339.                 {
  340.                     StaggerClient(i, pos)
  341.                 }
  342.             }
  343.         }
  344.     }
  345. }
  346.  
  347. public Fly(explosion, int target, float power)
  348. {
  349.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  return;
  350.    
  351.     float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
  352.    
  353.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);      
  354.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  355.    
  356.     if(power < 1)
  357.         return;
  358.    
  359.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  360.     GetVectorAngles(traceVec, resultingFling);
  361.        
  362.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  363.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  364.     resultingFling[2] = power + (power * 0.5);
  365.     if (GetClientTeam(target) == 2)
  366.     {
  367.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
  368.     }
  369.     else
  370.     {
  371.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);
  372.     }
  373. }
  374.  
  375. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  376. {
  377.     float victim_origin[3];
  378.     char rupture[32];
  379.     char damage_victim[32];
  380.     IntToString(damage, rupture, sizeof(rupture));
  381.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  382.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  383.     int entity = CreateEntityByName("point_hurt");
  384.     DispatchKeyValue(victim, "targetname", damage_victim);
  385.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  386.     DispatchKeyValue(entity, "Damage", rupture);
  387.     DispatchSpawn(entity);
  388.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  389.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  390.     DispatchKeyValue(entity, "classname", "point_hurt");
  391.     DispatchKeyValue(victim, "targetname", "null");
  392.     AcceptEntityInput(entity, "Kill");
  393. }
  394.  
  395. void StaggerClient(int iUserID, const float fPos[3])
  396. {
  397.     static int iScriptLogic = INVALID_ENT_REFERENCE;
  398.     if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  399.     {
  400.         iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
  401.         if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  402.             LogError("Could not create 'logic_script");
  403.  
  404.         DispatchSpawn(iScriptLogic);
  405.     }
  406.  
  407.     char sBuffer[96];
  408.     Format(sBuffer, sizeof(sBuffer), "GetPlayerFromUserID(%d).Stagger(Vector(%d,%d,%d))", iUserID, RoundFloat(fPos[0]), RoundFloat(fPos[1]), RoundFloat(fPos[2]));
  409.     SetVariantString(sBuffer);
  410.     AcceptEntityInput(iScriptLogic, "RunScriptCode");
  411.     AcceptEntityInput(iScriptLogic, "Kill");
  412. }
  413.  
  414. stock bool IsValidClient(int client)
  415. {
  416.     if ( client < 1 || client > MaxClients ) return false;
  417.     if( !IsClientInGame(client)) return false;
  418.     if ( !IsPlayerAlive( client )) return false;
  419.     return true;
  420. }
  421.  
  422. public void ScreenShake(int target, float power)
  423. {
  424.     Handle msg;
  425.     msg = StartMessageOne("Shake", target);
  426.     BfWriteByte(msg, 0);
  427.     BfWriteFloat(msg, power);
  428.     BfWriteFloat(msg, 10.0);
  429.     BfWriteFloat(msg, 3.0);
  430.     EndMessage();
  431. }
  432.  
  433. public void ScreenFade(int target, int red, int green, int blue, int alpha, int duration, int type)
  434. {
  435.     Handle msg = StartMessageOne("Fade", target);
  436.     BfWriteShort(msg, 500);
  437.     BfWriteShort(msg, duration);
  438.     if (type == 0)
  439.     {
  440.         BfWriteShort(msg, (0x0002 | 0x0008));
  441.     }
  442.     else
  443.     {
  444.         BfWriteShort(msg, (0x0001 | 0x0010));
  445.     }
  446.     BfWriteByte(msg, red);
  447.     BfWriteByte(msg, green);
  448.     BfWriteByte(msg, blue);
  449.     BfWriteByte(msg, alpha);
  450.     EndMessage();
  451. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement