Advertisement
FlacoBey

Untitled

Jan 18th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.48 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 sdkOnStaggered;
  9. Handle distance, Fling;
  10.  
  11. new Handle:sdkCallPushPlayer = INVALID_HANDLE;
  12. new Handle:GameConf = INVALID_HANDLE;
  13.  
  14. public OnPluginStart()
  15. {
  16.     distance    = CreateConVar("sv_rang_rock_stun", "400.0", "", FCVAR_NONE);
  17.     Fling    = CreateConVar("sv_rang_rock_stun_of_fling", "450.0", "", FCVAR_NONE);
  18.     Handle hGameConf = LoadGameConfigFile("tank_stun_rock");
  19.    
  20.     StartPrepSDKCall(SDKCall_Player);
  21.     PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "CTerrorPlayer_OnStaggered");
  22.     PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
  23.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  24.     sdkOnStaggered = EndPrepSDKCall();
  25.    
  26.     GameConf = LoadGameConfigFile("l4d2_detonationforce"); 
  27.        
  28.     StartPrepSDKCall(SDKCall_Player);
  29.     PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");
  30.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  31.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
  32.     PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  33.     PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  34.     sdkCallPushPlayer = EndPrepSDKCall();
  35.        
  36.     CloseHandle(GameConf);
  37.    
  38.     HookEvent("ability_use", ability_use);
  39. }
  40.  
  41. public Action ability_use(Event event, const char[] name, bool dontBroadcast)
  42. {
  43.     decl String:s[32];
  44.     GetEventString(event, "ability", s, 32);
  45.  
  46.     if(StrEqual(s, "ability_throw", true))
  47.     {  
  48.         tank = GetClientOfUserId(GetEventInt(event, "userid"));
  49.     }
  50. }
  51.  
  52. public OnEntityCreated(entity, const String:classname[])
  53. {
  54.     if(StrEqual(classname, "tank_rock", true) && GetEntProp(entity, Prop_Send, "m_iTeamNum")>=0)
  55.     {
  56.         if(IsValidEntity(entity) && IsValidEdict(entity))
  57.         {
  58.             if(GetEntityFlags(tank) & FL_ONFIRE)
  59.             {
  60.                 IgniteEntity(entity, 25.0);
  61.             }
  62.         }
  63.     }
  64. }
  65.  
  66. public OnEntityDestroyed(entity)
  67. {
  68.     if(IsValidEntity(entity) && IsValidEdict(entity))
  69.     {
  70.         decl String:g_classname[20];
  71.         GetEdictClassname(entity, g_classname, 20);
  72.         if(StrEqual(g_classname, "tank_rock", true) && GetEntProp(entity, Prop_Send, "m_iTeamNum")>=0)
  73.         {
  74.             for(int i = 1; i <= MaxClients; ++i)
  75.             {
  76.                 if(bIsSurvivor(i))
  77.                 {
  78.                     float fDamagerPos[3], fDangerPos[3];
  79.                     GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fDamagerPos);
  80.                     GetEntPropVector(i, Prop_Send, "m_vecOrigin", fDangerPos);
  81.                     float fTargetDistance = GetVectorDistance(fDamagerPos, fDangerPos);
  82.                     if (fTargetDistance > GetConVarFloat(distance)) continue;
  83.                    
  84.                     if(GetEntityFlags(tank) & FL_ONFIRE)
  85.                     {
  86.                         Fly(entity, i, GetConVarFloat(Fling))
  87.                     }
  88.                     else
  89.                     {
  90.                         SDKCall(sdkOnStaggered, i, entity, fDamagerPos);
  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.         DamageEffect(target, RoundToNearest(power));    // apply damage to the survivor
  128.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);// throwing survivor with animation 76 (charge animation)
  129.     }
  130.     else
  131.     if (GetClientTeam(target) == TEAM_INFECTED)
  132.     {
  133.         DamageEffect(target, RoundToNearest(power));    // apply damage to the infected
  134.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);// throwing infected with animation 2 (jump animation)
  135.     }
  136.  
  137. }
  138.  
  139. public DamageEffect(target, damage)
  140. {
  141.     decl String:sDamage[12];
  142.     IntToString(damage, sDamage, sizeof(sDamage));          // converting the damage from int to string
  143.  
  144.     new pointHurt = CreateEntityByName("point_hurt");       // Create point_hurt
  145.     DispatchKeyValue(target, "targetname", "hurtme");       // mark target
  146.     DispatchKeyValue(pointHurt, "Damage", sDamage);         // Set damage
  147.     DispatchKeyValue(pointHurt, "DamageTarget", "hurtme");  // Target Assignment
  148.     DispatchKeyValue(pointHurt, "DamageType", "65536");     // Type of damage
  149.     DispatchSpawn(pointHurt);                               // Spawn descriped point_hurt
  150.     AcceptEntityInput(pointHurt, "Hurt");                   // Trigger point_hurt execute
  151.     AcceptEntityInput(pointHurt, "Kill");                   // Remove point_hurt
  152.     DispatchKeyValue(target, "targetname", "cake");         // Clear target's mark
  153. }
  154.  
  155. stock bool bIsSurvivor(int client)
  156. {
  157.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement