Advertisement
FlacoBey

Untitled

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