/* * Generic get obj function that supports optional containers. -Thoric * currently only used for "eat" and "quaff". */ obj_data *find_obj( char_data * ch, string argument, bool carryonly ) { string arg1, arg2; obj_data *obj = NULL; argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if( !str_cmp( arg2, "from" ) && !argument.empty( ) ) argument = one_argument( argument, arg2 ); if( arg2.empty( ) ) { if( carryonly && !( obj = ch->get_obj_carry( arg1 ) ) ) { ch->print( "You do not have that item.\r\n" ); return NULL; } else if( !carryonly && !( obj = ch->get_obj_here( arg1 ) ) ) { ch->printf( "I see no %s here.\r\n", arg1.c_str( ) ); return NULL; } return obj; } else { obj_data *container = NULL; if( carryonly && !( container = ch->get_obj_carry( arg2 ) ) && !( container = ch->get_obj_wear( arg2 ) ) ) { ch->print( "You do not have that item.\r\n" ); return NULL; } if( !carryonly && !( container = ch->get_obj_here( arg2 ) ) ) { ch->printf( "I see no %s here.\r\n", arg2.c_str( ) ); return NULL; } if( !container->extra_flags.test( ITEM_COVERING ) && IS_SET( container->value[1], CONT_CLOSED ) ) { ch->printf( "The %s is closed.\r\n", container->name ); return NULL; } if( !( obj = get_obj_list( ch, arg1, container->contents ) ) ) act( AT_PLAIN, container->extra_flags.test( ITEM_COVERING ) ? "I see nothing like that beneath $p." : "I see nothing like that in $p.", ch, container, NULL, TO_CHAR ); return obj; } }
/* RT Enter portals */ void do_enter( CHAR_DATA *ch, char *argument) { ROOM_INDEX_DATA *location; if ( ch->fighting != NULL ) return; /* nifty portal stuff */ if (argument[0] != '\0') { ROOM_INDEX_DATA *old_room; OBJ_DATA *portal; CHAR_DATA *fch, *fch_next; old_room = ch->in_room; portal = get_obj_list( ch, argument, ch->in_room->contents ); if (portal == NULL) { send_to_char("You don't see that here.\n\r",ch); return; } if (portal->item_type != ITEM_PORTAL || (IS_SET(portal->value[1],EX_CLOSED) && !IS_TRUSTED(ch,KNIGHT))) { send_to_char("You can't seem to find a way in.\n\r",ch); return; } if (!IS_TRUSTED(ch,KNIGHT) && !IS_SET(portal->value[2],GATE_NOCURSE) && IS_AFFECTED(ch,AFF_CURSE) ) { send_to_char("Something prevents you from leaving...\n\r",ch); return; } if (IS_SET(portal->value[2],GATE_RANDOM) || portal->value[3] == -1) { location = get_random_room(ch); portal->value[3] = location->vnum; /* for record keeping :) */ } else if (IS_SET(portal->value[2],GATE_BUGGY) && (number_percent() < 5)) location = get_random_room(ch); else location = get_room_index(portal->value[3]); if (location == NULL || location == old_room || !can_see_room(ch,location) || (room_is_private(ch,location) && !IS_TRUSTED(ch,IMPLEMENTOR))) { act("$p doesn't seem to go anywhere.",ch,portal,NULL,TO_CHAR); return; } if (IS_NPC(ch) && IS_SET(ch->act,ACT_AGGRESSIVE) && IS_SET(location->room_flags,ROOM_LAW)) { send_to_char("Something prevents you from leaving...\n\r",ch); 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, location); if (IS_SET(portal->value[2],GATE_GOWITH)) /* take the gate along */ { obj_from_room(portal); obj_to_room(portal,location); } 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); do_look(ch,"auto"); /* charges */ if (portal->value[0] > 0) { portal->value[0]--; if (portal->value[0] == 0) portal->value[0] = -1; } /* protect against circular follows */ if (old_room == location) return; for ( fch = old_room->people; fch != NULL; fch = fch_next ) { fch_next = fch->next_in_room; if (portal == NULL || portal->value[0] == -1) /* no following through dead portals */ continue; if ( fch->master == ch && IS_AFFECTED(fch,AFF_CHARM) && fch->position < POS_STANDING) do_stand(fch,""); if ( fch->master == ch && fch->position == POS_STANDING) { if (IS_SET(ch->in_room->room_flags,ROOM_LAW) && (IS_NPC(fch) && IS_SET(fch->act,ACT_AGGRESSIVE))) { act("You can't bring $N into the city.", ch,NULL,fch,TO_CHAR); act("You aren't allowed in the city.", fch,NULL,NULL,TO_CHAR); continue; } act( "You follow $N.", fch, NULL, ch, TO_CHAR ); do_enter(fch,argument); } } if (portal != NULL && portal->value[0] == -1) { act("$p fades out of existence.",ch,portal,NULL,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,NULL,TO_ROOM); } extract_obj(portal); } /* * If someone is following the char, these triggers get activated * for the followers before the char, but it's safer this way... */ 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; } send_to_char("Nope, can't do it.\n\r",ch); return; }
void look_object(struct char_data *ch, struct gameobject *obj, const char *argument) { struct gameobject *portal; struct room_index_data *location; if (!validate_look(ch)) { return; } switch (obj->item_type) { default: send_to_char("That is not a container.\n\r", ch); break; case ITEM_DRINK_CON: if (obj->value[1] == 0) { send_to_char("It is empty.\n\r", ch); } else { printf_to_char(ch, "It's %sfilled with a %s liquid.\n\r", obj->value[1] < obj->value[0] / 4 ? "less than half-" : obj->value[1] < 3 * obj->value[0] / 4 ? "about half-" : "more than half-", liq_table[obj->value[2]].liq_color); } break; case ITEM_CONTAINER: case ITEM_CORPSE_NPC: case ITEM_CORPSE_PC: if (IS_SET(obj->value[1], CONT_CLOSED)) { send_to_char("It is closed.\n\r", ch); } else { act("$p holds```8:``", ch, obj, NULL, TO_CHAR); show_list_to_char(obj->contains, ch, true, true); } break; case ITEM_PORTAL: portal = get_obj_list(ch, argument, ch->in_room->contents); if (portal != NULL) { location = get_room_index(portal->value[3]); if (location == NULL) { send_to_char("It looks very empty..\n\r", ch); } else { send_to_char(location->name, ch); send_to_char("\n\r", ch); if (!IS_SET(location->room_flags, ROOM_INDOORS)) print_weather(ch); else send_to_char("You can not discern weather conditions beyond this portal.\n\r", ch); if (!IS_NPC(ch) && !IS_SET(ch->comm, COMM_BRIEF)) { send_to_char(location->description, ch); } send_to_char("\n\r", ch); if (!IS_NPC(ch) && IS_SET(ch->act, PLR_AUTOEXIT)) { char showexit[100]; sprintf(showexit, "%ld exits auto", location->vnum); do_at(ch, showexit); } show_list_to_char(location->contents, ch, false, false); show_char_to_char(location->people, ch); } } break; } }
void do_stand (CHAR_DATA * ch, char *argument) { OBJ_DATA *obj = NULL; if (argument[0] != '\0') { if(ch->infight) { send_to_char ("Maybe you should finish fighting first?\n\r", ch); return; } obj = get_obj_list (ch, argument, ch->in_room->contents); if (obj == NULL) { send_to_char ("You don't see that here.\n\r", ch); return; } if (obj->item_type != ITEM_FURNITURE || (!IS_SET (obj->value[2], STAND_AT) && !IS_SET (obj->value[2], STAND_ON) && !IS_SET (obj->value[2], STAND_IN))) { send_to_char ("You can't seem to find a place to stand.\n\r", ch); return; } if (ch->on != obj && count_users (obj) >= obj->value[0]) { act_new ("There's no room to stand on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); return; } ch->on = obj; } switch (ch->position) { case POS_SLEEPING: if (obj == NULL) { send_to_char ("You wake and stand up.\n\r", ch); act ("$n wakes and stands up.", ch, NULL, NULL, TO_ROOM); ch->on = NULL; } else if (IS_SET (obj->value[2], STAND_AT)) { act_new ("You wake and stand at $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); act ("$n wakes and stands at $p.", ch, obj, NULL, TO_ROOM); } else if (IS_SET (obj->value[2], STAND_ON)) { act_new ("You wake and stand on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); act ("$n wakes and stands on $p.", ch, obj, NULL, TO_ROOM); } else { act_new ("You wake and stand in $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); act ("$n wakes and stands in $p.", ch, obj, NULL, TO_ROOM); } ch->position = POS_STANDING; do_function (ch, &do_look, "auto"); break; case POS_RESTING: case POS_SITTING: if (obj == NULL) { send_to_char ("You stand up.\n\r", ch); act ("$n stands up.", ch, NULL, NULL, TO_ROOM); ch->on = NULL; } else if (IS_SET (obj->value[2], STAND_AT)) { act ("You stand at $p.", ch, obj, NULL, TO_CHAR); act ("$n stands at $p.", ch, obj, NULL, TO_ROOM); } else if (IS_SET (obj->value[2], STAND_ON)) { act ("You stand on $p.", ch, obj, NULL, TO_CHAR); act ("$n stands on $p.", ch, obj, NULL, TO_ROOM); } else { act ("You stand in $p.", ch, obj, NULL, TO_CHAR); act ("$n stands on $p.", ch, obj, NULL, TO_ROOM); } ch->position = POS_STANDING; break; case POS_STANDING: send_to_char ("You are already standing.\n\r", ch); break; case POS_FIGHTING: send_to_char ("You are already fighting!\n\r", ch); break; } return; }
void do_sleep (CHAR_DATA * ch, char *argument) { OBJ_DATA *obj = NULL; switch (ch->position) { case POS_SLEEPING: send_to_char ("You are already sleeping.\n\r", ch); break; case POS_RESTING: case POS_SITTING: case POS_STANDING: if (argument[0] == '\0' && ch->on == NULL) { send_to_char ("You go to sleep.\n\r", ch); act ("$n goes to sleep.", ch, NULL, NULL, TO_ROOM); ch->position = POS_SLEEPING; } else { /* find an object and sleep on it */ if (argument[0] == '\0') obj = ch->on; else obj = get_obj_list (ch, argument, ch->in_room->contents); if (obj == NULL) { send_to_char ("You don't see that here.\n\r", ch); return; } if (obj->item_type != ITEM_FURNITURE || (!IS_SET (obj->value[2], SLEEP_ON) && !IS_SET (obj->value[2], SLEEP_IN) && !IS_SET (obj->value[2], SLEEP_AT))) { send_to_char ("You can't sleep on that!\n\r", ch); return; } if (ch->on != obj && count_users (obj) >= obj->value[0]) { act_new ("There is no room on $p for you.", ch, obj, NULL, TO_CHAR, POS_DEAD); return; } ch->on = obj; if (IS_SET (obj->value[2], SLEEP_AT)) { act ("You go to sleep at $p.", ch, obj, NULL, TO_CHAR); act ("$n goes to sleep at $p.", ch, obj, NULL, TO_ROOM); } else if (IS_SET (obj->value[2], SLEEP_ON)) { act ("You go to sleep on $p.", ch, obj, NULL, TO_CHAR); act ("$n goes to sleep on $p.", ch, obj, NULL, TO_ROOM); } else { act ("You go to sleep in $p.", ch, obj, NULL, TO_CHAR); act ("$n goes to sleep in $p.", ch, obj, NULL, TO_ROOM); } ch->position = POS_SLEEPING; } break; case POS_FIGHTING: send_to_char ("You are already fighting!\n\r", ch); break; } return; }
void do_sit (CHAR_DATA * ch, char *argument) { OBJ_DATA *obj = NULL; if(ch->infight) { send_to_char ("Maybe you should finish this fight first?\n\r", ch); return; } /* okay, now that we know we can sit, find an object to sit on */ if (argument[0] != '\0') { obj = get_obj_list (ch, argument, ch->in_room->contents); if (obj == NULL) { send_to_char ("You don't see that here.\n\r", ch); return; } } else obj = ch->on; if (obj != NULL) { if (obj->item_type != ITEM_FURNITURE || (!IS_SET (obj->value[2], SIT_ON) && !IS_SET (obj->value[2], SIT_IN) && !IS_SET (obj->value[2], SIT_AT))) { send_to_char ("You can't sit on that.\n\r", ch); return; } if (obj != NULL && ch->on != obj && count_users (obj) >= obj->value[0]) { act_new ("There's no more room on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); return; } ch->on = obj; } switch (ch->position) { case POS_SLEEPING: if (obj == NULL) { send_to_char ("You wake and sit up.\n\r", ch); act ("$n wakes and sits up.", ch, NULL, NULL, TO_ROOM); } else if (IS_SET (obj->value[2], SIT_AT)) { act_new ("You wake and sit at $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); act ("$n wakes and sits at $p.", ch, obj, NULL, TO_ROOM); } else if (IS_SET (obj->value[2], SIT_ON)) { act_new ("You wake and sit on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); act ("$n wakes and sits at $p.", ch, obj, NULL, TO_ROOM); } else { act_new ("You wake and sit in $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); act ("$n wakes and sits in $p.", ch, obj, NULL, TO_ROOM); } ch->position = POS_SITTING; break; case POS_RESTING: if (obj == NULL) send_to_char ("You stop resting.\n\r", ch); else if (IS_SET (obj->value[2], SIT_AT)) { act ("You sit at $p.", ch, obj, NULL, TO_CHAR); act ("$n sits at $p.", ch, obj, NULL, TO_ROOM); } else if (IS_SET (obj->value[2], SIT_ON)) { act ("You sit on $p.", ch, obj, NULL, TO_CHAR); act ("$n sits on $p.", ch, obj, NULL, TO_ROOM); } ch->position = POS_SITTING; break; case POS_SITTING: send_to_char ("You are already sitting down.\n\r", ch); break; case POS_STANDING: if (obj == NULL) { send_to_char ("You sit down.\n\r", ch); act ("$n sits down on the ground.", ch, NULL, NULL, TO_ROOM); } else if (IS_SET (obj->value[2], SIT_AT)) { act ("You sit down at $p.", ch, obj, NULL, TO_CHAR); act ("$n sits down at $p.", ch, obj, NULL, TO_ROOM); } else if (IS_SET (obj->value[2], SIT_ON)) { act ("You sit on $p.", ch, obj, NULL, TO_CHAR); act ("$n sits on $p.", ch, obj, NULL, TO_ROOM); } else { act ("You sit down in $p.", ch, obj, NULL, TO_CHAR); act ("$n sits down in $p.", ch, obj, NULL, TO_ROOM); } ch->position = POS_SITTING; break; } return; }
void group_cast( int sn, int level, CHAR_DATA * ch, char * argument ) { CHAR_DATA * victim = NULL; OBJ_DATA * obj = NULL; int mana; if ( IS_NPC( ch ) ) { return; } if ( ch->gspell && ch->gspell->timer > 0 ) { send_to_char( AT_BLUE, "You already have a group spell in progress.\n\r", ch ); return; } mana = MANA_COST( ch, sn ); if ( number_percent() > ch->pcdata->learned[ sn ] ) { send_to_char( AT_BLUE, "You lost your concentration.\n\r", ch ); ch->mana -= mana / 2; return; } ch->mana -= mana; update_skpell( ch, sn ); switch ( skill_table[ sn ].target ) { default: bug( "group_cast: non-group target on sn #%d.", sn ); return; case TAR_GROUP_DEFENSIVE: if ( argument[ 0 ] == '\0' ) { victim = ch; break; } if ( !( victim = get_char_room( ch, argument ) ) ) { send_to_char( AT_BLUE, "They aren't here.\n\r", ch ); return; } add_gspell( ch, sn, level, (void *) victim ); break; case TAR_GROUP_OFFENSIVE: if ( argument[ 0 ] == '\0' ) { if ( ch->fighting ) { victim = ch->fighting; } else { send_to_char( AT_BLUE, "Cast the spell on whom?\n\r", ch ); return; } } else { if ( !( victim = get_char_room( ch, argument ) ) ) { send_to_char( AT_BLUE, "They aren't here.\n\r", ch ); return; } } add_gspell( ch, sn, level, (void *) victim ); break; case TAR_GROUP_ALL: add_gspell( ch, sn, level, NULL ); break; case TAR_GROUP_OBJ: if ( !( obj = get_obj_list( ch, argument, ch->in_room->contents ) ) ) { send_to_char( AT_WHITE, "You don't see that.\n\r", ch ); return; } add_gspell( ch, sn, level, (void *) obj ); break; case TAR_IGNORE: add_gspell( ch, sn, level, (void *) argument ); break; } return; }