ds2.9a12/bin/
ds2.9a12/extra/
ds2.9a12/extra/crat/
ds2.9a12/extra/creremote/
ds2.9a12/extra/mingw/
ds2.9a12/extra/wolfpaw/
ds2.9a12/fluffos-2.14-ds13/
ds2.9a12/fluffos-2.14-ds13/Win32/
ds2.9a12/fluffos-2.14-ds13/compat/
ds2.9a12/fluffos-2.14-ds13/compat/simuls/
ds2.9a12/fluffos-2.14-ds13/include/
ds2.9a12/fluffos-2.14-ds13/testsuite/
ds2.9a12/fluffos-2.14-ds13/testsuite/clone/
ds2.9a12/fluffos-2.14-ds13/testsuite/command/
ds2.9a12/fluffos-2.14-ds13/testsuite/data/
ds2.9a12/fluffos-2.14-ds13/testsuite/etc/
ds2.9a12/fluffos-2.14-ds13/testsuite/include/
ds2.9a12/fluffos-2.14-ds13/testsuite/inherit/
ds2.9a12/fluffos-2.14-ds13/testsuite/inherit/master/
ds2.9a12/fluffos-2.14-ds13/testsuite/log/
ds2.9a12/fluffos-2.14-ds13/testsuite/single/
ds2.9a12/fluffos-2.14-ds13/testsuite/single/tests/compiler/
ds2.9a12/fluffos-2.14-ds13/testsuite/single/tests/efuns/
ds2.9a12/fluffos-2.14-ds13/testsuite/single/tests/operators/
ds2.9a12/fluffos-2.14-ds13/testsuite/u/
ds2.9a12/lib/cmds/admins/
ds2.9a12/lib/cmds/common/
ds2.9a12/lib/cmds/creators/include/
ds2.9a12/lib/daemon/services/
ds2.9a12/lib/daemon/tmp/
ds2.9a12/lib/doc/
ds2.9a12/lib/doc/bguide/
ds2.9a12/lib/doc/efun/all/
ds2.9a12/lib/doc/efun/arrays/
ds2.9a12/lib/doc/efun/buffers/
ds2.9a12/lib/doc/efun/compile/
ds2.9a12/lib/doc/efun/floats/
ds2.9a12/lib/doc/efun/functions/
ds2.9a12/lib/doc/efun/general/
ds2.9a12/lib/doc/efun/mixed/
ds2.9a12/lib/doc/efun/numbers/
ds2.9a12/lib/doc/efun/parsing/
ds2.9a12/lib/doc/hbook/
ds2.9a12/lib/doc/help/classes/
ds2.9a12/lib/doc/help/races/
ds2.9a12/lib/doc/lfun/
ds2.9a12/lib/doc/lfun/all/
ds2.9a12/lib/doc/lfun/lib/abilities/
ds2.9a12/lib/doc/lfun/lib/armor/
ds2.9a12/lib/doc/lfun/lib/bank/
ds2.9a12/lib/doc/lfun/lib/bot/
ds2.9a12/lib/doc/lfun/lib/clay/
ds2.9a12/lib/doc/lfun/lib/clean/
ds2.9a12/lib/doc/lfun/lib/clerk/
ds2.9a12/lib/doc/lfun/lib/client/
ds2.9a12/lib/doc/lfun/lib/combat/
ds2.9a12/lib/doc/lfun/lib/connect/
ds2.9a12/lib/doc/lfun/lib/container/
ds2.9a12/lib/doc/lfun/lib/corpse/
ds2.9a12/lib/doc/lfun/lib/creator/
ds2.9a12/lib/doc/lfun/lib/daemon/
ds2.9a12/lib/doc/lfun/lib/damage/
ds2.9a12/lib/doc/lfun/lib/deterioration/
ds2.9a12/lib/doc/lfun/lib/donate/
ds2.9a12/lib/doc/lfun/lib/door/
ds2.9a12/lib/doc/lfun/lib/equip/
ds2.9a12/lib/doc/lfun/lib/file/
ds2.9a12/lib/doc/lfun/lib/fish/
ds2.9a12/lib/doc/lfun/lib/fishing/
ds2.9a12/lib/doc/lfun/lib/flashlight/
ds2.9a12/lib/doc/lfun/lib/follow/
ds2.9a12/lib/doc/lfun/lib/ftp_client/
ds2.9a12/lib/doc/lfun/lib/ftp_data_connection/
ds2.9a12/lib/doc/lfun/lib/fuel/
ds2.9a12/lib/doc/lfun/lib/furnace/
ds2.9a12/lib/doc/lfun/lib/genetics/
ds2.9a12/lib/doc/lfun/lib/holder/
ds2.9a12/lib/doc/lfun/lib/id/
ds2.9a12/lib/doc/lfun/lib/interactive/
ds2.9a12/lib/doc/lfun/lib/lamp/
ds2.9a12/lib/doc/lfun/lib/leader/
ds2.9a12/lib/doc/lfun/lib/light/
ds2.9a12/lib/doc/lfun/lib/limb/
ds2.9a12/lib/doc/lfun/lib/living/
ds2.9a12/lib/doc/lfun/lib/load/
ds2.9a12/lib/doc/lfun/lib/look/
ds2.9a12/lib/doc/lfun/lib/manipulate/
ds2.9a12/lib/doc/lfun/lib/meal/
ds2.9a12/lib/doc/lfun/lib/messages/
ds2.9a12/lib/doc/lfun/lib/player/
ds2.9a12/lib/doc/lfun/lib/poison/
ds2.9a12/lib/doc/lfun/lib/position/
ds2.9a12/lib/doc/lfun/lib/post_office/
ds2.9a12/lib/doc/lfun/lib/potion/
ds2.9a12/lib/doc/lfun/lib/room/
ds2.9a12/lib/doc/lfun/lib/server/
ds2.9a12/lib/doc/lfun/lib/spell/
ds2.9a12/lib/doc/lfun/lib/torch/
ds2.9a12/lib/doc/lfun/lib/vendor/
ds2.9a12/lib/doc/lfun/lib/virt_sky/
ds2.9a12/lib/doc/lfun/lib/weapon/
ds2.9a12/lib/doc/lfun/lib/worn_storage/
ds2.9a12/lib/doc/lpc/basic/
ds2.9a12/lib/doc/lpc/concepts/
ds2.9a12/lib/doc/lpc/constructs/
ds2.9a12/lib/doc/lpc/etc/
ds2.9a12/lib/doc/lpc/intermediate/
ds2.9a12/lib/doc/lpc/types/
ds2.9a12/lib/doc/misc/
ds2.9a12/lib/doc/old/
ds2.9a12/lib/domains/
ds2.9a12/lib/domains/Praxis/adm/
ds2.9a12/lib/domains/Praxis/attic/
ds2.9a12/lib/domains/Praxis/cemetery/mon/
ds2.9a12/lib/domains/Praxis/data/
ds2.9a12/lib/domains/Praxis/death/
ds2.9a12/lib/domains/Praxis/mountains/
ds2.9a12/lib/domains/Praxis/obj/armour/
ds2.9a12/lib/domains/Praxis/obj/magic/
ds2.9a12/lib/domains/Praxis/obj/weapon/
ds2.9a12/lib/domains/Praxis/orc_valley/
ds2.9a12/lib/domains/Ylsrim/
ds2.9a12/lib/domains/Ylsrim/adm/
ds2.9a12/lib/domains/Ylsrim/armor/
ds2.9a12/lib/domains/Ylsrim/broken/
ds2.9a12/lib/domains/Ylsrim/fish/
ds2.9a12/lib/domains/Ylsrim/meal/
ds2.9a12/lib/domains/Ylsrim/npc/
ds2.9a12/lib/domains/Ylsrim/obj/
ds2.9a12/lib/domains/Ylsrim/virtual/
ds2.9a12/lib/domains/Ylsrim/weapon/
ds2.9a12/lib/domains/campus/adm/
ds2.9a12/lib/domains/campus/etc/
ds2.9a12/lib/domains/campus/meals/
ds2.9a12/lib/domains/campus/save/
ds2.9a12/lib/domains/campus/txt/ai/charles/
ds2.9a12/lib/domains/campus/txt/ai/charles/bak2/
ds2.9a12/lib/domains/campus/txt/ai/charles/bak2/bak1/
ds2.9a12/lib/domains/campus/txt/ai/charly/
ds2.9a12/lib/domains/campus/txt/ai/charly/bak/
ds2.9a12/lib/domains/campus/txt/jenny/
ds2.9a12/lib/domains/cave/doors/
ds2.9a12/lib/domains/cave/etc/
ds2.9a12/lib/domains/cave/meals/
ds2.9a12/lib/domains/cave/weap/
ds2.9a12/lib/domains/default/creator/
ds2.9a12/lib/domains/default/doors/
ds2.9a12/lib/domains/default/etc/
ds2.9a12/lib/domains/default/vehicles/
ds2.9a12/lib/domains/default/virtual/
ds2.9a12/lib/domains/default/weap/
ds2.9a12/lib/domains/town/txt/shame/
ds2.9a12/lib/domains/town/virtual/
ds2.9a12/lib/domains/town/virtual/bottom/
ds2.9a12/lib/domains/town/virtual/space/
ds2.9a12/lib/estates/
ds2.9a12/lib/ftp/
ds2.9a12/lib/lib/comp/
ds2.9a12/lib/lib/daemons/
ds2.9a12/lib/lib/daemons/include/
ds2.9a12/lib/lib/lvs/
ds2.9a12/lib/lib/user/
ds2.9a12/lib/lib/virtual/
ds2.9a12/lib/log/
ds2.9a12/lib/log/adm/
ds2.9a12/lib/log/archive/
ds2.9a12/lib/log/chan/
ds2.9a12/lib/log/errors/
ds2.9a12/lib/log/law/adm/
ds2.9a12/lib/log/law/email/
ds2.9a12/lib/log/law/names/
ds2.9a12/lib/log/law/sites-misc/
ds2.9a12/lib/log/law/sites-register/
ds2.9a12/lib/log/law/sites-tempban/
ds2.9a12/lib/log/law/sites-watch/
ds2.9a12/lib/log/open/
ds2.9a12/lib/log/reports/
ds2.9a12/lib/log/router/
ds2.9a12/lib/log/secure/
ds2.9a12/lib/log/watch/
ds2.9a12/lib/obj/book_source/
ds2.9a12/lib/obj/include/
ds2.9a12/lib/powers/prayers/
ds2.9a12/lib/powers/spells/
ds2.9a12/lib/realms/template/adm/
ds2.9a12/lib/realms/template/area/armor/
ds2.9a12/lib/realms/template/area/npc/
ds2.9a12/lib/realms/template/area/obj/
ds2.9a12/lib/realms/template/area/room/
ds2.9a12/lib/realms/template/area/weap/
ds2.9a12/lib/realms/template/bak/
ds2.9a12/lib/realms/template/cmds/
ds2.9a12/lib/save/kills/o/
ds2.9a12/lib/secure/cfg/classes/
ds2.9a12/lib/secure/cmds/builders/
ds2.9a12/lib/secure/cmds/creators/include/
ds2.9a12/lib/secure/cmds/players/
ds2.9a12/lib/secure/cmds/players/include/
ds2.9a12/lib/secure/daemon/imc2server/
ds2.9a12/lib/secure/daemon/include/
ds2.9a12/lib/secure/lib/
ds2.9a12/lib/secure/lib/include/
ds2.9a12/lib/secure/lib/net/include/
ds2.9a12/lib/secure/lib/std/
ds2.9a12/lib/secure/log/adm/
ds2.9a12/lib/secure/log/bak/
ds2.9a12/lib/secure/log/intermud/
ds2.9a12/lib/secure/log/network/
ds2.9a12/lib/secure/modules/
ds2.9a12/lib/secure/npc/
ds2.9a12/lib/secure/obj/include/
ds2.9a12/lib/secure/room/
ds2.9a12/lib/secure/save/
ds2.9a12/lib/secure/save/backup/
ds2.9a12/lib/secure/save/boards/
ds2.9a12/lib/secure/tmp/
ds2.9a12/lib/secure/upgrades/files/
ds2.9a12/lib/secure/verbs/creators/
ds2.9a12/lib/std/board/
ds2.9a12/lib/std/lib/
ds2.9a12/lib/tmp/
ds2.9a12/lib/verbs/admins/include/
ds2.9a12/lib/verbs/builders/
ds2.9a12/lib/verbs/common/
ds2.9a12/lib/verbs/common/include/
ds2.9a12/lib/verbs/creators/
ds2.9a12/lib/verbs/creators/include/
ds2.9a12/lib/verbs/rooms/
ds2.9a12/lib/verbs/rooms/include/
ds2.9a12/lib/www/client/
ds2.9a12/lib/www/errors/
ds2.9a12/lib/www/images/
ds2.9a12/lib/www/lpmuds/downloads_files/
ds2.9a12/lib/www/lpmuds/intermud_files/
ds2.9a12/lib/www/lpmuds/links_files/
ds2.9a12/win32/
/*    /secure/cmds/admins/addemote.c
 *    From the Dead Souls V Object Library
 *    A sane command for doing emote addition
 *    Created by Descartes of Borg 961208
 *    Version: @(#) addemote.c 1.2@(#)
 *    Last modified: 96/12/14
 */

#include <lib.h>
#include <daemons.h>
#include <message_class.h>

inherit LIB_DAEMON;

static void MainMenu();
static void EditErrorMessage(string emote);
static void ShowEmote(string emote);
static void AddEmote(string emote);
static void AddRule(string rule, string emote);

static private void validate() {
    if(!this_player()) return 0;
    if( !((int)master()->valid_apply(({ "ASSIST" }))) &&
      !member_group(this_player(), "EMOTES") )
        error("Illegal attempt to access addemote: "+get_stack()+" "+identify(previous_object(-1)));
}

static void EnterEmote(string emote, string array emotes) {
    int x = to_int(emote);
    validate();
    if( x < 1 || x > sizeof(emotes) ) {
        if( member_array(emote, emotes) == -1 ) {
            if( emote[0] == 'q' ) {
                return;
            }
            MainMenu();
            return;
        }
    }
    else {
        emote = emotes[x-1];
    }
    ShowEmote(emote);
}

static void EnterEditChoice(string str, string array rules, string emote) {
    int x = to_int(str);
    validate();
    if( x < 1 || x > sizeof(rules) ) {
        if( member_array(str, rules) == -1 ) {
            if( !str || str == "" ) {
                MainMenu();
                return;
            }
            if( str[0] == 'q' ) {
                return;
            }
            else if( str[0] == 'e' ) {
                EditErrorMessage(emote);
                return;
            }
            else if( str[0] == 'a' ) {
                this_player()->eventPrint("Enter verb rule: ", MSG_PROMPT);
                input_to((: AddRule :), emote);
                return;
            }
            else {
                ShowEmote(emote);
                return;
            }
        }
        AddRule(str, emote);
    }
    else {
        AddRule(rules[x-1], emote);
    }
}

static void AddAdverbs(string adv, string emote, string array rules,
  string array verbs, string msg) {
    string array adverbs;
    validate();
    if( !adv || adv == "" ) {
        adverbs = ({});
    }
    else {
        adverbs = map(explode(adv, ","), (: trim :));
    }
    foreach(string rule in rules) {
        SOUL_D->AddRule(emote, rule, ({ verbs, msg }), adverbs);
    }
    this_player()->eventPrint("Emote '" + emote + "' added.");
}

static void AddMessage(string msg, string emote, string array rules,
  string array verbs) {
    validate();
    if( !msg || msg == "" ) {
        this_player()->eventPrint("Which message? [q to quit] ", MSG_PROMPT);
        input_to((: AddMessage :), emote, rules, verbs);
        return;
    }
    if( lower_case(msg) == "q" ) {
        this_player()->eventPrint("Addition of rule aborted.");
        return;
    }
    this_player()->eventPrint("Enter adverbs: ", MSG_PROMPT);
    input_to((: AddAdverbs :), emote, rules, verbs, msg);
}

static void AddVerbs(string list, string emote, string array rules) {
    string array verbs = map(explode(list, ","), (: trim :));
    validate();

    this_player()->eventPrint("Enter message: ", MSG_PROMPT);
    input_to((: AddMessage :), emote, rules, verbs);
}

static void AddRule(string rule, string emote) {
    string array rules = map(explode(rule, ","), (: trim :));
    validate();

    if( !sizeof(rules) ) {
        rules = ({ "" });
    }
    this_player()->eventPrint("Enter the verbs: ", MSG_PROMPT);
    input_to((: AddVerbs :), emote, rules);
}

static void AddErrorMessage(string msg, string emote) {
    validate();
    if( !msg || msg == "" ) {
        this_player()->eventPrint("Which message? [q to quit] ", MSG_PROMPT);
        input_to((: AddErrorMessage :), emote);
        return;
    }
    if( !emote || emote == "" ) {
        this_player()->eventPrint("Which emote? [q to quit] ", MSG_PROMPT);
        input_to((: AddEmote :));
        return;
    }	
    emote = lower_case(emote);
    if( lower_case(msg) == "q" ) {
        this_player()->eventPrint("Addition of emote aborted.");
        return;
    }
    SOUL_D->AddVerb(emote, msg);
    this_player()->eventPrint("Enter a parser rule for " + emote + ": ",
      MSG_PROMPT);
    input_to((: AddRule :), emote);
}

static void AddEmote(string emote) {
    validate();
    if( !emote || emote == "" ) {
        this_player()->eventPrint("Which emote? [q to quit] ", MSG_PROMPT);
        input_to((: AddEmote :));
        return;
    }
    emote = lower_case(emote);
    if( emote == "q" ) {
        this_player()->eventPrint("Addition of emote aborted.");
        return;
    }
    this_player()->eventPrint("Enter error message: ", MSG_PROMPT);
    input_to((: AddErrorMessage :), emote);
}

static void MainMenu() {
    string array emotes = SOUL_D->GetEmotes();
    string array display = allocate(sizeof(emotes));
    int array screen = this_player()->GetScreen() || ({ 80, 25 });
    string tmp;
    int i;
    validate();

    tmp = center("Dead Souls V Emote Editor", screen[0]) + "\n";
    for(i=0; i<sizeof(display); i++) {
        display[i] = "[" + (i+1) + "] " + emotes[i];
    }
    tmp += format_page(display, screen[0]/17) + "\n";
    this_player()->eventPrint(tmp, MSG_SYSTEM);
    this_player()->eventPrint("Enter an emote or 'q' to quit: ", MSG_PROMPT);
    input_to((: EnterEmote :), emotes);
}

static void EditErrorMessage(string emote) {
    validate();
    this_player()->eventPrint("Enter new error message: ", MSG_PROMPT);
    input_to(function(string str, string emote) {
          if( str && str != "" ) {
              SOUL_D->SetErrorMessage(emote, str);
          }
          ShowEmote(emote);
      }, emote);
}

static void ShowEmote(string emote) {
    string err = SOUL_D->GetErrorMessage(emote);
    mapping rules = SOUL_D->GetRules(emote);
    int array screen = this_player()->GetScreen() || ({ 80, 25 });
    string tmp = center("Dead Souls V Emote Editor", screen[0]) + "\n\n";
    string tmp2 = "";
    string array rule_array = allocate(sizeof(rules));
    int i = 0;
    validate();

    tmp += "%^GREEN%^Emote%^RESET%^: " + emote + "\n";
    tmp += "%^GREEN%^Error Message%^RESET%^: " + err + "\n";
    tmp += "%^GREEN%^Rules%^RESET%^:\n";
    foreach(string rule, mixed array data in rules) {
        rule_array[i] = rule;
        tmp += "[" + (i+1) + "] \"" + rule + "\": " + data[1][1] + "\n";
        tmp += "  Adverbs: " + wrap(item_list(data[0]), screen[0]) + "\n";
        i++;
    }
    //Following fix courtesy of Alecksy
    this_player()->eventPage(explode(tmp,"\n"), MSG_SYSTEM);
    tmp2 = "Enter rule to edit, 'a' to add rule, 'e' to edit error msg, or 'q' to quit: ";
    this_player()->eventPrint(tmp2,MSG_PROMPT);
    input_to( (: EnterEditChoice :), rule_array, emote );
}

mixed cmd(string args) {
    if( !((int)master()->valid_apply(({ "ASSIST" }))) &&
      !member_group(this_player(), "EMOTES") ){
        write("You are not admin, nor a member of the EMOTES group.");
        return 1;
    }

    if( !args || args == "" ) {
        this_player()->eventPrint("Enter emote name: ", MSG_PROMPT);
        input_to((: AddEmote :));
    }
    else if( args[0] == '-' ) {
        if( args == "-edit" ) {
            MainMenu();
        }
        else if( args == "-add") {
            this_player()->eventPrint("Enter emote name: ", MSG_PROMPT);
            input_to((: AddEmote :));
        }
        else {
            MainMenu();
        }
    }
    else {
        if( member_array(args, SOUL_D->GetEmotes()) == -1 ) {
            AddEmote(args);
        }
        else {
            ShowEmote(args);
        }
    }
    return 1;
}

string GetHelp(string str) {
    return ("Syntax: <addemote>\n"
      "        <addemote EMOTE>\n"
      "        <addemote -edit>\n"
      "        <addemote -add>\n\n"
      "You must be admin or member of the EMOTES group to use this command.\n\n"
      "Used to add and edit emotes in the soul daemon using complex "
      "rules and the Dead Souls V messaging system.  In order to add "
      "a new emote using this command, you need to know the following "
      "information:\n"
      "\t* Verb parse rule\n"
      "\t* Verbs to be conjugated in the message\n"
      "\t* The messaging system generic format for the message\n"
      "\t* Any adverbs supported specially for the message\n\n"
      "The verb parse rule is a set of tokens governing how the "
      "command should be entered. The only tokens supported by the "
      "soul are LIV (for one living thing), LVS (for one to many living "
      "things), and STR (for any arbitrary string).  In addition, the "
      "rule can contains prepositions like to, at, on, about, etc.  "
      "For example, to allow a player to do <smile at descartes>, you "
      "need the parse rule <at LIV> or <at LVS>.  <smile oddly at "
      "descartes> would be <STR at LIV> or <STR at LVS>.\n"
      "In general, you should allow players to enter in commands using "
      "correct English and a syntax without prepositions.  For "
      "example, since we have <at LVS>, we should also allow "
      "<LVS>.  To support identical rules like this, when the "
      "<addemote> command asks for a parser rule, you can enter in "
      "multiple identical rules on the same line, separated by "
      "commas:\n"
      "Enter parser rule: at LVS,LVS\n\n"
      "The next step is defining which verbs need conjugating in your "
      "message for the emote.  With the smile emote, the only verb is "
      "\"smile\".  However, for more complex emotes, you may have "
      "multiple verbs which need conjugating.  Just enter them as a "
      "comma separated list.  For example, if you have an emote that "
      "should print the message \"Descartes rants and raves.\", then "
      "you will need to enter the verbs rant and rave:\n"
      "Enter verbs: rant,rave\n\n"
      "The next step is specifying the message that gets shown.  Your "
      "message uses place holders, also called tokens, to stand in "
      "for bits of the message that change depending on point of "
      "view.  In the rant and rave example, Descartes would see:\n"
      "You rant and rave.\n"
      "Everyone else sees:\n"
      "Descartes rants and raves.\n"
      "The only thing that stays the same is the word \"and\".  You "
      "need tokens to stand for the rest.  A full list of tokens is "
      "specified in <help messaging> and they all begin with a $ sign.  "
      "One extremely important thing to remember is that you need "
      "the exact same number of $agent_verb or $target_verb tokens in "
      "your message as the number of verbs you specified for "
      "conjugation.  In the rant and rave example, I need two verb "
      "tokens to match up with my two verbs I am conjugating.  They "
      "will be handled in the order they appear.  In other words, the "
      "rant verb will match to the first verb token, and the rave "
      "verb will match to the second verb token.  Verb tokens count "
      "as any combination of $agent_verb and $target_verb:\n"
      "Enter message: $agent_name $agent_verb and $agent_verb.\n\n"
      "The last thing you need to enter is a list of adverbs.  "
      "As with other lists, this list is comma separated.  And as with "
      "other bits of this system, it has a little complexity to it.  "
      "If you do not enter anything, then no adverbs are used for this "
      "rule.  In fact, you must specify a STR token in the rule for "
      "adverbs to be relevant.  If you do specify an STR rule, you "
      "should specify something on the adverb line.  Any adverbs you "
      "enter are considered special adverbs just for this rule.  If "
      "you wish the general list of adverbs to be available as well, "
      "you can enter a - as one of the adverbs.  If you wish the "
      "player to be able to add anything that comes to mind, enter "
      "a *:\n"
      "Enter adverbs: -");
}