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

Function lava_effects

src/trap.c:6793–6987  ·  view source on GitHub ↗

hero enters pool of molten lava; returns True if hero is killed and then life-saved (with teleport to safe spot), False for other survival; no return at all if hero dies and isn't life-saved */

Source from the content-addressed store, hash-verified

6791 then life-saved (with teleport to safe spot), False for other survival;
6792 no return at all if hero dies and isn't life-saved */
6793boolean
6794lava_effects(void)
6795{
6796 struct obj *obj, *obj2, *nextobj;
6797 boolean usurvive, boil_away;
6798 unsigned protect_oid = 0;
6799 int burncount = 0, burnmesgcount = 0;
6800 const int dmg = d(6, 6); /* only applicable for water walking */
6801
6802 if (iflags.in_lava_effects) {
6803 debugpline0("Skipping recursive lava_effects().");
6804 return FALSE;
6805 }
6806 feel_newsym(u.ux, u.uy); /* in case Blind, map the lava here */
6807 burn_away_slime();
6808 if (likes_lava(gy.youmonst.data))
6809 return FALSE;
6810
6811 usurvive = Fire_resistance || (Wwalking && dmg < u.uhp);
6812 /*
6813 * A timely interrupt might manage to salvage your life
6814 * but not your gear. For scrolls and potions this
6815 * will destroy whole stacks, where fire resistant hero
6816 * survivor only loses partial stacks via destroy_items().
6817 *
6818 * Flag items to be destroyed before any messages so
6819 * that player causing hangup at --More-- won't get an
6820 * emergency save file created before item destruction.
6821 */
6822 if (!usurvive) {
6823 for (obj = gi.invent; obj; obj = nextobj) {
6824 nextobj = obj->nobj;
6825 if (obj->in_use) { /* remove_worn_item() sets in_use */
6826 /* one item can be protected from burning up [accommodates
6827 steal(AMULET_OF_FLYING) -> remove_worn_item() -> fall
6828 into lava (which happens before item is transferred
6829 from invent to thief->minvent)]; item will still be in
6830 inventory when we return to caller or save bones (or
6831 perform hangup save if that occurs) */
6832 if (!protect_oid) {
6833 protect_oid = obj->o_id;
6834 obj->in_use = 0;
6835 } else {
6836 impossible(
6837 "lava_effects: '%s' (#%u) is already in use; so is #%u.",
6838 simpleonames(obj), obj->o_id, protect_oid);
6839 }
6840 continue;
6841 }
6842 /* set obj->in_use for items which will be destroyed below */
6843 if ((is_organic(obj) || obj->oclass == POTION_CLASS)
6844 && !obj->oerodeproof
6845 && objects[obj->otyp].oc_oprop != FIRE_RES
6846 && obj->otyp != SCR_FIRE && obj->otyp != SPE_FIREBALL
6847 && !obj_resists(obj, 0, 0)) /* for invocation items */
6848 obj->in_use = 1;
6849 }
6850 }

Callers 3

pooleffectsFunction · 0.85
float_downFunction · 0.85
e_diedFunction · 0.85

Calls 15

dFunction · 0.85
feel_newsymFunction · 0.85
burn_away_slimeFunction · 0.85
simpleonamesFunction · 0.85
obj_resistsFunction · 0.85
Yobjnam2Function · 0.85
Boots_offFunction · 0.85
useupFunction · 0.85
pline_TheFunction · 0.85
hliquidFunction · 0.85
losehpFunction · 0.85
YouFunction · 0.85

Tested by

no test coverage detected