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

Function mm_2way_aggression

src/mon.c:2387–2420  ·  view source on GitHub ↗

Part of mm_aggression that represents two-way aggression. To avoid having to code each case twice, this function contains those cases that ought to happen twice, and mm_aggression will call it twice. */

Source from the content-addressed store, hash-verified

2385 having to code each case twice, this function contains those cases that
2386 ought to happen twice, and mm_aggression will call it twice. */
2387staticfn long
2388mm_2way_aggression(struct monst *magr, struct monst *mdef)
2389{
2390 if (On_W_tower_level(&u.uz)) {
2391 /* treat inside the Wizard's tower as if it were a separate level
2392 from outside so when hero is inside Wizard's tower, both monsters
2393 need to be too; when outside, the monsters need to be too */
2394 if (In_W_tower(u.ux, u.uy, &u.uz)
2395 ? (!In_W_tower(magr->mx, magr->my, &u.uz)
2396 || !In_W_tower(mdef->mx, mdef->my, &u.uz))
2397 : (In_W_tower(magr->mx, magr->my, &u.uz)
2398 || In_W_tower(mdef->mx, mdef->my, &u.uz)))
2399 return 0L;
2400 }
2401 /* liches/zombies vs things that can be zombified
2402
2403 Note: avoid this on the Castle level, partly for balance reasons
2404 (the monster-versus-monster fights clear out significant portions of
2405 the Castle and make it easier than it should be), partly for flavor
2406 reasons (monsters who attacked other monsters to zombify them would
2407 have been counterattacked to death long before the hero arrived).
2408
2409 Also don't include unique monsters in this, otherwise it leads to
2410 them waking up early (e.g. because a zombie decided to attack the
2411 Wizard of Yendor). */
2412 if (zombie_maker(magr) && zombie_form(mdef->data) != NON_PM) {
2413 if (magr->mgenmklev && mdef->mgenmklev)
2414 return 0L;
2415 if (!Is_stronghold(&u.uz)
2416 && !unique_corpstat(magr->data) && !unique_corpstat(mdef->data))
2417 return (ALLOW_M | ALLOW_TM);
2418 }
2419 return 0L;
2420}
2421
2422/* Monster against monster special attacks; for the specified monster
2423 combinations, this allows one monster to attack another adjacent one

Callers 1

mm_aggressionFunction · 0.85

Calls 4

On_W_tower_levelFunction · 0.85
In_W_towerFunction · 0.85
zombie_makerFunction · 0.85
zombie_formFunction · 0.85

Tested by

no test coverage detected