nomask static int cmd_hook(string cmd) { string file; string verb; int foo ; mapping before, after ; verb = query_verb(); if (environment() && environment()->valid_exit(verb)) { verb = "go"; cmd = query_verb(); } file = (string)CMD_D->find_cmd(verb, explode(query("PATH"), ":")); if(file && file != "") { #ifdef PROFILING before = rusage() ; #endif foo = (int)call_other(file, "cmd_" + verb, cmd); #ifdef PROFILING after = rusage() ; "/adm/daemons/profile"->log_cmd(verb,before,after) ; #endif return foo ; } if (environment() && environment()->query("quiet")) return 0 ; #ifdef PROFILING before = rusage() ; #endif foo = (int)EMOTE_D->parse(verb, cmd); if (foo) { #ifdef PROFILING after = rusage() ; "/adm/daemons/profile"->log_cmd(verb,before,after) ; #endif return foo ; } #ifdef PROFILING before = rusage(); #endif #ifndef INTERMUD if(verb == "gwiz" || verb == "interwiz"){ printf("Sorry, %s does not support intermud.\n",capitalize(mud_name())); return 1; } #endif /* INTERMUD */ foo = (int) CHANNELS_D -> parse_channel( verb, cmd ); #ifdef PROFILING if( foo ) { after = rsuage(); "/adm/daemons/profile" -> log_cmd( verb, before, after ); } #endif return foo; }
nomask static int cmd_hook(string cmd) { string file; string verb; int foo ; mapping before, after ; verb = query_verb(); if (environment() && environment()->valid_exit(verb)) { verb = "go"; cmd = query_verb(); } file = (string)CMD_D->find_cmd(verb, explode(query("PATH"), ":")); if(file && file != "") { #ifdef PROFILING before = rusage() ; #endif foo = (int)call_other(file, "cmd_" + verb, cmd); #ifdef PROFILING after = rusage() ; "/adm/daemons/profile"->log_cmd(verb,before,after) ; #endif return foo ; } if (environment() && environment()->query("quiet")) return 0 ; #ifdef PROFILING before = rusage() ; #endif foo = (int)EMOTE_D->parse(verb, cmd); if (foo) { #ifdef PROFILING after = rusage() ; "/adm/daemons/profile"->log_cmd(verb,before,after) ; #endif return foo ; } #ifdef PROFILING before = rusage(); #endif foo = (int) CHANNELS_D -> parse_channel( verb, cmd ); #ifdef PROFILING if( foo ) { after = rsuage(); "/adm/daemons/profile" -> log_cmd( verb, before, after ); } #endif return foo; }
int _lick_verb(string str) { if( id(str) ) { write("You "+(query_verb()=="lick" ? "lick" : "suck on")+ " the frog. You feel a brief euphoric high.\n"); say(this_player()->query_name()+" "+ (query_verb()=="lick" ? "licks" : "sucks on")+" the frog, and "+ "looks high for a moment.\n"); return 1; } notify_fail(capitalize(query_verb())+" whom?\n"); }
/* * Function name: stop * Description : Here all commands the player gives comes. * Argument : string str - The command line argument. * Returns : int 1/0 - success/failure. */ int stop(string str) { /* Only paralyze our environment */ if (environment() != this_player()) { return 0; } /* Some commands may always be issued. */ if (member_array(query_verb(), CMDPARSE_PARALYZE_ALLOWED) != -1) { return 0; } /* If there is a verb stopping the paralyze, check it. */ if (stringp(stop_verb) && (query_verb() == stop_verb)) { /* If a stop_fun is defined it MUST return 1 in order not stop the * paralyze. */ if (objectp(stop_object) && call_other(stop_object, stop_fun, str)) { return 1; } if (stringp(stop_message)) { this_player()->catch_msg(stop_message); } remove_object(); return 1; } /* We allow VBFC, so here we may use catch_msg(). */ if (stringp(fail_message)) { this_player()->catch_msg(fail_message); } /* Only paralyze mortals. */ if (!this_player()->query_wiz_level()) { return 1; } write("Since you are a wizard this paralyze won't affect you.\n"); return 0; }
int block_cmd(string args) { string verb; verb = query_verb(); if (verb == "recall") return 1; return 0; }
static int main(string arg) { object ply, island; string file, *map; if (!objectp(ply = this_player())) { return 0; } if (!stringp(arg) || !strlen(arg = getopts("ac", arg))) { if (!stringp(file = environment(ply)->query_island())) { return notify_fail("Usage: " + query_verb() + " <island>"); } sscanf(file, EMP_DIR_ISLANDS + "%s/island", arg); } else { file = EMP_DIR_ISLANDS + arg + "/island"; } if (file_size(file + ".c") < 0 || !objectp(island = file->__bootstrap()) || !arrayp(map = island->create_island_view())) { return notify_fail("Island '" + file + "' not found."); } if (opts['a']) { map = island->format_view(map, 1); } else if (opts['c']) { map = island->format_view(map, store_fp("do_unload"), arg); } else { map = island->format_view(map, store_fp("is_loaded"), arg); } tell_ansi(ply, "\n" + implode(map, "\n")); return 1; }
int block_cmd() { string verb = query_verb(); if (verb=="say") return 0; if (verb=="help") return 0; if (verb=="look") return 0; return 1; }
int re_route_cmd(string str) { string cmd; int i; string *invalid_cmds; cmd = query_verb(); invalid_cmds = ({"enforce", "meditate", "practice", "study", "wield", "exercise", "learn", "scribe", "conjure", "enchant", "exert", "perform", "respirate","drop"});
nomask static int cmd_hook(string cmd) { string file; string verb; verb = query_verb(); if (environment() && environment()->valid_exit(verb)) { verb = "go"; cmd = query_verb(); } file = (string)CMD_D->find_cmd(verb, explode(query("PATH"), ":")); if (file && file != "") return (int)call_other(file, "cmd_" + verb, cmd); if (environment() && environment()->query("quiet")) return 0 ; return (int)EMOTE_D->parse(verb, cmd); }
int do_drink(string str) { if(str == "water" || str == "from pond" || str == "water from pond") { W("You drink some water from the pond. It's cold and refreshing.\n"); S(TP->QN + " bends down and drinks some water from the pond.\n"); return 1; } return notify_fail(C(query_verb()) + " what?\n"); }
int block_cmd(string args) { string verb; verb = query_verb(); // if (verb == "bian") return 1; // by mon 7/15 if (verb == "xiudao") return 1; if (verb == "exert") return 1; return 0; }
int block_cmd() { string cmd; cmd = query_verb(); if (cmd == "say" || cmd == "tell" || cmd == "reply" || cmd == "who" || cmd == "look" || cmd == "quit" || cmd == "suicide" || cmd == "goto") return 0; return 1; }
int block_cmd(string args) { string verb; verb = query_verb(); if (verb == "bian") return 1; if (verb == "xiudao") return 1; if (verb == "exert") return 1; if (verb == "cast") return 1; //by cjl if (verb == "fly") return 1; //by cjl return 0; }
int special_verb() { string verb; verb=query_verb(); if (!verb||verb=="") return 0; if (verb[0]=='-') return 1; if (verb=="ruf"||verb=="rufe"||verb=="teile"||verb=="teil"||verb=="mruf"|| verb=="mrufe"||verb=="erzaehl"||verb=="erzaehle") return 1; return(0); // non-void funktion, Zesstra }
int block_cmd() { string verb = query_verb(); if (verb=="say") return 0; if (verb=="help") return 0; if (verb=="who") return 0; if (verb=="look") return 0; if (verb=="story") return 0; if (verb=="quit") return 0; if (verb=="post") return 0; return 1; }
int main( string param ) { if( !param && query_verb() == "go" ) { notify_fail("You run around in circles, like a dog chasing its tail. Then you stop.\n"); return 0; } else if( !param && query_verb() != "go" ) { param = query_verb(); } if( this_player()->query_dead() ) { return notify_fail("You're too stiff to move.\n"); } if( this_player()->query_in_combat() ) { return notify_fail("You cannot just walk out of a fight!\n"); } // Why do this? So that if you type a bunch of directions in a row, // like "n n n e e n" it'll queue them up properly. If you checked for // the existence of the exit in main(), it would look for the exits in // THIS room, not the room I'm going to be in after finishing the // rest of the action queue. this_player()->push_action( ({ 500, this_object(), this_player(), ST_STANDING, param }) );
int do_swim(string str) { if(str == "pond" || str == "in pond" || str == "into pond" || str == "water" || str == "in water" || str == "into water") { W("The water in the pond is too shallow to swim in. The pond " + "is meant for drinking, not swimming.\n"); S(TP->QN + " looks at the pond, pondering.\n"); return 1; } return notify_fail(C(query_verb()) + " where?\n"); }
int do_cmd(string str) { object tp = this_player(); int ret; if (cleaning) return 0; if (query_verb() == "quit") return 0; if (wizardp(tp) && query_verb() == "dest") return 0; if (environment(this_object()) != tp) return 0; if (!cmdob) return 0; if (!strlen(cmdfun)) return 0; ret = call_other(cmdob, cmdfun, str); if (ret == 0) return 0; if (!this_object()) return 1; // something removed us if (ret == -1 || (uses != -1 && --uses < 1)) { if (catchall) remove_action("do_cmd", ""); else if (cmdword) { if (stringp(cmdword)) remove_action("do_cmd", cmdword); else foreach (string word in cmdword) remove_action("do_cmd", word); } // can't remove the ob that defines the add_action you're running call_out("removeme", 0); } if (ret == -2) { cleaning = 1; return 0; } return 1; }
int do_build(string str) { object carrot = present("_scarecrow_quest_carrot_",TP), hay = present("_scarecrow_quest_hay_",TP), pumpkin = present("_scarecrow_quest_pumpkin_",TP), scarecrow; if(str == "scarecrow") { if(!carrot || !hay || !pumpkin) { W("You don't have everything you need to build a scarecrow. " + "You need enough hay to make the body, a suitable pumpkin " + "for the head and a suitable carrot for the nose.\n"); return 1; } else if(!ENV(TP)->query_is_quest_shed()) { W("You need to find a place where there are appropriate tools " + "for the job before you can make a scarecrow.\n"); return 1; } W("You grab a rake and break it into sticks. You tie them " + "together with a leather strap you get from a hook on the " + "wall. You tie the hay to the frame and stick the pumpkin on " + "top of it. As a finishing touch, you stick the carrot into " + "the pumpkin to make a nose. You've just made a scarecrow!\n"); S(TP->QN + " breaks a rake into twigs and grabs a leather " + "strap to tie them together, ties some hay to the frame, sticks " + "a pumpkin on top and, as a finishing touch, sticks a carrot " + "into the pumpking to make a nose.\n" + TP->QN + " has just " + "made a scarecrow!\n"); scarecrow = make(OBJECT + "scarecrow",ENV(TP)); // Things mess up here if we just destroy them, one item stays // in inventory sometimes, not always. So we use a junk room // where they're destroyed with a short delay instead so this // function has time to do what it's supposed to first transfer(carrot,ROOM + "dest_room"); transfer(hay,ROOM + "dest_room"); transfer(pumpkin,ROOM + "dest_room"); if(transfer(scarecrow,TP)) { W("It is too heavy for you to carry though.\n"); S(TP->QN + " doesn't seem to be able to carry the " + "scarecrow.\n"); } return 1; } return notify_fail(C(query_verb()) + " what?\n"); }
int filter(string str) { if (query_verb() == "ascend") { if (present("girl", this_object())->query_talking()) return notify_fail("You should listen to the girl finish talking first.\n"); write("%^YELLOW%^Your body begins to float, and with a blinding flash of " "light, you find yourself in a different place."); if (this_player()->query_subclass() == "antipaladin" || this_player()->query_subclass() == "kataan" || this_player()->query_subclass() == "necromancer") this_player()->move_player("/d/nopk/tirun/square", "light"); else this_player()->move_player(ROOMS"become", "light"); return 1; } if (wizardp(this_player()) || this_player()->is_monster()) return 0; write("The dead are incapable of such acts."); return 1; }
// Ok, this isn't going to work until we get 3.3.x online. // Rats. Will look at it later. -- Acius. int main( string param ) { string obname, fname; object ob; string obfile; string curr, buf; int line, i; if( !param || sscanf(param, "%s->%s", obname, fname) != 2 ) { notify_fail( query_verb() + " obj->func\n" ); return 0; } ob = find_thing( obname ); if( !ob ) { notify_fail( "Can't find object: " + obname + "\n" ); return 0; } obfile = function_exists( fname, ob, FEXISTS_FILENAME ); line = function_exists( fname, ob, FEXISTS_LINENO ); if( !obfile || !line ) { notify_fail("Can't find the function.\n"); return 0; } buf = read_file( obfile, line, 1 ); for( i = 1; i < 40 && line - i > 0; i++ ) { curr = read_file( obfile, line - i ); if( curr[0..2] == "/**" || curr[0..2] == "///" || curr[0..1] == " *" || curr[0..1] == " */" ) buf = curr + buf; else break; } buf += read_file( obfile, line+1, 40 ); i = strstr(buf, "\n}\n", 0); if( i > 0 ) buf = buf[..i+2]; msg("Function " + fname + " in file " + obfile + ":\n" + buf ); return 1; }
int do_rest(string str) { if(str == "bench" || str == "on bench") { if(present(fisherman)) { W("You sit down next to Andalf and rest for a little while. Quite "+ "enjoyable.\n"); S(TP->QN+" sits down on the bench next to Andalf and rests for a "+ "while.\n"); return 1; } else { W("You sit down on the bench and rest for a little while. Quite "+ "enjoyable.\n"); S(TP->QN+" sits down on the bench and rests for a while.\n"); return 1; } } notify_fail(C(query_verb())+" where?\n"); }
void add_history(string arg) { int i; if (ignore_history) { if (ignore_history == arg) { ignore_history = 0; return ; } ignore_history = 0; } if (arg[0] == '.' || arg[0] == '^') return; if (in_alias_command) return; if (!history) { history = allocate(40); numoff = -40; } history[hoffset++] = query_verb()+arg; if (hoffset>=sizeof(history)) { numoff += sizeof(history); hoffset = 0; } }
// This is the add_action hook handling movement, commands, emotes and // channels. Optimization is needed. // private nomask int command_hook(string arg) nomask int command_hook(string arg) { string verb, file; object me=this_object(); #ifdef PROFILE_COMMANDS int mem, utime, stime; mapping info; int ecost; // added by mon. 2/25/98 mem = memory_info(); info = rusage(); utime = info["utime"]; stime = info["stime"]; ecost=eval_cost(); #endif verb = query_verb(); //added by mon 11/23/97 if(userp(me)&& (me->query_temp("d_mana"))>0) { if(me->query_temp("is_living")!=1) { if(verb!="bian" && verb!="say" && verb!="tell" && verb!="reply" && verb!="look") { write("别忘了你现在是一"+ (undefinedp(me->query_temp("unit"))? "个":me->query_temp("unit")) +me->name()+"!\n"); return 1; } } } /* mon 10/10/98 if( !arg && (environment() && stringp(environment()->query("exits/" + verb))) && stringp(file = find_command("go")) && call_other(file, "main", this_object(), verb)) ; */ if( !arg && (environment() && environment()->query("exits/" + verb)) && stringp(file = find_command("go")) && call_other(file, "main", this_object(), verb)) ; else if( stringp(file = find_command(verb)) && call_other(file, "main", this_object(), arg)) ; else if( EMOTE_D->do_emote( this_object(), verb, arg ) ) ; else if( CHANNEL_D->do_channel( this_object(), verb, arg ) ) ; else return 0; #ifdef PROFILE_COMMANDS info = rusage(); PROFILE_D->log_command(verb, memory_info() - mem, info["stime"] - stime, info["utime"] - utime, ecost-eval_cost()); #endif return 1; }
int history_add(string str) { string verb; int i; if(is_debug) { write("history_add\n"); } verb = query_verb(); if(!needs_refresh) { counter += 1; } if(counter >= COUNT_UNTIL_REFRESH || verb == "get" || verb == "take") { counter = 0; if(!needs_refresh) { needs_refresh = 1; if(is_debug) { write("registered an refresh in 20 sec\n"); } call_out("refresh", 20, this_player()); } } if(is_debug) { write("verb=" + verb + "\n"); write("str=" + str + "\n"); } if(verb == 0 || verb =="") { return 0; } if(strlen(verb) > 1 && verb[0] == '%') { if(is_debug) { write("calling do_old\n"); } return do_old(verb, str); } if(verb == last_cmd_added) { if(!str) { return 0; } if(str == last_str_added) { return 0; } } if(no_history_add) { no_history_add = 0; return 0; } last_cmd_added = verb; last_str_added = str; i = 0; while(i < sizeof(list_ab)) { if(list_ab[i] == verb) { return 0; /* dont add aliases to the list */ } i += 1; } if(str && str != "") { list_history[history_pos] = verb + " " + str; } else { list_history[history_pos] = verb; } history_pos += 1; if(history_pos >= MAX_HISTORY) { history_pos = 0; wrapped = 1; } if(wrapped) { history_offset += 1; } return 0; }
int block_cmd() { string verb = query_verb(); if (verb=="score") return 1; return 0; }
int action(string arg) { string keyword,verb,type,err_msg,check_ob,clan,*ally; object obj; int check_clan; verb = query_verb(); keyword = env->query("action/"+verb+"/keyword"); type = env->query("action/"+verb+"/type"); err_msg = env->query("action/"+verb+"/err_msg"); check_ob = env->query("action/"+verb+"/check_ob"); check_clan = env->query("action/"+verb+"/check_clan"); sscanf(base_name(env),"/open/clan/%s/%*s",clan); ally = CLAN_D->clan_query( this_player()->query("clan/id"), "ally" ); if(!env->query("action/"+verb+"/filename")&& env->query("action/"+verb+"/filename")=="") return notify_fail("这个指令尚未完成。\n"); if(!type) return notify_fail("这个指令尚未完成。\n"); // 这边是检查帮派的部份. switch(check_clan){ // 1时..就非本帮的不能使用... case 1: if(this_player()->query("clan/id") != clan) return 0; break; // 2.非同盟帮的不能使用. case 2: if(member_array( clan, ally ) == -1 && this_player()->query("clan/id") != clan) return 0; default: } if(arg && keyword=="") return notify_fail(err_msg+"\n"); else if(keyword != "" && (!arg || arg != keyword)) return notify_fail(err_msg+"\n"); if(check_ob && !obj=present(check_ob,this_player())) return notify_fail(err_msg+"\n"); if(obj) destruct(obj); type(verb,"action"); return 1; } int type(string verb,string ftype) { string type,filename,check; type = env->query(ftype+"/"+verb+"/type"); filename = env->query(ftype+"/"+verb+"/filename"); //下面是防作弊检查 // 只检查帮派的区域,帮派以外的区域不给inherit... if(filename!="" && sscanf(filename,"/open/clan/%s/%*s",check)!=2){ log_file("clan/move_bug",sprintf("[%s] %s(%s)的房间 filename 为 %s\n", ctime(time()), this_player()->name(), getuid(this_player()), filename, base_name(env))); return 0; } // 以下是捡查该用那一种的移动,或招换..之类的.. // 并各自呼叫各字的fun... switch(type){ case "action_move": action_move(ftype,verb); break; case "link_way": link_way(ftype,verb); break; case "add_mob": add_mob(ftype,verb); break; case "find_obj": find_obj(ftype,verb); break; } return 1; }
int main() { return "/bin/go"->main(query_verb()); }