Page 1 of 1

MilHUD problem

Posted: Mon Sep 06, 2010 4:06 pm
by maik
I just swapped ships for the first time and was flying around in an Adder. MilHUD seems to get confused by low normal shield levels, it switches to Critical Condition immediately. Is there a chance I can get a warranty replacement? This is on Oolite 1.74.2 with MilHUD 3.4. No relevant messages in the log file.

Posted: Tue Sep 07, 2010 7:01 am
by Palmski
I believe it's to do with this line in the script.js:

Code: Select all

player.ship.energy < 109
My "Condition Critical" HUD kicks in when I've still got a 1/4 bar of E4 (of 5) left. It didn't bother me especially (it meant I got to see my animated HUD more often :lol: ) so I just left it.

I suggest tweaking the 109 value downwards until you find a value which works for you. Don't forget to change the snippets

Code: Select all

player.ship.energy > 108
as well so they are consistent though :wink:

Posted: Tue Sep 07, 2010 8:16 am
by maik
Cool, thanks! Is there a way to automate this, i.e. make it relative to the ship's max energy instead of giving it an absolute value?

Posted: Tue Sep 07, 2010 8:25 am
by Palmski
I was wondering the self same thing actually. However I cannot find any reference on the wiki to the player.ship.energy property let alone anything indicating a maximum value so that you could use a ratio. Even that likely wouldn't help on the face of it as you would need to take into account the number of energy bars a ship displays to work out what the value for 1 bar might be. I don't know if anyone more familiar with the API can comment?

Posted: Tue Sep 07, 2010 9:06 am
by Thargoid
Yes there is, using player.ship.energy and player.ship.maxEnergy.

The references you seek are in the wiki JS page for entities. The player ship is a specific sub-set of the general ship entries, which in turn are a sub-set of the generic ones for entities.

If I remember correctly each energy bar is 64 energy units. The number of bars is determined by the setting for maxEnergy.

Posted: Tue Sep 07, 2010 10:40 am
by Palmski
Thanks, looked in PlayerShip and Ship but didn't realise the Entity superclass existed :)

I'll have a play tonight and see if I can work something out, should not be hard.

I'm curious then, as you wrote the original hud switching script what made you choose 109 as the OMGWTFBBQ threshold?

Posted: Tue Sep 07, 2010 11:05 am
by Thargoid
There was a reason, but I must admit I don't remember offhand. It was certainly set high enough that it didn't get in the way of items like the Emergency Energy Unit or the Auto-Escape Pod, especially as it's more of a visual warning than anything else.

Really just to give the player warning in enough time that they can do something about things rather than just letting them know they're imminently going to die.

Posted: Tue Sep 07, 2010 2:21 pm
by Commander McLane
Thargoid wrote:
There was a reason, but I must admit I don't remember offhand. It was certainly set high enough that it didn't get in the way of items like the Emergency Energy Unit or the Auto-Escape Pod, especially as it's more of a visual warning than anything else.
The auto eject fires if(player.ship.energy < 22), which is one third of your last energy bank. Obviously the HUD should change before that point is reached.