-- Script to animate entity when not looking at it g_StatueWait = {} function ai_moveunseen_init(e) g_StatueWait[e] = 0 end function ai_moveunseen_main(e) -- Finds the veiwing angle difference to the entity dx = g_Entity[e]['x'] - g_PlayerPosX dz = g_Entity[e]['z'] - g_PlayerPosZ da = (math.atan2(dx,dz) / 6.28) * 360 plra = g_PlayerAngY if plra < 0 then plra = plra + 360 end if plra >= 360 then plra = plra - 360 end diffa = plra - da if diffa < 0 then diffa = diffa + 360 end if diffa > 180 then diffa = diffa - 360 end Playerdist = GetPlayerDistance(e) if diffa < -45 or diffa > 45 then --move the creature towards the player if Playerdist > 50 then RotateToPlayerSlowly(e, 10.0) MoveForward(e, 100.0) end else if Playerdist <= 50 then --kill the player if GetTimer(e) > g_StatueWait[e] then HurtPlayer(e, 1) g_StatueWait[e] = GetTimer(e) + 100 end end end Prompt('aimoveunseen - ' .. Playerdist) end