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

Function passive_obj

src/uhitm.c:6126–6195  ·  view source on GitHub ↗

* Special (passive) attacks on an attacking object by monsters done here. * Assumes the attack was successful. */

Source from the content-addressed store, hash-verified

6124 * Assumes the attack was successful.
6125 */
6126void
6127passive_obj(
6128 struct monst *mon,
6129 struct obj *obj, /* null means pick uwep, uswapwep or uarmg */
6130 struct attack *mattk) /* null means we find one internally */
6131{
6132 struct permonst *ptr = mon->data;
6133 int i;
6134
6135 /* [this first bit is obsolete; we're not called with Null anymore] */
6136 /* if caller hasn't specified an object, use uwep, uswapwep or uarmg */
6137 if (!obj) {
6138 obj = (u.twoweap && uswapwep && !rn2(2)) ? uswapwep : uwep;
6139 if (!obj && mattk->adtyp == AD_ENCH)
6140 obj = uarmg; /* no weapon? then must be gloves */
6141 if (!obj)
6142 return; /* no object to affect */
6143 }
6144
6145 /* if caller hasn't specified an attack, find one */
6146 if (!mattk) {
6147 for (i = 0;; i++) {
6148 if (i >= NATTK)
6149 return; /* no passive attacks */
6150 if (ptr->mattk[i].aatyp == AT_NONE)
6151 break; /* try this one */
6152 }
6153 mattk = &(ptr->mattk[i]);
6154 }
6155
6156 switch (mattk->adtyp) {
6157 case AD_FIRE:
6158 if (!rn2(6) && !mon->mcan
6159 /* steam vortex: fire resist applies, fire damage doesn't */
6160 && mon->data != &mons[PM_STEAM_VORTEX]) {
6161 (void) erode_obj(obj, NULL, ERODE_BURN, EF_NONE);
6162 }
6163 break;
6164 case AD_ACID:
6165 if (!rn2(6)) {
6166 (void) erode_obj(obj, NULL, ERODE_CORRODE, EF_GREASE);
6167 }
6168 break;
6169 case AD_RUST:
6170 if (!mon->mcan) {
6171 (void) erode_obj(obj, (char *) 0, ERODE_RUST, EF_GREASE);
6172 }
6173 break;
6174 case AD_CORR:
6175 if (!mon->mcan) {
6176 (void) erode_obj(obj, (char *) 0, ERODE_CORRODE, EF_GREASE);
6177 }
6178 break;
6179 case AD_ENCH:
6180 if (!mon->mcan) {
6181 if (drain_item(obj, TRUE) && carried(obj)
6182 && (obj->known || obj->oclass == ARMOR_CLASS)) {
6183 pline("%s less effective.", Yobjnam2(obj, "seem"));

Callers 3

passiveFunction · 0.85
thitmonstFunction · 0.85
drop_throwFunction · 0.85

Calls 6

rn2Function · 0.85
erode_objFunction · 0.85
drain_itemFunction · 0.85
Yobjnam2Function · 0.85
update_inventoryFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected