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

Function passivemm

src/mhitm.c:1303–1457  ·  view source on GitHub ↗

* Passive responses by defenders. Does not replicate responses already * handled above. Returns same values as mattackm. */

Source from the content-addressed store, hash-verified

1301 * handled above. Returns same values as mattackm.
1302 */
1303staticfn int
1304passivemm(
1305 struct monst *magr,
1306 struct monst *mdef,
1307 boolean mhitb,
1308 int mdead,
1309 struct obj *mwep)
1310{
1311 struct permonst *mddat = mdef->data;
1312 struct permonst *madat = magr->data;
1313 char buf[BUFSZ];
1314 int i, tmp;
1315 int mhit = mhitb ? M_ATTK_HIT : M_ATTK_MISS;
1316
1317 for (i = 0;; i++) {
1318 if (i >= NATTK)
1319 return (mdead | mhit); /* no passive attacks */
1320 if (mddat->mattk[i].aatyp == AT_NONE)
1321 break;
1322 }
1323 if (mddat->mattk[i].damn)
1324 tmp = d((int) mddat->mattk[i].damn, (int) mddat->mattk[i].damd);
1325 else if (mddat->mattk[i].damd)
1326 tmp = d((int) mddat->mlevel + 1, (int) mddat->mattk[i].damd);
1327 else
1328 tmp = 0;
1329
1330 /* These affect the enemy even if defender killed */
1331 switch (mddat->mattk[i].adtyp) {
1332 case AD_ACID:
1333 if (mhitb && !rn2(2)) {
1334 Strcpy(buf, Monnam(magr));
1335 if (canseemon(magr))
1336 pline("%s is splashed by %s %s!", buf,
1337 s_suffix(mon_nam(mdef)), hliquid("acid"));
1338 if (resists_acid(magr)) {
1339 if (canseemon(magr))
1340 pline("%s is not affected.", Monnam(magr));
1341 tmp = 0;
1342 }
1343 } else
1344 tmp = 0;
1345 if (!rn2(30))
1346 erode_armor(magr, ERODE_CORRODE);
1347 if (!rn2(6))
1348 acid_damage(MON_WEP(magr));
1349 goto assess_dmg;
1350 case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
1351 if (mhitb && !mdef->mcan && mwep) {
1352 (void) drain_item(mwep, FALSE);
1353 /* No message */
1354 }
1355 break;
1356 default:
1357 break;
1358 }
1359 if (mdead || mdef->mcan)
1360 return (mdead | mhit);

Callers 1

mattackmFunction · 0.85

Calls 15

dFunction · 0.85
rn2Function · 0.85
MonnamFunction · 0.85
canseemonFunction · 0.85
s_suffixFunction · 0.85
mon_namFunction · 0.85
hliquidFunction · 0.85
erode_armorFunction · 0.85
acid_damageFunction · 0.85
drain_itemFunction · 0.85
strNsubstFunction · 0.85
mon_reflectsFunction · 0.85

Tested by

no test coverage detected