
Let's say if enemies run into the "front"(red area) of the player, then they will get killed. Otherwise nothing happens.
Scripts
Define the back or the front of player
Define the back or the front of player
1


§5.3 - No memes, ASCII art or comparable fun pictures function findPlyAngle(ply1,ply2)
	local x1,y1=player(ply1,"x"),player(ply1,"y")
	local x2,y2=player(ply2,"x"),player(ply2,"y")
	local ang=-math.deg(math.atan2(x1-x2,y1-y2))
	return ang
end
function isInFront(ply1,ply2,f) --ply1 is the player in front of ply2
	local ang=findPlyAngle(ply1,ply2)
	local rot2=player(ply2,"rot")
	if rot2>180 then
		rot2=player(ply2,"rot")-180
	end
	if ang>=rot2-f and ang<=rot2+f then
		return true
	end
	return false
end
addhook("ms100","checkforinfront")
function checkforinfront()
	for _,id in pairs(player(0,"table")) do
		for _,iid in pairs(player(0,"table")) do
			if id~=iid then
				if isInFront(iid,id,45) then
					parse("customkill "..id.." Magic "..iid)
				end
			end
		end
	end
end
function normalizerad(r) 	if r>math.pi then 		r = -math.pi+r%math.pi 	elseif r<-math.pi then 		r = math.pi-(math.pi-r%math.pi) 	end 	return r end function torad(degrees) 	return normalizerad(math.rad(degrees+90)) end local fovw = 120 local fovd = 60 fovconst = math.atan2(fovw/2,fovd) --fovconst is pi/2 (or 90 degrees) function isinplayerfov(id,x,y) 	local a = math.atan2(player(id,"y")-y,player(id,"x")-x) 	local rot = torad(player(id,"rot")) 	return (a>(rot-fovconst) and a<(rot+fovconst)) end
Flacko's code is much better - use it instead.
function normalizerad(r) 	if r>math.pi then 		r = -math.pi+r%math.pi 	elseif r<-math.pi then 		r = math.pi-(math.pi-r%math.pi) 	end 	return r end function torad(degrees) 	return normalizerad(math.rad(degrees+90)) end local fovw = 120 local fovd = 60 fovconst = math.atan2(fovw/2,fovd) function isinplayerfov(id,x,y) 	local a = math.atan2(player(id,"y")-y,player(id,"x")-x) 	local rot = torad(player(id,"rot")) 	local dif = normalizerad(rot-a) 	return math.abs(dif)<fovconst end

fovconst = math.atan2(fovw/2,fovd)
local a = math.atan2(player(id,"y")-y,player(id,"x")-x)
local rot = torad(player(id,"rot"))
local dif = normalizerad(rot-a) return math.abs(dif)<fovconst
1
