MCPcopy Index your code
hub / github.com/NetHack/NetHack / dochug

Function dochug

src/monmove.c:689–989  ·  view source on GitHub ↗

returns 1 if monster died moving, 0 otherwise */ The whole dochugw/m_move/distfleeck/mfndpos section is serious spaghetti * code. --KAA */

Source from the content-addressed store, hash-verified

687 * code. --KAA
688 */
689int
690dochug(struct monst *mtmp)
691{
692 struct permonst *mdat;
693 int status = MMOVE_NOTHING;
694 int inrange, nearby, scared, res;
695 struct obj *otmp;
696 boolean panicattk = FALSE;
697
698 /*
699 * PHASE ONE: Pre-movement adjustments
700 */
701
702 mdat = mtmp->data;
703
704 if (mtmp->mstrategy & STRAT_ARRIVE) {
705 res = m_arrival(mtmp);
706 if (res >= 0)
707 return res;
708 }
709 /* check for waitmask status change */
710 if ((mtmp->mstrategy & STRAT_WAITFORU)
711 && (m_canseeu(mtmp) || mtmp->mhp < mtmp->mhpmax))
712 mtmp->mstrategy &= ~STRAT_WAITFORU;
713
714 /* update quest status flags */
715 quest_stat_check(mtmp);
716
717 if (!mtmp->mcanmove || (mtmp->mstrategy & STRAT_WAITMASK)) {
718 if (Hallucination)
719 newsym(mtmp->mx, mtmp->my);
720 if (mtmp->mcanmove && (mtmp->mstrategy & STRAT_CLOSE)
721 && !mtmp->msleeping && monnear(mtmp, u.ux, u.uy))
722 quest_talk(mtmp); /* give the leaders a chance to speak */
723 return 0; /* other frozen monsters can't do anything */
724 }
725
726 /* there is a chance we will wake it */
727 if (mtmp->msleeping && !disturb(mtmp)) {
728 if (Hallucination)
729 newsym(mtmp->mx, mtmp->my);
730 return 0;
731 }
732
733 /* not frozen or sleeping: wipe out texts written in the dust */
734 wipe_engr_at(mtmp->mx, mtmp->my, 1, FALSE);
735
736 /* confused monsters get unconfused with small probability */
737 if (mtmp->mconf && !rn2(50))
738 mtmp->mconf = 0;
739
740 /* stunned monsters get un-stunned with larger probability */
741 if (mtmp->mstun && !rn2(10))
742 mtmp->mstun = 0;
743
744 /* Some monsters teleport. Teleportation costs a turn. */
745 if (mtmp->mflee && !rn2(40) && can_teleport(mdat) && !mtmp->iswiz
746 && !noteleport_level(mtmp)) {

Callers 2

dochugwFunction · 0.85
u_entered_shopFunction · 0.85

Calls 15

m_arrivalFunction · 0.85
quest_stat_checkFunction · 0.85
newsymFunction · 0.85
monnearFunction · 0.85
quest_talkFunction · 0.85
disturbFunction · 0.85
wipe_engr_atFunction · 0.85
rn2Function · 0.85
noteleport_levelFunction · 0.85
rlocFunction · 0.85
leppie_stashFunction · 0.85
m_respondFunction · 0.85

Tested by

no test coverage detected