Re: Prompt

From: Con (raro94ab@hp4.econ.cbs.dk)
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 
fight).
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 :)
Con.

d.
--
***************************************************************************
*                            *    Visit my homepage:                      *
*   Rasmus Rønlev DOEK'94    *    http://www.econ.cbs.dk/people/raro94ab  *
*   Student instructor       *    Visit my Multi User Dungeon (MUD):      *
*   Mailto: rr@cbs.dk        *    ns3.ptd.net 5000 or 198.80.46.3 5000    *   
***************************************************************************
*                                                                         *
*      Student, B.Sc in Computer Science and Business Administration      *
*                                                                         *
***************************************************************************



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