Set an item on fire. Return whether the object was destroyed. */
| 4452 | |
| 4453 | /* Set an item on fire. Return whether the object was destroyed. */ |
| 4454 | boolean |
| 4455 | fire_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% |
no test coverage detected