Welcome to the Builder Academy

Question Trapped Items/Disarm Trap

More
28 Aug 2017 08:03 - 28 Aug 2017 16:33 #6844 by Papaya Pete
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.
Last edit: 28 Aug 2017 16:33 by Papaya Pete. Reason: Forgot some information.

Please Log in or Create an account to join the conversation.

More
28 Aug 2017 17:21 #6845 by Papaya Pete
I hope people don't see this as being spammy; I wanted to post some of the progress I wanted to make, as it resolves (sort of) one of the issues I was having.

Before, in zedit, it would only show doors as "locked," "closed," or "opened." Setting any other values in zedit won't work, and will just show up as "locked." I've rewritten it so it will display more options than those three!
Code:
case 'D': if (MYCMD.if_flag) write_to_output(d, " then "); write_to_output(d, "Set exit %s as", dirs[MYCMD.arg2]); switch (MYCMD.arg3) { case 0: write_to_output(d, " open"); break; case 1: write_to_output(d, " closed"); break; case 2: write_to_output(d, " locked"); break; case 3: write_to_output(d, " trapped"); break; case 4: write_to_output(d, " blocked by a trap"); break; case 5: write_to_output(d, " trapped with autorest"); break; case 6: write_to_output(d, " weak gas trapped"); break; case 7: write_to_output(d, " dart trapped"); break; case 8: write_to_output(d, " prankstered"); break; case 9: write_to_output(d, " poison gas trapped"); break; case 10: write_to_output(d, " weak flame trapped"); break; case 11: write_to_output(d, " small blade trapped"); break; case 12: write_to_output(d, " medium flame trapped"); break; case 13: write_to_output(d, " arrow trapped"); break; case 14: write_to_output(d, " spike trapped"); break; case 15: write_to_output(d, " large blade trapped"); break; case 16: write_to_output(d, " shock trapped"); break; case 17: write_to_output(d, " explosion trapped"); break; default: write_to_output(d, " something else you shouldn't see"); break; } /* Keeping around this old code, just in case. 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;

Now what is interesting is, looking back at my attempt to set an exit as closed, locked, trapped, and dart trapped, it now displays this in the zedit, even after rebooting the mud and the zone reseting, etc.
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 exit east as closed 1 - then Set exit east as locked 2 - then Set exit east as trapped 3 - then Set exit east as dart trapped 4 - <END OF LIST> N) Insert new command. E) Edit a command. D) Delete a command. Q) Quit Enter your choice :

Now it still doesn't set the exit as trapped or dart trapped yet... but this is progress. I'm still trying to see how this is all saved and read, as it doesn't look like the options you're given in zedit ("0 for open, 1 for closed, 2 for locked") do not match up with the exit_flag numbers in structs.h. Will tell you more when I find something out.

Please Log in or Create an account to join the conversation.

More
28 Aug 2017 18:00 #6846 by Papaya Pete
Got it.
Code:
case 'D': /* set state of door */ if (ZCMD.arg2 < 0 || ZCMD.arg2 >= DIR_COUNT || (world[ZCMD.arg1].dir_option[ZCMD.arg2] == NULL)) { char error[MAX_INPUT_LENGTH]; snprintf(error, sizeof(error), "door does not exist in room %d - dir %d, command disabled", world[ZCMD.arg1].number, ZCMD.arg2); ZONE_ERROR(error); ZCMD.command = '*'; } else switch (ZCMD.arg3) { case 0: REMOVE_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_LOCKED); REMOVE_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_CLOSED); break; case 1: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_CLOSED); REMOVE_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_LOCKED); break; case 2: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_LOCKED); SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_CLOSED); break; case 3: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_TRAPPED); break; case 4: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_TRAPBLOCK); break; case 5: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_TRAPRESET); break; case 6: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_WSICKTRAP); break; case 7: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_DARTTRAP); break; case 8: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_PRANKSTER); break; case 9: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_WPOISONTRAP); break; case 10: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_WFLAMETRAP); break; case 11: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_SBLADETRAP); break; case 12: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_MFLAMETRAP); break; case 13: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_ARROWTRAP); break; case 14: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_SPIKETRAP); break; case 15: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_LBLADETRAP); break; case 16: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_SHOCKTRAP); break; case 17: SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info, EX_LFLAMETRAP); break; } last_cmd = 1; tmob = NULL; tobj = NULL; break;

In db.c, I found where the state of a door, that you set via zedit, is used. Now it makes sense the way they did it!

And the best part is... it works. Zedit now properly loads/sets those extra trap flags.

I've been writing all of these changes and mods down in a txt file I can upload... I should update it now before it looks like a headache to write up.
The following user(s) said Thank You: thomas

Please Log in or Create an account to join the conversation.

More
25 Sep 2017 07:34 #6924 by Papaya Pete
So it's been a while since I last gave an update; I had other things to take care of and got distracted on top of that. Here's where I'm at so far:

Exits have traps that you can detect and disarm. You can set them to go off repeatedly, block an exit, or both. If you accidentally set one off, roll a saving throw to take less damage. If you're trying to disarm the trap and fail badly enough, it blows up in your face and you take the brunt of the damage. Also, if you use a key on a trapped door, it automatically disarms all of the traps. Note: if you disarm the trap by using the skill, you gain XP.

Containers also have traps, though I did a lot less just to save myself some headache atm. The traps tend to be a little more dangerous than exit traps, but I've made them so that they only go off once. If you use a key on the container, it will automatically disarm all traps (just like exits above).

Another note: you can stack multiple traps on exits and containers. So if you wanted to be really mean, you can flag an exit with 8 different traps.

Next, I will be working on the "check" skill for searching for traps on containers and "defuse" to disable a trap in a container. After that, it will be a matter of putting it into a txt file for others to read and destr-- err enjoy.

I found that trying to use flags for traps seems to work pretty well so far. Likely someone else will find a better way to do it. These traps also only do damage, so for those wanting to throw on affects like poison you're better off using DG Scripts in game for that!

Please Log in or Create an account to join the conversation.

More
25 Sep 2017 18:16 - 25 Sep 2017 19:04 #6925 by Papaya Pete
I've added traps to containers and am in the process of putting all of this into a txt file for others to take a look. I've done SOME testing, to make sure the basics work (mostly with my Admin character; there shouldn't be any crashes).

I'll edit this post and attach the txt file once I'm done.

Edit: Done!

If you notice any bugs or have done any fixes, let me know so I can do them on my copy! And I'll post anything else that comes up as I continue to test this out more with actual PCs (gotta do some building first).

Not sure why I named it Emeril's Tricks and Traps snippet... probably because one day I was thinking, "BAM! Yer hit by a trap! BAM BAM BAM!"

Another edit: I found a small bug. Simple fix. Head to exittraps and make the following addition.
Code:
} else { send_to_char(ch, "\trThe last thing you hear before your ears are ringing is a powerful, booming blast. Flame and intense pressure engulf you, and you're sent flying back from the force of the explosion!\r\n"); act("\tRThere's a thundering explosion right where $n is standing, and $e is sent flying back from the sheer force of the blow!\tn\r\n", TRUE, ch, 0, 0, TO_ROOM); dam += rand_number(1,10) + rand_number(1, 10) + rand_number(1, 10) + rand_number(1, 10) + rand_number(1, 10) * 5; } if (trapreset == false) REMOVE_BIT(EXIT(ch, dir)->exit_info, EX_LFLAMETRAP); } + if (EXIT_FLAGGED(EXIT(ch, dir), EX_TRAPPED)) { + if (trapreset == false) + REMOVE_BIT(EXIT(ch, dir)->exit_info, EX_TRAPPED); + } }

I essentially forgot to have it remove the TRAPPED flag on an exit. This would result in getting a message "You set off a trap!" on an exit when there's no real traps on it.
Attachments:
Last edit: 25 Sep 2017 19:04 by Papaya Pete. Reason: Finished the txt file.
The following user(s) said Thank You: Chime

Please Log in or Create an account to join the conversation.

More
25 Sep 2017 19:49 #6926 by thomas
Replied by thomas on topic Trapped Items/Disarm Trap
I think it looks good.

One thing - I'd probably try to avoid the magic numbers in the calls to the exittrap and objtrap functions. I suggest adding them to structs.h as
Code:
#define TRAP_SITUATION_TRIGGERED_BY_USE 0 #define TRAP_SITUATION_TRIGGERED_BY_PICK 1 #define TRAP_SITUATION_DISARM_FAILED 2 #define TRAP_SITUATION_DISARM_BY_KEY 3
Note that because we use these everywhere, it doesn't matter that the numbers aren't the ones you wrote :P
The following user(s) said Thank You: Papaya Pete

Please Log in or Create an account to join the conversation.

Time to create page: 0.281 seconds