Re: [Newbie] Coding question on traps

From: Shane P. Lee (
Date: 01/21/01

Okay, what you need is a function that checks for traps
in the room whenever a player arrives. You can take a look
at the mount.diff file at for a good
idea of where to put this check.
I've written a quick check for you, but I haven't tried to
compile it, and I may have missed a few things.


/* this needs work, will not compile as-is -spl */
void check_traps(struct char_data *ch)
  struct obj_data *obj, *next_obj;
  int found = 0;

    for (obj = world[ch->in_room].contents; obj; obj = next_obj) {
      next_obj = obj->next_content;
      if (IS_TRAP(ch, obj) {
        found = 1;

    if (!found) {
    /* no traps exist */

   } else {
    /* move the player, or whatever the trap does here */

You would want to add this to act.movement.c, and then do a
check_traps(ch); every time a character enters or exits a room,
depending on when you want to call it.
There are several ways a player could enter a room; via goto,
transportation, teleportation, possibly through a portal (if
you have them), or even good old walking.

Hope this helps some, maybe at least give you an idea on where
to start :-)

"Here's something to think about:  How come you never see
a headline like `Psychic Wins Lottery'?"
                -- Jay Leno

Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.

   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 12/03/01 PST