Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

act_enter.c

Go to the documentation of this file.
00001 /***************************************************************************
00002  *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
00003  *  Michael Seifert, Hans Henrik Strfeldt, Tom Madsen, and Katja Nyboe.    *
00004  *                                                                         *
00005  *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael          *
00006  *  Chastain, Michael Quan, and Mitchell Tse.                              *
00007  *                                                                         *
00008  *  In order to use any part of this Merc Diku Mud, you must comply with   *
00009  *  both the original Diku license in 'license.doc' as well the Merc       *
00010  *  license in 'license.txt'.  In particular, you may not remove either of *
00011  *  these copyright notices.                                               *
00012  *                                                                         *
00013  *  Much time and thought has gone into this software and you are          *
00014  *  benefitting.  We hope that you share your changes too.  What goes      *
00015  *  around, comes around.                                                  *
00016  ***************************************************************************/
00017 
00018 /***************************************************************************
00019  *  ROM 2.4 is copyright 1993-1998 Russ Taylor                             *
00020  *  ROM has been brought to you by the ROM consortium                      *
00021  *      Russ Taylor (rtaylor@hypercube.org)                                *
00022  *      Gabrielle Taylor (gtaylor@efn.org)                                 *
00023  *      Brian Moore (zump@rom.org)                                         *
00024  *  By using this code, you have agreed to follow the terms of the         *
00025  *  ROM license, in the file Rom24/doc/rom.license                         *
00026  ***************************************************************************/
00027 
00028 /*   QuickMUD - The Lazy Man's ROM - $Id: act_enter.c,v 1.2 2000/12/01 10:48:33 ring0 Exp $ */
00029 
00030 #if defined(macintosh)
00031 #include <types.h>
00032 #include <time.h>
00033 #else
00034 #include <sys/types.h>
00035 #include <sys/time.h>
00036 #endif
00037 #include <stdio.h>
00038 #include <string.h>
00039 #include <stdlib.h>
00040 #include "merc.h"
00041 #include "interp.h"
00042 
00043 /* random room generation procedure */
00044 ROOM_INDEX_DATA *get_random_room (CHAR_DATA * ch)
00045 {
00046     ROOM_INDEX_DATA *room;
00047 
00048     for (;;)
00049     {
00050         room = get_room_index (number_range (0, 65535));
00051         if (room != NULL)
00052             if (can_see_room (ch, room)
00053                 && !room_is_private (room)
00054                 && !IS_SET (room->room_flags, ROOM_PRIVATE)
00055                 && !IS_SET (room->room_flags, ROOM_SOLITARY)
00056                 && !IS_SET (room->room_flags, ROOM_SAFE)
00057                 && (IS_NPC (ch) || IS_SET (ch->act, ACT_AGGRESSIVE)
00058                     || !IS_SET (room->room_flags, ROOM_LAW)))
00059                 break;
00060     }
00061 
00062     return room;
00063 }
00064 
00065 /* RT Enter portals */
00066 void do_enter (CHAR_DATA * ch, char *argument)
00067 {
00068     ROOM_INDEX_DATA *location;
00069 
00070     if (ch->fighting != NULL)
00071         return;
00072 
00073     /* nifty portal stuff */
00074     if (argument[0] != '\0')
00075     {
00076         ROOM_INDEX_DATA *old_room;
00077         OBJ_DATA *portal;
00078         CHAR_DATA *fch, *fch_next;
00079 
00080         old_room = ch->in_room;
00081 
00082         portal = get_obj_list (ch, argument, ch->in_room->contents);
00083 
00084         if (portal == NULL)
00085         {
00086             send_to_char ("You don't see that here.\n\r", ch);
00087             return;
00088         }
00089 
00090         if (portal->item_type != ITEM_PORTAL
00091             || (IS_SET (portal->value[1], EX_CLOSED)
00092                 && !IS_TRUSTED (ch, ANGEL)))
00093         {
00094             send_to_char ("You can't seem to find a way in.\n\r", ch);
00095             return;
00096         }
00097 
00098         if (!IS_TRUSTED (ch, ANGEL)
00099             && !IS_SET (portal->value[2], GATE_NOCURSE)
00100             && (IS_AFFECTED (ch, AFF_CURSE)
00101                 || IS_SET (old_room->room_flags, ROOM_NO_RECALL)))
00102         {
00103             send_to_char ("Something prevents you from leaving...\n\r", ch);
00104             return;
00105         }
00106 
00107         if (IS_SET (portal->value[2], GATE_RANDOM) || portal->value[3] == -1)
00108         {
00109             location = get_random_room (ch);
00110             portal->value[3] = location->vnum;    /* for record keeping :) */
00111         }
00112         else if (IS_SET (portal->value[2], GATE_BUGGY)
00113                  && (number_percent () < 5)) location = get_random_room (ch);
00114         else
00115             location = get_room_index (portal->value[3]);
00116 
00117         if (location == NULL
00118             || location == old_room
00119             || !can_see_room (ch, location)
00120             || (room_is_private (location) && !IS_TRUSTED (ch, IMPLEMENTOR)))
00121         {
00122             act ("$p doesn't seem to go anywhere.", ch, portal, NULL,
00123                  TO_CHAR);
00124             return;
00125         }
00126 
00127         if (IS_NPC (ch) && IS_SET (ch->act, ACT_AGGRESSIVE)
00128             && IS_SET (location->room_flags, ROOM_LAW))
00129         {
00130             send_to_char ("Something prevents you from leaving...\n\r", ch);
00131             return;
00132         }
00133 
00134         act ("$n steps into $p.", ch, portal, NULL, TO_ROOM);
00135 
00136         if (IS_SET (portal->value[2], GATE_NORMAL_EXIT))
00137             act ("You enter $p.", ch, portal, NULL, TO_CHAR);
00138         else
00139             act ("You walk through $p and find yourself somewhere else...",
00140                  ch, portal, NULL, TO_CHAR);
00141 
00142         char_from_room (ch);
00143         char_to_room (ch, location);
00144 
00145         if (IS_SET (portal->value[2], GATE_GOWITH))
00146         {                        /* take the gate along */
00147             obj_from_room (portal);
00148             obj_to_room (portal, location);
00149         }
00150 
00151         if (IS_SET (portal->value[2], GATE_NORMAL_EXIT))
00152             act ("$n has arrived.", ch, portal, NULL, TO_ROOM);
00153         else
00154             act ("$n has arrived through $p.", ch, portal, NULL, TO_ROOM);
00155 
00156         do_function (ch, &do_look, "auto");
00157 
00158         /* charges */
00159         if (portal->value[0] > 0)
00160         {
00161             portal->value[0]--;
00162             if (portal->value[0] == 0)
00163                 portal->value[0] = -1;
00164         }
00165 
00166         /* protect against circular follows */
00167         if (old_room == location)
00168             return;
00169 
00170         for (fch = old_room->people; fch != NULL; fch = fch_next)
00171         {
00172             fch_next = fch->next_in_room;
00173 
00174             if (portal == NULL || portal->value[0] == -1)
00175                 /* no following through dead portals */
00176                 continue;
00177 
00178             if (fch->master == ch && IS_AFFECTED (fch, AFF_CHARM)
00179                 && fch->position < POS_STANDING)
00180                 do_function (fch, &do_stand, "");
00181 
00182             if (fch->master == ch && fch->position == POS_STANDING)
00183             {
00184 
00185                 if (IS_SET (ch->in_room->room_flags, ROOM_LAW)
00186                     && (IS_NPC (fch) && IS_SET (fch->act, ACT_AGGRESSIVE)))
00187                 {
00188                     act ("You can't bring $N into the city.",
00189                          ch, NULL, fch, TO_CHAR);
00190                     act ("You aren't allowed in the city.",
00191                          fch, NULL, NULL, TO_CHAR);
00192                     continue;
00193                 }
00194 
00195                 act ("You follow $N.", fch, NULL, ch, TO_CHAR);
00196                 do_function (fch, &do_enter, argument);
00197             }
00198         }
00199 
00200         if (portal != NULL && portal->value[0] == -1)
00201         {
00202             act ("$p fades out of existence.", ch, portal, NULL, TO_CHAR);
00203             if (ch->in_room == old_room)
00204                 act ("$p fades out of existence.", ch, portal, NULL, TO_ROOM);
00205             else if (old_room->people != NULL)
00206             {
00207                 act ("$p fades out of existence.",
00208                      old_room->people, portal, NULL, TO_CHAR);
00209                 act ("$p fades out of existence.",
00210                      old_room->people, portal, NULL, TO_ROOM);
00211             }
00212             extract_obj (portal);
00213         }
00214 
00215         /* 
00216          * If someone is following the char, these triggers get activated
00217          * for the followers before the char, but it's safer this way...
00218          */
00219         if (IS_NPC (ch) && HAS_TRIGGER (ch, TRIG_ENTRY))
00220             mp_percent_trigger (ch, NULL, NULL, NULL, TRIG_ENTRY);
00221         if (!IS_NPC (ch))
00222             mp_greet_trigger (ch);
00223 
00224         return;
00225     }
00226 
00227     send_to_char ("Nope, can't do it.\n\r", ch);
00228     return;
00229 }

Generated on Thu Jan 13 21:48:08 2005 for Beyond the Shadows by  doxygen 1.4.0