Re: Prompt

From: Con (
Date: 04/26/96

On Thu, 25 Apr 1996, corey hoitsma wrote:

> How do I display at percentage of the mob you are fighting's hp?
> I've tryed to use:
> (100 * GET_HIT(FIGHTING(FIGHTING(d->character)))) / GET_MAX
> _HIT(FIGHTING(FIGHTING(d->character))))
> But it just crashes..

I dunno' if this will help you, BUT...
Especially the FIGHTING() macro and FIGHTING(FIGHTING()) stuff will crash 
on allmost every other OS than Linux, if you're not VERY VERY VERY VERY 
VERY VERY.. (got the idea :) carefull!

If you just have this calculation going on all the time in each prompt, 
you'll hit a time where the FIGHTING() macro (pointer) will be pointing 
to something invallid or be NULL (i.e. when the person in question doesnt 
What you need to do to 'not' making it crash is something like this:

Oh yeah... you've allso made a little redundant stuff up there.. *chuckle*

int percent;
struct char_data *ch;
ch = d->character; /* Not needed, just want something short *grin* */

if(FIGHTING(ch))			/* Check if we have a pointer */
  percent = 100 * (GET_HIT(FIGHTING(ch)) / GET_MAX_HIT(FIGHTING(ch)));

 * Well, not we have a valid percentage of the mob's HP that we're 
 *  figting. Isn't this just great.. :)

Hope this helps you :)

*                            *    Visit my homepage:                      *
*   Rasmus Rønlev DOEK'94    *  *
*   Student instructor       *    Visit my Multi User Dungeon (MUD):      *
*   Mailto:        * 5000 or 5000    *   
*                                                                         *
*      Student, B.Sc in Computer Science and Business Administration      *
*                                                                         *

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