Re: Teleport rooms

From: Chaotic (chaotic@eskimo.com)
Date: 03/31/96


On Sun, 31 Mar 1996, Daniel W. Burke wrote:

> Does anyone happen to have the email I posted explaining how to drop my
> modified SillyMUD telelport rooms code?
> I'd appreciate soemone sending it my way, so I don't have to retype it :)

i saved 2 of the messages about this.  i'm sending them to you and the
list in case anyone else wants the info again.

Lauren

..........[ snip -- start of msg1 ]..........

Date: Tue, 21 Nov 1995 07:45:23 -0800
From: "Daniel W. Burke" <dwb@ix.netcom.com>
To: circle@pvv.unit.no
Subject: Teleport Room code from SillyMUD WARNING LONG MESSAGE

WARNING!  LONG MESSAGE!

Here's a very long message with exact code as I implemented it into
CircleMUD 3.0bpl8

If you have any problems let me know without being nasty, and I'll
do my best to help, but of course I garuntee nothing :)

You need to move 'int pulse = 0;' to outside the main game loop so
it can be used as a global variable (possibly unnecessarily used).

Oh, I'm not sure, but I think I needed to add
#include "interpreter.h"
in utils.c to get it to work (I did add it to utils.c, but I don't
remember if it was for this specifically)

Oh, one IMPORTANT, all be it annoying problem....
The way the info is read at bootup, if there is ANY extra spaces at
the end of the line boot will fail at that room.
(It's defined on the line defining roomflags and sector)

The code is AS IS in my mud, but READ THE COMMENTS to make sure it's
inserted properly :)

And yes, I'm VERY happy with it, no problems have been noticed
since I got it working the day before I announced it here :)

Explination of syntax in wld file:

SillyMUD apparently had no docs to explaine this, so heres a
modified section from HoloMUD's builder doc, but most of it should
apply.  Please excuse my ignorance on the exact meanings of the syntax,
the authors of SillyMUD really should have made some docs :P


FLAG           BIT

TELE_LOOK       1        Do a look when teleported
TELE_COUNT      2        Uncertain exactly, but the code appears fine
TELE_RANDOM     4        Randomizes time teleport room teleports PCs
TELE_SPIN       8        <not implemented>


The Timer is a value in 1/4sec. So if you set the timer to 60, it
would be a 15sec timer. (This shouldn't apply)

SO, a teleport room would look like:

#8717
The Room Gets Hotter~
     The temperature has risen several degrees. The heat has now become
unbearable. It would be best to get out of this room NOW!!!!
~
45 589 -1 30 8718 1 0    <-------  FOCUS ON THIS LINE FOR NOW!!!
D1
~
door~
1 -1 8722
D2
~
~
0 -1 8720
S

We discuss what all that stuff means below.  For now, focus on
the line I have indicated:

45 589 -1 32 8718 1 0

           45 = zone number -- SEE below
          589 = room flags -- SEE below
           -1 = expect more room details
           32 = teleport fires every 8 seconds
         8718 = teleports to room 8718
            1 = TELE_LOOK
            0 = the real sector flag (Inside)





Brazil    -    Imp of AddictMUD   -   199.201.186.114 4000
doesn't always hit in all areas -> tolkien.realms.org 4000


Code is as follows:


/* File: structs.h */

#define PULSE_TELEPORT  (10 RL_SEC)

#define TELE_LOOK    1
#define TELE_COUNT   2
#define TELE_RANDOM  4
#define TELE_SPIN    8

/* add to struct room_data {*/

   int tele_time;
   int tele_targ;
   int tele_mask;
   int tele_cnt;


/*****************************************************************/

/* File: utils.c - this really could have gone in any file
 * but that's where I put it */

void TeleportPulseStuff(int pulse)
{
  ACMD(do_look);
   int real_room(int virtual);
  /*
    check_mobile_activity(pulse);
    Teleport(pulse);
    */

  register struct char_data *ch;
  struct char_data *next, *tmp, *bk;
  int tick, tm, troom = 0, sroom = 0;
  struct obj_data *obj_object, *temp_obj;

  tm = pulse % PULSE_MOBILE;    /* this is dependent on P_M = 3*P_T */

  if (tm == 0) {
    tick = 0;
  } else if (tm == PULSE_TELEPORT) {
    tick = 1;
  } else if (tm == PULSE_TELEPORT*2) {
    tick = 2;
  }

  for (ch = character_list; ch; ch = next) {
    next = ch->next;
    /* if (IS_MOB(ch)) {
     * if (ch->specials.tick == tick) {
     *   mobile_activity(ch);
     * }
     * } else */
    if (!IS_NPC(ch)) {
      if (world[ch->in_room].number &&
          world[ch->in_room].tele_targ > 0 &&
          world[ch->in_room].tele_targ != world[ch->in_room].number &&
          world[ch->in_room].tele_time > 0 &&
          (pulse % world[ch->in_room].tele_time)==0) {

        if (!world[real_room(world[ch->in_room].tele_targ)].number) {
          log("invalid tele_targ");
          continue;
        }
        troom = real_room(world[ch->in_room].tele_targ);
        sroom = real_room(world[ch->in_room].number);
        obj_object = world[troom].contents;
        while (obj_object) {
          temp_obj = obj_object->next_content;
          obj_from_room(obj_object);
          obj_to_room(obj_object, troom);
          obj_object = temp_obj;
        }

        bk = 0;

        while(world[sroom].people/* should never fail */) {

          tmp = world[sroom].people;   /* work through the list of
people */
          if (!tmp) break;

          if (tmp == bk) break;

          bk = tmp;

          char_from_room(tmp); /* the list of people in the room has
changed */
          char_to_room(tmp, troom);

          if (IS_SET(TELE_LOOK, world[sroom].tele_mask) &&
!IS_NPC(tmp)) {
            do_look(tmp, "\0",15, 0);
	     /*look_at_room(ch, 0);*/
          }

          if (IS_SET(world[troom].room_flags, ROOM_DEATH) &&
(GET_LEVEL(tmp))  <
LVL_IMMORT) {
            if (tmp == next)
              next = tmp->next;
	      log_death_trap(tmp);
	     /*death_cry(tmp);*/
	     extract_char(tmp);
	     /*            NailThisSucker(tmp);*/
            continue;
          }
          /* if (dest->sector_type == SECT_AIR) {
           * n2 = tmp->next;
           * if (check_falling(tmp)) {
           *   if (tmp == next)
           *     next = n2;
           * }
           * } hmm.... maybe I should add this as welll*/
        }

        if (IS_SET(TELE_COUNT, world[sroom].tele_mask)) {
          world[sroom].tele_time = 0;   /* reset it for next count */
        }
        if (IS_SET(TELE_RANDOM, world[sroom].tele_mask)) {
          world[sroom].tele_time = number(1,10)*100;
        }
      }
    }
  }
}

/****************************************************************/

/* File: handler.c */
void char_to_room(struct char_data * ch, int room)
{
extern int pulse;
   if (!ch || room < 0 || room > top_of_world)
    log("SYSERR: Illegal value(s) passed to char_to_room");
  else {
    ch->next_in_room = world[room].people;
    world[room].people = ch;
    ch->in_room = room;

    if (GET_EQ(ch, WEAR_LIGHT))
      if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT)
        if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2))     /* Light ON */
          world[room].light++;


/* --------------------- NEW CODE added below ------------------ */
/* the rest of this procedure hasn't been changed */

  if (!IS_NPC(ch)) {
    if (world[ch->in_room].tele_cnt > 0 && world[ch->in_room].tele_time
== 0) {
      /* this is a teleport countdown room */
      world[ch->in_room].tele_time = pulse +
world[ch->in_room].tele_cnt; /* now round up */
      if (world[ch->in_room].tele_time % 10)
         world[ch->in_room].tele_time += 10 -
(world[ch->in_room].tele_time % 10);

      if (world[ch->in_room].tele_time > 2400) {
        world[ch->in_room].tele_time = world[ch->in_room].tele_cnt;  /*
start of next day */
      }
    }
  }

  }
}


/*******************************************************************/

/* File: comm.c */

/* External procedure */
void TeleportPulseStuff(int pulse);


/* in void game_loop(int mother_desc)
 * with all the other PULSE stuff */

    if (!(pulse % PULSE_TELEPORT))
       TeleportPulseStuff(pulse);


/*********************************************************************/


/* File: db.c */
/* in void parse_room(FILE * fl, int virtual_nr) */
/* sorry, I forget if I added and variables, so I'll put them all
 * here commented out */
/*  static int room_nr = 0, zone = 0;
 *  int t[10], i;
 * char line[256], flags[128];
 * struct extra_descr_data *new_descr; */

/*  world[room_nr].zone = zone;
 * world[room_nr].number = virtual_nr;
 * world[room_nr].name = fread_string(fl, buf2);
 * world[room_nr].description = fread_string(fl, buf2); */

/* The below commented code won't work with reading teleport rooms
 * like this (at least that I found, so I basically ported a
replacement
 * section from SillyMUD, I commented it in my code instead of deleting
it
 * for reference */
/*  if (!get_line(fl, line) || sscanf(line, " %d %s %d ", t, flags, t +
2) != 3) {
 *   fprintf(stderr, "Format error in room #%d\n", virtual_nr);
 *   exit(1);
 * } */

/* Replacement */
  fscanf(fl, " %d", t);
  fscanf(fl, " %s", flags);
   world[room_nr].room_flags = asciiflag_conv(flags);
  fscanf(fl, " %d", t + 2);
   world[room_nr].sector_type = t[2];
   if (t[2] == -1) {
      fscanf(fl, " %d", t + 3);
       world[room_nr].tele_time = t[3];
      fscanf(fl, " %d", t + 4);
      world[room_nr].tele_targ = t[4];
      fscanf(fl, " %d", t + 5);
      world[room_nr].tele_mask = t[5];
      if (IS_SET(world[room_nr].tele_mask, TELE_COUNT)) {
	 fscanf(fl, " %d", t + 6);
	 world[room_nr].tele_cnt = t[6];
      } else  {
      world[room_nr].tele_cnt = 0;
      }
      fscanf(fl, " %d", t + 7);
      world[room_nr].sector_type = t[7];
   } else  {
      world[room_nr].tele_time = 0;
      world[room_nr].tele_targ = 0;
      world[room_nr].tele_mask = 0;
      world[room_nr].tele_cnt = 0;
   }


This should be everything, let me know if it works....
I've used it, with no problems.... :)

..........[ snip -- end of msg1, start of msg2 ]..........

Date: Wed, 22 Nov 1995 22:30:10 -0800
From: "Daniel W. Burke" <dwb@ix.netcom.com>
Cc: circle@pvv.unit.no
Subject: Re: a few notes on using Daniel's Teleport code

You wrote:
>Hi ya, just went and cut/pasted Daniel Burke's Teleport code into
>my mud. Pretty good... but a few notes:
>
>You have to extern int pulse in handler.c
>You have to extern char_data *character_list  in utils.c
>
DOH!  Knew I'd forget something :P


>OTher then that, it should compile clean.
>A more stylistic issue, I went and changed the format so that
>a teleporting room is made in the door/extra descriptions area
>of a room definition.   To me, it made more sense there then to
>hack the zone-flags-sector line.

shrug... that's how it was done in sillymud, so I just used the same
thing... I've seen a few other muds use the same format, so I figured
might as well stick with something some builders would already know :)

..........[ snip -- end of msg2 ]..........



This archive was generated by hypermail 2b30 : 12/07/00 PST