Author Topic: How to draw an offscreen indicator at an arbitrary position?  (Read 1545 times)

0 Members and 1 Guest are viewing this topic.

Offline Shivan Hunter

  • 210
  • Dead fascists cannot rig elections
How to draw an offscreen indicator at an arbitrary position?
Question in title. gr.drawOffscreenIndicator() takes an Object reference, but I want to draw an indicator pointing towards something that is not an object. I tried creating a waypoint within the script, but gr.drawOffscreenIndicator() seems to do nothing when given a waypoint instead of a ship. I could create an invisible, non-colliding, protected, invulnerable, etc etc dummy ship but that seems... messy af. Is there a workaround?

 

Offline Shivan Hunter

  • 210
  • Dead fascists cannot rig elections
Re: How to draw an offscreen indicator at an arbitrary position?
(I did use the dummy ship solution and it "works" despite the massive train-is-a-hat energy)

Okay, another weird ass bug that I haven't fully tracked down: gr.drawOffscreenIndicator seems to draw an indicator at the wrong screen size (1024x768), but only the first time it is called per frame - the rest conform to the true screen resolution. It only fixes itself once the first incorrect indicator is actually drawn to the screen, so I can't fake it by passing false into the "draw" param, and I can't draw an invisible one because while it can use the gr.setColor(), it ignores the alpha of said color :mad:

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: How to draw an offscreen indicator at an arbitrary position?
In FotG we use gr.drawOffscreenIndicator() with waypoints, though they are almost always already existing waypoints. And could you post screenshots of that bug? I'm not exactly sure I can picture it. Also, if it is easier, feel free to use the scripting channel on the Discord since that is easier to do troubleshooting over :)
 
I'm also going to take a deeper dive into the code to see if there might be issues with it.
« Last Edit: March 14, 2026, 09:25:34 am by wookieejedi »

 

Offline Shivan Hunter

  • 210
  • Dead fascists cannot rig elections
Re: How to draw an offscreen indicator at an arbitrary position?
Looks like it depends on the base resolution of the HUD. Without MediaVPs: (red indicator by the weapons gauge)



And with MediaVPs 5.0.1, with a HUD with a higher base resolution: (above the main reticle)



Attached is a smol test mod including my script. It's basically my own version of the subsystem markbox script, but it shows HP bars even on the opposite side of a ship, shows offscreen indicators (buggy atm lol), and is designed a bit differently.

In all cases, the buggy indicator is the first one rendered in the frame (tested using my TurretHUD:debug() function to print its position and the name of the subsystem). I tried looking at the FSO source to find where the first call changes something that fixes subsequent calls, but my brain exploded.

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: How to draw an offscreen indicator at an arbitrary position?
Thanks, I'm digging around in the code and will test a few things and keep you posted!

 

Offline Shivan Hunter

  • 210
  • Dead fascists cannot rig elections
Re: How to draw an offscreen indicator at an arbitrary position?
Thanks :) Of course it's entirely possible I'm ballsing it up somewhere in the script! Might revisit it a bit later after FREDding a mission or three

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: How to draw an offscreen indicator at an arbitrary position?
Okay I did find one thing the code was missing, so I've made a pull request and ideally it will be reviewed and merged in a few days  :)

 

Offline Shivan Hunter

  • 210
  • Dead fascists cannot rig elections
Re: How to draw an offscreen indicator at an arbitrary position?
Thanks :D :D :D Just tested on the latest nightly and it works!

  

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: How to draw an offscreen indicator at an arbitrary position?
Excellent!