for (local particle; particle = Entities.FindByName(particle, "__antiparticle*");)
	EntFireByHandle(particle, "Kill", "", -1, null, null)

::antiparticlespawner <- Entities.CreateByClassname("trigger_particle")
antiparticlespawner.KeyValueFromInt("spawnflags", 64)
antiparticlespawner.KeyValueFromString("targetname",  "__antiparticle")

local function SpawnParticle(entity, name, attach_name, attach_type)
{
	NetProps.SetPropString(antiparticlespawner, "m_iszParticleName", name)
	NetProps.SetPropString(antiparticlespawner, "m_iszAttachmentName", attach_name)
	NetProps.SetPropInt(antiparticlespawner, "m_nAttachType", attach_type)
	antiparticlespawner.AcceptInput("StartTouch", "", entity, entity)
}

::antiparticle <- Entities.CreateByClassname("logic_relay")
antiparticle.KeyValueFromString("targetname",  "__antiparticle_dummy")
antiparticle.ValidateScriptScope()

antiparticle.GetScriptScope().AntiRocketParticleThink <- function()
{
	for (local proj; proj = Entities.FindByClassname(proj, "tf_projectile_rocket");)
	{
		if (proj.IsEFlagSet(2097152) || proj.GetTeam() == 2)
			continue

		NetProps.SetPropBool(proj, "m_bForcePurgeFixedupStrings", true)
		proj.AddEFlags(2097152)
		proj.AcceptInput("DispatchEffect", "ParticleEffectStop", null, null)
		SpawnParticle(proj, "flare_glow", "", 1)
	}
	return -1
}

AddThinkToEnt(antiparticle, "AntiRocketParticleThink")

printl("============== Anti rocket particles enabled ===========")