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

Function fire_damage

src/trap.c:4454–4542  ·  view source on GitHub ↗

Set an item on fire. Return whether the object was destroyed. */

Source from the content-addressed store, hash-verified

4452
4453/* Set an item on fire. Return whether the object was destroyed. */
4454boolean
4455fire_damage(
4456 struct obj *obj,
4457 boolean force, /* if True, skip luck-based protection check */
4458 coordxy x, coordxy y) /* where to place contents of burned up container */
4459{
4460 int chance;
4461 struct obj *otmp, *ncobj;
4462 int in_sight = !Blind && couldsee(x, y); /* Don't care if it's lit */
4463 int dindx;
4464
4465 /* object might light in a controlled manner */
4466 if (catch_lit(obj))
4467 return FALSE;
4468
4469 if (Is_container(obj) || obj->otyp == STATUE) {
4470 switch (obj->otyp) {
4471 case STATUE:
4472 case ICE_BOX:
4473 return FALSE; /* Immune */
4474 case CHEST:
4475 chance = 40;
4476 break;
4477 case LARGE_BOX:
4478 chance = 30;
4479 break;
4480 default:
4481 chance = 20;
4482 break;
4483 }
4484 if ((!force && (Luck + 5) > rn2(chance))
4485 /* note: containers aren't subject to erosion so are never
4486 marked fireproof/corrodeproof/&c */
4487 /*|| (is_flammable(obj) && obj->oerodeproof)*/
4488 ) {
4489 return FALSE;
4490 }
4491 /* Container is burnt up - dump contents out */
4492 if (in_sight)
4493 pline("%s catches fire and burns.", Yname2(obj));
4494 if (Has_contents(obj)) {
4495 if (in_sight)
4496 pline("Its contents fall out.");
4497 for (otmp = obj->cobj; otmp; otmp = ncobj) {
4498 ncobj = otmp->nobj;
4499 obj_extract_self(otmp);
4500 if (!flooreffects(otmp, x, y, ""))
4501 place_object(otmp, x, y);
4502 }
4503 }
4504 setnotworn(obj);
4505 delobj(obj);
4506 return TRUE;
4507 } else if (!force && (Luck + 5) > rn2(20)) {
4508 /* chance per item of sustaining damage:
4509 * max luck (Luck==13): 10%
4510 * avg luck (Luck==0): 75%
4511 * awful luck (Luck<-4): 100%

Callers 5

potion_dipFunction · 0.85
use_pick_axe2Function · 0.85
fire_damage_chainFunction · 0.85
lava_damageFunction · 0.85
use_whipFunction · 0.85

Calls 12

catch_litFunction · 0.85
rn2Function · 0.85
Yname2Function · 0.85
obj_extract_selfFunction · 0.85
flooreffectsFunction · 0.85
place_objectFunction · 0.85
setnotwornFunction · 0.85
delobjFunction · 0.85
theFunction · 0.85
xnameFunction · 0.85
erode_objFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected