FlacoBey

Untitled

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