Advertisement
MjnMixael

Untitled

Feb 3rd, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. #Conditional Hooks
  2.  
  3. $Application: FS2_Open
  4. $On Game Init:
  5. [
  6.  
  7. ert_active = false
  8. function string.filterInvisible(str)
  9. local index = str:find("#", 0, true)
  10.  
  11. if (index ~= nil) then
  12. str = str:sub(1, index - 1)
  13. end
  14.  
  15. return str
  16. end
  17.  
  18. function drawReticle(ship)
  19. local r, g, b = ship.Team:getColor()
  20. gr.setColor(255, 255, 255, 75)
  21.  
  22. local l, t, r, b = gr.drawTargetingBrackets(ship, true)
  23.  
  24. if l ~= nil then
  25. local dist = ship.Position:getDistance(hv.Player.Position)
  26. local distString = string.format("%.0fm", dist)
  27.  
  28. gr.drawString(ship.Name:filterInvisible(), r + 3, t)
  29. gr.drawString(ship.Class.Name:filterInvisible())
  30.  
  31. local hit_x = r + 3
  32. local hit_y = b - gr.CurrentFont.Height
  33. local percentage = ship.HitpointsLeft / ship.HitpointsMax
  34.  
  35. local hitpointsString
  36.  
  37. if (percentage <= 0) then
  38. percentage = 0
  39. end
  40.  
  41. hitpointsString = string.format("%.1f%%", percentage * 100)
  42.  
  43. if (t + 2 * gr.CurrentFont.Height > b - gr.CurrentFont.Height) then
  44. gr.drawString(hitpointsString)
  45. else
  46. gr.drawString(hitpointsString, hit_x, hit_y)
  47. end
  48.  
  49. gr.drawString(distString, r - gr.getStringWidth(distString), b + 3)
  50. end
  51. end
  52.  
  53. function ert_act()
  54. ert_active = true
  55. end
  56.  
  57. function ert_inact()
  58. ert_active = false
  59. end
  60. ]
  61.  
  62. $On Mission Start:
  63. [
  64. ert_active = false
  65. ]
  66.  
  67. $On HUD Draw:
  68. [
  69. if ert_active then
  70. if ert_missiontime == nil then
  71. ert_missiontime = mn.getMissionTime()
  72. ert_oldmissiontime = missiontime
  73. end
  74.  
  75. if ert_missiontime ~= nil then
  76. if hu.HUDDrawn then
  77. ert_missiontime = mn.getMissionTime()
  78.  
  79. if ert_oldmissiontime ~= ert_missiontime then
  80. if mn.EscortShips ~= nil then
  81. local NumberEscorted = #mn.EscortShips
  82. for i= 1,NumberEscorted do
  83. local escortedship = mn.EscortShips[i]
  84. if escortedship.Position:getScreenCoords() ~= false and escortedship ~= hv.Player.Target and escortedship.Team.Name == "Friendly" then
  85. drawReticle(escortedship)
  86. end
  87. end
  88. end
  89. end
  90. end
  91.  
  92. ert_oldmissiontime = ert_missiontime
  93. end
  94. end
  95. ]
  96.  
  97. #End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement