/********************************************************* * * * OBS!!! All changes should be added to ChangeLog * * M-x add-change-log-entry * * * *********************************************************/ inherit "/obj/wiz_line"; inherit "/obj/env_var"; inherit "/obj/simplemore"; static int time_to_heal; static int is_npc; #define MAX_IDLE 30*60 /* 30 minutes */ /* ** There can be a maximum of 30+10 concurrent users */ #define MAX_PLAYERS 50 #define MAX_ARCHWIZ 5 #define TICK_STATUE 15*60 /* 15 minutes per statue "tick" */ #define MAX_STATUE 4 /* 1 hours */ static string statue_type; #define USE_WETCODE /* Experimental "wet" code */ #define USE_FOLLOW /* Experimental "follow" code, see living.c also */ #include #include #include #include /* Milamber */ #define WIZ 1 #define ARCH 0 int term_rows,abrief; int term_cols; string term_type; static status is_linkdead; int file_exp; int tot_value; static string current_path; string access_list; static invite_list; static int nologin; static int num_users; static object myself; /* Ourselfs. */ static string change_dir,change_file; string title; /* Our official title. Wiz's can change it. */ string password; /* This players crypted password. */ static string password2;/* Temporary when setting new password */ string al_title; int intoxicated; /* How many ticks to stay intoxicated. */ int stuffed; /* How many ticks to stay stuffed */ int soaked; /* How many ticks to stay soaked */ int headache, max_headache; string called_from_ip; /* IP number was used last time */ string called_from_host;/* Hostname was used last time */ string called_from_user;/* Username was used last time */ string last_login_time; /* When we last did login */ string ident_user; /* Username on localhost */ string allow_from_host; /* Hosts to be able to login from */ static string rlogin_name; int use_rlogin; /* flag to set if rlogind should log us in */ string plan_desc; /* A plan to the finger command */ string quests; /* A list of all solved quests */ int my_quest_max; /* The max number of quest points when this player was created! */ string puzzles; /* A list of all solved puzzles */ status playerkilling; /* Is this player allowed to kill other players? */ static int time_to_save;/* Time to autosave. */ static status fake_ghost; /* Special for Ramses guild..sigh.. */ string testchar; /* Are we a testchar and in that case whose? */ static string saved_where; /* Temp... */ string mailaddr; /* Email address of player */ string host; /* Name of players remote host */ static string xx_realname; /* Used to prevent some guys from cheating.. /pen */ static string it; /* Last thing referenced. */ static int is_editing; /* If the poor wiz is using ed */ review() { write("mout:\t" + msgout + "\nmin:\t" + msgin + "\nmmout:\t" + mmsgout + "\nmmin:\t" + mmsgin + "\n"); return 1; } query_prevent_shadow(ob) { string tmp; if (sscanf(file_name(ob), "local/%s", tmp)) return 0; else return 1; } query_real_name() { return name; } static filter_users_fun(ob, level) { if (level > 0) return (ob && ob->query_level() >= level); else return (ob && ob->query_level() <= -level); } filter_users(level) { return filter_objects(users(), "filter_users_fun", this_object(), level); } /* logon() is called when the players log on. */ static logon() { string vers; vers = version(); time_to_save = 500; enable_commands(); write("Welcome to the NannyMUD multiuser adventure running on NannyMOS " + vers + "\n"); if(sizeof(users()) >= MAX_PLAYERS + MAX_ARCHWIZ) { write("*** NannyMUD is full. Please come back later.\n"); destruct(this_object()); } num_users = sizeof(users()) - sizeof(filter_users(22)); if(nologin = cat("/etc/NOLOGIN")) write("*** Login limited to Arch Wizards ***\n"); else if(num_users >= MAX_PLAYERS) write("*** NannyMUD is full. Only Arch Wizards are allowed to login.\n"); else cat("/etc/WELCOME"); ident_user = _query_ident(); #if 0 if(ident_user) if(rlogin_name = "/obj/daemon/rlogind"->query_rlogin(ident_user, query_ip_number())) { name = rlogin_name; restore_object("players/" + name); if(use_rlogin) { if((nologin || num_users >= MAX_PLAYERS) && level <= 21) { write("Sorry, login has been limited to Arch Wizards currently.\n"); write("Please come back later.\n"); destruct(this_object()); } host = 0; time_to_save = age + 500; /* Don't do this before the restore ! */ dead = ghost; myself = this_player(); if(is_invis) cap_name = "Someone"; else cap_name = capitalize(name); local_weight = 0; armour_class = 0; name_of_weapon = 0; weapon_class = 0; attacker_ob = 0; alt_attacker_ob = 0; move_player_to_start(0); #ifdef LOG_ENTER log_file("ENTER", name + ", " + extract(ctime(time()), 4, 15)+ " from " + ( ident_user ? ident_user + "@" : "") + query_ip_name() + ".\n"); #endif move_object(clone_object("obj/magobj"),this_object()); return 1; } else { restore_object("secure/emptychar"); name = "logon"; level = -1; password = 0; } } #endif if(name == "logon") { write("What is your name: "); input_to("logon2"); call_out("time_out", 120); return 1; } } static object other_copy; fiddle_obj(ob) { int weight; weight = call_other(ob, "query_weight"); /* * Don't move the soul. */ if (!call_other(ob, "id", "soul") && !call_other(ob, "id", "magobj") && add_weight(weight)) { if (ob == name_of_weapon && ob->query_weapon()) { ob->unwield(); stop_wielding(); } call_other(ob, "drop"); if (ob) move_object(ob, this_player()); } } nomask static try_throw_out(str) { object ob; if (str == "" || (str[0] != 'y' && str[0] != 'Y')) { write("Welcome another time then !\n"); destruct(this_object()); return; } ob = first_inventory(other_copy); while(ob) { object next_ob; string err; next_ob = next_inventory(ob); if (err = catch(fiddle_obj(ob))) { int old_level; _syslog("try_throw_out(): buggy object: " + err + "."); old_level = level; level = 99; _destruct(ob); level = old_level; } ob = next_ob; } ob = environment(other_copy); call_other(other_copy, "save_me",2); if (other_copy) destruct(other_copy); /* Is this really needed ? */ if (restore_object("players/" + name)) write("Points restored from the other object.\n"); other_copy = 0; host = 0; move_player_to_start(ob); #ifdef LOG_ENTER log_file("ENTER", " (throw)\n"); #endif } static logon2(str) { if (!str || str == "") { destruct(this_object()); return; } if (name != "logon") { illegal_patch("logon2 " + name); destruct(this_object()); return; } str = lower_case(str); if (!valid_name(str)) { input_to("logon2"); write("Give name again: "); return; } if (restore_object("banish/" + str)) { write("That name is reserved.\n"); destruct(this_object()); return; } if (!restore_object("players/" + str)) { write("New character.\n"); } ident_user = _query_ident(); if ((nologin || num_users >= MAX_PLAYERS) && level <= 21) { write("Sorry, login has been limited to Arch Wizards currently.\n"); write("Please come back later.\n"); destruct(this_object()); } if(!check_access()) { write("You may not login from this site!\n"); log_file("CRACKER", name + ", " + extract(ctime(time()),4,15) + " from " + ( ident_user ? ident_user +"@" : "") + query_ip_name()+".\n"); destruct(this_object()); return; } host = 0; time_to_save = age + 500; /* * Don't do this before the restore ! */ name = str; /* Must be here for a new player. */ dead = ghost; myself = this_player(); if (is_invis) cap_name = "Someone"; else cap_name = capitalize(name); local_weight = 0; armour_class = 0; name_of_weapon = 0; weapon_class = 0; /* If this is a new character, we call the adventurers guild to get * our first title ! */ if(level < 8) { /* new player or newbie. Need to get rid of some assholes */ if(!"obj/daemon/newbied"->allowed_newbie(query_ip_number(this_object()), lower_case(name))) { write("New players are not allowed to login from your site.\n"); write("Please mail nannymud@lysator.liu.se if you wish to start playing.\n"); write("State the name of the character you wish to play in the letter.\n"); destruct(this_object()); } } if (level != -1) input_to("check_password", 1); else input_to("new_password", 1); write("Password: "); if (name == "guest") { if("obj/daemon/newbied"->allowed_newbie(query_ip_number(this_object()), "guest")) write("(just CR) "); else { write("Guest login denied from your host.\n"); destruct(this_object()); } } attacker_ob = 0; alt_attacker_ob = 0; return; } /* Called by command 'save' */ save_character() { save_me(1); write("Ok.\n"); return 1; } reset(arg) { if (arg) return; /* * With arg = 0 this function should only be entered once! */ if(myself) return; if (creator(this_object())) { illegal_patch("Cloned player.c"); destruct(this_object()); return; } statue_type = "a nice"; level = -1; is_linkdead = 0; name = "logon"; cap_name = "Logon"; msgin = "arrives"; msgout = "leaves"; mmsgin = "arrives in a puff of smoke"; mmsgout = "disappears in a puff of smoke"; setenv(TITLE, "the title less"); al_title = "neutral"; term_rows = 24; term_cols = 80; term_type = "unknown"; host = 0; gender = -1; /* Illegal value, so it will be changed! */ my_quest_max = 0; /* Illegal value, so it will be changed! */ } /* Enable other objects to query our hit point. */ query_hit_point() { return hit_point; } string substitute_string(string str, string from, string to, int all) { string tmp1, tmp2; if(!stringp(str) || !stringp(from) || !stringp(to)) return 0; if(all) { while(sscanf(str, "%s" + from + "%s", tmp1, tmp2) == 2) str = tmp1 + to + tmp2; } else { if(sscanf(str, "%s" + from + "%s", tmp1, tmp2) == 2) str = tmp1 + to + tmp2; } return str; } fix_title(string var, string value) { string newtitle, tmp; if(!var || var != TITLE) return; if(!value) { title = ""; return; } if(sscanf(value, "%s$N", tmp) == 1) { newtitle = substitute_string(value, "$N", capitalize(name), 1); if(!newtitle) setenv(TITLE, capitalize(name) + " the title less"); else { if(sscanf(newtitle, "%s" + capitalize(name), tmp) != 1) setenv(TITLE, capitalize(name) + " " + newtitle); else setenv(TITLE, newtitle); } return; } if(sscanf(value, "%s" + capitalize(name), tmp) != 1) setenv(TITLE, capitalize(name) + " " + value); title = getenv(TITLE); } short() { string newtitle; if (is_invis) return 0; if (ghost) return "ghost of " + cap_name; if (!query_ip_number(this_object())) return statue_type + " statue of " + cap_name; if (frog) return cap_name + " the frog"; if(newtitle = getenv(TITLE)) return newtitle + " (" + al_title + ")"; return cap_name + " " + title + " (" + al_title + ")"; } long(str) { string cap_pronoun; if (!query_ip_number(this_object())) { write(capitalize(statue_type) + " stone statue of " + cap_name + ".\n"); return; } cap_pronoun = capitalize(query_pronoun()); write(short() + ".\n"); #ifdef USE_WETCODE if (wet_time > 0 && !environment(this_object())->query_property("waterfilled")) write(cap_pronoun + " is soaking wet, dripping water all over the place.\n"); #endif if (ghost || frog) return; if (hit_point < max_hp/10) { write(cap_pronoun + " is in very bad shape.\n"); return; } if (hit_point < max_hp/5) { write(cap_pronoun + " is in bad shape.\n"); return; } if (hit_point < max_hp/2) { write(cap_pronoun + " is not in a good shape.\n"); return; } if (hit_point < max_hp - 20) { write(cap_pronoun + " is slightly hurt.\n"); return; } write(cap_pronoun + " is in good shape.\n"); if (playerkilling) write(capitalize(query_possessive()) + " conscience will not stop " + query_objective() + " from killing other players.\n"); } score(arg) { string tmp; object ob; if (ghost) { write("You are in an immaterial state with no scores.\n"); return 1; } if (arg) { write("Str: " + this_object()->query_str() + "\n"); write("Dex: " + this_object()->query_dex() + "\n"); write("Int: " + this_object()->query_int() + "\n"); write("Con: " + this_object()->query_con() + "\n"); return 1; } write("You have " + experience + " experience points, " + money + " gold coins, "); write(query_cached_quest_points()+ " quest points ( "+ (my_quest_max * QUEST_POINTS_PERCENT_TO_WIZ) / 100 +" ).\n"); write(hit_point + " hit points(" + max_hp + ") and "); write(spell_points + " spell points("+max_sp+").\n"); if (hunter) write("You are hunted by " + capitalize(hunter->query_name()) + ".\n"); #ifdef USE_FOLLOW if (ob = query_follow()) write("You are following " + capitalize(ob->query_name()) + ".\n"); #endif if (intoxicated || stuffed || soaked) { tmp = "You are "; if (intoxicated) { tmp += "intoxicated"; if (stuffed && soaked) tmp += ", "; else { if (stuffed || soaked) tmp += " and "; else tmp += ".\n"; } } if (stuffed) { tmp += "satiated"; if (soaked) tmp += " and "; else tmp += ".\n"; } if (soaked) tmp += "not thirsty.\n"; write(tmp); } if (whimpy) write("Wimpy mode.\n"); if (playerkilling) write("Your conscience will not stop you from killing other players.\n"); show_age(); return 1; } /* Identify ourself. */ id(str, lvl) { /* * Some wizzies make invisibility items useable by * players , and this will prevent cheating. */ if (!str) return 0; str = lower_case(str); #if 0 if(level < 20) if(str == name || str == "ghost of " + name) return 1; #endif /* * I think this looks stupid. When I am invisible it is * because I want to work in PEACE. */ if (is_invis && lvl <= level) return 0; if (ghost) return str == "ghost of " + name; if (str == name) return 1; if(!myself) return 0; if (!query_ip_number(myself)) { if (str == "statue") return 1; if (str == "statue of " + name) return 1; } return 0; } query_title() { string newtitle; if(newtitle = getenv(TITLE)) { newtitle = substitute_string(newtitle, "$N", cap_name, 1); if (!newtitle) return title; return newtitle; } return title; } query_al_title() { return al_title; } set_level(lev) { object scroll; #if 1 /* Padrone loggar listigt l{bbiga luringar: */ log_file("LEVEL-TEMP-LOG", ctime(time()) + ": " + query_real_name() + " to " + lev + "\n"); if (previous_object()) log_file("LEVEL-TEMP-LOG", "previous_object() = " + file_name(previous_object()) + " (" + previous_object()->query_real_name() + ")\n"); if (this_player()) log_file("LEVEL-TEMP-LOG", "this_player() = " + file_name(this_player()) + " (" + this_player()->query_real_name() + ")\n"); #endif if(query_real_name()=="guest") { level=1; write("Sorry, as a guest you cannot advance in level.\n"); return; } if (lev > 21 || lev < level && level >= 20 || level <= 0) if(file_name(previous_object())!="room/adv_guild") /* Wing 920502, you shouldn't be able to change level of logon (no ways to snoop logon no I hope) */ return illegal_patch("set_level"); /* NOPE ! */ level = lev; if (level == 20) { tell_object(myself, "Adding wizard commands...\n"); wiz_commands(); } if (level == 21) { tell_object(myself, "Adding more wizard commands...\n"); wiz_commands2(); } } set_title(t) { if(!t) return 0; if (this_player() != this_object() && level >= 20 && this_player()->query_level_sec() <= level) return 0; if(this_player()!=this_object() && query_level()<20 && this_player()->query_level()>19) { log_file("TITLE",this_player()->query_real_name()+" changed "+query_real_name()+" to '"+t+"'\n"); } setenv("TITLE",t); return 1; } static wiz_commands2() { if (this_object() != this_player()) return; add_action("makedir", "mkdir"); add_action("removedir", "rmdir"); add_action("pwd", "pwd"); add_action("more", "more"); add_action("echo_to", "echoto"); add_action("echo", "echo"); add_action("echo_all", "echoall"); add_action("home", "home"); add_action("remove_file", "rm"); add_action("cp", "cp"); add_action("cp", "mv"); /* Yes, mv and cp use the same function */ add_action("list_files", "ls"); add_action("cat_file", "cat"); add_action("edit", "ed"); add_action("clone", "clone"); add_action("destruct_local_object", "destruct"); add_action("load", "load"); } static wiz_commands() { if (this_object() != this_player()) return; add_action("tail_file", "tail"); add_action("cd", "cd"); add_action("local_commands", "localcmd"); add_action("wiz_score_list", "wizlist"); add_action("force_player", "force"); add_action("spell_zap", "zap"); add_action("stat", "stat"); add_action("heal", "heal"); add_action("changed_dir","updir"); add_action("changed_dir","loaddir"); add_action("refresh","refresh"); add_action("update_object", "update"); add_action("set_title", "title"); add_action("teleport", "goto"); add_action("in_room", "in"); add_action("emote", "emote"); add_action("list_peoples", "people"); add_action("setmmin", "setmmin"); add_action("setmmout", "setmmout"); add_action("setmin", "setmin"); add_action("setmout", "setmout"); add_action("review", "review"); add_action("shut_down_game", "shutdown"); add_action("trans", "trans"); add_action("snoop_on", "snoop"); add_action("invis", "invis"); add_action("vis", "vis"); add_action("wiz","wiz",1); add_action("toggle_file_exp","fileexp"); add_action("invite_wiz","invite"); add_action("set_env","set"); add_action("set_env","setenv",1); add_action("unset_env","unset"); add_action("unset_env","unsetenv",1); if(rlogin_name) add_action("set_use_rlogin","rlogin"); } /* New shout routines to allow earmuffs via catch_shout() Possible future extension: filter_objects() returns an array holding the players that accepted the shout(), that is those who heard it. These could be listed to the shouter if one wishes. */ #define SHOUT_OLD(x) shout(x) #define SHOUT(x) gTellstring=x; filter_objects(users(),"filter_tell",this_object()) static string gTellstring; static int listen_to_shouts_from_level; filter_tell(ob) { if (ob == this_player()) return 0; return ob->catch_shout(gTellstring); } /* This is called for every shouted string to this player. */ catch_shout(str) { if (listen_to_shouts_from_level < 2 || this_player() && this_player()->query_level() >= listen_to_shouts_from_level) { tell_object(this_object(),str); return 1; } return 0; } /* This is the earmuff hook. You can set the level of the players to which you want to listen to, to one more than your own. This means you can not stop higher level players from shouting to you, but you can stop lower levels and your own level. */ listen_shout(lev) { if (lev /*&& lev <= level+1*/) listen_to_shouts_from_level=lev; return listen_to_shouts_from_level; } earmuffs(str) { int lev; if (str && sscanf(str, "%d", lev) == 1) listen_shout(lev); write("Earmuffs at level " + listen_to_shouts_from_level + ".\n"); return 1; } echo_all(str) { if (!str) { write("Echoall what?\n"); return 1; } SHOUT(str + "\n"); write("You echo: " + str + "\n"); log_file("ECHO", ctime(time()) + " " + name + " : echoall " + str+"\n"); return 1; } echo(str) { if (!str) { write ("Echo what?\n"); return 1; } say (str + "\n"); write ("You echo: " + str + "\n"); return 1; } echo_to(str) { object ob; string who; string msg; if (!str || sscanf(str, "%s %s", who, msg) != 2) { write("Echoto what ?\n"); return 1; } ob = find_living(lower_case(who)); if (!ob) { write("No player with that name.\n"); return 1; } tell_object(ob, msg + "\n"); write("You echo: " + msg + "\n"); log_file("ECHO", ctime(time()) + " " + name + " : echoto "+who+" "+msg+"\n"); return 1; } teleport(dest) { object ob; if (!dest) { write("Goto where ?\n"); return 1; } ob = find_living(dest); if (ob) { ob = environment(ob); if(!is_invis) say(cap_name + " " + mmsgout + ".\n"); move_object(myself, ob); if(!is_invis) say(cap_name + " " + mmsgin + ".\n"); display_look(ob, 0, brief); return 1; } dest = valid_read(mk_path(dest), WIZ); if (!dest || file_size("/" +dest + ".c") <= 0) { write("Invalid monster name or file name.\n"); return 1; } move_player("X#" + dest); return 1; } static destruct_all(force) { object ob, next; int temp_level; string err; ob = first_inventory(this_object()); while (ob) { _syslog("destruct_all(): destructing '"+file_name(ob)+"'."); next = next_inventory(ob); if (err = catch(destruct(ob))) { _syslog("destruct_all(): destruct() failed: " + err + "."); temp_level = level; level = 99; catch(_destruct(ob)); level = temp_level; } ob = next; } } quit() { string errstr; int tmp_level; save_me(0); last_login_time = extract(ctime(time()), 4, 15); errstr = catch(drop_all(1)); /* catch /pen 920116 */ if (errstr) { _syslog("Error in quit():drop_all() for player " + capitalize(name) + ": " + errstr + "."); destruct_all(1); } write("Saving "); write(capitalize(name)); write(".\n"); if (!is_invis && !is_linkdead) { #if 0 say(cap_name + " left the game.\n"); #else if (ghost) say("The mist left the game.\n"); else say(cap_name + " left the game.\n"); #endif } /* Notify mudfinger of the logout /Gwendolyn 930513 */ if(!is_invis || level <= 21) catch("/obj/daemon/mudwhod"->send_logout(this_object())); errstr = catch(destruct(this_object())); if (errstr) { _syslog("Error in quit():destruct() for player " + capitalize(name) + ": " + errstr + "."); tmp_level = level; level = 99; if (catch(_destruct(this_object()))) { level = tmp_level; _syslog("Error in quit():_destruct() for player " + capitalize(name) + ": " + errstr + "."); _disconnect(this_object()); } level = tmp_level; } return 1; } kill(str) { object ob; string living_ob; string weapon_ob; if (ghost) return 0; if (!str) { write("Kill what ?\n"); return 1; } ob = present(lower_case(str), environment(this_player())); if (!ob) { if (sscanf(str, "%s with %s", living_ob, weapon_ob)) { ob = present(lower_case(weapon_ob), this_player()); if (!ob) { write("Kill " + living_ob + " with what?\n"); return 1; } if (name_of_weapon != ob) if (wield(ob) == 0) return 1; str = living_ob; ob = present(lower_case(living_ob), environment(this_player())); } } if (!ob) { write("No " + str + " here !\n"); return 1; } if (!living(ob)) { write(str + " is not a living thing !\n"); say(cap_name + " tries foolishly to attack " + str + ".\n"); return 1; } if (ob == this_object()) { write("What ? Attack yourself ?\n"); return 1; } if (attacker_ob == ob || alt_attacker_ob == ob || ob->query_attack() == this_object()) { write("Yes, yes.\n"); return 1; } if (!attack_allowed(ob)) return 1; set_heart_beat(1); attack_object(ob); return 1; } communicate(str) { string verb; verb = query_verb(); if (str == 0) str = ""; if (verb[0] == "'"[0]) str = extract(verb, 1) + " " + str; write("Ok.\n"); if (ghost) { say(short() + " says: " + str + ".\n"); return 1; } say(cap_name + " says: " + str + "\n"); return 1; } int old_hp,old_sp; status idimode; toggle_idi() { idimode = !idimode; if(idimode) write("HP/SP info turned on.\n"); else write("HP/SP info turned off.\n"); return 1; } /* I made some small changes here, to restart the heart_beat * when a player loses it. I can see no bad side effects from * it. If you do, please tell me.... /Milamber */ static int cardiac; void restart_dah_heart_beat() { cardiac++; set_heart_beat(1); tell_object(this_object(),"Heart beat restarted."); log_file("LOSTHEARTBEAT",cap_name+", "+ctime(time())+" ("+cardiac+")\n"); tell_room(environment(),cap_name+" suddenly looks pale and utters: "+ "I had a cardiac attack!\n"); } static heart_beat() { call_out("restart_dah_heart_beat",1); /* Milamber */ if (!query_ip_number(this_object())) { set_heart_beat(0); if (!is_linkdead) { if (!ghost && !is_invis) say("Suddenly, " + capitalize(name) + " turns into stone!\n"); is_linkdead = 1; if (environment(this_object())) save_me(1); time_to_save = age + 500; statue_type = "a nice"; call_out("remove_statue", TICK_STATUE, 0); } remove_call_out("restart_dah_heart_beat"); return; } else { if (is_linkdead) { if (!ghost && !is_invis) say(capitalize(name) + " turns alive again!\n"); is_linkdead = 0; remove_call_out("remove_statue"); } } if (level < 23 && query_idle(this_object()) >= MAX_IDLE) /*Changed by Qqqq*/ { tell_object(this_object(), "\n** Maximum idle time reached.\n"); _disconnect(this_object()); } if (ghost) { remove_call_out("restart_dah_heart_beat"); /* Milamber */ return; } age += 1; if (age > time_to_save) { if (!abrief) write("Autosave.\n"); if(environment(this_object())) save_me(1); /* Angmar */ time_to_save = age + 500; } #ifdef USE_WETCODE if (wet_time > 0 && !environment(this_object())->query_property("waterfilled")) { wet_time--; if (random(40) == 0) { say("Some water drips from " + cap_name + ".\n"); write("Some water drips from you.\n"); } } #endif if (intoxicated && random(40) == 0) { int n; n = random(7); if (n == 0) { say(cap_name + " hiccups.\n"); write("You hiccup.\n"); } if (n == 1) { say(cap_name + " seems to fall, but takes a step and recovers.\n"); write("You stumble.\n"); } if (n == 3) { write("You feel drunk.\n"); say(cap_name + " looks drunk.\n"); } if (n == 5) { say(cap_name + " burps.\n"); write("You burp.\n"); } } /* No obvious effects of being stuffed or soaked */ if (hit_point < max_hp || spell_points < max_sp || intoxicated || headache) { time_to_heal -= 1; if (time_to_heal < 0) { if (headache) { headache -= 1; if (headache == 0) tell_object(myself, "You no longer have a headache.\n"); } if (hit_point < max_hp) { hit_point += 1; if (intoxicated) hit_point += 3; if (hit_point > max_hp) hit_point = max_hp; } if (spell_points < max_sp) { spell_points += 1; if (intoxicated) spell_points += 3; if (spell_points > max_sp) spell_points = max_sp; } if (intoxicated) { intoxicated -= 1; if (intoxicated == 0) { headache = max_headache; max_headache = 0; tell_object(myself,"You suddenly without reason"+ " get a bad headache.\n"); hit_point -= 3; if (hit_point < 0) hit_point = 0; } } time_to_heal = INTERVAL_BETWEEN_HEALING; } } if(idimode) { if(hit_point != old_hp || spell_points != old_sp) { tell_object(myself,"** HP: "+hit_point+"/"+max_hp+ " SP: "+spell_points+"/"+max_sp+"\n"); old_hp = hit_point; old_sp = spell_points; } } if (stuffed) stuffed--; if (soaked) soaked--; if (attacker_ob) attack(); if (attacker_ob && whimpy && hit_point < (whimpy>1?whimpy:max_hp/5)) run_away(); remove_call_out("restart_dah_heart_beat"); /* Milamber */ } /* * Update our aligment. */ add_alignment(a) { if (!intp(a)) { write("Bad type argument to add_alignment.\n"); return; } alignment = alignment*9/10 + a; if (level > 20) return; switch(alignment) { case KILL_NEUTRAL_ALIGNMENT*100+1..0x7fffffff: al_title="saintly"; return; case KILL_NEUTRAL_ALIGNMENT*20+1..KILL_NEUTRAL_ALIGNMENT*100: al_title="good"; return; case KILL_NEUTRAL_ALIGNMENT*4+1..KILL_NEUTRAL_ALIGNMENT*20: al_title="nice"; return; case -KILL_NEUTRAL_ALIGNMENT*4+1..KILL_NEUTRAL_ALIGNMENT*4: al_title="neutral"; return; case -KILL_NEUTRAL_ALIGNMENT*20+1..-KILL_NEUTRAL_ALIGNMENT*4: al_title="nasty"; return; case -KILL_NEUTRAL_ALIGNMENT*100+1..-KILL_NEUTRAL_ALIGNMENT*20: al_title="nasty"; return; default: al_title="demonic"; return; } } set_al(a) { if (intp(a)) alignment = a; } set_alignment(al) { al_title = al; } test_dark() { if (set_light(0) <= 0) { write("It is too dark.\n"); return 1; } return 0; } put(str) { int i; string item; string container; object item_o; object container_o; if (!str) return 0; if (test_dark()) return 1; if (sscanf(str, "%s in %s", item, container) != 2) { write("put what ?\n"); return 1; } container = lower_case(container); container_o = present(container, this_player()); if (!container_o) container_o = present(container, environment(this_player())); if (!container_o) { write("There are no " + container + "s here!\n"); return 1; } if (!call_other(container_o, "can_put_and_get", 0)) { write("You can't do that.\n"); return 1; } item = lower_case(item); item_o = present(item, this_player()); if (!item_o) { write("You have no " + item + "!\n"); return 1; } if (item_o == container_o) return 0; if (call_other(item_o, "prevent_insert", container_o)) return 1; if (call_other(item_o, "drop")) return 1; if (!item_o) return 1; i = call_other(item_o, "query_weight"); if (call_other(container_o, "add_weight", i)) { /* Remove the weight from the previous container. */ call_other(environment(item_o), "add_weight", -i); if (item_o == name_of_weapon && item_o->query_weapon()) { item_o->unwield(); stop_wielding(); } move_object(item_o, container_o); say(cap_name + " puts the " + item + " in the " + container + ".\n"); write("Ok.\n"); it = item; return 1; } write("There is not room for more.\n"); return 1; } pick_up(str) { string item; string container; object item_o; object container_o; int weight; if (!str) { write("What ?\n"); return 1; } if (ghost) { write("You fail.\n"); return 1; } if (test_dark()) return 1; if (str == "all") { get_all(environment()); return 1; } if (sscanf(str, "%s from %s", item, container) != 2) { pick_item(str); return 1; } container_o = present(lower_case(container)); if (!container_o) { write("There is no " + container + " here.\n"); return 1; } if (!call_other(container_o, "can_put_and_get", 0)) { write("You can't do that!\n"); return 1; } if (item == "all") { get_all(container_o); return 1; } item_o = present(item, container_o); if (!item_o) { write("There is no " + item + " in the " + container + ".\n"); return 1; } if (!call_other(item_o, "get", item)) { write("You can not take " + item + " from " + container + ".\n"); return 1; } weight = call_other(item_o, "query_weight", 0); if (!add_weight(weight)) { write("You can not carry more.\n"); return 1; } call_other(container_o, "add_weight", -weight); move_object(item_o, myself); write("Ok.\n"); say(cap_name + " takes " + item + " from " + container + ".\n"); return 1; } pick_item(obj) { object ob; int i; if (this_player() != this_object()) return 0; obj = lower_case(obj); if (environment(this_player())->id(obj)) { write("You can't take that.\n"); return 1; } ob = present(obj, environment(this_player())); if (!ob) { write("That is not here.\n"); return 1; } if (ghost) { write("You fail.\n"); return 1; } if (environment(ob) == myself) { write("You already have it!\n"); return 1; } if (call_other(ob, "get", 0) == 0) { write("You can not take that!\n"); return 1; } i = call_other(ob, "query_weight", 0); if (add_weight(i)) { move_object(ob, myself); say(cap_name + " takes " + obj + ".\n"); it = obj; write("Ok.\n"); return 1; } write("You can't carry that much.\n"); return 1; } drop_thing(obj) { string tmp; string tmp2; int i; int coins; if (!obj) { write("What ?\n"); return 1; } if (obj == "all") { drop_all(1); return 1; } if (sscanf(obj, "%s in %s", tmp, tmp2) == 2) { put(obj); return 1; } if (obj == "money" || obj == "all money") { drop_all_money(1); return 1; } if (sscanf(obj, "%d coins", coins) || sscanf(obj, "%d gold coins", coins)) { drop_money(coins); return 1; } if (obj == "1 coin" || obj == "1 gold coin") { drop_money(1); return 1; } tmp = obj; obj = present(lower_case(obj), this_player()); if (!obj) { write("That is not here.\n"); return 1; } if (drop_one_item(obj)) { it = tmp; write("Ok.\n"); say(cap_name + " drops the " + tmp + ".\n"); } return 1; } add_weight(w) { int max; max = query_str() + 10; /* Mats: was level + 10 */ if (frog) max = max / 2; if ((w + local_weight > max) && (w > 0)) /* Oros 910422 */ return 0; if(w + local_weight < 0) return 0; local_weight += w; return 1; } /* * Temporary move the player to another destination and execute * a command. */ static in_room(str) { object room; object old_room; string cmd; if (this_player() != this_object()) return 0; if (!str) return 0; if (sscanf(str, "%s %s", room, cmd) != 2) { write("Usage: in ROOM CMD\n"); return 1; } room = mk_path(room); room = valid_read(room, WIZ); if (!room) { write("Invalid file name.\n"); return 1; } old_room = environment(); move_object(myself, room); command(cmd); if (old_room) move_object(myself, old_room); else write("Could not go back again.\n"); return 1; } shout_to_all(str) { if (spell_points < 0) { write("You are low on power.\n"); return 1; } if (level < 20) spell_points -= 30; if (!str) { write("Shout what ?\n"); return 1; } if (ghost) { write("You fail.\n"); return 1; } if (!frog) { SHOUT(cap_name + " shouts: " + str + "\n"); } else { SHOUT(cap_name + " the frog shouts: " + "Hriibit! Hrriiibit!" + "\n"); } write("Ok.\n"); return 1; } emote(str) { if (this_player() != this_object()) return 0; if (!str) { write("emote what ?\n"); return 1; } say(cap_name + " " + str + "\n"); write("Ok.\n"); return 1; } inventory() { object ob,magobj; if (test_dark()) return 1; magobj = present("magobj"); ob = first_inventory(myself); while(ob) { string str; string name; str = call_other(ob, "short", 0); if (str && stringp(str)) { write(capitalize(str)); if (name_of_weapon && ob == name_of_weapon) if (name_of_weapon->query_property("cursed")) write(" (wielded & cursed)"); else write(" (wielded)"); if (magobj && magobj->check_bound(ob)) write(" (bounded)"); write(".\n"); it = str; } ob = next_inventory(ob); } return 1; } examine(str) { if (!str) { /* Mats 920117 */ write("Examine what?\n"); return 1; } return look("at " + str); } #if 0 static find_item(item, norecflag) { object ob; ob = present(item, this_player()); if (!ob && call_other(environment(this_player()), "id", item)) ob = environment(this_player()); if (!ob) ob = present(item, environment(this_player())); if (!ob && !norecflag) if (sscanf(item, "the %s", item) == 1) return find_item(item, 1); return ob; } #endif look(str) { object ob, ob_tmp, magobj; object wield_ob; string item; int max; if (environment()->dark(str)) /* Mats */ return 1; if (test_dark()) return 1; if (!str || str == "at room" || str == "around" || str == "at the room") { display_look(environment(), 0, 0); return 1; } magobj = present("magobj"); if (sscanf(str, "at %s", item) == 1 || sscanf(str, "in %s", item) == 1) { int weight; string desc; item = lower_case(item); /* ob = find_item(item, 0); */ /* Changed by Padrone, since env->long("the whatever") doesn't work: */ ob = present(item, this_player()); if (!ob && environment(this_player())->id(item)) ob = environment(this_player()); if (!ob) ob = present(item, environment(this_player())); if (!ob && sscanf(item, "the %s", item) == 1) { ob = present(item, this_player()); if (!ob && environment(this_player())->id(item)) ob = environment(this_player()); if (!ob) ob = present(item, environment(this_player())); } if (!ob) { /* This is an experiment by Padrone (August 1, 1992): */ if (environment(this_player())->query_mentioned_in_long(item)) { write("You look at the " + item + ", but you see nothing special.\n"); return 1; } /* if (sscanf(item, "%ss", str)) - Nope! Padrone, July 30, 1992 */ if (item[strlen(item) - 1] == 's') write("There are no " + item + " here.\n"); else write("There is no " + item + " here.\n"); return 1; } wield_ob = ob->query_wield(); it = item; desc = ob->query_long_desc(item); if (desc) write(desc); else { desc = ob->long(item); if (stringp( desc )) write( desc); } weight = ob->query_weight(); if (!living(ob)) { if (weight >= 5) write("It looks very heavy.\n"); else if (weight >= 3) write("It looks heavy.\n"); } if (magobj && magobj->check_bound(ob)) write("It is magically bounded to you.\n"); if (!call_other(ob, "can_put_and_get", item)) return 1; { object special; special = first_inventory(ob); while(special) { string extra_str; extra_str = call_other(special, "extra_look"); if (extra_str) write(capitalize(extra_str) + ".\n"); special = next_inventory(special); } ob_tmp = first_inventory(ob); while(ob_tmp && call_other(ob_tmp, "short") == 0) ob_tmp = next_inventory(ob_tmp); if (ob_tmp) { if (living(ob)) { write("\t" + capitalize(item) + " is carrying:\n"); } else write("\t" + capitalize(item) + " contains:\n"); } max = MAX_LIST; ob = first_inventory(ob); while(ob && max > 0) { string sh; sh = ob->short(); if (stringp(sh)) { write(capitalize(sh)); if (/* wield_ob == ob && */ ob->query_wielded()) write(" (wielded)"); if (magobj && magobj->check_bound(ob)) write(" (bounded)"); write(".\n"); } ob = next_inventory(ob); max -= 1; } } return 1; } write("Look AT something, or what ?\n"); return 1; } static check_access() { string ip; string a,b,c,d; ip = query_ip_number(); if(!allow_from_host) return 1; if(member_array(ip,allow_from_host) != -1) return 1; sscanf(ip,"%s.%s.%s.%s",a,b,c,d); if(member_array(a+"."+b+"."+c+".*",allow_from_host) != -1) return 1; if(member_array(a+"."+b+".*.*",allow_from_host) != -1) return 1; if(member_array(a+".*.*.*",allow_from_host) != -1) return 1; if(member_array("*.*.*.*",allow_from_host) != -1) return 1; return 0; } static add_access(str) { int i; if(!str) { if(allow_from_host) { write("Login allowed from:\n"); for(i = 0; i < sizeof(allow_from_host); i++) write(allow_from_host[i]+"\n"); } else { write("All hosts allowed.\n"); } return 1; } if(allow_from_host) { if(member_array(str,allow_from_host) == -1) allow_from_host += ({ str }); } else allow_from_host = ({ str }); if(member_array(query_ip_number(),allow_from_host) == -1) allow_from_host += ({ query_ip_number() }); write("Ok.\n"); return 1; } static rem_access_mapper(elm,host) { if(elm == host) return 0; else return 1; } static rem_access(str) { int pos; if(!str) return 0; if(str == "all") allow_from_host = 0; else { if(allow_from_host) allow_from_host = filter_array(allow_from_host,"rem_access_mapper", this_object(),str); if(sizeof(allow_from_host) == 0) allow_from_host = 0; } write("Ok.\n"); return 1; } static set_use_rlogin() { if(use_rlogin) { write("Rlogin turned off.\n"); use_rlogin = 0; save_me(1); } else { write("Rlogin turned on.\n"); use_rlogin = 1; save_me(1); } return 1; } static check_password(p) { object magobj; remove_call_out("time_out"); write("\n"); /* Pell */ if (password == 0) write("You have no password ! Set it with the 'password' cmd.\n"); else if (name != "guest" && crypt(p, password) != password) { write("Wrong password!\n"); name = 0; cap_name = 0; level = -1; destruct(myself); return; } move_player_to_start(0); #ifdef LOG_ENTER log_file("ENTER", name + ", " + extract(ctime(time()), 4, 15)+ " from " + ( ident_user ? ident_user + "@" : "") + query_ip_name() + ".\n"); #endif magobj=clone_object("obj/magobj"); move_object(magobj,myself); } /* * Give a new password to a player. */ static new_password(p) { object magobj; write("\n"); /* Pell */ if (!p || p == "") { write("Try again another time then.\n"); destruct(myself); return; } if (strlen(p) < 6) { write("The password must have at least 6 characters.\n"); input_to("new_password", 1); write("Password: "); return; } if (password == 0) { password = p; input_to("new_password", 1); write("Password: (again) "); return; } remove_call_out("time_out"); if (password != p) { write("You changed !\n"); destruct(myself); return; } password = crypt(password, 0); level = 0; call_other("room/adv_guild", "advance", 0); level = 1; /* can't use set_level if level < 1... Wing 920503 */ set_str(1); set_con(1); set_int(1); set_dex(1); hit_point = max_hp; move_player_to_start(0); #ifdef LOG_NEWPLAYER log_file("NEWPLAYER", cap_name + " " + ctime(time()) + " from " + ( ident_user ? ident_user +"@" : "") + query_ip_name()+".\n"); #endif magobj=clone_object("obj/magobj"); move_object(magobj,myself); } static move_player_to_start(where) { if (!mailaddr || mailaddr == "") { write("Please enter your email address (or 'none'): "); saved_where = where; input_to("getmailaddr"); return; } move_player_to_start2(where); } set_mailaddr(addr) { mailaddr = addr; } query_mailaddr() { return mailaddr; } static getmailaddr(maddr) { mailaddr = maddr; move_player_to_start2(saved_where); } static move_player_to_start2(where) { if (gender == -1) { write("Are you, male, female or other: "); input_to("getgender", where); return; } move_player_to_start3(where); } /* This function is called using input_to, and sets the * gender of this player. */ static getgender(gender_string) { gender_string = lower_case(gender_string); if (gender_string[0] == 'm') { write("Welcome, Sir!\n"); gender = MALE_GENDER; } else if (gender_string[0] == 'f') { write("Welcome, Madam!\n"); gender = FEMALE_GENDER; } else if (gender_string[0] == 'o') { write("Welcome, Creature!\n"); gender = NEUTER_GENDER; } else { write("Sorry, but that is too weird for this game!\n"); write("Are you, male, female or other (type m, f or o): "); input_to("getgender"); return; } write("Be sure to do 'help playerkilling' when you login.\n"); move_player_to_start3(saved_where); } static move_player_to_start3(where) { object ob; /* * See if we are already playing. * We must blank our own name, or we could find ourselves ! */ xx_realname = name; name = 0; other_copy = find_player(xx_realname); /* Find playing player */ if (!other_copy) other_copy = find_living(xx_realname); if (!other_copy) other_copy = find_living("ghost of " + xx_realname); if (other_copy) { while (other_copy && other_copy->query_npc()) { /* Got a monster with that name! - a wizard has fucked up, or LPMUD has.. */ destruct(other_copy); other_copy = find_living(xx_realname); } if (other_copy) { if(query_ip_number(other_copy)) { /*Added by Qqqq*/ write("You are already playing !\n"); write("Throw the other copy out ? "); input_to("try_throw_out"); name = xx_realname; return; } else { name = xx_realname; write("You are already playing, I will remove your statue.\n"); try_throw_out("yes"); return; } } } name = xx_realname; restore_object("players/" + name); ident_user = _query_ident(); last_login_time = extract(ctime(time()), 4, 15); save_object("players/" + name); /* enable_commands(); */ set_living_name(name); /* * Initilize the character stats, if not already done. if (!stats_is_updated) { int tmp; tmp = level; if (tmp > 20) tmp = 20; set_str(tmp); set_int(tmp); set_con(tmp); set_dex(tmp); stats_is_updated = 1; } not needed anymore, Mats 930409 */ max_hp = 42 + Con * 8; /*temporary*/ if(hit_point>max_hp) /*temporary*/ hit_point=max_hp; /*temporary*/ max_sp = 42 + Int * 8; /*temporary*/ if(spell_points>max_sp) /*temporary*/ spell_points=max_sp; /*temporary*/ /* * Now we can enter the game. Check tot_value if the game * crashed, and the values of the player was saved. */ set_heart_beat(1); add_standard_commands(); if (level >= 20) { wiz_commands(); init_wiz_line(); } if (level >= 21) wiz_commands2(); move_object(clone_object("obj/soul"), myself); if (tot_value) { write("You find " + tot_value + " coins of your lost money!\n"); money += tot_value; tot_value = 0; } write("\n"); cat("/etc/NEWS"); write("\n"); if (where) move_object(myself, where); else { if(level > 19) { where = getenv(START); if(where) if(!find_object(where)) if(catch(call_other(where, "????"))) where = 0; } if(!where) where = "room/church"; move_object(myself, where); load_auto_obj(auto_load); } if (is_invis && level < 20) vis(); /* Notify mudfinger of the login /Gwendolyn 930513 */ if(!is_invis || level <= 21) catch("/obj/daemon/mudwhod"->send_login(this_object())); /* To decide the number of quest points *this* player will have to collect. * Done here, so it is set for old players too, if they haven't had it set. */ if (my_quest_max == 0) my_quest_max = call_other("room/quest_room", "count_all"); if (!is_invis && !is_linkdead) #if 0 say(cap_name + " enters the game.\n"); #else { if (ghost) say("Some mist enters the game.\n"); else say(cap_name + " enters the game.\n"); } #endif else if (is_invis) write("YOU ARE INVISIBLE !\n\n"); if (level >= 21) { cat("/etc/WIZNEWS"); write("\n"); } call_other("room/post", "query_mail", 0); host = 0; if (!called_from_host) called_from_host = called_from_ip; if (query_ip_number(this_object()) != called_from_ip && called_from_ip || _query_ident() != called_from_user && called_from_user) { if (called_from_user) write("Your last login was from " + called_from_user + "@" + called_from_host + "\n"); else write("Your last login was from " + called_from_host + "\n"); } called_from_user = _query_ident(); called_from_ip = query_ip_number(this_object()); called_from_host = query_host(); ob = first_inventory(environment()); while(ob) { if (ob != this_object()) { string sh; sh = call_other(ob, "short"); if (sh && stringp(sh)) write(capitalize(sh) + ".\n"); } ob = next_inventory(ob); } current_path = "players/" + name; add_call_back(TITLE, this_object(), "fix_title"); if(!(sh = getenv(TITLE))) sh = title; setenv(TITLE, sh); } tail_file(path) { if (this_player() != this_object()) return 0; if (!path) return 0; if (!tail(mk_path(path))) return 0; return 1; } status help(string what) { if(what == "wizard" && level >= 20) { cat("/doc/wiz_help"); return 1; } if(what) { if(cat("/doc/helpdir/" + substitute_string(what, " ", "_", 1)) == 0) { notify_fail("No help available on '" + what + "'.\n"); return 0; } return 1; } cat("/doc/help"); return 1; } tell(string str) { object ob; string who, msg; if(this_player() != this_object()) return 0; if(ghost) return write("You fail.\n"), 1; if(spell_points < 0) return write("You are low on power.\n"), 1; if(!str || sscanf(str, "%s %s", who, msg) != 2) return write("Tell whom what?\n"), 1; it = lower_case(who); if(!(ob = present(it, environment(this_player()))) || !living(ob)) ob = find_living(it); if(!ob || (!ob->short() && level < (int) ob->query_level())) return write("No player with that name.\n"), 1; if(sscanf(file_name(ob), "obj/player#%*d") && !interactive(ob)) { write("That player has lost " + (string) ob->query_possessive() + " connection with reality.\n"); return 1; } /* If we are invisible, and talking to a wizard who is of higher level than we, then give him our real name */ if(is_invis && ((int) ob->query_level() > level || level >= 23)) tell_object(ob, capitalize(query_real_name()) + " tells you: " + msg + "\n"); else tell_object(ob, cap_name + " tells you: " + msg + "\n"); spell_points -= 5; write("Ok.\n"); return 1; } whisper(str) { object ob; string who; string msg; if (this_player() != this_object()) return 0; if (ghost) { write("You fail.\n"); return 1; } if (!str || sscanf(str, "%s %s", who, msg) != 2) { write("Whisper what ?\n"); return 1; } it = lower_case(who); ob = present(it, environment(this_player())); if (!ob || !living(ob)) { write("No player with that name in this room.\n"); return 1; } tell_object(ob, cap_name + " whispers to you: " + msg + "\n"); write("Ok.\n"); say(cap_name + " whispers something to " + capitalize(who) + ".\n", ob); return 1; } string *get_dir(string dir) { string *files; if(files = efun::get_dir(dir)) return files - ({ ".", ".." }); else return 0; } /*Added by Qqqq, used to update or load a dir*/ static check_dir(path) { string dir; if (query_level_sec()<23 && !valid_write(path+"/foo")) { write("Access denied.\n"); return 0; } if(path != "/") if(file_size(path+"/") != -2) { write("It isn't any directory.\n"); return 0; } dir = get_dir(path+"/"); if (!sizeof(dir)) { write("The directory is empty.\n"); return 0; } return dir; } static changed_dir(str) { string dir,text; int i,cflag; object obj; cflag = 1; if (query_verb() == "updir") text = "updated"; else text = "loaded"; if (str != "-c") { change_dir = mk_path(str); cflag = 0;} if (!(dir = check_dir(change_dir))) return 1; if(!(dir = filter_files2(dir,change_dir+"/","",1))) return 1; if (cflag && change_file && (cflag = member_array(change_file,dir)+1)) dir =slice_array(dir,cflag,sizeof(dir)-1); if (query_verb() == "updir") { for(i=0;ishow_stats(); return 1; } /* * This routine is called from other routines to drop one specified object. * We return true if success. */ /* changed by Angmar 90-09-12 */ /* This function was made static, wich caused compatibility problems. */ drop_one_item(ob) { int weight; object obj; if (call_other(ob, "drop", 0) || (obj = present("magobj")) && obj->check_bound(ob)) return 0; if (!ob) return 1; if (ob == name_of_weapon && ob->query_weapon()) { ob->unwield(); stop_wielding(); } weight = call_other(ob, "query_weight", 0); if (!weight) weight = 0; add_weight(-weight); move_object(ob, environment(myself)); return 1; } drop_all(verbose) { object ob; object next_ob; if (!myself || !living(myself)) return; ob = first_inventory(myself); while(ob) { string out; next_ob = next_inventory(ob); it = call_other(ob, "short", 0); if (drop_one_item(ob) && verbose && it) { out = it + ".\n"; say(cap_name + " drops " + out); tell_object(myself, "drop: " + out); } ob = next_ob; } } static shut_down_game(str) { if (!str) { write("You must give a shutdown reason as argument.\n"); return 1; } shout("Game is shut down by " + capitalize(name) + ".\n"); #ifdef LOG_SHUTDOWN log_file("GAME_LOG", ctime(time()) + " Game shutdown by " + name + "(" + str + ")\n"); #endif shutdown(); return 1; } /* * Check that a player name is valid. Only allow * lowercase letters. */ valid_name(str) { int i, length; if (str == "logon") { write("Invalid name"); return 0; } length = strlen(str); if (length > 11) { write("Too long name.\n"); log_file("BAD_NAME", str + "\n"); return 0; } i=0; while(i 'z') { write("Invalid characters in name:" + str + "\n"); write("Character number was " + (i+1) + ".\n"); return 0; } i += 1; } return 1; } /* * This one is called when the player wants to change his password. */ static change_password(str) { if (password != 0 && !str) { write("Give old password as an argument.\n"); return 1; } if (password != 0 && password != crypt(str, password)) { write("Wrong old password.\n"); return 1; } password2 = 0; input_to("change_password2", 1); write("New password: "); return 1; } static change_password2(str) { if (!str) { write("Password not changed.\n"); return; } if(strlen(str)<6) { write("Password must have at least 6 characters.\n"); return; } if (password2 == 0) { password2 = str; input_to("change_password2", 1); write("Again: "); return; } if (password2 != str) { write("Wrong! Password not changed.\n"); return; } password = crypt(password2, 0); password2 = 0; write("Password changed.\n"); } static bug(str) { if (!str) { write("Give an argument.\n"); return 1; } log_file("BUGS", "\n"); log_file("BUGS", cap_name + " (" + file_name(environment(this_object())) + "): "+ extract(ctime(time()) ,4,15)+"\n"); log_file("BUGS", str + "\n"); smart_report("Bug " + query_real_name() + "\n" + str); write("Ok.\n"); return 1; } static typo(str) { if (!str) { write("Give an argument.\n"); return 1; } log_file("TYPO", cap_name + " (" + file_name(environment(this_object())) + "): "+ extract(ctime(time()) ,4,15)+"\n"); log_file("TYPO", str + "\n"); smart_report("Typo " + query_real_name() + "\n" + str); write("Ok.\n"); return 1; } static idea(str) { if (!str) { write("Give an argument.\n"); return 1; } log_file("IDEA", cap_name + ": "+extract(ctime(time()) ,4,15)+"\n"); log_file("IDEA", str + "\n"); smart_report("Idea " + query_real_name() + "\n" + str); write("Ok.\n"); return 1; } static converse() { write("Give '**' to stop.\n"); write("]"); input_to("converse_more"); return 1; } static converse_more(str) { string cmd; if (str == "**") { write("Ok.\n"); return; } if (str[0] == '!') { sscanf(str, "!%s", cmd); command(cmd); } else if (str != "") { say(cap_name + " says: " + str + "\n"); } write("]"); input_to("converse_more"); } static toggle_whimpy(h) { if (!h) whimpy = !whimpy; else sscanf(h,"%d",whimpy); /* Mats 921030 */ if (whimpy) write("Wimpy mode.\n"); else write("Brave mode.\n"); return 1; } query_brief() { return brief; } toggle_brief() { brief = !brief; if (brief) write("Brief mode.\n"); else write("Verbose mode.\n"); return 1; } toggle_abrief() { abrief = !abrief; if (abrief) write("Autosave hide mode.\n"); else write("Autosave verbose mode.\n"); return 1; } add_exp(e) { #ifdef LOG_EXP if (this_player() && ( e<0 || (this_player() != this_object() && query_ip_number(this_player()) && level < 20 && (e >= ROOM_EXP_LIMIT)))) log_file("EXPERIENCE", ctime(time()) + " " + name + "(" + level + ") " + e + " exp by " + this_player()->query_real_name() + "(" + this_player()->query_level() + ")" +"\n"+ file_name(previous_object())+"\n"); #endif experience += e; if (level < 4 && experience > (level*1000+500)) experience = level*1000+500; if (level <= 19) add_worth(e); } sober() { intoxicated = 0; } add_intoxination(i) { if(i < 0) { if (-i > intoxicated / 10) i = -intoxicated / 10; } intoxicated += i; if(intoxicated < 0) intoxicated = 0; } query_intoxination() { return intoxicated; } query_stuffed() { return stuffed; } query_soaked() { return soaked; } add_stuffed(i) { if(i < 0) { if (-i > stuffed / 10) i = -stuffed / 10; } stuffed += i; if (stuffed < 0) stuffed = 0; } add_soaked(i) { if(i < 0) { if (-i > soaked / 10) i = -soaked / 10; } soaked += i; if (soaked < 0) soaked = 0; } second_life() { string tmp,tmp2; if (level >= 20) return illegal_patch("second_life"); make_scar(); ghost = 1; if (attacker_ob) { /* Pell */ tmp = creator(attacker_ob); tmp2 = attacker_ob->query_name(); if (!tmp) { if (attacker_ob->query_npc()) tmp = "npc"; else { /* Anvil 910606 Invisible wizards was logged as Someone */ tmp2 = capitalize(attacker_ob->query_real_name()); tmp = "player"; } } } else tmp = "none"; #ifdef LOG_KILLS log_file("KILLED", cap_name + " (" + level + ") " + ", by " + tmp2 + " ("+ tmp +") "+ extract(ctime(time()), 4, 15)+ ".\n"); #endif if (level > 1) level--; if (Str > 1) set_str(Str-1); if (Con > 1) set_con(Con-1); if (Dex > 1) set_dex(Dex-1); if (Int > 1) set_int(Int-1); msgin = "drifts around"; msgout = "blows"; headache = 0; intoxicated = 0; stuffed = 0; soaked = 0; hunter = 0; hunted = 0; attacker_ob = 0; alt_attacker_ob = 0; tell_object(myself, "\nYou die.\nYou have a strange feeling.\n" + "You can see your own dead body from above.\n\n"); say(cap_name + " died.\n"); /* Mats 920317 */ return 1; } remove_ghost() { if (!ghost) return 0; write("You feel a very strong force.\n"); write("You are sucked away...\n"); write("You reappear in a more solid form.\n"); say("Some mist disappears.\n"); say(cap_name + " appears in a solid form.\n"); ghost = 0; fake_ghost = 0; /* Special for Ramses guild..sigh.. */ dead = 0; msgin = "arrives"; msgout = "leaves"; add_alignment(-alignment/2); save_me(1); return 1; } static trans(str) { object ob; string out; if (this_player() != this_object() || !environment(this_player())) return 0; if (!str) return 0; ob = find_living(str); if (!ob) { write("No such living thing.\n"); return 1; } it = str; #if 1 tell_object(ob, "You are magically transfered somewhere.\n"); out = call_other(ob, "query_mmsgin", 0); if (!out) out = capitalize(ob->query_name()) + " arrives in a puff of smoke.\n"; else out = capitalize(ob->query_name()) + " " + out + ".\n"; say(out); write(out); move_object(ob, environment(this_object())); #else ob->move_player("X", environment(this_player())); #endif return 1; } stop_hunting_mode() { if (!hunted) { write("You are not hunting anyone.\n"); return 1; } call_other(hunted, "stop_hunter"); hunted = 0; write("Ok.\n"); return 1; } drink_alcohol(strength) { if (intoxicated > level + 3) { write("You fail to reach the drink with your mouth.\n"); return 0; } intoxicated += strength; if (intoxicated < 0) intoxicated = 0; if (intoxicated == 0) write("You are completely sober.\n"); if (intoxicated > 0 && headache) { headache = 0; tell_object(myself, "Your headache disappears.\n"); } if (intoxicated > max_headache) max_headache = intoxicated; if (max_headache > 8) max_headache = 8; return 1; } drink_alco(strength) { if (intoxicated + strength > level * 3) { write("You fail to reach the drink with your mouth.\n"); return 0; } intoxicated += strength / 2; if (intoxicated < 0) intoxicated = 0; if (intoxicated == 0) write("You are completely sober.\n"); if (intoxicated > 0 && headache) { headache = 0; tell_object(myself, "Your headache disappears.\n"); } if (intoxicated > max_headache) max_headache = intoxicated; if (max_headache > 8) max_headache = 8; return 1; } drink_soft(strength) { if (soaked + strength > level * 8) { write("You can't possibly drink that much right now!\n" + "You feel crosslegged enough as it is.\n"); return 0; } soaked += strength * 2; if (soaked < 0) soaked = 0; if (soaked == 0) write("You feel a bit dry in the mouth.\n"); return 1; } eat_food(strength) { if (stuffed + strength > level * 8) { write("This is much too rich for you right now! Perhaps something lighter?\n"); return 0; } stuffed += strength * 2; if (stuffed < 0) stuffed = 0; if (stuffed == 0) write("Your stomach makes a rumbling sound.\n"); return 1; } spell_missile(str) { object ob; if (test_dark()) return 1; if (level < 5) return 0; if (!str) ob = attacker_ob; else ob = present(lower_case(str), environment(this_player())); if (!ob || !living(ob)) { write("At whom ?\n"); return 1; } if (ob == myself) { write("What ?\n"); return 1; } if (!attack_allowed(ob)) return 1; set_heart_beat(1); missile_object(ob); return 1; } spell_shock(str) { object ob; if (test_dark()) return 1; if (level < 10) return 0; if (!str) ob = attacker_ob; else ob = present(lower_case(str), environment(this_player())); if (!ob || !living(ob)) { write("At whom ?\n"); return 1; } if (ob == myself) { write("What ?\n"); return 1; } if (!attack_allowed(ob)) return 1; set_heart_beat(1); shock_object(ob); return 1; } spell_fire_ball(str) { object ob; if (test_dark()) return 1; if (level < 15) return 0; if (!str) ob = attacker_ob; else ob = present(lower_case(str), environment(this_player())); if (!ob || !living(ob)) { write("At whom ?\n"); return 1; } if (ob == myself) { write("What ?\n"); return 1; } if (!attack_allowed(ob)) return 1; set_heart_beat(1); fire_ball_object(ob); return 1; } spell_zap(str) { object ob; if (this_player() != this_object()) return 0; if (!str) ob = attacker_ob; else ob = present(lower_case(str), environment(this_player())); if (!ob || !(interactive(ob) || ob->query_npc())) { write("At whom ?\n"); return 1; } if (!attack_allowed(ob)) return 1; zap_object(ob); return 1; } give_object(str) { string item, dest; object item_ob, dest_ob; int weight; int coins; if (!str) return 0; if (test_dark()) return 1; if (sscanf(str, "%d coins to %s", coins, dest) == 2) item = 0; else if ( sscanf(str, "1 coin to %s", dest) == 1) coins = 1; else if ( sscanf(str, "coin to %s", dest) == 1) coins = 1; else if (sscanf(str, "one coin to %s", dest) == 1) coins = 1; else if (sscanf(str, "%s to %s", item, dest) != 2) { write("Give what to whom ?\n"); return 1; } dest = lower_case(dest); if (item) { item = lower_case(item); item_ob = present(item, this_player()); if (!item_ob) { write("There are no " + item + " here.\n"); return 1; } it = item; if (environment(item_ob) == this_object() && call_other(item_ob, "drop", 0) == 1) { return 1; } else { if (!call_other(item_ob, "get")) { write("You can't get that !\n"); return 1; } } if (name_of_weapon == item_ob && item_ob->query_weapon()) { item_ob->unwield(); stop_wielding(); } } dest_ob = present(dest, environment(this_player())); if (!dest_ob) { write("There is no " + capitalize(dest) + " here.\n"); return 1; } if (!living(dest_ob)) { write("You can't do that.\n"); return 1; } if (!item) { if (coins <= 0 && level < 20) return 0; if (money < coins) { write("You don't have that much money.\n"); return 1; } money -= coins; /* Checkpoint the character, to prevent cheating */ if (coins > 1000 && level < 20) save_me(1); call_other(dest_ob, "add_money", coins); tell_object(dest_ob, cap_name + " gives you " + coins + " gold coins.\n"); write("Ok.\n"); return 1; } weight = call_other(item_ob, "query_weight", 0); if (!call_other(dest_ob, "add_weight", weight)) { write(capitalize(dest) + " can't carry any more.\n"); return 1; } add_weight(-weight); move_object(item_ob, dest_ob); /* * say(cap_name + " gives " + item + " to " + capitalize(dest) + ".\n", dest_ob); * tell_object(dest_ob, cap_name + " gives you " + item + ".\n"); * -- Who "fixed" this? Lots of old code depends on the exact wording of, * among others, this message! And why wasn't it recorded in ChangeLog? * Padrone (who fixed the fix), May 28, 1993 */ say(cap_name + " gives " + item + " to " + capitalize(dest) + ".\n"); write("Ok.\n"); return 1; } /* * Get all items here. */ get_all(from) { object ob, next_ob; if (this_player() != this_object()) return 0; ob = first_inventory(from); while(ob) { string item; next_ob = next_inventory(ob); item = call_other(ob, "short", 0); if (item && call_other(ob, "get", 0)) { int weight; weight = call_other(ob, "query_weight", 0); if (add_weight(weight)) { write(capitalize(item) + ": Ok.\n"); move_object(ob, this_object()); call_other(from, "add_weight", -weight); /* Padrone, 1 Mar 92 */ say(cap_name + " takes " + item + ".\n"); } else { write(capitalize(item) + ": Too heavy.\n"); } it = item; } ob = next_ob; } return 1; } force_player(str) { string who, what; object ob; if (!str) return 0; if (this_player() != this_object()) return 0; if (sscanf(str, "%s to %s", who, what) == 2 || sscanf(str, "%s %s", who, what) == 2) { ob = find_living(who); if (!ob) { write("No such player.\n"); return 1; } if (interactive(ob) && ob->query_level_sec() >= this_object()->query_level_sec()) { write("You fail.\n"); return 1; } tell_object(ob, cap_name + " force you to: " + what + "\n"); command(what, ob); write("Ok.\n"); return 1; } return 0; } clone(string str) { object ob; string mess; string ob_name; if (!str) { write("Clone what object ?\n"); return 1; } str = mk_path(str); ob = clone_object(str); if(!ob) return 1; ob_name = ob->short(); if(!ob_name) ob_name = ob->query_name(); if(!ob_name) ob_name = "something"; mess = getenv(MCLONE); if(!mess) mess = cap_name + " fetches something from another dimension."; else { mess = substitute_string(mess, "$N", cap_name, 1); mess = substitute_string(mess, "$O", ob_name, 1); } say(capitalize(mess) + "\n"); if (call_other(ob, "get")) transfer(ob, myself); if(ob && !environment(ob)) move_object(ob, environment()); write("Ok.\n"); return 1; } pose() { if (level >= 15) { write("You send a ball of fire into the sky.\n"); say(cap_name + " makes a magical gesture.\n"); say("A ball of fire explodes in the sky.\n"); return 1; } return 0; } destruct_local_object(string str) { object ob; string mess; string ob_name; if (this_player() != this_object()) return 0; if (!str) { notify_fail("Destruct what ?\n"); return 0; } str = lower_case(str); ob = present(str, this_player()); if (!ob) ob = present(str, environment(this_player())); if (!ob) { write("No " + str + " here.\n"); return 1; } ob_name = ob->short(); if(!ob_name) ob_name = str; mess = getenv(MDEST); if(!mess) mess = ob_name + " is disintegrated by " + cap_name + "."; else { mess = substitute_string(mess, "$N", cap_name, 1); mess = substitute_string(mess, "$O", ob_name, 1); } destruct(ob); say(capitalize(mess) + "\n"); write("Ok.\n"); return 1; } load(str) { object env; if (this_player() != this_object()) return 0; if (!str) { write("Load what ?\n"); return 1; } str = mk_path(str); if (!str) { write("Invalid file name.\n"); return 1; } env = environment(); /* We just call a non existing function in the object, and that way * force it to be loaded. */ call_other(str, "???"); write("Ok.\n"); return 1; } static snoop_on(str) { object ob; int ob_level; if (!str) { snoop(); return 1; } ob = find_player(str); if (!ob) { write("No such player.\n"); return 1; } if (!snoop(ob)) write("You fail.\n"); return 1; } invis() { if (is_invis) { tell_object(this_object(), "You are already invisible.\n"); return 1; } /* Make it look like a wiz with level > 21 logged out when going invis */ if(level > 21) catch("/obj/daemon/mudwhod"->send_logout(this_object())); is_invis = 1; tell_object(this_object(), "You are now invisible.\n"); say(cap_name + " " + mmsgout + ".\n", this_object()); cap_name = "Someone"; return 1; } vis() { if (!is_invis) { tell_object(this_object(), "You are not invisible.\n"); return 1; } /* Make it look like a wiz with level > 21 logged in when going vis */ if(level > 21) catch("/obj/daemon/mudwhod"->send_login(this_object())); is_invis = 0; tell_object(this_object(), "You are now visible.\n"); cap_name = capitalize(name); say(cap_name + " " + mmsgin + ".\n", this_object()); return 1; } static home() { string where; where = getenv(WORKROOM); if(!where) where = "players/" + name + "/workroom"; move_player("X#" + where); /* get_all(environment()); */ return 1; } wiz_score_list(arg) { if (arg) wizlist(arg); else wizlist(); return 1; } static remove_file(string str) { mixed *files; int i; if(!str) { notify_fail("Usage: rm \n"); return 0; } str = mk_path(str); if(!valid_write(str)) { write("rm: Permission denied: " + str + "\n"); return 1; } if(file_size(str) == -2) { write("rm: " + str + " is a directory\n"); return 1; } if(file_size(str) > -1) { if(rm(str)) write("rm: File removed: " + str + "\n"); else write("rm: rm failed: " + str + "\n"); return 1; } files = get_dir(str); if(!files || files == ({})) { write("rm: File not found: " + str + "\n"); return 1; } for(i=strlen(str); i && str[i] != '/'; i--) str = str; str = extract(str,0,i); i = 0; while(i < sizeof(files)) { if(rm(str + files[i])) write("rm: File removed: " + str + files[i] + "\n"); else write("rm: rm failed: " + str + files[i] + "\n"); i++; } return 1; } local_commands() { string *actions; int i, j; if (this_player() != this_object()) return 0; actions = _query_action(this_object()); write("Current local commands:\n"); j = 0; for (i = 0; i < sizeof(actions); i++) { if (j + strlen(actions[i]) > 70) { j = 0; write("\n"); } j+= strlen(actions[i]); write(actions[i]); if (i+1 < sizeof(actions)) { j++; write(" "); } } write("\n"); return 1; } /* * Recursively compute the values of the inventory. */ int compute_values(object ob) { int e,v,tmp; object *obs; obs=deep_inventory(ob); for(v=e=0;equery_value(); if (tmp > 1000) tmp = 1000; v+=tmp; } return v; } save_me(value_items) { tot_value = 0; if (value_items==1) tot_value = compute_values(this_object()); if(value_items<2) compute_auto_str(); save_object("players/" + name); } illegal_patch(what) { write("You are struck by a mental bolt from the interior of the game.\n"); log_file("ILLEGAL", ctime(time()) + ":\n" + call_other(this_player(), "query_real_name") + " " + what + "\n"); return 0; } load_auto_obj(str) { string file, argument, rest; object ob; mixed dum; while(str && str != "") { if (sscanf(str, "%s:%s^!%s", file, argument, rest) != 3) { write("Auto load string corrupt.\n"); return; } file="/obj/daemon/autoaliasd"->auto_load_alias(file); str = rest; dum=catch( ob = clone_object(file), argument ? ob->init_arg( argument ) : 0, move_object( ob, this_object() ) ); /* Wing 920821 */ if(dum && level>19) /* Profezzorn 921015 */ write(dum); } } compute_auto_str() { #if 1 auto_load=implode ( map_array ( all_inventory()->query_auto_load(), "check_auto_str", this_object() ), "^!" )+"^!"; #else object ob; string str; auto_load = ""; ob = first_inventory(this_object()); while(ob) { str = call_other(ob, "query_auto_load"); str = check_auto_str(str); ob = next_inventory(ob); if (!str) continue; auto_load = auto_load + str + "^!"; } #endif } check_auto_str(str) { if (!str || sscanf(str,"%s^!",str)) return 0; return str; } smart_report(str) { string who; string current_room; string current_date; current_date = extract(ctime(time()),4,15); current_room = file_name(environment(this_object())); if (sscanf(current_room, "players/%s/", who) != 1) log_file("ROOM.rep", current_room + " " +current_date+" " + str + "\n"); else log_file(who + ".rep", current_room + " "+current_date+" " + str + "\n"); } /* If we have many quests, the #-separated string is too slow, * so we use this temporary array of quests: */ static string *quests_array; fix_quests_array() { string tmp, rest, rest_tmp; int i; if (quests_array != 0) /* quests_array has already been set */ ; else if (quests == 0 || quests == "") /* No quests solved */ quests_array = ({ }); else quests_array = explode(quests, "#"); } /* fix_quests_array */ query_quests(str) { fix_quests_array(); if (str == 0) return quests; else return member_array(str, quests_array) != -1; } /* Temporary function - don't use! */ query_quests_array(str) { fix_quests_array(); if (str == 0) return quests_array; else return member_array(str, quests_array) != -1; } query_my_quest_max() { return my_quest_max; } static int cached_quest_points=-1; /* Milamber. */ query_cached_quest_points() { return (cached_quest_points!=-1)?cached_quest_points:query_quest_points(); } query_quest_points() { return cached_quest_points="room/quest_room"->count_solved(this_object()); } set_quest(q) { fix_quests_array(); if (!q) return; if (query_quests(q)) return 0; #ifdef LOG_SET_QUEST if (previous_object()) { log_file("QUESTS", ctime(time()) + ": "+name + ": " + q + " from " + file_name(previous_object()) + "\n"); if (this_player() && this_player() != this_object() && query_ip_number(this_player())) log_file("QUESTS", "Done by " + this_player()->query_real_name() + "\n"); } #endif /* LOG_SET_QUEST */ save_me(1); call_other("obj/quest_mailer", "solved", name, q); if (quests == 0) quests = q; else quests += "#" + q; quests_array +=({ q }); return 1; } query_puzzles(str) { string tmp, rest, rest_tmp; int i; if (str == 0) return puzzles; rest = puzzles; while(rest) { if (str == rest) return 1; i = sscanf(rest, "%s#%s", tmp, rest_tmp); if (i == 0) return 0; if (tmp == str) return 1; if (i == 1) return 0; rest = rest_tmp; } return 0; } set_puzzle(q) { if (!q) return; if (query_puzzles(q)) return 0; /* No logging of puzzles. */ if (puzzles == 0) puzzles = q; else puzzles = puzzles + "#" + q; return 1; } reset_all_puzzles() { log_file("PUZZLES", ctime(time()) + ": all puzzles reset in " + name + "\n"); if (previous_object()) log_file("PUZZLES", "previous_object() = " + file_name(previous_object()) + " (" + previous_object()->query_real_name() + ")\n"); if (this_player()) log_file("PUZZLES", "this_player() = " + file_name(this_player()) + " (" + this_player()->query_real_name() + ")\n"); puzzles = 0; } time_out() { name = 0; cap_name = 0; level = -1; write("Time out\n"); destruct(this_object()); } /* A player is never normally picked up by other players, but wizards * can do anything. Thus, if a player is dropped, the local weight * would be scrambled. drop() { return 1; } */ status who() { object *list; int i; list = users() + (object *) "obj/daemon/whod"->query(); list = m_values(mkmapping(map_array(list, "who_scale_fun", this_object()), list)); for(; i < sizeof(list); i++) { string sh; if(objectp(list[i])) { if(!(sh = (string) list[i]->short()) && (int) list[i]->query_level() > level) continue; else if(!sh) sh = "(" + capitalize((string) list[i]->query_real_name()) + ")"; if(list[i]->query_testchar()) sh += " "; write(sh + "\n"); } } return 1; } reset_host() { host = 0; } query_host() { if (!host) { host = query_ip_name(this_object()); if(host==query_ip_number()) { host=0; return query_ip_number(); } } return host; } status list_peoples(string str) { object *list; string host, pathname, username, restpath; int i, j, a, len, reset_flag, old_flag; old_flag = (str == "-old"); reset_flag = (str == "-reset"); #if 0 list = sort_array(users(), "people_sort_fun", this_object()); #else list = users(); list = m_values(mkmapping(map_array(list, "people_scale_fun", this_object()), list)); #endif for(i = 0, len = 0, a = 0; i < sizeof(list); i++) { if(list[i]->short() || list[i]->query_level() <= level) len++; if(query_idle(list[i]) >= MAX_IDLE/2) a++; } write("There are now " + len + " players (" + (len - a) + " active). " + query_load_average() + "\n"); for(i = 0; i < sizeof(list); i++) { string name, idle; if(reset_flag) list[i]->reset_host(); name = (string) list[i]->query_real_name(); host = (old_flag ? query_ip_number(list[i]) : (string) list[i]->query_host()); if(!host || host == "") host = "[NO HOST]"; if(!name) name = "logon"; name = capitalize(name); if(list[i]->query_npc() || (!list[i]->short() && (int) list[i]->query_level() > level)) { continue; } if(!list[i]->short()) name = "(" + name + ")"; a = (int) list[i]->query_level(); j = (int) list[i]->query_gender(); idle = "NMF"[j..j]; if(query_idle(list[i]) >= MAX_IDLE/2) idle += "I"; if(list[i]->query_testchar()) idle += "T"; name = extract(name + " ", 0, 11) + (a < 10 && a >= 0 ? " " : ""); host = extract(host + " ", 0, 25); idle = extract(idle + " ", 0, 2); write(name + " " + a + " " + idle + " " + host + " "); switch(a = (int) list[i]->query_age() * 2) { case 0..9: write(" " + a + " s"); break; case 10..59: write(" " + a + " s"); break; case 60..60 * 10 - 1: write(" " + (a / 60) + " m"); break; case 60 * 10..60 * 60 - 1: write(" " + (a / 60) + " m"); break; case 60 * 60..60 * 60 * 10 - 1: write(" " + (a / 3600) + " h"); break; case 60 * 60 * 10..60 * 60 * 24 - 1: write(" " + (a / 3600) + " h"); break; case 60 * 60 * 24..60 * 60 * 24 * 10 - 1: write(" " + (a / 86400) + " D"); break; case 60 * 60 * 24 * 10..60 * 60 * 24 * 100 - 1: write(" " + (a / 86400) + " D"); break; case 60 * 60 * 24 * 100..60 * 60 * 24 * 365 - 1: write((a / 86400) + " D"); break; case 60 * 60 * 24 * 365..60 * 60 * 24 * 365 * 10 - 1: write(" " + (a / (60 * 60 * 24 * 365)) + " Y"); break; default: write(" " + (a / (60 * 60 * 24 * 365)) + " Y"); break; } if(!environment(list[i])) write("\n"); else { pathname = file_name(environment(list[i])); if(!old_flag) { if(sscanf(pathname, "players/%s/%s", username, restpath)) { if(username == (string) query_real_name()) pathname = restpath; else pathname ="~" + username + "/" + restpath; } else pathname = "/" + pathname; } write(" " + pathname + "\n"); } } return 1; } people_scale_fun(o) { string a; a=o->query_name()+"\n\n\n"; return -o->query_level()*0x1000000+a[0]*0x10000+a[1]*0x100+a[2]; } who_scale_fun(o) { string a; a=o->query_name()+"\n\n\n\n"; return a[0]*0x1000000+a[1]*0x10000+a[2]*0x100+a[3]; } /* people_sort_fun(ob1,ob2) { int lev1,lev2; string name1,name2; lev1 = ob1->query_level(); lev2 = ob2->query_level(); name1 = ob1->query_real_name(); name2 = ob2->query_real_name(); if(lev1 == lev2) return name1 > name2; return lev1 < lev2; } who_sort_fun(ob1,ob2) { string name1,name2; name1 = ob1->query_real_name(); name2 = ob2->query_real_name(); if (!name1 || !name2) return 0; return name1 > name2; } */ pwd() { write("/" + current_path + "\n"); return 1; } makedir(str) { if (!str) return 0; if (mkdir(mk_path(str))) write("Ok.\n"); else write("Fail.\n"); return 1; } removedir(str) { if (!str) return 0; if (rmdir(mk_path(str))) write("Ok.\n"); else write("Fail.\n"); return 1; } query_path() { return current_path; } check_access_list(top, dir, file) { string tmp1, tmp2; object ob; if (access_list && sscanf(access_list, "%s" + dir + "#%s", tmp1, tmp2) == 2) return top + dir + "/" + file; if((ob=find_player(dir)) && interactive(ob) && ob->check_invite_list(name)) return top + dir + "/" + file; return 0; } check_invite_list(str) { string tmp1,tmp2; if(!str || !invite_list) return 0; if(sscanf(invite_list,"%s" + str + "#%s",tmp1,tmp2) == 2) return 1; return 0; } static invite_wiz(str) { object ob; if(!str) { notify_fail("Usage: invite \n"); return 0; } ob = find_player(str); if(!ob || !interactive(ob)) { write("Could not find " + capitalize(str) + ".\n"); return 1; } tell_object(ob,capitalize(name) + " has given you access to " + query_possessive() + " directory.\n"); if(invite_list) invite_list += str + "#"; else invite_list = str + "#"; write("Ok.\n"); return 1; } #define MAX_SCAR 10 int scar; static make_scar() { if (level < 10) return; scar |= 1 << random(MAX_SCAR); } show_scar() { int i, j, first, old_value; string scar_desc; scar_desc = ({ "left leg", "right leg", "nose", "left arm", "right arm", "left hand", "right hand", "forehead", "left cheek", "right cheek" }); j = 1; first = 1; old_value = scar; while(i < MAX_SCAR) { if (scar & j) { old_value &= ~j; if (first) { write(cap_name + " has a scar on " + query_possessive() + " " + scar_desc[i]); first = 0; } else if (old_value) { write(", " + query_possessive() + " " + scar_desc[i]); } else { write(" and " + query_possessive() + " " + scar_desc[i]); } } j *= 2; i += 1; } if (!first) write(".\n"); } static set_email(str) { if (!str) { write("Your official electronic mail address is: " + mailaddr + "\n"); return 1; } mailaddr = str; write("Changed your email address.\n"); return 1; } add_standard_commands() { add_action("earmuffs", "earmuffs"); /* Mats 930304 */ add_action("do_wield", "wield"); /* Lpd, 920124 */ add_action("plan","Plan"); /*Added by Qqqq*/ add_action("finger","Finger"); /*Added by Qqqq*/ if(name != "guest") { add_action("add_access","addhost"); /* Anvil, 921026 */ add_action("rem_access","subhost"); } add_action("set_email", "email"); add_action("give_object", "give"); add_action("score", "score"); add_action("save_character", "save"); add_action("quit", "quit"); add_action("kill", "kill"); add_action("communicate", "say"); add_action("communicate", "'", 1); add_action("shout_to_all", "shout"); add_action("put", "put"); add_action("pick_up", "get"); add_action("pick_up", "take"); add_action("drop_thing", "drop"); add_action("inventory", "i"); add_action("look", "look"); add_action("look", "l"); add_action("examine", "examine"); add_action("examine", "exa", 1); add_action("help", "help"); add_action("retell","retell"); /*Added by Q4 921022*/ add_action("tell", "tell"); add_action("whisper", "whisper"); add_action("change_password", "password"); add_action("idea", "idea"); add_action("typo", "typo"); add_action("bug", "bug"); add_action("converse", "converse"); add_action("toggle_brief", "brief"); add_action("toggle_abrief", "auto_save"); add_action("toggle_whimpy", "wimpy"); add_action("stop_hunting_mode", "stop"); add_action("spell_missile", "missile"); add_action("spell_shock", "shock"); add_action("spell_fire_ball", "fireball"); add_action("pose", "pose"); add_action("who", "who"); add_action("stty", "stty"); add_action("toggle_idi","hpinfo"); #ifdef USE_FOLLOW if(level>19) add_action("follow", "_follow"); #endif } static ofindplayer(str) { object list; int i; string name; list = users(); while (i < sizeof(list)) { name = list[i]->query_real_name(); if (!name) name = list[i]->query_name(); if (name && name == str) return list[i]; i += 1; } return 0; } toggle_file_exp() { file_exp = !file_exp; write("Filename expansion "); if(file_exp) write("on.\n"); else write("off.\n"); return 1; } cd(path) { string tmp; if(!path) { current_path = getenv(HOMEDIR); if(!current_path) current_path = "players/" + name; } else { path = mk_path(path); /* Evaluate the path */ if(path != "/") { tmp = valid_read(path+"/"); /* Check read access */ if(!tmp || file_size(path+"/") != -2) { write("Can't find directory or access denied.\n"); return 1; } sscanf(path,"/%s",current_path); } else current_path = ""; } write("/" + current_path + "\n"); return 1; } static cat_file(file) { int from,to; if (this_player() != this_object()) return 0; if(!file) { notify_fail("Usage: cat [from length]\n"); return 0; } sscanf(file,"%s %d %d",file,from,to); if(from && !to) to = 20; file = mk_path(file); file = find_file(file); if(file) file = valid_read(file); if(!file) { write("Couldn't find.\n"); return 1; } if(!cat("/"+file,from,to)) { write("Couldn't find " + file + "\n"); return 1; } write("Ok.\n"); return 1; } get_prev_dir(path) { path = explode(path,"/"); if(!path || path==({}) || sizeof(path)==1) return "/"; return "/" + implode(slice_array(path,0,sizeof(path)-2),"/") + "/"; } static list_files(path) { string tmp, files; path = mk_path(path); if(!valid_read(path+"/")) { write("Can't find directory or access denied.\n"); return 1; } if(path != "/") { if(file_size(path+"/") == -2) { path += "/"; files = get_dir(path); } else { files = get_dir(path); if(!files || files == ({})) { if(valid_read(path+"/") && (sscanf(path,"%s*",tmp) || sscanf(path,"%s?",tmp))) write("No match.\n"); else write("Can't find directory or access denied.\n"); return 1; } path = get_prev_dir(path); } } else files = get_dir("/"); if(!files || files == ({})) write("Empty directory.\n"); else print_files(files,path); return 1; } mk_path(path) { int i; string rest; if(!path) return "/" + current_path; if(path == "~") return "/players/" + name; if(sscanf(path,"~/%s",path)) path = "/players/" + name + "/" + path; else if(sscanf(path,"~%s",path)) path = "/players/" + path; i = strlen(path)-1; rest = ""; if(path[i] == '/') rest = "/"; if( i && path[i] == '.' && path[i-1] == '/') rest = "/."; if(path[0] != '/') path = current_path + "/" + path; path = explode(path,"/"); if(!path || path == ({})) return "/"; path = filter_objects(path,"path_fun",this_object()); for(i = member_array("..",path); i != -1; i = member_array("..",path)) { if( i > 1) if(i == sizeof(path)-1) path = path[0..i-2]; else path = path[0..i-2] + path[i+1..sizeof(path)-1]; else path = path[i+1..sizeof(path)-1]; } if(!path || path == ({})) return "/"; path = implode(path,"/"); return "/" + path + rest;; } path_fun(str) { if(str != "" && str != ".") return 1; } /*Added by Qqqq 920427*/ nomask query_valid_write(str) { return this_object()->valid_write(str); } nomask query_valid_read(str) { return this_object()->valid_read(str); } nomask logging(str) { log_file("qqqq.enter","The file "+str+" was created "+ctime(time())+"\n" +"The following stats about it are avaliable: \n"); log_file("qqqq.enter","this_object() == "+this_object()->query_real_name()+"\n"); if (this_player()) log_file("qqqq.enter","this_player() == "+this_player()->query_real_name()+"\n"); if (this_player(1)) log_file("qqqq.enter","this_player(1) == "+this_player(1)->query_real_name()+"\n"); if (previous_object()) { if(interactive(previous_object())) log_file("qqqq.enter","previous_object() == "+previous_object()->query_real_name()+"\n"); else log_file("qqqq.enter","previous_object() == "+file_name(previous_object())+"\n"); } } #if 0 #define _IFMT 0170000 #define _IFLNK 0120000 #define LINKP(file) (((efun::_file_stat(file)[0])&_IFMT) == _IFLNK) nomask link_in_path(string path) { string p2,q; p2=""; while(sscanf(path,"%s/%s",q,path)) { p2+=q+"/"; write("Stating: "+p2+"\n"); if(LINKP(p2)) return 1; } } #endif nomask valid_write(str, logread) { string who, file, owner,tmp,tmp2; if(!str || sscanf(str, "/secure/%*s") == 1 || sscanf(str, "/obj/daemon/%*s") == 1) return 0; #if 0 if(link_in_path(str)) return 0; #endif if(sscanf(str, "/open/%s", file) == 1) { #if 0 if(!logread) logging(str); #endif return "open/" + file; } if(sscanf(str, "/log/%s", who) == 1) { if((who[0] >= 'A' && who[0] <= 'Z') && level <= 23) return 0; #if 0 if(!logread) logging(str); #endif return "log/" + who; } if(sscanf(str, "/permissions/%s", file) == 1 && level > 21) { return "permissions/" + file; } owner = name; if(previous_object() && previous_object() != this_object()) { tmp = file_name(previous_object()); if(sscanf(tmp, "players/%s/", who) == 1) { if(who == "" || who == ".") return 0; owner = who; } else { if(sscanf(tmp, "secure/%s", who) || sscanf(tmp, "local/%s",who)) { sscanf(str,"/%s",str); return str; } return 0; } } if(str[0] != '/') { /* Prepend the name of the wizard that created the object (if any) */ if(previous_object() && previous_object() != this_object()) { str = "players/" + owner + "/" + str; return str; } if(current_path != "") str = "/" + current_path + "/" + str; else str = "/" + str; } if(sscanf(str, "/players/%s/%s", who, file) == 2) { if(who == owner || (query_level_sec() > 22 && name==owner)) /* Angmar */ return "players/" + who + "/" + file; if(who && strlen(who) > 0) return check_access_list("players/", who, file); } return 0; } /* "file_exists_in_or_above" calls "file_size" * and "file_size" calls "valid_read", * so we must check for infinite recursion in "valid_read". */ static int valid_read_recursion = 0; static status file_exists_in_or_above(string file, string dir) { string *pathparts, path; int i, n, file_size_res; path = ""; pathparts = explode(dir, "/"); n = sizeof(pathparts); for (i = -1; i < n; ++i) { if (i >= 0) path += pathparts[i] + "/"; valid_read_recursion = 1; file_size_res = file_size(path + file); valid_read_recursion = 0; if (file_size_res >= 0) return 1; } /* for all (plus one before) parts in the path */ return 0; } /* file_exists_in_or_above */ nomask valid_read(str, lvl) { string who, file, tmp, tmp2; int prev_obj; if(valid_read_recursion) return str; /* In this case, we know that str doesn't start with '/' */ if(!str) return 0; if(str[0] != '/') str = mk_path(str); if(file = valid_write(str, 1)) return file; if(previous_object() && previous_object() != this_object()) { if(sscanf(file_name(previous_object()), "local/%s", tmp)) return extract(str,1); prev_obj = 1; } if(sscanf(str,"/./%s",file)) return 0; if(sscanf(str, "/players/%s", file) == 1 && (prev_obj || query_level_sec() < 23) && sscanf(str,"/players/%s/public/%s",tmp,tmp2) != 2 && !file_exists_in_or_above("READ_ACCESS", str)) { /* If you have any subdirs called public then wizards may read them. * If a file called "READ_ACCESS" exists in a dir, then * that dir, and all its subdirs, are readable. */ return 0; } if(sscanf(str, "/secure%s", file) == 1 && (prev_obj || query_level_sec() < 23)) return 0; if(sscanf(str, "/local/%s", file) == 1 && (prev_obj || query_level_sec() < 23)) return 0; if(sscanf(str, "/mail/%s", file) == 1 && (prev_obj || query_level_sec() < 23)) return 0; if(sscanf(str, "/bboard/%s", file) == 1 && (prev_obj || query_level_sec() < 23)) return 0; if(sscanf(str, "/room/post_dir/%s", file) == 1 && (prev_obj || query_level_sec() < 23)) return 0; if(sscanf(str,"/%s",file) == 1) return file; return 0; } #define CHUNK 17 #define SEARCH_LINES 500 static string file; static string f_name; static int tot_lines; static int lines; static int current_line; static int no_show; set_lines(arg) { lines = arg; } more(str) { string tmp; current_line = 1; if(!lines) lines = CHUNK; if(!str) { str = "/" + file_name(environment(this_player())) + ".c"; if(!valid_read(str)) { write("Usage: more \n"); return 1; } } file = mk_path(str); file = find_file(file); if(file) file = this_player()->query_valid_read(file); if(file) file = "/" + file; if(file){ tot_lines = count_lines(file); tmp = explode(file,"/"); f_name = tmp[sizeof(tmp)-1]; show_text(); more_prompt(); } else if(!file_exp) write("Couldn't find " + str + ".\n"); return 1; } more_input(str) { int jump; int tmp_line; int rem_line; int ret; if(str[0] == '/') { sscanf(str,"/%s",str); search_string(str); } else if(sscanf(str,"-%d",tmp_line) == 1) { current_line -= tmp_line; if (current_line < 1) current_line = 1; } else if(sscanf(str,"+%d",tmp_line) == 1) { current_line += tmp_line; jump = 1; } else if(sscanf(str,"%d",tmp_line) == 1) { rem_line = current_line; current_line = tmp_line; } else if(sscanf(str,"l%d",lines) == 1) { if(lines < 1) lines = CHUNK; if(lines > 40) lines = 40; write("\nPage length set to " + lines + "\n\n"); no_show = 1; } else switch(str) { case "u": case "p": current_line -= lines; if(current_line < 1) current_line = 1; break; case "b": current_line -= 4; if(current_line < 1) current_line = 1; break; case "": case "n": current_line += lines; break; case "d": current_line += 4; break; case "q": end_more(); return; case "h": help_more(); break; case "?": help_more(); default: no_show = 1; } if(!no_show) { ret = show_text(); if(!ret) if(!jump) { write("EOF\n"); return; } else { write("To long jump.\n"); current_line = rem_line; } } more_prompt(); } show_text() { return cat(file,current_line,lines); } more_prompt() { int perc; no_show = 0; perc = (current_line + lines - 1)*100/(tot_lines ? tot_lines : 1); if(perc > 100) perc = 100; write(f_name + " : " + current_line + "-" + (current_line+lines-1)); write(" (" + tot_lines + ") " + (tot_lines ? perc : "--") + "%"); write(" -- [,d,u,b,#,/,q,?] "); input_to("more_input"); } end_more() { write("Ok.\n"); } help_more() { write("\n--------- More Help ---------\n\n"); write("\tu,p\tOne page up.\n"); write("\t,n\tOne page down.\n"); write("\tb,d\tUp/down 4 lines.\n"); write("\t#\tGoto line #.\n"); write("\t+/-#\tJump # lines up/down.\n"); write("\t/str\tGoto line with first occurance of str.\n"); write("\tl#\tSet page length.\n\n"); } #define COUNT_LINES 1000 count_lines(path) { int i,j; string tmp, slask; if(file_size(path) < 0) return 0; while(tmp = read_file(path,i,COUNT_LINES)) { j += sizeof(explode(tmp,"\n")); i += COUNT_LINES; } return j; } search_string(str) { int tmp_line; int s_lines; string tmp_str; string tmp; if(!str) return; tmp_line = current_line + lines -2; s_lines = SEARCH_LINES; tmp_str = read_file(file, tmp_line, s_lines); while( tmp_str && s_lines ) { tmp_str = read_file(file, tmp_line, s_lines); while(tmp_str && !sizeof(regexp( ({ tmp_str }), str))) { tmp_line += s_lines; tmp_str = read_file(file, tmp_line, s_lines); } if(tmp_str) /* Got a matching string */ s_lines = ( s_lines > 10 ) ? s_lines/10 : s_lines-1; else break; /* No match and eof *sulk* */ } if(tmp_str) { current_line = tmp_line - 2; return 1; } write("No match.\n"); no_show = 1; } find_file(str) { string dir; string files; int stat; int i; stat = file_size(str); if(stat > -1) return str; if(!file_exp) return 0; if(stat == -2) { write(str + " is a directory containing:\n"); if(str != "/") str += "/"; print_files(get_dir(str),str); return 0; } dir = get_prev_dir(str); files = get_dir(dir); if(!files) { write("Couldn't read directory: " + dir + "\n"); return 0; } files = filter_files(files,dir,str,1); if(files) if(sizeof(files) > 1) { write("Several files matches: " + str + "\n"); print_files(files,dir); return 0; } else { write("Treating: " + dir + files[0] + "\n"); return dir + files[0]; } write("No file matches " + str + "\n"); } filter_files(files,dir,str,no_dir) { int i; string tmp; string tmp_files; int c; for(i = 0; i < sizeof(files); i++) if(sscanf(dir + files[i],str+"%s",tmp) && (!no_dir || file_size(dir+files[i]) !=-2) && (c = files[i][strlen(files[i])-1]) && c != '~' && c != '#') if(!tmp_files) tmp_files = ({ files[i] }); else tmp_files += ({ files[i] }); return tmp_files; } filter_files2(files,dir,str,no_dir) { int i; string tmp; string tmp_files; int c; for(i = 0; i < sizeof(files); i++) if(sscanf(dir + files[i],str+"%s.c",tmp) && (!no_dir || file_size(dir+files[i]) !=-2) && (c = files[i][strlen(files[i])-1]) && c != '~' && c != '#') if(!tmp_files) tmp_files = ({ files[i] }); else tmp_files += ({ files[i] }); return tmp_files; } print_files(files,path) { int i; int len; string tmp; for (i=0; i < sizeof(files); i++) { string name; if (file_size(path + files[i]) == -2) name = files[i] + "/ "; else name = files[i] + " "; tmp = strlen(name); while(tmp % 19) { tmp++; name += " "; } if (len + tmp > 79) { len = 0; write("\n"); } len += tmp; write(name); } write("\n"); } /*A small finger function added by Qqqq*/ #define FINGERD "/obj/daemon/fingerd" finger(str) { if (!str) { write("You use it: Finger \n"); return 1; } if(!(str = FINGERD->finger(str))) { write("There is no player with that name.\n"); return 1; } write(str); return 1; } int plan(string str) { if (!str) { if (plan_desc) write("Your plan reads: "+plan_desc+"\n"); else write("You have no plan.\n"); } else { plan_desc = str; write("Your plan reads: "+plan_desc+"\n"); } save_me(1); return 1; } query_wiz_level() { return random(42);} #ifdef USE_FOLLOW follow(str) { object ob, ob2; if (!str) { if (!follow_ob) { write("You are not following anyone.\n"); return 1; } follow_ob->remove_follow(); write("You are not following " + capitalize(follow_ob->query_real_name()) + " anymore.\n"); follow_ob = 0; return 1; } ob = present(str, environment()); if (!ob) { write("Follow what?\n"); return 1; } /* May not automatically follow wizards */ if (!ob->query_npc() && ob->query_level() >= 20) /* Changed is_npc to query_npc, by Padrone May 11, 1992 */ { write("You may not follow " + capitalize(ob->query_real_name()) + "!\n"); return 1; } /* Check for follow loops */ ob2 = ob; while ((ob2 = ob2->is_following()) && ob2 != this_object()) ; if (ob2) { write("You cannot follow him.\n"); return 1; } if (ob->start_follow()) { write("You are now following " + capitalize(ob->query_real_name()) + ".\n"); follow_ob = ob; } else write("You cannot follow that!\n"); return 1; } is_following() { return follow_ob; } #endif /* cp -- Oros Jan 1991 */ static cp(string str) { string from, to; string verb, tmp; string *files; int i, force, dir; verb = query_verb(); if(!str || (!(force = (sscanf(str, "-f %s %s", from, to) == 2)) && sscanf(str,"%s %s",from,to) != 2)) { notify_fail("Usage: " + verb + " [ -f ] \n"); return 0; } /* Get the full path name */ from = mk_path(from); to = mk_path(to); /* Check read and write access */ if(verb[0] == 'c') { if(!valid_read(from + "/")) { write(verb + ": Permission denied: " + from + "\n"); return 1; } } else { if(!valid_write(from + "/")) { write(verb + ": Permission denied: " + from + "\n"); return 1; } } if(!valid_write(to + "/")) { write(verb + ": Permission denied: " + to + "\n"); return 1; } /* If we have wildcards in the string or if str is a dir */ /* then the target must be a directory */ if ((sscanf(from,"%s*",tmp) || sscanf(from,"%s?",tmp) || (dir = (file_size(from + "/") == -2))) && file_size(to+"/") != -2) { write(verb + ": Target must be a directory when using wildcards.\n"); return 1; } if(dir) from += "/"; files = get_dir(from); if (!files || files == ({})) { write(verb + ": Couldn't find any files.\n"); return 1; } from = get_prev_dir(from + "/"); for(i = 0; i < sizeof(files); i++) do_copy(from, files[i], to, force, verb); return 1; } static do_copy(from, file, to, force, verb) { int i; string tmp; if(file_size(from + file + "/") == -2) { write(verb + ": " + from + file + " is a directory.\n"); return 1; } if(file_size(to + "/") == -2) to += "/"+file; if (to == (from+file)) return write(verb + ": "+to+" not effected, because source and target file are the same.\n"); /* Check if the 'to' file exists. Remove it if we have the force flag */ if(file_size(to)>0) { if(!force) { write(verb + ": file already exists: " + to + "\n"); return 1; } else rm(to); } from += file; /* Copy the file */ for(i = 1; tmp = read_file(from,i,500); i += 500) write_file(to,tmp); /* Let's see if the copy was succesful */ if(file_size(to) != file_size(from)) { rm(to); write(verb + " failed.\n"); return 1; } if(verb[0] == 'c') verb = "Copied"; else { verb = "Moved"; rm(from); /* Remove the source file if the command was move */ } write(verb + ": " + from + " to " + to + "\n"); return 1; } do_wield(str) { object ob; if (!str) { write("Wield what?\n"); return 1; } ob = present(str, this_object()); if (!ob) { write("You don't have that!\n"); return 1; } if (!ob->query_weapon()) if (ob->weapon_class()) return 0; /* Old weapon, be compatible... */ else { /* Not a new or old weapon */ write("You cannot wield that!\n"); return 1; } if (silent_wield(ob)) write("Ok.\n"); else write("You cannot wield that!\n"); return 1; } remove_statue(arg) { object *oblist; int i; arg++; switch (arg) { case 1: statue_type = "a dusty"; break; case 2: statue_type = "an old"; break; case 3: statue_type = "a slightly cracked"; break; } if (arg >= MAX_STATUE) { object ob; if(!is_invis) { say("A nearby statue starts to crumble, and as time passes\n"); say("it withers to dust.\n"); } is_linkdead = 0; statue_type = "a nice"; ob = clone_object("/obj/dust"); move_object(ob, environment()); move_object(this_object(), "/room/void"); quit(); } else call_out("remove_statue", TICK_STATUE, arg); } int set_env(string str) { string var, value, verb; if(!str) { if(!printenv()) write("No variables set.\n"); return 1; } verb = query_verb(); if(sscanf(str, "%s %s", var, value) != 2) { notify_fail("Usage: " + verb + " [ ]\n"); return 0; } setenv(var, value); write("Ok.\n"); return 1; } int unset_env(string var) { if(!var) { notify_fail("Usage: " + query_verb() + " \n"); return 0; } if(!unsetenv(var)) write("Couldn't find variable " + var + ".\n"); else write("Ok.\n"); return 1; } /*----------- Most of the playerkilling code here: ------------*/ query_playerkilling() { return playerkilling; } set_playerkilling(s) { log_file("PLAYERKILLING", ctime(time()) + ": Changed status of " + query_real_name() + " from " + playerkilling + " to " + s + "\n"); if (previous_object()) log_file("PLAYERKILLING", "previous_object() = " + file_name(previous_object()) + " (" + previous_object()->query_real_name() + ")\n"); if (this_player() != this_object()) log_file("PLAYERKILLING", "this_player() = " + file_name(this_player()) + " (" + this_player()->query_real_name() + ")\n"); playerkilling = s; } /* set_playerkilling */ /* Check if we are allowed to attack, with respect to statues and playerkilling */ attack_allowed(victim) { object the_room; the_room = environment(this_object()); if (the_room == 0) return 0; if (the_room->query_haven()) { write("Such actions are forbidden here.\n"); return 0; } if (!victim->query_npc() && !query_ip_number(victim)) { write("You can't fight with stone statues!\n"); say(cap_name + " tries foolishly to attack a statue of " + victim->query_name() + ".\n"); return 0; } if (!victim->query_npc()) { /* We are trying to attack another player. */ log_file("PLAYERKILLING", ctime(time()) + ": " + query_real_name() + " tried to attack " + victim->query_real_name() + "\n"); if (previous_object()) log_file("PLAYERKILLING", "previous_object() = " + file_name(previous_object()) + " (" + previous_object()->query_real_name() + ")\n"); if (this_player() != this_object()) log_file("PLAYERKILLING", "this_player() = " + file_name(this_player()) + " (" + this_player()->query_real_name() + ")\n"); if (the_room->query_playerkilling()) { log_file("PLAYERKILLING", "ALLOWED - in " + file_name(the_room) + ".\n"); return 1; } if (query_playerkilling() && victim->query_playerkilling()) { log_file("PLAYERKILLING", "ALLOWED - both players are playerkillers.\n"); return 1; } write("Your conscience doesn't allow you to do that.\n"); log_file("PLAYERKILLING", "DENIED.\n"); return 0; } return 1; } /* attack_allowed */ /* No more bouncing /wing 920512 */ nomask query_level() { return level; } nomask query_level_sec(string func) { object pob; string s1,f; if (func == "query_ident") { object ob; if (previous_object() == this_object()) return 23; else { ob = previous_object(); if (ob) log_file("QUERYSEC", "Previous_object ("+ file_name(ob) + ") != this_object().\n"); else log_file("QUERYSEC", "No Previous object ()!\n"); } } if( level <= 21 ) return level; pob=previous_object(); if(!pob) return level; f=file_name(pob); if(sscanf(f,"obj/%s",s1)==1 || sscanf(f,"room/%s",s1)==1 || sscanf(f,"secure/%s",s1)==1 || sscanf(f,"local/%s",s1)==1 || sscanf(f,"players/"+name+"/%s",s1)==1) return level; return 21; } get_nickname(str) { return str; } restore_me() { return restore_object("players/" + name); } set_ghost() /* Special for Ramses guild..sigh.. */ { ghost = 1; fake_ghost = 1; drop_all(1); } query_real_ghost() { return (ghost && !fake_ghost); } int query_rows() { return term_rows; } int query_cols() { return term_cols; } string query_term() { return term_type; } /* Added 93036 pen@lysator.liu.se */ static stty(str) { string cmd; string val; if (!str || str == "" || str == "all" || str == "everything") { write("" + term_rows + " rows, " + term_cols + " columns\n"); if (str == "everything" || str == "all") write("Terminal type is " + term_type + "\n"); return 1; } else { if (sscanf(str, "%s %s", cmd, val) != 2) { write("stty: illegal options '" + str + "'\n"); return 1; } if (cmd == "rows") { if (sscanf(val, "%d", term_rows) != 1) { write("stty: illegal rows argument '"+val+"'\n"); return 1; } } else if (cmd == "cols" || cmd == "columns") { if (sscanf(val, "%d", term_cols) != 1) { write("stty: illegal columns argument '"+val+"'\n"); return 1; } } else if (cmd == "term") { term_type = val; } else { write("stty: illegal option '" + cmd + "'\n"); return 1; } } write("Ok.\n"); return 1; } object query_hunter() { return hunter; } query_testchar() { return testchar; } void set_testchar(string whose) { if(this_player(1) && (int) this_player(1)->query_level() > 24) testchar = whose; } set_gender(g) { /* profezzorn loggar {ckligt l{bbiga lynglar */ log_file("GENDER", file_name(previous_object())+":"+ (this_player(1)?this_player(1)->query_real_name():"")+":"+ query_real_name()+":"+ g+"\n" ); if (g>-1 && g<3) gender = g; } set_neuter() { set_gender(0); } set_male() { set_gender(1); } set_female() { set_gender(2); }