MCPcopy Create free account
hub / github.com/NetHack/NetHack / movemon_singlemon

Function movemon_singlemon

src/mon.c:1213–1322  ·  view source on GitHub ↗

perform movement for a single monster. meant to be used with iter_mons_safe. */

Source from the content-addressed store, hash-verified

1211/* perform movement for a single monster.
1212 meant to be used with iter_mons_safe. */
1213boolean
1214movemon_singlemon(struct monst *mtmp)
1215{
1216 /* end monster movement early if hero is flagged to leave the level */
1217 if (u.utotype
1218#ifdef SAFERHANGUP
1219 /* or if the program has lost contact with the user */
1220 || program_state.done_hup
1221#endif
1222 ) {
1223 gs.somebody_can_move = FALSE;
1224 return TRUE;
1225 }
1226
1227 /* one dead monster needs to perform a move after death: vault
1228 guard whose temporary corridor is still on the map; live
1229 guards who have led the hero back to civilization get moved
1230 off the map too; gd_move() decides whether the temporary
1231 corridor can be removed and guard discarded (via clearing
1232 mon->isgd flag so that dmonsfree() will get rid of mon) */
1233 if (mtmp->isgd && !mtmp->mx && !(mtmp->mstate & MON_MIGRATING)) {
1234 /* parked at <0,0>; eventually isgd should get set to false */
1235 if (svm.moves > mtmp->mlstmv) {
1236 (void) gd_move(mtmp);
1237 mtmp->mlstmv = svm.moves;
1238 }
1239 return FALSE;
1240 }
1241 if (DEADMONSTER(mtmp))
1242 return FALSE;
1243
1244 /* monster isn't on this map anymore */
1245 if (mon_offmap(mtmp))
1246 return FALSE;
1247
1248 m_everyturn_effect(mtmp);
1249
1250 /* Find a monster that we have not treated yet. */
1251 if (mtmp->movement < NORMAL_SPEED)
1252 return FALSE;
1253
1254 mtmp->movement -= NORMAL_SPEED;
1255 if (mtmp->movement >= NORMAL_SPEED)
1256 gs.somebody_can_move = TRUE;
1257
1258 if (gv.vision_full_recalc)
1259 vision_recalc(0); /* vision! */
1260
1261 /* reset obj bypasses before next monster moves */
1262 if (svc.context.bypasses)
1263 clear_bypasses();
1264 clear_splitobjs();
1265 if (minliquid(mtmp))
1266 return FALSE;
1267
1268 /* after losing equipment, try to put on replacement */
1269 if (mtmp->misc_worn_check & I_SPECIAL) {
1270 long oldworn;

Callers

nothing calls this directly

Calls 14

gd_moveFunction · 0.85
m_everyturn_effectFunction · 0.85
vision_recalcFunction · 0.85
clear_bypassesFunction · 0.85
clear_splitobjsFunction · 0.85
minliquidFunction · 0.85
dist2Function · 0.85
m_dowearFunction · 0.85
restrapFunction · 0.85
canseemonFunction · 0.85
rn2Function · 0.85
hideunderFunction · 0.85

Tested by

no test coverage detected