FlacoBey

Untitled

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