FlacoBey

Untitled

May 21st, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.55 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include sdkhooks
  4.  
  5. //Survivors
  6. float iDamageGrenadeLauncherS = 2000.0;
  7. float iPowerSFling = 600.0;
  8. float iRadiusSdie = 200.0
  9. float iRadiusSFling = 900.0
  10. float iRadiusSDamage = 400.0
  11.  
  12. //Survivors Pipe Bomb
  13. float iDamagePipeS = 600.0;
  14. float iPowerSFlingPipe = 550.0;
  15. float iRadiusSdiePipe = 200.0
  16. float iRadiusSFlingPipe = 700.0
  17. float iRadiusSDamagePipe = 900.0
  18.  
  19. //Barrel
  20. float iDamageB = 600.0;
  21. float iPowerBFling = 550.0;
  22. float iRadiusBdie = 200.0
  23. float iRadiusBFling = 700.0
  24. float iRadiusBDamage = 900.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.             for( int i = 0; i < 32; i++ )
  55.             {
  56.                 if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  57.                 {
  58.                     GrenadeTouch(entity, i);
  59.                 }
  60.             }
  61.         }
  62.         if (StrEqual(classname, "pipe_bomb_projectile", false))
  63.         {
  64.             for( int i = 0; i < 32; i++ )
  65.             {
  66.                 if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  67.                 {
  68.                     BombTouch(entity, i);
  69.                 }
  70.             }
  71.         }
  72.         if (StrEqual(classname, "prop_fuel_barrel", false))
  73.         {
  74.             for( int i = 0; i < 32; i++ )
  75.             {
  76.                 if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  77.                 {
  78.                     BarrelTouch(entity, i);
  79.                 }
  80.             }
  81.         }
  82.     }
  83. }
  84.  
  85. public int GrenadeTouch(int entity, int target)
  86. {
  87.     float pos[3];
  88.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  89.     GranadeExplode(entity, pos, iRadiusSDamage, iDamageGrenadeLauncherS);
  90. }
  91.  
  92. public int BombTouch(int entity, int target)
  93. {
  94.     float pos[3];
  95.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  96.     BombExplode(entity, pos, iRadiusSDamagePipe, iDamagePipeS)
  97. }
  98.  
  99. public int BarrelTouch(int entity, int target)
  100. {
  101.     float pos[3];
  102.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  103.     BarrelExplode(entity, pos, iRadiusBDamage, iDamageB);
  104. }
  105.  
  106. int GranadeExplode(int entity, float pos[3], float radius, float damage)
  107. {
  108.     int explosion = CreateEntityByName("env_explosion", -1);
  109.     DispatchKeyValue(explosion, "spawnflags", "64");
  110.     DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  111.     DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  112.     DispatchSpawn(explosion);
  113.     TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  114.     AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  115.     AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  116.    
  117.     float fDistance = 0.0;
  118.     float pos2[3];
  119.     for( int i = 0; i < 32; i++ )
  120.     {
  121.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  122.         {
  123.             GetClientAbsOrigin(i, pos2);
  124.             fDistance = GetVectorDistance(pos, pos2);
  125.             if(fDistance < iRadiusSFling)
  126.             {
  127.                 Fly(entity, i, iPowerSFling)
  128.             }
  129.             if(fDistance < iRadiusSdie)
  130.             {
  131.                 ForcePlayerSuicide(i)
  132.             }
  133.         }
  134.     }
  135. }
  136.  
  137. int BombExplode(int entity, float pos[3], float radius, float damage)
  138. {
  139.     int explosion = CreateEntityByName("env_explosion", -1);
  140.     DispatchKeyValue(explosion, "spawnflags", "1916");
  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 < iRadiusSFlingPipe)
  157.             {
  158.                 Fly(entity, i, iPowerSFlingPipe)
  159.             }
  160.             if(fDistance < iRadiusSdiePipe)
  161.             {
  162.                 ForcePlayerSuicide(i)
  163.             }
  164.         }
  165.     }
  166. }
  167.  
  168. int BarrelExplode(int entity, float pos[3], float radius, float damage)
  169. {
  170.     int explosion = CreateEntityByName("env_explosion", -1);
  171.     DispatchKeyValue(explosion, "spawnflags", "1916");
  172.     DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  173.     DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  174.     DispatchSpawn(explosion);
  175.     TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  176.     AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  177.     AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  178.    
  179.     float fDistance = 0.0;
  180.     float pos2[3];
  181.     for( int i = 0; i < 32; i++ )
  182.     {
  183.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  184.         {
  185.             GetClientAbsOrigin(i, pos2);
  186.             fDistance = GetVectorDistance(pos, pos2);
  187.             if(fDistance < iRadiusBFling)
  188.             {
  189.                 Fly(entity, i, iPowerBFling)
  190.             }
  191.             if(fDistance < iRadiusBdie)
  192.             {
  193.                 ForcePlayerSuicide(i)
  194.             }
  195.         }
  196.     }
  197. }
  198.  
  199. /*
  200. static bool IsVisibleTo(float position[3], float targetposition[3])
  201. {
  202.     float vAngles[3], vLookAt[3];
  203.    
  204.     MakeVectorFromPoints(position, targetposition, vLookAt); // compute vector from start to target
  205.     GetVectorAngles(vLookAt, vAngles); // get angles from vector for trace
  206.    
  207.     // execute Trace
  208.     Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);
  209.    
  210.     bool isVisible = false;
  211.     if (TR_DidHit(trace))
  212.     {
  213.         float vStart[3];
  214.         TR_GetEndPosition(vStart, trace); // retrieve our trace endpoint
  215.        
  216.         if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
  217.         {
  218.             isVisible = true; // if trace ray length plus tolerance equal or bigger absolute distance, you hit the target
  219.         }
  220.     }
  221.    
  222.     return isVisible;
  223. }
  224.  
  225. public bool _TraceFilter(int entity, int contentsMask)
  226. {
  227.     if (!entity || entity <= MaxClients || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit
  228.     {
  229.         return false;
  230.     }
  231.     return true;
  232. }
  233. */
  234. public Fly(explosion, int target, float power)
  235. {
  236.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  return;
  237.    
  238.     float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
  239.    
  240.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);      
  241.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  242.    
  243.     if(power < 1)
  244.         return;
  245.    
  246.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  247.     GetVectorAngles(traceVec, resultingFling);
  248.        
  249.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  250.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  251.     resultingFling[2] = power + (power * 0.5);
  252.  
  253.     if (GetClientTeam(target) == 2)
  254.     {
  255.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
  256.     }
  257.     else
  258.     {
  259.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);
  260.     }
  261.  
  262. }
  263.  
  264.  
  265.  
  266. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  267. {
  268.     float victim_origin[3];
  269.     char rupture[32];
  270.     char damage_victim[32];
  271.     IntToString(damage, rupture, sizeof(rupture));
  272.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  273.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  274.     int entity = CreateEntityByName("point_hurt");
  275.     DispatchKeyValue(victim, "targetname", damage_victim);
  276.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  277.     DispatchKeyValue(entity, "Damage", rupture);
  278.     DispatchSpawn(entity);
  279.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  280.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  281.     DispatchKeyValue(entity, "classname", "point_hurt");
  282.     DispatchKeyValue(victim, "targetname", "null");
  283.     AcceptEntityInput(entity, "Kill");
  284. }
  285.  
  286. stock bool IsValidClient(int client)
  287. {
  288.     if ( client < 1 || client > MaxClients ) return false;
  289.     if( !IsClientInGame(client)) return false;
  290.     if ( !IsPlayerAlive( client )) return false;
  291.     return true;
  292. }
Advertisement
Add Comment
Please, Sign In to add comment