MilHUD problem

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2028
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

MilHUD problem

Post 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.
User avatar
Palmski
Dangerous
Dangerous
Posts: 68
Joined: Fri Apr 09, 2010 8:18 am

Post 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:
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2028
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Post 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?
User avatar
Palmski
Dangerous
Dangerous
Posts: 68
Joined: Fri Apr 09, 2010 8:18 am

Post 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?
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post 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.
User avatar
Palmski
Dangerous
Dangerous
Posts: 68
Joined: Fri Apr 09, 2010 8:18 am

Post 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?
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post 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.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post 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.
Post Reply