mondata.c formatting
This commit is contained in:
119
src/mondata.c
119
src/mondata.c
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 mondata.c $NHDT-Date: 1672003297 2022/12/25 21:21:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.119 $ */
|
/* NetHack 3.7 mondata.c $NHDT-Date: 1685180674 2023/05/27 09:44:34 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.122 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -39,7 +39,7 @@ set_mon_data(struct monst *mon, struct permonst *ptr)
|
|||||||
|
|
||||||
/* does monster-type have any attack for a specific type of damage? */
|
/* does monster-type have any attack for a specific type of damage? */
|
||||||
struct attack *
|
struct attack *
|
||||||
attacktype_fordmg(struct permonst* ptr, int atyp, int dtyp)
|
attacktype_fordmg(struct permonst *ptr, int atyp, int dtyp)
|
||||||
{
|
{
|
||||||
struct attack *a;
|
struct attack *a;
|
||||||
|
|
||||||
@@ -51,14 +51,14 @@ attacktype_fordmg(struct permonst* ptr, int atyp, int dtyp)
|
|||||||
|
|
||||||
/* does monster-type have a particular type of attack */
|
/* does monster-type have a particular type of attack */
|
||||||
boolean
|
boolean
|
||||||
attacktype(struct permonst* ptr, int atyp)
|
attacktype(struct permonst *ptr, int atyp)
|
||||||
{
|
{
|
||||||
return attacktype_fordmg(ptr, atyp, AD_ANY) ? TRUE : FALSE;
|
return attacktype_fordmg(ptr, atyp, AD_ANY) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns True if monster doesn't attack, False if it does */
|
/* returns True if monster doesn't attack, False if it does */
|
||||||
boolean
|
boolean
|
||||||
noattacks(struct permonst* ptr)
|
noattacks(struct permonst *ptr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct attack *mattk = ptr->mattk;
|
struct attack *mattk = ptr->mattk;
|
||||||
@@ -139,7 +139,7 @@ resists_drli(struct monst *mon)
|
|||||||
|
|
||||||
/* True if monster is magic-missile (actually, general magic) resistant */
|
/* True if monster is magic-missile (actually, general magic) resistant */
|
||||||
boolean
|
boolean
|
||||||
resists_magm(struct monst* mon)
|
resists_magm(struct monst *mon)
|
||||||
{
|
{
|
||||||
struct permonst *ptr = mon->data;
|
struct permonst *ptr = mon->data;
|
||||||
boolean is_you = (mon == &gy.youmonst);
|
boolean is_you = (mon == &gy.youmonst);
|
||||||
@@ -172,7 +172,7 @@ resists_magm(struct monst* mon)
|
|||||||
|
|
||||||
/* True iff monster is resistant to light-induced blindness */
|
/* True iff monster is resistant to light-induced blindness */
|
||||||
boolean
|
boolean
|
||||||
resists_blnd(struct monst* mon)
|
resists_blnd(struct monst *mon)
|
||||||
{
|
{
|
||||||
struct permonst *ptr = mon->data;
|
struct permonst *ptr = mon->data;
|
||||||
boolean is_you = (mon == &gy.youmonst);
|
boolean is_you = (mon == &gy.youmonst);
|
||||||
@@ -305,7 +305,7 @@ can_blnd(
|
|||||||
|
|
||||||
/* returns True if monster can attack at range */
|
/* returns True if monster can attack at range */
|
||||||
boolean
|
boolean
|
||||||
ranged_attk(struct permonst* ptr)
|
ranged_attk(struct permonst *ptr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -331,7 +331,7 @@ static boolean mstrength_ranged_attk(struct permonst *);
|
|||||||
an approximation of monster strength. It uses a similar method of
|
an approximation of monster strength. It uses a similar method of
|
||||||
determination as "experience()" to arrive at the strength. */
|
determination as "experience()" to arrive at the strength. */
|
||||||
int
|
int
|
||||||
mstrength(struct permonst* ptr)
|
mstrength(struct permonst *ptr)
|
||||||
{
|
{
|
||||||
int i, tmp2, n, tmp = ptr->mlevel;
|
int i, tmp2, n, tmp = ptr->mlevel;
|
||||||
|
|
||||||
@@ -364,7 +364,8 @@ mstrength(struct permonst* ptr)
|
|||||||
/* {freezing,flaming,shocking} spheres are fairly weak but
|
/* {freezing,flaming,shocking} spheres are fairly weak but
|
||||||
can destroy equipment; {yellow,black} lights can't */
|
can destroy equipment; {yellow,black} lights can't */
|
||||||
n += ((tmp3 == AD_COLD || tmp3 == AD_FIRE) ? 3
|
n += ((tmp3 == AD_COLD || tmp3 == AD_FIRE) ? 3
|
||||||
: (tmp3 == AD_ELEC) ? 5 : 0);
|
: (tmp3 == AD_ELEC) ? 5
|
||||||
|
: 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,7 +398,7 @@ mstrength(struct permonst* ptr)
|
|||||||
|
|
||||||
/* returns True if monster can attack at range */
|
/* returns True if monster can attack at range */
|
||||||
static boolean
|
static boolean
|
||||||
mstrength_ranged_attk(register struct permonst* ptr)
|
mstrength_ranged_attk(struct permonst *ptr)
|
||||||
{
|
{
|
||||||
register int i, j;
|
register int i, j;
|
||||||
register int atk_mask = (1 << AT_BREA) | (1 << AT_SPIT) | (1 << AT_GAZE);
|
register int atk_mask = (1 << AT_BREA) | (1 << AT_SPIT) | (1 << AT_GAZE);
|
||||||
@@ -463,7 +464,7 @@ passes_bars(struct permonst *mptr)
|
|||||||
|
|
||||||
/* returns True if monster can blow (whistle, etc) */
|
/* returns True if monster can blow (whistle, etc) */
|
||||||
boolean
|
boolean
|
||||||
can_blow(struct monst* mtmp)
|
can_blow(struct monst *mtmp)
|
||||||
{
|
{
|
||||||
if ((is_silent(mtmp->data) || mtmp->data->msound == MS_BUZZ)
|
if ((is_silent(mtmp->data) || mtmp->data->msound == MS_BUZZ)
|
||||||
&& (breathless(mtmp->data) || verysmall(mtmp->data)
|
&& (breathless(mtmp->data) || verysmall(mtmp->data)
|
||||||
@@ -476,7 +477,7 @@ can_blow(struct monst* mtmp)
|
|||||||
|
|
||||||
/* for casting spells and reading scrolls while blind */
|
/* for casting spells and reading scrolls while blind */
|
||||||
boolean
|
boolean
|
||||||
can_chant(struct monst* mtmp)
|
can_chant(struct monst *mtmp)
|
||||||
{
|
{
|
||||||
if ((mtmp == &gy.youmonst && Strangled)
|
if ((mtmp == &gy.youmonst && Strangled)
|
||||||
|| is_silent(mtmp->data) || !has_head(mtmp->data)
|
|| is_silent(mtmp->data) || !has_head(mtmp->data)
|
||||||
@@ -487,7 +488,7 @@ can_chant(struct monst* mtmp)
|
|||||||
|
|
||||||
/* True if mon is vulnerable to strangulation */
|
/* True if mon is vulnerable to strangulation */
|
||||||
boolean
|
boolean
|
||||||
can_be_strangled(struct monst* mon)
|
can_be_strangled(struct monst *mon)
|
||||||
{
|
{
|
||||||
struct obj *mamul;
|
struct obj *mamul;
|
||||||
boolean nonbreathing, nobrainer;
|
boolean nonbreathing, nobrainer;
|
||||||
@@ -519,17 +520,16 @@ can_be_strangled(struct monst* mon)
|
|||||||
|
|
||||||
/* returns True if monster can track well */
|
/* returns True if monster can track well */
|
||||||
boolean
|
boolean
|
||||||
can_track(register struct permonst* ptr)
|
can_track(struct permonst *ptr)
|
||||||
{
|
{
|
||||||
if (u_wield_art(ART_EXCALIBUR))
|
if (u_wield_art(ART_EXCALIBUR))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
return (boolean) haseyes(ptr);
|
||||||
return (boolean) haseyes(ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* creature will slide out of armor */
|
/* creature will slide out of armor */
|
||||||
boolean
|
boolean
|
||||||
sliparm(register struct permonst* ptr)
|
sliparm(struct permonst *ptr)
|
||||||
{
|
{
|
||||||
return (boolean) (is_whirly(ptr) || ptr->msize <= MZ_SMALL
|
return (boolean) (is_whirly(ptr) || ptr->msize <= MZ_SMALL
|
||||||
|| noncorporeal(ptr));
|
|| noncorporeal(ptr));
|
||||||
@@ -537,7 +537,7 @@ sliparm(register struct permonst* ptr)
|
|||||||
|
|
||||||
/* creature will break out of armor */
|
/* creature will break out of armor */
|
||||||
boolean
|
boolean
|
||||||
breakarm(register struct permonst* ptr)
|
breakarm(struct permonst *ptr)
|
||||||
{
|
{
|
||||||
if (sliparm(ptr))
|
if (sliparm(ptr))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -551,7 +551,7 @@ breakarm(register struct permonst* ptr)
|
|||||||
|
|
||||||
/* creature sticks other creatures it hits */
|
/* creature sticks other creatures it hits */
|
||||||
boolean
|
boolean
|
||||||
sticks(register struct permonst* ptr)
|
sticks(register struct permonst *ptr)
|
||||||
{
|
{
|
||||||
return (boolean) (dmgtype(ptr, AD_STCK)
|
return (boolean) (dmgtype(ptr, AD_STCK)
|
||||||
|| (dmgtype(ptr, AD_WRAP) && !attacktype(ptr, AT_ENGL))
|
|| (dmgtype(ptr, AD_WRAP) && !attacktype(ptr, AT_ENGL))
|
||||||
@@ -560,7 +560,7 @@ sticks(register struct permonst* ptr)
|
|||||||
|
|
||||||
/* some monster-types can't vomit */
|
/* some monster-types can't vomit */
|
||||||
boolean
|
boolean
|
||||||
cantvomit(struct permonst* ptr)
|
cantvomit(struct permonst *ptr)
|
||||||
{
|
{
|
||||||
/* rats and mice are incapable of vomiting;
|
/* rats and mice are incapable of vomiting;
|
||||||
which other creatures have the same limitation? */
|
which other creatures have the same limitation? */
|
||||||
@@ -572,7 +572,7 @@ cantvomit(struct permonst* ptr)
|
|||||||
|
|
||||||
/* number of horns this type of monster has on its head */
|
/* number of horns this type of monster has on its head */
|
||||||
int
|
int
|
||||||
num_horns(struct permonst* ptr)
|
num_horns(struct permonst *ptr)
|
||||||
{
|
{
|
||||||
switch (monsndx(ptr)) {
|
switch (monsndx(ptr)) {
|
||||||
case PM_HORNED_DEVIL: /* ? "more than one" */
|
case PM_HORNED_DEVIL: /* ? "more than one" */
|
||||||
@@ -594,7 +594,7 @@ num_horns(struct permonst* ptr)
|
|||||||
/* does monster-type deal out a particular type of damage from a particular
|
/* does monster-type deal out a particular type of damage from a particular
|
||||||
type of attack? */
|
type of attack? */
|
||||||
struct attack *
|
struct attack *
|
||||||
dmgtype_fromattack(struct permonst* ptr, int dtyp, int atyp)
|
dmgtype_fromattack(struct permonst *ptr, int dtyp, int atyp)
|
||||||
{
|
{
|
||||||
struct attack *a;
|
struct attack *a;
|
||||||
|
|
||||||
@@ -606,7 +606,7 @@ dmgtype_fromattack(struct permonst* ptr, int dtyp, int atyp)
|
|||||||
|
|
||||||
/* does monster-type deal out a particular type of damage from any attack */
|
/* does monster-type deal out a particular type of damage from any attack */
|
||||||
boolean
|
boolean
|
||||||
dmgtype(struct permonst* ptr, int dtyp)
|
dmgtype(struct permonst *ptr, int dtyp)
|
||||||
{
|
{
|
||||||
return dmgtype_fromattack(ptr, dtyp, AT_ANY) ? TRUE : FALSE;
|
return dmgtype_fromattack(ptr, dtyp, AT_ANY) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
@@ -614,7 +614,7 @@ dmgtype(struct permonst* ptr, int dtyp)
|
|||||||
/* returns the maximum damage a defender can do to the attacker via
|
/* returns the maximum damage a defender can do to the attacker via
|
||||||
a passive defense */
|
a passive defense */
|
||||||
int
|
int
|
||||||
max_passive_dmg(register struct monst* mdef, register struct monst* magr)
|
max_passive_dmg(register struct monst *mdef, register struct monst *magr)
|
||||||
{
|
{
|
||||||
int i, dmg, multi2 = 0;
|
int i, dmg, multi2 = 0;
|
||||||
uchar adtyp;
|
uchar adtyp;
|
||||||
@@ -665,7 +665,7 @@ max_passive_dmg(register struct monst* mdef, register struct monst* magr)
|
|||||||
|
|
||||||
/* determine whether two monster types are from the same species */
|
/* determine whether two monster types are from the same species */
|
||||||
boolean
|
boolean
|
||||||
same_race(struct permonst* pm1, struct permonst* pm2)
|
same_race(struct permonst *pm1, struct permonst *pm2)
|
||||||
{
|
{
|
||||||
char let1 = pm1->mlet, let2 = pm2->mlet;
|
char let1 = pm1->mlet, let2 = pm2->mlet;
|
||||||
|
|
||||||
@@ -771,7 +771,7 @@ DISABLE_WARNING_UNREACHABLE_CODE
|
|||||||
|
|
||||||
/* return an index into the mons array */
|
/* return an index into the mons array */
|
||||||
int
|
int
|
||||||
monsndx(struct permonst* ptr)
|
monsndx(struct permonst *ptr)
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
@@ -958,7 +958,8 @@ name_to_monplus(
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
m_i_len = strlen(mons[i].pmnames[mgend]);
|
m_i_len = strlen(mons[i].pmnames[mgend]);
|
||||||
if (m_i_len > (size_t) len && !strncmpi(mons[i].pmnames[mgend], str, (int) m_i_len)) {
|
if (m_i_len > (size_t) len
|
||||||
|
&& !strncmpi(mons[i].pmnames[mgend], str, (int) m_i_len)) {
|
||||||
if (m_i_len == slen) {
|
if (m_i_len == slen) {
|
||||||
mntmp = i;
|
mntmp = i;
|
||||||
len = (int) m_i_len;
|
len = (int) m_i_len;
|
||||||
@@ -1091,7 +1092,7 @@ name_to_monclass(const char *in_str, int * mndx_p)
|
|||||||
|
|
||||||
/* returns 3 values (0=male, 1=female, 2=none) */
|
/* returns 3 values (0=male, 1=female, 2=none) */
|
||||||
int
|
int
|
||||||
gender(register struct monst* mtmp)
|
gender(register struct monst *mtmp)
|
||||||
{
|
{
|
||||||
if (is_neuter(mtmp->data))
|
if (is_neuter(mtmp->data))
|
||||||
return 2;
|
return 2;
|
||||||
@@ -1122,7 +1123,7 @@ pronoun_gender(
|
|||||||
|
|
||||||
/* used for nearby monsters when you go to another level */
|
/* used for nearby monsters when you go to another level */
|
||||||
boolean
|
boolean
|
||||||
levl_follower(struct monst* mtmp)
|
levl_follower(struct monst *mtmp)
|
||||||
{
|
{
|
||||||
if (mtmp == u.usteed)
|
if (mtmp == u.usteed)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -1270,49 +1271,49 @@ big_little_match(int montyp1, int montyp2)
|
|||||||
* player. It does not return a pointer to player role character.
|
* player. It does not return a pointer to player role character.
|
||||||
*/
|
*/
|
||||||
const struct permonst *
|
const struct permonst *
|
||||||
raceptr(struct monst* mtmp)
|
raceptr(struct monst *mtmp)
|
||||||
{
|
{
|
||||||
if (mtmp == &gy.youmonst && !Upolyd)
|
if (mtmp == &gy.youmonst && !Upolyd)
|
||||||
return &mons[gu.urace.mnum];
|
return &mons[gu.urace.mnum];
|
||||||
else
|
return mtmp->data;
|
||||||
return mtmp->data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const levitate[4] = { "float", "Float", "wobble", "Wobble" };
|
typedef const char *const locoverbs[4];
|
||||||
static const char *const flys[4] = { "fly", "Fly", "flutter", "Flutter" };
|
locoverbs levitate = { "float", "Float", "wobble", "Wobble" },
|
||||||
static const char *const flyl[4] = { "fly", "Fly", "stagger", "Stagger" };
|
flys = { "fly", "Fly", "flutter", "Flutter" },
|
||||||
static const char *const slither[4] = { "slither", "Slither", "falter", "Falter" };
|
flyl = { "fly", "Fly", "stagger", "Stagger" },
|
||||||
static const char *const ooze[4] = { "ooze", "Ooze", "tremble", "Tremble" };
|
slither = { "slither", "Slither", "falter", "Falter" },
|
||||||
static const char *const immobile[4] = { "wiggle", "Wiggle", "pulsate", "Pulsate" };
|
ooze = { "ooze", "Ooze", "tremble", "Tremble" },
|
||||||
static const char *const crawl[4] = { "crawl", "Crawl", "falter", "Falter" };
|
immobile = { "wiggle", "Wiggle", "pulsate", "Pulsate" },
|
||||||
|
crawl = { "crawl", "Crawl", "falter", "Falter" };
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
locomotion(const struct permonst* ptr, const char* def)
|
locomotion(const struct permonst *ptr, const char *def)
|
||||||
{
|
{
|
||||||
int capitalize = (*def == highc(*def));
|
int locoindx = (*def != highc(*def)) ? 0 : 1;
|
||||||
|
|
||||||
return (is_floater(ptr) ? levitate[capitalize]
|
return (is_floater(ptr) ? levitate[locoindx]
|
||||||
: (is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[capitalize]
|
: (is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[locoindx]
|
||||||
: (is_flyer(ptr) && ptr->msize > MZ_SMALL) ? flyl[capitalize]
|
: (is_flyer(ptr) && ptr->msize > MZ_SMALL) ? flyl[locoindx]
|
||||||
: slithy(ptr) ? slither[capitalize]
|
: slithy(ptr) ? slither[locoindx]
|
||||||
: amorphous(ptr) ? ooze[capitalize]
|
: amorphous(ptr) ? ooze[locoindx]
|
||||||
: !ptr->mmove ? immobile[capitalize]
|
: !ptr->mmove ? immobile[locoindx]
|
||||||
: nolimbs(ptr) ? crawl[capitalize]
|
: nolimbs(ptr) ? crawl[locoindx]
|
||||||
: def);
|
: def);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
stagger(const struct permonst* ptr, const char* def)
|
stagger(const struct permonst *ptr, const char *def)
|
||||||
{
|
{
|
||||||
int capitalize = 2 + (*def == highc(*def));
|
int locoindx = (*def != highc(*def)) ? 2 : 3;
|
||||||
|
|
||||||
return (is_floater(ptr) ? levitate[capitalize]
|
return (is_floater(ptr) ? levitate[locoindx]
|
||||||
: (is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[capitalize]
|
: (is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[locoindx]
|
||||||
: (is_flyer(ptr) && ptr->msize > MZ_SMALL) ? flyl[capitalize]
|
: (is_flyer(ptr) && ptr->msize > MZ_SMALL) ? flyl[locoindx]
|
||||||
: slithy(ptr) ? slither[capitalize]
|
: slithy(ptr) ? slither[locoindx]
|
||||||
: amorphous(ptr) ? ooze[capitalize]
|
: amorphous(ptr) ? ooze[locoindx]
|
||||||
: !ptr->mmove ? immobile[capitalize]
|
: !ptr->mmove ? immobile[locoindx]
|
||||||
: nolimbs(ptr) ? crawl[capitalize]
|
: nolimbs(ptr) ? crawl[locoindx]
|
||||||
: def);
|
: def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1410,7 +1411,7 @@ msummon_environ(struct permonst *mptr, const char **cloud)
|
|||||||
* False if monster definitely does not have a sense of smell.
|
* False if monster definitely does not have a sense of smell.
|
||||||
*
|
*
|
||||||
* Do not base this on presence of a head or nose, since many
|
* Do not base this on presence of a head or nose, since many
|
||||||
* creatures sense smells other ways (feelers, forked-tongues, etc.)
|
* creatures sense smells other ways (feelers, forked-tongues, etc).
|
||||||
* We're assuming all insects can smell at a distance too.
|
* We're assuming all insects can smell at a distance too.
|
||||||
*/
|
*/
|
||||||
boolean
|
boolean
|
||||||
@@ -1466,7 +1467,7 @@ monstseesu(unsigned long seenres)
|
|||||||
for them much more easily than low-CHA ones.
|
for them much more easily than low-CHA ones.
|
||||||
*/
|
*/
|
||||||
boolean
|
boolean
|
||||||
resist_conflict(struct monst* mtmp)
|
resist_conflict(struct monst *mtmp)
|
||||||
{
|
{
|
||||||
/* always a small chance at 19 */
|
/* always a small chance at 19 */
|
||||||
int resist_chance = min(19, (ACURR(A_CHA) - mtmp->m_lev + u.ulevel));
|
int resist_chance = min(19, (ACURR(A_CHA) - mtmp->m_lev + u.ulevel));
|
||||||
|
|||||||
Reference in New Issue
Block a user