Advertisement
Guest User

Untitled

a guest
Feb 7th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. local dir_to_npc = npc:position():sub(db.actor:position())
  2. local actor_dir = device().cam_dir
  3.  
  4. local angleX = tools.get_horizontal_angle(dir_to_npc, actor_dir)
  5. local angleY = tools.get_vertical_angle(dir_to_npc, actor_dir)--tools.get_horizontal_angle(dir_to_npc, actor_dir)
  6.  
  7. local img_name = "hud_indicator"
  8. local hud = get_hud()
  9. local custom_static = hud:GetCustomStatic(img_name)
  10.  
  11. local centre_x = 512
  12. local centre_y = 384
  13. local modif = 50 -- more or less both max X camera angle and Y camera angle, determined through observation
  14. angleX = math.max(-modif, angleX)
  15. angleY = math.max(-modif, angleY)
  16. angleX = math.min(modif, angleX)
  17. angleY = math.min(modif, angleY)
  18. angleX = angleX + modif
  19. angleY = angleY + modif
  20. local x_max = 1024
  21. local y_max = 768
  22. local current_x_position = (x_max/(2*modif) * angleX) - 16 --the indicator is 32x32
  23. current_x_position = math.max(0, current_x_position)
  24. current_x_position = math.min(x_max-32, current_x_position)
  25. 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
  26. current_y_position = math.max(0, current_y_position)
  27. current_y_position = math.min(y_max-32, current_y_position)
  28.  
  29.  
  30. if custom_static == nil then
  31. hud:AddCustomStatic(img_name)
  32. custom_static = hud:GetCustomStatic(img_name)
  33.  
  34. end
  35. if custom_static then
  36. custom_static:wnd():SetWndPos(vector2():set(current_x_position,current_y_position))
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement