Quick HUD question

General discussion for players of Oolite.

Moderators: winston, another_commander

User avatar
ClassicPCGames101
Above Average
Above Average
Posts: 17
Joined: Wed May 06, 2015 1:16 pm

Quick HUD question

Post by ClassicPCGames101 »

Just a quick question about the Heads Up Display:

Is there a HUD that gives a visual signal if your lasers hit the target? - I often play in the living room and the missus and the kids are fed up with the noise, but also the missus gets annoyed if I wear headphones (on account of the fact that I will be unable to hear her continuous intelligent stream of thoughts).
Why are pirates called pirates ... because they AARGH!
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: Quick HUD question

Post by another_commander »

It is not exactly a HUD, but Custom Shields OXP does give a very visible indication of lasers hitting. Like in the screenie below:
Image
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Quick HUD question

Post by Smivs »

ClassicPCGames101 wrote:
...the missus...I will be unable to hear her continuous intelligent stream of thoughts).
You know, I completely understand.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2453
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Quick HUD question

Post by Wildeblood »

ClassicPCGames101 wrote:
Is there a HUD that gives a visual signal if your lasers hit the target?
Is there a JS event for that?
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Quick HUD question

Post by phkb »

Wouldn't shipTakingDamage handle that?

Code: Select all

this.shipTakingDamage = function(amount, whom, type)
{
     // Your code here
}
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Quick HUD question

Post by Norby »

The shipTakingDamage handler is not called for all ships, in worldScript for the player ship only, in ship scripts for the ship which use the script.

You can insert a custom code into the ship's script in shipSpawned worldScript event (as the mentioned customshields do this also) but you must save the original shipTakingDamage and call at the end of your new function.

There is an example of using code insertion in the [wiki]Scanner Alerting Enhancement[/wiki] OXP by jh145:

Code: Select all

  var pss = player.ship.script;
  this._oldSTA = pss.shipTargetAcquired;
  if (this._oldSTA === undefined) this._oldSTA = function(target) { return; }

  pss.shipTargetAcquired = function(target) {
    var ws = worldScripts['jh145_04_world'];
    if (ws._entityToWatch(target)) ws._updateScannerDisplayColour(target,ws._TARGETED);
    ws._oldSTA(target);
  }
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2453
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Quick HUD question

Post by Wildeblood »

Okay, I'm a bit more awake now... shipAttackedOther surely. But that also gets called for missiles and such, so there's at least one conditional involved... then you want to display the, let's call it "beep" for now, for a moment that is longer than a single frame so a timer or frame callback is needed. There are your first two three design decisions:-

How long should beep appear? 1/2 second? 1/4 second?
Use JS timer or frame callback?
If another hit occurs during beep, do you reset timer to extend beep?

Hmm, this reference only mentions laser hits for triggering shipAttckedOther, but that is not my recollection from my previous attempt to use it years ago...?
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Quick HUD question

Post by Smivs »

No idea if this would work, but possibly a script to detect when 'laserhits.ogg' (the sound you get when you do hit a target) is triggered using the 'isPlaying' property, and then the script could trigger a HUD feature.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2453
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Quick HUD question

Post by Wildeblood »

Smivs wrote:
...the script could trigger a HUD feature.
Changing the cross-hairs seems appropriate to me. I can add this into Auto Crosshairs OXZ if it can be done without being more trouble than it's worth.

P.S. I've found my previous experiment with shipAttackedOther:

https://bb.oolite.space/viewtopic.php?f=3&t=12491
User avatar
ClassicPCGames101
Above Average
Above Average
Posts: 17
Joined: Wed May 06, 2015 1:16 pm

Re: Quick HUD question

Post by ClassicPCGames101 »

Wildeblood wrote:
Smivs wrote:
...the script could trigger a HUD feature.
Changing the cross-hairs seems appropriate to me. I can add this into Auto Crosshairs OXZ if it can be done without being more trouble than it's worth.

P.S. I've found my previous experiment with shipAttackedOther:

https://bb.oolite.space/viewtopic.php?f=3&t=12491
I'm going to give the custom shields a go but a flash or colour change to the crosshairs when you hit (even better if you're on target) would be great in my silent ooniverse.
Why are pirates called pirates ... because they AARGH!
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Quick HUD question

Post by Cody »

ClassicPCGames101 wrote:
... or colour change to the crosshairs when you hit (even better if you're on target) would be great in my silent ooniverse.
Doesn't the Scanner Targeting Enhancement turn the target reticle red when on target?
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Quick HUD question

Post by cim »

Smivs wrote:
No idea if this would work, but possibly a script to detect when 'laserhits.ogg' (the sound you get when you do hit a target) is triggered using the 'isPlaying' property, and then the script could trigger a HUD feature.
This wouldn't work - isPlaying checks if that particular sound source is playing, not if any sound source using that source file is playing, and the various built in sounds use sources not accessible to JS.
Cody wrote:
Doesn't the Scanner Targeting Enhancement turn the target reticle red when on target?
Only if by HUD settings or JS that option has been turned on - and even then it's not a completely accurate indicator at long range.
User avatar
ClassicPCGames101
Above Average
Above Average
Posts: 17
Joined: Wed May 06, 2015 1:16 pm

Re: Quick HUD question

Post by ClassicPCGames101 »

Cody wrote:
ClassicPCGames101 wrote:
... or colour change to the crosshairs when you hit (even better if you're on target) would be great in my silent ooniverse.
Doesn't the Scanner Targeting Enhancement turn the target reticle red when on target?
I found the auto crosshairs OZP and it works well on local station traffic, haven't tried it in combat yet.
Why are pirates called pirates ... because they AARGH!
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Quick HUD question

Post by Cody »

cim wrote:
Only if by HUD settings or JS that option has been turned on - and even then it's not a completely accurate indicator at long range.
Ah yes, I often forget that it's not the default in core kit - and yes, it ain't reliably accurate.
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
ClassicPCGames101
Above Average
Above Average
Posts: 17
Joined: Wed May 06, 2015 1:16 pm

Re: Quick HUD question

Post by ClassicPCGames101 »

ClassicPCGames101 wrote:

I found the auto crosshairs OZP and it works well on local station traffic, haven't tried it in combat yet.
Erm well it's not too accurate at long distance, the Custom Shields is working well though.
Why are pirates called pirates ... because they AARGH!
Post Reply