* Object obj was hit by the effect of the wand/spell otmp. Return * non-zero if the wand/spell had any effect. */
| 2116 | * non-zero if the wand/spell had any effect. |
| 2117 | */ |
| 2118 | int |
| 2119 | bhito(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 |
no test coverage detected