-/* NetHack 3.6 mon.c $NHDT-Date: 1446166647 2015/10/30 00:57:27 $ $NHDT-Branch: master $:$NHDT-Revision: 1.193 $ */
+/* NetHack 3.6 mon.c $NHDT-Date: 1446458009 2015/11/02 09:53:29 $ $NHDT-Branch: master $:$NHDT-Revision: 1.194 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
struct monst *mtmp;
const char *msg;
{
- if (DEADMONSTER(mtmp)) return;
- if ((mtmp->data < &mons[LOW_PM]) || (mtmp->data >= &mons[NUMMONS]))
+ if (DEADMONSTER(mtmp))
+ return;
+ if (mtmp->data < &mons[LOW_PM] || mtmp->data >= &mons[NUMMONS])
impossible("illegal mon data (%s)", msg);
}
case PM_BLUE_DRAGON:
case PM_GREEN_DRAGON:
case PM_YELLOW_DRAGON:
- /* Make dragon scales. This assumes that the order of the */
- /* dragons is the same as the order of the scales. */
+ /* Make dragon scales. This assumes that the order of the
+ dragons is the same as the order of the scales. */
if (!rn2(mtmp->mrevived ? 20 : 3)) {
num = GRAY_DRAGON_SCALES + monsndx(mdat) - PM_GRAY_DRAGON;
obj = mksobj_at(num, x, y, FALSE, FALSE);
(void) bury_an_obj(obj, &dealloc);
newsym(x, y);
- return (dealloc ? NULL : obj);
+ return dealloc ? (struct obj *) 0 : obj;
}
}
break;
if (has_mname(mtmp))
obj = oname(obj, MNAME(mtmp));
- /* Avoid "It was hidden under a green mold corpse!"
+ /* Avoid "It was hidden under a green mold corpse!"
* during Blind combat. An unseen monster referred to as "it"
* could be killed and leave a corpse. If a hider then hid
* underneath it, you could be told the corpse type of a
int mmove = mon->data->mmove;
/* Note: MSLOW's `+ 1' prevents slowed speed 1 getting reduced to 0;
- * MFAST's `+ 2' prevents hasted speed 1 from becoming a no-op;
- * both adjustments have negligible effect on higher speeds.
+ * MFAST's `+ 2' prevents hasted speed 1 from becoming a no-op;
+ * both adjustments have negligible effect on higher speeds.
*/
if (mon->mspeed == MSLOW)
mmove = (2 * mmove + 1) / 3;
if (DEADMONSTER(mtmp))
continue;
- /* Find a monster that we have not treated yet. */
+ /* Find a monster that we have not treated yet. */
if (mtmp->movement < NORMAL_SPEED)
continue;
register struct obj *otmp, *otmp2, *otmp3;
int carryamt = 0;
- /* prevent shopkeepers from leaving the door of their shop */
+ /* prevent shopkeepers from leaving the door of their shop */
if (mtmp->isshk && inhishop(mtmp))
return FALSE;
*
* this will probably cause very amusing behavior with pets and gold coins.
*
- * TODO: allow picking up 2-N objects from a pile of N based on weight
+ * TODO: allow picking up 2-N objects from a pile of N based on weight.
+ * Change from 'int' to 'long' to accomate big stacks of gold.
+ * Right now we fake it by reporting a partial quantity, but the
+ * likesgold handling m_move results in picking up the whole stack.
*/
int
can_carry(mtmp, otmp)
struct monst *mtmp;
struct obj *otmp;
{
- int otyp = otmp->otyp, newload = otmp->owt;
+ int iquan, otyp = otmp->otyp, newload = otmp->owt;
struct permonst *mdat = mtmp->data;
short nattk = 0;
&& (otyp != BELL_OF_OPENING || !is_covetous(mdat)))
return 0;
+ /* hostile monsters who like gold will pick up the whole stack;
+ tame mosnters with hands will pick up the partial stack */
+ iquan = (otmp->quan > (long) LARGEST_INT)
+ ? 20000 + rn2(LARGEST_INT - 20000 + 1)
+ : (int) otmp->quan;
+
/* monsters without hands can't pick up multiple objects at once
* unless they have an engulfing attack
*
- * ...dragons, of course, can always carry gold pieces and gems somehow */
- if (otmp->quan > 1) {
+ * ...dragons, of course, can always carry gold pieces and gems somehow
+ */
+ if (iquan > 1) {
boolean glomper = FALSE;
if (mtmp->data->mlet == S_DRAGON
if (mtmp == u.usteed)
return 0;
if (mtmp->isshk)
- return otmp->quan; /* no limit */
+ return iquan; /* no limit */
if (mtmp->mpeaceful && !mtmp->mtame)
return 0;
/* otherwise players might find themselves obligated to violate
/* special--boulder throwers carry unlimited amounts of boulders */
if (throws_rocks(mdat) && otyp == BOULDER)
- return otmp->quan;
+ return iquan;
/* nymphs deal in stolen merchandise, but not boulders or statues */
if (mdat->mlet == S_NYMPH)
- return (otmp->oclass == ROCK_CLASS) ? 0 : otmp->quan;
+ return (otmp->oclass == ROCK_CLASS) ? 0 : iquan;
if (curr_mon_load(mtmp) + newload > max_mon_load(mtmp))
return 0;
- return otmp->quan;
+ return iquan;
}
/* return number of acceptable neighbour positions */
nodiag = NODIAG(mdat - mons);
wantpool = mdat->mlet == S_EEL;
- poolok =
- is_flyer(mdat) || is_clinger(mdat) || (is_swimmer(mdat) && !wantpool);
- lavaok = is_flyer(mdat) || is_clinger(mdat) || likes_lava(mdat);
+ poolok = (is_flyer(mdat) || is_clinger(mdat)
+ || (is_swimmer(mdat) && !wantpool));
+ lavaok = (is_flyer(mdat) || is_clinger(mdat) || likes_lava(mdat));
thrudoor = ((flag & (ALLOW_WALL | BUSTDOOR)) != 0L);
if (flag & ALLOW_DIG) {
struct obj *mw_tmp;
STATIC_OVL long
mm_aggression(magr, mdef)
struct monst *magr, /* monster that is currently deciding where to move */
- *mdef; /* another monster which is next to it */
+ *mdef; /* another monster which is next to it */
{
/* supposedly purple worms are attracted to shrieking because they
like to eat shriekers, so attack the latter when feasible */
STATIC_OVL long
mm_displacement(magr, mdef)
struct monst *magr, /* monster that is currently deciding where to move */
- *mdef; /* another monster which is next to it */
+ *mdef; /* another monster which is next to it */
{
struct permonst *pa = magr->data, *pd = mdef->data;
/* mnearto()
* Put monster near (or at) location if possible.
* Returns:
- * 1 - if a monster was moved from x, y to put mtmp at x, y.
- * 0 - in most cases.
+ * 1 - if a monster was moved from x, y to put mtmp at x, y.
+ * 0 - in most cases.
*/
boolean
mnearto(mtmp, x, y, move_other)
}
/* attacking your own quest leader will anger his or her guardians */
- if (!context.mon_moving && /* should always be the case here */
- mtmp->data == &mons[quest_info(MS_LEADER)]) {
+ if (!context.mon_moving /* should always be the case here */
+ && mtmp->data == &mons[quest_info(MS_LEADER)]) {
struct monst *mon;
struct permonst *q_guardian = &mons[quest_info(MS_GUARDIAN)];
int got_mad = 0;
#if 0 /* not used */
} else if (otmp->otyp == TIN) {
if (dead_species(otmp->corpsenm, FALSE))
- otmp->corpsenm = NON_PM; /* empty tin */
+ otmp->corpsenm = NON_PM; /* empty tin */
} else if (otmp->otyp == CORPSE) {
if (dead_species(otmp->corpsenm, FALSE))
; /* not yet implemented... */
* their intended destinations, so possessions get deposited there.
*
* Chameleon handling:
- * 1) if chameleons have been genocided, destroy them
- * regardless of current form;
- * 2) otherwise, force every chameleon which is imitating
- * any genocided species to take on a new form.
+ * 1) if chameleons have been genocided, destroy them
+ * regardless of current form;
+ * 2) otherwise, force every chameleon which is imitating
+ * any genocided species to take on a new form.
*/
for (mtmp = fmon; mtmp; mtmp = mtmp2) {
mtmp2 = mtmp->nmon;