Advertisement
FlacoBey

Untitled

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