is it possible to detect whether a NPC sighted a Player (attacking, moving to him) or not? One simple idea would be to check if they were moving or not, but they juyt could be stuck behind an obstacle.
Thank you in advance!
addhook("objectdamage","NPCHealth") function NPCHealth(id,damage) if (object(id,"type") == 30) then 	 local hp = object(id,"health") 	 local dm = damage 	 local hpdm = hp - dm 	 msg(hpdm) end end
constants 				= {}; constants.ScreenWidth 	= 640; constants.ScreenHeight 	= 480; function AbsoluteHud(hudid, txt, pid, x, y) 	local x_player = player(pid, "x"); 	local y_player = player(pid, "y"); 	local x_left 	= x_player-constants.ScreenWidth/2; 	local x_right 	= x_player+constants.ScreenWidth/2; 	local y_top 	= y_player-constants.ScreenHeight/2; 	local y_bottom 	= y_player+constants.ScreenHeight/2; 	 	if 	( 		x < x_left or x > x_right 		or 		y < y_top or y > y_bottom 	) 	then 		return false; -- not in players view 	end 	local relative_x = x - x_left; 	local relative_y = y - y_top; 	parse("hudtxt2 "..pid.." "..hudid.." \""..txt.."\" "..relative_x.." "..relative_y.." 1"); --centered hudtxt2 	 	return true; end --Example usage print("Example"); addhook("hit", "example_hit"); function example_hit(id, src, wpn, hp_dmg) 	--Is player? 	if (src <= 0 and src > 32) then return 0; end; 	 	--Show damage done to attacker on victims position 	AbsoluteHud(0, tostring(hp_dmg), src, player(id, "x"), player(id, "y")); end
addhook("objectdamage","NPCHealth") function NPCHealth(id,damage, src) if (object(id,"type") == 30 and src > 0) then local hp = object(id,"health") local dm = damage local hpdm = hp - dm AbsoluteHud(0, tostring(hpdm), src, object(id, "x"), object(id, "y")); end end
huddata = {}; huddata.objectid = {}; huddata.data = {}; --bring hud to screen (location depends foreach player) addhook("ms100", "ichbinflummidasreh"); function ichbinflummidasreh() 	for i = 0, 49 do 		if (huddata.objectid[i] ~= nil) then 			for pid = 1, 32 do 			AbsoluteHud(i, huddata.data[i], pid, object(huddata.objectid[i], "x"), object(huddata.objectid[i], "y") ); 			end 		end 	end end --update hud data addhook("objectdamage","NPCHealth") function NPCHealth(id,damage, src) if (object(id,"type") == 30 and src > 0) then local hp = object(id,"health") local dm = damage local hpdm = hp - dm 	for i = 0, 49 do 		if (huddata.objectid[i] == nil) then 			huddata.objectid[i] = id; 			huddata.data[i] = tostring(hpdm); 			break; 		end 	end end end --Free object from hudlist addhook("objectkill", "oblivioninmyass"); function oblivioninmyass(obj) 	for i = 0, 49 do 		if (huddata.objectid[i] ~= nil) then 			if (huddata.objectid[i] == obj) then 				huddata.objectid[i] = nil; 				for pid = 1, 32 do parse("hudtxt2 "..pid.." "..i.."\"\" 0 0"); end; --remove old hudtxt 				break; 			end 		end 	end end