Advertisement
FlacoBey

Untitled

Jan 19th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.85 KB | None | 0 0
  1. #include sdktools
  2. #include sdkhooks
  3.  
  4. #define TEAM_SURVIVORS  2
  5. #define TEAM_INFECTED   3
  6. #define ZC_BOOMER               2
  7.  
  8. Handle distance, damage_flint;
  9.  
  10. new Handle:sdkCallPushPlayer = INVALID_HANDLE;
  11. new Handle:GameConf = INVALID_HANDLE;
  12.  
  13. public OnPluginStart()
  14. {
  15.     distance    = CreateConVar("sv_boomer_death_distance", "400.0", "", FCVAR_NONE);
  16.     damage_flint = CreateConVar("sv_distance_flint", "400.0", "", FCVAR_NONE);
  17.     GameConf = LoadGameConfigFile("l4d2_detonationforce");
  18.        
  19.     StartPrepSDKCall(SDKCall_Player);
  20.     PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");
  21.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  22.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
  23.     PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  24.     PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  25.     sdkCallPushPlayer = EndPrepSDKCall();
  26.        
  27.     CloseHandle(GameConf);
  28.    
  29.     HookEvent("player_death", death);
  30. }
  31.  
  32. public Action death(Event event, const char[] name, bool dontBroadcast)
  33. {
  34.     int client = GetClientOfUserId(GetEventInt(event, "userid"));
  35.     float fDamagerPos[3], fDangerPos[3];
  36.     if(IsValidBoomer(client))
  37.     {
  38.         for(int i = 1; i <= MaxClients; ++i)
  39.         {
  40.             if(bIsSurvivor(i))
  41.             {
  42.                 GetEntPropVector(i, Prop_Send, "m_vecOrigin", fDamagerPos);
  43.                 GetEntPropVector(client, Prop_Send, "m_vecOrigin", fDangerPos);
  44.                 float fTargetDistance = GetVectorDistance(fDamagerPos, fDangerPos);
  45.                 if (fTargetDistance < GetConVarFloat(distance))
  46.                 {
  47.                     Fly(client, i, GetConVarFloat(damage_flint))
  48.                 }
  49.             }
  50.         }
  51.     }
  52. }
  53.  
  54.  
  55. public Fly(explosion, target, Float:power)
  56. {
  57.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  // check if the taget is a valid entity
  58.         return;
  59.  
  60.     decl Float:targetPos[3], Float:explosionPos[3], Float:traceVec[3], Float:resultingFling[3];
  61.    
  62.     /* getting the target and explosion position */
  63.    
  64.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);    
  65.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  66.    
  67.     power = power - GetVectorDistance(targetPos,explosionPos);  // an easy way to define the explosion power, is the "base power" minus the distance between the target and the explosion
  68.    
  69.     if(power < 1)       // if the power is irrelevant, doesn't worth to continue
  70.         return;
  71.    
  72.     /* getting the resulting */
  73.    
  74.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  75.     GetVectorAngles(traceVec, resultingFling);
  76.        
  77.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  78.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  79.     resultingFling[2] = power + (power * 0.5);
  80.  
  81.     /* for L4D 2 */
  82.     if (GetClientTeam(target) == TEAM_SURVIVORS)
  83.     {
  84.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);// throwing survivor with animation 76 (charge animation)
  85.     }
  86.     else
  87.     if (GetClientTeam(target) == TEAM_INFECTED)
  88.     {
  89.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);// throwing infected with animation 2 (jump animation)
  90.     }
  91.  
  92. }
  93.  
  94. public IsValidBoomer(client)
  95. {
  96.     if (IsValidClient(client) && GetClientTeam(client) == TEAM_INFECTED)
  97.     {
  98.         new class = GetEntProp(client, Prop_Send, "m_zombieClass");
  99.        
  100.         if (class == ZC_BOOMER)
  101.             return true;
  102.        
  103.         return false;
  104.     }
  105.    
  106.     return false;
  107.  
  108. }
  109.  
  110. public IsValidClient(client)
  111. {
  112.     if (client <= 0)
  113.         return false;
  114.        
  115.     if (client > MaxClients)
  116.         return false;
  117.        
  118.     if (!IsClientInGame(client))
  119.         return false;
  120.  
  121.     return true;
  122. }
  123.  
  124. stock bool bIsSurvivor(int client)
  125. {
  126.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement