kippcore.gz
snippets · 54.1 KB · 2010-03-30
KippCore: a ColdC core text dump (gzipped).
Download « Back to the snippets list
object #1;
var #1 name = "Root Class";
var #1 commands = [];
var #1 plural = 0;
public method .set_user() {
set_user();
};
public method .tell() {
arg @args;
};
public method .notify() {
arg @args;
};
public method .title() {
arg who, options, @amount;
var rname;
// This handles all text cosmetics, including invisibility.
// It should be easy to add Pueblo/RIP/html codes.
if (who == this()) {
return "you";
} else if (.is_visible_to(who)) {
if (amount && ((amount[1]) > 1))
rname = (((amount[1]).english_number()) + " ") + ((.plural()) || ((.name()).plural()));
else
rname = (((.name())[1]) in "aeiou") ? "an " + (.name()) : ("a " + (.name()));
return rname;
} else {
return "something";
}
};
public method .commands() {
arg @args;
var x, ocmd, y;
if ((listlen(args) == 1) && (type(args[1]) == 'list)) {
commands = (ocmd = []);
for x in (.parents())
ocmd += x.commands();
for y in (args[1]) {
if (!(y in ocmd))
commands = setadd(commands, y);
}
} else if (args) {
throw(~numargs, "Called with too many or invalid arguments.");
}
ocmd = commands || [];
for x in (.parents())
ocmd += x.commands();
return ocmd;
};
public method .name() {
arg @args;
if ((listlen(args) == 1) && (type(args[1]) == 'string))
name = args[1];
else if (args)
throw(~numargs, "Called with too many or invalid arguments.");
else
return name || "(Unnamed)";
};
public method .add_var() {
arg @args;
return (> add_var(@args) <);
};
public method .clear_var() {
arg @args;
return (> clear_var(@args) <);
};
public method .del_var() {
arg @args;
return (> del_var(@args) <);
};
public method .get_var() {
arg @args;
return (> get_var(@args) <);
};
public method .set_var() {
arg @args;
return (> set_var(@args) <);
};
public method .variables() {
arg @args;
return (> variables(@args) <);
};
public method .add_method() {
arg @args;
return (> add_method(@args) <);
};
public method .list_method() {
arg @args;
return (> list_method(@args) <);
};
public method .decompile() {
arg @args;
return (> list_method(@args) <);
};
public method .del_method() {
arg @args;
return (> del_method(@args) <);
};
public method .find_method() {
arg @args;
return (> find_method(@args) <);
};
public method .find_next_method() {
arg @args;
return (> find_next_method(@args) <);
};
public method .method_bytecode() {
arg @args;
return (> method_bytecode(@args) <);
};
public method .method_access() {
arg @args;
return (> method_access(@args) <);
};
public method .method_info() {
arg @args;
return (> method_info(@args) <);
};
public method .method_flags() {
arg @args;
return (> method_flags(@args) <);
};
public method .methods() {
arg @args;
return (> methods(@args) <);
};
public method .rename_method() {
arg @args;
return (> rename_method(@args) <);
};
public method .set_method_access() {
arg @args;
return (> set_method_access(@args) <);
};
public method .set_method_flags() {
arg @args;
return (> set_method_flags(@args) <);
};
public method .ancestors() {
arg @args;
return (> ancestors(@args) <);
};
public method .chparents() {
arg @args;
return (> chparents(@args) <);
};
public method .create() {
var what, thing, n;
what = (> create([this()]) <);
thing = tostr((what.parents())[1]).subrange(2);
n = 1;
while (!(| what.set_objname(tosym((thing + "_") + n)) |))
n = n + 1;
return what;
};
public method .data() {
arg @args;
return (> data(@args) <);
};
public method .del_objname() {
arg @args;
return (> del_objname(@args) <);
};
public method .destroy() {
arg @args;
return (> destroy(@args) <);
};
public method .children() {
arg @args;
return (> children(@args) <);
};
public method .has_ancestor() {
arg @args;
return (> has_ancestor(@args) <);
};
public method .lookup() {
arg @args;
return (> lookup(@args) <);
};
public method .objname() {
arg @args;
return (> objname(@args) <);
};
public method .objnum() {
arg @args;
return (> objnum(@args) <);
};
public method .parents() {
arg @args;
return (> parents(@args) <);
};
public method .set_objname() {
arg @args;
return (> set_objname(@args) <);
};
public method .print() {
arg @args;
};
public method .is_this() {
arg str;
var x, nm;
nm = .title($sys.user(), []);
for x in (nm.explode()) {
if ((str in x) == 1)
return 1;
}
return ((str in nm) == 1) || (((str in ((.plural()) || ((.name()).plural()))) == 1) || ((str in (.name())) == 1));
};
public method .is_visible_to() {
arg @args;
return 1;
};
public method .plural() {
arg @args;
if (args)
plural = args[1];
return plural;
};
public method .all_children() {
var kids, x;
kids = [];
for x in (.children())
kids += [@x.all_children(), x];
return kids;
};
object #0: #1;
var #1 name = "System Object";
var #0 tasks = [];
var #0 users = #[[115, #16]];
driver method .startup() {
arg args;
var x, y;
set_heartbeat(1);
catch any {
for x in ($connection.children())
x.destroy();
}
bind_function('set_user, $sys);
bind_function('user, $sys);
// set_user() and user() have been replaced by $sys.*
dblog("Database started... Heartbeat set to 60, initializing $login...");
for x in (args) {
if ((y = x.match_pattern("-port*")))
$login.port(toint(y[1]));
}
$login.startup();
};
driver method .signal() {
arg @args;
};
public method .next_objnum(): native;
public method .status(): native;
public method .version(): native;
public method .user() {
return (| users[task_id()] |) || 0;
};
public method .set_user() {
arg @args;
if (!tasks())
users = #[];
if (args)
users = users.add(task_id(), args[1]);
else
users = users.add(task_id(), sender());
};
public method .heartbeat() {
var x;
for x in (tasks) {
if ((x[1]) <= time()) {
tasks = tasks.setremove(x);
(| resume(x[2]) |);
}
}
};
public method .suspend() {
arg amount;
tasks = (tasks || []).setadd([time() + amount, task_id()]);
return suspend();
};
public method .shutdown() {
var x;
for x in ($connection.children())
x.destroy();
shutdown();
};
public method .core_objects() {
return [$connection, $login, $room, $sys, $libraries, @$libraries.children(), $zone, $object, $socials, $help, $distrib_conn, $distrib, $root, $player, $item, $frob, @$frob.all_children(), $reaper];
};
new object #2: #1;
name $libraries #2;
new object #3: #2;
name $string #3;
var #3 cache = #[["Exits: {k/south}south{ek}, {k/east}east{ek}, {k/north}north{ek} and {k/west}west{ek}", ["Exits: ", ['link, "south"], "south", ['endlink], ", ", ['link, "east"], "east", ['endlink], ", ", ['link, "north"], "north", ['endlink], " and ", ['link, "west"], "west", ['endlink]]], ["{s} {v/is/are} here.", [['value, 1, 'english_list], " ", ['verb, 1, "is", "are"], " here."]], ["{o} {v/waves}.", [['obj, "you", 1, 'title], " ", ['verb, 1, "waves", "wave"], "."]], ["{o} {v/giggles}.", [['obj, "you", 1, 'title], " ", ['verb, 1, "giggles", "giggle"], "."]], ["{l/1/14} {l/2/15} {l/3/26} {l/4/7} {s/5}", [['left, 1, 14, " "], " ", ['left, 2, 15, " "], " ", ['left, 3, 26, " "], " ", ['left, 4, 7, " "], " ", ['value, 5, 'english_list]]], ["{o} {v/nods}.", [['obj, "you", 1, 'title], " ", ['verb, 1, "nods", "nod"], "."]], ["{q/pueblo}Exits: {k/south}south{ek}, {k/east}east{ek}, {k/north}north{ek} and {k/west}west{ek}", [['required, 'pueblo], "Exits: ", ['link, "south"], "south", ['endlink], ", ", ['link, "east"], "east", ['endlink], ", ", ['link, "north"], "north", ['endlink], " and ", ['link, "west"], "west", ['endlink]]], ["{q/pueblo}{s} {v/is/are} here.", [['required, 'pueblo], ['value, 1, 'english_list], " ", ['verb, 1, "is", "are"], " here."]], ["{o} {v/looks/look/2} {s/3} you{s/5}", [['obj, "you", 1, 'title], " ", ['verb, 2, "looks", "look"], " ", ['value, 3, 'english_list], " you", ['value, 5, 'english_list]]], ["{o} {v/looks/look/2} {s/3} {v/he/you/1}.{s/5}", [['obj, "you", 1, 'title], " ", ['verb, 2, "looks", "look"], " ", ['value, 3, 'english_list], " ", ['verb, 1, "he", "you"], ".", ['value, 5, 'english_list]]], ["{o} {v/shakes/shake/2} {o/3/you/po/1} {s/4} {s/5}{s/6}", [['obj, "you", 1, 'title], " ", ['verb, 2, "shakes", "shake"], " ", ['obj, "you", 3, 'po], " ", ['value, 4, 'english_list], " ", ['value, 5, 'english_list], ['value, 6, 'english_list]]], ["{o} {v/frowns/frown/2}, {s/3}{s/4}", [['obj, "you", 1, 'title], " ", ['verb, 2, "frowns", "frown"], ", ", ['value, 3, 'english_list], ['value, 4, 'english_list]]], ["{o} {v/kisses/kiss/2} you {s/4} {s/5}{s/6}", [['obj, "you", 1, 'title], " ", ['verb, 2, "kisses", "kiss"], " you ", ['value, 4, 'english_list], " ", ['value, 5, 'english_list], ['value, 6, 'english_list]]], ["{o} {v/kisses/kiss/2} {o/3/you/name} {s/4} {s/5}{s/6}", [['obj, "you", 1, 'title], " ", ['verb, 2, "kisses", "kiss"], " ", ['obj, "you", 3, 'name], " ", ['value, 4, 'english_list], " ", ['value, 5, 'english_list], ['value, 6, 'english_list]]], ["{o} {v/rolls/roll/2} {o/3/you/po/1} {s/4} {s/5}{s/6}", [['obj, "you", 1, 'title], " ", ['verb, 2, "rolls", "roll"], " ", ['obj, "you", 3, 'po], " ", ['value, 4, 'english_list], " ", ['value, 5, 'english_list], ['value, 6, 'english_list]]], ["{o} {v/kisses/kiss/2} {o/3/you/name} {s/4}{s/5}", [['obj, "you", 1, 'title], " ", ['verb, 2, "kisses", "kiss"], " ", ['obj, "you", 3, 'name], " ", ['value, 4, 'english_list], ['value, 5, 'english_list]]], ["{o} {v/smiles}.", [['obj, "you", 1, 'title], " ", ['verb, 1, "smiles", "smile"], "."]], ["{o} {v/kisses/kiss/2} {s/3} {s/4}{s/5}", [['obj, "you", 1, 'title], " ", ['verb, 2, "kisses", "kiss"], " ", ['value, 3, 'english_list], " ", ['value, 4, 'english_list], ['value, 5, 'english_list]]], ["{o} {v/says/say}, \"{s/2}\"", [['obj, "you", 1, 'title], " ", ['verb, 1, "says", "say"], ", \"", ['value, 2, 'english_list], "\""]], ["{o} {v/waves} at {o/2}.", [['obj, "you", 1, 'title], " ", ['verb, 1, "waves", "wave"], " at ", ['obj, "you", 2, 'title], "."]]];
public method .match_object() {
arg str, @who;
if (who)
who = who[1];
else
who = $sys.user();
if (str == "me")
return who;
else if (str == "here")
return who.location();
return ((who.location()) && ((who.location()).match_object(str))) || (who.match_object(str));
};
public method .capitalize(): native;
public method .parse_text() {
arg line, reciever, options, @info;
return (line.compile_text()).parse_text(reciever, options, @info);
};
public method .compile_text() {
arg text;
var i, out, j, ot;
// {code,arg,arg,arg etc}
// object, obj, o -- Index [1], WhatYouSee [you], WhatMethod [title]
// verb, v -- SingularVerb, PluralVerb [auto-plural], Index [1]
// brace
// value, s -- Index [1], WhatMethod [english_list]
// required, q -- RequiredFlag
// !required, !q -- NotRequiredFlag
// left, l -- Index, Width, Spacer [ ]
// right, r -- Index, Width, Spacer [ ]
// center, c -- Index, Width, Spacer [ ]
// link, k -- Command
// endlink, ek
if ((i = (| cache[text] |))) {
// Re-place entry at end of cache.
cache = (cache.dict_del(text)).dict_add(text, i);
return i;
}
ot = text;
out = [];
while ((i = text.capture("{", "}", "/"))) {
text = i[listlen(i)];
out = [@out, i[1]];
j = i.subrange(2, listlen(i) - 2);
switch (j[1]) {
case "object", "obj", "o":
out = [@out, ['obj, [@j, "you", "you"][3], toint([@j, 1][2]), tosym([@j, "title", "title", "title"][4])]];
case "verb", "v":
out = [@out, ['verb, (listlen(j) > 3) ? toint(j[4]) : 1, j[2], (listlen(j) > 2) ? j[3] : ((j[2]).singular())]];
case "brace":
out = [@out, "{"];
case "value", "s":
out = [@out, ['value, (listlen(j) > 1) ? toint(j[2]) : 1, tosym([@j, "english_list", "english_list"][3])]];
case "!required", "!q":
out = [@out, ['notreq, tosym(j[2])]];
case "left", "l":
// {left|right|center/infonum/width[/seperator]}
out = [@out, ['left, toint(j[2]), toint(j[3]), [@j, " ", " "][4]]];
case "right", "r":
out = [@out, ['right, toint(j[2]), toint(j[3]), [@j, " ", " "][4]]];
case "center", "c":
out = [@out, ['center, toint(j[2]), toint(j[3]), [@j, " ", " "][4]]];
case "required", "q":
out = [@out, ['required, tosym(j[2])]];
case "link", "k":
out = [@out, ['link, j[2]]];
case "endlink", "ek":
out = [@out, ['endlink]];
}
}
out = [@out, text];
while ((j = setremove(out, "")) != out)
out = j;
// If it's worthy of caching, delete oldest cache entry and enter new one.
if ((out.length()) > 3)
cache = (cache.dict_del((cache.keys())[1])).dict_add(ot, out);
return out;
};
public method .make() {
arg str, amount;
var res, x;
res = "";
for x in [1 .. amount]
res = res + str;
return res;
};
public method .left() {
arg str, width, @sep;
if ('pueblo in sep)
width = width + (str.pueblo_code_widths());
sep = [@sep, " "][1];
return (str + (sep.make(width))).subrange(1, width);
};
public method .right() {
arg str, width, @sep;
var res;
if ('pueblo in sep)
width = width + (str.pueblo_code_widths());
sep = [@sep, " "][1];
res = (sep.make(width)) + str;
return res.subrange((strlen(res) - width) + 1);
};
public method .center() {
arg str, width, @sep;
var res, spc;
if ('pueblo in sep)
width = width + (str.pueblo_code_widths());
sep = [@sep, " "][1];
spc = sep.make(((width / 2) - (strlen(str) / 2)) / strlen(sep));
res = ((spc + str) + spc) + sep;
return res.subrange(1, width);
};
public method .english_list() {
arg str, @args;
// An english list of 1 element is the 1 element.
// This is done for compatability with .compile_text and .parse_text
// So that a string's value returns correctly...
// And a list's value is turned to english_list.
return str;
};
public method .singular() {
arg st;
var len, st, i;
len = st.length();
if ((i = st in ["lies", "has", "is", "was", "doesn't", "raises", "uses", "curses"]))
return ["lie", "have", "are", "were", "don't", "raise", "use", "curse"][i];
else if (st == "thieves")
return (st[1]) + "hief";
else if ((len <= 3) || ((st[len]) != "s"))
return st;
else if ((st.subrange(len - 2)) == "ies")
return (st.subrange(1, len - 3)) + "y";
else if ((st.subrange(len - 2)) in ["ses", "hes", "oes"])
return st.subrange(1, len - 2);
else if ((st[len - 1]) != "e")
return st.subrange(1, len - 1);
else if ((((st[len - 2]) == "h") && ("cs" in (st[len - 3]))) || (("ox" in (st[len - 2])) || ((st.subrange(len - 3, 1)) == "ss")))
return st.subrange(1, len - 2);
else
return st.subrange(1, len - 1);
};
public method .plural() {
arg str;
var last1, len, i;
if ((i = str in ["are", "have", "do", "don't", "were", "aren't", "doesn't"]))
return ["is", "has", "does", "doesn't", "was", "isn't", "don't"][i];
len = strlen(str);
last1 = str.subrange(len);
if (last1 in ["s", "o", "h"])
return str + "es";
else if (last1 in ["y"])
return (str.subrange(1, (str.length()) - 1)) + "ies";
else
return str + "s";
};
public method .first_in() {
arg string, segs, @start;
var x, min, i, s;
s = 1;
if (start)
s = start[1];
min = strlen(string) + 1;
for x in (segs) {
if ((i = x in (string.subrange(s))) && (i < min))
min = i;
}
return (min == (strlen(string) + 1)) ? 0 : ((min + s) - 1);
};
public method .capture() {
arg str, begin, end, @seperator;
var i, start, starter, ender, others, fstr, indent;
start = 1;
indent = 0;
ender = strlen(str);
others = [];
if (seperator) {
if (listlen(seperator) == 2)
start = seperator[2];
seperator = seperator[1];
} else {
seperator = [0];
}
while (start < ender) {
if (indent)
i = str.first_in([begin, seperator, end], start);
else
i = str.first_in([begin, end], start);
if (!i)
return 0;
switch (str[i]) {
case begin:
if (start == 1) {
starter = i + 1;
fstr = str.subrange(1, i - 1);
}
indent++;
case end:
if (fstr != 0)
indent--;
case seperator[1]:
if (((seperator in (str.subrange(i))) == 1) && (indent == 1)) {
others = [@others, str.subrange(starter, i - starter)];
starter = i + strlen(seperator);
}
}
if ((start != 1) && (indent == 0))
return [fstr, @others, str.subrange(starter, i - starter), str.subrange(i + 1)];
start = i + 1;
}
return 0;
};
public method .match_player() {
arg str;
var x, kids, n;
for x in ((kids = $player.children())) {
if (str == (x.name()))
return x;
}
for x in (kids) {
if ((str in (x.name())) == 1)
return x;
}
return 0;
};
public method .str_to_buf() {
arg @args;
return (> str_to_buf(@args) <);
};
public method .trim(): native;
public method .subrange(): native;
public method .crypt(): native;
public method .explode(): native;
public method .lowercase(): native;
public method .match_begin(): native;
public method .match_pattern(): native;
public method .match_regexp(): native;
public method .match_template(): native;
public method .pad(): native;
public method .regexp(): native;
public method .strcmp() {
arg @args;
return (> strcmp(@args) <);
};
public method .strfmt() {
arg @args;
return (> strfmt(@args) <);
};
public method .strgraft() {
arg @args;
return (> strgraft(@args) <);
};
public method .strlen() {
arg @args;
return (> strlen(@args) <);
};
public method .strsed() {
arg @args;
return (> strsed(@args) <);
};
public method .strsub() {
arg @args;
return (> strsub(@args) <);
};
public method .substr() {
arg @args;
return (> substr(@args) <);
};
public method .uppercase(): native;
public method .length(): native;
public method .sed(): native;
public method .replace(): native;
public method .compare(): native;
public method .format(): native;
public method .split(): native;
public method .from_english_number() {
arg string;
var ones, tens, teens, split, i, neg;
neg = 1;
split = [];
if ("negative " in string) {
string = string.subrange(10);
neg = -1;
}
if (!string)
return 0;
ones = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty"];
tens = ["ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"];
teens = ["eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty"];
if ((i = string in ones))
return i * neg;
if ((i = string in tens))
return (i * 10) * neg;
if ((!(" " in string)) && (i = ((string.explode("-"))[1]) in tens))
return (i * 10) + (((string.explode("-"))[2]) in ones);
split = string.explode(" ");
if ((split[2]) == "billion")
return (((split[1]).from_english_number()) * 1000000000) + (((split.subrange(3)).combine(" ")).from_english_number());
if ((split[2]) == "million")
return (((split[1]).from_english_number()) * 1000000) + (((split.subrange(3)).combine(" ")).from_english_number());
if ((split[2]) == "thousand")
return (((split[1]).from_english_number()) * 1000) + (((split.subrange(3)).combine(" ")).from_english_number());
if ((split[2]) == "hundred")
return (((split[1]).from_english_number()) * 100) + (((split.subrange(3)).combine(" ")).from_english_number());
};
public method .word(): native;
public method .dbquote_explode(): native;
public method .fromliteral() {
arg str;
var result;
// This method 'parses' a string into a piece of data.
// First we add a trailing "*" to the string as an eof, and call
// ._fromliteral()
result = ._fromliteral(str + "*");
// Next, we check the result...
if (((result[2]).replace(" ", "")) != "*")
throw(~parse, "Parse error");
result = result[1];
return result;
// $#Edited: 16 Aug 96 19:29 $user_charles
// $#Copied 16 Aug 96 19:52 from $user_charles.parse_data() by $jenner
// Copied from the ColdCore by Kipp.
};
public method ._fromliteral() {
arg str;
var tmp, i, result, key, assn, type, value;
// Take a string and recursively parse
switch (str[1]) {
case "'":
// Symbol:
i = 2;
tmp = "";
// We just scan over the characters, and convert it
while ((!((str[i]) in "!@#$%^&*()_+-=~`'{}[]|/?\",.<>;: ")) || ((str[i]) == "_")) {
tmp = tmp + (str[i]);
i = i + 1;
}
if (!tmp)
throw(~parse, "' must precede a symbol");
result = tosym(tmp);
str = str.subrange(i);
case "$":
// Objref:
i = 2;
tmp = "";
while ((!((str[i]) in "!@#$%^&*()_+-=~`'{}[]|/?\",.<>;: ")) || ((str[i]) == "_")) {
tmp = tmp + (str[i]);
i = i + 1;
}
result = lookup(tosym(tmp));
str = str.subrange(i);
case "#":
// Two possibilities here:
if ((str[2]) == "[") {
// Dictionary:
result = #[];
str = str.subrange(3);
// For each entry, get the key and assn, using ._fromliteral()
while ((str[1]) != "]") {
if ((str[1]) != "[")
throw(~parse, "Parse error.");
str = str.subrange(2);
tmp = ._fromliteral(str);
key = tmp[1];
str = tmp[2];
// Now get the association
if ((str[1]) != ",")
throw(~parse, "Parse error in dict");
str = str.subrange(2);
while ((str[1]) == " ")
str = str.subrange(2);
tmp = ._fromliteral(str);
assn = tmp[1];
str = tmp[2];
if ((str[1]) != "]")
throw(~parse, "Parse error in dict.");
str = str.subrange(2);
if ((str[1]) == ",")
str = str.subrange(2);
while ((str[1]) == " ")
str = str.subrange(2);
result = result.add(key, assn);
}
str = str.subrange(2);
} else {
// Another objref:
i = 2;
tmp = "#";
while ((!((str[i]) in "!@#$%^&*()_+-=~`'{}[]|/?\",.<>;: ")) || ((str[i]) == "_")) {
tmp = tmp + (str[i]);
i = i + 1;
}
result = $object_lib.to_dbref(tmp);
str = str.subrange(i);
}
case "[":
// List:
// For each element, recursively call ._fromliteral()
result = [];
str = str.subrange(2);
while ((str[1]) != "]") {
tmp = ._fromliteral(str);
result = result + [tmp[1]];
str = tmp[2];
if ((str[1]) == ",")
str = str.subrange(2);
while ((str[1]) == " ")
str = str.subrange(2);
}
str = str.subrange(2);
case "<":
// Frob:
// Get the type:
str = str.subrange(2);
tmp = ._fromliteral(str);
type = tmp[1];
str = tmp[2];
if ((str[1]) != ",")
throw(~parse, "Parse error");
str = str.subrange(2);
while ((str[1]) == " ")
str = str.subrange(2);
// Now get the value
tmp = ._fromliteral(str);
value = tmp[1];
str = tmp[2];
if ((str[1]) != ">")
throw(~parse, "Parse error");
str = str.subrange(2);
result = (<type, value>);
case "`":
// Buffer:
str = str.subrange(3);
tmp = "";
i = 1;
while ((str[i]) != "]") {
tmp = tmp + (str[i]);
i = i + 1;
}
str = str.subrange(i + 1);
tmp = (tmp.replace(" ", "")).explode(",");
result = `[];
for i in (tmp)
result = result + `[toint(i)];
case "~":
// Error:
str = str.subrange(2);
i = 1;
tmp = "";
while ((!((str[i]) in "!@#$%^&*()_+-=~`'{}[]|/?\",.<>;: ")) || ((str[i]) == "_")) {
tmp = tmp + (str[i]);
i = i + 1;
}
str = str.subrange(i);
result = toerr(tmp);
// result = toerr(tmp);
// result = ~error;
case "\"":
// String:
i = 2;
tmp = "";
while ((str[i]) != "\"") {
if ((str[i]) == "\\") {
if (((str[i + 1]) == "\\") || ((str[i + 1]) == "\"")) {
i = i + 2;
tmp = tmp + (str[i - 1]);
} else {
tmp = tmp + (str[i++]);
}
} else {
tmp = tmp + (str[i]);
i = i + 1;
}
}
result = tmp;
str = str.subrange(i + 1);
case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "-":
// Integer or float:
i = 2;
tmp = str[1];
while (((str[i]) in "0123456789") || ((str[i]) == ".")) {
tmp = tmp + (str[i]);
i = i + 1;
}
if ("." in tmp)
result = tofloat(tmp);
else
result = toint(tmp);
str = str.subrange(i);
default:
throw(~parse, "Parse error.");
}
return [result, str];
// $#Edited: 16 Aug 96 20:58 $user_charles
// $#Copied 16 Aug 96 21:01 from $user_charles._parse_data() by $jenner
// Copied from the ColdCore by Kipp.
};
public method .pueblo_code_widths() {
arg str;
var x, w;
while ((x = str.match_pattern("*<*>*"))) {
w = (w + 2) + ((x[2]).length());
str = x[3];
}
return w;
};
public method .buffer() {
arg blah;
return str_to_buf(blah);
};
public method .symbol() {
arg blah;
return tosym(blah);
};
public method .integer() {
arg str;
return toint(str);
};
public method .match_whole() {
arg destination;
var res;
if ((destination[1]) == "#")
return toobjnum(toint(destination.subrange(2)));
else if ((res = destination.match_pattern("$*@*")) && (| lookup(tosym(res[2])) |))
return (<$distrib, [tosym(res[2]), tosym(res[1])], 'handle>);
else if ((destination[1]) == "$")
return lookup(tosym(destination.subrange(2)));
return destination.match_object();
};
new object #4: #2;
name $list #4;
var #1 commands = [<#5, #[['location, #6], ['amount, 2]]>];
public method .parse_text() {
arg line, reciever, options, @info;
var str, res, x, plural, objs, y;
// Returns 0 if there is nothing visible, otherwise the string
objs = 2;
str = "";
for x in (line) {
if (type(x) == 'string) {
res = x;
} else {
res = "";
switch (x[1]) {
case 'obj:
if ((info[x[3]]).is_visible_to(reciever))
objs = 1;
else if (objs == 2)
objs = 0;
if (reciever == (info[x[3]]))
res = x[2];
else if ((x[4]) == 'title)
res = (info[x[3]]).title(reciever, options);
else
res = (info[x[3]]).(x[4])();
case 'verb:
if (plural || (reciever == (info[x[2]])))
res = x[4];
else
res = x[3];
case 'required:
if (!((x[2]) in options))
return 0;
case 'notreq:
if ((x[2]) in options)
return 0;
case 'value:
if (type(info[x[2]]) == 'list) {
if (listlen(info[x[2]]) > 1)
plural = 2;
for y in (info[x[2]]) {
if (type(y) != 'objnum) {
// blah.
} else if (y.is_visible_to(reciever)) {
objs = 1;
} else if (objs == 2) {
objs = 0;
}
}
}
if ((x[3]) == 'english_list) {
if ((| listlen(info[x[2]]) > 1 |))
plural = 2;
res = (info[x[2]]).english_list(reciever, options);
} else {
res = (info[x[2]]).(x[3])();
}
case 'left:
res = (((info[x[2]]).parse_text(reciever, options, @info)).left(x[3], x[4], @options)) || "";
case 'right:
res = (((info[x[2]]).parse_text(reciever, options, @info)).right(x[3], x[4], @options)) || "";
case 'center:
res = (((info[x[2]]).parse_text(reciever, options, @info)).center(x[3], x[4], @options)) || "";
case 'link:
if ('pueblo in options)
res = ("<a xch_cmd=\"" + (x[2])) + "\">";
case 'endlink:
if ('pueblo in options)
res = "</a>";
}
if (plural != 0)
plural = plural - 1;
}
str = str + res;
}
return objs && ((str.capitalize()).replace("you's", "your"));
};
public method .sort_object_list() {
arg stuff, who, options;
var list, title, names, amounts, x, len;
list = (names = (amounts = []));
for x in (stuff) {
title = x.title(who, options);
if ((len = title in names)) {
amounts = amounts.replace(len, [(amounts[len])[1], ((amounts[len])[2]) + 1]);
} else {
names += [title];
amounts += [[x, 1]];
}
refresh();
}
for x in (amounts) {
list += [(x[1]).title(who, options, x[2])];
refresh();
}
return list;
};
public method .english_list() {
arg stuff, @whonothing;
var len, x, str, who, options, list;
who = $sys.user();
for x in (whonothing) {
if (type(x) == 'objnum)
who = x;
}
options = [];
for x in (whonothing) {
if (type(x) == 'list)
options = x;
}
if (stuff && (type(stuff[1]) in ['frob, 'objnum]))
list = stuff.sort_object_list(who, options);
else
list = stuff;
if (!list) {
for x in (whonothing) {
if (type(x) == 'string)
return x;
}
return "nothing";
}
len = listlen(list);
if (len == 1)
return "" + (list[1]);
str = "";
for x in ((list.delete(len)).delete(1))
str = (str + ", ") + x;
str = (list[1]) + str;
return (str + " and ") + (list[len]);
};
public method .combine() {
arg list, @sep;
var x, str;
str = "";
if (!sep)
sep = [""];
else if (!list)
return "";
for x in (list.delete(1))
str = (str + (sep[1])) + x;
return (list[1]) + str;
};
public method .delete(): native;
public method .insert(): native;
public method .listlen() {
arg @args;
return (> listlen(@args) <);
};
public method .listgraft() {
arg @args;
return (> listgraft(@args) <);
};
public method .replace(): native;
public method .setadd(): native;
public method .setremove(): native;
public method .sublist() {
arg @args;
return (> sublist(@args) <);
};
public method .union(): native;
public method .length(): native;
public method .subrange(): native;
public method .join(): native;
public method .friendly_traceback() {
arg tb;
var x, s;
s = [];
for x in (tb) {
if (listlen(x) == 5)
s += [((((((((tostr(x[1]).left(10)) + " ") + (x[2])) + " ") + (x[3])) + " ") + (x[4])) + ", line ") + (x[5])];
}
return s;
};
public method .sort(): native;
public method .compile_text() {
arg aa;
// Already compiled, I guess.
return aa;
};
public method .make() {
arg what, amount;
var x, r;
r = [];
for x in [1 .. amount]
r += [what];
return r;
};
public method .columnise() {
arg items, n, width;
var height, colwidths, result, row, col, line;
// list.columnize (items, n, width);
height = (((items.length()) + n) - 1) / n;
items += .make("", (height * n) - (items.length()));
colwidths = [];
for col in [1 .. n - 1]
colwidths += [((width + 1) * col) / n];
result = [];
for row in [1 .. height] {
line = tostr(items[row]);
for col in [1 .. n - 1]
line = ((line.left(colwidths[col])) + " ") + (items[row + (col * height)]);
result += [line.subrange(1, min(line.length(), width))];
}
return result;
};
new object #7: #2;
name $integer #7;
var #7 ones = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
var #7 teens = ["eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"];
var #7 tens = ["ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"];
public method .english_number() {
arg number;
var an, isneg, temp;
an = abs(number);
isneg = (number < 0) ? "negative " : "";
if (!number)
return "zero";
if (an < 11)
return isneg + (ones[an]);
if (an < 20)
return isneg + (teens[an - 10]);
if (an < 100)
return (isneg + (tens[an / 10])) + ((temp = an % 10) ? "-" + (temp.english_number()) : "");
if (an < 1000)
return ((isneg + (ones[an / 100])) + " hundred") + ((temp = an % 100) ? " " + (temp.english_number()) : "");
if (an < 1000000)
return ((isneg + ((an / 1000).english_number())) + " thousand") + ((temp = an % 1000) ? " " + (temp.english_number()) : "");
if (an < 1000000000)
return ((isneg + ((an / 1000000).english_number())) + " million") + ((temp = an % 1000000) ? " " + (temp.english_number()) : "");
return ((isneg + ((an / 1000000000).english_number())) + " billion") + ((temp = an % 1000000000) ? " " + (temp.english_number()) : "");
};
public method .abs() {
arg @args;
return (> abs(@args) <);
};
public method .max() {
arg @args;
return (> max(@args) <);
};
public method .min() {
arg @args;
return (> min(@args) <);
};
public method .random() {
arg num;
return random(num);
};
public method .sin() {
arg @args;
return (> sin(@args) <);
};
public method .exp() {
arg @args;
return (> exp(@args) <);
};
public method .log() {
arg @args;
return (> log(@args) <);
};
public method .cos() {
arg @args;
return (> cos(@args) <);
};
public method .tan() {
arg @args;
return (> tan(@args) <);
};
public method .sqrt() {
arg @args;
return (> sqrt(@args) <);
};
public method .asin() {
arg @args;
return (> asin(@args) <);
};
public method .acos() {
arg @args;
return (> acos(@args) <);
};
public method .atan() {
arg @args;
return (> atan(@args) <);
};
public method .pow() {
arg @args;
return (> pow(@args) <);
};
public method .atan2() {
arg @args;
return (> atan2(@args) <);
};
public method .and(): native;
public method .or(): native;
public method .xor(): native;
public method .shleft(): native;
public method .shright(): native;
public method .not(): native;
public method .exponent() {
arg num, exp;
var x;
if (exp == 0)
return 1;
for x in [2 .. exp]
num = num * num;
return num;
};
new object #8: #2;
name $float #8;
public method .abs() {
arg @args;
return (> abs(@args) <);
};
public method .max() {
arg @args;
return (> max(@args) <);
};
public method .min() {
arg @args;
return (> min(@args) <);
};
public method .random() {
arg @args;
return (> random(@args) <);
};
public method .sin() {
arg @args;
return (> sin(@args) <);
};
public method .exp() {
arg @args;
return (> exp(@args) <);
};
public method .log() {
arg @args;
return (> log(@args) <);
};
public method .cos() {
arg @args;
return (> cos(@args) <);
};
public method .tan() {
arg @args;
return (> tan(@args) <);
};
public method .sqrt() {
arg @args;
return (> sqrt(@args) <);
};
public method .asin() {
arg @args;
return (> asin(@args) <);
};
public method .acos() {
arg @args;
return (> acos(@args) <);
};
public method .atan() {
arg @args;
return (> atan(@args) <);
};
public method .pow() {
arg @args;
return (> pow(@args) <);
};
public method .atan2() {
arg @args;
return (> atan2(@args) <);
};
new object #9: #2;
name $dictionary #9;
public method .dict_add() {
arg @args;
return (> dict_add(@args) <);
};
public method .dict_contains() {
arg @args;
return (> dict_contains(@args) <);
};
public method .dict_del() {
arg @args;
return (> dict_del(@args) <);
};
public method .dict_keys() {
arg @args;
return (> dict_keys(@args) <);
};
public method .keys(): native;
public method .add(): native;
public method .union(): native;
public method .del(): native;
public method .contains(): native;
public method .values(): native;
public method .length() {
arg dict;
return (dict.keys()).length();
};
new object #10: #2;
name $buffer #10;
public method .subrange(): native;
public method .buflen() {
arg @args;
return (> buflen(@args) <);
};
public method .bufgraft() {
arg @args;
return (> bufgraft(@args) <);
};
public method .buf_replace() {
arg @args;
return (> buf_replace(@args) <);
};
public method .buf_to_str() {
arg @args;
return (> buf_to_str(@args) <);
};
public method .buf_to_strings() {
arg @args;
return (> buf_to_strings(@args) <);
};
public method .strings_to_buf() {
arg @args;
return (> strings_to_buf(@args) <);
};
public method .subbuf() {
arg @args;
return (> subbuf(@args) <);
};
public method .length(): native;
public method .replace(): native;
public method .to_string(): native;
public method .to_strings(): native;
public method .from_string(): native;
public method .from_strings(): native;
public method .to_veil_pkts(): native;
public method .from_veil_pkts(): native;
public method .string() {
arg blah;
return buf_to_str(blah);
};
new object #945: #2;
name $symbol #945;
new object #1242: #2;
name $network #1242;
public method .ip(): native;
public method .hostname(): native;
new object #11: #1;
name $login #11;
var #1 name = "Login Object";
var #11 port = 4479;
var #11 welcome = ["You may now log in as root, password root."];
var #11 messages = #[['newpass, "Enter the password you want: "], ['noconfirm_newpass, "Type the password more carefully: "], ['nomatch, "Passwords don't match."], ['confirmpass, "Type it again to make sure: "], ['badname, "Name can only contain alphanumeric characters."], ['confirmname, "Did I get that right, {o}? "], ['gender, "Enter a gender (m/f): "], ['connected, "Connected."], ['badpass, "Bad password."], ['bad_command, "I don't understand THAT!"], ['user, "Username: "], ['notsure_user, "Well, what IS it then? "], ['badname_user, "Enter a simpler username: "], ['badpass_user, "Enter a name you know the password for: "], ['pass, "Password: "], ['nologin, 0]];
var #11 pwelcome = "</xch_mudtext><img xch_mode=purehtml>";
public method .set_message() {
arg message, value;
// Cause a TB if bad msg
messages[message];
messages = dict_add(messages, message, value);
};
public method .messages() {
return messages;
};
public method .welcome() {
arg @args;
if (args)
welcome = args[1];
return welcome;
};
public method .startup() {
dblog("Binding port..." + port);
bind_port(port);
};
driver method .connect() {
arg ip, server_ip, socket, @args;
var c;
dblog("New connection: " + ip);
c = $connection.create();
c.state(['login]);
reassign_connection(c);
c.name(ip);
c.time(1);
c.print("This world is Pueblo 1.0 enhanced.");
c.print(.welcome());
c.print(str_to_buf((.messages())['user]));
};
public method .state_login() {
arg line, conn;
var who, resp, x;
if (!line)
return;
// $user_kipp.print("Newconn says: " + line);
if (((line.explode())[1]) == "PUEBLOCLIENT") {
conn.display_options(setadd(conn.display_options(), 'pueblo));
conn.print(str_to_buf(.pueblo_welcome()));
} else if (line == "PUEBLOFORM ?cnew=Create+New") {
if ((| (.messages())['nologin] |)) {
conn.print("Auto-creation is disabled.");
} else {
conn.print(str_to_buf("Enter the name you want: "));
conn.print(str_to_buf("<xch_pane name=login action=close>"));
}
} else if ((resp = line.match_pattern("PUEBLOFORM ?user=*&pass=*&*"))) {
if ((who = (resp[1]).match_player())) {
if ((resp[2]) != (who.password())) {
conn.print((.messages())['badpass]);
} else {
conn.print(str_to_buf("<xch_pane name=login action=close>"));
conn.state(['connected]);
conn.player(who);
who.add_connection(conn);
}
} else if ((| (.messages())['nologin] |)) {
conn.print(str_to_buf((.messages())['nologin]));
} else {
conn.print("No such character. Try clicking on 'Create'");
}
} else if (((line.explode())[1]) == "PASS") {
conn.display_options([(line.explode())[2]]);
} else if (((line.explode())[1]) == "NICK") {
if ((who = ((line.explode())[2]).match_player())) {
if ((| (conn.display_options())[1] |) != (who.password())) {
conn.print(("No authorization for using \"" + who) + "\".");
conn.destroy();
return;
}
conn.state(['connected]);
conn.player(who);
who.add_connection(conn);
conn.print(" -- OK");
who.print((.messages())['connected]);
resp = "";
for x in (.connected_players())
resp = (resp + (x.name())) + " ";
conn.print((":" + (who.name())) + "!you@yes.you JOIN #vampcastle");
conn.print((":moo.syr.edu 332 " + (who.name())) + " #vampcastle :Cold Paradigm Chat");
conn.print((":moo.syr.edu 333 " + (who.name())) + " #vampcastle Kipp 845955000");
conn.print((((":moo.syr.edu 353 " + (who.name())) + " @ #vampcastle :") + resp) + "@command");
conn.print((":moo.syr.edu 366 " + (who.name())) + " #vampcastle :End of /NAMES list.");
conn.display_options(['IRC, @who.display_options()]);
return;
} else {
conn.print("No authorization.");
conn.destroy();
}
} else if ((who = line.match_player())) {
conn.state(['pass, who]);
conn.print(str_to_buf((.messages())['pass]) + `[255, 251, 1]);
} else if ((| (.messages())['nologin] |)) {
conn.print(str_to_buf((.messages())['nologin]));
} else if (line == "Guest") {
conn.print("Guests are not implemented. Enter the name you WISH to be known as: ".buffer());
} else {
resp = line;
for x in [1 .. 36]
resp = resp.replace("0123456789abcdefghijklmnopqrstuvwxyz"[x], "");
if (resp) {
conn.print((.messages())['badname]);
conn.print(str_to_buf((.messages())['badname_user]));
} else {
conn.print(str_to_buf(((.messages())['confirmname]).replace("{o}", line)));
conn.state(['confirm, line]);
}
}
};
public method .state_confirm() {
arg line, conn;
if ((line[1]) != "y") {
conn.print(str_to_buf((.messages())['notsure_user]));
conn.state(['login]);
} else {
conn.print(str_to_buf((.messages())['newpass]) + `[255, 251, 1]);
conn.state(['pass1, (conn.state())[2]]);
}
};
public method .state_pass1() {
arg line, conn;
conn.print("");
conn.print(str_to_buf((.messages())['confirmpass]));
conn.state(['pass2, (conn.state())[2], line]);
};
public method .state_pass2() {
arg line, conn;
conn.print("");
if (line != ((conn.state())[3])) {
conn.print((.messages())['nomatch]);
conn.print(str_to_buf((.messages())['noconfirm_newpass]));
conn.state(['pass1, (conn.state())[2]]);
return;
}
conn.print(`[255, 252, 1]);
conn.print(str_to_buf((.messages())['gender]));
conn.state(['gender, (conn.state())[2], line]);
};
public method .state_gender() {
arg line, conn;
var who;
if (line.match_template("m?ale|f?emale|n?euter")) {
who = $player.new(((conn.state())[2]).capitalize(), (conn.state())[3]);
who.gender(["male", "female", "neuter"][(line[1]) in "mfn"]);
conn.state(['connected]);
conn.player(who);
who.add_connection(conn);
conn.print(`[255, 252, 1]);
who.print((.messages())['connected]);
conn.display_options((conn.display_options()) + (who.display_options()));
}
};
public method .state_pass() {
arg line, conn;
var who;
conn.print("");
if (line == ((who = (conn.state())[2]).password())) {
conn.state(['connected]);
conn.player(who);
who.add_connection(conn);
conn.print(`[255, 252, 1]);
who.print((.messages())['connected]);
conn.display_options([@conn.display_options(), @who.display_options()]);
} else {
conn.state(['login]);
conn.print((.messages())['badpass]);
conn.print(str_to_buf((.messages())['badpass_user]) + `[255, 252, 1]);
}
};
public method .do_parse() {
arg line, @ccon;
var conn, resp;
if (ccon)
conn = ccon[1];
else
conn = sender();
if (('IRC in (conn.display_options())) && (!(line = .from_irc(line, conn))))
return;
dblog((("doing parse on " + conn) + "... line: ") + line);
switch ((conn.state())[1]) {
case 'connected:
(conn.player()).curcon(conn);
resp = (conn.player()).parse_line(line);
if (!resp) {
conn.print((.messages())['bad_command]);
} else if (resp == 'disconnect) {
conn.destroy();
} else if (type(resp) == 'string) {
conn.print(resp);
} else if (type(resp) == 'list) {
switch (resp[1]) {
case 'notify:
conn.notify(@resp.subrange(2));
case 'tell:
(conn.player()).notify(@resp.subrange(2));
case 'announce:
((conn.player()).location()).announce(@resp.subrange(2));
default:
conn.notify(@resp);
}
}
case 'reading:
resp = (conn.state())[2];
conn.state(['connected]);
resume(resp, line);
default:
.(tosym("state_" + ((conn.state())[1])))(line, conn);
}
};
public method .pueblo_welcome() {
arg @args;
if (args)
pwelcome = args[1];
return pwelcome;
};
public method .connected_players() {
var x, s;
s = [];
for x in ($connection.children())
s = s.setadd(x.player());
return s.setremove(0);
};
public method .from_irc() {
arg line, conn;
var x, users, who, nwho, nline;
users = "";
switch ((line.explode())[1]) {
case "MODE":
conn.print((":moo.syr.edu 324 " + ((conn.player()).name())) + " #vampcastle +nts");
conn.print((":moo.syr.edu 329 " + ((conn.player()).name())) + " #vampcastle 845953842");
return 0;
case "PART":
for x in (.connected_players())
users = (users + (x.name())) + " ";
conn.print((":" + ((conn.player()).name())) + "!you@yes.you JOIN #vampcastle");
conn.print((":moo.syr.edu 332 " + ((conn.player()).name())) + " #vampcastle :Cold Paradigm Chat");
conn.print((":moo.syr.edu 333 " + ((conn.player()).name())) + " #vampcastle Kipp 845955000");
conn.print((((":moo.syr.edu 353 " + ((conn.player()).name())) + " @ #vampcastle :") + users) + "@command");
conn.print((":moo.syr.edu 366 " + ((conn.player()).name())) + " #vampcastle :End of /NAMES list.");
conn.print("Type /QUIT if you want to leave.");
return 0;
case "PRIVMSG":
nline = line.subrange((":" in line) + 1);
if ((who = (line.explode())[2]) == "#vampcastle") {
if (((nline.explode())[1]) == "ACTION")
return "emote" + (nline.subrange(7));
return "say " + nline;
} else if ((who = (line.explode())[2]) == "command") {
return nline;
} else if ((nwho = who.match_player())) {
if (((nline.explode())[1]) == "ACTION") {
nwho.print(("*** (Remote): " + ((conn.player()).name())) + nline);
return 0;
}
nwho.print((("*** (Remote): " + ((conn.player()).name())) + " says: ") + nline);
return 0;
} else {
conn.print(who + " isn't here.");
}
}
// $user_kipp.print("IRC: " + line);
return 0;
};
public method .bind_port() {
arg port;
bind_port(port);
};
public method .unbind_port() {
arg port;
unbind_port(port);
};
public method .port() {
arg @args;
if (args)
port = args[1];
return port;
};
new object #12: #1;
name $connection #12;
var #1 name = "Generic Connection";
var #12 state = ['null];
var #12 input = "";
var #12 player = 0;
var #12 options = [];
var #12 lines = [];
var #12 cname = 0;
var #12 idle_time = 0;
var #12 connection_time = 0;
public method .display_options() {
arg @args;
// This is where you'd want to set Pueblo and stuff.
if ((listlen(args) == 1) && (type(args[1]) == 'list))
options = args[1];
else if (args)
throw(~numargs, "Called with too many or invalid arguments.");
else
return options || [];
};
public method .print() {
arg line;
var x;
if (type(line) == 'buffer) {
cwrite(line);
return;
}
if (type(line) == 'string)
line = [line];
if ('IRC in (.display_options())) {
for x in (line) {
if ((x[1]) == ":")
cwrite(strings_to_buf([x]));
else
cwrite(strings_to_buf([((":command!h@h PRIVMSG " + ((.player()).name())) + " :") + x]));
}
} else if ('pueblo in (.display_options())) {
for x in (line)
cwrite(str_to_buf(x + "<br>"));
} else {
cwrite(strings_to_buf(line));
}
};
public method .notify() {
arg line, @info;
var x;
if (!(.player()))
return;
x = line.parse_text(.player(), .display_options(), @info);
if ('pueblo in (.display_options()))
x += "<br>";
if ('IRC in (.display_options())) {
if (line == "{o} {v/says/say}, \"{s/2}\"") {
if ((info[1]) != (.player()))
cwrite(strings_to_buf([((":" + ((info[1]).name())) + "!you@yeah.you PRIVMSG #vampcastle :") + (info[2])]));
return;
} else if ((| (stack()[4])[3] |) == 'emote_cmd) {
if ((info[1]) != (.player()))
cwrite((str_to_buf((":" + (x.subrange(1, (" " in x) - 1))) + "!you@yeah.you PRIVMSG #vampcastle :") + `[1, 65, 67, 84, 73, 79, 78, 32]) + strings_to_buf([x.subrange((" " in x) + 1)]));
return;
}
cwrite(strings_to_buf([((":command!h@h PRIVMSG " + ((.player()).name())) + " :") + x]));
return;
}
if (x)
cwrite(strings_to_buf([x]));
};
driver method .parse() {
arg line, @args;
var i;
idle_time = time();
i = buf_to_strings((input || `[]) + line);
input = i[listlen(i)];
lines = (lines || []) + (i.delete(listlen(i)));
while (lines) {
line = lines[1];
lines = lines.delete(1);
catch any {
$login.do_parse(line);
} with {
.print("Error!");
.print(toliteral(traceback()));
}
}
(| $sys.set_var('users, ($sys.get_var('users)).del(task_id())) |);
};
public method .state() {
arg @args;
if (args)
state = args[1];
return state;
};
driver method .disconnect() {
arg @args;
dblog("Disconnected.");
.destroy();
};
public method .player() {
arg @args;
if (args)
player = args[1];
return player;
};
public method .destroy() {
arg @args;
var tp;
tp = player;
player = 0;
(| tp.remove_connection(this()) |);
catch any {
close_connection();
if (((.state())[1]) == 'reading)
resume((.state())[2]);
}
destroy();
};
public method .connection() {
return connection();
};
public method .name() {
arg @args;
if (listlen(args) == 1)
cname = args[1];
return cname;
};
public method .idle() {
return time() - idle_time;
};
public method .time() {
arg @args;
if (args)
connection_time = time();
return time() - connection_time;
};
new object #17: #1;
name $zone #17;
var #1 name = "Generic Zone";
var #17 zonename = 0;
var #17 rooms = [];
var #17 midi = 0;
var #17 owner = 0;
var #17 picture_path = 0;
public method .locate() {
arg x, y, z;
var xyz;
xyz = [x, y, z];
for x in (rooms) {
if ((x.xyz()) == xyz)
return x;
}
return 0;
};
public method .zonename() {
arg @args;
if ((listlen(args) == 1) && (type(args[1]) == 'string)) {
.set_objname(("zone_" + (args[1])).symbol());
zonename = args[1];
} else if (args) {
throw(~numargs, "Called with too many or invalid arguments.");
} else {
return zonename;
}
};
public method .remove_room() {
arg room;
rooms = setremove(rooms || [], room);
};
public method .add_room() {
arg room;
var x;
for x in ($zone.children()) {
if (room in (x.rooms()))
x.remove_room(room);
}
rooms = setadd(rooms || [], room);
};
public method .rooms() {
return rooms || [];
};
public method .midi() {
arg @args;
if (args)
midi = args[1];
return midi;
};
public method .owner() {
arg @args;
if (args)
owner = args[1];
return owner;
};
public method .destroy() {
var x;
if (rooms) {
// throw(~perm, "Can not destroy a zone with rooms.");
for x in (rooms)
x.destroy();
}
// else
pass();
};
public method .picture_path() {
arg @args;
if (args)
picture_path = args[1];
return picture_path || "";
};
new object #2478: #17;
name $zone_start #2478;
var #17 zonename = "start";
var #1 name = "start";
var #17 owner = #16;
var #17 rooms = [#2479];
new object #29: #1;
name $object #29;
var #1 name = "Generic Object";
var #29 location = 0;
var #29 contents = #[];
var #29 description = [];
var #29 flags = [];
var #29 messages = 0;
var #29 moveable = 0;
var #29 creator = 0;
public method .destroy() {
arg @args;
var x;
for x in (.all_contents())
(| x.move(.location()) |);
(| .move(0) |);
return (> destroy(@args) <);
};
public method .get_message() {
arg message;
return (| messages[message] |) || 0;
};
public method .set_message() {
arg message, value;
messages = dict_add(messages || #[], message, value);
};
public method .match_object() {
arg str;
var x;
for x in (.all_contents()) {
if (x.is_this(str))
return x;
}
return 0;
};
public method .english_list() {
arg @whonothing;
var x, options, who;
// An english list of 1 element is the 1 element.
// This is done for compatability with .compile_text and .parse_text
// So that a string's value returns correctly...
// And a list's value is turned to english_list.
options = [];
for x in (whonothing) {
if (type(x) == 'list)
options = x;
}
who = $sys.user();
for x in (whonothing) {
if (type(x) == 'objnum)
who = x;
}
return .title(who, options);
};
public method .is_visible_to() {
arg who;
return ('see_invisible in (who.flags())) || (!('invisible in (.flags())));
};
public method .flags() {
return flags || [];
};
public method .add_flag() {
arg flag;
flags = [@flags || [], flag];
};
public method .remove_flag() {
arg flag;
flags = setremove(flags || [], flag);
};
public method .description() {
arg @args;
if ((listlen(args) == 1) && (type(args[1]) == 'list))
description = args[1];
else if (args)
throw(~type, "Invalid number or type of arguments.");
return description || ["You see nothing important."];
};
public method .change_frob() {
arg frob, @new;
var x;
for x in (contents.dict_keys()) {
if (frob in (contents[x])) {
contents = contents.dict_add(x, setremove(contents[x], frob));
if (new)
contents = contents.dict_add(x, [@contents[x], new[1]]);
return;
}
}
throw(~frob, "Frob not found.");
};
public method .location() {
// Locked because move() problems can get BIG.
return location;
};
public method .set_contents() {
arg value;
contents = value;
};
public method .all_contents() {
var x, c;
c = [];
for x in (.contents(0))
c = [@c, @.contents(x)];
return c;
};
public method .contents() {
arg @args;
var key;
// Locked because move() problems can get BIG.
// .contents() -> default conts
// .contents('key) -> specific conts
// .contents(0) -> keys
// .contents(1) -> all contents data
if (contents == 0) {
// I hope we can assume the first parent is a room or player,
// Which contain correct contents info.
contents = (parents()[1]).contents(1);
}
if (listlen(args) > 1)
throw(~numargs, "Requires 0 or 1 argument.");
if (args == [1])
return contents;
if (!contents) {
// Note it has no contents because it can't hold anything.
if (args && (args != [0]))
throw(~keynf, "Object can not carry things there.");
return [];
}
if (args)
key = args[1];
else
key = (contents.dict_keys())[1];
if (!key)
return contents.dict_keys();
return (> contents[key] <);
};
public method .move() {
arg destination, @part;
.do_move(destination, @part);
};
protected method .do_move(): nooverride {
arg destination, @part;
var keys, dkey, skey, x, source;
// Locked because move() problems can get BIG. Use .move instead.
if (location) {
for x in (location.contents(0)) {
if (this() in (location.contents(x))) {
skey = x;
break;
}
}
}
source = location;
if (!(.moveable())) {
throw(~move, "This object can not be moved.");
} else if (destination in ['nowhere, 0]) {
if (location != 0)
location.remove_contents(this(), skey);
location = 0;
} else if ((!(destination.has_ancestor($object))) && (!(destination.has_ancestor($frob)))) {
throw(~move, "Destination is not a virtual object.");
} else if (!(keys = destination.contents(0))) {
throw(~move, "Destination can not hold objects.");
} else if (part && (type(part[1]) != 'symbol)) {
throw(~type, "Second argument must be a symbol.");
} else {
dkey = part ? part[1] : (keys[1]);
if (!(dkey in keys))
throw(~move, "Destination does not hold objects there.");
if (location && (!(location.exiting(this())))) {
throw(~move, "Source refused exit.");
} else if (destination.entering(this(), dkey)) {
if (location)
location.remove_contents(this(), skey);
destination.append_contents(this(), dkey);
location = destination;
} else {
throw(~move, "Destination refused entrance.");
}
}
(| source.exited(this(), skey) |);
(| destination.entered(this(), dkey) |);
};
public method .entering() {
arg thing, key;
};
public method .exiting() {
arg thing;
};
public method .moveable() {
arg @args;
// Completely NOT. moveable=1 = unmoveable
if (args)
moveable = !(args[1]);
return !moveable;
};
public method .messages() {
return dict_keys(messages || #[]);
};
public method .title() {
arg who, options, @amount;
var nm;
nm = pass(who, options, @amount);
if ('pueblo in options)
return ((("<a xch_cmd=\"look at " + pass(who, options)) + "\">") + nm) + "</a>";
return nm;
};
public method .money() {
arg @args;
if (args)
money = args[1];
return money;
};
public method .creator() {
arg @args;
if (args)
creator = args[1];
return creator;
};
public method .create() {
arg @args;
var r;
r = pass(@args);
r.creator($sys.user());
return r;
};
public method .append_contents() {
arg value, key;
contents = contents.dict_add(key, [@contents[key], value]);
};
public method .remove_contents() {
arg value, key;
contents = contents.dict_add(key, (contents[key]).setremove(value));
};
new object #30: #29;
name $player #30;
var #1 name = "Generic Player";
var #30 connections = [];
var #1 commands = [["name * as *", 'name_cmd, 'private], ["quit", 'quit_cmd, 'private], ["who", 'who_cmd, 'private], ["i?nventory", 'inventory_cmd, 'private], ["paste", 'paste_cmd, 'private], ["eq?uipment", 'eq_cmd, 'private], ["PUEBLOCLOSE *", 'puebloclose_cmd, 'private], ["sco?re", 'score_cmd, 'private], ["l?ook *", 'look_cmd], ["CLICK *,*", 'click_cmd, 'private], ["echo *", 'echo_cmd, 'private], ["hole n?orth|s?outh|e?ast|w?est|u?p|d?own", 'punch_cmd, 'private], ["wall n?orth|s?outh|e?ast|w?est|u?p|d?own", 'wall_cmd, 'private], ["desc?ribe *", 'low_describe_cmd, 'private], ["appoint * as|to|for N?obody|N?othing|N?one|N?ormal|H?ero|D?isciple|L?ord|A?dvisor|K?ing|G?od|I?mplementor", 'appoint_cmd, 'private], ["hold *", 'hold_cmd, 'private], ["release*", 'release_cmd, 'private], ["forge *", 'forge_cmd, 'private], ["help *", 'help_cmd, 'private], ["roomflag *", 'roomflag_cmd, 'private], ["wintoggle *", 'wintoggle_cmd, 'private]];
var #30 password = 0;
var #29 contents = #[['inventory, []], ['clothing, []], ['equipment, []]];
var #30 home = #31;
var #30 display_options = [];
var #30 curcon = 0;
var #30 creation_time = 0;
var #30 gender = "neuter";
var #30 level = 0;
var #30 badwindows = 0;
var #30 lord = 0;
var #30 windows = 0;
var #30 stat_str = 0;
var #30 stat_dex = 0;
var #30 stat_con = 0;
var #30 stat_int = 0;
var #30 stat_wis = 0;
var #30 stat_cha = 0;
var #30 busy = 0;
var #30 health = [0, 0, 0];
var #30 skills = ['teaching, 'building, 'damage, 'forgery];
var #30 window_info = ["hi", [0, 0], 0, []];
var #30 flying = 0;
var #30 holder = 0;
var #30 holding = 0;
var #30 last_connect_time = 0;
var #30 lord_change_time = 0;
public method .connections() {
return connections || [];
};
public method .inventory_cmd() {
arg @args;
var x, c, pre, y;
pre = "";
if ('pueblo in args)
pre = "{q/pueblo}";
.window_start("Inventory", "inventory", 200, 100, 1);
c = .contents();
.notify(pre + "Inventory:");
for y in (.connections()) {
for x in (c.sort_object_list(this(), y.display_options()))
y.notify(pre + x);
}
.notify(pre + "--");
.window_end();
};
public method .commands() {
arg @args;
var extras;
extras = [];
if (args == [1])
return pass();
if (level >= 100)
extras += [["image *", 'image_cmd, 'private], ["newplayer|new-player|new_player * p?assword * m?ale|f?emale|n?one|ne?uter", 'newplayer_cmd, 'private]];
if (level > 102)
extras += [["list *.*", 'list_cmd, 'private], ["code *.*", 'code_cmd, 'private], ["messages *", 'messages_cmd, 'private], ["desc?ribe *", 'describe_cmd, 'private], ["zone *", 'zone_cmd, 'private], ["setxy", 'setxy_cmd, 'private], ["addhelp *", 'add_help_cmd, 'private], ["@* * is *", 'set_message_cmd, 'private], ["sockets", 'sockets_cmd, 'private]];
if (level > 104)
extras += [["localedit *.*", 'localedit_cmd, 'private], ["eval *", 'eval_cmd, 'private], [";*", 'eval_cmd, 'private], ["program *.*", 'prog_cmd, 'private], ["prog *.*", 'prog_cmd, 'private], ["punch n?orth|s?outh|e?ast|w?est|u?p|d?own", 'punch_cmd, 'private], ["connect n?orth|s?outh|e?ast|w?est|u?p|d?own to *", 'connect_cmd, 'private], ["new_zone|new-zone|newzone *", 'new_zone_cmd, 'private]];
return extras + pass(@args);
};
public method .level() {
arg @args;
var x, total;
if ((listlen(args) == 1) && (type(args[1]) == 'integer)) {
level = args[1];
for x in ($player.children()) {
if ("who" in (x.windows()))
x.who_cmd();
}
} else if (args) {
throw(~numargs, "Called with too many or invalid arguments.");
} else {
if (level < 100) {
total = 99;
for x in (.skills())
(| (total = total + (x[2])) |);
(| (total = total / 100) |);
if (total > level) {
.print("Congratulations, you just gained a level!");
level = total;
} else if (total < level) {
level = total;
}
}
return level;
}
};
public method .who_cmd() {
arg @stuff;
var x, lev, i, pre, l;
pre = "";
if ('pueblo in stuff)
pre = "{q/pueblo}";
// {left|right|center/infonum/width[/seperator]}
.window_start("Connected Players", "who", 100, 100, 1);
.notify(pre + "{center/1/15/-}{center/2/25/-}", "Name", "Level");
for x in ($login.connected_players()) {
l = x.level();
if ((i = l in [0, 100, 101, 102, 103, 104, 105, 106]))
lev = ["Newbie", ("Hero (" + ((x.lord()).name())) + ")", "Disciple of " + ((x.lord()).name()), "Lord", "Advisor", "King", "God", "Implementor"][i];
else
lev = ((l + " (") + ((x.lord()).name())) + ")";
.notify(pre + "{left/1/15}|{center/2/24}", "{o/3}", lev, x);
}
.notify(pre + "----------------------------------------");
.window_end();
};
public method .punch_cmd() {
arg verb, direction;
var fs, zone, room, opdir, skill, resources, x, xyz;
fs = .location();
if ((!('inside in (fs.flags()))) && (!('outside in (fs.flags()))))
return "You can't build here; The room is neither inside or outside.";
else if ((fs.name()) == "(Unnamed)")
return "You can't build here; The room is unnamed.";
else if ((fs.description()) == ["You see nothing important."])
return "You can't build here; The room in undescribed.";
else if (!(zone = fs.zone()))
return "You can't build here; The room has no zone.";
else if (((xyz = fs.xyz())[1]) > 1000000000)
return "You can't build here; The room's xyz is not set properly.";
opdir = ['north, 'south, 'east, 'west, 'up, 'down][(direction[1]) in "snwedu"];
direction = ['north, 'south, 'east, 'west, 'up, 'down][(direction[1]) in "nsewud"];
if ((| (fs.exits())[direction] |) != ~keynf)
return "That exit is already taken.";
if ((.level()) < 104) {
if (!(| (skill = .skills('building)) |))
return "You don't know how to do that.";
if (((zone.owner()) != (.lord())) && ((.level()) < 103))
return "But this is not your Lord's land!";
// 5 points for trying.
.skills('building, 5);
if (random(100) > skill)
return "You try but fail miserably.";
if (!(.take_resource(#[['wood, (((-skill) + 1000) / 300) + 2], ['stone, (((-skill) + 1000) / 300) + 2]])))
return ("Resources needed: " + ((((-skill) + 1000) / 300) + 2)) + " wood & stone.";
.set_busy(((-skill) + 1000) / 25, ("You finish building " + direction) + ".");
}
switch (direction) {
case 'north:
xyz = [xyz[1], (xyz[2]) - 1, xyz[3]];
case 'south:
xyz = [xyz[1], (xyz[2]) + 1, xyz[3]];
case 'east:
xyz = [(xyz[1]) + 1, xyz[2], xyz[3]];
case 'west:
xyz = [(xyz[1]) - 1, xyz[2], xyz[3]];
case 'up:
xyz = [xyz[1], xyz[2], (xyz[3]) - 1];
case 'down:
xyz = [xyz[1], xyz[2], (xyz[3]) + 1];
}
if (!(room = fs.exit_destination(direction))) {
room = $room.create();
room.set_zone(zone);
room.set_xyz(@xyz);
}
fs.exits(dict_add(fs.exits(), direction, #[]));
room.exits(dict_add(room.exits(), opdir, #[]));
fs.announce(("[LEARN:building,2]{o} {v/builds} " + direction) + ".", $sys.user());
room.announce(("[LEARN:building,2]{o} {v/builds} in from the " + opdir) + ".", $sys.user());
};
public method .connect_cmd() {
arg verb, direction, junk, destination;
var fs, zone, xyz, room, opdir;
fs = .location();
if ((!('inside in (fs.flags()))) && (!('outside in (fs.flags()))))
return "You can't build here; The room is neither inside or outside.";
else if ((fs.description()) == ["You see nothing important."])
return "You can't build here; The room in undescribed.";
else if (!(zone = fs.zone()))
return "You can't build here; The room has no zone.";
else if ((!((xyz = fs.xyz())[1])) > 100000)
return "You can't build here; The room's xyz is not set properly.";
opdir = ['north, 'south, 'east, 'west, 'up, 'down][(direction[1]) in "snwedu"];
direction = ['north, 'south, 'east, 'west, 'up, 'down][(direction[1]) in "nsewud"];
if ((| (fs.exits())[direction] |) != ~keynf)
return "That exit is already taken.";
if (!(room = destination.match_whole())) {
room = $room.create();
room.name(destination);
} else if (!(room.has_ancestor($room))) {
return "Destination number is not a room";
}
fs.exits(dict_add(fs.exits(), direction, #[['destination, room]]));
room.exits(dict_add(room.exits(), opdir, #[['destination, fs]]));
fs.announce(("{o} {v/builds} to the " + direction) + ".", $sys.user());
room.announce(("{o} {v/builds} in from the " + opdir) + ".", $sys.user());
};
public method .zone_cmd() {
arg verb, zonename;
(.location()).set_zone(zonename);
return "Zone set.";
};
public method .gender() {
arg @new;
if (new) {
if ((new[1]) in ["male", "female", "neuter"])
return (gender = new[1]);
throw(~gender, "Unknown gender.");
}
return gender;
};
public method .po() {
return ["him", "her", "it"][(gender in ["male", "female", "neuter"]) || 3];
};
public method .pp() {
return ["his", "her", "its"][(gender in ["male", "female", "neuter"]) || 3];
};
public method .pq() {
return ["his", "hers", "its"][(gender in ["male", "female", "neuter"]) || 3];
};
public method .pr() {
return ["himself", "herself", "itself"][(gender in ["male", "female", "neuter"]) || 3];
};
public method .ps() {
return ["he", "she", "it"][(gender in ["male", "female", "neuter"]) || 3];
};
public method .read() {
(.curcon()).state(['reading, task_id()]);
return suspend();
};
public method .curcon() {
arg @conn;
if (conn)
curcon = conn[1];
return curcon;
};
public method .display_options() {
arg @args;
if ((listlen(args) == 1) && (type(args[1]) == 'list))
display_options = args[1];
else if (args)
throw(~numargs, "Called with too many or invalid arguments.");
else
return display_options || [];
};
public method .quit_cmd() {
arg @nothing;
return 'disconnect;
};
public method .list_cmd() {
arg obj, method;
var vc, x;
catch any {
if ((obj[1]) == "$")
obj = lookup(tosym(obj.subrange(2)));
else if ((obj[1]) == "#")
obj = toobjnum(toint(obj.subrange(2)));
else
obj = obj.match_object();
if (!obj)
return "Unknown object.";
} with {
return "Unknown object.";
}
catch any
vc = obj.decompile(tosym(method));
with
return "Method not found.";
.pueblo_code("pre");
for x in [1 .. listlen(vc)]
.print(((tostr(x).left(5)) + ": ") + (vc[x]));
.pueblo_code("/pre");
.print("Done.");
};
public method .code_cmd() {
arg obj, method;
var vc;
if ((obj[1]) == "$")
obj = lookup(tosym(obj.subrange(2)));
else if ((obj[1]) == "#")
obj = toobjnum(toint(obj.subrange(2)));
else
obj = obj.match_object();
if (!obj)
return "Unknown object.";
// Might want to use obj + method instead of "code"
.window_start(((("Code for" + obj) + ".") + method) + " --", "code", 0, 0, 1);
// .pueblo_code("form method=xch_cmd");
// .pueblo_code("textarea rows=25 cols=80");
.print((("program " + obj) + ".") + method);
catch any
.print(obj.decompile(tosym(method)));
with
.print("Method not found.");
.print(".");
// .pueblo_code("/textarea");
// .pueblo_code("/form");
.window_end();
};
public method .prog_cmd() {
arg obj, method;
var vc, r;
if ((obj[1]) == "$")
obj = lookup(tosym(obj.subrange(2)));
else if ((obj[1]) == "#")
obj = toobjnum(toint(obj.subrange(2)));
else
obj = obj.match_object();
if (!obj)
return "Unknown object.";
.print(((("(Programming " + obj) + ".") + method) + ")");
(.curcon()).print("Enter method code, type . to end.");
vc = [];
while ((r = .read()) != ".")
vc = [@vc, r];
.print((obj.add_method(vc, tosym(method))) || "Method programmed.");
};
public method .title() {
arg who, options, @amount;
var suffix;
// This handles all text cosmetics, including invisibility.
// It should be easy to add Pueblo/RIP/html codes.
suffix = "";
if (holder) {
suffix = " (held by " + (holder.name());
if (holder.flying())
suffix += (", " + (holder.flying())) + " stories up";
suffix += ")";
} else if (flying) {
suffix = (flying == 1) ? " (flying)" : ((" (flying " + flying) + " stories up)");
}
if (who == this()) {
return "you";
} else if (.is_visible_to(who)) {
if (('pueblo in options) && ((who.location()) == (.location())))
return (((("<a xch_cmd=\"look at " + (.name())) + "\">") + (.name())) + suffix) + "</a>";
else
return (.name()) + suffix;
} else {
return "someone";
}
};
public method .home() {
arg @args;
if ((listlen(args) == 1) && (type(args[1]) == 'objnum))
home = args[1];
else if (args)
throw(~numargs, "Called with too many or invalid arguments.");
else
return home || (($room.children())[1]);
};
public method .new() {
arg name, pwd;
var new, x, lname;
// for x in (["[", "]", "#", "$", " ", ".", "\", "\""]) {
// if (x in name)
// throw(~name, "Name contains invalid characters.");
// }
if (!($player.name_ok(name)))
throw(~name, "Name already in use at this MUD!");
for x in ($distrib_conn.children()) {
if ((x.connected()) && (((<$distrib, [tosym(tostr(x).subrange(2)), 'player], 'handle>).name_ok(name)) == ~name))
throw(~name, "Name already in use at another MUD!");
}
new = .create();
new.creation_time(time());
new.name(name);
new.password(pwd);
lname = "";
for x in [1 .. strlen(name)] {
if ((name[x]) in "abcdefghijklmnopqrstuvwxyz")
lname = lname + ((name[x]).lowercase());
}
if ((| lookup(tosym("user_" + lname)) |))
lname = (lname + "_") + random(2000000000);
new.set_objname(tosym("user_" + lname));
return new;
};
public method .password() {
arg @args;
if ((listlen(args) == 1) && (type(args[1]) == 'string))
password = args[1];
else if (args)
throw(~numargs, "Called with too many arguments. Requires zero or one.");
else
return password;
};
public method .remove_connection() {
arg conn;
var x;
connections = setremove(connections || [], conn);
if (!connections) {
.windows([]);
for x in ($player.children()) {
if ((| "who" in (x.windows()) |))
(| x.who_cmd('pueblo) |);
}
(.location()).dumb_announce((.name()) + " has disconnected.");
.home(.location());
.move(0);
if ((.password()) == "TEMPORARY CHARACTER")
.destroy();
}
};
public method .add_connection() {
arg conn;
var x;
if (!connections) {
connections = setadd(connections || [], conn);
// Fresh connection; no windows yet.
.window_info([0, [0, 0], 0, []]);
windows = [];
for x in ($player.children()) {
if ("who" in (x.windows()))
x.who_cmd('pueblo);
}
catch any {
// Take 'em home
(.home()).dumb_announce((.name()) + " has connected.");
$sys.set_user();
.move(.home());
} with {
.print("Can't move to home.");
(| .move(($room.children())[1]) |);
}
} else {
connections = setadd(connections || [], conn);
}
if ('pueblo in (conn.display_options())) {
conn.print(str_to_buf("<xch_pane name=login action=close><body fgcolor=#FEDCBA>"));
// Display the Pueblo toolbar...
}
last_connect_time = time();
};
public method .print() {
arg line;
var x, y;
if (type(line) == 'string) {
if ((y = line.match_pattern("[LEARN:*,*]*"))) {
if ((| (($sys.user()).skills())[tosym(y[1])] |) > (| (.skills())[tosym(y[1])] |))
.skills(tosym(y[1]), toint(y[2]));
line = y[3];
}
}
switch (type(line)) {
case 'string:
for x in (connections || []) {
if ('pueblo in (x.display_options()))
x.print(((line.replace("&", "&")).replace("<", "<")).replace(">", ">"));
else
x.print(line);
}
case 'list:
for y in (line) {
for x in (connections || []) {
if ('pueblo in (x.display_options()))
x.print(((y.replace("&", "&")).replace("<", "<")).replace(">", ">"));
else
x.print(y);
}
}
case 'buffer:
for x in (connections || [])
x.print(line);
}
};
public method .notify() {
arg @args;
var x, y, pargs, bah, berr;
// Pueblo codes should never be sent to the player itself.
// Always to the connection. Thus, we do pueblocode substitution here.
bah = args[1];
if (type(bah) == 'list) {
bah = (| bah[1] |);
berr = 1;
}
if (type(bah) == 'string) {
if ((y = bah.match_pattern("[LEARN:*,*]*"))) {
if ((| ((($sys.user()).skills())[tosym(y[1])]) > ((| (.skills())[tosym(y[1])] |) || 0) |))
.skills(tosym(y[1]), toint(y[2]));
if (berr)
args = args.replace(1, (args[1]).subrange(2));
else
args = args.replace(1, y[3]);
}
}
for x in (.connections()) {
if ('pueblo in (x.display_options())) {
if (!pargs) {
pargs = [];
for y in (args)
pargs = [@pargs, (type(y) == 'string) ? ((y.replace("&", "&")).replace("<", "<")).replace(">", ">") : y];
}
} else {
pargs = args;
}
x.notify(@pargs);
}
};
public method .eval_cmd() {
arg @line;
var object, i, r, evaltemp;
line = line[listlen(line)];
object = this();
if ((i = "|" in line)) {
object = lookup(tosym(line.subrange(1, i - 1)));
line = line.subrange(i + 1);
}
if (!(";" in line))
line = "return " + line;
evaltemp = tosym("evaltemp_" + random(2000000000));
r = object.add_method([(".del_method(" + toliteral(evaltemp)) + ");", line + ";"], evaltemp);
r = object.(evaltemp)();
.print("=> " + toliteral(r));
};
public method .parse_line() {
arg line;
var a, x, y, places, i, data, msginfo, b;
// Object return codes:
// "string" -> displays "string" to the user, IF nothing else parses.
// For example, when you can't get a certain object, it will display
// "You can't get that" only if you don't pick up something else.
// [list] -> calls conn.notify(@list,@data);
// (@data defaults to empty)
// ['again,DATA or 0,newcmd,[program,<message>,<data>]] -> parses the line again, from the next
// object, not from the start. Useful for: "get 10 blah"
// will return ['again,"get 9 blah",$someobj]. "get 1 blah" or
// "get blah" will return:
// ['stop,DATA,Program,"{o} {v/gets} {s/2}",$sys.user()]
// ['stop,data,program,message,data];
// Program can be one of:
// 'announce: Announce to the room
// 'notify: Notify only the sending connection.
// 'print: Notify all of the player's connections.
// This will stop the looping of 'get', and will notify the connection
// of ("{o} {v/gets} {s/2}.",$sys.user(),DATAS)
// The third argument sent to conn.notify will be a collection of
// *all* the DATA returned.
if (!line)
return 1;
$sys.set_user();
data = [];
places = [this()];
if (.location())
places = [this(), .location(), @(| setremove((.location()).contents(), this()) |) || [], @.all_contents()];
for y in (places) {
for x in (y.commands()) {
if (((!('private in x)) || (this() == y)) && (((b = line.match_template(x[1])) || (b = line.match_pattern(x[1]))) && (a = y.(x[2])(@b)))) {
if (type(a) == 'list) {
switch (a[1]) {
case 'again:
data = [@data, a[2]];
line = a[3];
msginfo = [@a[4], data];
continue;
case 'stop:
return [@a.subrange(3), [@data, a[2]]];
}
} else if (type(a) == 'string) {
if (!msginfo)
msginfo = a;
continue;
}
return a;
}
// Should check to see if the first word matches, and the offer help.
}
refresh();
}
if (!msginfo)
msginfo = $socials.check_social(line);
return msginfo;
};
public method .localedit_cmd() {
arg obj, method;
if ((obj[1]) == "$")
obj = lookup(tosym(obj.subrange(2)));
else if ((obj[1]) == "#")
obj = toobjnum(toint(obj.subrange(2)));
else
obj = obj.match_object();
if (!obj)
return "Unknown object.";
(.curcon()).print((("#$# edit name: METHOD upload: program " + obj) + ".") + method);
(.curcon()).print(obj.decompile(tosym(method)));
(.curcon()).print(".");
};
public method .roomflag_cmd() {
arg verb, flag;
if (!flag) {
.print(("Room flags: [ " + (((.location()).flags()).combine(" "))) + " ]");
return;
}
if (!(| (flag = tosym(flag)) |))
return "Invalid flag.";
if ((.level()) < 105) {
if ((((.location()).zone()).owner()) != (.lord()))
return "This isn't your lord's land.";
if ((.skills('building)) < random(100))
return "You try but fail miserably.";
if (!(flag in ['dark, 'inside, 'outside]))
return "You can't do that.";
}
if (flag in ((.location()).flags())) {
(.location()).remove_flag(flag);
return "Flag removed.";
}
(.location()).add_flag(flag);
return "Flag added.";
};
public method .describe_cmd() {
arg verb, obj;
var vc, r;
if (obj == "here")
obj = .location();
else if ((obj[1]) == "$")
obj = lookup(tosym(obj.subrange(2)));
else if ((obj[1]) == "#")
obj = toobjnum(toint(obj.subrange(2)));
else
obj = obj.match_object();
if (!obj)
return "Unknown object.";
.print("Setting description.");
(.curcon()).print("Enter description text, type . to end.");
vc = [];
while ((r = .read()) != ".")
vc = [@vc, r];
.print("Description set.");
obj.description(vc);
};
public method .name_cmd() {
arg verb, obj, prep, name;
if (obj == "here")
obj = .location();
else if ((obj[1]) == "$")
obj = lookup(tosym(obj.subrange(2)));
else if ((obj[1]) == "#")
obj = toobjnum(toint(obj.subrange(2)));
else
obj = obj.match_object();
if (!obj)
return "Unknown object.";
if (((.level()) < 103) && (((obj.creator()) != ($sys.user())) && (!(((.level()) == 102) && (obj.has_ancestor($room))))))
return "You can't name something you didn't create.";
obj.name(name);
return "Name set.";
};
public method .puebloedit_cmd() {
arg obj, method;
if ((obj[1]) == "$")
obj = lookup(tosym(obj.subrange(2)));
else if ((obj[1]) == "#")
obj = toobjnum(toint(obj.subrange(2)));
else
obj = obj.match_object();
if (!obj)
return "Unknown object.";
.print(str_to_buf(((("<form method=xch_cmd><textarea name=\"" + obj) + ".") + method) + "\" rows=20 cols=80>"));
.print(obj.decompile(tosym(method)));
.print(str_to_buf("</textarea><input type=submit value=Reprogram></form>"));
};
public method .messages_cmd() {
arg verb, obj;
var x, msg, t, n;
if (type((t = (| ((.location()).exits())[tosym(obj)] |))) == 'dictionary) {
if (!t)
return "There are no defined messages on that.";
for x in (t)
.print((((("@" + (x[1])) + " ") + obj) + " is ") + toliteral(x[2]));
return;
} else if ((obj[1]) == "$") {
obj = lookup(tosym(obj.subrange(2)));
} else if ((obj[1]) == "#") {
obj = toobjnum(toint(obj.subrange(2)));
} else {
obj = obj.match_object();
}
if (!obj)
return "I haven't got a clue what you're talking about.";
if (!(msg = obj.messages()))
return "There are no defined messages on that.";
for x in (msg)
.print((((("@" + x) + " ") + obj) + " is ") + toliteral(obj.get_message(x)));
};
public method .wall_cmd() {
arg verb, direction;
var fs, zone, room, opdir, skill, resources, x, rc;
fs = .location();
if ((!('inside in (fs.flags()))) && (!('outside in (fs.flags()))))
return "You can't build here; The room is neither inside or outside.";
else if ((fs.name()) == "(Unnamed)")
return "You can't build here; The room is unnamed.";
else if ((fs.description()) == ["You see nothing important."])
return "You can't build here; The room in undescribed.";
else if (!(zone = fs.zone()))
return "You can't build here; The room has no zone.";
else if (((fs.xyz())[1]) > 1000000000)
return "You can't build here; The room's xyz is not set properly.";
opdir = ['north, 'south, 'east, 'west, 'up, 'down][(direction[1]) in "snwedu"];
direction = ['north, 'south, 'east, 'west, 'up, 'down][(direction[1]) in "nsewud"];
if ((| (fs.exits())[direction] |) == ~keynf)
return "There already is a wall there.";
if ('tree in ((room = fs.exit_destination(direction)).flags()))
return "You can't build in a forest.";
if ((.level()) < 104) {
if (!(skill = .skills('building)))
return "You don't know how to do that.";
if ((((.location()).zone()).owner()) != (.lord()))
return "But this is not your Lord's land!";
// 5 points for trying.
.skills('building, 5);
if (random(100) > skill)
return "You try but fail miserably.";
resources = [];
for x in [1 .. (((-skill) + 1000) / 300) + 2]
resources = [@resources, 'wood, 'stone];
if (!(.take_resource(#[['wood, (((-skill) + 1000) / 300) + 2], ['stone, (((-skill) + 1000) / 300) + 2]])))
return ("Resources needed: " + ((((-skill) + 1000) / 300) + 2)) + " wood & stone.";
.set_busy(((-skill) + 1000) / 25, ("Building " + direction) + "...");
}
fs.exits(dict_del(fs.exits(), direction));
room.exits(dict_del(room.exits(), opdir));
fs.announce(("[LEARN:building,2]{o} {v/builds} a wall to the " + direction) + ".", $sys.user());
room.announce(("[LEARN:building,2]{o} {v/builds} a wall to the " + opdir) + ".", $sys.user());
if ((listlen((rc = room.connections())) < listlen(fs.connections())) && (!((($room.children())[1]) in (room.connections())))) {
for x in (rc)
x.destroy();
}
};
public method .toggle() {
arg @args;
if (!args)
return toggles || [];
if (!toggles)
toggles = [];
if ((args[1]) in toggles) {
toggles = setremove(toggles, args[1]);
return 0;
} else {
toggles += args;
return 1;
}
};
public method .paste_cmd() {
arg @args;
var text, x;
.print("Enter lines of text, '.' to end, '.abort' to abort.");
text = [];
while ((x = .read()) != ".") {
if (x == ".abort")
return "Aborted.";
else if ((| x[1] |) == ".")
x = x.subrange(2);
text = [@text, x];
}
for x in ((.location()).contents())
(| x.pueblo_code("code") |);
(.location()).announce("{c/1/78/-}", " {o/2} ", $sys.user());
(.location()).dumb_announce(text);
(.location()).announce("{c/1/78/-}", " {o/2} ", $sys.user());
for x in ((.location()).contents())
(| x.pueblo_code("/code") |);
};
public method .lord() {
arg @args;
var x;
if (args) {
lord = args[1];
for x in ($login.connected_players()) {
if ("who" in (x.windows()))
x.who_cmd();
}
}
return lord || (($player.children())[1]);
};
public method .appoint_cmd() {
arg verb, who, prep, what;
var app, alv, vlv, dlv, kq, x;
if (!(| (app = lookup(tosym("user_" + (who.lowercase())))) |))
return "Appoint who?";
alv = .level();
vlv = app.level();
dlv = ((what[1]) in "NHDLAKGI") + 98;
if (dlv == 98)
dlv = 104;
if (dlv == 99) {
app.level(0);
.print((app.name()) + " loses social status.");
app.print("You've lost your social status!");
} else if ((alv in [104, 105, 106]) && (dlv == 104)) {
kq = ((app.gender()) == "female") ? "Queen" : "King";
app.lord(this());
app.level(104);
app.print(((("You have been appointed to " + kq) + " by ") + (.name())) + "!");
.print((((app.name()) + " is now a ") + kq) + ".");
} else if ((alv == 103) && (dlv == 104)) {
kq = ((app.gender()) == "female") ? "Queen" : "King";
for x in ($player.children()) {
if ((x.level()) == 104)
return ((("Appointing a new " + kq) + " is ") + (x.name())) + "'s job at the moment.";
}
app.lord(this());
app.level(104);
app.print(((("You have been appointed to " + kq) + " by ") + (.name())) + "!");
.print((((app.name()) + " is now a ") + kq) + ".");
} else if ((alv in [104, 105, 106]) && (dlv == 103)) {
app.lord(this());
app.level(103);
app.print(("You have been appointed to Advisor by " + (.name())) + "!");
.print((app.name()) + " is now an Advisor.");
} else if ((alv in [103, 104, 105, 106]) && (dlv == 102)) {
app.lord(this());
app.level(102);
app.print(("You have been appointed to Lord by " + (.name())) + "!");
.print((app.name()) + " is now a Lord.");
} else if ((alv in [102]) && (dlv == 101)) {
if ((app.lord()) != this())
return ("You are not " + (app.name())) + "'s Lord.";
app.level(101);
app.print(("You have been appointed to Disciple by " + (.name())) + "!");
.print((app.name()) + " is now your Disciple.");
} else if ((alv in [102, 103, 104, 105, 106]) && (dlv == 100)) {
app.level(100);
app.print(("You have been appointed to Hero by " + (.name())) + "!");
.print((app.name()) + " is now a hero.");
} else if ((alv in [101]) && (dlv == 102)) {
if (app == (.lord()))
return "No change.";
.level(100);
.print("You are demoted to Hero.");
.lord(app);
.print((app.name()) + " is now your new Lord.");
} else if ((alv < 101) && (dlv == 102)) {
if (((.lord_change_time()) + 14400) > time())
return "You can't change your lord within 4 hours.";
if ((app.level()) != 102)
return (app.name()) + " isn't a lord!";
if (app == (.lord()))
return "No change.";
.lord(app);
.print((app.name()) + " is now your new Lord.");
.lord_change_time(time());
} else if ((alv in [106]) && (dlv == 105)) {
app.lord(this());
app.level(105);
app.print(("You have been appointed to GOD by " + (.name())) + "!");
.print((app.name()) + " is now a GOD.");
} else if ((alv in [106]) && (dlv == 106)) {
app.lord(this());
app.level(106);
app.print(("You have been appointed to IMPLEMENTOR by " + (.name())) + "!");
.print((app.name()) + " is now an implementor.");
} else {
return "You can't do that.";
}
};
public method .can_wear() {
arg what;
var x, amt, bp;
bp = what.bodypart();
for x in ((.contents('clothing)) + (.contents('equipment))) {
if ((x.bodypart()) == bp)
amt = amt + (x.percent());
}
return (amt + (what.percent())) <= 100;
};
public method .eq_cmd() {
arg verb;
var list, title, names, amounts, x, len, stuff, z, pre;
pre = "";
if (verb == 'pueblo)
pre = "{q/pueblo}";
.window_start("Equipment and clothing", "equipment", 350, 100, 1);
stuff = [@.contents('equipment), @.contents('clothing)];
names = (amounts = []);
for x in (stuff) {
title = x.title(this(), []);
if (!(x.is_visible_to(this()))) {
;
} else if ((len = title in names)) {
amounts = amounts.replace(len, [(amounts[len])[1], ((amounts[len])[2]) + 1]);
} else {
names += [title];
amounts += [[x, 1]];
}
refresh();
}
.notify(pre + "Equipment:");
for x in (amounts) {
for z in (.connections())
z.notify(((((((pre + " ") + ((x[1]).title(this(), z.display_options()))) + " (") + ((x[1]).bodypart())) + " ") + ((x[1]).percent())) + "%)");
}
.notify(pre + "--");
.window_end();
};
public method .window_start() {
arg wintitle, winname, width, ht, clear;
var x, winstr, did;
if (type(winname) in ['frob, 'objnum])
winname = winname.name();
else
winname = winname + "";
winstr = ((((((((((("<xch_pane action=redirect width=" + width) + " height=") + ht) + " name=\"") + winname) + "\" panetitle=\"") + wintitle) + "\" options=\"floating ") + (width ? "" : "fit ")) + "persistent small_title noclose\">") + (clear ? "<xch_page clear=text>" : "")) + "<font size=3><code>";
for x in ((.connections()).setremove(.curcon())) {
if ('pueblo in (x.display_options()))
x.print(str_to_buf(("<xch_pane action=close name=\"" + winname) + "\">"));
}
if ('pueblo in ((.curcon()).display_options())) {
if (!(winname in (.badwindows())))
(.curcon()).print(str_to_buf(winstr));
// MAKE SURE the FIRST element is the new window, for window_end
windows = [winname, @setremove(.windows(), winname)];
}
};
public method .window_end() {
var x, what;
what = (| str_to_buf(("</code></font><a xch_cmd=\"PUEBLOCLOSE " + ((.windows())[1])) + "\" xch_hint=\"Close this window\"><FONT SIZE=2 fgcolor=FF0000>Close</font></a><xch_pane action=redirect name=_top>") |);
// <img border=0 src=http://moo.syr.edu/~fool/MOO/gifs/cancel.gif>
if ('pueblo in ((.curcon()).display_options())) {
if (((.windows())[1]) in (.badwindows()))
.windows((.windows()).setremove((.windows())[1]));
else
(.curcon()).print(what);
}
};
public method .windows() {
arg @args;
if (args)
windows = args[1];
return windows || [];
};
public method .puebloclose_cmd() {
arg verb, win;
var what, x;
.pueblo_code(("xch_pane action=close name=\"" + win) + "\"");
windows = setremove(windows, win);
};
public method .str() {
arg @args;
var rstat, varn, x;
// .str() -> Modified stat
// .str(1) -> Unmodified stat
// .str(3-20) -> Set unmodified stat
varn = tosym("stat_" + method());
if (args && ((args[1]) > 2)) {
set_var(tosym("stat_" + method()), args[1]);
if ("score" in (.windows()))
.score_cmd('pueblo);
}
rstat = get_var(varn);
if (!rstat)
set_var(varn, (rstat = (random(6) + random(6)) + random(6)));
if (!args) {
for x in (.contents('equipment))
rstat = x.modify(varn, rstat);
}
return rstat;
};
public method .entered() {
arg what, dkey;
if ('pueblo in ((.curcon()).display_options())) {
if ((what.name()) in (.windows()))
what.look_cmd('pueblo, what.name());
if ((dkey == 'inventory) && ("inventory" in (.windows())))
.inventory_cmd('pueblo);
else if ((dkey in ['clothing, 'equipment]) && ("equipment" in (.windows())))
.eq_cmd('pueblo);
if ((dkey == 'equipment) && ("score" in (.windows())))
.score_cmd('pueblo);
}
};
public method .exited() {
arg what, skey;
if ((what.name()) in (.windows()))
what.look_cmd('pueblo, what.name());
if ('pueblo in ((.curcon()).display_options())) {
if ((skey == 'inventory) && ("inventory" in (.windows())))
.inventory_cmd('pueblo);
else if ((skey in ['clothing, 'equipment]) && ("equipment" in (.windows())))
.eq_cmd('pueblo);
if ((skey == 'equipment) && ("score" in (.windows())))
.score_cmd('pueblo);
}
};
public method .dex() {
arg @args;
var rstat, varn, x;
// .str() -> Modified stat
// .str(1) -> Unmodified stat
// .str(3-20) -> Set unmodified stat
varn = tosym("stat_" + method());
if (args && ((args[1]) > 2)) {
set_var(tosym("stat_" + method()), args[1]);
if ("score" in (.windows()))
.score_cmd('pueblo);
}
rstat = get_var(varn);
if (!rstat)
set_var(varn, (rstat = (random(6) + random(6)) + random(6)));
if (!args) {
for x in (.contents('equipment))
rstat = x.modify(varn, rstat);
}
return rstat;
};
public method .con() {
arg @args;
var rstat, varn, x;
// .str() -> Modified stat
// .str(1) -> Unmodified stat
// .str(3-20) -> Set unmodified stat
varn = tosym("stat_" + method());
if (args && ((args[1]) > 2)) {
set_var(tosym("stat_" + method()), args[1]);
if ("score" in (.windows()))
.score_cmd('pueblo);
}
rstat = get_var(varn);
if (!rstat)
set_var(varn, (rstat = (random(6) + random(6)) + random(6)));
if (!args) {
for x in (.contents('equipment))
rstat = x.modify(varn, rstat);
}
return rstat;
};
public method .wis() {
arg @args;
var rstat, varn, x;
// .str() -> Modified stat
// .str(1) -> Unmodified stat
// .str(3-20) -> Set unmodified stat
varn = tosym("stat_" + method());
if (args && ((args[1]) > 2)) {
set_var(tosym("stat_" + method()), args[1]);
if ("score" in (.windows()))
.score_cmd('pueblo);
}
rstat = get_var(varn);
if (!rstat)
set_var(varn, (rstat = (random(6) + random(6)) + random(6)));
if (!args) {
for x in (.contents('equipment))
rstat = x.modify(varn, rstat);
}
return rstat;
};
public method .int() {
arg @args;
var rstat, varn, x;
// .str() -> Modified stat
// .str(1) -> Unmodified stat
// .str(3-20) -> Set unmodified stat
varn = tosym("stat_" + method());
if (args && ((args[1]) > 2)) {
set_var(tosym("stat_" + method()), args[1]);
if ("score" in (.windows()))
.score_cmd('pueblo);
}
rstat = get_var(varn);
if (!rstat)
set_var(varn, (rstat = (random(6) + random(6)) + random(6)));
if (!args) {
for x in (.contents('equipment))
rstat = x.modify(varn, rstat);
}
return rstat;
};
public method .cha() {
arg @args;
var rstat, varn, x;
// .str() -> Modified stat
// .str(1) -> Unmodified stat
// .str(3-20) -> Set unmodified stat
varn = tosym("stat_" + method());
if (args && ((args[1]) > 2)) {
set_var(tosym("stat_" + method()), args[1]);
if ("score" in (.windows()))
.score_cmd('pueblo);
}
rstat = get_var(varn);
if (!rstat)
set_var(varn, (rstat = (random(6) + random(6)) + random(6)));
if (!args) {
for x in (.contents('equipment))
rstat = x.modify(varn, rstat);
}
return rstat;
};
public method .statstr() {
arg stat;
var rstat, mstat, temp;
rstat = .(stat)(1);
mstat = .(stat)() - rstat;
if (mstat == 0)
temp = "";
else if (mstat > 0)
temp = (" (+" + mstat) + ")";
else
temp = (" (" + mstat) + ")";
return rstat + temp;
};
public method .score_cmd() {
arg verb;
var stuff, pre, h, temp, x, temp2;
pre = "";
if ('pueblo == verb)
pre = "{q/pueblo}";
.window_start("Score and Statistics:", "score", 500, 100, 1);
.pueblo_code("code");
h = .health();
.notify((((((pre + "Name: ") + (.name())) + " Gender: ") + (.gender())) + " Level: ") + (.level()));
.notify(pre + "{l/1/20}{l/2/20}{l/3/20}", "Str: " + (.statstr('str)), "Wis: " + (.statstr('wis)), "Minor wounds: " + (h[1]));
.notify(pre + "{l/1/20}{l/2/20}{l/3/20}", "Dex: " + (.statstr('dex)), "Int: " + (.statstr('int)), "Major wounds: " + (h[2]));
.notify(pre + "{l/1/20}{l/2/20}{l/3/20}", "Cha: " + (.statstr('cha)), "Con: " + (.statstr('con)), "Fatal wounds: " + (h[3]));
if (.skills()) {
.notify(pre + "-- Skills:");
temp = [];
for x in (.skills()) {
temp2 = "";
if ((x[2]) != (.skills(x[1]))) {
h = (.skills(x[1])) + (x[2]);
if (h > 0)
temp2 = (" (+" + h) + ")";
else
temp2 = (" (" + h) + ")";
}
if ((!temp) || (listlen(temp[1]) == 3))
temp = [[(((x[1]) + ": ") + (x[2])) + temp2], @temp];
else
temp = [[@temp[1], (((x[1]) + ": ") + (x[2])) + temp2], @temp.subrange(2)];
}
for x in (temp)
.notify(pre + "{l/1/20}{l/2/20}{l/3/20}", @x, "", "");
}
.pueblo_code("/code");
.window_end();
};
public method .pueblo_code() {
arg str;
var x;
str = str_to_buf(("<" + str) + ">");
for x in (.connections()) {
if ('pueblo in (x.display_options()))
x.print(str);
}
};
public method .destroy() {
arg @args;
var x;
for x in (.connections())
x.destroy();
return pass(@args);
};
public method .creation_time() {
arg @args;
if (args)
creation_time = args[1];
return creation_time;
};
public method .busy() {
arg @args;
if (args)
busy = args[1];
return busy || [];
};
public method .set_busy() {
arg duration, @msg;
var x, total;
// .set_busy(duration,"You finish blah blah...")
// -> immediate 0 -- No busy.
// -> pause 1 -- Was busy.
if ((.busy()) && (((.busy())[1]) < time()))
.busy(0);
if (!(.busy())) {
if (duration)
.busy([time() + duration, msg[1]]);
return 0;
}
total = ((.busy())[1]) - time();
if (duration)
.busy([((.busy())[1]) + duration, msg[1]]);
(.curcon()).print("Busy: " + ((.busy())[2]));
$sys.suspend(total);
return 1;
};
public method .image_cmd() {
arg @args;
var what, x;
what = args[listlen(args)];
for x in ((.location()).contents())
(| x.pueblo_code(("img href=" + what) + "><br") |);
(.location()).announce("{o} activated Pueblo multimedia...", $sys.user());
};
public method .health() {
return health || [0, 0, 0];
};
public method .change_health() {
arg change;
var h;
// .change_health(+heal/-hurt) -> .health()
h = .health();
h = h.replace(1, (h[1]) + change);
while ((h[1]) > 20)
h = [(h[1]) - 20, (h[2]) + 1, h[3]];
while ((h[1]) < 0)
h = [(h[1]) + 20, (h[2]) - 1, h[3]];
while ((h[2]) > 5) {
h = [h[1], (h[2]) - 5, (h[3]) + 1];
(.location()).announce("{o} {v/is/are} fatally wounded and will soon die if not aided.", this());
}
while ((h[2]) < 0) {
h = [h[1], (h[2]) + 5, (h[3]) - 1];
.print("Your wounds have healed.");
}
if ((h[3]) > 1) {
// DEAD.
}
health = h;
if ("score" in (.windows()))
.score_cmd('pueblo);
return h;
};
public method .look_cmd() {
arg verb, what;
var h, info, list, title, names, amounts, x, len, stuff, z;
info = [];
if ("at " in what)
what = what.subrange(4);
if ((!what) || (!(.is_this(what))))
return "I don't see that here.";
($sys.user()).window_start(.name(), "lookplayer", 300, 100, 1);
($sys.user()).print(.name());
($sys.user()).print(.description());
h = .health();
if ((h[1]) > 15)
info = info.setadd("many bruises and scratches");
else if ((h[1]) > 5)
info = info.setadd("a few bruises and scratches");
if ((h[2]) > 3)
info = info.setadd("several large open wounds");
else if ((h[2]) > 1)
info = info.setadd("a couple large wounds");
else if ((h[2]) == 1)
info = info.setadd("a large wound");
if (h[3]) {
info = info.setadd(("a big bleeding opening in " + (.pp())) + " chest");
info = info.setadd("will soon die if not aided");
}
($sys.user()).notify(((.ps()) + (info ? " has " + (info.english_list()) : " is in perfect condition")) + ".");
stuff = [@.contents('equipment), @.contents('clothing)];
names = (amounts = []);
for x in (stuff) {
title = x.title($sys.user(), []);
if (!(x.is_visible_to($sys.user()))) {
;
} else if ((len = title in names)) {
amounts = amounts.replace(len, [(amounts[len])[1], ((amounts[len])[2]) + 1]);
} else {
names += [title];
amounts += [[x, 1]];
}
refresh();
}
($sys.user()).notify("Equipment:");
for x in (amounts)
($sys.user()).print((((((" " + ((x[1]).title(this(), []))) + " (") + ((x[1]).bodypart())) + " ") + ((x[1]).percent())) + "%)");
($sys.user()).window_end();
};
public method .skills() {
arg @args;
var rsk, x;
// .skills() -> dictionary SKILLS
// (EXCLUDING unlearned skills)
// .skills(skill) -> modified skill
// .skills(skill,difference) -> original+difference
if ((args.length()) == 1) {
if (!((args[1]) in ($player.skills())))
throw(~skill, "No such skill.");
rsk = (| skills[args[1]] |) || 0;
for x in (.contents('equipment))
rsk = x.modify(args[1], rsk);
return rsk;
} else if (args) {
if (!((args[1]) in ($player.skills())))
throw(~skill, "No such skill.");
skills = (.skills()).dict_add(args[1], min((rsk = ((| (.skills())[args[1]] |) || 0) + (args[2])), 10000));
if ("score" in (.windows()))
.score_cmd('pueblo);
if (rsk == 0)
skills = (.skills()).dict_del(args[1]);
return rsk;
}
return skills || #[];
};
public method .practice_cmd() {
arg verb, what;
var curskill, skillgain;
what = tosym(what);
if ((| ((.skills())[what]) > 100 |))
skillgain = 3;
else
skillgain = 1;
catch ~skill {
.set_busy(60, "You finish your practicing...");
.skills(what, skillgain);
.print(("You practice " + what) + " for a minute.");
} with {
.print("You couldn't even dream of making up such a skill.");
}
};
public method .set_skills() {
arg what;
skills = what;
};
public method .click_cmd() {
arg x, y;
var z;
x = toint(x.subrange(2));
y = toint(y);
for z in ((.window_info())[4]) {
if (((z[1]) < x) && (((z[2]) < y) && (((z[3]) > x) && ((z[4]) > y)))) {
$login.do_parse(z[5], .curcon());
return;
}
}
};
public method .setxy_cmd() {
arg verb;
var x1, y1, x2, y2, r, wi, codes;
.print("Click upper-left corner:");
r = .read();
x1 = toint(r.subrange(8, ("," in r) - 8));
y1 = toint(r.subrange(("," in r) + 1));
.print("Click lower-right corner:");
r = .read();
x2 = toint(r.subrange(8, ("," in r) - 8));
y2 = toint(r.subrange(("," in r) + 1));
.print("Type command to be executed:");
r = .read();
wi = .window_info();
if ((wi[2])[1]) {
codes = (| ((((wi[2])[1]).exits())[(wi[2])[2]])['codes] |) || [];
codes = codes.setadd([x1, y1, x2, y2, r]);
((wi[2])[1]).exits((((wi[2])[1]).exits()).dict_add((wi[2])[2], ((((wi[2])[1]).exits())[(wi[2])[2]]).dict_add('codes, codes)));
} else {
codes = (.location()).picture_codes();
codes = codes.setadd([x1, y1, x2, y2, r]);
(.location()).picture_codes(codes);
}
.print("You need to re-enter the room for changes to take effect.");
};
public method .window_info() {
arg @args;
// returns ["pictureURL",[sourceroom,exitsymbol],destroom,[[left,top,right,bottom,"command"],...]]
if (args) {
if (((args[1])[1]) && ((args[1])[3])) {
.window_start("Current Room", "room", 600, 400, 1);
.pueblo_code("a xch_cmd=\"CLICK \"");
.pueblo_code("img border=0 ismap src=" + ((args[1])[1]));
.pueblo_code("/a");
.pueblo_code("br");
.window_end();
}
window_info = args[1];
}
return window_info || ["", [0, 0], 0, []];
};
public method .echo_cmd() {
arg verb, what;
if (("[" in what) == 1)
what = " " + what;
.print(what);
};
public method .set_health() {
arg ta;
health = ta;
};
public method .take_resource() {
arg kinds;
var togo, x, bye, k;
// Returns 0 if the player doesn't have the resources,
// otherwise removes the resources from inventory.
// and returns 1
if (type(kinds) == 'dictionary) {
togo = kinds;
} else {
togo = #[];
for x in (kinds)
togo = togo.add(x, (| togo[x] |) ? (togo[x]) + 1 : 1);
}
bye = [];
for x in (.contents()) {
if (((x.parents()) == [$resource]) && ((k = x.kind()) in (togo.keys()))) {
if ((x.amount()) < (togo[k])) {
return 0;
} else {
bye += [[x, togo[k]]];
togo = togo.del(k);
}
}
}
if (togo)
return 0;
for x in (bye)
(x[1]).move_kind(x[2], 0);
return 1;
};
public method .set_message_cmd() {
arg what, obj, result;
var x, msg, t, n;
if (type((t = (| ((.location()).exits())[tosym(obj)] |))) == 'dictionary) {
if (result) {
t = dict_add(t, tosym(what), result.fromliteral());
.print("Message set.");
} else {
t = dict_del(t, tosym(what));
.print("Message deleted.");
}
(.location()).exits(dict_add((.location()).exits(), tosym(obj), t));
return;
} else if ((obj[1]) == "$") {
obj = lookup(tosym(obj.subrange(2)));
} else if ((obj[1]) == "#") {
obj = toobjnum(toint(obj.subrange(2)));
} else {
obj = obj.match_object();
}
if (!(msg = obj.messages()))
return "There are no defined messages on that.";
obj.set_message(tosym(what), result.fromliteral());
};
public method .newplayer_cmd() {
arg v, n, j, p, g;
var who;
if (type((who = $player.new(n, p))) == 'objnum) {
who.gender((g = ["male", "female", "neuter"][(g[1]) in "mfn"]));
return ((((n + " created with password ") + p) + " and gender ") + g) + ".";
}
return "Error!";
};
public method .low_describe_cmd() {
arg verb, obj;
var vc, r, x, skill;
if (obj == "here")
obj = .location();
else if ((obj in ["me", "myself"]) || (.is_this(obj)))
obj = this();
else
obj = obj.match_object();
if ((!obj) || (type(obj) != 'objnum))
return "Unknown object.";
if (obj != this()) {
if (obj.has_ancestor($room)) {
if (!(skill = (.skills())['building]))
return "You don't know how to do that.";
if ((((.location()).zone()).owner()) != (.lord()))
return "But this is not your Lord's land!";
// 5 points for trying.
.skills('building, 5);
if (random(100) > skill)
return "You try but fail miserably.";
resources = [];
for x in [1 .. (((-skill) + 1000) / 300) + 2]
resources = [@resources, 'wood, 'stone];
if (!(.take_resources(resources)))
return ("Resources needed: " + ((((-skill) + 1000) / 300) + 2)) + " wood & stone.";
.set_busy(((-skill) + 1000) / 20, "You finish the appearance of the room...");
} else if ((obj.creator()) != this()) {
return "You aren't creating that; you can't describe it.";
} else {
.set_busy(20, "You finish the description...");
}
}
.print("Setting description.");
(.curcon()).print("Enter description text, type . to end.");
vc = [];
while ((r = .read()) != ".")
vc = [@vc, r];
.print("Description set.");
obj.description(vc);
};
public method .new_zone_cmd() {
arg verb, zname;
var newz, room;
if (!zname)
return "Need a zone name, dude.";
newz = $zone.create();
newz.zonename(zname);
newz.name(zname);
newz.owner(this());
room = $room.create();
room.set_zone(newz);
room.set_xyz(0, 0, 0);
return (("New zone created with name " + zname) + ", first room is ") + room;
};
public method .flying() {
arg @args;
var x;
if (args) {
flying = args[1];
for x in ((.location()).all_contents()) {
if ((| "rcont" in (x.windows()) |))
(.location()).detail_cmd('pueblo, x);
}
}
return flying;
};
public method .can_fly() {
return level > 104;
};
public method .holder() {
arg @args;
var x;
if (args) {
holder = args[1];
for x in ((.location()).all_contents()) {
if ((| "rcont" in (x.windows()) |))
(.location()).detail_cmd('pueblo, x);
}
}
return holder;
};
public method .holding() {
arg @args;
var x;
if (args)
holding = args[1];
return holding;
};
public method .hold_cmd() {
arg verb, who;
if ((!(who = who.match_object())) || (!(who.has_ancestor($player))))
return "I don't see that person here.";
if (who.holder())
return "That person is already being held.";
if (.holder())
return "You can't hold people while being held.";
if (.holding())
return "You're already holding someone.";
.set_busy(5, ("You perfect your grip on " + (who.name())) + ".");
if (who.holder())
return "That person is already being held.";
if (.holder())
return "You can't hold people while being held.";
if (.holding())
return "You're already holding someone.";
who.holder(this());
.holding(who);
(.location()).announce("{o} {v/holds} on to {o/2}.", this(), who);
.print("Type 'release' to let go.");
};
public method .release_cmd() {
arg who;
if (!(.holding()))
return "You aren't holding anyone.";
if (.flying())
return ("You're in the air. I'm sure you can find a more clever way to kill " + ((.holding()).name())) + ".";
who = .holding();
who.holder(0);
.holding(0);
(.location()).announce("{o} {v/lets} go of {o/2}.", this(), who);
};
public method .forge_cmd() {
arg e, argstr;
var dfrob, s, res;
if (!argstr)
return "Usage: forge [<bladeType>] <blade size (1-7)>";
e = argstr.explode();
dfrob = #[['name, "blade"], ['folds, 0], ['sharpness, 1], ['creator, this()], ['location, 0], ['bodypart, 'hands]];
if ((e.length()) == 1) {
e = (e[1]).integer();
} else {
dfrob = dfrob.add('type, e[1]);
e = (e[2]).integer();
}
if ((e < 1) || (e > 7))
return "You can only forge things sizes 1 to 7.";
if (e > 5)
dfrob = dfrob.add('percent, 100);
else
dfrob = dfrob.add('percent, 50);
dfrob = dfrob.add('size, e);
s = .skills('forgery);
if (((100).random()) > s) {
// 1 pt for trying.
.skills('forgery, 1);
.set_busy(3, "Trying forgery...");
return "You try but fail miserably.";
}
res = ((-(s / 200)) + 6) + e;
if (!(.take_resource($list.make('metal, res))))
return ("You need " + res) + " metal to make that.";
.set_busy(6, "Working on blade...");
.skills('forgery, 2);
(.location()).announce("[LEARN:forgery,3]{o} {v/pounds} a piece of metal into a blade.", $sys.user());
(<$frob_blade, dfrob>).move(this());
};
public method .last_connect_time() {
arg @args;
return last_connect_time;
};
public method .help_cmd() {
arg verb, topic;
var r, x;
if (!topic)
topic = "main";
if (!(r = $help.find_topic(topic.lowercase())))
return "There is no help for that topic.";
.window_start("Help", "help", 320, 200, 1);
.print("---- Help for " + (r[1]));
for x in (r.subrange(2))
.notify(x);
.print("--------------------");
.window_end();
};
public method .add_help_cmd() {
arg verb, topic;
var text, x;
topic = tosym(topic.lowercase());
.print(("Adding topic: " + topic) + "...");
.print("Enter lines of text, '.' to end, '.abort' to abort.");
text = [];
while ((x = .read()) != ".") {
if (x == ".abort")
return "Aborted.";
else if ((| x[1] |) == ".")
x = x.subrange(2);
text = [@text, x];
}
(| $help.add_var(topic) |);
$help.set_var(topic, text);
.print("Help topic created and set.");
};
public method .move() {
arg @args;
if ((args[1]) == 0) {
if (.holder())
(.holder()).holding(0);
if (.holding())
(.holding()).holder(0);
.holding(0);
.holder(0);
}
return pass(@args);
};
public method .connection_names() {
arg @args;
var lst, a;
lst = [];
for a in (.connections())
lst = [@lst, a.name()];
return lst;
};
public method .sockets_cmd() {
arg @args;
var x, i, c;
.notify("--- Object --- --- Server ---- ---------- Host ---------- - I/C - - Player -");
.pueblo_code("code");
for x in ($connection.children()) {
i = x.idle();
c = x.time();
if (i > 86400)
i = (i / 86400) + "d";
else if (i > 3600)
i = (i / 3600) + "h";
else if (i > 60)
i = (i / 60) + "m";
else
i = i + "s";
if (c > 86400)
c = (c / 86400) + "d";
else if (c > 3600)
c = (c / 3600) + "h";
else if (c > 60)
c = (c / 60) + "m";
else
c = c + "s";
.notify("{l/1/14} {l/2/15} {l/3/26} {l/4/7} {s/5}", tostr(x), x.name(), $network.hostname(x.name()), (i + "/") + c, (| x.player() |) || "(Login)");
}
.notify("-------------- --------------- -------------------------- ------- ----------");
.pueblo_code("/code");
};
public method .wintoggle_cmd() {
arg verb, window;
if (!window) {
.print("Open windows: " + ((.windows()).english_list()));
.print("Suppressed windows: " + ((.badwindows()).english_list()));
return;
}
if (window in (badwindows = .badwindows())) {
badwindows = badwindows.setremove(window);
.print("Window enabled.");
.windows((.windows()).setremove(window));
} else {
badwindows = badwindows.setadd(window);
.print("Window disabled.");
}
};
public method .badwindows() {
return badwindows || [];
};
public method .lord_change_time() {
arg @args;
if (args)
lord_change_time = args[1];
return lord_change_time;
};
public method .name_ok() {
arg name;
var x;
for x in ($player.children()) {
if ((x.name()) == name)
throw(~name, "Name already in use.");
}
return 1;
};
new object #16: #30;
name $user_root #16;
var #1 name = "Root";
var #30 connections = [];
var #1 commands = [[".allobj", 'all_cmd, 'private]];
var #30 password = "root";
var #30 creation_time = 840919749;
var #30 level = 106;
var #29 location = 0;
var #30 curcon = #2477;
var #29 contents = #[['inventory, [<#35, #[['location, #16]]>, <#35, #[['location, #16]]>, <#35, #[['location, #16]]>, <#35, #[['location, #16]]>, <#35, #[['location, #16]]>, <#35, #[['location, #16]]>, <#1366, #[['location, #16], ['amount, 1999000000], ['kind, 'leather]]>, <#1366, #[['location, #16], ['amount, 1997999980], ['kind, 'wood]]>, <#35, #[['location, #16]]>, <#1366, #[['location, #16], ['amount, 1997999959], ['kind, 'stone]]>, <#1366, #[['location, #16], ['amount, 1997999235], ['kind, 'metal]]>, <#1366, #[['location, #16], ['amount, 1997999974], ['kind, 'ivory]]>, <#5, #[['location, #16], ['amount, 1997997085]]>, <#1200, #[['name, "blade"], ['folds, 0], ['sharpness, 2], ['creator, #14], ['location, #16], ['bodypart, 'hands], ['percent, 50], ['size, 5]]>]], ['clothing, [<#36, #[['location, #16]]>, <#37, #[['location, #16]]>]], ['equipment, [<#1200, #[['type, "katana"], ['name, "god's katana"], ['folds, 3000], ['sharpness, 5], ['creator, #16], ['location, #16], ['bodypart, 'hands], ['percent, 50], ['size, 5], ['handle, 'ivory]]>]]];
var #30 toggles = ['menu];
var #30 windows = [];
var #30 gender = "male";
var #16 temp = 2;
var #30 stat_str = 8;
var #30 stat_wis = 18;
var #30 stat_dex = 19;
var #30 stat_int = 20;
var #30 stat_cha = 17;
var #30 stat_con = 10;
var #30 busy = 0;
var #30 health = [0, 0, 0];
var #29 description = ["Kipp is wearing a black trench coat, black boots, black pants and a black shirt. He thinks it looks good on him. His skin is pale white, and would blend into the white walls if he didn't have such long, dark hair.", "Being the creator of all you see, objects occasionally appear in his hands as he gingerly sets them in place."];
var #30 skills = #[['building, 114], ['forgery, 464], ['damage, 1]];
var #30 window_info = [0, [0, 0], #2479, []];
var #30 flying = 0;
var #30 holding = 0;
var #30 home = #2479;
var #30 holder = 0;
var #30 last_connect_time = 858242395;
var #30 badwindows = [];
var #30 lord_change_time = 0;
public method .all_cmd() {
arg @args;
.print(toliteral(.suball($root)));
};
public method .suball() {
arg what;
var chillen, x, stuff;
stuff = [];
for x in (what.children()) {
stuff = setadd(stuff, x);
stuff = [@stuff, @.suball(x)];
}
return stuff;
};
public method .lag() {
var s, n, maxtime, st, t;
maxtime = 60;
st = time() + maxtime;
while (time() < st) {
n = n + 1;
t = time();
pause();
s = s + (time() - t);
}
return tofloat(s) / tofloat(n);
};
public method .solve() {
arg stuff;
var result, solved, y;
if (type(stuff) in ['integer, 'float, 'dictionary])
return stuff;
return .(tosym("solve_" + (stuff[1])))(.solve(stuff[2]), .solve(stuff[3]));
};
public method .getnum() {
arg str;
var num, rest, x, res;
rest = "";
if ("x" in str)
rest = "x";
str = str.replace("x", "");
if (("." in str) && (((num = tofloat(str)) != 0.0) || (str in ["0", "0.0"])))
res = [rest, num];
else if (((num = toint(str)) != 0.0) || (str in ["0", "0.0"]))
res = [rest, num];
if (res)
res = res.replace(1, (res[1]) + (str.subrange(strlen(tostr(num)) + 1)));
return res;
};
public method .distribute() {
arg exp;
var a, begin, b, c, x, num1, num2, result, st;
if ((a = exp.capture("(", ")", " + "))) {
st = a[1];
begin = st.explode();
st = (begin.subrange(1, listlen(begin) - 1)).combine(" ");
begin = (begin.subrange(listlen(begin)))[1];
.print("Distributing " + begin);
b = a.subrange(2, listlen(a) - 2);
.print("Distributed elements: " + b);
c = [];
for x in (b) {
if ((num1 = .getnum(begin)) && (num2 = .getnum(x)))
result = ((num1[1]) + (num2[1])) + ((num1[2]) * (num2[2]));
else
result = begin + x;
c += [result];
}
exp = ((st + " ") + (c.combine(" + "))) + (a[listlen(a)]);
// return .distribute(exp);
}
return exp;
};
public method .bplus1() {
arg what;
// Nothing in, nothing out :)
if (!what)
return "";
// If it's a minus, add one. That's a plus.
if ((what[1]) == "-")
return "+" + (what.subrange(2));
// If it's a plus, add one. That's an "x"
if ((what[1]) == "+")
return "x" + (what.subrange(2));
// If it's an "x", add one. Uh-oh, out of digits.
// Start over at the minus, and add one to the next digit.
if ((what[1]) == "x")
return "-" + (.bplus1(what.subrange(2)));
// **note** this works *backwards* from decimal/binary, from the left
// to the right. I did this because blah.subrange(2) and blah[1]
// are faster than blah.subrange(1,strlen(blah)-1) and blah[strlen(blah)]
};
public method .pom() {
arg numbers, total;
var ops, len, result, x, ps, m, ending;
len = listlen(numbers) - 1;
ops = "-".make(len);
ending = ops;
while ((!ps) || (ops != ending)) {
result = numbers[1];
for x in [1 .. len]
result += ((ops[x]).replace("x", "")) + (numbers[x + 1]);
.add_method([("return " + result) + ";"], 'pomtemp);
x = .pomtemp();
if (total == x) {
.print((result + "=") + x);
m = m + 1;
}
refresh();
ps = ps + 1;
ops = .bplus1(ops);
}
.del_method('pomtemp);
return ((ps + " possibilities. ") + m) + " match(es).";
};
public method .coreall() {
var x, s;
s = [];
for x in (.suball($root)) {
if (x.methods())
s = [@s, x];
}
return s;
};
public method .lag2() {
var a, t;
t = time() + 2;
while (time() < t)
a = a + 1;
return a;
};
public method .fixit() {
var x;
for x in [1 .. 100]
(<$frob_blade, #[['location, $user_kipp], ['kind, 'metal]]>).move(0);
};
public method .mcd() {
var core, newz, room, x;
core = ($sys.core_objects()) + [$sys.user(), @($sys.user()).connections()];
($sys.user()).move(0);
for x in ($root.all_children()) {
if (!(x in core)) {
x.add_method(["destroy();"], 'destroy);
(| x.destroy() |);
}
refresh();
}
newz = $zone.create();
newz.zonename("start");
newz.name("start");
newz.owner($sys.user());
room = $room.create();
room.set_zone(newz);
room.set_xyz(0, 0, 0);
($sys.user()).move(room);
($sys.user()).name("Root");
($sys.user()).set_objname('user_root);
($sys.user()).password("root");
$login.welcome(["You may now log in as root, password root."]);
$login.pueblo_welcome("</xch_mudtext><img xch_mode=purehtml>");
};
new object #65: #29;
name $room #65;
var #1 name = "Generic Room";
var #29 location = 0;
var #29 contents = #[['contents, []]];
var #1 commands = [["say *", 'say_cmd], ["\"*", 'say_cmd], ["'*", 'say_cmd], ["emote *", 'emote_cmd], [":*", 'emote_cmd], ["l?ook", 'look_cmd], ["n?orth|s?outh|e?ast|w?est|u?p|d?own", 'go_cmd], ["de?tails", 'detail_cmd]];
var #65 exits = #[];
var #65 zone = 0;
var #65 xyz = [0, 0, 0];
var #65 picture = 0;
var #65 picture_codes = 0;
var #29 flags = ['inside, 'outside, 'tree, 'mine, 'dark];
public method .go_cmd() {
arg direction;
var opdir, dirinfo, dest, temp, owin, nada, wt, wtmsg;
opdir = ["the north", "the south", "the east", "the west", "above", "below"][(direction[1]) in "snwedu"];
direction = ['north, 'south, 'east, 'west, 'up, 'down][(direction[1]) in "nsewud"];
// If they're fatally wounded, it takes 2 secs to move.
wt = ((($sys.user()).health())[3]) * 2;
wtmsg = ("Fatally wounded, you continue your struggle " + direction) + "...";
if ((temp = ($sys.user()).holding())) {
wt = wt + 1;
wtmsg = ("You continue carrying " + (temp.name())) + "...";
}
($sys.user()).set_busy(wt, wtmsg);
if ((($sys.user()).location()) != this())
return;
if ((temp = ($sys.user()).holder())) {
if (temp.flying()) {
return ("Believe me, you DON'T want " + (temp.name())) + " to let you fall.";
} else if (((($sys.user()).str()) + random(15)) > ((temp.str()) + random(25))) {
($sys.user()).holder(0);
temp.holding(0);
($sys.user()).flying(0);
.announce("{o} {v/wiggles} free from {o/2}'s grip!", $sys.user(), temp);
} else {
.announce("{o} {v/tries} to wiggle free from {o/2}'s grip.", $sys.user(), temp);
($sys.user()).set_busy(4, "You continue struggling to free yourself!");
return;
}
}
if (!(.zone()))
return "This room is a void. You can not move.";
temp = #[['north, [0, -1]], ['south, [0, 1]], ['west, [-1, 0]], ['east, [1, 0]], ['up, [0, 0]], ['down, [0, 0]]][direction];
if ((($sys.user()).flying()) && (!(direction in ['up, 'down]))) {
dest = .exit_destination(direction);
if ((| 'outside in (dest.flags()) |)) {
// ok
nada = ($sys.user()).flying();
dirinfo = (.exits())[direction];
} else if ((dest = (.zone()).locate((xyz[1]) + (temp[1]), (xyz[2]) + (temp[2]), (xyz[3]) - (($sys.user()).flying())))) {
if ('outside in (dest.flags())) {
// ok
} else {
return "You can't fly that way.";
}
} else {
return "You can't fly that way.";
}
} else if (((($sys.user()).flying()) && (direction == 'down)) || ((| (dirinfo = (.exits())[direction]) |) == ~keynf)) {
if ((($sys.user()).can_fly()) && ('outside in (.flags()))) {
if (direction == 'up) {
($sys.user()).flying((($sys.user()).flying()) + 1);
if ((($sys.user()).flying()) == 10) {
if ((($sys.user()).level()) < 104) {
($sys.user()).flying(9);
return "You can't fly much higher than this!";
} else {
dest = $room_god_0_0_0;
}
} else if ((($sys.user()).flying()) == 1) {
.announce("{o} {v/floats} off the ground.", $sys.user());
return;
} else {
.announce("{o} {v/flies} higher.", $sys.user());
return;
}
} else if (direction == 'down) {
if (!(($sys.user()).flying()))
return "You can't go any lower than the ground.";
($sys.user()).flying((($sys.user()).flying()) - 1);
if ((($sys.user()).flying()) == 0)
.announce("{o} {v/lands} on the ground.", $sys.user());
else
.announce("{o} {v/flies} lower.", $sys.user());
return;
} else {
nada = -(xyz[3]);
if ((!(dest = (.zone()).locate((xyz[1]) + (temp[1]), (xyz[2]) + (temp[2]), 0))) || (!('outside in (dest.flags()))))
return "You can't fly that way.";
}
} else {
return "You can't go that way.";
}
} else {
dest = .exit_destination(direction);
}
owin = ($sys.user()).window_info();
if ((| dirinfo['picture] |))
($sys.user()).window_info([(((.zone()).picture_path()) + (dirinfo['picture])) + ".jpg", [this(), direction], dest, (| dirinfo['codes] |) || []]);
else
($sys.user()).window_info([0, [0, 0], 0, 0]);
catch any {
($sys.user()).move(dest);
if (($sys.user()).holding())
(($sys.user()).holding()).move(dest);
} with {
($sys.user()).window_info(owin);
.print((| dirinfo['nogo] |) || "You can't move in that direction. (?)");
if ((temp = (| dirinfo['onogo] |)))
.hannounce(temp);
return;
}
($sys.user()).flying(nada);
if ((temp = ($sys.user()).holding()))
temp.flying(nada);
.hannounce((| dirinfo['oleave] |) || "{o} {v/goes} {s/2}.", $sys.user(), tostr(direction));
dest.hannounce((| dirinfo['oarrive] |) || "{o} {v/arrives} from {s/2}.", $sys.user(), opdir);
if ((temp = ($sys.user()).holding()))
(($sys.user()).location()).announce("{o} {v/carries} {o/2} in.", $sys.user(), temp);
};
public method .xyz() {
return xyz || [2000000000, 2000000000, 2000000000];
};
public method .set_xyz() {
arg x, y, z;
if ((zone.locate(x, y, z)) in [this(), 0]) {
xyz = [x, y, z];
.set_objname(tosym(((((((("room_" + (zone.zonename())) + "_") + x) + "_") + y) + "_") + z).replace("-", "n")));
} else {
throw(~zone, "Room coordinates already taken.");
}
};
public method .zone() {
return zone;
};
public method .set_zone() {
arg zname;
var x;
if (.zone())
(.zone()).remove_room(this());
if (type(zname) == 'objnum) {
zone = zname;
zname.add_room(this());
return;
}
for x in ($zone.children()) {
if ((x.zonename()) == zname) {
zone = x;
x.add_room(this());
return;
}
}
throw(~zone, "Zone not found.");
};
public method .exits() {
arg @args;
var x;
// Exit format:
// #[['direction, #[['destination,objnum], ['nogo,msg]...]] ...]
// All direction arguments are optional.
// No destination will simply follow the grid.
if ((listlen(args) == 1) && (type(args[1]) == 'dictionary)) {
exits = args[1];
for x in (.all_contents()) {
if ((| "rcont" in (x.windows()) |))
.detail_cmd('pueblo, x);
}
} else if (args) {
throw(~numargs, "Called with too many or invalid arguments.");
} else {
return exits || #[];
}
};
public method .exited() {
arg @args;
var x, n, loc;
n = (args[1]).name();
loc = (args[1]).location();
for x in (.all_contents()) {
if ((| "rcont" in (x.windows()) |))
.detail_cmd('pueblo, x);
if ((loc != x) && (| n in (x.windows()) |))
x.puebloclose_cmd(0, n);
}
};
public method .look_cmd() {
arg @verb;
var who, x, pre, y, pio;
pre = "";
if ('pueblo in verb)
pre = "{q/pueblo}";
who = $sys.user();
for x in (verb) {
if (type(x) == 'objnum)
who = x;
}
who.notify(pre + ((.name()) + (((who.level()) > 99) ? (((" (" + this()) + ") [ ") + ((.flags()).combine(" "))) + " ]" : "")));
if ((((($sys.user()).window_info())[3]) == this()) && ("room" in (($sys.user()).windows()))) {
.detail_cmd(@verb);
return;
}
for x in (who.connections()) {
if ((pio = 'pueblo in (x.display_options()))) {
if ((!(.picture())) || (!pio)) {
who.window_start("Current Room", "room", 600, 400, 1);
for y in (.description())
x.print(y);
who.window_end();
}
} else {
for y in (.description())
x.print(y);
}
}
if (!("room" in (($sys.user()).badwindows())))
($sys.user()).window_info([.picture(), [0, 0], this(), .picture_codes()]);
.detail_cmd(@verb);
};
public method .move() {
arg @args;
throw(~move, "Can't move rooms.");
};
public method .say_cmd() {
arg @argstr;
argstr = argstr[listlen(argstr)];
.announce("{o} {v/says/say}, \"{s/2}\"", $sys.user(), argstr);
};
public method .emote_cmd() {
arg @argstr;
var stuff, sch, isa, temp, x, word, temp2, match, temp3, reverse, wsr, lasts, rest;
argstr = argstr[listlen(argstr)];
rest = "";
if ((temp = ("|" in argstr) || (("\"" in argstr) || ("/" in argstr)))) {
rest = argstr.subrange(temp + 1);
argstr = argstr.subrange(1, temp);
}
sch = "";
stuff = argstr.explode();
isa = 1;
lasts = $sys.user();
for x in [1 .. listlen(stuff)] {
word = stuff[x];
temp = (word.first_in(["{", "/", "}", "!", ".", "?", ":", ",", "'"])) || (strlen(word) + 1);
temp3 = (word.first_in(["{", "/", "}", "!", ".", "?", ":", ","])) || (strlen(word) + 1);
if ((| (word.subrange((word.length()) - 1)) == "ly" |)) {
sch += (" {s/" + (x + 1)) + "}";
continue;
}
if ((temp2 = (word.subrange(1, temp - 1)) in ["him", "her", "he", "she", "his", "her", "his", "hers", "himself", "herself"])) {
sch += ((((((" {o/" + (x + 1)) + "/") + (["you", "you", "your", "yours", "yourself"][((temp2 - 1) / 2) + 1])) + "/") + (["po", "ps", "pp", "pq", "pr"][((temp2 - 1) / 2) + 1])) + "/1}") + (word.subrange(temp));
stuff = stuff.replace(x, lasts);
} else if ((temp2 = (word.subrange(1, temp - 1)) in ["i", "me", "my", "mine", "myself"])) {
sch += ((((" {v/" + ([($sys.user()).ps(), ($sys.user()).ps(), ($sys.user()).pp(), ($sys.user()).pq(), ($sys.user()).pr()][temp2])) + "/") + (["you", "you", "your", "yours", "yourself"][temp2])) + "/1}") + (word.subrange(temp));
} else if ((word.subrange(1, temp - 1)) == "you") {
sch += " " + word;
} else if ((temp > 3) && (match = (word.subrange(1, temp - 1)).match_object())) {
if ($player in (match.parents()))
lasts = match;
stuff = stuff.replace(x, match);
sch += ((" {o/" + (x + 1)) + "/you/name}") + (word.subrange(temp));
} else if ((temp > 5) && (((word.subrange(temp - 3, 2)) == "'s") && (match = (word.subrange(1, temp - 3)).match_object()))) {
stuff = stuff.replace(x, match);
if ($player in (match.parents()))
lasts = match;
sch += ((" {o/" + (x + 1)) + "/your/name}") + (word.subrange(temp));
} else if ((isa == 1) || (isa && (reverse || ((| (word.subrange(temp3 - 1, 1)) == "s" |) || (("'" in word) || (word in ["does", "has", "is", "was"])))))) {
if ((wsr = (| word.subrange(temp3 - 1, 1) |))) {
if ((wsr != "s") && (!(wsr in ["doesn't", "does", "has", "is", "was"])))
reverse = 1;
wsr = word.subrange(1, temp3 - 1);
if (reverse)
sch += ((((((" {v/" + (wsr.plural())) + "/") + wsr) + "/") + (x + 1)) + "}") + (word.subrange(temp3));
else
sch += ((((((" {v/" + wsr) + "/") + (wsr.singular())) + "/") + (x + 1)) + "}") + (word.subrange(temp3));
stuff = stuff.replace(x, lasts);
} else {
sch += " " + (word.subrange(temp3));
}
} else {
sch += (" {s/" + (x + 1)) + "}";
}
isa = 0;
if (temp2 in [3, 4])
isa = 2;
temp2 = word.subrange(1, temp - 1);
if ((temp2 in ["then", "or", "and"]) || (| (temp2.subrange(strlen(temp2) - 1)) in ["ly"] |))
isa = 2;
}
.announce((((("{o}" + sch) + "{s/") + ((stuff.length()) + 2)) + "}").compile_text(), $sys.user(), @stuff, rest);
};
public method .dumb_announce() {
arg line;
var x;
for x in (.contents())
x.print(line);
};
public method .announce() {
arg line, @info;
var x;
line = line.compile_text();
for x in (.contents())
x.notify(line, @info);
.rannounce(line, @info);
};
public method .hannounce() {
arg line, @info;
var od, x;
line = line.compile_text();
for x in (setremove(.contents(), $sys.user()))
x.notify(line, @info);
.rannounce(line, @info);
};
public method .destroy() {
arg @args;
var dest, x, y;
catch any {
for x in (.exits()) {
for y in ((dest = .destination(x[1])).exits()) {
if ((dest.destination(y[1])) == this())
dest.exits((dest.exits()).dict_del(y[1]));
}
}
}
if (zone)
(| zone.remove_room(this()) |);
dest = (| (((.zone()).rooms()).setremove(this()))[1] |);
if (!dest)
dest = $zone_god_0_0_0;
if (.contents())
dest.announce("{s} appears suddenly.", .contents());
for x in (.contents())
x.move(dest);
return pass(@args);
};
public method .destination() {
arg exit;
var dest, xyz, ex;
if ((dest = (| (ex = (.exits())[exit])['destination] |)))
return dest;
xyz = .xyz();
switch (exit) {
case 'north:
xyz = [xyz[1], (xyz[2]) - 1, xyz[3]];
case 'south:
xyz = [xyz[1], (xyz[2]) + 1, xyz[3]];
case 'west:
xyz = [(xyz[1]) - 1, xyz[2], xyz[3]];
case 'east:
xyz = [(xyz[1]) + 1, xyz[2], xyz[3]];
case 'up:
xyz = [xyz[1], xyz[2], (xyz[3]) - 1];
case 'down:
xyz = [xyz[1], xyz[2], (xyz[3]) + 1];
}
return zone.locate(@xyz);
};
public method .entered() {
arg @args;
var x;
for x in (.all_contents()) {
if ((| "rcont" in (x.windows()) |))
.detail_cmd('pueblo, x);
}
if ((args[1]).has_ancestor($player))
.look_cmd(args[1]);
};
public method .picture() {
arg @args;
if (args)
picture = args[1];
return picture && ((((.zone()).picture_path()) + picture) + ".jpg");
};
public method .detail_cmd() {
arg @verb;
var pre, x, who, ve, y, room;
pre = "";
if ('pueblo in verb)
pre = "{q/pueblo}";
who = $sys.user();
for x in (verb) {
if (type(x) == 'objnum)
who = x;
}
ve = [];
for x in ((.visible_exits(who)).sort())
ve += [((("{k/" + x) + "}") + x) + "{ek}"];
who.window_start("Room's contents --", "rcont", 300, 30, 1);
ve && (who.notify((pre + "Exits: ") + (ve.english_list())));
((setremove(.contents(), who).sort_object_list(who, [])) && (who.notify(pre + "{s} {v/is/are} here.", setremove(.contents(), who)))) || (who.print("Nothing is here."));
who.window_end();
if (!pre) {
for x in (['north, 'south, 'east, 'west, 'up, 'down]) {
room = this();
for y in [1 .. 4] {
room = room.exit_destination(x);
if (!room)
break;
if (room.contents())
(((room.contents()).sort_object_list(who, [])) && (who.notify(((pre + "{s} {v/is/are} ") + ((y == 1) ? "1 room " + x : ((y + " rooms ") + x))) + ".", room.contents()))) || (who.print("Nothing is here."));
}
}
}
};
public method .picture_codes() {
arg @args;
if (args)
picture_codes = args[1];
return picture_codes || [];
};
public method .connections() {
arg @all;
var x, direction, cords, dest, cords;
for x in ((.exits()).keys()) {
dest = .exit_destination(x);
if (!(dest in all))
all = dest.connections(@all.setadd(this()));
}
return all.setadd(this());
};
public method .exit_destination() {
arg x;
var xyz;
if (!(x in ((.exits()).keys())))
return 0;
if ((| (xyz = ((.exits())[x])['destination]) |))
return xyz;
xyz = .xyz();
switch (x) {
case 'north:
xyz = [xyz[1], (xyz[2]) - 1, xyz[3]];
case 'south:
xyz = [xyz[1], (xyz[2]) + 1, xyz[3]];
case 'east:
xyz = [(xyz[1]) + 1, xyz[2], xyz[3]];
case 'west:
xyz = [(xyz[1]) - 1, xyz[2], xyz[3]];
case 'up:
xyz = [xyz[1], xyz[2], (xyz[3]) - 1];
case 'down:
xyz = [xyz[1], xyz[2], (xyz[3]) + 1];
}
return (.zone()).locate(@xyz);
};
public method .visible_exits() {
arg who;
var ex, exs, x, dest;
ex = .exits();
exs = [];
for x in ((.exits()).dict_keys()) {
dest = .exit_destination(x);
if (((| (ex[x])['hidden] |) in ["1", "yes", "true"]) || (('tree in (dest.flags())) || ('mine in (dest.flags()))))
;
else
exs = [@exs, x];
}
return exs;
};
public method .description() {
arg @args;
var x, p;
p = pass(@args);
if (args) {
for x in (.all_contents()) {
if ((| "room" in (x.windows()) |)) {
x.windows((x.windows()).setremove("room"));
.look_cmd('pueblo, x);
}
}
}
return p;
};
public method .rannounce() {
arg line, @info;
var x, y, z, room, od;
if ((| (y = (line[1]).match_pattern("[LEARN:*,*]*")) |))
line = line.replace(1, y[3]);
for x in (['north, 'south, 'east, 'west, 'up, 'down]) {
od = ['south, 'north, 'west, 'east, 'down, 'up][x in ['north, 'south, 'east, 'west, 'up, 'down]];
room = this();
for y in [1 .. 4] {
if ((| ((.exits())[x])['soundless] |))
break;
room = room.exit_destination(x);
if (!room)
break;
for z in ((room.contents()).setremove($sys.user()))
z.notify([(y == 1) ? ("1 room " + od) + "> " : (((y + " rooms ") + od) + "> ")] + line, @info);
}
}
};
new object #2479: #65;
name $room_start_0_0_0 #2479;
var #29 creator = #16;
var #65 zone = #2478;
var #65 xyz = [0, 0, 0];
var #29 contents = #[['contents, []]];
new object #67: #29;
name $item #67;
var #1 name = "Generic Object";
var #29 contents = #[];
var #1 commands = [["g?et|t?ake *", 'get_cmd], ["dr?op *", 'drop_cmd], ["l?ook *", 'look_cmd], ["gi?ve * to *", 'give_cmd]];
public method .look_cmd() {
arg verb, what;
var cmds, x, y;
if ("at " in what)
what = what.subrange(4);
if (!(.is_this(what)))
return 0;
($sys.user()).window_start(.name(), "lookreal", 300, 100, 1);
($sys.user()).print(.name());
($sys.user()).print(.description());
cmds = "";
if ((.location()) == ($sys.user()))
cmds += ("<a xch_cmd=\"drop " + (.name())) + "\">Drop</a><br>";
else if ((.location()) == (($sys.user()).location()))
cmds += ("<a xch_cmd=\"get " + (.name())) + "\">Take</a><br>";
for y in (($sys.user()).connections()) {
if ('pueblo in (y.display_options()))
y.print(str_to_buf(("<center>" + cmds) + "</center>"));
}
($sys.user()).window_end();
};
public method .get_cmd() {
arg verb, what;
var amount, rest;
if (!what)
return (.get_message('get_what)) || "Get what?";
else if (((.location()) != (($sys.user()).location())) || (!(.is_visible_to($sys.user()))))
return 0;
amount = (what.explode())[1];
if ((rest = (| amount.from_english_number() |))) {
what = what.subrange(strlen(amount) + 2);
amount = tostr(rest);
rest = " " + what;
} else if ((!toint(amount)) && (amount != "all")) {
amount = "1";
} else if ((amount == "all") && (what == "all")) {
what = .name();
rest = "";
} else {
what = what.subrange(strlen(amount) + 2);
rest = " " + what;
}
if (!(.is_this(what)))
return 0;
catch any
.move($sys.user());
with
return ((.get_message('no_getShowing the first 150 KB. Download the file for the full text.