Wow, 5 years? It's been that long since I asked this question? Time flies when you're having fun!
I've been working on this snippet as I've been in the mood to code again recently. It's been years though, and I'm a bit rusty, so I'm having an issue that I can't figure out (but is most likely very simple and I'm missing it).
I'm adding traps to exits and containers by using flags, taking advantage of a door flag system someone else on here (name fails me) set up. It's pretty basic: if you want an exit to have a trap, turn on the TRAPPED flag along with whatever desired trap you have in mind (I'm making a long list of different traps that can be used, with them doing progressively more damage the further down the list you go). You can even have multiple traps, with them blocking your progress through the exit until they are disarmed/fired off. You can also set whether they reset themselves; will those traps keep firing off each time you go through an exit, or just once when you pass through?
Anyways, here's the issue.
Code:
1) DOOR 2) PICKPROOF
3) LOCKED 4) CLOSED
5) HIDDEN 6) CLIMBING
7) JUMPING 8) TRAPPED
9) TRAPBLOCK 10) TRAPRESET
11) WSICKTRAP 12) DARTTRAP
13) PRANKSTER 14) WPOISONTRAP
15) WFLAMETRAP 16) SBLADETRAP
17) MFLAMETRAP 18) ARROWTRAP
19) SPIKETRAP 20) LBLADETRAP
21) SHOCKTRAP 22) MSICKTRAP
23) MPOISONTRAP 24) LSICKTRAP
25) LPOISONTRAP 26) LFLAMETRAP
Exit flags: NOBITS
Enter Exit flags, 0 to quit :
This is what my exit flag menu looks like. Looks Ok, and I can toggle on and off flags 1-15 just fine. However, when I toggle flag 16...
Code:
1) DOOR 2) PICKPROOF
3) LOCKED 4) CLOSED
5) HIDDEN 6) CLIMBING
7) JUMPING 8) TRAPPED
9) TRAPBLOCK 10) TRAPRESET
11) WSICKTRAP 12) DARTTRAP
13) PRANKSTER 14) WPOISONTRAP
15) WFLAMETRAP 16) SBLADETRAP
17) MFLAMETRAP 18) ARROWTRAP
19) SPIKETRAP 20) LBLADETRAP
21) SHOCKTRAP 22) MSICKTRAP
23) MPOISONTRAP 24) LSICKTRAP
25) LPOISONTRAP 26) LFLAMETRAP
Exit flags: SBLADETRAP MFLAMETRAP ARROWTRAP SPIKETRAP LBLADETRAP SHOCKTRAP MSICKTRAP MPOISONTRAP LSICKTRAP LPOISONTRAP LFLAMETRAP UNDEFINED UNDEFINED UNDEFINED UNDEFINED UNDEFINED UNDEFINED
Enter Exit flags, 0 to quit :
I get this mess. I've doubled check constants.c and structs.h; I've seen this before and it was goofing up in these spots.
Code:
/** Exit bits for doors.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *exit_bits[] = {
"DOOR",
"PICKPROOF",
"LOCKED",
"CLOSED",
"HIDDEN",
"CLIMBING",
"JUMPING",
"TRAPPED",
"TRAPBLOCK",
"TRAPRESET",
"WSICKTRAP",
"DARTTRAP",
"PRANKSTER",
"WPOISONTRAP",
"WFLAMETRAP",
"SBLADETRAP",
"MFLAMETRAP",
"ARROWTRAP",
"SPIKETRAP",
"LBLADETRAP",
"SHOCKTRAP",
"MSICKTRAP",
"MPOISONTRAP",
"LSICKTRAP",
"LPOISONTRAP",
"LFLAMETRAP",
"\n"
};
Code:
/* Exit info: used in room_data.dir_option.exit_info */
#define EX_ISDOOR (1 << 0) /**< Exit is a door */
#define EX_PICKPROOF (1 << 1) /**< The door is closed */
#define EX_LOCKED (1 << 2) /**< The door is locked */
#define EX_CLOSED (1 << 3) /**< Lock can't be picked */
#define EX_HIDDEN (1 << 4) /**< Exit is hidden, secret */
#define EX_CLIMBING (1 << 5) /**< Requires one to climb to pass through */
#define EX_JUMPING (1 << 6) /**< Requires one to jump to pass through */
#define EX_TRAPPED (1 << 7) /**< Exit is trapped, used for checking */
#define EX_TRAPBLOCK (1 << 8) /**< Trap prevents players from passing through */
#define EX_TRAPRESET (1 << 9) /**< Trap automatically resets itself. */
#define EX_WSICKTRAP (1 << 10) /**< Trapped, is a weak sickness trap. */
#define EX_DARTTRAP (1 << 11) /**< Trapped, weak dart trap */
#define EX_PRANKSTER (1 << 12) /**< Trapped, hammer swings down from ceiling. */
#define EX_WPOISONTRAP (1 << 13) /**< Trapped, is a weak poison trap. */
#define EX_WFLAMETRAP (1 << 14) /**< Trapped, weak flame trap */
#define EX_SBLADETRAP (1 << 15) /**< Trapped, a small blade */
#define EX_MFLAMETRAP (1 << 16) /**< is a medium fire trap. */
#define EX_ARROWTRAP (1 << 17) /**< arrows shoot out */
#define EX_SPIKETRAP (1 << 18) /**< spikes eject out of the ground but retract */
#define EX_LBLADETRAP (1 << 19) /**< a large circular blade trap */
#define EX_SHOCKTRAP (1 << 20) /**< shocking trap */
#define EX_MSICKTRAP (1 << 21) /**< Major illness trap */
#define EX_MPOISONTRAP (1 << 22) /**< major poison trap */
#define EX_LSICKTRAP (1 << 23) /**< lethal illness trap */
#define EX_LPOISONTRAP (1 << 24) /**< lethal poison trap */
#define EX_LFLAMETRAP (1 << 25) /**< a large explosion */
#define NUM_EXIT_FLAGS 26
Everything here looks fine. When I try to toggle any flags after 16, nothing happens. Nothing is turned off or on. Any ideas what I did wrong here? Did I just put in too many flags and broke it? Any thoughts or direction would be greatly appreciated.
Edit: I see someone else is working on this too, that's great! I've actually gotten the traps to work thus far; they will do damage depending on the trap that is triggered, and give an appropriate message. Traps that block the exit work that way, but I haven't put in traps reseting themselves (at this point they automatically do; they'll keep going off each time the exit is passed through) nor single-use traps losing their trap flags on use. Before I add in trap detection and disarming I wanted to put the traps in completely. One thing at a time, am I right? Cheers!