[Circle] CODE: color stat prompt.

From: Terry Valladon (Reaper@cyber.reno.nv.us)
Date: 07/26/96


here is the finished code, just replace your existing make_prompt in comm.c
with it, after i give it to you I will explane why i did things the way I
did so you can give me some (constructave) critasisam <my spelling bites!>.
and thank you all of you that helped me out with hints and stuff, by the
time I had read most of your messages I had figured it out and slaped my
self on the head for not seeing it, but a lot of you did help. use the code
as you see fit, but remember I made it so dont take credit, ok? ok. k00l.

----snip----

void make_prompt(struct descriptor_data *d)
{
  char prompt[MAX_INPUT_LENGTH];

  if (d->str)
    write_to_descriptor(d->descriptor, "] ");
  else if (d->showstr_count) {
    sprintf(prompt,
	    "\r[ Return to continue, (q)uit, (r)efresh, (b)ack, or page number
(%d/%d) ]",
	    d->showstr_page, d->showstr_count);
    write_to_descriptor(d->descriptor, prompt);
  } else if (!d->connected) {
    char prompt[MAX_INPUT_LENGTH];

    *prompt = '\0';

    if (GET_INVIS_LEV(d->character))
      sprintf(prompt, "%sI%d%s|", CCBLU(d->character, C_NRM),
GET_INVIS_LEV(d->character), CCNRM(d->character, C_NRM));


    if (PRF_FLAGGED(d->character, PRF_DISPHP))
      if (GET_HIT(d->character) <= (GET_MAX_HIT(d->character)*1))
         if (GET_HIT(d->character) >= (GET_MAX_HIT(d->character)*.504))
             sprintf(prompt, "%s%s%dH%s|", prompt, CCGRN(d->character, C_NRM),
             GET_HIT(d->character), CCNRM(d->character, C_NRM));
         if (GET_HIT(d->character) >= (GET_MAX_HIT(d->character)*.254))
             if (GET_HIT(d->character) <= (GET_MAX_HIT(d->character)*.506))
	     sprintf(prompt, "%s%s%dH%s|", prompt, CCYEL(d->character, C_NRM),
             GET_HIT(d->character), CCNRM(d->character, C_NRM));
	 if (GET_HIT(d->character) <= (GET_MAX_HIT(d->character)*.256))
             sprintf(prompt, "%s%s%dH%s|", prompt, CCRED(d->character, C_NRM),
             GET_HIT(d->character), CCNRM(d->character, C_NRM));

    if (PRF_FLAGGED(d->character, PRF_DISPMANA))
      if (GET_MANA(d->character) <= (GET_MAX_MANA(d->character)*1))
         if (GET_MANA(d->character) >= (GET_MAX_MANA(d->character)*.504))
             sprintf(prompt, "%s%s%dM%s|", prompt, CCGRN(d->character, C_NRM),
             GET_MANA(d->character), CCNRM(d->character, C_NRM));
         if (GET_MANA(d->character) >= (GET_MAX_MANA(d->character)*.254))
             if (GET_MANA(d->character) <= (GET_MAX_MANA(d->character)*.506))
             sprintf(prompt, "%s%s%dM%s|", prompt, CCYEL(d->character, C_NRM),
             GET_MANA(d->character), CCNRM(d->character, C_NRM));
         if (GET_MANA(d->character) <= (GET_MAX_MANA(d->character)*.256))
             sprintf(prompt, "%s%s%dM%s|", prompt, CCRED(d->character, C_NRM),
             GET_MANA(d->character), CCNRM(d->character, C_NRM));

if (PRF_FLAGGED(d->character, PRF_DISPMOVE))
      if (GET_MOVE(d->character) <= (GET_MAX_MOVE(d->character)*1))
         if (GET_MOVE(d->character) >= (GET_MAX_MOVE(d->character)*.504))
             sprintf(prompt, "%s%s%dV%s|", prompt, CCGRN(d->character, C_NRM),
             GET_MOVE(d->character), CCNRM(d->character, C_NRM));
         if (GET_MOVE(d->character) >= (GET_MAX_MOVE(d->character)*.254))
             if (GET_MOVE(d->character) <= (GET_MAX_MOVE(d->character)*.506))
             sprintf(prompt, "%s%s%dV%s|", prompt, CCYEL(d->character, C_NRM),
             GET_MOVE(d->character), CCNRM(d->character, C_NRM));
         if (GET_MOVE(d->character) <= (GET_MAX_MOVE(d->character)*.256))
             sprintf(prompt, "%s%s%dV%s|", prompt, CCRED(d->character, C_NRM),
             GET_MOVE(d->character), CCNRM(d->character, C_NRM));


    strcat(prompt, "> ");
    write_to_descriptor(d->descriptor, prompt);
  }
}


----snip----

ok, I went to three decmal places because in my testing I found that if I
did not it sometimes skipped it, ie out of 500 max hit points if you were at
251 it would not show up, I did the check for above and below so that there
was no chance that it would display say, a green 250H and a yellow 250H at
the same time, I also added the blue to invis to catch attention, I am
always forgeting I am invis and scaring players =:).

ok, at 0% to 25% the stat is red, 26% to 50% yellow above that it is green,
now because of the third decimal place it may be a little off, but no more
then 3 numbers unless your HP go above 500 =:) well, there it is and once
again thank you all for all your help!!!!!
Cyber Reaper
Realms of Reality
***UNDER CONSTRUCTION!!!***
telnet://login.greatbasin.net 4000

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



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