Add hallucinatory trap names

This adds many funny, realistic, and nonsensical traps to the game, to
be shown when the player is hallucinating.

Architecturally, the biggest change is merging the what_trap macro and
the "defsyms[trap_to_defsym(ttyp)].explanation" pattern into a single
function "trapname", which returns the name of the trap, handling the
hallucination case. There is also a second parameter used for overriding
hallucination in the occasional cases where the actual trap name should
always be returned.

In addition, the what_trap and random_trap macros are now obsolete and
not used anywhere, so they are removed.
This commit is contained in:
copperwater
2019-01-06 00:56:05 -05:00
parent b2ad4651f3
commit 31ea7c1f62
13 changed files with 84 additions and 52 deletions

View File

@@ -142,25 +142,21 @@
/*
* random_monster()
* random_object()
* random_trap()
*
* Respectively return a random monster, object, or trap number.
* Respectively return a random monster or object.
*/
#define random_monster() rn2(NUMMONS)
#define random_object() rn1(NUM_OBJECTS - 1, 1)
#define random_trap() rn1(TRAPNUM - 1, 1)
/*
* what_obj()
* what_mon()
* what_trap()
*
* If hallucinating, choose a random object/monster, otherwise, use the one
* given.
*/
#define what_obj(obj) (Hallucination ? random_object() : obj)
#define what_mon(mon) (Hallucination ? random_monster() : mon)
#define what_trap(trp) (Hallucination ? random_trap() : trp)
/*
* covers_objects()
@@ -319,7 +315,7 @@
((((expltype) * MAXEXPCHARS) + ((idx) - S_explode1)) + GLYPH_EXPLODE_OFF)
#define trap_to_glyph(trap) \
cmap_to_glyph(trap_to_defsym(what_trap((trap)->ttyp)))
cmap_to_glyph(trap_to_defsym((trap)->ttyp))
/* Not affected by hallucination. Gives a generic body for CORPSE */
/* MRKR: ...and the generic statue */

View File

@@ -2499,6 +2499,7 @@ E boolean FDECL(uteetering_at_seen_pit, (struct trap *));
E boolean NDECL(lava_effects);
E void NDECL(sink_into_lava);
E void NDECL(sokoban_guilt);
E const char * FDECL(trapname, (int, BOOLEAN_P));
/* ### u_init.c ### */