Healthbar for targeted monster

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Healthbar for targeted monster

Post by amv2k9 »

Something I've wanted to do in a mod for quite some time is have a healthbar printed to the screen when you're aiming a weapon at an enemy. I've tried studying jpalomo's JPHUD to figure out how, but since I'm all thumbs when it comes to ACS, I didn't get anywhere.

This was the primary reason for me suggesting what became [wiki]GetSpawnHealth[/wiki]. I know that the activator for the script needs to be set to the target (as a weapon will be calling the script), but what equation should I use to determine target's current health out of max health? I can't just divide the former by the latter, because that returns a number smaller than 1, and thus it'll be rounded up, right?
Blue Shadow
Posts: 5043
Joined: Sun Nov 14, 2010 12:59 am

Re: Healthbar for targeted monster

Post by Blue Shadow »

Here is a basic demo that displays "enemy" health (not bar*):
enemy_hp_bar.pk3
(1.3 KiB) Downloaded 114 times
Spoiler: *
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Healthbar for targeted monster

Post by amv2k9 »

Blue Shadow wrote:If your ultimate goal is to do the drawing of bars in SBARINFO, I can adjust the demo to do just that.
Actually my intention was to have it render through a weapon's Flash state, like this:

Code: Select all

Flash_TargetHP:
 TNT1 A 0 A_JumpIf(CallACS("CheckTargetHP", 0, 0, 0)>=100,"TargetHPMax")
 TNT1 A 0 A_JumpIf(CallACS("CheckTargetHP", 0, 0, 0)>=90,"TargetHP90")
 ...
TargetHPMax:
 H100 A 1
 Goto LightDone
TargetHP90:
 H090 A 1
 Goto LightDone
But hopefully I can figure it out.
User avatar
kodi
 
 
Posts: 1361
Joined: Mon May 06, 2013 8:02 am

Re: Healthbar for targeted monster

Post by kodi »

There are at least a couple of ways you can do it. Not sure whether an ACS loop with SETACTIVATORTOTARGET and a class check or a custom hitscan attack like I'm using here (to be able to angle it) is the most performance-efficient.
Image
Blue Shadow
Posts: 5043
Joined: Sun Nov 14, 2010 12:59 am

Re: Healthbar for targeted monster

Post by Blue Shadow »

amv2k9 wrote:Actually my intention was to have it render through a weapon's Flash state
Curious, why through a weapon, instead of more suitable solutions like ACS or SBARINFO?
User avatar
T_Silverwolf
Posts: 50
Joined: Mon Feb 24, 2014 2:26 pm
Location: http://www.tammysilverwolf.com
Contact:

Re: Healthbar for targeted monster

Post by T_Silverwolf »

kodi wrote:There are at least a couple of ways you can do it. Not sure whether an ACS loop with SETACTIVATORTOTARGET and a class check or a custom hitscan attack like I'm using here (to be able to angle it) is the most performance-efficient.
Image
I'd actually be quite interested in this, is there a demo out there somewhere?
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: Healthbar for targeted monster

Post by cocka »

Hi!

I think this would be an initial try from me:
monsternamehealth.wad
(3.81 KiB) Downloaded 88 times
Just use it as you wish.
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Healthbar for targeted monster

Post by amv2k9 »

Thanks for all your help, BlueShadow & cocka!
Image
Image
User avatar
kodi
 
 
Posts: 1361
Joined: Mon May 06, 2013 8:02 am

Re: Healthbar for targeted monster

Post by kodi »

@T_Silverwolf
It's part of a bigger system yet to be released. The hp/class name thing was just for testing purposes but should be easy to recreate.

@amv2k9
That's a hella sweet looking hud man!
User avatar
T_Silverwolf
Posts: 50
Joined: Mon Feb 24, 2014 2:26 pm
Location: http://www.tammysilverwolf.com
Contact:

Re: Healthbar for targeted monster

Post by T_Silverwolf »

kodi wrote:@T_Silverwolf
It's part of a bigger system yet to be released. The hp/class name thing was just for testing purposes but should be easy to recreate.

@amv2k9
That's a hella sweet looking hud man!
Wow, nice. O_o I'm trying to do something vaguely similar (though not a point and click style thing) I guess I'll have to keep digging, scripting really isn't my strongest suit.
Locked

Return to “Editing (Archive)”