Advertisement
FlacoBey

Untitled

Jan 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.55 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(IsClientConnected(tank) && IsClientInGame(tank) && IsPlayerAlive(tank))
  54.             {
  55.                 if(GetEntityFlags(tank) & FL_ONFIRE)
  56.                 {
  57.                     IgniteEntity(entity, 25.0);
  58.                 }
  59.             }
  60.         }
  61.     }
  62. }
  63.  
  64. public OnEntityDestroyed(entity)
  65. {
  66.     if(IsValidEntity(entity) && IsValidEdict(entity))
  67.     {
  68.         decl String:g_classname[20];
  69.         GetEdictClassname(entity, g_classname, 20);
  70.         if(StrEqual(g_classname, "tank_rock", true) && GetEntProp(entity, Prop_Send, "m_iTeamNum")>=0)
  71.         {
  72.             for(int i = 1; i <= MaxClients; ++i)
  73.             {
  74.                 if(bIsSurvivor(i))
  75.                 {
  76.                     float fDamagerPos[3], fDangerPos[3];
  77.                     GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fDamagerPos);
  78.                     GetEntPropVector(i, Prop_Send, "m_vecOrigin", fDangerPos);
  79.                     float fTargetDistance = GetVectorDistance(fDamagerPos, fDangerPos);
  80.                     if (fTargetDistance > GetConVarFloat(distance)) continue;
  81.                    
  82.                     Fly(entity, i, GetConVarFloat(Fling))
  83.                     if(GetEntityFlags(tank) & FL_ONFIRE)
  84.                     {
  85.                         DamageEffect(i, GetConVarInt(FireDamage))
  86.                         IgniteEntity(i, 4.0);
  87.                     }
  88.                     else
  89.                     {
  90.                         DamageEffect(i, GetConVarInt(FlingDamage))
  91.                     }
  92.                 }
  93.             }
  94.         }
  95.     }
  96. }
  97.  
  98. public Fly(explosion, target, Float:power)
  99. {
  100.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  // check if the taget is a valid entity
  101.         return;
  102.  
  103.     decl Float:targetPos[3], Float:explosionPos[3], Float:traceVec[3], Float:resultingFling[3];
  104.    
  105.     /* getting the target and explosion position */
  106.    
  107.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);    
  108.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  109.    
  110.     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
  111.    
  112.     if(power < 1)       // if the power is irrelevant, doesn't worth to continue
  113.         return;
  114.    
  115.     /* getting the resulting */
  116.    
  117.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  118.     GetVectorAngles(traceVec, resultingFling);
  119.        
  120.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  121.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  122.     resultingFling[2] = power + (power * 0.5);
  123.  
  124.     /* for L4D 2 */
  125.     if (GetClientTeam(target) == TEAM_SURVIVORS)
  126.     {
  127.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);// throwing survivor with animation 76 (charge animation)
  128.     }
  129.     else
  130.     if (GetClientTeam(target) == TEAM_INFECTED)
  131.     {
  132.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);// throwing infected with animation 2 (jump animation)
  133.     }
  134.  
  135. }
  136.  
  137. public DamageEffect(target, damage)
  138. {
  139.     decl String:sDamage[12];
  140.     IntToString(damage, sDamage, sizeof(sDamage));          // converting the damage from int to string
  141.  
  142.     new pointHurt = CreateEntityByName("point_hurt");       // Create point_hurt
  143.     DispatchKeyValue(target, "targetname", "hurtme");       // mark target
  144.     DispatchKeyValue(pointHurt, "Damage", sDamage);         // Set damage
  145.     DispatchKeyValue(pointHurt, "DamageTarget", "hurtme");  // Target Assignmen
  146.     DispatchKeyValue(pointHurt, "DamageType", "65536");
  147.     DispatchSpawn(pointHurt);                               // Spawn descriped point_hurt
  148.     AcceptEntityInput(pointHurt, "Hurt");                   // Trigger point_hurt execute
  149.     AcceptEntityInput(pointHurt, "Kill");                   // Remove point_hurt
  150.     DispatchKeyValue(target, "targetname", "cake");         // Clear target's mark
  151. }
  152.  
  153. stock bool bIsSurvivor(int client)
  154. {
  155.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement