Re: [Newbie] Coding question on traps

From: Shane P. Lee (tacodog21@yahoo.com)
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 ftp.circlemud.org 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.

***WARNING*** MAILER CODE FOLLOWS!

/* 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 */
    return;

   } 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 :-)
-FIRE



=====
"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.
http://auctions.yahoo.com/

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



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