MCPcopy Index your code
hub / github.com/NetHack/NetHack / bhito

Function bhito

src/zap.c:2118–2424  ·  view source on GitHub ↗

* Object obj was hit by the effect of the wand/spell otmp. Return * non-zero if the wand/spell had any effect. */

Source from the content-addressed store, hash-verified

2116 * non-zero if the wand/spell had any effect.
2117 */
2118int
2119bhito(struct obj *obj, struct obj *otmp)
2120{
2121 int res = 1; /* affected object by default */
2122 boolean learn_it = FALSE, maybelearnit;
2123
2124 /* fundamental: a wand effect hitting itself doesn't do anything;
2125 otherwise we need to guard against accessing otmp after something
2126 strange has happened to it (along the lines of polymorph or
2127 stone-to-flesh [which aren't good examples since polymorph wands
2128 aren't affected by polymorph zaps and stone-to-flesh isn't
2129 available in wand form, but the concept still applies...]) */
2130 if (obj == otmp)
2131 return 0;
2132
2133 if (obj->bypass) {
2134 /* The bypass bit is currently only used as follows:
2135 *
2136 * POLYMORPH - When a monster being polymorphed drops something
2137 * from its inventory as a result of the change.
2138 * If the items fall to the floor, they are not
2139 * subject to direct subsequent polymorphing
2140 * themselves on that same zap. This makes it
2141 * consistent with items that remain in the monster's
2142 * inventory. They are not polymorphed either.
2143 * UNDEAD_TURNING - When an undead creature gets killed via
2144 * undead turning, prevent its corpse from being
2145 * immediately revived by the same effect.
2146 * STONE_TO_FLESH - If a statue can't be revived, its
2147 * contents get dropped before turning it into
2148 * meat; prevent those contents from being hit.
2149 * retouch_equipment() - bypass flag is used to track which
2150 * items have been handled (bhito isn't involved).
2151 * menu_drop(), askchain() - inventory traversal where multiple
2152 * Drop can alter the invent chain while traversal
2153 * is in progress (bhito isn't involved).
2154 * destroy_items() - inventory traversal where item destruction can
2155 * trigger drop or destruction of other item(s) and alter
2156 * the invent or mon->minvent chain, possibly recursively.
2157 *
2158 * The bypass bit on all objects is reset each turn, whenever
2159 * svc.context.bypasses is set.
2160 *
2161 * We check the obj->bypass bit above AND svc.context.bypasses
2162 * as a safeguard against any stray occurrence left in an obj
2163 * struct someplace, although that should never happen.
2164 */
2165 if (svc.context.bypasses) {
2166 return 0;
2167 } else {
2168 debugpline1("%s for a moment.", Tobjnam(obj, "pulsate"));
2169 obj->bypass = 0;
2170 }
2171 }
2172
2173 /*
2174 * Some parts of this function expect the object to be on the floor
2175 * obj->{ox,oy} to be valid. The exception to this (so far) is

Callers 2

zapyourselfFunction · 0.85
zap_updownFunction · 0.85

Calls 15

TobjnamFunction · 0.85
unpunishFunction · 0.85
obj_unpolyableFunction · 0.85
livelog_printfFunction · 0.85
boxlockFunction · 0.85
obj_shuddersFunction · 0.85
do_osshockFunction · 0.85
hideunderFunction · 0.85
poly_objFunction · 0.85
newsymFunction · 0.85
observe_objectFunction · 0.85
YouFunction · 0.85

Tested by

no test coverage detected