Login
User Name:

Password:



Register

Forgot your password?
void nanny_get_new_race -- comm.c
Mar 13, 2025 7:08 am
By Elwood
IPv6
Jan 25, 2025 10:45 pm
By Samson
mudstrlcpy and mudstrlcat
Jan 18, 2025 5:23 pm
By Samson
I3 and IMC
Jan 17, 2025 9:35 pm
By Samson
AFKMud 2.5.1
Jan 17, 2025 2:22 pm
By Samson
SWFotEFUSS 1.5.3
Author: Various
Submitted by: Samson
SWRFUSS 1.4.3
Author: Various
Submitted by: Samson
SmaugFUSS 1.9.8
Author: Various
Submitted by: Samson
AFKMud 2.5.2
Author: AFKMud Team
Submitted by: Samson
SmaugFUSS 1.9.7
Author: Various
Submitted by: Samson
Users Online
Anthropic, Bing, Bytespider, AhrefsBot, Amazonbot

Members: 0
Guests: 1
Stats
Files
Topics
Posts
Members
Newest Member
507
3,812
19,722
591
TracySpencer

» SmaugMuds » 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 21, 2018 1:11 am   Last edited Mar 21, 2018 2:28 am by joeyfogas
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
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 2:16 am   Last edited Mar 21, 2018 3:08 am by joeyfogas
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
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 12:50 pm   
Go to the top of the page
Go to the bottom of the page

joeyfogas
Apprentice
GroupMembers
Posts78
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 >>