some zap.c formatting

This commit is contained in:
PatR
2024-04-01 14:18:25 -07:00
parent 40e3b3b64a
commit de69dd750b
+31 -34
View File
@@ -340,11 +340,10 @@ bhitm(struct monst *mtmp, struct obj *otmp)
pline("%s turns transparent!", nambuf); pline("%s turns transparent!", nambuf);
reveal_invis = TRUE; reveal_invis = TRUE;
learn_it = TRUE; learn_it = TRUE;
} } else if (couldsee && !canseemon(mtmp)) {
else if (couldsee && !canseemon(mtmp)) {
/* keep the immediate effects of make invisible and teleportation /* keep the immediate effects of make invisible and teleportation
* ambiguous by using the same message that's used if we teleported ambiguous by using the same message that's used if we
* mtmp (and it ended up somewhere you can't see) */ teleported mtmp (and it ended up somewhere you can't see) */
pline("%s vanishes!", nambuf); pline("%s vanishes!", nambuf);
} }
break; break;
@@ -5442,8 +5441,8 @@ break_statue(struct obj *obj)
return TRUE; return TRUE;
} }
/* Return TRUE if obj is eligible to pass to maybe_destroy_item given the type of /* Return TRUE if obj is eligible to pass to maybe_destroy_item given
* elemental damage it's being subjected to. * the type of elemental damage it's being subjected to.
* Note that things like the Book of the Dead are eligible even though they * Note that things like the Book of the Dead are eligible even though they
* won't get destroyed, because it will attempt to be destroyed but print a * won't get destroyed, because it will attempt to be destroyed but print a
* special message instead. */ * special message instead. */
@@ -5621,10 +5620,10 @@ const char *const destroy_strings[][3] = {
}; };
/* guts of destroy_items(); /* guts of destroy_items();
caller must decide whether obj is eligible, though there's one case (Book of caller must decide whether obj is eligible, though there's one case (Book
the Dead) in which an eligible item shouldn't be destroyed (it prints a of the Dead) in which an eligible item shouldn't be destroyed (it prints a
special message instead). special message instead).
Returns the amount of damage done, but this is used differently depending on Returns the amount of damage done, but it's used differently depending on
whether it's the player or a monster having an item destroyed: players lose whether it's the player or a monster having an item destroyed: players lose
the HP and possibly die in this function, and the return value is unused, the HP and possibly die in this function, and the return value is unused,
whereas monsters return the damage to their caller to be taken off later */ whereas monsters return the damage to their caller to be taken off later */
@@ -5735,19 +5734,19 @@ maybe_destroy_item(
return 0; return 0;
if (u_carry || vis) { if (u_carry || vis) {
mult = (cnt == 1L) mult = (cnt == 1L) ? ((quan == 1L) ? "" /* 1 of 1 */
? ((quan == 1L) ? "" /* 1 of 1 */ : "One of ") /* 1 of N */
: "One of ") /* 1 of N */ : ((cnt < quan) ? "Some of " /* n of N */
: ((cnt < quan) ? "Some of " /* n of N */ : (quan == 2L) ? "Both of " /* 2 of 2 */
: (quan == 2L) ? "Both of " /* 2 of 2 */ : "All of "); /* N of N */
: "All of "); /* N of N */
pline("%s%s %s!", mult, pline("%s%s %s!", mult,
(cnt == 1L && quan == 1L) ? Yname2(obj) : yname(obj), (cnt == 1L && quan == 1L) ? Yname2(obj) : yname(obj),
destroy_strings[dindx][(cnt > 1L)]); destroy_strings[dindx][(cnt > 1L)]);
} }
if (u_carry) { /* effects that happen only to the player */ if (u_carry) { /* effects that happen only to the player */
if (osym == POTION_CLASS && dmgtyp != AD_COLD if (osym == POTION_CLASS && dmgtyp != AD_COLD
&& (!breathless(gy.youmonst.data) || haseyes(gy.youmonst.data))) { && (!breathless(gy.youmonst.data)
|| haseyes(gy.youmonst.data))) {
potionbreathe(obj); potionbreathe(obj);
} }
if (obj->owornmask) { /* m_useup handles these for monster */ if (obj->owornmask) { /* m_useup handles these for monster */
@@ -5787,20 +5786,20 @@ maybe_destroy_item(
return dmg; return dmg;
} }
/* scaling factor; dmg/5 stacks of items will be subjected to destroy_items() */ /* scaling factor; dmg/5 stacks will be subjected to destroy_items() */
#define DMG_DESTROY_SCALE 5 #define DMG_DESTROY_SCALE 5
/* largest amount of stacks that will be destroyed in a single call */ /* largest amount of stacks that will be destroyed in a single call */
#define MAX_ITEMS_DESTROYED 20 #define MAX_ITEMS_DESTROYED 20
/* target items of specified class in mon's inventory for possible destruction /* target items of specified class in mon's inventory for possible destruction
* return total amount of damage inflicted, though this is unused if mon is the return total amount of damage inflicted, though this is unused if mon is
* player */ the player */
int int
destroy_items( destroy_items(
struct monst *mon, /* monster whose invent is being subjected to struct monst *mon, /* monster whose invent is being subjected to
* destruction */ * destruction */
int dmgtyp, /* AD_**** - currently only cold, fire, elec */ int dmgtyp, /* AD_**** - currently only cold, fire, elec */
int dmg_in) /* the amount of HP damage the attack dealt */ int dmg_in) /* the amount of HP damage the attack dealt */
{ {
struct obj *obj; struct obj *obj;
int i, defer; int i, defer;
@@ -5822,9 +5821,9 @@ destroy_items(
items_to_destroy[i].deferred = FALSE; items_to_destroy[i].deferred = FALSE;
} }
/* Don't straight up destroy all items with an equal chance; limit it based /* don't straight up destroy all items with an equal chance; limit it
* on the amount of damage being dealt by the source of the item based on the amount of damage being dealt by the source of the item
* destruction. */ destruction */
limit = dmg_in / DMG_DESTROY_SCALE; limit = dmg_in / DMG_DESTROY_SCALE;
if (dmg_in % DMG_DESTROY_SCALE > rn2(DMG_DESTROY_SCALE)) { if (dmg_in % DMG_DESTROY_SCALE > rn2(DMG_DESTROY_SCALE)) {
limit++; /* dmg = 9: 20% chance of limit=1, 80% of limit=2, etc */ limit++; /* dmg = 9: 20% chance of limit=1, 80% of limit=2, etc */
@@ -5895,8 +5894,7 @@ destroy_items(
|| (obj->otyp == POT_WATER && ismnum(u.ulycn) || (obj->otyp == POT_WATER && ismnum(u.ulycn)
&& (Upolyd ? obj->blessed : obj->cursed)))) { && (Upolyd ? obj->blessed : obj->cursed)))) {
items_to_destroy[i].deferred = TRUE; items_to_destroy[i].deferred = TRUE;
} } else {
else {
items_to_destroy[i].deferred = FALSE; items_to_destroy[i].deferred = FALSE;
} }
} }
@@ -5919,8 +5917,8 @@ destroy_items(
} }
} }
} }
/* almost certainly not everything was destroyed; remove bypass bit after it /* almost certainly not everything was destroyed; clear bypass bit after
* was set earlier */ it was set earlier */
bypass_objlist(*objchn, FALSE); bypass_objlist(*objchn, FALSE);
return dmg_out; return dmg_out;
} }
@@ -6123,7 +6121,7 @@ makewish(void)
else else
livelog_printf((LL_WISH | maybe_LL_arti), "wished for %s", wish); livelog_printf((LL_WISH | maybe_LL_arti), "wished for %s", wish);
/* TODO? maybe generate a second event describing what was received since /* TODO? maybe generate a second event describing what was received since
those just echo player's request rather than show actual result */ these just echo player's request rather than show actual result */
const char *verb = ((Is_airlevel(&u.uz) || u.uinwater) ? "slip" : "drop"), const char *verb = ((Is_airlevel(&u.uz) || u.uinwater) ? "slip" : "drop"),
*oops_msg = (u.uswallow *oops_msg = (u.uswallow
@@ -6153,12 +6151,11 @@ flash_str(
typ = zaptype(typ); typ = zaptype(typ);
if (Hallucination && !nohallu) { if (Hallucination && !nohallu) {
/* always return "blast of foo" for simplicity. /* always return "blast of foo" for simplicity;
* This could be extended with hallucinatory rays, but probably this could be extended with hallucinatory rays, but probably
* not worth it at this time. */ not worth it at this time */
Sprintf(fltxt, "blast of %s", rnd_hallublast()); Sprintf(fltxt, "blast of %s", rnd_hallublast());
} } else {
else {
Strcpy(fltxt, flash_types[typ]); Strcpy(fltxt, flash_types[typ]);
} }
return fltxt; return fltxt;