monster movement comments

A bit of reformatting and a couple of new comments.  No change in
behavior.
This commit is contained in:
PatR
2019-04-17 18:57:14 -07:00
parent 7088247883
commit bbe4991a7f
2 changed files with 26 additions and 23 deletions
+16 -14
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 allmain.c $NHDT-Date: 1554895741 2019/04/10 11:29:01 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.99 $ */ /* NetHack 3.6 allmain.c $NHDT-Date: 1555552624 2019/04/18 01:57:04 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.100 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -106,21 +106,24 @@ boolean resuming;
context.mon_moving = FALSE; context.mon_moving = FALSE;
if (!monscanmove && youmonst.movement < NORMAL_SPEED) { if (!monscanmove && youmonst.movement < NORMAL_SPEED) {
/* both you and the monsters are out of steam this round /* both hero and monsters are out of steam this round */
*/
/* set up for a new turn */
struct monst *mtmp; struct monst *mtmp;
/* set up for a new turn */
mcalcdistress(); /* adjust monsters' trap, blind, etc */ mcalcdistress(); /* adjust monsters' trap, blind, etc */
/* reallocate movement rations to monsters */ /* reallocate movement rations to monsters; don't need
to skip dead monsters here because they will have
been purged at end of their previous round of moving */
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
mtmp->movement += mcalcmove(mtmp); mtmp->movement += mcalcmove(mtmp);
if (!rn2(u.uevent.udemigod /* occasionally add another monster; since this takes
? 25 place after movement has been allotted, the new
: (depth(&u.uz) > depth(&stronghold_level)) monster effectively loses its first turn */
? 50 if (!rn2(u.uevent.udemigod ? 25
: 70)) : (depth(&u.uz) > depth(&stronghold_level)) ? 50
: 70))
(void) makemon((struct permonst *) 0, 0, 0, (void) makemon((struct permonst *) 0, 0, 0,
NO_MM_FLAGS); NO_MM_FLAGS);
@@ -131,11 +134,11 @@ boolean resuming;
} else { } else {
moveamt = youmonst.data->mmove; moveamt = youmonst.data->mmove;
if (Very_fast) { /* speed boots or potion */ if (Very_fast) { /* speed boots, potion, or spell */
/* gain a free action on 2/3 of turns */ /* gain a free action on 2/3 of turns */
if (rn2(3) != 0) if (rn2(3) != 0)
moveamt += NORMAL_SPEED; moveamt += NORMAL_SPEED;
} else if (Fast) { } else if (Fast) { /* intrinsic */
/* gain a free action on 1/3 of turns */ /* gain a free action on 1/3 of turns */
if (rn2(3) == 0) if (rn2(3) == 0)
moveamt += NORMAL_SPEED; moveamt += NORMAL_SPEED;
@@ -313,8 +316,7 @@ boolean resuming;
} }
} }
} }
} while (youmonst.movement } while (youmonst.movement < NORMAL_SPEED); /* hero can't move */
< NORMAL_SPEED); /* hero can't move loop */
/******************************************/ /******************************************/
/* once-per-hero-took-time things go here */ /* once-per-hero-took-time things go here */
+10 -9
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 mon.c $NHDT-Date: 1555022326 2019/04/11 22:38:46 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.281 $ */ /* NetHack 3.6 mon.c $NHDT-Date: 1555552629 2019/04/18 01:57:09 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.282 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */ /*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -654,12 +654,12 @@ struct monst *mon;
mmove = ((rn2(2) ? 4 : 5) * mmove) / 3; mmove = ((rn2(2) ? 4 : 5) * mmove) / 3;
} }
/* Randomly round the monster's speed to a multiple of NORMAL_SPEED. This /* Randomly round the monster's speed to a multiple of NORMAL_SPEED.
makes it impossible for the player to predict when they'll get a free This makes it impossible for the player to predict when they'll get
turn (thus preventing exploits like "melee kiting"), while retaining a free turn (thus preventing exploits like "melee kiting"), while
guarantees about shopkeepers not being outsped by a normal-speed player, retaining guarantees about shopkeepers not being outsped by a
normal-speed players being unable to open up a gap when fleeing a normal-speed player, normal-speed players being unable to open up
normal-speed monster, etc.*/ a gap when fleeing a normal-speed monster, etc. */
mmove_adj = mmove % NORMAL_SPEED; mmove_adj = mmove % NORMAL_SPEED;
mmove -= mmove_adj; mmove -= mmove_adj;
if (rn2(NORMAL_SPEED) < mmove_adj) if (rn2(NORMAL_SPEED) < mmove_adj)
@@ -680,8 +680,9 @@ mcalcdistress()
if (DEADMONSTER(mtmp)) if (DEADMONSTER(mtmp))
continue; continue;
/* must check non-moving monsters once/turn in case /* must check non-moving monsters once/turn in case they managed
* they managed to end up in liquid */ to end up in water or lava; note: when not in liquid they regen,
shape-shift, timeout temporary maladies just like other monsters */
if (mtmp->data->mmove == 0) { if (mtmp->data->mmove == 0) {
if (vision_full_recalc) if (vision_full_recalc)
vision_recalc(0); vision_recalc(0);