Trapped Items/Disarm Trap

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
6 years 2 weeks ago #305 by Papaya Pete
Trapped Items/Disarm Trap was created by Papaya Pete
I can't really think of a mud in which I've seen this, but is there a snippit out there for adding traps to doors and containers? Going along with that, of course, would be the disarm/disable trap skill.

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

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
10 months 3 weeks ago - 10 months 3 weeks ago #6832 by Papaya Pete
Replied by Papaya Pete on topic Trapped Items/Disarm Trap
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.
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...
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.
/** 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"
};
/* 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!
Last edit: 10 months 3 weeks ago by Papaya Pete. Reason: Just making a small note.

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

More
10 months 3 weeks ago #6833 by thomas
Replied by thomas on topic Trapped Items/Disarm Trap
Hi :)

From structs.h:
struct room_direction_data
{
  char *general_description; /**< Show to char looking in this direction. */

  char *keyword; /**< for interacting (open/close) this direction */

  sh_int /*bitvector_t*/ exit_info; /**< Door, and what type? */
  obj_vnum key;      /**< Key's vnum (-1 for no key) */
  room_rnum to_room; /**< Where direction leads, or NOWHERE if not defined */
};
A door flag is a short (sh_int) which means that there are only 16 bits in it (numbered 0-15).
So, putting in "1 << 16" into it (where "1" here represents a 32-bit integer), overflows.
The behaviour of such an overflow is not specified in the C specs, so it is implementation-defined. Apparently, on your platform, it inserts -1 (ie, binary 1111111111111111) into the field.

Solution: make exit_info a bigger field, for instance an int. The world has moved on, memory is cheaper now.

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

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
10 months 3 weeks ago #6834 by Papaya Pete
Replied by Papaya Pete on topic Trapped Items/Disarm Trap
I figured it was something so simple! And I thought it was so strange how it just stopped right at the same flag. Thank you!

I've gotten traps to work on exits; now I'm working on how a character can search for them. It's likely because it's so late at night, but before I ask any questions I'll keep looking it over. Usually, I just look at how other functions do what I need to do (example: finding the exit the player is wanting to search, and if it's an invalid exit, telling the player "That's not an exit.").

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

More
10 months 2 weeks ago #6837 by thomas
Replied by thomas on topic Trapped Items/Disarm Trap
What have you tried? I would look at the lock/unlock/open code for doors for seeing how those are iterated over.

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

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
10 months 2 weeks ago #6842 by Papaya Pete
Replied by Papaya Pete on topic Trapped Items/Disarm Trap
I cannot remember what I was trying at first but I remembered that I had done something similar (reading what direction the player wanted to do something) before in the spy skill snippet. I used that and it compiles fine. I have a working exittrap function that sets off traps (or disarmed them), depending on the situation. The skill to search for traps is almost in place, I just have to double check things and test it before I move on.

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

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
10 months 2 weeks ago - 10 months 2 weeks ago #6844 by Papaya Pete
Replied by Papaya Pete on topic Trapped Items/Disarm Trap
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.
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.
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...
#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.
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.
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...
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: 10 months 2 weeks ago by Papaya Pete. Reason: Forgot some information.

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

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
10 months 2 weeks ago #6845 by Papaya Pete
Replied by Papaya Pete on topic Trapped Items/Disarm Trap
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!
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.
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.

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
10 months 2 weeks ago #6846 by Papaya Pete
Replied by Papaya Pete on topic Trapped Items/Disarm Trap
Got it.
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.

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
9 months 3 weeks ago #6924 by Papaya Pete
Replied by Papaya Pete on topic Trapped Items/Disarm Trap
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.

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
9 months 3 weeks ago - 9 months 3 weeks ago #6925 by Papaya Pete
Replied by Papaya Pete on topic Trapped Items/Disarm Trap
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.
} 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: 9 months 3 weeks ago by Papaya Pete. Reason: Finished the txt file.

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

More
9 months 3 weeks ago #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
#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.

  • Papaya Pete
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
9 months 2 weeks ago #6927 by Papaya Pete
Replied by Papaya Pete on topic Trapped Items/Disarm Trap
That's a great idea! I'm going to make that change, I didn't even think of adding that to structs.h. honestly I was losing track of what those numbers meant as I was writing.

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

Time to create page: 1.672 seconds