Advertisement
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
- 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, "y_max -" because angle is 0 if at the bottom of the screen and Y of the screen is 0 at the top
- current_y_position = math.max(0, current_y_position)
- current_y_position = math.min(y_max-32, current_y_position)
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement