/*************************************************************************** * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, * * Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. * * * * Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael * * Chastain, Michael Quan, and Mitchell Tse. * * * * In order to use any part of this Merc Diku Mud, you must comply with * * both the original Diku license in 'license.doc' as well the Merc * * license in 'license.txt'. In particular, you may not remove either of * * these copyright notices. * * * * Much time and thought has gone into this software and you are * * benefitting. We hope that you share your changes too. What goes * * around, comes around. * ***************************************************************************/ /*************************************************************************** * ROM 2.4 is copyright 1993-1998 Russ Taylor * * ROM has been brought to you by the ROM consortium * * Russ Taylor (rtaylor@hypercube.org) * * Gabrielle Taylor (gtaylor@efn.org) * * Brian Moore (zump@rom.org) * * By using this code, you have agreed to follow the terms of the * * ROM license, in the file Rom24/doc/rom.license * ***************************************************************************/ #include "merc.h" #include "interp.h" /* random room generation procedure */ ROOM_INDEX_DATA *get_random_room(CHAR_DATA *ch) { ROOM_INDEX_DATA *room; for ( ; ; ) { room = get_room_index( number_range( 0, 65535 ) ); if (room != NULL ) if (can_see_room(ch,room) && !AREA_FLAGGED(room->area, AREA_UNLINKED) && !room_is_private(room) && !IS_SET(room->room_flags, ROOM_PRIVATE) && !IS_SET(room->room_flags, ROOM_SOLITARY) && !IS_SET(room->room_flags, ROOM_SAFE) && (IS_NPC(ch) || IS_SET(ch->act,ACT_AGGRESSIVE) || !IS_SET(room->room_flags,ROOM_LAW))) break; } return room; } ACMD(do_enter) { ROOM_INDEX_DATA *to_room; OBJ_DATA *vehicle, *portal; if (ch->fighting != NULL) return; vehicle = get_obj_list(ch, argument, IN_ROOM(ch)->contents); portal = get_obj_list(ch, argument, IN_ROOM(ch)->contents); if (vehicle && vehicle->item_type == ITEM_VEHICLE) { if (IS_MOUNTABLE(vehicle)) act("You can ride $p, but not get into it.", ch, vehicle, 0, TO_CHAR); else if ((to_room = get_room_index(vehicle->value[0])) == NULL) ch->Send("Serious problem: Vehicle has no insides!\n\r"); else { act("You climb into $p.", ch, vehicle, 0, TO_CHAR); act("$n climbs into $p", ch, vehicle, 0, TO_ROOM); char_from_room(ch); char_to_room(ch, to_room); act("$n climbs in.", ch, 0, 0, TO_ROOM); if (ch->desc != NULL) look_at_room(ch, 0); } return; } else if (portal && portal->item_type == ITEM_PORTAL) { CHAR_DATA *fch, *fch_next; ROOM_INDEX_DATA *old_room = IN_ROOM(ch); if (IS_SET(portal->value[2], GATE_RANDOM) || portal->value[3] == -1) { to_room = get_random_room(ch); portal->value[3] = to_room->vnum; } else if (IS_SET(portal->value[2], GATE_BUGGY) && (number_percent() < 5)) to_room = get_random_room(ch); else to_room = get_room_index(portal->value[3]); if (to_room == NULL || to_room == old_room || !can_see_room(ch, to_room) || (room_is_private(to_room) && !IS_TRUSTED(ch, IMPLEMENTOR))) { act("$p doesn't seem to go anywhere.", ch, portal, 0, TO_CHAR); return; } if (MOB_FLAGGED(ch, ACT_AGGRESSIVE) && ROOM_FLAGGED(to_room, ROOM_LAW)) { ch->Send("Something prevents you from leaving...\n\r"); return; } act("$n steps into $p.", ch, portal, NULL, TO_ROOM); if (IS_SET(portal->value[2], GATE_NORMAL_EXIT)) act("You enter $p.", ch, portal, NULL, TO_CHAR); else act("You walk through $p and find yourself somewhere else...", ch, portal, NULL, TO_CHAR); char_from_room(ch); char_to_room(ch, to_room); if (IS_SET(portal->value[2], GATE_GOWITH)) { obj_from_room(portal); obj_to_room(portal, to_room); } if (IS_SET(portal->value[2], GATE_NORMAL_EXIT)) act("$n has arrived.", ch, portal, NULL, TO_ROOM); else act("$n has arrived through $p.", ch, portal, NULL, TO_ROOM); look_at_room(ch, 0); if (portal->value[0] > 0) { portal->value[0]--; if (portal->value[0] == 0) portal->value[0] = -1; } if (old_room == to_room) return; for (fch = old_room->people; fch != NULL; fch = fch->next) { fch_next = fch->next_in_room; if (portal == NULL || portal->value[0] == -1) continue; if (fch->master != ch) continue; if (AFF_FLAGGED(fch, AFF_CHARM) && fch->position < POS_STANDING) do_function(fch, &do_stand, "", 0); if (fch->position == POS_STANDING) { if (ROOM_FLAGGED(to_room, ROOM_LAW) && MOB_FLAGGED(fch, ACT_AGGRESSIVE)) { act("You can't bring $N into the city.", ch, 0, fch, TO_CHAR); act("You aren't allowed in the city.", fch, 0, 0, TO_CHAR); continue; } } act("You follow $N.", fch, 0, ch, TO_CHAR); do_function(fch, &do_enter, argument, 0); } if (portal != NULL && portal->value[0] == -1) { act("$p fades out of existence.", ch, portal, 0, TO_CHAR); if (ch->in_room == old_room) act("$p fades out of existence.",ch,portal,NULL,TO_ROOM); else if (old_room->people != NULL) { act("$p fades out of existence.", old_room->people,portal,NULL,TO_CHAR); act("$p fades out of existence.", old_room->people, portal, 0, TO_ROOM); } extract_obj(portal); } if (IS_NPC(ch) && HAS_TRIGGER(ch, TRIG_ENTRY)) mp_percent_trigger(ch, NULL, NULL, NULL, TRIG_ENTRY); if (!IS_NPC(ch)) mp_greet_trigger(ch); return; } else if (vehicle || portal) ch->Send("You cannot enter that!\n\r"); else ch->Send("You do not see that here.\n\r"); } ACMD(do_leave) { OBJ_DATA *hatch, *vehicle; OBJ_DATA *find_vehicle_by_vnum(int vnum); if ((hatch = get_obj_list_type(ITEM_V_HATCH, IN_ROOM(ch)->contents))) { vehicle = find_vehicle_by_vnum(hatch->value[0]); if (!vehicle || IN_ROOM(vehicle) == NULL) { ch->Send("The hatch seems to lead nowhere...\n\r"); return; } act("$n leaves $p.", ch, vehicle, 0, TO_ROOM); act("You climb out of $p.", ch, vehicle, 0, TO_CHAR); char_from_room(ch); char_to_room(ch, IN_ROOM(vehicle)); act("$n climbs out of $p.", ch, vehicle, 0, TO_ROOM); if (ch->desc != NULL) look_at_room(ch, 0); return; } else if (!ROOM_FLAGGED(IN_ROOM(ch), ROOM_INDOORS)) ch->Send("You are outside.. where do you want to go?\n\r"); else ch->Send("I see no obvious exits to the outside.\n\r"); return; }