
Pages:<< prev 1 next >>


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
it seems to only display blank unless I am at 100% health.
it should display similar to this at 50%
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%
[||||||||||||| ]


Apprentice

GroupMembers
Posts78
JoinedAug 28, 2016
i tried it with float value.. still same outcome
edit: i am aware that the bar is too large... focused on getting it working before making it look good
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



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 >>