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

Function burn_floor_objects

src/zap.c:4597–4656  ·  view source on GitHub ↗

* burn objects (such as scrolls and spellbooks) on floor * at position x,y; return the number of objects burned */

Source from the content-addressed store, hash-verified

4595 * at position x,y; return the number of objects burned
4596 */
4597int
4598burn_floor_objects(
4599 coordxy x, coordxy y,
4600 boolean give_feedback, /* caller needs to decide about visibility checks */
4601 boolean u_caused)
4602{
4603 struct obj *obj, *obj2;
4604 long i, scrquan, delquan;
4605 char buf1[BUFSZ], buf2[BUFSZ];
4606 int cnt = 0;
4607
4608 for (obj = svl.level.objects[x][y]; obj; obj = obj2) {
4609 obj2 = obj->nexthere;
4610 if (obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS
4611 || (obj->oclass == FOOD_CLASS
4612 && obj->otyp == GLOB_OF_GREEN_SLIME)) {
4613 if (obj->otyp == SCR_FIRE || obj->otyp == SPE_FIREBALL
4614 || obj_resists(obj, 2, 100))
4615 continue;
4616 scrquan = obj->quan; /* number present */
4617 delquan = 0L; /* number to destroy */
4618 for (i = scrquan; i > 0L; i--)
4619 if (!rn2(3))
4620 delquan++;
4621 if (delquan) {
4622 /* save name before potential delobj() */
4623 if (give_feedback) {
4624 obj->quan = 1L;
4625 Strcpy(buf1, u_at(x, y)
4626 ? xname(obj)
4627 : distant_name(obj, xname));
4628 obj->quan = 2L;
4629 Strcpy(buf2, u_at(x, y)
4630 ? xname(obj)
4631 : distant_name(obj, xname));
4632 obj->quan = scrquan;
4633 }
4634 /* useupf(), which charges, only if hero caused damage */
4635 if (u_caused)
4636 useupf(obj, delquan);
4637 else if (delquan < scrquan) {
4638 obj->quan -= delquan;
4639 obj->owt = weight(obj);
4640 } else
4641 delobj(obj);
4642 cnt += delquan;
4643 if (give_feedback) {
4644 if (delquan > 1L)
4645 pline("%ld %s burn.", delquan, buf2);
4646 else
4647 pline("%s burns.", An(buf1));
4648 }
4649 }
4650 }
4651 }
4652 /* This also ignites floor items, but does not change cnt
4653 because they weren't consumed. */
4654 ignite_items(svl.level.objects[x][y]);

Callers 3

trapeffect_fire_trapFunction · 0.85
dofiretrapFunction · 0.85
zap_over_floorFunction · 0.85

Calls 10

obj_resistsFunction · 0.85
rn2Function · 0.85
xnameFunction · 0.85
distant_nameFunction · 0.85
useupfFunction · 0.85
weightFunction · 0.85
delobjFunction · 0.85
AnFunction · 0.85
ignite_itemsFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected