Opened 11 years ago

Closed 10 years ago

Last modified 4 years ago

#1902 closed enhancement (fixed)

[PATCH] Color hero icon based on health

Reported by: fabio Owned by: Michael
Priority: Nice to Have Milestone: Alpha 16
Component: UI & Simulation Keywords: simple patch
Cc: Pureon Patch:

Description (last modified by leper)

It would be nice to have the hero icon become reddish when his health is low. Similar to the building icon when you have not enough resources to build them.

Attachments (5)

test1.zip (15.3 KB ) - added by MishFTW 11 years ago.
Session.js and session.xml with lines added
hero_colors.diff (1.5 KB ) - added by sanderd17 11 years ago.
savegame_hero_health_overlay_test.0adsave (1.1 MB ) - added by Michael 10 years ago.
Save game to test the new hero features. (r14504)
hero_health.patch (11.5 KB ) - added by Michael 10 years ago.
Hero healthbar and faded color overlay in case of attack.
hero_health_v2.patch (12.3 KB ) - added by Michael 10 years ago.
Adapted coding style on sanderd17's recommendation.

Download all attachments as: .zip

Change History (32)

comment:1 by Kieran P, 11 years ago

Milestone: BacklogAlpha 14

comment:2 by historic_bruno, 11 years ago

What about something blinking? That could be annoying if done improperly (so we do it tastefully ;)) but is more attention grabbing than a color change alone. A sound would also be helpful, some kind of horn or unique battle-type sound.

comment:3 by leper, 11 years ago

Component: Core engineUI & Simulation
Description: modified (diff)
Keywords: simple added
Summary: color hero icon based on healtColor hero icon based on health

in reply to:  2 comment:4 by zoot, 11 years ago

Replying to historic_bruno:

What about something blinking? That could be annoying if done improperly (so we do it tastefully ;))

I think a 'pulsating' effect would be tasteful, and in line with what other games do. Unfortunately, I don't think this can currently be done with the existing GUI engine?

comment:6 by MishFTW, 11 years ago

Owner: set to MishFTW
Status: newassigned

comment:7 by MishFTW, 11 years ago

Need to upload a patch now. Was a trivial change in session.xml and session.js

comment:9 by historic_bruno, 11 years ago

Any progress on this, Geek377?

comment:10 by Kieran P, 11 years ago

Milestone: Alpha 14Alpha 15

comment:11 by historic_bruno, 11 years ago

Milestone: Alpha 15Backlog

comment:12 by historic_bruno, 11 years ago

Owner: MishFTW removed
Status: assignednew

comment:13 by MishFTW, 11 years ago

Keywords: review added
Milestone: BacklogAlpha 14
Owner: set to MishFTW
Status: newassigned

Sorry got back from vacation and was sorting through stuff. So this basically adds an overlay in the XML file which remains hidden unless the hero's health hits 50% or below.

JS new lines added: 477-479; XML new lines: 796

by MishFTW, 11 years ago

Attachment: test1.zip added

Session.js and session.xml with lines added

by sanderd17, 11 years ago

Attachment: hero_colors.diff added

comment:14 by sanderd17, 11 years ago

Next time it's better if you add a diff (a lot smaller, easier to review, and easier to apply).

As for the change itself, IMHO, becoming red when below 50% health is a bit quick. I'd probably change it to orange first, and red only when it's below 25, or even lower.

comment:15 by historic_bruno, 11 years ago

Keywords: patch added
Summary: Color hero icon based on health[PATCH] Color hero icon based on health

The overlay should be re-hidden if the hero's health returns to above the threshold (from healing or regen).

I agree with sanderd17 that the red overlay may be overkill at 50% health. But it's also ugly and doesn't really catch my eye, would we be better showing a health bar, and blending it from green to red or something as health decreases?

comment:16 by sanderd17, 11 years ago

To have colour changing by health, this would be a nice formula:

var hpp = heroState.hitpoints / heroState.maxHitpoints;
var red = 255;
var green = 255;
if (hpp > 0.5)
    red = Math.round((1-hpp)*2*255);
else 
    green = Math.round(hpp*2*255);

getGUIObjectByName('heroOverlay').sprite="colour: "+red+" "+green+" 0 60";

Then it will go smoothly from green over yellow and orange to red (at 50%, it will be yellow). As for where to use that colour (as overlay, or on a health bar), I don't really have an opinion without seeing the different options. But the current one does look a bit weird indeed.

Last edited 11 years ago by sanderd17 (previous) (diff)

in reply to:  16 ; comment:17 by MishFTW, 11 years ago

I agree with sanderd. I simply uploaded the work I did way back and thats how it was specified. I like the idea of gradual change of overlay color better than an additional bar. It does not create clutter and it conveys subtle but noticeable message to the player.

comment:18 by sanderd17, 11 years ago

Following specifications isn't always needed. maybe it looks better when the opacity is lighter or something. Can you pull off something nice for A14 (I think we should also ask an artist to comment on this)?

in reply to:  17 comment:19 by historic_bruno, 11 years ago

Cc: Pureon added

Replying to Geek377:

I agree with sanderd. I simply uploaded the work I did way back and thats how it was specified. I like the idea of gradual change of overlay color better than an additional bar. It does not create clutter and it conveys subtle but noticeable message to the player.

It wouldn't be clutter, only a few pixels on the side, the same style as the health status bars in the unit details panel. The bonus is it would indicate the exact health level without obscuring the hero portrait :)

comment:20 by leper, 11 years ago

Milestone: Alpha 14Alpha 15

comment:21 by leper, 10 years ago

Keywords: design added; review removed
Milestone: Alpha 15Backlog

comment:22 by Michael, 10 years ago

I added a patch which

  • adds a health bar to the hero
  • creates a faded colour overlay in case the hero gets attacked

Any comments on this ?

comment:23 by Michael, 10 years ago

Keywords: review added
Milestone: BacklogAlpha 16
Owner: changed from MishFTW to Michael
Status: assignednew

by Michael, 10 years ago

Save game to test the new hero features. (r14504)

by Michael, 10 years ago

Attachment: hero_health.patch added

Hero healthbar and faded color overlay in case of attack.

comment:24 by Michael, 10 years ago

@sanderd17: (Checking, if heros health changed; see session.js: var g_heroHitpoints)

It should be possible to get the change of the health points using the AttackDetection class but I think this might be an overkill because it would have to loop always through the list of all ongoing attacks.

The minimap notification is handeled by the Engine. (see AttackDetection.js :35)

Last edited 10 years ago by Michael (previous) (diff)

by Michael, 10 years ago

Attachment: hero_health_v2.patch added

Adapted coding style on sanderd17's recommendation.

comment:25 by sanderd17, 10 years ago

Resolution: fixed
Status: newclosed

In 14525:

Fix code style of files committed too soon in r14524
Adds blinking overlay to ther hero icon when he's attacked
Adds a health bar to the hero icon
Fixes #1902
Patch by boeseRaupe

comment:26 by sanderd17, 10 years ago

Keywords: review design removed

comment:27 by elexis, 4 years ago

In 23089:

Decouple panel entities code from session code and use class notation, refs #5387, #3000, #1902, #1802, rP18361.

Change the logic to only insert/delete buttonhandlers on ownershipchange and update only the entitystate dependent part on simulation update.

Differential Revision: https://code.wildfiregames.com/D2387

Note: See TracTickets for help on using tickets.