Re: [NEWBIE] Modification of hitpoins and manapoints

From: Kanocz Alexander (kanocz@fic.cz)
Date: 02/14/00


I have looked in structs.h and I feel as confused and scared as before and
may be more :-)

Here is the code I made:
It wants to do this

Your Hitpts |##################.........|
Your Mana   |#######################....|
Opps Lives  |######.....................|

Could any1 try to help me out how to implement it more easily ?
I will learn C, I promise :-)
---------- rip ----------

static char _buf[ 80 + 3 ] = {'\0'};

void _setBuffer( int curItm, int maxItm, const char *head ) {
   #define BORDER_MARK    '|'
   #define USABLE_ITEM    '#'
   #define UNUSABLE_ITEM  '.'
   #define CHAR_COUNT     50

   int i, j, iUse = maxItm
                  ? (((float) curItm) / maxItm) * CHAR_COUNT + .5
                  : 0;
   if ( head ) strcpy( _buf, head );
   else _buf[0] = '\0';
   _buf[ j = strlen( _buf ) ] = BORDER_MARK;
   _buf[ ++j ] = '\0';
   for ( i = 0; i < CHAR_COUNT; i++ )
         _buf[j + i] = i < iUse ? USABLE_ITEM : UNUSABLE_ITEM;
   _buf[j += i] = BORDER_MARK;
   _buf[++j] = '\r'; _buf[++j] = '\n'; _buf[++j] = '\0';

   #undef USABLE_ITEM
   #undef UNUSABLE_ITEM
   #undef CHAR_COUNT
   #undef BORDER_MARK
}

ACMD(do_hpstatus) {
   _setBuffer( GET_HIT(ch),  GET_MAX_HIT(ch),  "Your Hitpts " );
   send_to_char(_buf, ch);
   _setBuffer( GET_MANA(ch), GET_MAX_MANA(ch), "Your Mana   " );
   send_to_char(_buf, ch);

   if ((GET_POS(ch)) == POS_FIGHTING) {
      _setBuffer( GET_HIT(FIGHTING(ch)),
                  GET_MAX_HIT(FIGHTING(ch)),
                  "Opps Lives  " );
      send_to_char(_buf, ch);
   }
}
--------- end ----------


-----Původní zpráva-----
Od: Ben Cartwright [mailto:europa@vt.edu]
Odesláno: 14. února 2000 9:36
Komu: CIRCLE@POST.QUEENSU.CA
Předmět: Re: [CIRCLE] [NEWBIE] Modification of hitpoins and manapoints


> I know, that this is dump question, but i spent weekend with it and i feel
> confused.
> I have created a function, which tells player his HIT and MANA status more
> understandly, that Xh Xm in prompt. Now I want to call it WHENEVER his
hits
> or mana changes, but i didn't found where is such function defined nor
> called.
>

The easiest way to do this would be to:
1) Add a "int need_advanced_prompt" to struct player_specials in structs.h.
2) Add a check in make_prompt (in comm.c) to see if the need_advanced_prompt
variable is nonzero, and if it is, then set it back to zero and call the
function you wrote.
3) grep "GET_HIT(" *.c
or if you're using Windows use the Find program to find any *.c files
containing the text "GET_HIT(".
After each occurance that modifies the HP, set the need_advanced_prompt
variable to nonzero.
4) Do the same for GET_MANA(, and GET_MOVE( too if you want.

You might want to make a macro or two in utils.h, such as:

#define GET_NEED_ADV_PROMPT(ch) \
    CHECK_PLR((ch), ((ch)->player_specials->need_advanced_prompt))

/* usage: MODIFY_HMV(ch); -- call after you change a player's HMV */
#define MODIFY_HMV(ch)    do { \
    GET_NEED_ADV_PROMPT(ch) = 1; \
    } while(0);

--Ben Cartwright


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT