|
Meterbar for Attributes [by Adam Days] |
|
|
|
Posted Wednesday, August 12th @ 11:31:15 PM, by George Greer in the Utils dept.
Added Dec 3, 1996. Click the link below to read it or download it.
From: Adam Days <g98s12@oemsunix.onysd.wednet.edu>
Subject: act.informative.c
I just wanted to say I got it working thanks to everyone who helped me
out. I especially want to thank grimlockk@bbs.mpi-net.com, Christopher
Dickey, Barid Bel Medar (icarus@berkshire.net), and Eric Helvey. THANKS!!!
P.S. I have the meter bar for Life, Mana and Movement, here is what the
final product looks like if anyone is interested. Also if any one has any
optimazation tips for this function, please let me know.
void meter_bar(struct char_data * ch, int meter_flag) {
int i, i_percent, max = 0, current = 0, chars = 0;
float percent = 0;
char *meter_name [] = {
"Hit ",
"Mana",
"Move"};
*buf2 = '\0';
switch (meter_flag) {
case 0:
percent = ((float)GET_HIT(ch)) / ((float)GET_MAX_HIT(ch));
current=GET_HIT(ch);
max=GET_MAX_HIT(ch);
break;
case 1:
percent = ((float)GET_MANA(ch)) / ((float)GET_MAX_MANA(ch));
current=GET_MANA(ch);
max=GET_MAX_MANA(ch);
break;
case 2:
percent = ((float)GET_MOVE(ch)) / ((float)GET_MAX_MOVE(ch));
current=GET_MOVE(ch);
max=GET_MAX_MOVE(ch);
break;
default:
break;
}
i_percent = ((float)percent) * 100.0;
chars = 50 * percent;
if (chars > 50)
chars = 50;
for(i=0; i < chars; ++i)
*(buf2 + i) = '#';
*(buf2 + i) = '\0';
for(; i < 50; ++i)
*(buf2 + i) = '-';
*(buf2 + i) = '\0';
sprintf(buf, "[%s%-50s%s] %s %s%d%s/%s(%d)%s\r\n",CCRED(ch, C_NRM),
buf2, CCNRM(ch, C_NRM),meter_name[meter_flag],
CCYEL(ch, C_NRM), current, CCNRM(ch, C_NRM), CCRED(ch, C_NRM),
max, CCNRM(ch, C_NRM));
send_to_char(buf, ch);
}
/* Then in do_score I put in these: */
meter_bar(ch, 0); /* Hit Point */
meter_bar(ch, 1); /* Mana Point */
meter_bar(ch, 2); /* Move Point */
<< Multi Classing/Multi Leveling [by Demond LaZaro] | Reply | View as text | Flattened | Meterbar for attributes (Another) [by Professor Hoopster] >> |
|
Related Links |
|
|
|
CircleMUD Snippets |
|
|
Note: Not all of these snippets will work perfectly with
your version of code, so be prepared to fix one
or two bugs that may arise, and please let me know
what you needed to do to fix it. Sending a corrected
version is always welcome.
|
Finally, if you wish to use any of the snippets from this
page, you are more than welcome, just mention the
authors in your credits. If you wish to release any
of these snippets to the public on another site,
contact me FIRST.
|
|
|
|
|
|
|