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) Robert Patrick Rankin, 2011. */
|
||||
/* 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? */
|
||||
struct attack *
|
||||
attacktype_fordmg(struct permonst* ptr, int atyp, int dtyp)
|
||||
attacktype_fordmg(struct permonst *ptr, int atyp, int dtyp)
|
||||
{
|
||||
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 */
|
||||
boolean
|
||||
attacktype(struct permonst* ptr, int atyp)
|
||||
attacktype(struct permonst *ptr, int atyp)
|
||||
{
|
||||
return attacktype_fordmg(ptr, atyp, AD_ANY) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/* returns True if monster doesn't attack, False if it does */
|
||||
boolean
|
||||
noattacks(struct permonst* ptr)
|
||||
noattacks(struct permonst *ptr)
|
||||
{
|
||||
int i;
|
||||
struct attack *mattk = ptr->mattk;
|
||||
@@ -139,7 +139,7 @@ resists_drli(struct monst *mon)
|
||||
|
||||
/* True if monster is magic-missile (actually, general magic) resistant */
|
||||
boolean
|
||||
resists_magm(struct monst* mon)
|
||||
resists_magm(struct monst *mon)
|
||||
{
|
||||
struct permonst *ptr = mon->data;
|
||||
boolean is_you = (mon == &gy.youmonst);
|
||||
@@ -172,7 +172,7 @@ resists_magm(struct monst* mon)
|
||||
|
||||
/* True iff monster is resistant to light-induced blindness */
|
||||
boolean
|
||||
resists_blnd(struct monst* mon)
|
||||
resists_blnd(struct monst *mon)
|
||||
{
|
||||
struct permonst *ptr = mon->data;
|
||||
boolean is_you = (mon == &gy.youmonst);
|
||||
@@ -305,7 +305,7 @@ can_blnd(
|
||||
|
||||
/* returns True if monster can attack at range */
|
||||
boolean
|
||||
ranged_attk(struct permonst* ptr)
|
||||
ranged_attk(struct permonst *ptr)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -331,7 +331,7 @@ static boolean mstrength_ranged_attk(struct permonst *);
|
||||
an approximation of monster strength. It uses a similar method of
|
||||
determination as "experience()" to arrive at the strength. */
|
||||
int
|
||||
mstrength(struct permonst* ptr)
|
||||
mstrength(struct permonst *ptr)
|
||||
{
|
||||
int i, tmp2, n, tmp = ptr->mlevel;
|
||||
|
||||
@@ -364,7 +364,8 @@ mstrength(struct permonst* ptr)
|
||||
/* {freezing,flaming,shocking} spheres are fairly weak but
|
||||
can destroy equipment; {yellow,black} lights can't */
|
||||
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 */
|
||||
static boolean
|
||||
mstrength_ranged_attk(register struct permonst* ptr)
|
||||
mstrength_ranged_attk(struct permonst *ptr)
|
||||
{
|
||||
register int i, j;
|
||||
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) */
|
||||
boolean
|
||||
can_blow(struct monst* mtmp)
|
||||
can_blow(struct monst *mtmp)
|
||||
{
|
||||
if ((is_silent(mtmp->data) || mtmp->data->msound == MS_BUZZ)
|
||||
&& (breathless(mtmp->data) || verysmall(mtmp->data)
|
||||
@@ -476,7 +477,7 @@ can_blow(struct monst* mtmp)
|
||||
|
||||
/* for casting spells and reading scrolls while blind */
|
||||
boolean
|
||||
can_chant(struct monst* mtmp)
|
||||
can_chant(struct monst *mtmp)
|
||||
{
|
||||
if ((mtmp == &gy.youmonst && Strangled)
|
||||
|| is_silent(mtmp->data) || !has_head(mtmp->data)
|
||||
@@ -487,7 +488,7 @@ can_chant(struct monst* mtmp)
|
||||
|
||||
/* True if mon is vulnerable to strangulation */
|
||||
boolean
|
||||
can_be_strangled(struct monst* mon)
|
||||
can_be_strangled(struct monst *mon)
|
||||
{
|
||||
struct obj *mamul;
|
||||
boolean nonbreathing, nobrainer;
|
||||
@@ -519,17 +520,16 @@ can_be_strangled(struct monst* mon)
|
||||
|
||||
/* returns True if monster can track well */
|
||||
boolean
|
||||
can_track(register struct permonst* ptr)
|
||||
can_track(struct permonst *ptr)
|
||||
{
|
||||
if (u_wield_art(ART_EXCALIBUR))
|
||||
return TRUE;
|
||||
else
|
||||
return (boolean) haseyes(ptr);
|
||||
return (boolean) haseyes(ptr);
|
||||
}
|
||||
|
||||
/* creature will slide out of armor */
|
||||
boolean
|
||||
sliparm(register struct permonst* ptr)
|
||||
sliparm(struct permonst *ptr)
|
||||
{
|
||||
return (boolean) (is_whirly(ptr) || ptr->msize <= MZ_SMALL
|
||||
|| noncorporeal(ptr));
|
||||
@@ -537,7 +537,7 @@ sliparm(register struct permonst* ptr)
|
||||
|
||||
/* creature will break out of armor */
|
||||
boolean
|
||||
breakarm(register struct permonst* ptr)
|
||||
breakarm(struct permonst *ptr)
|
||||
{
|
||||
if (sliparm(ptr))
|
||||
return FALSE;
|
||||
@@ -551,7 +551,7 @@ breakarm(register struct permonst* ptr)
|
||||
|
||||
/* creature sticks other creatures it hits */
|
||||
boolean
|
||||
sticks(register struct permonst* ptr)
|
||||
sticks(register struct permonst *ptr)
|
||||
{
|
||||
return (boolean) (dmgtype(ptr, AD_STCK)
|
||||
|| (dmgtype(ptr, AD_WRAP) && !attacktype(ptr, AT_ENGL))
|
||||
@@ -560,7 +560,7 @@ sticks(register struct permonst* ptr)
|
||||
|
||||
/* some monster-types can't vomit */
|
||||
boolean
|
||||
cantvomit(struct permonst* ptr)
|
||||
cantvomit(struct permonst *ptr)
|
||||
{
|
||||
/* rats and mice are incapable of vomiting;
|
||||
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 */
|
||||
int
|
||||
num_horns(struct permonst* ptr)
|
||||
num_horns(struct permonst *ptr)
|
||||
{
|
||||
switch (monsndx(ptr)) {
|
||||
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
|
||||
type of attack? */
|
||||
struct attack *
|
||||
dmgtype_fromattack(struct permonst* ptr, int dtyp, int atyp)
|
||||
dmgtype_fromattack(struct permonst *ptr, int dtyp, int atyp)
|
||||
{
|
||||
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 */
|
||||
boolean
|
||||
dmgtype(struct permonst* ptr, int dtyp)
|
||||
dmgtype(struct permonst *ptr, int dtyp)
|
||||
{
|
||||
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
|
||||
a passive defense */
|
||||
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;
|
||||
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 */
|
||||
boolean
|
||||
same_race(struct permonst* pm1, struct permonst* pm2)
|
||||
same_race(struct permonst *pm1, struct permonst *pm2)
|
||||
{
|
||||
char let1 = pm1->mlet, let2 = pm2->mlet;
|
||||
|
||||
@@ -771,7 +771,7 @@ DISABLE_WARNING_UNREACHABLE_CODE
|
||||
|
||||
/* return an index into the mons array */
|
||||
int
|
||||
monsndx(struct permonst* ptr)
|
||||
monsndx(struct permonst *ptr)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -958,7 +958,8 @@ name_to_monplus(
|
||||
continue;
|
||||
|
||||
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) {
|
||||
mntmp = i;
|
||||
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) */
|
||||
int
|
||||
gender(register struct monst* mtmp)
|
||||
gender(register struct monst *mtmp)
|
||||
{
|
||||
if (is_neuter(mtmp->data))
|
||||
return 2;
|
||||
@@ -1122,7 +1123,7 @@ pronoun_gender(
|
||||
|
||||
/* used for nearby monsters when you go to another level */
|
||||
boolean
|
||||
levl_follower(struct monst* mtmp)
|
||||
levl_follower(struct monst *mtmp)
|
||||
{
|
||||
if (mtmp == u.usteed)
|
||||
return TRUE;
|
||||
@@ -1270,49 +1271,49 @@ big_little_match(int montyp1, int montyp2)
|
||||
* player. It does not return a pointer to player role character.
|
||||
*/
|
||||
const struct permonst *
|
||||
raceptr(struct monst* mtmp)
|
||||
raceptr(struct monst *mtmp)
|
||||
{
|
||||
if (mtmp == &gy.youmonst && !Upolyd)
|
||||
return &mons[gu.urace.mnum];
|
||||
else
|
||||
return mtmp->data;
|
||||
return mtmp->data;
|
||||
}
|
||||
|
||||
static const char *const levitate[4] = { "float", "Float", "wobble", "Wobble" };
|
||||
static const char *const flys[4] = { "fly", "Fly", "flutter", "Flutter" };
|
||||
static const char *const flyl[4] = { "fly", "Fly", "stagger", "Stagger" };
|
||||
static const char *const slither[4] = { "slither", "Slither", "falter", "Falter" };
|
||||
static const char *const ooze[4] = { "ooze", "Ooze", "tremble", "Tremble" };
|
||||
static const char *const immobile[4] = { "wiggle", "Wiggle", "pulsate", "Pulsate" };
|
||||
static const char *const crawl[4] = { "crawl", "Crawl", "falter", "Falter" };
|
||||
typedef const char *const locoverbs[4];
|
||||
locoverbs levitate = { "float", "Float", "wobble", "Wobble" },
|
||||
flys = { "fly", "Fly", "flutter", "Flutter" },
|
||||
flyl = { "fly", "Fly", "stagger", "Stagger" },
|
||||
slither = { "slither", "Slither", "falter", "Falter" },
|
||||
ooze = { "ooze", "Ooze", "tremble", "Tremble" },
|
||||
immobile = { "wiggle", "Wiggle", "pulsate", "Pulsate" },
|
||||
crawl = { "crawl", "Crawl", "falter", "Falter" };
|
||||
|
||||
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]
|
||||
: (is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[capitalize]
|
||||
: (is_flyer(ptr) && ptr->msize > MZ_SMALL) ? flyl[capitalize]
|
||||
: slithy(ptr) ? slither[capitalize]
|
||||
: amorphous(ptr) ? ooze[capitalize]
|
||||
: !ptr->mmove ? immobile[capitalize]
|
||||
: nolimbs(ptr) ? crawl[capitalize]
|
||||
return (is_floater(ptr) ? levitate[locoindx]
|
||||
: (is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[locoindx]
|
||||
: (is_flyer(ptr) && ptr->msize > MZ_SMALL) ? flyl[locoindx]
|
||||
: slithy(ptr) ? slither[locoindx]
|
||||
: amorphous(ptr) ? ooze[locoindx]
|
||||
: !ptr->mmove ? immobile[locoindx]
|
||||
: nolimbs(ptr) ? crawl[locoindx]
|
||||
: def);
|
||||
}
|
||||
|
||||
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]
|
||||
: (is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[capitalize]
|
||||
: (is_flyer(ptr) && ptr->msize > MZ_SMALL) ? flyl[capitalize]
|
||||
: slithy(ptr) ? slither[capitalize]
|
||||
: amorphous(ptr) ? ooze[capitalize]
|
||||
: !ptr->mmove ? immobile[capitalize]
|
||||
: nolimbs(ptr) ? crawl[capitalize]
|
||||
return (is_floater(ptr) ? levitate[locoindx]
|
||||
: (is_flyer(ptr) && ptr->msize <= MZ_SMALL) ? flys[locoindx]
|
||||
: (is_flyer(ptr) && ptr->msize > MZ_SMALL) ? flyl[locoindx]
|
||||
: slithy(ptr) ? slither[locoindx]
|
||||
: amorphous(ptr) ? ooze[locoindx]
|
||||
: !ptr->mmove ? immobile[locoindx]
|
||||
: nolimbs(ptr) ? crawl[locoindx]
|
||||
: def);
|
||||
}
|
||||
|
||||
@@ -1410,7 +1411,7 @@ msummon_environ(struct permonst *mptr, const char **cloud)
|
||||
* False if monster definitely does not have a sense of smell.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
boolean
|
||||
@@ -1466,7 +1467,7 @@ monstseesu(unsigned long seenres)
|
||||
for them much more easily than low-CHA ones.
|
||||
*/
|
||||
boolean
|
||||
resist_conflict(struct monst* mtmp)
|
||||
resist_conflict(struct monst *mtmp)
|
||||
{
|
||||
/* always a small chance at 19 */
|
||||
int resist_chance = min(19, (ACURR(A_CHA) - mtmp->m_lev + u.ulevel));
|
||||
|
||||
Reference in New Issue
Block a user