Advertisement
FlacoBey

Untitled

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