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

Function artifact_hit

src/artifact.c:1436–1721  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1434}
1435
1436DISABLE_WARNING_FORMAT_NONLITERAL
1437
1438/* Function used when someone attacks someone else with an artifact
1439 * weapon. Only adds the special (artifact) damage, and returns a 1 if it
1440 * did something special (in which case the caller won't print the normal
1441 * hit message). This should be called once upon every artifact attack;
1442 * dmgval() no longer takes artifact bonuses into account. Possible
1443 * extension: change the killer so that when an orc kills you with
1444 * Stormbringer it's "killed by Stormbringer" instead of "killed by an orc".
1445 */
1446boolean
1447artifact_hit(
1448 struct monst *magr, /* attacker; might be Null if 'mdef' is youmonst */
1449 struct monst *mdef, /* defender */
1450 struct obj *otmp, /* artifact weapon */
1451 int *dmgptr, /* output */
1452 int dieroll) /* needed for Magicbane and vorpal blades */
1453{
1454 boolean youattack = (magr == &gy.youmonst);
1455 boolean youdefend = (mdef == &gy.youmonst);
1456 boolean vis = (!youattack && magr && cansee(magr->mx, magr->my))
1457 || (!youdefend && cansee(mdef->mx, mdef->my))
1458 || (youattack && engulfing_u(mdef) && !Blind);
1459 boolean realizes_damage;
1460 const char *wepdesc;
1461 static const char you[] = "you";
1462 char hittee[BUFSZ];
1463
1464 Strcpy(hittee, youdefend ? you : mon_nam(mdef));
1465
1466 /* The following takes care of most of the damage, but not all--
1467 * the exception being for level draining, which is specially
1468 * handled. Messages are done in this function, however.
1469 */
1470 *dmgptr += spec_dbon(otmp, mdef, *dmgptr);
1471
1472 if (youattack && youdefend) {
1473 impossible("attacking yourself with weapon?");
1474 return FALSE;
1475 }
1476
1477 realizes_damage = (youdefend || vis
1478 /* feel the effect even if not seen */
1479 || (youattack && mdef == u.ustuck));
1480
1481 /* the four basic attacks: fire, cold, shock and missiles */
1482 if (attacks(AD_FIRE, otmp)) {
1483 if (realizes_damage)
1484 pline_The("fiery blade %s %s%c",
1485 !gs.spec_dbon_applies
1486 ? "hits"
1487 : (mdef->data == &mons[PM_WATER_ELEMENTAL])
1488 ? "vaporizes part of"
1489 : "burns",
1490 hittee, !gs.spec_dbon_applies ? '.' : '!');
1491 if (!rn2(4)) {
1492 int itemdmg = destroy_items(mdef, AD_FIRE, *dmgptr);
1493 if (!youdefend)

Callers 5

hmon_hitmon_weapon_meleeFunction · 0.85
mhitm_ad_physFunction · 0.85
toss_upFunction · 0.85
throwitFunction · 0.85
return_from_mtossFunction · 0.85

Calls 15

mon_namFunction · 0.85
spec_dbonFunction · 0.85
attacksFunction · 0.85
pline_TheFunction · 0.85
rn2Function · 0.85
destroy_itemsFunction · 0.85
ignite_itemsFunction · 0.85
burn_away_slimeFunction · 0.85
wake_neartoFunction · 0.85
Mb_hitFunction · 0.85
spec_abilityFunction · 0.85
is_artFunction · 0.85

Tested by

no test coverage detected