Re:diagnose

From: E.I. (gast@SunUe.mch.sni.de)
Date: 10/05/95


	Lo, people ...
To put auto diagnose in each hit sequence of the fight can be implemented in
various ways, the way I did it is the following :

	The file comm.c contains the prompt routines etc so it is :

void make_prompt(struct descriptor_data * d)
{
+  extern struct title_type titles[NUM_CLASSES][LVL_IMPL + 1];
  int percent;

  if (d->str)
    write_to_descriptor(d->descriptor, "] ");
  else if (d->showstr_point)
    write_to_descriptor(d->descriptor,
                        "*** Press return to continue, q to quit ***");
  else if (!d->connected) {
    char prompt[MAX_INPUT_LENGTH];

    *prompt = '\0';

    if (GET_INVIS_LEV(d->character))
      sprintf(prompt, "i%d ", GET_INVIS_LEV(d->character));

    if (PRF_FLAGGED(d->character, PRF_DISPHP))
      sprintf(prompt, "%s%dH ", prompt, GET_HIT(d->character));

    if (PRF_FLAGGED(d->character, PRF_DISPMANA))
      sprintf(prompt, "%s%dM ", prompt, GET_MANA(d->character));

    if (PRF_FLAGGED(d->character, PRF_DISPMOVE))
      sprintf(prompt, "%s%dV ", prompt, GET_MOVE(d->character));

------------------------------------------------------------------------------
NOTE: Till here the code is as it is in Cirlce 3 pl 8 except the line marked
with +. Now I implemented 2 extras on my prompt during fight : The DIagnose and
the exp needed for the next level the rest of the lines are :
------------------------------------------------------------------------------
    if (GET_POS(d->character) == POS_FIGHTING){
      sprintf(prompt, "%s[*%d xp*] ", prompt, (titles[(int) GET_CLASS(d->character)][GET_LEVEL(d->character) + 1].exp) - GET_EXP(d->character));
      sprintf(prompt, "%s[#Dia: ",prompt);
      if (GET_MAX_HIT(FIGHTING(d->character)) > 0)
        percent = (100 * GET_HIT(FIGHTING(d->character))) / GET_MAX_HIT(FIGHTING(d->character));
      else
        percent = -1;
     if (percent >= 100)
       sprintf(prompt, "%sexcellent#]", prompt);
     else if (percent >= 90)
       sprintf(prompt, "%sscratched#]", prompt);
     else if (percent >= 75)
       sprintf(prompt, "%ssmall wounds#]", prompt);
     else if (percent >= 50)
       sprintf(prompt, "%swounded#]", prompt);
     else if (percent >= 30)
       sprintf(prompt, "%sbig wounds#]", prompt);
     else if (percent >= 15)
       sprintf(prompt, "%shurt#]", prompt);
     else if (percent >= 0)
       sprintf(prompt, "%sawful#]", prompt);
     else
       sprintf(prompt, "%sbleeding#]", prompt);
    }
------------------------------------------------------------------------------
Now this is not efficient perhaps as it checks for every prompt request if the
PC is moving, also I omit the NPC check too to have something usefull during
quests etc...And the check for the hitpoints and the strings printed are
according to my system etc...(which is quiet the standard one)
The rest of the function is :
------------------------------------------------------------------------------

    strcat(prompt, " > ");

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


That' s all, well hope that it serves someone, Enjoy life

	Emre I.



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