Advertisement
FlacoBey

Untitled

May 21st, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.00 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.  
  21. Handle sdkCallPushPlayer;
  22.  
  23. public OnPluginStart()
  24. {
  25.     Handle GameConf = LoadGameConfigFile("gamedata_stager");  
  26.            
  27.     if(GameConf == INVALID_HANDLE)
  28.     {
  29.         SetFailState("Couldn't find the offsets and signatures file. Please, check that it is installed correctly.");
  30.     }
  31.        
  32.     StartPrepSDKCall(SDKCall_Player);
  33.     PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");
  34.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  35.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
  36.     PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  37.     PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  38.     sdkCallPushPlayer = EndPrepSDKCall();
  39. }
  40.  
  41. public OnClientPutInServer(client)
  42. {
  43.     SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  44. }
  45.  
  46. public OnClientDisconnect(client)
  47. {
  48.     SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  49. }
  50.  
  51. public Action:OnTakeDamage(victim, &attacker, &entity, &Float:damage, &damageType, &weapon, Float:damageForce[3], Float:damagePosition[3])
  52. {
  53.     if (victim <= 0 || victim > MaxClients || !IsClientInGame(victim) || GetClientTeam(victim) != 2 || !IsPlayerAlive(victim) || !IsValidEdict(victim))
  54.     {
  55.         return Plugin_Continue;
  56.     }
  57.    
  58.     if(entity <= 0 || !IsValidEdict(entity))
  59.     {
  60.         return Plugin_Continue;
  61.     }
  62.    
  63.     char sWeaponEx[32]
  64.     GetEdictClassname(entity, sWeaponEx, sizeof(sWeaponEx));
  65.    
  66.     if(StrEqual(sWeaponEx, "grenade_launcher_projectile"))
  67.     {
  68.         float vPos[3], vDamager[3];
  69.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vDamager);
  70.         for(int i = 1; i <= 32; ++i)
  71.         {
  72.             if(!IsValidClient(i)) continue;
  73.            
  74.             GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
  75.            
  76.             float fTargetDistance = GetVectorDistance(vDamager, vPos);
  77.             if(GetClientTeam(i) == 2)
  78.             {
  79.                 if (fTargetDistance < 300)
  80.                 {
  81.                     ForcePlayerSuicide(i)
  82.                 }
  83.                 if (fTargetDistance < 5000)
  84.                 {
  85.                     Fly(entity, i, 400.0)
  86.                 }
  87.                 if (fTargetDistance < 10000)
  88.                 {
  89.                     damage = 25.0
  90.                 }
  91.             }
  92.             return Plugin_Changed;
  93.         }
  94.     }
  95.     else if(StrEqual(sWeaponEx, "pipe_bomb_projectile"))
  96.     {
  97.         for(int i = 1; i <= MaxClients; ++i)
  98.         {
  99.             if(IsValidClient(i))
  100.             {
  101.                 float vPos[3], vDamager[3];
  102.                 GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vDamager);
  103.                 GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
  104.                 float fTargetDistance = GetVectorDistance(vDamager, vPos);
  105.                    
  106.                 if(GetClientTeam(i) == 2)
  107.                 {
  108.                     if (fTargetDistance < 9000)
  109.                     {
  110.                         ForcePlayerSuicide(i)
  111.                     }
  112.                     if (fTargetDistance < 7000)
  113.                     {
  114.                         Fly(entity, i, 300.0)
  115.                     }
  116.                     if (fTargetDistance < 10000)
  117.                     {
  118.                         damage = 66.0
  119.                     }
  120.                     return Plugin_Changed;
  121.                 }
  122.             }
  123.         }
  124.     }
  125.     return Plugin_Continue;
  126. }
  127. /*
  128. static bool IsVisibleTo(float position[3], float targetposition[3])
  129. {
  130.     float vAngles[3], vLookAt[3];
  131.    
  132.     MakeVectorFromPoints(position, targetposition, vLookAt); // compute vector from start to target
  133.     GetVectorAngles(vLookAt, vAngles); // get angles from vector for trace
  134.    
  135.     // execute Trace
  136.     Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);
  137.    
  138.     bool isVisible = false;
  139.     if (TR_DidHit(trace))
  140.     {
  141.         float vStart[3];
  142.         TR_GetEndPosition(vStart, trace); // retrieve our trace endpoint
  143.        
  144.         if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
  145.         {
  146.             isVisible = true; // if trace ray length plus tolerance equal or bigger absolute distance, you hit the target
  147.         }
  148.     }
  149.    
  150.     return isVisible;
  151. }
  152.  
  153. public bool _TraceFilter(int entity, int contentsMask)
  154. {
  155.     if (!entity || entity <= MaxClients || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit
  156.     {
  157.         return false;
  158.     }
  159.     return true;
  160. }
  161. */
  162. public Fly(explosion, int target, float power)
  163. {
  164.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  return;
  165.    
  166.     float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
  167.    
  168.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);      
  169.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  170.    
  171.     if(power < 1)
  172.         return;
  173.    
  174.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  175.     GetVectorAngles(traceVec, resultingFling);
  176.        
  177.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  178.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  179.     resultingFling[2] = power + (power * 0.5);
  180.  
  181.     if (GetClientTeam(target) == 2)
  182.     {
  183.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
  184.     }
  185.     else
  186.     {
  187.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);
  188.     }
  189.  
  190. }
  191.  
  192. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  193. {
  194.     float victim_origin[3];
  195.     char rupture[32];
  196.     char damage_victim[32];
  197.     IntToString(damage, rupture, sizeof(rupture));
  198.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  199.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  200.     int entity = CreateEntityByName("point_hurt");
  201.     DispatchKeyValue(victim, "targetname", damage_victim);
  202.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  203.     DispatchKeyValue(entity, "Damage", rupture);
  204.     DispatchSpawn(entity);
  205.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  206.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  207.     DispatchKeyValue(entity, "classname", "point_hurt");
  208.     DispatchKeyValue(victim, "targetname", "null");
  209.     AcceptEntityInput(entity, "Kill");
  210. }
  211.  
  212. stock bool IsValidClient(int client)
  213. {
  214.     if ( client < 1 || client > MaxClients ) return false;
  215.     if( !IsClientInGame(client)) return false;
  216.     if ( !IsPlayerAlive( client )) return false;
  217.     return true;
  218. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement