string query_mhalt() { string str ; str = (string)this_object()->getenv("MHALT") + "" ; if (strsrch(str, "$N") == -1) str = "There is a bright flash of light as $N ends his battle." ; str = substr(str, "$N", (string)this_object()->query("cap_name") ) ; return str ; }
mixed set(string prop, mixed data) { if( !mapp(dbase) ) dbase = ([]); if( strsrch(prop, '/')!=-1 ) return _set( dbase, explode(prop, "/"), data ); return dbase[prop] = data; }
string query_minvis() { string str; str = (string)this_object()->getenv("MINVIS") + ""; if ( strsrch ( str, "$N" ) == (-1) ) str = "$N seems to disappear."; str = substr( str, "$N", (string)this_object()->query("cap_name") ); return str; }
string query_mmin() { string str; str = (string)this_object()->getenv("MMIN") + ""; if ( strsrch ( str, "$N" ) == (-1) ) str = "$N appears from the shadows."; str = substr( str, "$N", (string)this_object()->query("cap_name") ); return str; }
string query_mmout() { string str; str = (string)this_object()->getenv("MMOUT") + ""; if ( strsrch ( str, "$N" ) == (-1) ) str = "$N fades into the shadows."; str = substr( str, "$N", (string)this_object()->query("cap_name") ); return str; }
mixed set_with_slash(string prop, mixed data) { if( !mapp(dbase) ) dbase = ([]); if( strsrch(prop, '.')!=-1 ) return _set( dbase, explode(prop, "."), data ); return dbase[prop] = data; }
string query_mhome() { string str; str = (string)this_object()->getenv("MHOME") + ""; if ( strsrch ( str, "$N" ) == (-1) ) str = "$N heads home."; str = substr( str, "$N", (string)this_object()->query("cap_name") ); return str; }
int visit_room(string room_path, mapping info, mapping mapdb_info, mixed args) { object room; if( strsrch(room_path, "/d/wudang/") != 0 ) return 1; room = find_object(room_path); if( !objectp(room) ) return 0; message("info", HIR"「啊~~~」半山突然传来一阵极凄厉的惨叫声。\n"NOR, room, 0); }
string query_mvis() { string str; str = (string)this_object()->getenv("MVIS") + ""; if ( strsrch ( str, "$N" ) == (-1) ) str = "$N appears out of the corner of your eye."; str = substr( str, "$N", (string)this_object()->query("cap_name") ); return str; }
string _the_short(mixed x) { if(objectp(x)) return x->the_short(); // Check for "the" prefix - if missing, add it if(stringp(x)) if(strsrch(lower_case(x), "the ") != 0) return "the " + x; return x; }
int do_changecoor(string tofile,string line) { string x,y,z; string line2; int ix,iy,iz; int i; //去掉table键; line2=replace_string(line,"\t",""); //去掉空格 line2=replace_string(line2," ",""); x="set(\"coor/x\","; y="set(\"coor/y\","; z="set(\"coor/z\","; //is it x? if(strsrch(line2,x,1)!=-1) { sscanf(line2,x+"%d);",ix); line2=sprintf("\t%s%d);\n",x,ix-xcenter); line=line2; } //is it y? if(strsrch(line2,y,1)!=-1) { sscanf(line2,y+"%d);",iy); line2=sprintf("\t%s%d);\n",y,iy-ycenter); line=line2; } //is it z if(strsrch(line2,z,1)!=-1) { sscanf(line2,z+"%d);",iz); line2=sprintf("\t%s%d);\n",z,iz-zcenter); line=line2; } efun::write_file(tofile,line,0); }
varargs mixed query_with_slash(string prop, int raw) { mixed data; if( !mapp(dbase) ) return 0; if( undefinedp(dbase[prop]) && (strsrch(prop, '.')!=-1) ) data = _query(dbase, explode(prop, ".")); else data = dbase[prop]; if( undefinedp(data) && default_ob ) data = default_ob->query(prop, 1); if( raw ) return data; return evaluate( data, this_object() ); }
int do_answer(string arg) { if( !arg ) return notify_fail("你说什么?\n"); this_player()->set_temp("pending/jiangjun_answer", 0); message_vision("$N答道:" + arg + "\n", this_player()); if( strsrch(arg, "拜师") >=0 ) { command("haha"); command("say 不是我吹,我家将军武功没人能比!\n"); this_player()->set_temp("pending/jiangjun_answer", 1); } else { command("say 你胡说什么呀?一边玩去!\n"); } return 1; }
int CanReceive(object ob){ int ret, level; level = ob->GetLevel(); if((creatorp(ob) && !archp(ob)) || (userp(ob) && level > 20)){ write("Sorry. This area is for normal players."); return 0; } ret = room::CanReceive(ob); if(ret){ object *inv = deep_inventory(ob); foreach(object element in inv){ string name = base_name(element); level = element->GetLevel(); if(creatorp(element) && !archp(element) || (userp(element) && level > 20)){ write("Sorry. This is a player-only area."); return 0; } if(!strsrch(name,"/realms/") || !strsrch(name,"/open/")){ element->eventMove(ROOM_FURNACE); } } }
int set_title(string str) { if ( this_body() != this_object() ) error("invalid attempt to set a title\n"); if ( str && strsrch(str, "$N") == -1 ) error("bad title -- needs to contain $N\n"); if ( !str ) title = sprintf("%s the title-less.", capitalize(query_name())); else title = replace_string(str,"$N", capitalize(query_name())); title += "%^RESET%^"; }
int cmd_eagledive(string str) { object tp = this_player(); object env = environment(tp); object tgt, tgtenv; string tgtname, dir = ""; mixed tmp; if (!abil()) return 0; // last word is the exit name, exits cannot contain spaces if (str && (tmp = strsrch(str, " ", -1)) != -1) { tgtname = str[0..tmp-1]; dir = str[tmp+1..<1]; }
void phase_func() { string look_msg=WEATHER_D->query_current_day_phase(); if(strsrch(look_msg,"sun")>-1) { set_long(wrap(longdesc + "It is day, and the sun shines through the "+ "window.\n")); } else { set_long(wrap(longdesc + "It is night, and the moons shine through the "+ "window.\n")); } }
string outsidefunc() { string look_msg=WEATHER_D->query_current_day_phase(); if(strsrch(look_msg,"sun")>-1) { return "It is daytime outside. The sun shines through and warms you a "+ "bit.\n"; } else { return "It is nighttime outside. A cool breeze flows through, making you "+ "shiver a bit.\n"; } }
void search_dir (int count, string *dir, int i, string address, object me) { object ob; int j; string *ppls, name, str, adr, s1, s2, s3, s4; string info; if (i == sizeof(dir)) { tell_object(me,"共有"+to_chinese(count)+"位使用者从这个地址上线。\n"); } else { ppls = get_dir(DATA_DIR + "login/" + dir[i] + "/"); for(j=0; j<sizeof(ppls); j++) { reset_eval_cost(); if (sscanf(ppls[j], "%s.o", str)==1) { // What are these for??? Where was "name" assigned? // if (name == str) // continue; ob = new(LOGIN_OB); ob->set("id", str); if (! ob->restore()) { destruct(ob); continue; } if (! ob->query("last_from")) { destruct(ob); continue; } adr = ob->query("last_from"); if (strsrch(adr, address)==-1) { destruct(ob); continue; } info = sprintf("%-10s%-14s%-11s%-6s%s\n", ob->query("id"), ob->query("name"), ctime(ob->query("last_on"))[0..10], ctime(ob->query("last_on"))[20..24], ob->query("last_from")); tell_object (me,info); destruct(ob); count ++; } } i++; call_out ("search_dir",0,count,dir,i,address,me); } }
string ansi_display( string str, int length ) { string space = " "; int i; if( strsrch( str, "" ) == -1 ) return str; if( !length ) return str; if( ( i = length - strlen( str ) + ansi_count( str ) - 1 ) > 0 ) return str + space[0..i]; else return str; }
int main(object me, string arg) { mapping doors; string *dirs, dir; string key, *key_of_room; object ob, env; int i; if( !arg ) return notify_fail("你要打开什么的锁?\n"); arg = lower_case(arg); if (sscanf (arg, "%s with %s", arg, key) != 2) return notify_fail ("你想用什么打开门啊。\n"); if (!ob=present (key, me)) return notify_fail ("你身上并没有 "+key+"。\n"); env=environment(me); doors = env->query_doors(); if( mapp(doors) ) { dirs = keys(doors); if( member_array(arg, dirs)!=-1 ) dir = arg; else for(i=0; i<sizeof(dirs); i++) if( arg==doors[dirs[i]]["name"] || member_array(arg, doors[dirs[i]]["id"])!=-1 ) { dir = dirs[i]; break; } if( !dir ) return notify_fail("你要打开什么的锁?\n"); if ((string)env->query("need_key/"+dir) || (string)env->query("need_key/door")) { key_of_room=ob->query("key_of_room"); if (!sizeof (key_of_room) || strsrch(implode(key_of_room," "), file_name (env))==-1) { return notify_fail ("这把钥匙不能开这个门。\n"); } } if( env->unlock_door(dir) ) { message_vision("$N听到喀的一声, 将" + doors[dir]["name"] + "的锁打开了。\n", me); return 1; } } return 1; }
void announce (string str) { string s = str; int i, j; while ((i = strlen(s)) > 0) { j = strsrch (s, "\n"); if (j < 0) { announcing (s); return; } announcing (s[0..j]); s = s[j+1..i]; } }
int MarriageRequest(mixed arg1, mixed arg2, mixed arg3){ string s1, s2, dudename; object ob1, ob2; if(strsrch(arg2,"divorce") != -1){ this_object()->performDivorce(arg1); return 1; } if(sscanf(arg3,"%s and %s", s1, s2) !=2 && sscanf(arg3,"%s to %s", s1, s2) !=2){ eventForce("say "+arg1->GetName()+", you are confusing me."); return 1; } dudename = arg1->GetKeyName(); if(s1 == "me" || s1 == "i") s1 = dudename; if(s2 == "me" || s2 == "i") s2 = dudename; if(s1 != dudename && s2 != dudename ){ eventForce("say Those people will have to decide "+ "to get married on their own. It isn't "+ "any of your business."); return 1; } if( s1 == s2){ eventForce("say we don't do single-member marriages here."); return 1; } if(! ob1 = present(s1, environment(this_object()))){ eventForce("say "+capitalize(s1)+" isn't here."); return 1; } if(! ob2 = present(s2, environment(this_object()))){ eventForce("say "+capitalize(s2)+" isn't here."); return 1; } if(!living(ob1) || !living(ob2)){ eventForce("say I do not perform marriages with inanimate objects."); return 1; } this_object()->performMarriage(ob1, ob2); return 1; }
string strip_color(string str) { string ret = ""; string code = "%^"; string *tmp; int flag; if (!str || str == "") return ""; tmp = explode(str, code); if (strsrch(str, code) == 0) flag=1; else flag=0; for (int i=flag; i<sizeof(tmp); i+=2) ret += tmp[i]; return ret; }
mixed GoHome(string str) { object ob, prev; string who, room; prev = environment(this_player()); if( !str || str == "" || !creatorp(this_player())){ who = this_player()->GetKeyName(); } else who = lower_case(str); if(!user_exists(who)) return "There's no such user."; room = PLAYERS_D->GetHomeRoom(who); if(!room || !strsrch(room, "/tmp/")){ str = user_path(who, 1); if(!directory_exists(str)) return "That person has no home dir."; str = user_path(who, 1)+"workroom.c"; arg = str; if(!unguarded((: file_exists(arg) :))) return capitalize(who)+" has no active workroom."; }
mixed cmd(string str) { object *ov, ob; if(strsrch(str, "in everyone") != -1) return notify_fail("Please don't do that. You've been asked not to " "and it causes lag.\n"); notify_fail("Pathof what?\n"); ov = WIZ_PRESENT->wiz_present(str, this_player()); if (!sizeof(ov)) return 0; foreach (ob in ov) { if (!objectp(ob)) continue; write("Path of " + WIZ_PRESENT->desc_object(ob) + " in " + WIZ_PRESENT->desc_object(environment(ob)) + ":\n"); write(file_name(ob)+ "\n"); } return 1; }
int main(string str) { string source, dest; if(!str || !sscanf(str, "%s %s", source, dest)) return notify_fail("Syntax: cp <source> <dest>\n"); source = resolve_path(this_player()->query("cwd"), source); dest = resolve_path(this_player()->query("cwd"), dest); if(directory_exists(dest) || dest[<1..<1] == "/") { if(dest[<1..<1] != "/") dest += "/"; if(strsrch(source, "/", -1) != -1) { dest += source[(strsrch(source, "/", -1) + 1)..<1]; } else dest += source;
string query_mzap(object target, int flag) { string str, victim ; if (!target) victim = "Someone" ; else victim = target->query("cap_name") ; str = (string)this_object()->getenv("MZAP") + "" ; if (strsrch(str,"$N")==-1) str = "$N summons lightning that strikes $V in the chest." ; if (!flag) { str = substr(str, "$N", (string)this_object()->query("cap_name")) ; str = substr(str, "$V", victim) ; } if (flag==1) { str = substr(str, "$N", (string)this_object()->query("cap_name")) ; str = substr(str, "$V", "you") ; } if (flag==2) { str = substr(str, "$N", "You") ; str = substr(str, "$V", victim) ; } return str ; }
int cmd_sar( mixed str ) { int i, siz; string *files; string s1, s2, s3, s4; notify_fail("SAR: sar <search_string> <replace_string> <file(s)>\n"); if( !str || str == "" ) return 0; s4 = str[0..0]; if( sscanf( str, s4 + "%s" + s4 + " " + s4 + "%s" + s4 + " %s", s1, s2, s3) != 3 ) if( sscanf( str, "%s %s %s", s1, s2, s3 ) != 3 ) return 0; if( s1 == s2 ) return notify_fail( "SAR: <search_string> should not match <replace_string>.\n" ); files = (string *) this_player() -> wild_card( s3 ); if( !(siz = sizeof( files )) ) { notify_fail( sprintf( "SAR: File(s) %O not found.\n", s3 ) ); return 0; } message("developer", "SAR: Beginning file sweep.\n",this_player() ); for( i = 0; i < siz; i++ ) { if( !file_exists( files[i] ) ) continue; s4 = read_file( files[i] ); if( s4 && ( strsrch( s4, s1 ) > -1 ) ) { message("developer",sprintf( "SAR: Opening %O ... ", files[i], ), this_player() ); s4 = replace_string( s4, s1, s2 ); rm( files[i] ); write_file( files[i], s4 + "\n" ); message("developer","replaced.\n",this_player() ); } }
mixed do_dest_obj(object ob){ string name; if(base_name(ob) == LIB_DUMMY) { write(capitalize(ob->GetShort())+" isn't a normal destable item. It remains in place."); return 1; } if(archp(ob) && !archp(this_player())){ write("You can't dest an admin."); tell_player(ob, this_player()->GetName()+" just tried to dest you."); return 1; } if(!creatorp(this_player()) && strsrch(base_name(ob), homedir(this_player()))){ write("As a builder, you can only dest items that you created."); return 1; } if(!living(ob)) name = ob->GetShort(); else name = ob->GetName(); write("You dest "+name+"."); say( this_player()->GetMessage( "dest", ob ) ); ob->eventDestruct(); if(ob) destruct(ob); return 1; }