00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
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
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
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;
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 {
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
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
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
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
00217
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 }