FlacoBey

Untitled

Jun 1st, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.59 KB | None | 0 0
  1. #include sdktools
  2. #include sdkhooks
  3.  
  4. #pragma semicolon 1
  5. #pragma newdecls required
  6.  
  7. #define TEAM_SURVIVORS  2
  8. #define TEAM_INFECTED   3
  9.  
  10. Handle distance, Fling, FlingDamage;
  11.  
  12. Handle sdkCallPushPlayer = INVALID_HANDLE;
  13. Handle GameConf = INVALID_HANDLE;
  14.  
  15. public void OnPluginStart()
  16. {
  17.     distance    = CreateConVar("sv_rang_rock_stun", "400.0", "", FCVAR_NONE);
  18.     Fling    = CreateConVar("sv_power_rock_of_fling", "450.0", "", FCVAR_NONE);
  19.     FlingDamage    = CreateConVar("sv_rock_damage_fling", "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. }
  34.  
  35. public void OnEntityDestroyed(int entity)
  36. {
  37.     if(IsValidEntity(entity) && IsValidEdict(entity))
  38.     {
  39.         char g_classname[20];
  40.         GetEdictClassname(entity, g_classname, 20);
  41.         if(StrEqual(g_classname, "tank_rock", true) && GetEntProp(entity, Prop_Send, "m_iTeamNum") >= 0)
  42.         {
  43.             for(int i = 1; i <= MaxClients; ++i)
  44.             {
  45.                 if(bIsSurvivor(i))
  46.                 {
  47.                     float fDamagerPos[3], fDangerPos[3];
  48.                     GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fDamagerPos);
  49.                     GetEntPropVector(i, Prop_Send, "m_vecOrigin", fDangerPos);
  50.                     float fTargetDistance = GetVectorDistance(fDamagerPos, fDangerPos);
  51.                     if (fTargetDistance > GetConVarFloat(distance)) continue;
  52.                     int iCurrentWeapon = GetEntPropEnt(i, Prop_Send, "m_hActiveWeapon");
  53.                     if(IsValidEntity(iCurrentWeapon)) SDKCallWeaponDrop(i, iCurrentWeapon);
  54.                     Fly(entity, i, GetConVarFloat(Fling));
  55.                     DamageEffect(i, GetConVarInt(FlingDamage));
  56.                 }
  57.             }
  58.         }
  59.     }
  60. }
  61.  
  62. public int Fly(int explosion, int target, float power)
  63. {
  64.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))
  65.         return;
  66.  
  67.     float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
  68.    
  69.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);    
  70.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  71.    
  72.     float fDistance = GetVectorDistance(targetPos,explosionPos);
  73.     float iOne = GetConVarInt(distance) - fDistance;
  74.     float vForward = GetConVarInt(distance) / iOne;
  75.     power = GetConVarInt(Fling) / (vForward * vForward * vForward);
  76.    
  77.     if(power < 1) return;
  78.  
  79.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  80.     GetVectorAngles(traceVec, resultingFling);
  81.        
  82.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  83.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  84.     resultingFling[2] = power + (power * 0.5);
  85.  
  86.     if (GetClientTeam(target) == TEAM_SURVIVORS)
  87.     {
  88.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
  89.     }
  90. }
  91.  
  92. public void DamageEffect(int target, int damage)
  93. {
  94.     char sDamage[12];
  95.     IntToString(damage, sDamage, sizeof(sDamage));
  96.     int pointHurt = CreateEntityByName("point_hurt");
  97.     DispatchKeyValue(target, "targetname", "hurtme");
  98.     DispatchKeyValue(pointHurt, "Damage", sDamage);
  99.     DispatchKeyValue(pointHurt, "DamageTarget", "hurtme");
  100.     DispatchKeyValue(pointHurt, "DamageType", "65536");
  101.     DispatchSpawn(pointHurt);
  102.     AcceptEntityInput(pointHurt, "Hurt");
  103.     AcceptEntityInput(pointHurt, "Kill");
  104.     DispatchKeyValue(target, "targetname", "cake");
  105. }
  106.  
  107. stock void SDKCallWeaponDrop(int client, int weapon)
  108. {
  109.     float vecAngles[3], vecVelocity[3];
  110.     GetClientEyeAngles(client, vecAngles);
  111.     GetAngleVectors(vecAngles, vecVelocity, NULL_VECTOR, NULL_VECTOR);
  112.     vecVelocity[0] = vecAngles[0] * GetRandomInt(2, 4);
  113.     vecVelocity[1] = vecAngles[1] * GetRandomInt(2, 4);
  114.     vecVelocity[2] = vecAngles[2] * GetRandomInt(2, 4);
  115.     SDKHooks_DropWeapon(client, weapon, NULL_VECTOR, NULL_VECTOR);
  116.     TeleportEntity(weapon, NULL_VECTOR, NULL_VECTOR, vecVelocity);
  117. }
  118.  
  119. stock bool bIsSurvivor(int client)
  120. {
  121.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  122. }
Advertisement
Add Comment
Please, Sign In to add comment