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

Function invoke_banish

src/artifact.c:1962–2019  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1960}
1961
1962staticfn int
1963invoke_banish(struct obj *obj UNUSED)
1964{
1965 int nvanished = 0, nstayed = 0;
1966 struct monst *mtmp, *mtmp2;
1967 d_level dest;
1968
1969 find_hell(&dest);
1970
1971 for (mtmp = fmon; mtmp; mtmp = mtmp2) {
1972 int chance = 1;
1973
1974 mtmp2 = mtmp->nmon;
1975 if (DEADMONSTER(mtmp) || !isok(mtmp->mx, mtmp->my))
1976 continue;
1977 if (!is_demon(mtmp->data) && mtmp->data->mlet != S_IMP)
1978 continue;
1979 if (!couldsee(mtmp->mx, mtmp->my))
1980 continue;
1981 if (mtmp->data->msound == MS_NEMESIS)
1982 continue;
1983
1984 if (In_quest(&u.uz) && !svq.quest_status.killed_nemesis)
1985 chance += 10;
1986 if (is_dprince(mtmp->data))
1987 chance += 2;
1988 if (is_dlord(mtmp->data))
1989 chance++;
1990
1991 mtmp->msleeping = mtmp->mtame = mtmp->mpeaceful = 0;
1992 if (chance <= 1 || !rn2(chance)) {
1993 if (!Inhell) {
1994 nvanished++;
1995 /* banish to a random level in Gehennom */
1996 dest.dlevel = rn2(dunlevs_in_dungeon(&dest));
1997 migrate_mon(mtmp, ledger_no(&dest), MIGR_RANDOM);
1998 } else {
1999 u_teleport_mon(mtmp, FALSE);
2000 }
2001 } else {
2002 nstayed++;
2003 }
2004 }
2005
2006 if (nvanished) {
2007 char subject[] = "demons";
2008
2009 if (nvanished == 1)
2010 *(eos(subject) - 1) = '\0'; /* remove 's' */
2011 pline("%s %s %s in a cloud of brimstone!",
2012 nstayed ? ((nvanished > nstayed)
2013 ? "Most of the"
2014 : "Some of the")
2015 : "The",
2016 subject, vtense(subject, "disappear"));
2017 }
2018 return ECMD_TIME;
2019}

Callers 1

arti_invokeFunction · 0.85

Calls 11

find_hellFunction · 0.85
isokFunction · 0.85
In_questFunction · 0.85
rn2Function · 0.85
dunlevs_in_dungeonFunction · 0.85
migrate_monFunction · 0.85
ledger_noFunction · 0.85
u_teleport_monFunction · 0.85
eosFunction · 0.85
vtenseFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected