act.informative.cc
AwakeMUD-0.6Beta/src/act.informative.cc · 71.4 KB
From the archive AwakeMUD-0.60_Beta.tgz
Download the archive « Back to the archive contents
/*************************************************************************
* File: act.informative.c Part of CircleMUD *
* Usage: Player-level commands of an informative nature *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include <stdio.h>
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <errno.h>
#include <sys/time.h>
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "dblist.h"
#include "spells.h"
#include "screen.h"
#include "list.h"
#include "awake.h"
char *CCHAR;
extern class objList ObjList;
/* extern variables */
extern struct room_data *world;
extern struct descriptor_data *descriptor_list;
extern struct char_data *character_list;
extern const char *bioware_names[];
extern const char *cyberware_names[];
extern const char *pc_race_types[];
extern const char *pc_class_types[];
extern const char *allergy_names[];
extern const char *severity_names[];
extern const char *totem_types[];
extern const char *npc_classes[];
extern const char *sector_types[];
extern const char *wielding_hands[];
extern const char *spell_categories[];
extern const char *spirits[];
extern char *credits;
extern char *news;
extern char *info;
extern char *motd;
extern char *imotd;
extern char *wizlist;
extern char *immlist;
extern char *policies;
extern char *handbook;
extern const char *dirs[];
extern const char *exitdirs[];
extern const char *where[];
extern const char *hands[];
extern const char *wielding_hands[];
extern const char *color_liquid[];
extern const char *fullness[];
extern const char *connected_types[];
extern const char *class_abbrevs[];
extern const char *room_bits[];
extern const char *spells[];
extern char *short_object(int virt, int where);
extern const char *dist_name[];
extern int convert_look[];
extern const char *lookdirs[];
extern struct zone_data *zone_table;
extern struct index_data *mob_index;
extern int same_obj(struct obj_data * obj1, struct obj_data * obj2);
extern int find_node_required(struct char_data *persona);
extern int find_sight(struct char_data *ch);
extern int is_blocker(struct char_data *ic);
extern int belongs_to(struct char_data *ch, struct obj_data *obj);
extern int ok_damage_shopkeeper(struct char_data * ch, struct char_data * victim);
extern char *colorize(struct descriptor_data *, char *);
void get_obj_condition(struct char_data *ch, struct obj_data *obj)
{
if (IS_SET(GET_OBJ_EXTRA(obj), ITEM_CORPSE)) {
send_to_char("Examining it reveals that it really IS dead.\r\n", ch);
return;
}
int condition = GET_OBJ_CONDITION(obj) * 100 / GET_OBJ_BARRIER(obj);
if (condition >= 100)
send_to_char(ch, "%s is in excellent condition.\r\n", CAP(obj->short_description));
else if (condition >= 90)
send_to_char(ch, "%s is barely damaged.\r\n", CAP(obj->short_description));
else if (condition >= 80)
send_to_char(ch, "%s is lightly damaged.\r\n", CAP(obj->short_description));
else if (condition >= 60)
send_to_char(ch, "%s is moderately damaged.\r\n", CAP(obj->short_description));
else if (condition >= 30)
send_to_char(ch, "%s is seriously damaged.\r\n", CAP(obj->short_description));
else if (condition >= 10)
send_to_char(ch, "%s is extremely damaged.\r\n", CAP(obj->short_description));
else send_to_char(ch, "%s is almost completely destroyed.\r\n", CAP(obj->short_description));
}
void show_obj_to_char(struct obj_data * object, struct char_data * ch, int mode)
{
bool found;
*buf = '\0';
if ((mode == 0) && object->description) {
strcpy(buf, CCHAR ? CCHAR : "");
strcat(buf, object->description);
} else if (object->short_description && ((mode == 1) ||
(mode == 2) || (mode == 3) || (mode == 4)))
strcpy(buf, object->short_description);
else if (mode == 5) {
if (GET_OBJ_TYPE(object) != ITEM_DRINKCON) {
if (object->long_description)
strcpy(buf, object->long_description);
else strcpy(buf, "You see nothing special..");
} else /* ITEM_TYPE == ITEM_DRINKCON||FOUNTAIN */
strcpy(buf, "It looks like a drink container.");
}
if (mode != 3) {
found = FALSE;
if (IS_OBJ_STAT(object, ITEM_INVISIBLE)) {
sprintf(buf, "%s ^B(invisible)", buf);
found = TRUE;
}
if (IS_OBJ_STAT(object, ITEM_BLESS) && (IS_ASTRAL(ch) || IS_DUAL(ch) ||
IS_AFFECTED(ch, AFF_DETECT_ALIGN))) {
sprintf(buf, "%s ^b(blue aura)", buf);
found = TRUE;
}
if (IS_OBJ_STAT(object, ITEM_MAGIC)
&& (IS_ASTRAL(ch)
|| IS_DUAL(ch)
|| IS_AFFECTED(ch, AFF_DETECT_MAGIC))) {
sprintf(buf, "%s ^Y(yellow aura)", buf);
found = TRUE;
}
if (IS_OBJ_STAT(object, ITEM_GLOW)) {
sprintf(buf, "%s ^W(glowing)", buf);
found = TRUE;
}
if (IS_OBJ_STAT(object, ITEM_HUM)) {
sprintf(buf, "%s ^c(humming)", buf);
found = TRUE;
}
if ((IS_PROJECT(ch) || PLR_FLAGGED(ch, PLR_PERCEIVE)
|| IS_ASTRAL(ch) || IS_DUAL(ch))
&& GET_OBJ_TYPE(object) == ITEM_WEAPON
&& GET_OBJ_VAL(object, 3) < TYPE_TASER
&& GET_OBJ_VAL(object, 7) > 0
&& GET_OBJ_VAL(object, 8) > 0
&& GET_OBJ_VAL(object, 9) > 0)
{
sprintf(buf, "%s ^m(weapon focus)", buf );
found = TRUE;
}
else if (GET_OBJ_TYPE(object) == ITEM_FOCUS
&& (IS_ASTRAL(ch) || IS_DUAL(ch)))
{
found = TRUE;
if ( GET_OBJ_VAL(object, 9) > 0 )
{
switch( GET_OBJ_VAL(object, VALUE_FOCUS_TYPE) )
{
case FOCI_SPELL:
sprintf(buf, "%s ^m(%s focus", buf,
spells[GET_OBJ_VAL(object,VALUE_FOCUS_SPECIFY)]);
break;
case FOCI_SPELL_CAT:
sprintf(buf, "%s ^m(%c%s focus", buf,
LOWER(*spell_categories[GET_OBJ_VAL(object,VALUE_FOCUS_SPECIFY)]),
spell_categories[GET_OBJ_VAL(object,VALUE_FOCUS_SPECIFY)]+1);
break;
case FOCI_SPIRIT:
sprintf(buf, "%s ^m(%c%s focus", buf,
LOWER(*spirits[GET_OBJ_VAL(object,VALUE_FOCUS_SPECIFY)]),
spirits[GET_OBJ_VAL(object,VALUE_FOCUS_SPECIFY)]+1);
break;
case FOCI_POWER:
sprintf(buf, "%s ^m(power focus", buf );
break;
case FOCI_LOCK:
sprintf(buf, "%s ^m(spell lock", buf );
break;
case FOCI_WEAPON:
sprintf(buf, "%s ^m(weapon focus", buf );
break;
default:
sprintf(buf, "%s ^m(focus", buf);
break;
}
if ( GET_OBJ_VAL(object, 5) == 0 )
sprintf(buf, "%s--inactive", buf);
strcat(buf, ")");
}
else
{
switch( GET_OBJ_VAL(object, VALUE_FOCUS_TYPE) )
{
case FOCI_SPELL:
sprintf(buf, "%s ^m(unbonded spell focus)", buf );
break;
case FOCI_SPELL_CAT:
sprintf(buf, "%s ^m(unbonded category focus)", buf );
break;
case FOCI_SPIRIT:
sprintf(buf, "%s ^m(unbonded spirit focus)", buf );
break;
case FOCI_POWER:
sprintf(buf, "%s ^m(unbonded power focus)", buf );
break;
case FOCI_LOCK:
sprintf(buf, "%s ^m(unbonded spell lock)", buf );
break;
case FOCI_WEAPON:
sprintf(buf, "%s ^m(unbonded weapon focus)", buf );
break;
default:
sprintf(buf, "%s ^m(unbonded focus)", buf);
break;
}
}
}
}
strcat(buf, "^N\r\n");
page_string(ch->desc, buf, 1);
}
#define IS_INVIS(o) IS_OBJ_STAT(o, ITEM_INVISIBLE)
void list_obj_to_char(struct obj_data * list, struct char_data * ch, int mode,
bool show, bool corpse)
{
struct obj_data *i, *vis_obj;
int num = 1;
bool found;
found = FALSE;
for (i = list; i; i = i->next_content) {
while (i->next_content) {
if (i->item_number != i->next_content->item_number ||
strcmp(i->description, i->next_content->description) ||
IS_INVIS(i) != IS_INVIS(i->next_content))
break;
if (CAN_SEE_OBJ(ch, i)) {
num++;
vis_obj = i;
}
i = i->next_content;
}
if (CAN_SEE_OBJ(ch, i)) {
if (corpse && IS_OBJ_STAT(i, ITEM_CORPSE)) {
if (num > 1) {
send_to_char(ch, "(%d) ", num);
}
show_obj_to_char(i, ch, mode);
} else
if (!corpse && !mode && !IS_OBJ_STAT(i, ITEM_CORPSE)) {
if (num > 1) {
send_to_char(ch, "(%d) ", num);
}
show_obj_to_char(i, ch, mode);
} else if (mode) {
if (num > 1) {
send_to_char(ch, "(%d) ", num);
}
show_obj_to_char(i, ch, mode);
}
found = TRUE;
num = 1;
}
}
if (!found && show)
send_to_char(" Nothing.\r\n", ch);
}
void diag_char_to_char(struct char_data * i, struct char_data * ch)
{
int ment, phys;
if (GET_MAX_PHYSICAL(i) >= 100)
phys = (100 * GET_PHYSICAL(i)) / GET_MAX_PHYSICAL(i);
else phys = -1; /* How could MAX_PHYSICAL be < 1?? */
if (GET_MAX_MENTAL(i) >= 100)
ment = (100 * GET_MENTAL(i)) / GET_MAX_MENTAL(i);
else ment = -1;
strcpy(buf, PERS(i, ch));
CAP(buf);
if (phys >= 100 || (GET_TRADITION(i) == TRAD_ADEPT && phys >= 0 &&
((100 - phys) / 10) <= GET_SKILL(i, SKILL_RESISTANCE)))
strcat(buf, " is in excellent physical condition");
else if (phys >= 90)
strcat(buf, " has a few scratches");
else if (phys >= 75)
strcat(buf, " has some small wounds and bruises");
else if (phys >= 50)
strcat(buf, " has quite a few wounds");
else if (phys >= 30)
strcat(buf, " has some big nasty wounds and scratches");
else if (phys >= 15)
strcat(buf, " looks pretty hurt");
else if (phys >= 0)
strcat(buf, " is in awful condition");
else strcat(buf, " is bleeding awfully from big wounds");
if (phys <= 0)
strcat(buf, " and is unconscious.\r\n");
else if (ment >= 100 || (GET_TRADITION(i) == TRAD_ADEPT && ment >= 0 &&
((100 - ment) / 10) <= (GET_SKILL(i, SKILL_RESISTANCE) -
(int)((GET_MAX_PHYSICAL(i) - GET_PHYSICAL(i)) / 100))))
strcat(buf, " and is alert.\r\n");
else if (ment >= 90)
strcat(buf, " and is barely tired.\r\n");
else if (ment >= 75)
strcat(buf, " and is slightly worn out.\r\n");
else if (ment >= 50)
strcat(buf, " and is fatigued.\r\n");
else if (ment >= 30)
strcat(buf, " and is weary.\r\n");
else if (ment >= 10)
strcat(buf, " and is groggy.\r\n");
else strcat(buf, " is completely unconscious.\r\n");
send_to_char(buf, ch);
}
void look_at_char(struct char_data * i, struct char_data * ch)
{
int j, found, weight;
float height;
struct obj_data *tmp_obj;
if (i->player.description)
send_to_char(i->player.description, ch);
else act("You see nothing special about $m.", FALSE, i, 0, ch, TO_VICT);
if (i != ch && GET_HEIGHT(i) > 0 && GET_WEIGHT(i) > 0) {
if ((GET_HEIGHT(i) % 10) < 5)
height = (float)(GET_HEIGHT(i) - (GET_HEIGHT(i) % 10)) / 100;
else height = (float)(GET_HEIGHT(i) - (GET_HEIGHT(i) % 10) + 10) / 100;
if ((GET_WEIGHT(i) % 10) < 5)
weight = GET_WEIGHT(i) - (GET_WEIGHT(i) % 10);
else weight = GET_WEIGHT(i) - (GET_WEIGHT(i) % 10) + 10;
sprintf(buf, "$e looks to be about %0.1f meters tall and "
"seems to weigh about %d kg.", height, weight);
act(buf, FALSE, i, 0, ch, TO_VICT);
}
diag_char_to_char(i, ch);
found = FALSE;
for (j = 0; !found && j < NUM_WEARS; j++)
if (GET_EQ(i, j) && CAN_SEE_OBJ(ch, GET_EQ(i, j)))
found = TRUE;
if (IS_PERSONA(i))
found = FALSE;
if (found) {
act("\r\n$n is using:", FALSE, i, 0, ch, TO_VICT);
for (j = 0; j < NUM_WEARS; j++)
if (GET_EQ(i, j) && CAN_SEE_OBJ(ch, GET_EQ(i, j))) {
if (j == WEAR_WIELD || j == WEAR_HOLD) {
if (IS_OBJ_STAT(GET_EQ(i, j), ITEM_TWOHANDS))
send_to_char(hands[2], ch);
else if (j == WEAR_WIELD)
send_to_char(hands[i->char_specials.saved.left_handed], ch);
else send_to_char(hands[!i->char_specials.saved.left_handed], ch);
} else send_to_char(where[j], ch);
show_obj_to_char(GET_EQ(i, j), ch, 1);
}
}
found = FALSE;
for (tmp_obj = i->cyberware; tmp_obj && !found; tmp_obj = tmp_obj->next_content)
if ((GET_OBJ_VAL(tmp_obj, 2) == 0 || GET_OBJ_VAL(tmp_obj, 2) == 1 ||
GET_OBJ_VAL(tmp_obj, 2) == 23 || (GET_OBJ_VAL(tmp_obj, 2) == 27 && GET_OBJ_VAL(tmp_obj, 1) > 0) ||
((GET_OBJ_VAL(tmp_obj, 2) == 19 || GET_OBJ_VAL(tmp_obj, 2) == 21) &&
GET_POS(i) == POS_FIGHTING && !GET_EQ(i, WEAR_WIELD))))
found = TRUE;
if (found) {
act("\r\nVisible cyberware:", FALSE, i, 0, ch, TO_VICT);
for (tmp_obj = i->cyberware; tmp_obj; tmp_obj = tmp_obj->next_content)
if ((GET_OBJ_VAL(tmp_obj, 2) == 0 || GET_OBJ_VAL(tmp_obj, 2) == 1 ||
GET_OBJ_VAL(tmp_obj, 2) == 23 || (GET_OBJ_VAL(tmp_obj, 2) == 27 && GET_OBJ_VAL(tmp_obj, 1) > 0) ||
((GET_OBJ_VAL(tmp_obj, 2) == 19 || GET_OBJ_VAL(tmp_obj, 2) == 21) &&
GET_POS(i) == POS_FIGHTING && !GET_EQ(i, WEAR_WIELD))))
if (GET_OBJ_VAL(tmp_obj, 2) == 23 && isname("sheathing", tmp_obj->name))
send_to_char(ch, "dermal sheathing\r\n");
else send_to_char(ch, "%s\r\n", cyberware_names[GET_OBJ_VAL(tmp_obj, 2)]);
}
found = FALSE;
for (tmp_obj = i->bioware; tmp_obj && !found; tmp_obj = tmp_obj->next_content)
if (GET_OBJ_VAL(tmp_obj, 2) == 2)
found = TRUE;
if (found) {
act("\r\nVisible bioware:", FALSE, i, 0, ch, TO_VICT);
for (tmp_obj = i->bioware; tmp_obj; tmp_obj = tmp_obj->next_content)
if (GET_OBJ_VAL(tmp_obj, 2) == 2)
send_to_char(ch, "%s\r\n", bioware_names[GET_OBJ_VAL(tmp_obj, 2)]);
}
if (ch != i && (GET_REAL_LEVEL(ch) >= LVL_LEGEND)) {
found = FALSE;
act("\r\nYou peek at $s inventory:", FALSE, i, 0, ch, TO_VICT);
for (tmp_obj = i->carrying; tmp_obj; tmp_obj = tmp_obj->next_content) {
if (CAN_SEE_OBJ(ch, tmp_obj)) {
show_obj_to_char(tmp_obj, ch, 1);
found = TRUE;
}
}
if (!found)
send_to_char("You can't see anything.\r\n", ch);
}
}
void list_one_char(struct char_data * i, struct char_data * ch)
{
char *positions[] = {
" is lying here, dead.",
" is lying here, mortally wounded.",
" is lying here, incapacitated.",
" is lying here, stunned.",
" is sleeping here.",
" is resting here.",
" is sitting here.",
"!FIGHTING!",
" is standing here."
};
if (IS_NPC(i) && i->player.long_descr && GET_POS(i) == GET_DEFAULT_POS(i)) {
if (IS_IC(i) && GET_RACE(i) > CLASS_SCRAMBLE && !is_blocker(i) &&
zone_table[world[i->in_room].zone].alert < 2 && IS_PERSONA(ch))
return;
if (IS_AFFECTED(i, AFF_INVISIBLE))
strcpy(buf, "*");
else *buf = '\0';
if (IS_AFFECTED(ch, AFF_DETECT_ALIGN) || IS_ASTRAL(ch) || IS_DUAL(ch)) {
if (IS_EVIL(i))
strcat(buf, "(Red Aura) ");
else if (IS_GOOD(i))
strcat(buf, "(Blue Aura) ");
}
if (IS_ASTRAL(ch) || IS_DUAL(ch)) {
if (IS_ASTRAL(i))
strcat(buf, "(astral) ");
else if (IS_DUAL(i) && IS_NPC(i))
strcat(buf, "(dual) ");
}
strcat(buf, i->player.long_descr);
send_to_char(buf, ch);
if (IS_AFFECTED(i, AFF_BLIND))
act("...$e is groping around blindly!", FALSE, i, 0, ch, TO_VICT);
return;
}
if (IS_NPC(i)) {
strcpy(buf, i->player.short_descr);
CAP(buf);
} else sprintf(buf, "%s%s%s %s", (GET_PRETITLE(i) ? GET_PRETITLE(i) : ""),
(GET_PRETITLE(i) && strlen(GET_PRETITLE(i)) ? " " : ""), i->player.name, GET_TITLE(i));
if (PRF_FLAGGED(i, PRF_AFK))
strcat(buf, " (AFK)");
if (PLR_FLAGGED(i, PLR_SWITCHED))
strcat(buf, " (switched)");
if (PLR_FLAGGED(i, PLR_MATRIX))
strcat(buf, " (decking)");
if (IS_AFFECTED(i, AFF_INVISIBLE) || IS_AFFECTED(i, AFF_IMP_INVIS))
strcat(buf, " (invisible)");
if (IS_AFFECTED(i, AFF_HIDE))
strcat(buf, " (hidden)");
if (!IS_NPC(i) && !i->desc && !PLR_FLAGGED(i, PLR_MATRIX | PLR_PROJECT | PLR_SWITCHED))
strcat(buf, " (linkless)");
if (IS_ASTRAL(i) && (IS_ASTRAL(ch) || IS_DUAL(ch)))
strcat(buf, " (astral)");
if (IS_NPC(i) && IS_DUAL(i) && (IS_ASTRAL(ch) || IS_DUAL(ch)))
strcat(buf, " (dual)");
if (PLR_FLAGGED(i, PLR_WRITING))
strcat(buf, " (writing)");
if (PLR_FLAGGED(i, PLR_MAILING))
strcat(buf, " (mailing)");
if (PLR_FLAGGED(i, PLR_EDITING))
strcat(buf, " (editing)");
if (PLR_FLAGGED(i, PLR_PROJECT))
strcat(buf, " (projecting)");
if (GET_POS(i) != POS_FIGHTING)
strcat(buf, positions[(int) GET_POS(i)]);
else {
if (FIGHTING(i)) {
strcat(buf, " is here, fighting ");
if (FIGHTING(i) == ch)
strcat(buf, "YOU!");
else {
if (i->in_room == FIGHTING(i)->in_room)
strcat(buf, PERS(FIGHTING(i), ch));
else strcat(buf, "someone in the distance");
strcat(buf, "!");
}
} else /* NIL fighting pointer */
strcat(buf, " is here struggling with thin air.");
}
if (IS_AFFECTED(ch, AFF_DETECT_ALIGN)) {
if (IS_EVIL(i))
strcat(buf, " (Red Aura)");
else if (IS_GOOD(i))
strcat(buf, " (Blue Aura)");
}
strcat(buf, "\r\n");
send_to_char(buf, ch);
}
void list_char_to_char(struct char_data * list, struct char_data * ch)
{
struct char_data *i;
for (i = list; i; i = i->next_in_room)
if (ch != i)
if (CAN_SEE(ch, i))
list_one_char(i, ch);
}
void do_auto_exits(struct char_data * ch)
{
int door;
*buf = '\0';
for (door = 0; door < (NUM_OF_DIRS - 1); door++)
if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE) {
if (GET_REAL_LEVEL(ch) >= LVL_LEGEND
|| IS_ASTRAL(ch)
|| IS_DUAL(ch)) {
if (IS_SET(EXIT(ch, door)->exit_info, EX_LOCKED))
sprintf(buf, "%s%s(L) ", buf, exitdirs[door]);
else if (IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED))
sprintf(buf, "%s%s(C) ", buf, exitdirs[door]);
else sprintf(buf, "%s%s ", buf, exitdirs[door]);
} else if (!IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED | EX_HIDDEN))
sprintf(buf, "%s%s ", buf, exitdirs[door]);
}
sprintf(buf2, "^c[ Exits: %s]^n\r\n", *buf ? buf : "None! ");
send_to_char(buf2, ch);
}
ACMD(do_exits)
{
int door;
*buf = '\0';
buf2[0] = '\0'; // so strcats will start at the beginning
if (IS_AFFECTED(ch, AFF_BLIND))
{
send_to_char("You can't see a damned thing, you're blind!\r\n", ch);
return;
}
for (door = 0; door < NUM_OF_DIRS; door++)
{
if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE &&
(IS_ASTRAL(ch) || IS_SPIRIT(ch) || GET_REAL_LEVEL(ch) >= LVL_LEGEND ||
!IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED)))
{
if (GET_REAL_LEVEL(ch) >= LVL_LEGEND) {
sprintf(buf2, "%-5s - [%5d] %s%s\r\n", dirs[door],
world[EXIT(ch, door)->to_room].number,
world[EXIT(ch, door)->to_room].name,
(IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED) ? " (closed)" : ""));
} else if (!IS_SET(EXIT(ch, door)->exit_info, EX_HIDDEN)) {
sprintf(buf2, "%-5s - ", dirs[door]);
if (!IS_PERSONA(ch) && !IS_ASTRAL(ch) &&
((IS_DARK(EXIT(ch, door)->to_room) && !IS_AFFECTED(ch, AFF_INFRAVISION)) ||
(IS_LOW(EXIT(ch, door)->to_room) &&
!IS_AFFECTED(ch, AFF_INFRAVISION | AFF_LOW_LIGHT))))
strcat(buf2, "Too dark to tell.\r\n");
else {
strcat(buf2, world[EXIT(ch, door)->to_room].name);
if (IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED) && IS_ASTRAL(ch))
strcat(buf2, " (closed)\r\n");
else strcat(buf2, "\r\n");
}
}
strcat(buf, CAP(buf2));
}
}
send_to_char("Obvious exits:\r\n", ch);
if (*buf)
send_to_char(buf, ch);
else send_to_char(" None.\r\n", ch);
}
void look_at_room(struct char_data * ch, int ignore_brief)
{
if (IS_AFFECTED(ch, AFF_BLIND)) {
send_to_char("You see nothing but infinite darkness...\r\n", ch);
return;
} else if (!LIGHT_OK(ch)) {
send_to_char("It is pitch black...\r\n", ch);
return;
}
if (PRF_FLAGGED(ch, PRF_ROOMFLAGS) && GET_REAL_LEVEL(ch) >= LVL_LEGEND)
{
sprintbit((long) ROOM_FLAGS(ch->in_room), room_bits, buf);
sprintf(buf2, "^C[%5d] %s [ %s]^n", world[ch->in_room].number,
world[ch->in_room].name, buf);
send_to_char(buf2, ch);
}
else send_to_char(ch, "^C%s^n", world[ch->in_room].name, ch);
send_to_char("\r\n", ch);
send_to_char(world[ch->in_room].description, ch);
/* autoexits */
if (PRF_FLAGGED(ch, PRF_AUTOEXIT))
do_auto_exits(ch);
if (PRF_FLAGGED(ch, PRF_MSP) && world[ch->in_room].msp_trigger && !ignore_brief)
send_to_char(ch, "!!%s", world[ch->in_room].msp_trigger);
/* now list characters & objects */
// what fun just to get a colorized listing
CCHAR = "^g";
CGLOB = KGRN;
list_obj_to_char(world[ch->in_room].contents, ch, 0, FALSE, FALSE);
CGLOB = KNRM;
CCHAR = NULL;
list_obj_to_char(world[ch->in_room].contents, ch, 0, FALSE, TRUE);
list_char_to_char(world[ch->in_room].people, ch);
}
void look_in_direction(struct char_data * ch, int dir)
{
bool found = FALSE;
if (EXIT(ch, dir)) {
if (IS_SET(EXIT(ch, dir)->exit_info, EX_HIDDEN))
if (!success_test(GET_INT(ch), EXIT(ch, dir)->hidden)) {
send_to_char("You see nothing special.\r\n", ch);
return;
} else {
REMOVE_BIT(EXIT(ch, dir)->exit_info, EX_HIDDEN);
found = TRUE;
}
if (EXIT(ch, dir)->general_description)
send_to_char(EXIT(ch, dir)->general_description, ch);
else send_to_char("You see nothing special.\r\n", ch);
if (found)
send_to_char("You discover an exit...\r\n", ch);
if (IS_SET(EXIT(ch, dir)->exit_info, EX_DESTROYED) && EXIT(ch, dir)->keyword)
send_to_char(ch, "The %s is destroyed.\r\n", fname(EXIT(ch, dir)->keyword));
else if (IS_SET(EXIT(ch, dir)->exit_info, EX_CLOSED) && EXIT(ch, dir)->keyword)
send_to_char(ch, "The %s is closed.\r\n", fname(EXIT(ch, dir)->keyword));
else if (IS_SET(EXIT(ch, dir)->exit_info, EX_ISDOOR) && EXIT(ch, dir)->keyword)
send_to_char(ch, "The %s is open.\r\n", fname(EXIT(ch, dir)->keyword));
} else send_to_char("You see nothing special.\r\n", ch);
}
void look_in_obj(struct char_data * ch, char *arg)
{
struct obj_data *obj = NULL;
struct char_data *dummy = NULL;
int amt, bits;
if (!*arg)
send_to_char("Look in what?\r\n", ch);
else if (!(bits = generic_find(arg, FIND_OBJ_INV | FIND_OBJ_ROOM |
FIND_OBJ_EQUIP, ch, &dummy, &obj))) {
sprintf(buf, "There doesn't seem to be %s %s here.\r\n", AN(arg), arg);
send_to_char(buf, ch);
} else if ((GET_OBJ_TYPE(obj) != ITEM_DRINKCON) &&
(GET_OBJ_TYPE(obj) != ITEM_FOUNTAIN) &&
(GET_OBJ_TYPE(obj) != ITEM_CONTAINER) &&
(GET_OBJ_TYPE(obj) != ITEM_QUIVER))
send_to_char("There's nothing inside that!\r\n", ch);
else {
if (GET_OBJ_TYPE(obj) == ITEM_CONTAINER) {
if (IS_SET(GET_OBJ_VAL(obj, 1), CONT_CLOSED))
send_to_char("It is closed.\r\n", ch);
else {
send_to_char(fname(obj->name), ch);
switch (bits) {
case FIND_OBJ_INV:
send_to_char(" (carried): \r\n", ch);
break;
case FIND_OBJ_ROOM:
send_to_char(" (here): \r\n", ch);
break;
case FIND_OBJ_EQUIP:
send_to_char(" (used): \r\n", ch);
break;
}
list_obj_to_char(obj->contains, ch, 2, TRUE, FALSE);
}
} else { /* item must be a fountain or drink container */
if (GET_OBJ_VAL(obj, 1) <= 0)
send_to_char("It is empty.\r\n", ch);
else {
amt = ((GET_OBJ_VAL(obj, 1) * 3) / GET_OBJ_VAL(obj, 0));
sprintf(buf, "It's %sfull of a %s liquid.\r\n", fullness[amt],
color_liquid[GET_OBJ_VAL(obj, 2)]);
send_to_char(buf, ch);
}
}
}
}
char *find_exdesc(char *word, struct extra_descr_data * list)
{
struct extra_descr_data *i;
for (i = list; i; i = i->next)
if (isname(word, i->keyword))
return (i->description);
return NULL;
}
/*
* Given the argument "look at <target>", figure out what object or char
* matches the target. First, see if there is another char in the room
* with the name. Then check local objs for exdescs.
*/
void look_at_target(struct char_data * ch, char *arg)
{
int bits, found = 0, j;
struct char_data *found_char = NULL;
struct obj_data *obj = NULL, *found_obj = NULL;
char *desc;
if (!*arg) {
send_to_char("Look at what?\r\n", ch);
return;
}
bits = generic_find(arg, FIND_OBJ_INV | FIND_OBJ_ROOM | FIND_OBJ_EQUIP |
FIND_CHAR_ROOM, ch, &found_char, &found_obj);
/* Is the target a character? */
if (found_char != NULL) {
look_at_char(found_char, ch);
if (ch != found_char) {
if (CAN_SEE(found_char, ch))
act("$n looks at you.", TRUE, ch, 0, found_char, TO_VICT);
act("$n looks at $N.", TRUE, ch, 0, found_char, TO_NOTVICT);
}
return;
}
/* Does the argument match an extra desc in the room? */
if ((desc = find_exdesc(arg, world[ch->in_room].ex_description)) != NULL) {
page_string(ch->desc, desc, 0);
return;
}
/* Does the argument match a piece of equipment */
for (j = 0; j < NUM_WEARS && !found; j++)
if (ch->equipment[j] && CAN_SEE_OBJ(ch, ch->equipment[j]) &&
isname(arg, ch->equipment[j]->name))
if (ch->equipment[j]->long_description) {
send_to_char(ch->equipment[j]->long_description, ch);
found = TRUE;
}
/* Does the argument match an extra desc in the char's equipment? */
for (j = 0; j < NUM_WEARS && !found; j++)
if (ch->equipment[j] && CAN_SEE_OBJ(ch, ch->equipment[j]))
if ((desc = find_exdesc(arg, ch->equipment[j]->ex_description)) != NULL) {
page_string(ch->desc, desc, 1);
found = 1;
}
/* Does the argument match an extra desc in the char's inventory? */
for (obj = ch->carrying; obj && !found; obj = obj->next_content) {
if (CAN_SEE_OBJ(ch, obj))
if ((desc = find_exdesc(arg, obj->ex_description)) != NULL) {
page_string(ch->desc, desc, 1);
found = 1;
}
}
/* Does the argument match an extra desc of an object in the room? */
for (obj = world[ch->in_room].contents; obj && !found; obj = obj->next_content)
if (CAN_SEE_OBJ(ch, obj))
if ((desc = find_exdesc(arg, obj->ex_description)) != NULL) {
send_to_char(desc, ch);
found = 1;
}
if (bits) { /* If an object was found back in
* generic_find */
if (!found)
show_obj_to_char(found_obj, ch, 5); /* Show no-description */
else
show_obj_to_char(found_obj, ch, 6); /* Find hum, glow etc */
} else if (!found)
send_to_char("You do not see that here.\r\n", ch);
}
ACMD(do_look)
{
static char arg2[MAX_INPUT_LENGTH];
int look_type;
if (!ch->desc)
return;
if (GET_POS(ch) < POS_SLEEPING)
send_to_char("You can't see anything but stars!\r\n", ch);
else if (IS_AFFECTED(ch, AFF_BLIND))
send_to_char("You can't see a damned thing, you're blind!\r\n", ch);
else if (!LIGHT_OK(ch)) {
send_to_char("It is pitch black...\r\n", ch);
} else {
half_chop(argument, arg, arg2);
if (subcmd == SCMD_READ) {
if (!*arg)
send_to_char("Read what?\r\n", ch);
else look_at_target(ch, arg);
return;
}
if (!*arg) /* "look" alone, without an argument at all */
look_at_room(ch, 1);
else if (is_abbrev(arg, "in"))
look_in_obj(ch, arg2);
/* did the char type 'look <direction>?' */
else if ((look_type = search_block(arg, lookdirs, FALSE)) >= 0)
look_in_direction(ch, convert_look[look_type]);
else if (is_abbrev(arg, "at"))
look_at_target(ch, arg2);
else look_at_target(ch, arg);
}
}
ACMD(do_examine)
{
int bits, i;
struct char_data *tmp_char;
struct obj_data *tmp_object;
one_argument(argument, arg);
if (!*arg) {
send_to_char("Examine what?\r\n", ch);
return;
}
look_at_target(ch, arg);
bits = generic_find(arg, FIND_OBJ_INV | FIND_OBJ_ROOM | FIND_CHAR_ROOM |
FIND_OBJ_EQUIP, ch, &tmp_char, &tmp_object);
if (tmp_object) {
if ((GET_OBJ_TYPE(tmp_object) == ITEM_DRINKCON) || (GET_OBJ_TYPE(tmp_object) == ITEM_FOUNTAIN) ||
(GET_OBJ_TYPE(tmp_object) == ITEM_CONTAINER)) {
send_to_char("When you look inside, you see:\r\n", ch);
look_in_obj(ch, arg);
} else {
if ((GET_OBJ_TYPE(tmp_object) == ITEM_WEAPON) && (GET_OBJ_VAL(tmp_object, 3) >= TYPE_PISTOL)) {
for (i = 7; i < 10; ++i)
if (GET_OBJ_VAL(tmp_object, i) > 0) {
sprintf(buf1, "There is %s attached to the %s of it.\r\n",
short_object(GET_OBJ_VAL(tmp_object, i), 2), (i == 7 ? "top" :
(i == 8 ? "barrel" : "bottom")));
send_to_char(buf1, ch);
}
sprintf(buf, "It contains %d bullet%s, and can hold %d bullet%s.\r\n",
MIN(GET_OBJ_VAL(tmp_object, 6), GET_OBJ_VAL(tmp_object, 5)),
(GET_OBJ_VAL(tmp_object, 6) != 1 ? "s" : ""), GET_OBJ_VAL(tmp_object, 5),
(GET_OBJ_VAL(tmp_object, 5) != 1 ? "s" : ""));
if (GET_OBJ_VAL(tmp_object, 5) > 0)
send_to_char(buf, ch);
}
}
if (GET_OBJ_TYPE(tmp_object) == ITEM_MONEY) {
if (!GET_OBJ_VAL(tmp_object, 1)) // paper money
send_to_char(ch, "There looks to be about %d nuyen.\r\n", GET_OBJ_VAL(tmp_object, 0));
else {
if (GET_OBJ_VAL(tmp_object, 4)) {
if (belongs_to(ch, tmp_object))
send_to_char("It has been activated by you.\r\n", ch);
else send_to_char("It has been activated.\r\n", ch);
} else send_to_char("It has not been activated.\r\n", ch);
send_to_char(ch, "The account display shows %d nuyen.\r\n", GET_OBJ_VAL(tmp_object, 0));
}
}
if (GET_OBJ_TYPE(tmp_object) == ITEM_SPELL_FORMULA)
send_to_char(ch, "It appears to be a %s spell.\r\n",
(GET_OBJ_VAL(tmp_object, 7) ? "shaman" : "mage"));
get_obj_condition(ch, tmp_object);
}
}
ACMD(do_gold)
{
if (IS_PERSONA(ch)) {
send_to_char("That is not a valid command.\r\n", ch);
return;
}
if (GET_NUYEN(ch) == 0)
send_to_char("You're broke!\r\n", ch);
else if (GET_NUYEN(ch) == 1)
send_to_char("You have one miserable nuyen.\r\n", ch);
else {
sprintf(buf, "You have %d nuyen.\r\n", GET_NUYEN(ch));
send_to_char(buf, ch);
}
}
ACMD(do_pool)
{
char pools[MAX_INPUT_LENGTH];
sprintf(pools, " Combat: %d (Defense: %d Offense: %d)\r\n",
GET_COMBAT(ch), GET_DEFENSE(ch), GET_OFFENSE(ch));
if (GET_ASTRAL(ch) > 0)
sprintf(pools, "%s Astral: %d\r\n", pools, GET_ASTRAL(ch));
if (GET_HACKING(ch) > 0)
sprintf(pools, "%s Hacking: %d\r\n", pools, GET_HACKING(ch));
if (GET_MAGIC(ch) > 0)
sprintf(pools, "%s Magic: %d\r\n", pools, GET_MAGIC(ch));
send_to_char(pools, ch);
}
ACMD(do_score)
{
extern int has_mail(long); // to check to see if they have mail
struct time_info_data playing_time;
struct time_info_data real_time_passed(time_t t2, time_t t1);
char buf3[20];
char buf4[20];
if ( IS_NPC(ch) && ch->desc == NULL )
return;
sprinttype(ch->player.race, pc_race_types, buf2);
sprinttype(GET_TOTEM(ch), totem_types, buf4);
if (!IS_NPC(ch) && access_level(ch, LVL_LEGEND))
sprintf(buf, "You are an ageless %s.", buf2);
else sprintf(buf, "You are a %d year old %s.", GET_AGE(ch), buf2);
if (GET_TOTEM(ch))
sprintf(buf, "%s Your totem is %s.", buf, buf4);
else if (ch->desc != NULL && ch->desc->original != NULL )
{
if (IS_SET(PLR_FLAGS(ch->desc->original), PLR_MATRIX))
sprintf(buf, "You are connected to the Matrix.");
else if (IS_PROJECT(ch))
sprintf(buf, "You are astrally projecting.");
else sprintf(buf, "You are occupying the body of %s.", GET_NAME(ch));
}
if ((age(ch).month == 0) && (age(ch).day == 0) && (IS_NPC(ch) ||
!access_level(ch, LVL_LEGEND))) {
if (!(ch->desc->original))
strcat(buf, " It's your birthday today.\r\n");
else strcat(buf, "\r\n");
} else strcat(buf, "\r\n");
if (ch->desc != NULL && ch->desc->original != NULL && IS_PERSONA(ch)) {
sprintf(buf, "%s Condition:^B%3d^n Physical:^R%3d(%2d)^n\r\n"
" Bod:%3d Evasion:%3d\r\n"
" Masking:%3d Sensors:%3d\r\n"
" Hardening:%3d\r\n", buf,
(int)(GET_PHYSICAL(ch) / 100),
(int)(GET_PHYSICAL(ch->desc->original) / 100),
(int)(GET_MAX_PHYSICAL(ch->desc->original) / 100),
GET_BOD(ch), GET_QUI(ch), GET_CHA(ch), GET_INT(ch), GET_BALLISTIC(ch));
} else {
if (!IS_NPC(ch) && GET_TRADITION(ch) == TRAD_ADEPT)
sprintf(buf2, "^C%0.2f^c (%0.2f)^n", (float)GET_MAG(ch) / 100,
(float)ch->real_abils.mag / 100);
else if (!IS_NPC(ch) && GET_TRADITION(ch) == TRAD_MUNDANE && GET_LEVEL(ch) < LVL_LEGEND)
sprintf(buf2, "^C 0^c ( 0)^n" );
else
sprintf(buf2, "^C%2d^c (%2d)^n Grade: %d", (int)(GET_MAG(ch) / 100),
(int)(ch->real_abils.mag / 100),GET_GRADE(ch));
sprintf(buf, "%sPhysical: ^Y%2d (%2d)^n Mental: ^B%2d (%2d)^n\r\n", buf,
(int)(GET_PHYSICAL(ch) / 100), (int)(GET_MAX_PHYSICAL(ch) / 100),
(int)(GET_MENTAL(ch) / 100), (int)(GET_MAX_MENTAL(ch) / 100));
/*
Changed Body Index to Essence Index as per SRIII Man & Machine
*/
sprintf(buf, "%sBod: ^C%2d ^c(%2d)^n Qui: ^C%2d ^c(%2d)^n "
"Str: ^C%2d ^c(%2d)^n Rea: ^C%2d ^c(%2d)^n\r\n"
"Cha: ^C%2d ^c(%2d)^n Int: ^C%2d ^c(%2d)^n "
"Wil: ^C%2d ^c(%2d)^n Mag: %s\r\n"
"Ess: ^C%0.2f ^c(%0.2f)^n Ess Index: ^C%0.2f^n\r\n",
buf, GET_BOD(ch), ch->real_abils.bod, GET_QUI(ch), ch->real_abils.qui,
GET_STR(ch), ch->real_abils.str, GET_REA(ch), ch->real_abils.rea,
GET_CHA(ch), ch->real_abils.cha, GET_INT(ch), ch->real_abils.intel,
GET_WIL(ch), ch->real_abils.wil, buf2,
((float)GET_ESS(ch) / 100), ((float)ch->real_abils.ess / 100), ((float)GET_INDEX(ch) / 100));
sprintf(buf, "%sBallistic: ^C%2d^n Impact: ^C%2d^n\r\n",
buf, GET_BALLISTIC(ch), GET_IMPACT(ch));
}
/* Rep string */
sprintf(buf2,"Rep: ^y%d^n", GET_REP(ch) );
if (!IS_NPC(ch))
{
sprintf(buf, "%sKarma: ^m%-9.2f^n Nuyen: ^Y%d ¥^n %s\r\n"
"You are %0.2f meters tall and weigh %d kilograms.\r\nYou are carrying %d kilograms out of %d kilorgrams.\n\r",
buf, ((float)GET_KARMA(ch) / 100), GET_NUYEN(ch),
!PLR_FLAGGED(ch, PLR_NEWBIE) ? buf2 : "",
((float)GET_HEIGHT(ch) / 100), GET_WEIGHT(ch), IS_CARRYING_W(ch) ,CAN_CARRY_W(ch) );
playing_time = real_time_passed((time(0) - ch->player.time.logon) +
ch->player.time.played, 0);
sprintf(buf, "%sYou have been playing for %d days and %d hours.\r\n",
buf, playing_time.day, playing_time.hours);
}
/* list their allergies */
if (GET_ALLERGY(ch) != ALLERGIC_NONE && !(IS_NPC(ch) ||
PLR_FLAGGED(ch, PLR_NEWBIE) || access_level(ch, LVL_LEGEND))) {
sprinttype(GET_ALLERGY(ch), allergy_names, buf2);
sprinttype(GET_SEVERITY(ch), severity_names, buf3);
sprintf(buf, "%sYou are %s allergic to %s.\r\n", buf, buf3, buf2);
}
if (IS_AFFECTED(ch, AFF_INFRAVISION) && !IS_PERSONA(ch) && !IS_ASTRAL(ch))
strcat(buf, "You have ^rinfravision^n.\r\n");
else if (IS_AFFECTED(ch, AFF_LOW_LIGHT))
strcat(buf, "You have ^ylow-light eyes^n.\r\n");
switch (GET_POS(ch)) {
case POS_DEAD:
strcat(buf, "You are DEAD!\r\n");
break;
case POS_MORTALLYW:
strcat(buf, "You are mortally wounded! You should seek help!\r\n");
break;
case POS_INCAP:
strcat(buf, "You are incapacitated, slowly fading away...\r\n");
break;
case POS_STUNNED:
strcat(buf, "You are stunned! You can't move!\r\n");
break;
case POS_SLEEPING:
strcat(buf, "You are sleeping.\r\n");
break;
case POS_RESTING:
strcat(buf, "You are resting.\r\n");
break;
case POS_SITTING:
strcat(buf, "You are sitting.\r\n");
break;
case POS_FIGHTING:
if (FIGHTING(ch))
sprintf(buf, "%sYou are fighting %s.\r\n", buf, PERS(FIGHTING(ch), ch));
else strcat(buf, "You are fighting thin air.\r\n");
break;
case POS_STANDING:
if (SECT(ch->in_room) == SECT_WATER_SWIM)
strcat(buf, "You are swimming.\r\n");
else strcat(buf, "You are standing.\r\n");
break;
default:
strcat(buf, "You are floating.\r\n");
break;
}
if ( ch->desc != NULL && ch->desc->original != NULL )
{
if (GET_COND(ch, DRUNK) > 10)
strcat(buf, "You are ^Mintoxicated^n.\r\n");
if (GET_COND(ch, FULL) == 0)
strcat(buf, "You are ^yhungry^n.\r\n");
if (GET_COND(ch, THIRST) == 0)
strcat(buf, "You are ^cthirsty^n.\r\n");
}
if (IS_AFFECTED(ch, AFF_BLIND))
strcat(buf, "You have been ^Lblinded^n!\r\n");
if (IS_AFFECTED(ch, AFF_INVISIBLE) || IS_AFFECTED(ch, AFF_IMP_INVIS))
strcat(buf, "You are ^Linvisible^n.\r\n");
if (IS_AFFECTED(ch, AFF_DETECT_INVIS))
strcat(buf, "You are sensitive to the presence of ^Linvisible^n things.\r\n");
if (IS_AFFECTED(ch, AFF_POISON))
strcat(buf, "You are ^Gpoisoned^n!\r\n");
if (IS_AFFECTED(ch, AFF_CHARM))
strcat(buf, "You have been ^Rcharmed^n!\r\n");
if (!IS_NPC(ch) && has_mail(GET_IDNUM(ch)))
strcat(buf, "You have ^G«mail»^n.\r\n");
send_to_char(buf, ch);
}
ACMD(do_inventory)
{
if (IS_PERSONA(ch)) {
send_to_char("Technically, nonexistent people cannot carry things.\r\n", ch);
return;
}
send_to_char("You are carrying:\r\n", ch);
list_obj_to_char(ch->carrying, ch, 1, TRUE, FALSE);
}
ACMD(do_cyberware)
{
struct obj_data *obj;
if (!ch->cyberware) {
send_to_char("You have no cyberware.\r\n", ch);
return;
}
send_to_char("You have the following cyberware:\r\n", ch);
for (obj = ch->cyberware; obj != NULL; obj = obj->next_content) {
sprintf(buf, "%-30s Rating: %-2d Essence: %0.2f\r\n", obj->short_description,
GET_OBJ_VAL(obj, 0), ((float)GET_OBJ_VAL(obj, 1) / 100));
send_to_char(buf, ch);
}
}
ACMD(do_bioware)
{
struct obj_data *obj;
if (!ch->bioware) {
send_to_char("You have no bioware.\r\n", ch);
return;
}
send_to_char("You have the following bioware:\r\n", ch);
for (obj = ch->bioware; obj != NULL; obj = obj->next_content) {
sprintf(buf, "%-30s Rating: %-2d Body Index: %0.2f\r\n", obj->short_description,
GET_OBJ_VAL(obj, 0), ((float)GET_OBJ_VAL(obj, 1) / 100));
send_to_char(buf, ch);
}
}
ACMD(do_equipment)
{
int i, found = 0;
if (IS_PERSONA(ch)) {
send_to_char("That is not a valid command.\r\n", ch);
return;
}
send_to_char("You are using:\r\n", ch);
for (i = 0; i < NUM_WEARS; i++) {
if (GET_EQ(ch, i)) {
if (i == WEAR_WIELD || i == WEAR_HOLD) {
if (IS_OBJ_STAT(GET_EQ(ch, i), ITEM_TWOHANDS))
send_to_char(hands[2], ch);
else if (GET_WIELDED(ch, i - WEAR_WIELD)) { // wielding something?
if (i == WEAR_WIELD)
send_to_char(wielding_hands[ch->char_specials.saved.left_handed], ch);
else send_to_char(wielding_hands[!ch->char_specials.saved.left_handed], ch);
} else { // just held
if (i == WEAR_WIELD)
send_to_char(hands[ch->char_specials.saved.left_handed], ch);
else send_to_char(hands[!ch->char_specials.saved.left_handed], ch);
}
} else send_to_char(where[i], ch);
if (CAN_SEE_OBJ(ch, GET_EQ(ch, i)))
show_obj_to_char(GET_EQ(ch, i), ch, 1);
else send_to_char("Something.\r\n", ch);
found = TRUE;
}
}
if (!found) {
send_to_char(" Nothing.\r\n", ch);
}
}
ACMD(do_time)
{
sh_int year, month, day, hour, minute, pm;
extern struct time_info_data time_info;
extern const char *weekdays[];
extern const char *month_name[];
if (subcmd == SCMD_NORMAL && GET_REAL_LEVEL(ch) >= LVL_LEGEND)
subcmd = SCMD_PRECISE;
year = time_info.year % 100;
month = time_info.month + 1;
day = time_info.day + 1;
hour = (time_info.hours % 12 == 0 ? 12 : time_info.hours % 12);
minute = time_info.minute;
pm = (time_info.hours >= 12);
if (subcmd == SCMD_NORMAL)
sprintf(buf, "%d o'clock %s, %s, %s %d, %d.\r\n", hour, pm ? "PM" : "AM",
weekdays[time_info.weekday], month_name[month - 1], day, time_info.year);
else sprintf(buf, "%d:%s%d %s, %s, %s%d/%s%d/%d.\r\n", hour,
minute < 10 ? "0" : "", minute, pm ? "PM" : "AM",
weekdays[time_info.weekday], month < 10 ? "0" : "", month,
day < 10 ? "0" : "", day, year);
send_to_char(buf, ch);
}
ACMD(do_weather)
{
static char *sky_look[] =
{
"cloudless",
"cloudy",
"rainy",
"lit by flashes of lightning"
};
if (OUTSIDE(ch))
{
sprintf(buf, "The sky is %s and %s.\r\n", sky_look[weather_info.sky],
(weather_info.change >= 0 ? "you feel a warm wind from south" :
"your foot tells you bad weather is due"));
send_to_char(buf, ch);
}
else
send_to_char("You have no feeling about the weather at all.\r\n", ch);
}
bool help_to_buf(char *buffer, char *argument)
{
extern int top_of_helpt;
extern struct help_index_element *help_index;
extern FILE *help_fl;
extern char *help;
extern char *hindex;
int chk;
int bot = 0;
int top = top_of_helpt;
for (;;) {
int mid = (bot + top) >> 1;
int minlen = strlen(argument);
if (!(chk = strn_cmp(argument, help_index[mid].keyword, minlen))) {
/* trace backwards to find first matching entry. Thanks Jeff Fink! */
while ((mid > 0) &&
(!(chk = strn_cmp(argument, help_index[mid - 1].keyword, minlen))))
mid--;
fseek(help_fl, help_index[mid].pos, SEEK_SET);
*buffer = '\0';
for (;;) {
fgets(buf, 128, help_fl);
if (*buf == '#')
break;
buf[strlen(buf) - 1] = '\0'; /* cleave off the trailing \n */
strcat(buffer, strcat(buf, "\r\n"));
}
return TRUE;
} else if (bot >= top) {
return FALSE;
} else if (chk > 0)
bot = ++mid;
else top = --mid;
}
}
// this command sends the index to the player--it can take a letter as an
// argument and will send only words that fall under that letter
ACMD(do_index)
{
extern char *hindex;
extern int top_of_helpt;
extern struct help_index_element *help_index;
char *temp = argument;
skip_spaces(&temp);
if (!*temp) {
page_string(ch->desc, hindex, 0);
return;
}
char letter = *temp;
if (!isalpha(letter)) {
send_to_char("Only letters can be sent to the index command.\r\n", ch);
return;
}
letter = tolower(letter);
sprintf(buf2, "\t\t\t\t ^W%c\r\n", letter);
strcat(buf2, "---------------------------------------------------------------------^n\r\n");
// now we run through the list and print out an index to the player
register int i = 0;
// first we find the first keyword equal to the letter
while (*help_index[i].keyword < letter) // this is dangerous cause I'm not
++i; // checking to make sure we don't
// overrun the array--however I've
// know MY help table has a 'z'
letter++; // increment the letter so we know where we are headed
// then we send the list to the char
int j = 0;
while ((i < top_of_helpt) && (*help_index[i].keyword < letter)) {
j += strlen(help_index[i].keyword) + 2;
if (j < 75)
strcat(buf2, help_index[i].keyword);
else
{
j = strlen(help_index[i].keyword) + 2;
strcat(buf2, "\r\n");
strcat(buf2, help_index[i].keyword);
}
if (++i < top_of_helpt)
strcat(buf2, ", ");
else
strcat(buf2, "\r\n");
}
strcat(buf2, "\r\n\r\n^W-----Done-----^n\r\n");
send_to_char(buf2, ch);
}
ACMD(do_help)
{
extern int top_of_helpt;
extern struct help_index_element *help_index;
extern FILE *help_fl;
extern char *help;
int chk, bot, top, mid, minlen;
if (!ch->desc)
return;
skip_spaces(&argument);
if (!*argument) {
page_string(ch->desc, help, 0);
return;
}
if (!help_index) {
send_to_char("No help available.\r\n", ch);
return;
}
if (help_to_buf(buf2, argument))
page_string(ch->desc, buf2, TRUE);
else send_to_char("No help found for that word.\r\n", ch);
}
bool wizhelp_to_buf(char *buffer, char *argument)
{
extern int top_of_wizhelpt;
extern struct help_index_element *wizhelp_index;
extern FILE *wizhelp_fl;
int chk;
int bot = 0;
int top = top_of_wizhelpt;
for (;;) {
int mid = (bot + top) >> 1;
int minlen = strlen(argument);
if (!(chk = strn_cmp(argument, wizhelp_index[mid].keyword, minlen))) {
/* trace backwards to find first matching entry. Thanks Jeff Fink! */
while ((mid > 0) &&
(!(chk = strn_cmp(argument, wizhelp_index[mid - 1].keyword, minlen))))
mid--;
fseek(wizhelp_fl, wizhelp_index[mid].pos, SEEK_SET);
*buffer = '\0';
for (;;) {
fgets(buf, 128, wizhelp_fl);
if (*buf == '#')
break;
buf[strlen(buf) - 1] = '\0'; /* cleave off the trailing \n */
strcat(buffer, strcat(buf, "\r\n"));
}
return TRUE;
} else if (bot >= top)
return FALSE;
else if (chk > 0)
bot = ++mid;
else top = --mid;
}
}
ACMD(do_wizhelp)
{
extern struct help_index_element *wizhelp_index;
struct char_data *vict = NULL;
int no, cmd_num;
if (!ch->desc)
return;
skip_spaces(&argument);
if (!*argument || ((vict = get_char_vis(ch, argument)) && !IS_NPC(vict) &&
access_level(vict, LVL_LEGEND))) {
if (!vict)
vict = ch;
sprintf(buf, "The following privileged commands are available to %s:\r\n",
vict == ch ? "you" : GET_NAME(vict));
/* cmd_num starts at 1, not 0, to remove 'RESERVED' */
for (no = 1, cmd_num = 1; *cmd_info[cmd_num].command != '\n'; cmd_num++)
if (cmd_info[cmd_num].minimum_level >= LVL_LEGEND
&& GET_LEVEL(vict) >= cmd_info[cmd_num].minimum_level) {
sprintf(buf + strlen(buf), "%-13s", cmd_info[cmd_num].command);
if (!(no % 6))
strcat(buf, "\r\n");
no++;
}
strcat(buf, "\r\n");
send_to_char(buf, ch);
return;
} else if (!wizhelp_index) {
send_to_char("No wizhelp available.\r\n", ch);
return;
}
if (wizhelp_to_buf(buf2, argument))
page_string(ch->desc, buf2, TRUE);
else send_to_char("No help found for that word.\r\n", ch);
}
#define WHO_FORMAT "format: who [sort] [quest] [pker] [immortal] [mortal]\r\n"
ACMD(do_who)
{
struct descriptor_data *d;
struct char_data *tch;
unsigned int i;
int sort = -1, quest = 0, pker = 0, immort = 0, mortal = 0, num_can_see = 0;
skip_spaces(&argument);
strcpy(buf, argument);
while (*buf) {
half_chop(buf, arg, buf1);
if (is_abbrev(arg, "sort"))
sort = LVL_OWNER;
else if (is_abbrev(arg, "quest"))
quest = 1;
else if (is_abbrev(arg, "pker"))
pker = 1;
else if (is_abbrev(arg, "immortal"))
immort = 1;
else if (is_abbrev(arg, "mortal"))
mortal = 1;
else {
send_to_char(WHO_FORMAT, ch);
return;
}
strcpy(buf, buf1);
} /* end while (parser) */
if (immort)
send_to_char("Immortals\r\n-------\r\n", ch);
else send_to_char("Players\r\n-------\r\n", ch);
*buf = '\0';
for (; sort != 0; sort > 0 ? sort-- : sort++)
for (d = descriptor_list; d; d = d->next) {
if (d->connected)
continue;
if (d->original)
tch = d->original;
else if (!(tch = d->character))
continue;
if (!CAN_SEE(ch, tch) || (mortal && access_level(tch, LVL_LEGEND)) ||
(immort && !access_level(tch, LVL_LEGEND)))
continue;
if (quest && !PRF_FLAGGED(tch, PRF_QUEST))
continue;
if (pker && !PRF_FLAGGED(tch, PRF_PKER))
continue;
if (sort > 0 && GET_LEVEL(tch) != sort)
continue;
num_can_see++;
switch (GET_LEVEL(tch)) {
case LVL_LEGEND: sprintf(buf1, "^g"); break;
case LVL_BUILDER: sprintf(buf1, "^G"); break;
case LVL_ARCHITECT: sprintf(buf1, "^c"); break;
case LVL_MANAGER: sprintf(buf1, "^C"); break;
case LVL_ADVISOR: sprintf(buf1, "^r"); break;
case LVL_DIRECTOR: sprintf(buf1, "^R"); break;
case LVL_PRESIDENT: sprintf(buf1, "^b"); break;
case LVL_OWNER: sprintf(buf1, "^B"); break;
default: sprintf(buf1, "^n"); break;
}
sprintf(buf2, "[%5.5s] %s%s%s %s^n", (PLR_FLAGGED(tch, PLR_GUEST) ? "GUEST" :
(GET_WHOTITLE(tch) ? GET_WHOTITLE(tch) : "")),
(GET_PRETITLE(tch) ? GET_PRETITLE(tch) : ""), (GET_PRETITLE(tch) &&
strlen(GET_PRETITLE(tch)) ? " " : ""), GET_NAME(tch), GET_TITLE(tch));
strcat(buf1, buf2);
if (PRF_FLAGGED(tch, PRF_AFK))
strcat(buf1, " (AFK)");
if (GET_INVIS_LEV(tch))
sprintf(buf1, "%s (i%d)", buf1, GET_INVIS_LEV(tch));
if (PLR_FLAGGED(tch, PLR_MAILING))
strcat(buf1, " (mailing)");
else if (PLR_FLAGGED(tch, PLR_WRITING))
strcat(buf1, " (writing)");
if (PLR_FLAGGED(tch, PLR_EDITING))
strcat(buf1, " (editing)");
if (PLR_FLAGGED(tch, PLR_MATRIX))
strcat(buf1, " (decking)");
else if (PLR_FLAGGED(tch, PLR_PROJECT))
strcat(buf1, " (projecting)");
else if (d->original) {
if (IS_NPC(d->character) && GET_MOB_VNUM(d->character) >= 50 &&
GET_MOB_VNUM(d->character) < 70)
strcat(buf1, " (morphed)");
else strcat(buf1, " (switched)");
}
if (!pker && PRF_FLAGGED(tch, PRF_PKER))
strcat(buf1, " (pk)");
if (!quest && PRF_FLAGGED(tch, PRF_QUEST))
strcat(buf1, " (hired)");
if (PRF_FLAGGED(tch, PRF_NOTELL))
strcat(buf1, " (notell)");
if (PLR_FLAGGED(tch, PLR_THIEF))
strcat(buf1, " (THIEF)");
if (PLR_FLAGGED(tch, PLR_KILLER))
strcat(buf1, " (KILLER)");
if (PLR_FLAGGED(tch, PLR_WANTED))
strcat(buf1, " (WANTED)");
strcat(buf1, "\r\n");
strcat(buf, buf1);
CGLOB = KNRM;
}
if (num_can_see == 0)
strcat(buf, "\r\nNo-one at all!\r\n");
else if (num_can_see == 1)
strcat(buf, "\r\nOne lonely chummer displayed.\r\n");
else sprintf(buf, "%s\r\n%d chummers displayed.\r\n", buf, num_can_see);
page_string(ch->desc, buf, 1);
}
#define USERS_FORMAT "format: users [-n name] [-h host] [-o] [-p]\r\n"
ACMD(do_users)
{
extern const char *connected_types[];
char line[200], line2[220], idletime[10];
char state[30], *timeptr, *format, mode;
char name_search[MAX_INPUT_LENGTH], host_search[MAX_INPUT_LENGTH];
struct char_data *tch;
struct descriptor_data *d;
unsigned int i;
int num_can_see = 0;
int showclass = 0, outlaws = 0, playing = 0, deadweight = 0;
host_search[0] = name_search[0] = '\0';
strcpy(buf, argument);
while (*buf) {
half_chop(buf, arg, buf1);
if (*arg == '-') {
mode = *(arg + 1); /* just in case; we destroy arg in the switch */
switch (mode) {
case 'o': case 'k':
outlaws = 1;
playing = 1;
strcpy(buf, buf1);
break;
case 'p':
playing = 1;
strcpy(buf, buf1);
break;
case 'd':
deadweight = 1;
strcpy(buf, buf1);
break;
case 'n':
playing = 1;
half_chop(buf1, name_search, buf);
break;
case 'h':
playing = 1;
half_chop(buf1, host_search, buf);
break;
default:
send_to_char(USERS_FORMAT, ch);
return;
break;
} /* end of switch */
} else { /* endif */
send_to_char(USERS_FORMAT, ch);
return;
}
} /* end while (parser) */
strcpy(line, "Num Name State Idle Login@ Site\r\n");
strcat(line, "---- -------------- --------------- ---- -------- ---------------------------\r\n");
send_to_char(line, ch);
one_argument(argument, arg);
for (d = descriptor_list; d; d = d->next) {
if (d->connected && playing)
continue;
if (!d->connected && deadweight)
continue;
if (!d->connected) {
if (d->original)
tch = d->original;
else if (!(tch = d->character))
continue;
if (*host_search && !strstr((const char *)d->host, host_search))
continue;
if (*name_search && str_cmp(GET_NAME(tch), name_search))
continue;
if (!CAN_SEE(ch, tch))
continue;
if (outlaws && !PLR_FLAGGED(tch, PLR_KILLER) && !PLR_FLAGGED(tch, PLR_THIEF))
continue;
if (GET_INVIS_LEV(ch) > GET_LEVEL(ch))
continue;
}
timeptr = asctime(localtime(&d->login_time));
timeptr += 11;
*(timeptr + 8) = '\0';
if (!d->connected && d->original)
strcpy(state, "Switched");
else strcpy(state, connected_types[d->connected]);
if (d->character && !d->connected)
sprintf(idletime, "%4d", d->character->char_specials.timer);
else strcpy(idletime, "");
format = "%-4d %-14s %-15s %-4s %-8s ";
if (d->character && d->character->player.name) {
if (d->original)
sprintf(line, format, d->desc_num, d->original->player.name, state, idletime, timeptr);
else sprintf(line, format, d->desc_num, d->character->player.name, state, idletime, timeptr);
} else sprintf(line, format, d->desc_num, "UNDEFINED", state, idletime, timeptr);
if (d->host && *d->host)
sprintf(line + strlen(line), "[%s]\r\n", d->host);
else strcat(line, "[Hostname unknown]\r\n");
if (d->connected) {
sprintf(line2, "^g%s^n", line);
strcpy(line, line2);
}
if ((d->connected && !d->character) || CAN_SEE(ch, d->character)) {
send_to_char(line, ch);
num_can_see++;
}
}
sprintf(line, "\r\n%d visible sockets connected.\r\n", num_can_see);
send_to_char(line, ch);
}
ACMD(do_glist)
{
struct descriptor_data *d;
struct follow_type *k;
char line[80];
int group = 0, found = 0, previous = 0;
for (d = descriptor_list; d; d = d->next)
if (d->character && !d->connected && !d->character->master) {
if (IS_AFFECTED(d->character, AFF_GROUP) && CAN_SEE(ch, d->character))
group = 1;
else group = 0;
for (k = d->character->followers; k && !group; k = k->next)
if (IS_AFFECTED(k->follower, AFF_GROUP) && CAN_SEE(ch, k->follower))
group = 1;
if (group) {
if (!found) {
sprintf(buf, "The following groups are currently running around Seattle:\r\n\r\n");
found = 1;
}
previous = 0;
if (d->character->player_specials->gname)
sprintf(buf, "%s%s:\r\n", buf, d->character->player_specials->gname);
else strcat(buf, "(unnamed):\r\n");
if (IS_AFFECTED(d->character, AFF_GROUP)) {
if (CAN_SEE(ch, d->character)) {
sprintf(line, " %s (leader)", GET_NAME(d->character));
previous = 1;
} else sprintf(line, " ");
} else sprintf(line, " ");
for (k = d->character->followers; k; k = k->next)
if (IS_AFFECTED(k->follower, AFF_GROUP) && CAN_SEE(ch, k->follower)) {
if (strlen(line) + strlen(GET_NAME(k->follower)) > 77) {
strcat(line, ",\r\n");
strcat(buf, line);
sprintf(line, " %s", GET_NAME(k->follower));
} else sprintf(line, "%s%s%s", line, previous ? ", " : "", GET_NAME(k->follower));
if (!previous)
previous = 1;
}
strcat(line, "\r\n");
strcat(buf, line);
}
}
if (!found)
sprintf(buf, "There are presently no groups running around Seattle.\r\n");
send_to_char(buf, ch);
}
void save_text(struct char_data *ch, int subcmd)
{
char buf[80];
switch (subcmd) {
case SCMD_MOTD: strcpy(buf, MOTD_FILE); break;
case SCMD_IMOTD: strcpy(buf, IMOTD_FILE); break;
default: cerr << "UNKNOWN SCMD" << endl; return;
}
ofstream file(buf);
if (!file) {
cerr << "Unable to open " << buf << " for writing (act.informative.cc)"
<< endl;
return;
}
switch (subcmd) {
case SCMD_MOTD: file << motd; file.close(); break;
case SCMD_IMOTD: file << imotd; file.close(); break;
default:
cerr << "Unknown SCMD in save_text in act.informative.cc" << endl;
break;
}
}
void edit_text(struct char_data *ch, int subcmd)
{
int i;
switch (subcmd) {
case SCMD_MOTD:
if (!IS_NPC(ch))
SET_BIT(PLR_FLAGS(ch), PLR_WRITING);
if (motd)
delete [] motd;
motd = new char[MAX_STRING_LENGTH];
motd = 0;
ch->desc->str = &motd;
ch->desc->max_str = MAX_STRING_LENGTH;
break;
case SCMD_IMOTD:
if (!IS_NPC(ch))
SET_BIT(PLR_FLAGS(ch), PLR_WRITING);
if (imotd)
delete [] imotd;
imotd = new char[MAX_STRING_LENGTH];
imotd = 0;
ch->desc->str = &imotd;
ch->desc->max_str = MAX_STRING_LENGTH;
break;
default:
cerr << "Unknown SCMD in edit_text, act.informative.cc" << endl;
}
return;
}
/* Generic page_string function for displaying text */
ACMD(do_gen_ps)
{
extern char circlemud_version[];
extern char awakemud_version[];
switch (subcmd) {
case SCMD_CREDITS:
page_string(ch->desc, credits, 0);
break;
case SCMD_NEWS:
page_string(ch->desc, news, 0);
break;
case SCMD_INFO:
page_string(ch->desc, info, 0);
break;
case SCMD_WIZLIST:
send_to_char(ch, wizlist);
break;
case SCMD_IMMLIST:
send_to_char(ch, immlist);
break;
case SCMD_HANDBOOK:
page_string(ch->desc, handbook, 0);
break;
case SCMD_POLICIES:
page_string(ch->desc, policies, 0);
break;
case SCMD_MOTD:
skip_spaces(&argument);
if (access_level(ch, LVL_OWNER)) {
if (!strcmp(argument, "edit"))
edit_text(ch, subcmd);
else if (!strcmp(argument, "save"))
save_text(ch, subcmd);
else page_string(ch->desc, motd, 0);
} else page_string(ch->desc, motd, 0);
break;
case SCMD_IMOTD:
skip_spaces(&argument);
if (access_level(ch, LVL_OWNER)) {
if (!strcmp(argument, "edit"))
edit_text(ch, subcmd);
else if (!strcmp(argument, "save"))
save_text(ch, subcmd);
else page_string(ch->desc, imotd, 0);
} else page_string(ch->desc, imotd, 0);
break;
case SCMD_CLEAR:
send_to_char("\033[H\033[J", ch);
break;
case SCMD_VERSION:
send_to_char(awakemud_version, ch);
break;
case SCMD_WHOAMI:
send_to_char(strcat(strcpy(buf, GET_NAME(ch)), "\r\n"), ch);
break;
default:
return;
break;
}
}
extern void nonsensical_reply( struct char_data *ch );
void perform_mortal_where(struct char_data * ch, char *arg)
{
/* DISABLED FOR MORTALS */
nonsensical_reply(ch);
return;
register struct char_data *i;
register struct descriptor_data *d;
if (!*arg) {
send_to_char("Players in your Zone\r\n--------------------\r\n", ch);
for (d = descriptor_list; d; d = d->next)
if (!d->connected) {
i = (d->original ? d->original : d->character);
if (i && i->in_room && ch && ch->in_room && CAN_SEE(ch, i) && (i->in_room != NOWHERE) &&
(world[ch->in_room].zone == world[i->in_room].zone) &&
(zone_table[ch->in_room].number != 6 && i->in_room == ch->in_room) ) {
sprintf(buf, "%-20s - %s\r\n", GET_NAME(i), world[i->in_room].name);
send_to_char(buf, ch);
}
}
} else { /* print only FIRST char, not all. */
for (i = character_list; i; i = i->next)
if (world[i->in_room].zone == world[ch->in_room].zone && CAN_SEE(ch, i) &&
(i->in_room != NOWHERE) && isname(arg, i->player.name)) {
sprintf(buf, "%-25s - %s\r\n", GET_NAME(i), world[i->in_room].name);
send_to_char(buf, ch);
return;
}
send_to_char("No-one around by that name.\r\n", ch);
}
}
void print_object_location(int num, struct obj_data *obj, struct char_data *ch,
int recur)
{
if (num > 0)
sprintf(buf + strlen(buf), "O%3d. %-25s - ", num, obj->short_description);
else
sprintf(buf + strlen(buf), "%33s", " - ");
if (obj->in_room > NOWHERE)
sprintf(buf + strlen(buf), "[%5d] %s\r\n", world[obj->in_room].number,
world[obj->in_room].name);
else if (obj->carried_by)
sprintf(buf + strlen(buf), "carried by %s\r\n", PERS(obj->carried_by, ch));
else if (obj->worn_by)
sprintf(buf + strlen(buf), "worn by %s\r\n", PERS(obj->worn_by, ch));
else if (obj->in_obj) {
sprintf(buf + strlen(buf), "inside %s%s\r\n",
obj->in_obj->short_description, (recur ? ", which is" : " "));
if (recur)
print_object_location(0, obj->in_obj, ch, recur);
} else
sprintf(buf + strlen(buf), "in an unknown location\r\n");
}
void perform_immort_where(struct char_data * ch, char *arg)
{
register struct char_data *i;
register struct obj_data *k;
struct descriptor_data *d;
int num = 0, found = 0;
int found2 = FALSE;
if (!*arg) {
strcpy(buf, "Players\r\n-------\r\n");
for (d = descriptor_list; d; d = d->next)
if (!d->connected) {
i = (d->original ? d->original : d->character);
if (i && CAN_SEE(ch, i) && (i->in_room != NOWHERE)) {
if (d->original)
sprintf(buf + strlen(buf), "%-20s - [%5d] %s (in %s)\r\n",
GET_NAME(i), world[d->character->in_room].number,
world[d->character->in_room].name, GET_NAME(d->character));
else
sprintf(buf + strlen(buf), "%-20s - [%5d] %s\r\n", GET_NAME(i),
world[i->in_room].number, world[i->in_room].name);
}
}
page_string(ch->desc, buf, 1);
} else {
*buf = '\0';
for (i = character_list; i; i = i->next)
if (CAN_SEE(ch, i) && i->in_room != NOWHERE &&
isname(arg, i->player.name)) {
found = 1;
sprintf(buf + strlen(buf), "M%3d. %-25s - [%5d] %s\r\n", ++num,
GET_NAME(i), world[i->in_room].number, world[i->in_room].name);
}
found2 = ObjList.PrintList(ch, arg);
if (!found && !found2)
send_to_char("Couldn't find any such thing.\r\n", ch);
else page_string(ch->desc, buf, 1);
}
}
ACMD(do_where)
{
one_argument(argument, arg);
/* DISABLED FOR MORTALS */
if (GET_REAL_LEVEL(ch) >= LVL_LEGEND)
perform_immort_where(ch, arg);
else perform_mortal_where(ch, arg);
}
ACMD(do_consider)
{
struct char_data *victim;
int diff;
one_argument(argument, buf);
if (!(victim = get_char_room_vis(ch, buf))) {
send_to_char("Consider killing who?\r\n", ch);
return;
}
if (victim == ch) {
send_to_char("Easy! Very easy indeed! \r\n", ch);
return;
}
if (!IS_NPC(victim) || !ok_damage_shopkeeper(ch, victim)) {
send_to_char("Would you like to borrow a cross and a shovel?\r\n", ch);
return;
}
diff = (GET_BALLISTIC(victim) - GET_BALLISTIC(ch));
diff += (GET_IMPACT(victim) - GET_IMPACT(ch));
diff += (GET_BOD(victim) - GET_BOD(ch));
diff += (GET_QUI(victim) - GET_QUI(ch));
diff += (GET_STR(victim) - GET_STR(ch));
diff += (GET_COMBAT(victim) - GET_COMBAT(ch));
if (GET_MAG(victim) >= 100) {
diff += (int)((GET_MAG(victim) - GET_MAG(ch)) / 100);
diff += GET_SKILL(victim, SKILL_SORCERY);
}
if (GET_MAG(ch) >= 100 && (IS_NPC(ch) || (GET_TRADITION(ch) == TRAD_HERMETIC ||
GET_TRADITION(ch) == TRAD_SHAMANIC)))
diff -= GET_SKILL(ch, SKILL_SORCERY);
if (GET_EQ(victim, WEAR_WIELD))
diff += GET_SKILL(victim, GET_OBJ_VAL(GET_EQ(victim, WEAR_WIELD), 4));
else diff += GET_SKILL(victim, SKILL_UNARMED_COMBAT);
if (GET_EQ(ch, WEAR_WIELD))
diff -= GET_SKILL(ch, GET_OBJ_VAL(GET_EQ(ch, WEAR_WIELD), 4));
else diff -= GET_SKILL(ch, SKILL_UNARMED_COMBAT);
if (diff <= -18)
send_to_char("Now where did that chicken go?\r\n", ch);
else if (diff <= -12)
send_to_char("You could do it with a needle!\r\n", ch);
else if (diff <= -6)
send_to_char("Easy.\r\n", ch);
else if (diff <= -3)
send_to_char("Fairly easy.\r\n", ch);
else if (diff == 0)
send_to_char("The perfect match!\r\n", ch);
else if (diff <= 3)
send_to_char("You would need some luck!\r\n", ch);
else if (diff <= 6)
send_to_char("You would need a lot of luck!\r\n", ch);
else if (diff <= 12)
send_to_char("You would need a lot of luck and great equipment!\r\n", ch);
else if (diff <= 18)
send_to_char("Do you feel lucky, punk?\r\n", ch);
else if (diff <= 30)
send_to_char("Are you mad!?\r\n", ch);
else send_to_char("You ARE mad!\r\n", ch);
}
ACMD(do_diagnose)
{
struct char_data *vict;
one_argument(argument, buf);
if (*buf) {
if (!(vict = get_char_room_vis(ch, buf))) {
send_to_char(NOPERSON, ch);
return;
} else diag_char_to_char(vict, ch);
} else {
if (FIGHTING(ch))
diag_char_to_char(FIGHTING(ch), ch);
else send_to_char("Diagnose who?\r\n", ch);
}
}
const char *ctypes[] = {
"off",
"sparse",
"normal",
"complete",
"\n"
};
ACMD(do_color)
{
int tp;
if (IS_NPC(ch)) {
send_to_char("You shouldn't tamper with color while in this form.\r\n", ch);
return;
}
one_argument(argument, arg);
if (!*arg) {
sprintf(buf, "Your current color level is %s.\r\n", ctypes[COLOR_LEV(ch)]);
send_to_char(buf, ch);
return;
}
if (((tp = search_block(arg, ctypes, FALSE)) == -1)) {
send_to_char("Usage: color { Off | Sparse | Normal | Complete }\r\n", ch);
return;
}
REMOVE_BIT(PRF_FLAGS(ch), PRF_COLOR_1 | PRF_COLOR_2);
SET_BIT(PRF_FLAGS(ch), (PRF_COLOR_1 * (tp & 1)) | (PRF_COLOR_2 * (tp & 2) >> 1));
sprintf(buf, "Your ^Rc^Bo^Gl^Co^Yr^n is now %s.\r\n", ctypes[tp]);
send_to_char(buf, ch);
}
struct sort_struct {
int sort_pos;
byte is_social;
} *cmd_sort_info = NULL;
int num_of_cmds;
void sort_commands(void)
{
int a, b, tmp;
ACMD(do_action);
num_of_cmds = 0;
/*
* first, count commands (num_of_commands is actually one greater than the
* number of commands; it inclues the '\n'.
*/
while (*cmd_info[num_of_cmds].command != '\n')
num_of_cmds++;
/* create data array */
cmd_sort_info = new sort_struct[num_of_cmds];
/* initialize it */
for (a = 1; a < num_of_cmds; a++) {
cmd_sort_info[a].sort_pos = a;
cmd_sort_info[a].is_social = (cmd_info[a].command_pointer == do_action);
}
/* the infernal special case */
cmd_sort_info[find_command("insult")].is_social = TRUE;
/* Sort. 'a' starts at 1, not 0, to remove 'RESERVED' */
for (a = 1; a < num_of_cmds - 1; a++)
for (b = a + 1; b < num_of_cmds; b++)
if (strcmp(cmd_info[cmd_sort_info[a].sort_pos].command,
cmd_info[cmd_sort_info[b].sort_pos].command) > 0) {
tmp = cmd_sort_info[a].sort_pos;
cmd_sort_info[a].sort_pos = cmd_sort_info[b].sort_pos;
cmd_sort_info[b].sort_pos = tmp;
}
}
ACMD(do_commands)
{
int no, i, cmd_num;
int socials = 0;
struct char_data *vict;
one_argument(argument, arg);
if (*arg) {
if (!(vict = get_char_vis(ch, arg)) || IS_NPC(vict)) {
send_to_char("Who is that?\r\n", ch);
return;
}
if (GET_REAL_LEVEL(ch) < GET_REAL_LEVEL(vict)) {
send_to_char("You can't see the commands of people above your level.\r\n", ch);
return;
}
} else vict = ch;
if (subcmd == SCMD_SOCIALS)
socials = 1;
sprintf(buf, "The following %s are available to %s:\r\n",
socials ? "socials" : "commands",
vict == ch ? "you" : GET_NAME(vict));
/* cmd_num starts at 1, not 0, to remove 'RESERVED' */
for (no = 1, cmd_num = 1; cmd_num < num_of_cmds; cmd_num++) {
i = cmd_sort_info[cmd_num].sort_pos;
if (cmd_info[i].minimum_level >= 0 &&
((!IS_NPC(vict) && GET_REAL_LEVEL(vict) >= cmd_info[i].minimum_level) ||
(IS_NPC(vict) && vict->desc->original && GET_REAL_LEVEL(vict->desc->original) >= cmd_info[i].minimum_level)) &&
(socials == cmd_sort_info[i].is_social)) {
sprintf(buf + strlen(buf), "%-11s", cmd_info[i].command);
if (!(no % 7))
strcat(buf, "\r\n");
no++;
}
}
strcat(buf, "\r\n");
send_to_char(buf, ch);
}
ACMD(do_scan)
{
struct char_data *list;
bool specific = FALSE, infra, lowlight, onethere, anythere = FALSE, done = FALSE;
int i = 0, j, was_in_room;
int dist = 3;
int temp;
argument = any_one_arg(argument, buf);
if (*buf) {
if (is_abbrev(buf, "south")) {
i = SCMD_SOUTH;
specific = TRUE;
} else for (;!specific && (i < (NUM_OF_DIRS - 1)); ++i) {
if (is_abbrev(buf, dirs[i]))
specific = TRUE;
}
}
infra = ((PRF_FLAGGED(ch, PRF_HOLYLIGHT) || PLR_FLAGGED(ch, AFF_INFRAVISION)) ? TRUE : FALSE);
lowlight = ((PRF_FLAGGED(ch, PRF_HOLYLIGHT) || PLR_FLAGGED(ch, AFF_LOW_LIGHT)) ? TRUE : FALSE);
if (!infra && IS_ASTRAL(ch))
infra = TRUE;
if (!specific && IS_PERSONA(ch)) {
send_to_char("You can't scan in all directions/\r\n", ch);
return;
}
if (!specific) {
for (i = 0; i < (NUM_OF_DIRS - 1); ++i) {
if (CAN_GO(ch, i)) {
onethere = FALSE;
if (!((!infra && IS_DARK(EXIT(ch, i)->to_room)) ||
((!infra || !lowlight) && IS_LOW(EXIT(ch, i)->to_room)))) {
strcpy(buf1, "");
for (list = world[EXIT(ch, i)->to_room].people; list; list = list->next_in_room) {
if (CAN_SEE(ch, list)) {
if (IS_NPC(list)) {
sprintf(buf1, "%s %s\r\n",buf1, list->player.short_descr);
CAP(buf1);
} else sprintf(buf1, "%s %s\r\n",buf1, list->player.name);
onethere = TRUE;
anythere = TRUE;
}
}
}
if (onethere) {
sprintf(buf2, "%s %s:\r\n%s\r\n", dirs[i], dist_name[0], buf1);
CAP(buf2);
send_to_char(buf2, ch);
}
}
}
if (!anythere) {
send_to_char("You don't seem to see anyone in the surrounding areas.\r\n", ch);
return;
}
} else {
--i;
dist = find_sight(ch);
if (CAN_GO(ch, i)) {
was_in_room = ch->in_room;
anythere = FALSE;
for (j = 0;!done && (j < dist); ++j) {
onethere = FALSE;
if (CAN_GO(ch, i)) {
strcpy(buf1, "");
for (list = world[EXIT(ch, i)->to_room].people; list; list = list->next_in_room)
if (CAN_SEE(ch, list)) {
if (IS_PERSONA(ch) && !(IS_IC(list) && (GET_RACE(list) <= CLASS_SCRAMBLE ||
is_blocker(list)))) {
temp = success_test(GET_INT(ch), GET_LEVEL(list));
if (temp >= find_node_required(list)) {
sprintf(buf1, "%s %s\r\n", buf1, list->player.short_descr);
CAP(buf1);
}
} else if (IS_NPC(list)) {
sprintf(buf1, "%s %s\r\n", buf1, list->player.short_descr);
CAP(buf1);
} else sprintf(buf1, "%s %s\r\n", buf1, list->player.name);
onethere = TRUE;
anythere = TRUE;
}
ch->in_room = EXIT(ch, i)->to_room;
if (onethere) {
sprintf(buf2, "%s %s:\r\n%s\r\n", dirs[i], dist_name[j], buf1);
CAP(buf2);
send_to_char(buf2, ch);
}
} else done = TRUE;
}
ch->in_room = was_in_room;
if (!anythere) {
send_to_char("You don't seem to see anyone in that direction.\r\n", ch);
return;
}
} else {
send_to_char("There is no exit in that direction.\r\n", ch);
return;
}
}
}