Advertisement
FlacoBey

Untitled

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