//special thanks to Golden, Ors, and Nightwolf
local function nomissile(actor)
	// possibly choose another target
	if (multiplayer and not actor.threshold and (actor.target.health <= 0 or not P_CheckSight(actor, actor.target))
		and P_LookForPlayers(actor, 0, true, false))
		return // got a new target
	end
	// chase towards player
	actor.movecount = $1 - 1 
	if (actor.movecount < 0 or not P_Move(actor, actor.info.speed))
		P_NewChaseDir(actor)
	end
end
function A_PlasmaChase(actor)
	local delta
	if not actor.target
	return
	end

	assert(actor)
	assert(actor.valid)
	actor.reactiontime = actor.info.reactiontime

	// modify target threshold
	if (actor.threshold)
		if (not actor.target or actor.target.health <= 0)
			actor.threshold = 0
		else
			actor.threshold = $1 - 1
		end
	end
	// turn towards movement direction if not there yet
	if (actor.movedir < NUMDIRS)
		actor.angle = $1 & (7<<29)
		delta = actor.angle - (actor.movedir << 29)

		if (delta > 0)
			actor.angle = $-ANGLE_45
		elseif (delta < 0)
			actor.angle = $+ANGLE_45
		end
	end
	if (not actor.target or not (actor.target.flags & MF_SHOOTABLE))
		// look for a new target
		if (P_LookForPlayers(actor, 0, true, false))
			return // got a new target
		end

		P_SetMobjStateNF(actor, actor.info.spawnstate)
		return
	end
	// do not attack twice in a row
	if (actor.flags2 & MF2_JUSTATTACKED)
		actor.flags2 = $1 & ~MF2_JUSTATTACKED
		P_NewChaseDir(actor)
		return
	end
	nomissile(actor)
end