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

Function wiz_kill

src/wizcmds.c:238–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238RESTORE_WARNING_FORMAT_NONLITERAL
239
240/* the #wizkill command - pick targets and reduce them to 0HP;
241 by default, the hero is credited/blamed; use 'm' prefix to avoid that */
242int
243wiz_kill(void)
244{
245 struct monst *mtmp;
246 coord cc;
247 int ans;
248 char c, qbuf[QBUFSZ];
249 const char *prompt = "Pick first monster to slay";
250 boolean save_verbose = flags.verbose,
251 save_autodescribe = iflags.autodescribe;
252 d_level uarehere = u.uz;
253
254 cc.x = u.ux, cc.y = u.uy;
255 for (;;) {
256 pline("%s:", prompt);
257 prompt = "Next monster";
258
259 flags.verbose = FALSE;
260 iflags.autodescribe = TRUE;
261 ans = getpos(&cc, TRUE, "a monster");
262 flags.verbose = save_verbose;
263 iflags.autodescribe = save_autodescribe;
264 if (ans < 0 || cc.x < 1)
265 break;
266
267 mtmp = 0;
268 if (u_at(cc.x, cc.y)) {
269 if (u.usteed) {
270 Sprintf(qbuf, "Kill %.110s?", mon_nam(u.usteed));
271 if ((c = ynq(qbuf)) == 'q')
272 break;
273 if (c == 'y')
274 mtmp = u.usteed;
275 }
276 if (!mtmp) {
277 Sprintf(qbuf, "%s?", Role_if(PM_SAMURAI) ? "Perform seppuku"
278 : "Commit suicide");
279 if (paranoid_query(TRUE, qbuf)) {
280 Sprintf(svk.killer.name, "%s own player", uhis());
281 svk.killer.format = KILLED_BY;
282 done(DIED);
283 }
284 break;
285 }
286 } else if (u.uswallow) {
287 mtmp = next2u(cc.x, cc.y) ? u.ustuck : 0;
288 } else {
289 mtmp = m_at(cc.x, cc.y);
290 }
291
292 /* whether there's an unseen monster here or not, player will know
293 that there's no monster here after the kill or failed attempt;
294 let hero know too */
295 (void) unmap_invisible(cc.x, cc.y);

Callers

nothing calls this directly

Calls 13

getposFunction · 0.85
mon_namFunction · 0.85
paranoid_queryFunction · 0.85
doneFunction · 0.85
unmap_invisibleFunction · 0.85
YouFunction · 0.85
xkilledFunction · 0.85
upstartFunction · 0.85
monkilledFunction · 0.85
on_levelFunction · 0.85
ThereFunction · 0.85
dmonsfreeFunction · 0.85

Tested by

no test coverage detected