Scripts / health bar

Author
Message
Bikay
User Banned
Posted: 25th Jun 2016 20:15
Hey guys,I have watch a video on youtube of gameguru,there I saw healthbar with % and even light which get attach with character and even with wizard character.so can anyone gave me an idea how do I make this type of healthbar.below I have attach some screenshot.

Attachments

Login to view attachments
Nathan38
13
Years of Service
User Offline
Joined: 13th Feb 2011
Location:
Posted: 26th Jun 2016 09:18
The PromptLocal command is the one you're looking for, I believe. Bit rusty on LUA, not done it for a while, however you could try writing something like PromptLocal (g_entityhealth) in the character's AI script. Hopefully one of the more experienced scripters will answer your question soon.
Bikay
User Banned
Posted: 26th Jun 2016 09:27
Thanks nathan38, yeah m waiting for experience scripter who could show me with coding or video.
Nathan38
13
Years of Service
User Offline
Joined: 13th Feb 2011
Location:
Posted: 26th Jun 2016 09:30 Edited at: 26th Jun 2016 09:55
Ah ha! Sorted it for you, simply add this line to the AI script of the character you are using:

PromptLocal (e, "Health: " .. g_Entity[e]['health']).

For example, if you're using, "Combat Soldier", open the script called ai_soldier.lua in the scriptbank and add that line just below this one:

function ai_soldier_main(e)

should be line 26.

Have fun!

EDIT: I should also say that is a very simple way of implementing this, as it will show an enemies health regardless of how far away they are and if they're hiding behind something. For example if you place an enemy behind a wall, you will still see their health, but not them

EDIT 2:
Heres a video of it in action
https://www.youtube.com/watch?v=uOeV3CtMyrc


EDIT 3: If you want the bar to only show when the character is engaged in combat, add this instead :
if ai_soldier_state[e] == "combat" then
PromptLocal (e, "Health: " .. g_Entity[e]['health'])
end
Bikay
User Banned
Posted: 27th Jun 2016 18:58
Looks great yeah,sure I will try by the way will it works for thirdperson.
Bro nathan38 thanks for sharing ur ideas ya.
Bikay
User Banned
Posted: 28th Jun 2016 18:51
Thanks nathan38, it's working.suppose if I want to add image health bar instead of text then what should I do any idea.instead of down to show up on top of character head.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 28th Jun 2016 22:16
Here is a starting point, unfortunately there doesn't seem to be a way to scale Decals in only one axis so it is a bit clunky but it works fine, just needs a bit of polish.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM

Login to post a reply

Server time is: 2024-05-02 14:20:40
Your offset time is: 2024-05-02 14:20:40