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

Function elemental_clog

src/mon.c:3877–3950  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3875}
3876
3877void
3878elemental_clog(struct monst *mon)
3879{
3880 static long msgmv = 0L;
3881 int m_lev = 0;
3882 struct monst *mtmp, *m1, *m2, *m3, *m4, *m5, *zm;
3883
3884 if (In_endgame(&u.uz)) {
3885 m1 = m2 = m3 = m4 = m5 = zm = (struct monst *) 0;
3886 if (!msgmv || (svm.moves - msgmv) > 200L) {
3887 if (!msgmv || rn2(2))
3888 You_feel("besieged.");
3889 msgmv = svm.moves;
3890 }
3891 /*
3892 * m1 an elemental from another plane.
3893 * m2 an elemental from this plane.
3894 * m3 the least powerful monst encountered in loop so far.
3895 * m4 some other non-tame monster.
3896 * m5 a pet.
3897 */
3898 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
3899 if (DEADMONSTER(mtmp) || mtmp == mon)
3900 continue;
3901 if (mtmp->mx == 0 && mtmp->my == 0)
3902 continue;
3903 if (mon_has_amulet(mtmp) || !ok_to_obliterate(mtmp))
3904 continue;
3905 if (mtmp->data->mlet == S_ELEMENTAL) {
3906 if (!is_home_elemental(mtmp->data)) {
3907 if (!m1)
3908 m1 = mtmp;
3909 } else {
3910 if (!m2)
3911 m2 = mtmp;
3912 }
3913 } else {
3914 if (!mtmp->mtame) {
3915 if (!m_lev || mtmp->m_lev < m_lev) {
3916 m_lev = mtmp->m_lev;
3917 m3 = mtmp;
3918 } else if (!m4) {
3919 m4 = mtmp;
3920 }
3921 } else {
3922 if (!m5)
3923 m5 = mtmp;
3924 break;
3925 }
3926 }
3927 }
3928 mtmp = m1 ? m1 : m2 ? m2 : m3 ? m3 : m4 ? m4 : m5 ? m5 : zm;
3929 if (mtmp) {
3930 int mx = mtmp->mx, my = mtmp->my;
3931
3932 mtmp->mstate |= MON_OBLITERATE;
3933 mongone(mtmp);
3934 /* places in the code might still reference mtmp->mx, mtmp->my */

Callers 2

deal_with_overcrowdingFunction · 0.85
mv_bubbleFunction · 0.85

Calls 9

rn2Function · 0.85
You_feelFunction · 0.85
mon_has_amuletFunction · 0.85
ok_to_obliterateFunction · 0.85
is_home_elementalFunction · 0.85
mongoneFunction · 0.85
rloc_toFunction · 0.85
ledger_noFunction · 0.85
migrate_monFunction · 0.85

Tested by

no test coverage detected