Advertisement
FlacoBey

Untitled

May 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.64 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include sdkhooks
  4.  
  5. //Survivors
  6. float iDamageGrenadeLauncherS = 100.0;
  7. float iPowerSFling = 250.0;
  8. float iRadiusSdie = 1.0
  9. float iRadiusSFling = 250.0
  10. float iRadiusSDamage = 500.0
  11.  
  12. //Survivors Pipe Bomb
  13. float iDamagePipeS = 100.0;
  14. float iPowerSFlingPipe = 250.0;
  15. float iRadiusSdiePipe = 1.0
  16. float iRadiusSFlingPipe = 250.0
  17. float iRadiusSDamagePipe = 500.0
  18.  
  19. //Barrel
  20. float iDamageB = 100.0;
  21. float iPowerBFling = 250.0;
  22. float iRadiusBdie = 1.0
  23. float iRadiusBFling = 250.0
  24. float iRadiusBDamage = 500.0
  25.  
  26. Handle sdkCallPushPlayer;
  27.  
  28. public OnPluginStart()
  29. {
  30.     Handle GameConf = LoadGameConfigFile("gamedata_stager");  
  31.            
  32.     if(GameConf == INVALID_HANDLE)
  33.     {
  34.         SetFailState("Couldn't find the offsets and signatures file. Please, check that it is installed correctly.");
  35.     }
  36.        
  37.     StartPrepSDKCall(SDKCall_Player);
  38.     PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");
  39.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  40.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
  41.     PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  42.     PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  43.     sdkCallPushPlayer = EndPrepSDKCall();
  44. }
  45.  
  46. public void OnEntityDestroyed(int entity)
  47. {
  48.     if (IsValidEntity(entity) && IsValidEdict(entity))
  49.     {
  50.         char classname[128];
  51.         GetEdictClassname(entity, classname, 128);
  52.         if (StrEqual(classname, "grenade_launcher_projectile", false))
  53.         {
  54.             GrenadeTouch(entity);
  55.         }
  56.         if (StrEqual(classname, "pipe_bomb_projectile", false))
  57.         {
  58.             BombTouch(entity);
  59.         }
  60.         if (StrEqual(classname, "prop_fuel_barrel", false))
  61.         {
  62.             BarrelTouch(entity);
  63.         }
  64.     }
  65. }
  66.  
  67. public int GrenadeTouch(int entity)
  68. {
  69.     float pos[3];
  70.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  71.     GranadeExplode(entity, pos);
  72. }
  73.  
  74. public int BombTouch(int entity)
  75. {
  76.     float pos[3];
  77.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  78.     BombExplode(entity, pos)
  79. }
  80.  
  81. public int BarrelTouch(int entity)
  82. {
  83.     float pos[3];
  84.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  85.     BarrelExplode(entity, pos);
  86. }
  87.  
  88. int GranadeExplode(int entity, float pos[3])
  89. {
  90.     float fDistance = 0.0;
  91.     float pos2[3];
  92.     for( int i = 0; i < 32; i++ )
  93.     {
  94.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  95.         {
  96.             GetClientAbsOrigin(i, pos2);
  97.             fDistance = GetVectorDistance(pos, pos2);
  98.             if(fDistance < iRadiusSFling)
  99.             {
  100.                 Fly(entity, i, iPowerSFling)
  101.             }
  102.             if(fDistance < iRadiusSdie)
  103.             {
  104.                 ForcePlayerSuicide(i)
  105.             }
  106.             if(fDistance < iRadiusSDamage)
  107.             {
  108.                 int iDamage = RoundToCeil(iDamageGrenadeLauncherS - fDistance)
  109.                 ForceDamageEntity(entity, iDamage, i)
  110.             }
  111.         }
  112.     }
  113. }
  114.  
  115. int BombExplode(int entity, float pos[3])
  116. {
  117.    
  118.     float fDistance = 0.0;
  119.     float pos2[3];
  120.     for( int i = 0; i < 32; i++ )
  121.     {
  122.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  123.         {
  124.             GetClientAbsOrigin(i, pos2);
  125.             fDistance = GetVectorDistance(pos, pos2);
  126.             if(fDistance < iRadiusSFlingPipe)
  127.             {
  128.                 Fly(entity, i, iPowerSFlingPipe)
  129.             }
  130.             if(fDistance < iRadiusSdiePipe)
  131.             {
  132.                 ForcePlayerSuicide(i)
  133.             }
  134.             if(fDistance < iRadiusSDamagePipe)
  135.             {
  136.                 int iDamage = RoundToCeil(iDamagePipeS - fDistance)
  137.                 ForceDamageEntity(entity, iDamage, i)
  138.             }
  139.         }
  140.     }
  141. }
  142.  
  143. int BarrelExplode(int entity, float pos[3])
  144. {
  145.     float fDistance = 0.0;
  146.     float pos2[3];
  147.     for( int i = 0; i < 32; i++ )
  148.     {
  149.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  150.         {
  151.             GetClientAbsOrigin(i, pos2);
  152.             fDistance = GetVectorDistance(pos, pos2);
  153.             if(fDistance < iRadiusBFling)
  154.             {
  155.                 Fly(entity, i, iPowerBFling)
  156.             }
  157.             if(fDistance < iRadiusBdie)
  158.             {
  159.                 ForcePlayerSuicide(i)
  160.             }
  161.             if(fDistance < iRadiusBDamage)
  162.             {
  163.                 int iDamage = RoundToCeil(iDamageB - fDistance)
  164.                 ForceDamageEntity(entity, iDamage, i)
  165.             }
  166.         }
  167.     }
  168. }
  169.  
  170. public Fly(explosion, int target, float power)
  171. {
  172.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  return;
  173.    
  174.     float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
  175.    
  176.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);      
  177.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  178.    
  179.     if(power < 1)
  180.         return;
  181.    
  182.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  183.     GetVectorAngles(traceVec, resultingFling);
  184.        
  185.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  186.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  187.     resultingFling[2] = power + (power * 0.5);
  188.  
  189.     if (GetClientTeam(target) == 2)
  190.     {
  191.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
  192.     }
  193.     else
  194.     {
  195.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);
  196.     }
  197.  
  198. }
  199.  
  200. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  201. {
  202.     float victim_origin[3];
  203.     char rupture[32];
  204.     char damage_victim[32];
  205.     IntToString(damage, rupture, sizeof(rupture));
  206.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  207.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  208.     int entity = CreateEntityByName("point_hurt");
  209.     DispatchKeyValue(victim, "targetname", damage_victim);
  210.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  211.     DispatchKeyValue(entity, "Damage", rupture);
  212.     DispatchSpawn(entity);
  213.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  214.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  215.     DispatchKeyValue(entity, "classname", "point_hurt");
  216.     DispatchKeyValue(victim, "targetname", "null");
  217.     AcceptEntityInput(entity, "Kill");
  218. }
  219.  
  220. stock bool IsValidClient(int client)
  221. {
  222.     if ( client < 1 || client > MaxClients ) return false;
  223.     if( !IsClientInGame(client)) return false;
  224.     if ( !IsPlayerAlive( client )) return false;
  225.     return true;
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement