SHARE
TWEET

Untitled

a guest May 23rd, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sourcemod>  
  2. #include <sdktools>  
  3. #include sdkhooks  
  4.    
  5. #pragma tabsize 0  
  6.    
  7. float GrenadeDamage = 100.0  
  8. float PipeBombDamage = 100.0  
  9. float BarrelDamage = 100.0  
  10.    
  11. float GrenadeRadius = 10.0  
  12. float PipeRadius = 1500.0  
  13. float BarrelRadius = 1500.0  
  14.    
  15. float GrenadeFling = 450.0  
  16. float PipeFling = 450.0  
  17. float BarrelFling = 450.0  
  18.    
  19. float RadiusFlingGrenade = 250.0  
  20. float RadiusFlingPipe = 250.0  
  21. float RadiusFlingBarrel = 250.0  
  22.    
  23. float ShakeGrenade = 1500.0  
  24. float ShakePipe = 1500.0  
  25. float ShakeBarrel = 1500.0  
  26.    
  27. float PowerShakeG = 150.0  
  28. float PowerShakeP = 150.0  
  29. float PowerShakeB = 150.0  
  30.    
  31. Handle sdkCallPushPlayer;  
  32.    
  33. public OnPluginStart()  
  34. {  
  35.     Handle GameConf = LoadGameConfigFile("gamedata_stager");    
  36.              
  37.     if(GameConf == INVALID_HANDLE)  
  38.     {  
  39.         SetFailState("Couldn't find the offsets and signatures file. Please, check that it is installed correctly.");  
  40.     }  
  41.          
  42.     StartPrepSDKCall(SDKCall_Player);  
  43.     PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");  
  44.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);  
  45.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);  
  46.     PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);  
  47.     PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);  
  48.     sdkCallPushPlayer = EndPrepSDKCall();  
  49. }  
  50.    
  51. bool IsAllow = false;  
  52.    
  53. public OnMapStart()  
  54. {  
  55.     IsAllow = false;  
  56.     CreateTimer(3.0, allow)  
  57. }  
  58.    
  59. public Action allow(Handle timer)  
  60. {  
  61.     IsAllow = true;  
  62. }  
  63.    
  64. public void OnEntityDestroyed(int entity)  
  65. {  
  66.     if(!IsAllow) return;  
  67.      
  68.     if (IsValidEntity(entity) && IsValidEdict(entity))  
  69.     {  
  70.         char classname[128];  
  71.         GetEdictClassname(entity, classname, 128);  
  72.         if (StrEqual(classname, "grenade_launcher_projectile", false))  
  73.         {  
  74.             GrenadeTouch(entity);  
  75.         }  
  76.         if (StrEqual(classname, "pipe_bomb_projectile", false))  
  77.         {  
  78.             BombTouch(entity);  
  79.         }  
  80.         if (StrEqual(classname, "prop_fuel_barrel", false))  
  81.         {  
  82.             BarrelTouch(entity);  
  83.         }  
  84.     }  
  85. }  
  86.    
  87. public int GrenadeTouch(int entity)  
  88. {  
  89.     float pos[3];  
  90.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);  
  91.     GranadeExplode(pos);  
  92. }  
  93.    
  94. public int BombTouch(int entity)  
  95. {  
  96.     float pos[3];  
  97.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);  
  98.     BombExplode(pos)  
  99. }  
  100.    
  101. public int BarrelTouch(int entity)  
  102. {  
  103.     float pos[3];  
  104.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);  
  105.     BarrelExplode(pos);  
  106. }  
  107.    
  108. int GranadeExplode(float pos[3])  
  109. {  
  110.     float fDistance = 0.0;  
  111.     float pos2[3];  
  112.     for( int i = 0; i < 32; i++ )  
  113.     {  
  114.         if(IsValidClient(i) && GetClientTeam(i) == 2)  
  115.         {  
  116.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")  
  117.             if(vClass == 9)  
  118.             {  
  119.                 GetClientAbsOrigin(i, pos2);  
  120.                 if (!IsVisibleTo(pos, pos2)) continue;  
  121.                 fDistance = GetVectorDistance(pos, pos2);  
  122.                 if(fDistance < RadiusFlingGrenade)  
  123.                 {  
  124.                     Fly(i, i, GrenadeFling)  
  125.                 }  
  126.                 if(fDistance < GrenadeRadius)  
  127.                 {  
  128.                     float iOne = GrenadeRadius - fDistance  
  129.                     float vForward = GrenadeRadius / iOne  
  130.                     int iDamage = RoundToCeil(GrenadeDamage / (vForward * vForward * vForward))  
  131.                     ForceDamageEntity(i, iDamage, i)  
  132.                 }  
  133.                 if(fDistance < ShakeGrenade)  
  134.                 {  
  135.                     float iOne = ShakeGrenade - fDistance  
  136.                     float vForward = ShakeGrenade / iOne  
  137.                     float iDamage = (PowerShakeG / (vForward * vForward * vForward)) * 1.0  
  138.                     ScreenShake(i, iDamage)  
  139.                 }  
  140.             }  
  141.         }  
  142.     }  
  143. }  
  144.    
  145. int BombExplode(float pos[3])  
  146. {  
  147.     float fDistance = 0.0;  
  148.     float pos2[3];  
  149.     for( int i = 0; i < 32; i++ )  
  150.     {  
  151.         if(IsValidClient(i) && GetClientTeam(i) == 2)  
  152.         {  
  153.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")  
  154.             if(vClass == 9)  
  155.             {  
  156.                 GetClientAbsOrigin(i, pos2);  
  157.                 if (!IsVisibleTo(pos, pos2)) continue;  
  158.                 fDistance = GetVectorDistance(pos, pos2);  
  159.                 if(fDistance < RadiusFlingPipe)  
  160.                 {  
  161.                     Fly(i, i, PipeFling)  
  162.                 }  
  163.                 if(fDistance < PipeRadius)  
  164.                 {  
  165.                     float iOne = PipeRadius - fDistance  
  166.                     float vForward = PipeRadius / iOne  
  167.                     int iDamage = RoundToCeil(PipeBombDamage / (vForward * vForward * vForward))  
  168.                     ForceDamageEntity(i, iDamage, i)  
  169.                 }  
  170.                 if(fDistance < ShakePipe)  
  171.                 {  
  172.                     float iOne = ShakePipe - fDistance  
  173.                     float vForward = ShakePipe / iOne  
  174.                     float iDamage = (PowerShakeP / (vForward * vForward * vForward)) * 1.0  
  175.                     ScreenShake(i, iDamage)  
  176.                 }  
  177.             }  
  178.         }  
  179.     }  
  180. }  
  181.    
  182. int BarrelExplode(float pos[3])  
  183. {  
  184.     float fDistance = 0.0;  
  185.     float pos2[3];  
  186.     for( int i = 0; i < 32; i++ )  
  187.     {  
  188.         if(IsValidClient(i) && GetClientTeam(i) == 2)  
  189.         {  
  190.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")  
  191.             if(vClass == 9)  
  192.             {  
  193.                 GetClientAbsOrigin(i, pos2);  
  194.                 if (!IsVisibleTo(pos, pos2)) continue;  
  195.                 fDistance = GetVectorDistance(pos, pos2);  
  196.                 if(fDistance < RadiusFlingBarrel)  
  197.                 {  
  198.                     Fly(i, i, BarrelFling)  
  199.                 }  
  200.                 if(fDistance < BarrelRadius)  
  201.                 {  
  202.                     float iOne = BarrelRadius - fDistance  
  203.                     float vForward = BarrelRadius / iOne  
  204.                     int iDamage = RoundToCeil(BarrelDamage / (vForward * vForward * vForward))  
  205.                     ForceDamageEntity(i, iDamage, i)  
  206.                 }  
  207.                 if(fDistance < ShakeBarrel)  
  208.                 {  
  209.                     float iOne = ShakeBarrel - fDistance  
  210.                     float vForward = ShakeBarrel / iOne  
  211.                     float iDamage = (PowerShakeB / (vForward * vForward * vForward)) * 1.0  
  212.                     ScreenShake(i, iDamage)  
  213.                 }  
  214.             }  
  215.         }  
  216.     }  
  217. }  
  218.    
  219. public Fly(explosion, int target, float power)  
  220. {  
  221.     if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  return;  
  222.      
  223.     float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];  
  224.      
  225.     GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);        
  226.     GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);  
  227.      
  228.     float fDistance = GetVectorDistance(targetPos, explosionPos)  
  229.     float iOne = GrenadeRadius - fDistance  
  230.     float iDamage = GrenadeRadius / iOne  
  231.     power = (GrenadeDamage / (iDamage * iDamage * iDamage)) * 1.0  
  232.     if(power < 1)  
  233.         return;  
  234.      
  235.     MakeVectorFromPoints(explosionPos, targetPos, traceVec);  
  236.     GetVectorAngles(traceVec, resultingFling);  
  237.          
  238.     resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;  
  239.     resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;  
  240.     resultingFling[2] = power + (power * 0.5);  
  241.     if (GetClientTeam(target) == 2)  
  242.     {  
  243.         SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);  
  244.     }  
  245.     else  
  246.     {  
  247.         SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);  
  248.     }  
  249. }  
  250.    
  251. public void ScreenShake(int target, float power)  
  252. {  
  253.     Handle msg;  
  254.     msg = StartMessageOne("Shake", target);  
  255.     BfWriteByte(msg, 0);  
  256.     BfWriteFloat(msg, power);  
  257.     BfWriteFloat(msg, 10.0);  
  258.     BfWriteFloat(msg, 3.0);  
  259.     EndMessage();  
  260. }  
  261.  
  262. static bool IsVisibleTo(float position[3], float targetposition[3])  
  263. {  
  264.     float vAngles[3], vLookAt[3];  
  265.      
  266.     MakeVectorFromPoints(position, targetposition, vLookAt); // compute vector from start to target  
  267.     GetVectorAngles(vLookAt, vAngles); // get angles from vector for trace  
  268.      
  269.     // execute Trace  
  270.     Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);  
  271.      
  272.     bool isVisible = false;  
  273.     if (TR_DidHit(trace))  
  274.     {  
  275.         float vStart[3];  
  276.         TR_GetEndPosition(vStart, trace); // retrieve our trace endpoint  
  277.          
  278.         if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))  
  279.         {  
  280.             isVisible = true; // if trace ray length plus tolerance equal or bigger absolute distance, you hit the target  
  281.         }  
  282.     }  
  283.      
  284.     return isVisible;  
  285. }  
  286.    
  287. public bool _TraceFilter(int entity, int contentsMask)  
  288. {  
  289.     if (!entity || entity <= MaxClients || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit  
  290.     {  
  291.         return false;  
  292.     }  
  293.     return true;  
  294. }  
  295. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to &#36798;&#26031;*&#32500;&#36798;  
  296. {  
  297.     float victim_origin[3];  
  298.     char rupture[32];  
  299.     char damage_victim[32];  
  300.     IntToString(damage, rupture, sizeof(rupture));  
  301.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);  
  302.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);  
  303.     int entity = CreateEntityByName("point_hurt");  
  304.     DispatchKeyValue(victim, "targetname", damage_victim);  
  305.     DispatchKeyValue(entity, "DamageTarget", damage_victim);  
  306.     DispatchKeyValue(entity, "Damage", rupture);  
  307.     DispatchSpawn(entity);  
  308.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);  
  309.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);  
  310.     DispatchKeyValue(entity, "classname", "point_hurt");  
  311.     DispatchKeyValue(victim, "targetname", "null");  
  312.     AcceptEntityInput(entity, "Kill");  
  313. }  
  314.    
  315. stock bool IsValidClient(int client)  
  316. {  
  317.     if ( client < 1 || client > MaxClients ) return false;  
  318.     if( !IsClientInGame(client)) return false;  
  319.     if ( !IsPlayerAlive( client )) return false;  
  320.     return true;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top