raceptr()

Add a routine for returning a ptr
to the correct race of monst.
Compensates for polyd and non-polyd player.
This commit is contained in:
nethack.allison
2002-12-30 01:42:36 +00:00
parent e8ca725e92
commit bbfd597a80
3 changed files with 15 additions and 4 deletions

View File

@@ -1167,6 +1167,7 @@ E int FDECL(big_to_little, (int));
E const char *FDECL(locomotion, (const struct permonst *,const char *));
E const char *FDECL(stagger, (const struct permonst *,const char *));
E const char *FDECL(on_fire, (struct permonst *,struct attack *));
E const struct permonst *FDECL(raceptr, (struct monst *));
/* ### monmove.c ### */

View File

@@ -616,6 +616,19 @@ int montype;
return montype;
}
/*
* Return the permonst ptr for the race of the monster.
* Returns correct pointer for non-polymorphed and polymorphed
* player. It does not return a pointer to player role character.
*/
const struct permonst *
raceptr(mtmp)
struct monst *mtmp;
{
if (mtmp == &youmonst && !Upolyd) return(&mons[urace.malenum]);
else return(mtmp->data);
}
static const char *levitate[4] = { "float", "Float", "wobble", "Wobble" };
static const char *flys[4] = { "fly", "Fly", "flutter", "Flutter" };
static const char *flyl[4] = { "fly", "Fly", "stagger", "Stagger" };

View File

@@ -761,10 +761,7 @@ racial_exception(mon, obj)
struct monst *mon;
struct obj *obj;
{
struct permonst *ptr;
if (mon == &youmonst && !Upolyd) ptr = &mons[urace.malenum];
else ptr = mon->data;
const struct permonst *ptr = raceptr(mon);
/* Acceptable Exceptions: */
/* Allow hobbits to wear elven armor - LoTR */