called when an attack or trap has poisoned hero (used to be in mon.c) */
| 314 | |
| 315 | /* called when an attack or trap has poisoned hero (used to be in mon.c) */ |
| 316 | void |
| 317 | poisoned( |
| 318 | const char *reason, /* controls what messages we display */ |
| 319 | int typ, |
| 320 | const char *pkiller, /* for score+log file if fatal */ |
| 321 | int fatal, /* if fatal is 0, limit damage to adjattrib */ |
| 322 | boolean thrown_weapon) /* thrown weapons are less deadly */ |
| 323 | { |
| 324 | int i, loss, kprefix = KILLED_BY_AN; |
| 325 | boolean blast = !strcmp(reason, "blast"); |
| 326 | |
| 327 | /* inform player about being poisoned unless that's already been done; |
| 328 | "blast" has given a "blast of poison gas" message; "poison arrow", |
| 329 | "poison dart", etc have implicitly given poison messages too... */ |
| 330 | if (!blast && !strstri(reason, "poison")) { |
| 331 | boolean plural = (reason[strlen(reason) - 1] == 's') ? 1 : 0; |
| 332 | |
| 333 | /* avoid "The" Orcus's sting was poisoned... */ |
| 334 | pline("%s%s %s poisoned!", |
| 335 | isupper((uchar) *reason) ? "" : "The ", reason, |
| 336 | plural ? "were" : "was"); |
| 337 | } |
| 338 | if (Poison_resistance) { |
| 339 | if (blast) |
| 340 | shieldeff(u.ux, u.uy); |
| 341 | pline_The("poison doesn't seem to affect you."); |
| 342 | return; |
| 343 | } |
| 344 | |
| 345 | /* suppress killer prefix if it already has one */ |
| 346 | i = name_to_mon(pkiller, (int *) 0); |
| 347 | if (ismnum(i) && (mons[i].geno & G_UNIQ)) { |
| 348 | kprefix = KILLED_BY; |
| 349 | if (!type_is_pname(&mons[i])) |
| 350 | pkiller = the(pkiller); |
| 351 | } else if (!strncmpi(pkiller, "the ", 4) || !strncmpi(pkiller, "an ", 3) |
| 352 | || !strncmpi(pkiller, "a ", 2)) { |
| 353 | /*[ does this need a plural check too? ]*/ |
| 354 | kprefix = KILLED_BY; |
| 355 | } |
| 356 | |
| 357 | /* |
| 358 | * FIXME: |
| 359 | * this operates on u.uhp[max] even when hero is polymorphed.... |
| 360 | */ |
| 361 | |
| 362 | i = !fatal ? 1 : rn2(fatal + (thrown_weapon ? 20 : 0)); |
| 363 | if (i == 0 && typ != A_CHA) { |
| 364 | /* sometimes survivable instant kill */ |
| 365 | loss = 6 + d(4, 6); /* 6 + 4d6 => 10..34 */ |
| 366 | if (u.uhp <= loss) { |
| 367 | u.uhp = -1; |
| 368 | disp.botl = TRUE; |
| 369 | pline_The("poison was deadly..."); |
| 370 | } else { |
| 371 | /* survived, but with severe reaction */ |
| 372 | int olduhp = u.uhp, |
| 373 | newuhpmax = u.uhpmax - (loss / 2); |
no test coverage detected