FlacoBey

Untitled

May 21st, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.11 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.             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, iRadiusSDamage, iDamageGrenadeLauncherS);
  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, iRadiusSDamagePipe, iDamagePipeS)
  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, iRadiusBDamage, iDamageB);
  86. }
  87.  
  88. int GranadeExplode(int entity, float pos[3], float radius, float damage)
  89. {
  90.     int explosion = CreateEntityByName("env_explosion", -1);
  91.     DispatchKeyValue(explosion, "spawnflags", "64");
  92.     DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  93.     DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  94.     DispatchSpawn(explosion);
  95.     TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  96.     AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  97.     AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  98.    
  99.     float fDistance = 0.0;
  100.     float pos2[3];
  101.     for( int i = 0; i < 32; i++ )
  102.     {
  103.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  104.         {
  105.             GetClientAbsOrigin(i, pos2);
  106.             fDistance = GetVectorDistance(pos, pos2);
  107.             if(fDistance < iRadiusSFling)
  108.             {
  109.                 Fly(entity, i, iPowerSFling)
  110.             }
  111.             if(fDistance < iRadiusSdie)
  112.             {
  113.                 ForcePlayerSuicide(i)
  114.             }
  115.         }
  116.     }
  117. }
  118.  
  119. int BombExplode(int entity, float pos[3], float radius, float damage)
  120. {
  121.     int explosion = CreateEntityByName("env_explosion", -1);
  122.     DispatchKeyValue(explosion, "spawnflags", "1916");
  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) == 2 && IsPlayerAlive(i))
  135.         {
  136.             GetClientAbsOrigin(i, pos2);
  137.             fDistance = GetVectorDistance(pos, pos2);
  138.             if(fDistance < iRadiusSFlingPipe)
  139.             {
  140.                 Fly(entity, i, iPowerSFlingPipe)
  141.             }
  142.             if(fDistance < iRadiusSdiePipe)
  143.             {
  144.                 ForcePlayerSuicide(i)
  145.             }
  146.         }
  147.     }
  148. }
  149.  
  150. int BarrelExplode(int entity, float pos[3], float radius, float damage)
  151. {
  152.     int explosion = CreateEntityByName("env_explosion", -1);
  153.     DispatchKeyValue(explosion, "spawnflags", "1916");
  154.     DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  155.     DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  156.     DispatchSpawn(explosion);
  157.     TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  158.     AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  159.     AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  160.    
  161.     float fDistance = 0.0;
  162.     float pos2[3];
  163.     for( int i = 0; i < 32; i++ )
  164.     {
  165.         if (IsValidClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
  166.         {
  167.             GetClientAbsOrigin(i, pos2);
  168.             fDistance = GetVectorDistance(pos, pos2);
  169.             if(fDistance < iRadiusBFling)
  170.             {
  171.                 Fly(entity, i, iPowerBFling)
  172.             }
  173.             if(fDistance < iRadiusBdie)
  174.             {
  175.                 ForcePlayerSuicide(i)
  176.             }
  177.         }
  178.     }
  179. }
  180.  
  181. /*
  182. static bool IsVisibleTo(float position[3], float targetposition[3])
  183. {
  184.     float vAngles[3], vLookAt[3];
  185.    
  186.     MakeVectorFromPoints(position, targetposition, vLookAt); // compute vector from start to target
  187.     GetVectorAngles(vLookAt, vAngles); // get angles from vector for trace
  188.    
  189.     // execute Trace
  190.     Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);
  191.    
  192.     bool isVisible = false;
  193.     if (TR_DidHit(trace))
  194.     {
  195.         float vStart[3];
  196.         TR_GetEndPosition(vStart, trace); // retrieve our trace endpoint
  197.        
  198.         if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
  199.         {
  200.             isVisible = true; // if trace ray length plus tolerance equal or bigger absolute distance, you hit the target
  201.         }
  202.     }
  203.    
  204.     return isVisible;
  205. }
  206.  
  207. public bool _TraceFilter(int entity, int contentsMask)
  208. {
  209.     if (!entity || entity <= MaxClients || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit
  210.     {
  211.         return false;
  212.     }
  213.     return true;
  214. }
  215. */
  216. public Fly(explosion, int target, float power)
  217. {
  218.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  return;
  219.    
  220.     float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
  221.    
  222.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);      
  223.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  224.    
  225.     if(power < 1)
  226.         return;
  227.    
  228.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  229.     GetVectorAngles(traceVec, resultingFling);
  230.        
  231.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  232.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  233.     resultingFling[2] = power + (power * 0.5);
  234.  
  235.     if (GetClientTeam(target) == 2)
  236.     {
  237.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
  238.     }
  239.     else
  240.     {
  241.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);
  242.     }
  243.  
  244. }
  245.  
  246.  
  247.  
  248. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  249. {
  250.     float victim_origin[3];
  251.     char rupture[32];
  252.     char damage_victim[32];
  253.     IntToString(damage, rupture, sizeof(rupture));
  254.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  255.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  256.     int entity = CreateEntityByName("point_hurt");
  257.     DispatchKeyValue(victim, "targetname", damage_victim);
  258.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  259.     DispatchKeyValue(entity, "Damage", rupture);
  260.     DispatchSpawn(entity);
  261.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  262.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  263.     DispatchKeyValue(entity, "classname", "point_hurt");
  264.     DispatchKeyValue(victim, "targetname", "null");
  265.     AcceptEntityInput(entity, "Kill");
  266. }
  267.  
  268. stock bool IsValidClient(int client)
  269. {
  270.     if ( client < 1 || client > MaxClients ) return false;
  271.     if( !IsClientInGame(client)) return false;
  272.     if ( !IsPlayerAlive( client )) return false;
  273.     return true;
  274. }
Advertisement
Add Comment
Please, Sign In to add comment