Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dir_to_npc = npc:position():sub(db.actor:position())
- local actor_dir = device().cam_dir
- --dir_to_npc.y = 0
- --actor_dir.y = 0
- --local angle = ((dir_to_npc.x * actor_dir.x) + (dir_to_npc.z * actor_dir.z)) / (math.sqrt(dir_to_npc.x^2 + dir_to_npc.z^2) * math.sqrt(actor_dir.x^2 + actor_dir.z^2))
- --angle = (math.acos(angle) * 180) / math.pi
- local angleX = tools.get_horizontal_angle(dir_to_npc, actor_dir)
- local angleY = tools.get_vertical_angle(dir_to_npc, actor_dir)--tools.get_horizontal_angle(dir_to_npc, actor_dir)
- local img_name = "hud_indicator"
- local hud = get_hud()
- local custom_static = hud:GetCustomStatic(img_name)
- local centre_x = 512
- local centre_y = 384
- local modif = 50 -- more or less both max X camera angle and Y camera angle, determined through observation
- angleX = math.max(-modif, angleX)
- angleY = math.max(-modif, angleY)
- angleX = math.min(modif, angleX)
- angleY = math.min(modif, angleY)
- angleX = angleX + modif
- angleY = angleY + modif
- local x_max = 1024
- local y_max = 768
- local current_x_position = (x_max/(2*modif) * angleX) - 16 --the indicator is 32x32
- current_x_position = math.max(0, current_x_position)
- current_x_position = math.min(x_max-32, current_x_position)
- local current_y_position = (y_max - (y_max/(2*modif) * angleY)) - 16 --the indicator is 32x32
- current_y_position = math.max(0, current_y_position)
- current_y_position = math.min(y_max-32, current_y_position)
- --current_y_position = y_max - current_y_position
- --error_log("Height = "..tostring(device().height))
- --error_log("Width = "..tostring(device().width))
- --error_log("Top = "..tostring(tools.get_vertical_angle(device().cam_top, actor_dir)))
- --error_log("Right = "..tostring(tools.get_horizontal_angle(device().cam_right, actor_dir)))
- --error_log(string.format("%s, %s, %s", tostring(device().cam_top.x), tostring(device().cam_top.y), tostring(device().cam_top.z)))
- if custom_static == nil then
- hud:AddCustomStatic(img_name)
- custom_static = hud:GetCustomStatic(img_name)
- end
- if custom_static then
- custom_static:wnd():SetWndPos(vector2():set(current_x_position,current_y_position))
- end
Add Comment
Please, Sign In to add comment