FlacoBey

Untitled

May 21st, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.10 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. 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.                     damage = iDamageGrenadeLauncherS
  88.                 }
  89.             }
  90.             return Plugin_Changed;
  91.         }
  92.     }
  93.     else if(StrEqual(sWeaponEx, "pipe_bomb_projectile"))
  94.     {
  95.         for(int i = 1; i <= MaxClients; ++i)
  96.         {
  97.             if(IsValidClient(i))
  98.             {
  99.                 float vPos[3], vDamager[3];
  100.                 GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vDamager);
  101.                 GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
  102.                 float fTargetDistance = GetVectorDistance(vDamager, vPos);
  103.                    
  104.                 if(GetClientTeam(i) == 2)
  105.                 {
  106.                     if (fTargetDistance < iRadiusSdiePipe)
  107.                     {
  108.                         ForcePlayerSuicide(i)
  109.                     }
  110.                     if (fTargetDistance < iRadiusSFlingPipe)
  111.                     {
  112.                         Fly(entity, i, iPowerSFlingPipe)
  113.                     }
  114.                     if (fTargetDistance < iRadiusSDamagePipe)
  115.                     {
  116.                         damage = iDamagePipeS
  117.                     }
  118.                     return Plugin_Changed;
  119.                 }
  120.             }
  121.         }
  122.     }
  123.     return Plugin_Continue;
  124. }
  125. /*
  126. static bool IsVisibleTo(float position[3], float targetposition[3])
  127. {
  128.     float vAngles[3], vLookAt[3];
  129.    
  130.     MakeVectorFromPoints(position, targetposition, vLookAt); // compute vector from start to target
  131.     GetVectorAngles(vLookAt, vAngles); // get angles from vector for trace
  132.    
  133.     // execute Trace
  134.     Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);
  135.    
  136.     bool isVisible = false;
  137.     if (TR_DidHit(trace))
  138.     {
  139.         float vStart[3];
  140.         TR_GetEndPosition(vStart, trace); // retrieve our trace endpoint
  141.        
  142.         if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
  143.         {
  144.             isVisible = true; // if trace ray length plus tolerance equal or bigger absolute distance, you hit the target
  145.         }
  146.     }
  147.    
  148.     return isVisible;
  149. }
  150.  
  151. public bool _TraceFilter(int entity, int contentsMask)
  152. {
  153.     if (!entity || entity <= MaxClients || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit
  154.     {
  155.         return false;
  156.     }
  157.     return true;
  158. }
  159. */
  160. public Fly(explosion, int target, float power)
  161. {
  162.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  return;
  163.    
  164.     float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
  165.    
  166.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);      
  167.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  168.    
  169.     if(power < 1)
  170.         return;
  171.    
  172.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  173.     GetVectorAngles(traceVec, resultingFling);
  174.        
  175.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  176.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  177.     resultingFling[2] = power + (power * 0.5);
  178.  
  179.     if (GetClientTeam(target) == 2)
  180.     {
  181.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
  182.     }
  183.     else
  184.     {
  185.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);
  186.     }
  187.  
  188. }
  189.  
  190. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  191. {
  192.     float victim_origin[3];
  193.     char rupture[32];
  194.     char damage_victim[32];
  195.     IntToString(damage, rupture, sizeof(rupture));
  196.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  197.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  198.     int entity = CreateEntityByName("point_hurt");
  199.     DispatchKeyValue(victim, "targetname", damage_victim);
  200.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  201.     DispatchKeyValue(entity, "Damage", rupture);
  202.     DispatchSpawn(entity);
  203.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  204.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  205.     DispatchKeyValue(entity, "classname", "point_hurt");
  206.     DispatchKeyValue(victim, "targetname", "null");
  207.     AcceptEntityInput(entity, "Kill");
  208. }
  209.  
  210. stock bool IsValidClient(int client)
  211. {
  212.     if ( client < 1 || client > MaxClients ) return false;
  213.     if( !IsClientInGame(client)) return false;
  214.     if ( !IsPlayerAlive( client )) return false;
  215.     return true;
  216. }
Advertisement
Add Comment
Please, Sign In to add comment