Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include sdkhooks
- #pragma tabsize 0
- float GrenadeDamage = 1000.0
- float PipeBombDamage = 1000.0
- float BarrelDamage = 1000.0
- float GrenadeRadius = 500.0
- float PipeRadius = 500.0
- float BarrelRadius = 500.0
- bool IsAllow = false;
- public OnMapStart()
- {
- IsAllow = false;
- CreateTimer(3.0, allow)
- }
- public Action allow(Handle timer)
- {
- IsAllow = true;
- }
- public void OnEntityDestroyed(int entity)
- {
- if(!IsAllow) return;
- if (IsValidEntity(entity) && IsValidEdict(entity))
- {
- char classname[128];
- GetEdictClassname(entity, classname, 128);
- if (StrEqual(classname, "grenade_launcher_projectile", false))
- {
- GrenadeTouch(entity);
- }
- if (StrEqual(classname, "pipe_bomb_projectile", false))
- {
- BombTouch(entity);
- }
- if (StrEqual(classname, "prop_fuel_barrel", false))
- {
- BarrelTouch(entity);
- }
- }
- }
- public int GrenadeTouch(int entity)
- {
- float pos[3];
- GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
- GranadeExplode(pos);
- }
- public int BombTouch(int entity)
- {
- float pos[3];
- GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
- BombExplode(pos)
- }
- public int BarrelTouch(int entity)
- {
- float pos[3];
- GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
- BarrelExplode(pos);
- }
- int GranadeExplode(float pos[3])
- {
- float fDistance = 0.0;
- float pos2[3];
- for( int i = 0; i < 32; i++ )
- {
- if(IsValidClient(i) && GetClientTeam(i) == 3)
- {
- int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
- if(vClass == 6)
- {
- GetClientAbsOrigin(i, pos2);
- fDistance = GetVectorDistance(pos, pos2);
- if(fDistance < GrenadeRadius)
- {
- float iOne = GrenadeRadius - fDistance
- float vForward = GrenadeRadius / iOne
- int iDamage = RoundToCeil(GrenadeDamage / (vForward * vForward))
- ForceDamageEntity(i, iDamage, i)
- }
- }
- }
- }
- }
- int BombExplode(float pos[3])
- {
- float fDistance = 0.0;
- float pos2[3];
- for( int i = 0; i < 32; i++ )
- {
- if(IsValidClient(i) && GetClientTeam(i) == 3)
- {
- int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
- if(vClass == 6)
- {
- GetClientAbsOrigin(i, pos2);
- fDistance = GetVectorDistance(pos, pos2);
- if(fDistance < PipeRadius)
- {
- float iOne = PipeRadius - fDistance
- float vForward = PipeRadius / iOne
- int iDamage = RoundToCeil(PipeBombDamage / (vForward * vForward))
- ForceDamageEntity(i, iDamage, i)
- }
- }
- }
- }
- }
- int BarrelExplode(float pos[3])
- {
- float fDistance = 0.0;
- float pos2[3];
- for( int i = 0; i < 32; i++ )
- {
- if(IsValidClient(i) && GetClientTeam(i) == 3)
- {
- int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
- if(vClass == 6)
- {
- GetClientAbsOrigin(i, pos2);
- fDistance = GetVectorDistance(pos, pos2);
- if(fDistance < BarrelRadius)
- {
- float iOne = BarrelRadius - fDistance
- float vForward = BarrelRadius / iOne
- int iDamage = RoundToCeil(BarrelDamage / (vForward * vForward))
- ForceDamageEntity(i, iDamage, i)
- }
- }
- }
- }
- }
- stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
- {
- float victim_origin[3];
- char rupture[32];
- char damage_victim[32];
- IntToString(damage, rupture, sizeof(rupture));
- Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
- GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
- int entity = CreateEntityByName("point_hurt");
- DispatchKeyValue(victim, "targetname", damage_victim);
- DispatchKeyValue(entity, "DamageTarget", damage_victim);
- DispatchKeyValue(entity, "Damage", rupture);
- DispatchSpawn(entity);
- TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
- AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
- DispatchKeyValue(entity, "classname", "point_hurt");
- DispatchKeyValue(victim, "targetname", "null");
- AcceptEntityInput(entity, "Kill");
- }
- stock bool:IsValidClient(client)
- {
- if ( client < 1 || client > MaxClients ) return false;
- if ( !IsClientConnected( client )) return false;
- if ( !IsClientInGame( client )) return false;
- if ( GetClientTeam( client ) != 3 ) return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment