Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Development
Nov 28, 2018, 10:10 am
By Keirath
First Immortal
Oct 12, 2018, 12:02 pm
By GatewaySysop
Bug in do_climb( )
Jun 5, 2018, 5:31 pm
By joeyfogas
question on overland code
May 31, 2018, 10:03 am
By joeyfogas
KaVir's Protocol Snip
May 15, 2018, 7:57 pm
By joeyfogas
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Bing

Members: 0
Guests: 20
Stats
Files
Topics
Posts
Members
Newest Member
481
3,740
19,397
640
KieraZajac
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Coding » health bar code not displayin...
Forum Rules | Mark all | Recent Posts

health bar code not displaying correctly. why?
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 20, 2018, 11:11 pm   Last edited Mar 21, 2018, 12:28 am by joeyfogas
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts77
JoinedAug 28, 2016

can anyone help out and tell me why this code doesn't display right?

it is supposed to be a healthbar based on health percentage
send_to_char("[",ch);
int value = 100 * (ch->hit/ch->max_hit) ;
                          for (start = 1; start <= 100; start++ )

                                {
                          if (start <= value )
                                        send_to_char("|",ch);
                                  else
                                        send_to_char(" ",ch);
                                }
                    send_to_char("]  \r",ch);


it seems to only display blank unless I am at 100% health.

it should display similar to this at 50%
[|||||||||||||             ]
       
Post is unread #2 Mar 21, 2018, 12:16 am   Last edited Mar 21, 2018, 1:08 am by joeyfogas
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts77
JoinedAug 28, 2016

i tried it with float value.. still same outcome

send_to_char("[",ch);
float value = 100.0 * (ch->hit/ch->max_hit) ;
                          for (start = 1; start <= 100; start++ )

                                {
                          if (start <= value )
                                        send_to_char("|",ch);
                                  else
                                        send_to_char(" ",ch);
                                }
                    send_to_char("]  \r",ch);


----------------------------------------------------------------------------
You are a level 65 Elf Adventurer from  O'ran Thalore.
Your TIER rank is 0.

STR  :  10      Attack:      0                  Health: 300/600
[                                                                               
                     ]  


edit: i am aware that the bar is too large... focused on getting it working before making it look good
       
Post is unread #3 Mar 21, 2018, 10:50 am
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts77
JoinedAug 28, 2016

Nick Gammon helped out... the equation would not work unless it was changed as such

float value = 100.0 * ((float) ch->hit / (float) ch->max_hit) ;


       
Pages:<< prev 1 next >>