Alright, so I now have the search ability working. If you search for a trap without inputting an exit or choosing one that does not exist, it'll kick back a "Which direction do you want to search?" If you search an exit, it will check your appropriate skill. If you succeed, it will display (by means of a short blurb like, "There's a small gas trap here.") all traps that are attached to that exit. If you fail, it will say you found nothing. If you fail by more than 20, it sets off all traps. If there was a successful skill check and there were no traps, it will say you found nothing; it'll be the exact same message if you failed the check.
Now that I did that, I'm working on being able to use zedit to stick those trap flags on exits. I've tried a little bit, but I'm a little confused by how it chooses to save those flags.
I did a little experimenting (I figured it wouldn't work but I wanted to see how the game would react if I did this), and changed part of zedit.
Code:
static void zedit_disp_arg3(struct descriptor_data *d)
{
write_to_output(d, "\r\n");
switch (OLC_CMD(d).command) {
case 'E':
column_list(d->character, 0, equipment_types, NUM_WEARS, TRUE);
write_to_output(d, "Location to equip : ");
break;
case 'P':
write_to_output(d, "Virtual number of the container : ");
break;
case 'D':
write_to_output(d, "0) Door open\r\n"
"1) Door closed\r\n"
"2) Door locked\r\n"
"3) Exit Trapped\r\n"
"4) Exit Blocked by Trap\r\n"
"5) Trap Autoresets\r\n"
"6) Weak Gas Trap\r\n"
"7) Dart Trap\r\n"
"8) Prankster Trap\r\n"
"9) Poison Gas Trap\r\n"
"10) Small Flame Trap\r\n"
"11) Small Blade Trap\r\n"
"12) Medium Flame Trap\r\n"
"13) Arrow Trap\r\n"
"14) Spike Trap\r\n"
"15) Large Blade Trap\r\n"
"16) Shock Trap\r\n"
"17) Explosion Trap\r\n"
"Enter state of the door : ");
break;
case 'V':
case 'T':
case 'M':
case 'O':
case 'R':
case 'G':
default:
/* We should never get here, just in case. */
cleanup_olc(d, CLEANUP_ALL);
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: zedit_disp_arg3(): Help!");
write_to_output(d, "Oops...\r\n");
return;
}
OLC_MODE(d) = ZEDIT_ARG3;
}
That displays argument 3 options. So for doors/exits, it would show you the option (normally) to set the door as open, closed, or locked. Here is where your input is saved, and I'll mark where I made a change.
Code:
case ZEDIT_ARG3:
/* Parse the input for arg3, and go back to main menu. */
if (!isdigit(*arg)) {
write_to_output(d, "Must be a numeric value, try again : ");
return;
}
switch (OLC_CMD(d).command) {
case 'E':
pos = atoi(arg) - 1;
/* Count number of wear positions. */
if (pos < 0 || pos >= NUM_WEARS)
write_to_output(d, "Try again : ");
else {
OLC_CMD(d).arg3 = pos;
zedit_disp_menu(d);
}
break;
case 'P':
if ((pos = real_object(atoi(arg))) != NOTHING) {
OLC_CMD(d).arg3 = pos;
zedit_disp_menu(d);
} else
write_to_output(d, "That object does not exist, try again : ");
break;
case 'D':
pos = atoi(arg);
if (pos < 0 || pos > 17) // Changed this here. Originally it was pos > 2... 0 for open, 1 for closed, 2 for locked
write_to_output(d, "Try again : ");
else {
OLC_CMD(d).arg3 = pos;
zedit_disp_menu(d);
}
break;
case 'M':
case 'O':
case 'G':
case 'R':
case 'T':
case 'V':
default:
/* We should never get here, but just in case. */
cleanup_olc(d, CLEANUP_ALL);
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: zedit_parse(): case ARG3: Ack!");
write_to_output(d, "Oops...\r\n");
break;
}
break;
Here is where I am confused. How are these values saved? I set up an exit to be closed, locked, trapped, and have a trap on it (this time the poison gas trap). Honestly, I expected different flags to be thrown up instead of trapped. In structs.h...
Code:
#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 */
I expected to have a Hidden flag set for that exit.
This is probably something else that is simple but eludes me. If someone can please explain how this is all saved to file (I tried reading the wld file that has that room, not familiar with the method it records flags on there), I think it would clear up a lot for me.
Overall this is coming out pretty good; I'm looking forward to sharing the results of this work once it's complete!
Edit:
I forgot to show what I see when using zedit, redit, etc. Also, it is behaving a little differently than I experienced last night.
So, here is what the zedit looks like after I try having a door set as closed, locked, trapped, and dart trapped.
Code:
Room number: 1000 Room zone: 10
1) Builders : None.
Z) Zone name : OOC Grid and Tutorial Area
L) Lifespan : 24 minutes
B) Bottom of zone : 1000
T) Top of zone : 1199
R) Reset Mode : Normal reset.
F) Zone Flags : NOBITS
M) Level Range : <Not Set!>
[Command list]
0 - Set door east as closed.
1 - then Set door east as locked.
2 - then Set door east as locked.
3 - then Set door east as locked.
4 - <END OF LIST>
N) Insert new command.
E) Edit a command.
D) Delete a command.
Q) Quit
Enter your choice :
I know why #2 says locked, not trapped: there's that strange if statement in a different function...
Note, this is in the zedit_disp_menu function, which displays the main menu.
Code:
case 'D':
write_to_output(d, "%sSet door %s as %s.",
MYCMD.if_flag ? " then " : "",
dirs[MYCMD.arg2],
MYCMD.arg3 ? ((MYCMD.arg3 == 1) ? "closed" : "locked") : "open"
);
break;
It will only display closed, locked, or open. Not any other flags. So if I am going to change this, I am going to have to rewrite it (I'm sorry, that is just so hard for me to read).
Back on topic; we know what the zedit looks like. Closed, locked, trapped, dart trapped. However, when you look at the exit itself, after a zone reset, in redit...
Code:
1) Exit to : 1002
2) Description :-
<NONE>
3) Door name : door
4) Key : 0
5) Exit flags : DOOR LOCKED CLOSED
6) Purge exit.
Enter choice, 0 to quit :
Only the locked and closed flags have been toggled on (the door one I set on that exit before messing with zedit).
So, it is behaving differently than I thought: it doesn't even set the exit as Trapped. I actually toggled that on myself earlier. I will keep looking this over, but I don't really see how to make this work atm.