FlacoBey

Untitled

May 22nd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.01 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include sdkhooks
  4.  
  5. #pragma tabsize 0
  6.  
  7. float GrenadeDamage = 1000.0
  8. float PipeBombDamage = 1000.0
  9. float BarrelDamage = 1000.0
  10.  
  11. float GrenadeRadius = 500.0
  12. float PipeRadius = 500.0
  13. float BarrelRadius = 500.0
  14.  
  15. float RadiusStumbleGrenade = 500.0
  16. float RadiusStublePipe = 500.0
  17. float RadiusStumbleBarrel = 500.0
  18.  
  19. Handle sdkCallPushPlayer;
  20.  
  21. public OnPluginStart()
  22. {
  23.     Handle GameConf = LoadGameConfigFile("gamedata_stager");  
  24.            
  25.     if(GameConf == INVALID_HANDLE)
  26.     {
  27.         SetFailState("Couldn't find the offsets and signatures file. Please, check that it is installed correctly.");
  28.     }
  29.        
  30.     StartPrepSDKCall(SDKCall_Player);
  31.     PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");
  32.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  33.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
  34.     PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  35.     PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  36.     sdkCallPushPlayer = EndPrepSDKCall();
  37. }
  38.  
  39. bool IsAllow = false;
  40.  
  41. public OnMapStart()
  42. {
  43.     IsAllow = false;
  44.     CreateTimer(3.0, allow)
  45. }
  46.  
  47. public Action allow(Handle timer)
  48. {
  49.     IsAllow = true;
  50. }
  51.  
  52. public void OnEntityDestroyed(int entity)
  53. {
  54.     if(!IsAllow) return;
  55.    
  56.     if (IsValidEntity(entity) && IsValidEdict(entity))
  57.     {
  58.         char classname[128];
  59.         GetEdictClassname(entity, classname, 128);
  60.         if (StrEqual(classname, "grenade_launcher_projectile", false))
  61.         {
  62.             GrenadeTouch(entity);
  63.         }
  64.         if (StrEqual(classname, "pipe_bomb_projectile", false))
  65.         {
  66.             BombTouch(entity);
  67.         }
  68.         if (StrEqual(classname, "prop_fuel_barrel", false))
  69.         {
  70.             BarrelTouch(entity);
  71.         }
  72.     }
  73. }
  74.  
  75. public int GrenadeTouch(int entity)
  76. {
  77.     float pos[3];
  78.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  79.     GranadeExplode(pos);
  80. }
  81.  
  82. public int BombTouch(int entity)
  83. {
  84.     float pos[3];
  85.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  86.     BombExplode(pos)
  87. }
  88.  
  89. public int BarrelTouch(int entity)
  90. {
  91.     float pos[3];
  92.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  93.     BarrelExplode(pos);
  94. }
  95.  
  96. int GranadeExplode(float pos[3])
  97. {
  98.     float fDistance = 0.0;
  99.     float pos2[3];
  100.     for( int i = 0; i < 32; i++ )
  101.     {
  102.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  103.         {
  104.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  105.             if(vClass == 8)
  106.             {
  107.                 GetClientAbsOrigin(i, pos2);
  108.                 fDistance = GetVectorDistance(pos, pos2);
  109.                 if(fDistance < RadiusStumbleGrenade)
  110.                 {
  111.                     StaggerClient(i, pos)
  112.                 }
  113.                 if(fDistance < GrenadeRadius)
  114.                 {
  115.                     float iOne = GrenadeRadius - fDistance
  116.                     float vForward = GrenadeRadius / iOne
  117.                     int iDamage = RoundToCeil(GrenadeDamage / (vForward * vForward))
  118.                     ForceDamageEntity(i, iDamage, i)
  119.                 }
  120.             }
  121.         }
  122.     }
  123. }
  124.  
  125. int BombExplode(float pos[3])
  126. {
  127.     float fDistance = 0.0;
  128.     float pos2[3];
  129.     for( int i = 0; i < 32; i++ )
  130.     {
  131.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  132.         {
  133.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  134.             if(vClass == 8)
  135.             {
  136.                 GetClientAbsOrigin(i, pos2);
  137.                 fDistance = GetVectorDistance(pos, pos2);
  138.                 if(fDistance < RadiusStublePipe)
  139.                 {
  140.                     StaggerClient(i, pos)
  141.                 }
  142.                 if(fDistance < PipeRadius)
  143.                 {
  144.                     float iOne = PipeRadius - fDistance
  145.                     float vForward = PipeRadius / iOne
  146.                     int iDamage = RoundToCeil(PipeBombDamage / (vForward * vForward))
  147.                     ForceDamageEntity(i, iDamage, i)
  148.                 }
  149.                
  150.             }
  151.         }
  152.     }
  153. }
  154.  
  155. int BarrelExplode(float pos[3])
  156. {
  157.     float fDistance = 0.0;
  158.     float pos2[3];
  159.     for( int i = 0; i < 32; i++ )
  160.     {
  161.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  162.         {
  163.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  164.             if(vClass == 8)
  165.             {
  166.                 GetClientAbsOrigin(i, pos2);
  167.                 fDistance = GetVectorDistance(pos, pos2);
  168.                 if(fDistance < RadiusStumbleBarrel)
  169.                 {
  170.                     StaggerClient(i, pos)
  171.                 }
  172.                 if(fDistance < BarrelRadius)
  173.                 {
  174.                     float iOne = BarrelRadius - fDistance
  175.                     float vForward = BarrelRadius / iOne
  176.                     int iDamage = RoundToCeil(BarrelDamage / (vForward * vForward))
  177.                     ForceDamageEntity(i, iDamage, i)
  178.                 }
  179.             }
  180.         }
  181.     }
  182. }
  183.  
  184. public Fly(explosion, int target, float power)
  185. {
  186.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  return;
  187.    
  188.     float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
  189.    
  190.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);      
  191.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  192.    
  193.     if(power < 1)
  194.         return;
  195.    
  196.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  197.     GetVectorAngles(traceVec, resultingFling);
  198.        
  199.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  200.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  201.     resultingFling[2] = power + (power * 0.5);
  202.     if (GetClientTeam(target) == 2)
  203.     {
  204.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
  205.     }
  206.     else
  207.     {
  208.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);
  209.     }
  210. }
  211.  
  212. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  213. {
  214.     float victim_origin[3];
  215.     char rupture[32];
  216.     char damage_victim[32];
  217.     IntToString(damage, rupture, sizeof(rupture));
  218.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  219.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  220.     int entity = CreateEntityByName("point_hurt");
  221.     DispatchKeyValue(victim, "targetname", damage_victim);
  222.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  223.     DispatchKeyValue(entity, "Damage", rupture);
  224.     DispatchSpawn(entity);
  225.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  226.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  227.     DispatchKeyValue(entity, "classname", "point_hurt");
  228.     DispatchKeyValue(victim, "targetname", "null");
  229.     AcceptEntityInput(entity, "Kill");
  230. }
  231.  
  232. void StaggerClient(int iUserID, const float fPos[3])
  233. {
  234.     static int iScriptLogic = INVALID_ENT_REFERENCE;
  235.     if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  236.     {
  237.         iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
  238.         if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  239.             LogError("Could not create 'logic_script");
  240.  
  241.         DispatchSpawn(iScriptLogic);
  242.     }
  243.  
  244.     char sBuffer[96];
  245.     Format(sBuffer, sizeof(sBuffer), "GetPlayerFromUserID(%d).Stagger(Vector(%d,%d,%d))", iUserID, RoundFloat(fPos[0]), RoundFloat(fPos[1]), RoundFloat(fPos[2]));
  246.     SetVariantString(sBuffer);
  247.     AcceptEntityInput(iScriptLogic, "RunScriptCode");
  248.     AcceptEntityInput(iScriptLogic, "Kill");
  249. }
  250.  
  251. stock bool IsValidClient(int client)
  252. {
  253.     if ( client < 1 || client > MaxClients ) return false;
  254.     if( !IsClientInGame(client)) return false;
  255.     if ( !IsPlayerAlive( client )) return false;
  256.     return true;
  257. }
  258.  
  259. public void ScreenShake(int target, float power)
  260. {
  261.     Handle msg;
  262.     msg = StartMessageOne("Shake", target);
  263.     BfWriteByte(msg, 0);
  264.     BfWriteFloat(msg, power);
  265.     BfWriteFloat(msg, 10.0);
  266.     BfWriteFloat(msg, 3.0);
  267.     EndMessage();
  268. }
Advertisement
Add Comment
Please, Sign In to add comment