Advertisement
FlacoBey

Untitled

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