Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- new bool:IsAlreadyInflicted[2048+1] = false;
- #define Electric "electrical_arc_01_system"
- public OnPluginStart()
- {
- HookEvent("infected_hurt", HurtInfected);
- }
- public HurtInfected(Handle:event, const String:name[], bool:dontBroadcast)
- {
- int victim = GetEventInt(event, "entityid");
- int damagetype = GetEventInt(event, "type");
- float vicPos[3], target_distance[3];
- if (damagetype & DMG_BULLET)
- {
- GetEntPropVector(victim, Prop_Send, "m_vecOrigin", vicPos);
- for (int target = 33; target < 2049; target++)
- {
- if (IsCommonInfected(target))
- {
- if(!IsAlreadyInflicted[target])
- {
- GetEntPropVector(target, Prop_Send, "m_vecOrigin", target_distance);
- float fTargetDistance = GetVectorDistance(vicPos, target_distance);
- if (fTargetDistance > 200.0) continue;
- ForceDamageEntity(victim, 1000, target);
- CreateEffect(target);
- IsAlreadyInflicted[target] = true;
- FindNewTarget(target);
- }
- }
- }
- }
- }
- public OnEntityCreated(entity, const char[] classname)
- {
- if(IsCommonInfected(entity))
- {
- IsAlreadyInflicted[entity] = false;
- }
- }
- void CreateEffect(index)
- {
- float index_origin[3];
- GetEntPropVector(index, Prop_Send, "m_vecOrigin", index_origin);
- new iEnt = CreateEntityByName("info_particle_system");
- DispatchKeyValue(iEnt, "start_active", "1");
- DispatchKeyValue(iEnt, "effect_name", Electric);
- TeleportEntity(iEnt, index_origin, NULL_VECTOR, NULL_VECTOR);
- DispatchSpawn(iEnt);
- ActivateEntity(iEnt);
- SetVariantString("!activator");
- AcceptEntityInput(iEnt, "SetParent", index, iEnt);
- AcceptEntityInput(iEnt, "Start");
- }
- 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;
- }
- stock ForceDamageEntity(causer, damage, victim)
- {
- float victim_origin[3];
- new String:rupture[32];
- new String: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);
- new 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 FindNewTarget(zombie)
- {
- new entity = -1;
- while ((entity = FindEntityByClassname(entity, "infected")) != INVALID_ENT_REFERENCE)
- {
- if (entity != zombie && IsAlreadyInflicted[entity])
- {
- float victim_orig[3], index_origin[3]
- GetEntPropVector(zombie, Prop_Send, "m_vecOrigin", index_origin);
- GetEntPropVector(entity, Prop_Send, "m_vecOrigin", victim_orig);
- float fTargetDistance = GetVectorDistance(victim_orig, index_origin);
- if (fTargetDistance > 200.0) continue;
- if (entity != zombie && !IsAlreadyInflicted[entity])
- {
- IsAlreadyInflicted[entity]=true;FindNewTarget(entity);
- ForceDamageEntity(zombie, 1000, entity);
- CreateEffect(zombie);break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment