Advertisement
FlacoBey

Untitled

Jan 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.70 KB | None | 0 0
  1. #include sdktools
  2. #include sdkhooks
  3.  
  4. #define TEAM_SURVIVORS  2
  5. #define TEAM_INFECTED   3
  6.  
  7. int tank;
  8. Handle distance, Fling, FlingDamage, FireDamage;
  9.  
  10. new Handle:sdkCallPushPlayer = INVALID_HANDLE;
  11. new Handle:GameConf = INVALID_HANDLE;
  12.  
  13. public OnPluginStart()
  14. {
  15.     distance    = CreateConVar("sv_rang_rock_stun", "400.0", "", FCVAR_NONE);
  16.     Fling    = CreateConVar("sv_power_rock_of_fling", "450.0", "", FCVAR_NONE);
  17.     FlingDamage    = CreateConVar("sv_rock_damage_fling", "20.0", "", FCVAR_NONE);
  18.     FireDamage    = CreateConVar("sv_rock_damage_fire", "5", "", FCVAR_NONE);
  19.    
  20.     GameConf = LoadGameConfigFile("l4d2_detonationforce");
  21.        
  22.     StartPrepSDKCall(SDKCall_Player);
  23.     PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");
  24.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  25.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
  26.     PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  27.     PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  28.     sdkCallPushPlayer = EndPrepSDKCall();
  29.        
  30.     CloseHandle(GameConf);
  31.    
  32.     HookEvent("ability_use", ability_use);
  33. }
  34.  
  35. public Action ability_use(Event event, const char[] name, bool dontBroadcast)
  36. {
  37.     decl String:s[32];
  38.     GetEventString(event, "ability", s, 32);
  39.  
  40.     if(StrEqual(s, "ability_throw", true))
  41.     {  
  42.         tank = GetClientOfUserId(GetEventInt(event, "userid"));
  43.     }
  44. }
  45.  
  46. public OnEntityCreated(entity, const String:classname[])
  47. {
  48.     if(StrEqual(classname, "tank_rock", true) && GetEntProp(entity, Prop_Send, "m_iTeamNum")>=0)
  49.     {
  50.         if(IsValidEntity(entity) && IsValidEdict(entity))
  51.         {
  52.             if(GetEntityFlags(tank) & FL_ONFIRE)
  53.             {
  54.                 IgniteEntity(entity, 25.0);
  55.             }
  56.         }
  57.     }
  58. }
  59.  
  60. public OnEntityDestroyed(entity)
  61. {
  62.     if(IsValidEntity(entity) && IsValidEdict(entity))
  63.     {
  64.         decl String:g_classname[20];
  65.         GetEdictClassname(entity, g_classname, 20);
  66.         if(StrEqual(g_classname, "tank_rock", true) && GetEntProp(entity, Prop_Send, "m_iTeamNum")>=0)
  67.         {
  68.             for(int i = 1; i <= MaxClients; ++i)
  69.             {
  70.                 if(bIsSurvivor(i))
  71.                 {
  72.                     float fDamagerPos[3], fDangerPos[3];
  73.                     GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fDamagerPos);
  74.                     GetEntPropVector(i, Prop_Send, "m_vecOrigin", fDangerPos);
  75.                     float fTargetDistance = GetVectorDistance(fDamagerPos, fDangerPos);
  76.                     if (fTargetDistance > GetConVarFloat(distance)) continue;
  77.                    
  78.                     Fly(entity, i, GetConVarFloat(Fling))
  79.                     if(GetEntityFlags(tank) & FL_ONFIRE)
  80.                     {
  81.                         DamageEffect(i, GetConVarInt(FireDamage))
  82.                         IgniteEntity(i, 5.0);
  83.                     }
  84.                 }
  85.             }
  86.         }
  87.     }
  88. }
  89.  
  90. public Fly(explosion, target, Float:power)
  91. {
  92.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  // check if the taget is a valid entity
  93.         return;
  94.  
  95.     decl Float:targetPos[3], Float:explosionPos[3], Float:traceVec[3], Float:resultingFling[3];
  96.    
  97.     /* getting the target and explosion position */
  98.    
  99.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);    
  100.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  101.    
  102.     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
  103.    
  104.     if(power < 1)       // if the power is irrelevant, doesn't worth to continue
  105.         return;
  106.    
  107.     /* getting the resulting */
  108.    
  109.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  110.     GetVectorAngles(traceVec, resultingFling);
  111.        
  112.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  113.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  114.     resultingFling[2] = power + (power * 0.5);
  115.  
  116.     /* for L4D 2 */
  117.     if (GetClientTeam(target) == TEAM_SURVIVORS)
  118.     {
  119.         DamageEffect(target, RoundToNearest(GetConVarFloat(FlingDamage)));    // apply damage to the survivor
  120.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);// throwing survivor with animation 76 (charge animation)
  121.     }
  122.     else
  123.     if (GetClientTeam(target) == TEAM_INFECTED)
  124.     {
  125.         DamageEffect(target, RoundToNearest(GetConVarFloat(FlingDamage)));    // apply damage to the infected
  126.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);// throwing infected with animation 2 (jump animation)
  127.     }
  128.  
  129. }
  130.  
  131. public DamageEffect(target, damage)
  132. {
  133.     decl String:sDamage[12];
  134.     IntToString(damage, sDamage, sizeof(sDamage));          // converting the damage from int to string
  135.  
  136.     new pointHurt = CreateEntityByName("point_hurt");       // Create point_hurt
  137.     DispatchKeyValue(target, "targetname", "hurtme");       // mark target
  138.     DispatchKeyValue(pointHurt, "Damage", sDamage);         // Set damage
  139.     DispatchKeyValue(pointHurt, "DamageTarget", "hurtme");  // Target Assignmen
  140.     DispatchKeyValue(pointHurt, "DamageType", "65536");
  141.     DispatchSpawn(pointHurt);                               // Spawn descriped point_hurt
  142.     AcceptEntityInput(pointHurt, "Hurt");                   // Trigger point_hurt execute
  143.     AcceptEntityInput(pointHurt, "Kill");                   // Remove point_hurt
  144.     DispatchKeyValue(target, "targetname", "cake");         // Clear target's mark
  145. }
  146.  
  147. stock bool bIsSurvivor(int client)
  148. {
  149.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement