/* Do_Who * Created by Rhyaehar (Rhyaehar@planiamud.org) */ /* At the top of your act.informative.c */ /* Below */ extern const char *class_abbrevs[]; /* Add */ extern const char *pc_class_types[]; /* Replace your exisiting do_who with the following */ #define WHO_FORMAT \ "format: who [minlev[-maxlev]] [-n name] [-c classlist] [-s] [-o] [-q] [-r] [-z]\r\n" ACMD(do_who) { struct descriptor_data *d; struct char_data *tch; char buf[MAX_STRING_LENGTH], buf1[MAX_STRING_LENGTH], arg[MAX_STRING_LENGTH]; char name_search[MAX_NAME_LENGTH+1]; char mode; int low = 0, high = LVL_IMPL, showclass = 0; bool who_room = FALSE, who_zone = FALSE, who_quest = 0; bool outlaws = FALSE, noimm = FALSE, nomort = FALSE; int top = 115; // This MUST be your highest level int gods = 0, heroes = 0, morts = 0; int icheck = 0, mcheck = 0; size_t i; const char *godlevs[LVL_IMPL - (LVL_IMMORT-1)] = { "Immortal", "Seraph", "Angel", "Demi God", "God", "Greater God", "Creator", "Deity", "Supreme" }; const char *mhero[105 - 100] = { "Hero", "Lord", "Baron", "Duke", "Prince", "King", }; const char *fhero[105 - 100] = { "Hero", "Lady", "Baroness", "Dutchess", "Princess", "Queen", }; skip_spaces(&argument); strcpy(buf, argument); name_search[0] = '\0'; while (*buf) { half_chop(buf, arg, buf1); if (isdigit(*arg)) { sscanf(arg, "%d-%d", &low, &high); strcpy(buf, buf1); } else if (*arg == '-') { mode = *(arg + 1); /* just in case; we destroy arg in the switch */ switch (mode) { case 'o': outlaws = TRUE; strcpy(buf, buf1); break; case 'z': who_zone = TRUE; strcpy(buf, buf1); break; case 'q': who_quest = TRUE; strcpy(buf, buf1); break; case 'l': half_chop(buf1, arg, buf); sscanf(arg, "%d-%d", &low, &high); break; case 'n': half_chop(buf1, name_search, buf); break; case 'r': who_room = TRUE; strcpy(buf, buf1); break; case 'c': half_chop(buf1, arg, buf); for (i = 0; i < strlen(arg); i++) showclass |= find_class_bitvector(arg); break; case 'i': nomort = TRUE; strcpy(buf, buf1); break; case 'm': noimm = TRUE; strcpy(buf, buf1); break; default: send_to_char(ch, WHO_FORMAT); return; break; } /* end of switch */ } else { /* endif */ send_to_char(ch, WHO_FORMAT); return; } } /* end while (parser) */ for (; top > 0; top--) { /* Sorting by levels */ for (d = descriptor_list; d; d = d->next) { if (d->connected) continue; if (GET_LEVEL(d->character) != top) /* end of sorting by levels */ continue; if (d->original) tch = d->original; else if (!(tch = d->character)) continue; if (!CAN_SEE(ch, tch)) continue; if (GET_LEVEL(tch) < low || GET_LEVEL(tch) > high) continue; if ((noimm && GET_LEVEL(tch) >= LVL_IMMORT) || (nomort && GET_LEVEL(tch) < LVL_IMMORT)) continue; if (*name_search && str_cmp(GET_NAME(tch), name_search) && !strstr(GET_TITLE(tch), name_search)) continue; if (outlaws && !PLR_FLAGGED(tch, PLR_KILLER) && !PLR_FLAGGED(tch, PLR_THIEF)) continue; if (who_quest && !PRF_FLAGGED(tch, PRF_QUEST)) continue; if (who_zone && world[ch->in_room].zone != world[tch->in_room].zone) continue; if (who_room && (tch->in_room != ch->in_room)) continue; if (showclass && !(showclass & (1 << GET_CLASS(tch)))) continue; if ((GET_LEVEL(tch) == top) && (GET_LEVEL(tch) >= LVL_IMMORT)) { if (icheck == 0) { send_to_char(ch, " Listing of the Gods\r\n"); send_to_char(ch, "-=-=-=-=-=-=-=-=-=-=-\r\n"); icheck = 1; } } else { if (mcheck == 0) { send_to_char(ch, "\r\n"); send_to_char(ch, " List of the Mortals\r\n"); send_to_char(ch, "-=-=-=-=-=-=-=-=-=-=-\r\n"); mcheck = 1; } } if (GET_LEVEL(tch) >= LVL_IMMORT) { send_to_char(ch, "%s[%-11s] %s %s", CCYEL(ch, C_SPR), godlevs[GET_LEVEL(tch)-(LVL_IMMORT - 1)], GET_NAME(tch), GET_TITLE(tch)); gods++; } else if (GET_LEVEL(tch) >= (LVL_IMMORT - 1)) { send_to_char(ch, "%s[%-11s] %s %s", CCYEL(ch, C_SPR), (SEX_FEMALE(ch) ? fhero[GET_LEVEL(tch)-100] : mhero[GET_LEVEL(tch)-100]), GET_NAME(tch), GET_TITLE(tch)); heroes++; } else { send_to_char(ch, "[%-11s] %s %s", pc_class_types[(int) GET_CLASS(tch)], GET_NAME(tch), GET_TITLE(tch)); morts++; } *buf = '\0'; if (GET_INVIS_LEV(tch)) send_to_char(ch, " (i%d)", GET_INVIS_LEV(tch)); else if (IS_AFFECTED(tch, AFF_INVISIBLE)) send_to_char(ch, " (invis)"); if (PLR_FLAGGED(tch, PLR_MAILING)) send_to_char(ch, " (mailing)"); else if (PLR_FLAGGED(tch, PLR_WRITING)) send_to_char(ch, " (writing)"); if (PRF_FLAGGED(tch, PRF_DEAF)) send_to_char(ch, " (deaf)"); if (PRF_FLAGGED(tch, PRF_NOTELL)) send_to_char(ch, " (notell)"); if (PRF_FLAGGED(tch, PRF_QUEST)) send_to_char(ch, " (quest)"); if (PLR_FLAGGED(tch, PLR_THIEF)) send_to_char(ch, " (THIEF)"); if (PLR_FLAGGED(tch, PLR_KILLER)) send_to_char(ch, " (KILLER)"); // if (PRF_FLAGGED(tch, PRF_AFK)) // send_to_char(ch, " (AFK)"); send_to_char(ch, "%s\r\n", CCNRM(ch, C_SPR)); } /* end of for */ } send_to_char(ch, "\r\n"); /* Display number of immortals */ if (gods != 0) send_to_char(ch, "There %s %d visible immortal%s.\r\n", (gods == 1 ? "is" : "are"), gods, (gods == 1 ? "" : "s")); else send_to_char(ch, "There are no visible immortals.\r\n"); /* Display number of mortals */ if ((morts !=0) || (heroes != 0)) send_to_char(ch, "There %s %d visible mortal%s, of which %d %s Hero%s.\r\n", (morts == 1 ? "is" : "are"), morts, (morts == 1 ? "" : "s"), heroes, (heroes == 1 ? "is" : "are"), (heroes == 1 ? "" : "es")); else send_to_char(ch, "There are no visible mortals.\r\n"); send_to_char(ch, "There is a total of %d visible players.\r\n", gods+heroes+morts); }