act.informative.c

From: Adam Days (g98s12@oemsunix.onysd.wednet.edu)
Date: 07/24/96


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


*******************************************************************************
 Adam Days  a.k.a		  ** "Being an Outcast is only a frame of mind
 Drizzt Do'Urden                  **  and not something that is placed upon
 Unholy Lands <164.116.34.2 4000> **  you."  -Adam Days
*******************************************************************************



This archive was generated by hypermail 2b30 : 12/07/00 PST