Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include sdkhooks
- #pragma tabsize 0
- float iGrenade = 1000.0
- float iPipe = 1000.0
- float iBarrel = 1000.0
- float iRadiusG = 440.0
- float iRadiusP = 440.0
- float iRadiusB = 440.0
- public void OnEntityDestroyed(int entity)
- {
- if (IsValidEntity(entity) && IsValidEdict(entity))
- {
- char classname[128];
- GetEdictClassname(entity, classname, 128);
- if (StrEqual(classname, "grenade_launcher_projectile", false))
- {
- float bPos[3]
- GetEntPropVector(entity, Prop_Send, "m_vecOrigin", bPos);
- for (new i = 33; i <= 2048; i++)
- {
- if(IsCommonInfected(i))
- {
- float vPos[3]
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
- if (!IsVisibleTo(bPos, vPos)) continue;
- int iCreator = GetEntPropEnt(entity, Prop_Send, "m_hThrower")
- float fTargetDistance = GetVectorDistance(bPos, vPos);
- if(fTargetDistance < iRadiusG)
- {
- float vTransit = iRadiusG - fTargetDistance
- float vForward = iRadiusG / vTransit
- int iTotal = RoundToCeil(iGrenade / (vForward * vForward * vForward));
- ForceDamageEntity(iCreator, iTotal, i)
- }
- }
- }
- }
- if (StrEqual(classname, "pipe_bomb_projectile", false))
- {
- float bPos[3]
- GetEntPropVector(entity, Prop_Send, "m_vecOrigin", bPos);
- for (new i = 33; i <= 2048; i++)
- {
- if(IsCommonInfected(i))
- {
- float vPos[3]
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
- if (!IsVisibleTo(bPos, vPos)) continue;
- int iOwner = GetEntPropEnt(entity, Prop_Send, "m_hThrower")
- float fTargetDistance = GetVectorDistance(bPos, vPos);
- if(fTargetDistance < iRadiusP)
- {
- float vTransit = iRadiusP - fTargetDistance
- float vForward = iRadiusP / vTransit
- int iTotal = RoundToCeil(iPipe / (vForward * vForward * vForward));
- ForceDamageEntity(iOwner, iTotal, i)
- }
- }
- }
- }
- if (StrEqual(classname, "prop_fuel_barrel", false))
- {
- float bPos[3]
- GetEntPropVector(entity, Prop_Send, "m_vecOrigin", bPos);
- for (new i = 33; i <= 2048; i++)
- {
- if(IsCommonInfected(i))
- {
- float vPos[3]
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
- if (!IsVisibleTo(bPos, vPos)) continue;
- float fTargetDistance = GetVectorDistance(bPos, vPos);
- if(fTargetDistance < iRadiusB)
- {
- float vTransit = iRadiusB - fTargetDistance
- float vForward = iRadiusB / vTransit
- int iTotal = RoundToCeil(iBarrel / (vForward * vForward * vForward));
- ForceDamageEntity(i, iTotal, 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");
- }
- static bool IsVisibleTo(float position[3], float targetposition[3])
- {
- float vAngles[3], vLookAt[3];
- MakeVectorFromPoints(position, targetposition, vLookAt); // compute vector from start to target
- GetVectorAngles(vLookAt, vAngles); // get angles from vector for trace
- // execute Trace
- Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);
- bool isVisible = false;
- if (TR_DidHit(trace))
- {
- float vStart[3];
- TR_GetEndPosition(vStart, trace); // retrieve our trace endpoint
- if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
- {
- isVisible = true; // if trace ray length plus tolerance equal or bigger absolute distance, you hit the target
- }
- }
- return isVisible;
- }
- public bool _TraceFilter(int entity, int contentsMask)
- {
- if (!entity || entity <= MaxClients || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit
- {
- return false;
- }
- return true;
- }
- stock bool IsCommonInfected(int entity)
- {
- if (entity > 0 && IsValidEntity(entity) && IsValidEdict(entity))
- {
- char entType[64];
- GetEdictClassname(entity, entType, sizeof(entType));
- return StrEqual(entType, "infected");
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement