//벻Ҫհ´룬ΪMUDʵ̫һĻٽ޸  Jackyboy
//һЩӦӵĶ
#define TMA \x19  //ASCII25
#define TMB \x1A  //ASCII26
#define TMI(x) (TMA+x+TMB)
#define ALERT(x) TMI("alert "+x)
#define L_ITEM(x) RANK_D->new_short(x)
#define L_ICON(x) TMI("licon "+x)
#define CLEAN0  TMI("lbclear0")
#define ADD0(x) TMI("lbadd0 "+L_ITEM(x)+";")
#define REM0(x) TMI("lbrem0 "+L_ITEM(x)+";")
#define CLEAN1  TMI("lbclear1")
#define ADD1(x) TMI("lbadd1 "+L_ITEM(x)+";")
#define REM1(x) TMI("lbrem1 "+L_ITEM(x)+";")
#define CLEAN2  TMI("lbclear2")
#define ADD2(x) TMI("lbadd2 "+L_ITEM(x)+";")
#define REM2(x) TMI("lbrem2 "+L_ITEM(x)+";")

//ע⣬ȷʹЩ壬עⲻҪѶTOMUDͻûϢ͸ˣᵼZMUDû޷Ϸ
//Ȼֻ֧TOMUDЭ鵱Ȼνˡ
/* new_short()һҪŵRANK_Dġ
//RANK_D->new_short()
//γƷItemString By JackyBoy@TOMUD 2002/1/6
varargs string new_short( object ob ,int withshort)
{
	mixed tmp;
	string icon="", str;
	if(!objectp(ob))
	{
		CHANNEL_D->do_channel(this_player(),"chat","object");
		return "";
	}
	if(!ob->query_temp("apply/id")||!ob->query_temp("apply/name")||!ob->query_temp("apply/short"))
		str = ob->query("name") + "(" +ob->query("id") + ")" +(!withshort?"":ob->short());
	else
		str = ob->query_temp("apply/name")[0] + "(" +ob->query_temp("apply/id")[0] + ")" +(!withshort?"":ob->query_temp("apply/short")[0]);
	if( (tmp = ob->query("icon")))
	{
		if( intp(tmp) )
			icon = sprintf("%d",tmp);
		else if( stringp(tmp) )
			icon = tmp;
		else 
			icon = "00901";
	}
	else
	{
		if(userp(ob)) icon=( ob->query("gender") == "" )?"1174":"1173";
		else if(living(ob)) icon = "00901";
		else icon = "00961";
	}
	while( sizeof(icon)<5 )
		icon = "0" + icon;

    return str + icon;
}
*/
==========================================================================================================================
/* ʵбҪõĴ롣Դhttp://bbs.tomud.com/dl/move.c õʹõĴ
//δ嵽feature/move.cmove()бӺɾ
//Modify By JackyBoy@TOMUD 2002/1/6
	if(!wizardp(this_object())||!query("env/invisible"))
	{
		if (env)
		{
			env->add_encumbrance(-weight());
			if(userp(env)) tell_object(env,REM1(this_object()) ); //ǴƶߣӦREM1
			else if(!living(env)) tell_room(env,REM0(this_object()),this_object() );//ǴӷƶߣӦREM0
			//else log_file("move.log",ctime(time())+"֪ʾREMϢ---"+base_name(env)+"\n");
		}
		if (ob)
		{
			ob->add_encumbrance(weight());
			if(userp(ob)||interactive(ob)) tell_object(ob,ADD1(this_object()) ); //ƶϣӦADD1
			else if(!ob->is_character()) tell_room(ob,ADD0(this_object()),this_object() );//ƶӦADD0
		}
	}
//& δ嵽/feature/move.cremove()ҪҵʵĵطԴбȥ
		//Add By JackyBoy@TOMUD 2002/1/27
		if(userp(ob))
			tell_object(ob,REM1(me) ); //ǴƶߣӦREM1
		else if(!living(ob)&&!ob->is_character())
			tell_room(ob,REM0(me),me );//ǴӷƶߣӦREM0ߣ
*/
================================================================================================
//Ĵ뵽who
if(arg=="ҰЦ")
{
	str = "";
	ob = users();
	i = sizeof(ob);
	while ( i -- )
	{
		if ( !ob[i] )
			continue;
		if ( !environment(ob[i]) ) 
		{
			destruct(ob[i]);//еΣ
			continue;
		}
		str += ADD2(ob[i]);
	}

	write(CLEAN2+str);
	return 1;
}

================================================================================================

//actionavailableĴŵ/cmds/std/actionavailable.c
// actionavailable.c

#include <ansi.h>
#include <weapon.h>
#include <login.h>
inherit F_CLEAN_UP;

int room_path(object, object);
int user_path(object, object);

int main(object me, string arg)
{
	object ob, *inv;
	string win,*ids;

	if( sscanf(arg, "%s,%s", arg, win)!=2) return 0;
	switch (win){
		case "0" :
			ob=present(arg,environment(me));
			if(!objectp(ob)) {
				inv=all_inventory(environment(me));
				for(int i = 0; i<sizeof(inv); i++) {
					if(inv[i]==me) continue;
					if(ids=inv[i]->query_temp("apply/id"))
					for(int j=0;j<sizeof(ids);j++) {
						if(ids[j]==arg)
						ob=inv[i];
					}
				}
			}
			room_path(me,ob);
			break;
		case "1" :
			ob=present(arg,me);
			user_path(me,ob);
			break;
	}
	return 1;
}

int room_path(object me, object ob)
{
	mapping skills,meskills;
	object *inv;
	string *str,id,*ids,name,tmp;
	int i,my_skill;

	if(!objectp(ob)) return 1;
	
	if(stringp(tmp=ob->query_menu(me,0)))//ܽͲ˵ֱӷز˵
	{
		write(tmp);
		return 1;
	}
	

	if(!ob->query("apply/id")) id=ob->query("id");
	else {
		ids=ob->query_temp("apply/id");
		id=ids[sizeof(ids)-1];
	}

//	if(ob->query_temp("apply/name")) name=ob->query_temp("apply/name");
	tmp=TMI("mbegin "+ob->name(1)+";"+id)+TMI("mitem ۲$U;look "+id);
	if(living(ob))
	{
		if(interactive(ob))
		{
			tmp+=TMI("mitem $U...;tell "+id+" ...")+TMI("mitem $U...;whisper "+id+" ...");
			if(id==me->query_temp("reply"))
				write(TMI("mitem ش$U...;reply ..."));
		}

		tmp+=(me->query_leader()==ob)?TMI("mitem ֹͣ$U;follow none"):TMI("mitem $U;follow "+id);
		if(!environment(me)->query("no_fight"))
		{
			tmp+=TMI("mitem $Uд;fight "+id);
			if ((int)ob->query("age") > 17 || !interactive(ob))
				tmp+=TMI("mitem $U;hit "+id)+TMI("mitem ɱ$U;kill "+id)+TMI("mitem ͵Ϯ$U;touxi "+id)+TMI("mitem ͵$U...;steal ... from "+id);
		}
		if(ob->query("inquiry")) {
			str=keys(ob->query("inquiry"));
			for(i=0; i<sizeof(str); i++)
				tmp+=TMI("mitem $U"+str[i]+"Ϣ;ask "+id+" about "+str[i]+"");
		}
		tmp+=TMI("mitem $U...;give ... to "+id );
		if(me->query("family/family_name") == "ؤ" ) {
			if ( me->query_skill("checking",1) >= 10 )
				tmp+=TMI("mitem ̽...ļ;check ...");
			if(ob->query("family/family_name") != "ؤ" )
				tmp+=TMI("mitem $U...;beg ... from "+id);
		}
		if(ob->query("vendor_goods")) {
			tmp+=TMI("mitem ѯ$U۵Ķ;list");
			tmp+=TMI("mitem $U...;buy ...");
		}
		if(ob->query("dealer")=="pawn") {
			if(!ob->query("vendor_goods")) {
				tmp+=TMI("mitem ѯ$U۵Ķ;list");
				tmp+=TMI("mitem $U...;buy ...");
			}
			tmp+=TMI("mitem ...;value ...");
			tmp+=TMI("mitem ...$U;sell ...");
			tmp+=TMI("mitem 䵱...$U;pawn ...");
			if(me->query("pawns"))
				tmp+=TMI("mitem Ʒ...;redeem ...");
		}
		if(ob->query("dealer")=="bank") {
			tmp+=TMI("mitem һ;convert ...");
			tmp+=TMI("mitem Ǯ;deposit ...");
			if(me->query("money")) {
				tmp+=TMI("mitem ѯ;check");
				tmp+=TMI("mitem ȡǮ;withdraw ...");
			}
		}
		if(me->query("family/master_name")!=ob->name(1)) {
			if(ob->is_master())
				tmp+=TMI("mitem $UΪʦ;bai "+id);
		} else {
			tmp+=TMI("mitem ʦ$Uͷ;bai "+id);
			tmp+=TMI("mitem ѯʦ$U;skills "+id);
			if(ob->query_skills() && me->query("jing")>=1
				&& (int)me->query("potential")>(int)me->query("learned_points")) {
				skills=ob->query_skills();
				str=keys(skills);
				for(i=0; i<sizeof(str); i++) {
					if(me->query_skills()) {
						meskills=me->query_skills();
						my_skill = me->query_skill(str[i], 1);
						if( (string)SKILL_D(str[i])->type()=="martial"
							&& my_skill*my_skill*my_skill/10>(int)me->query("combat_exp") )
							continue;
						if(skills[str[i]]>my_skill && str[i]!="idle")
							tmp+=TMI("mitem ѧϰ"+to_chinese(str[i])+";learn "+id+" "+str[i]+" ...");
					} else
					tmp+=TMI("mitem ѧϰ"+to_chinese(str[i])+";learn "+id+" "+str[i]+" ...");
				}
			}
		}
	} else {
		if(!ob->query("no_get"))
			tmp+=TMI("mitem $U;get "+id);
		if(ob->is_container()) {
			inv = all_inventory(ob);
			if(sizeof(inv)) {
				tmp+=TMI("mitem $UĶó;get all from "+id);
				tmp+=TMI("mitem $Uó...;get ... from "+id);
			}
			tmp+=TMI("mitem ...װ$U;put ... in "+id);
		}
		if(id=="board") {
			tmp+=TMI("mitem µ;read new");
			tmp+=TMI("mitem ...;read ...");
			tmp+=TMI("mitem дµ;post ...");
			tmp+=TMI("mitem ɾ...;discard ...");
		}
	}
	tmp+=TMI("mendd");
	tell_object(me,tmp);
	return 1;
}

int user_path(object me, object ob)
{
	mapping prop;
	string id,tmp;

	if(!objectp(ob)) return 1;
	
	if(stringp(tmp=ob->query_menu(me,1)))//ܽͲ˵ֱӷز˵
	{
		write(tmp);
		return 1;
	}
	
	id=ob->query("id");
	tmp=TMI("mbegin "+ob->name(1)+";"+id)+TMI("mitem ۲$U;look "+id);

	if(!ob->query("no_drop"))
		tmp+=TMI("mitem $U;drop "+id);

	if(!ob->query("no_give"))
		tmp+=TMI("mitem $U...;give "+id+" to ...");

	if(ob->query("liquid")) {
		if(ob->query("liquid/remaining"))
			tmp+=TMI("mitem $U;drink "+id);
		if(environment(me)->query("resource/water"))
			tmp+=TMI("mitem $Uװˮ;fill "+id);
	}
	
	if(ob->query("food_remaining"))
		tmp+=TMI("mitem $U;eat "+id);
		
	if(ob->is_container()) {
		tmp+=TMI("mitem $UĶó;get all from "+id);
		tmp+=TMI("mitem $Uó...;get ... from "+id);
		tmp+=TMI("mitem ...װ$U;put ... in "+id);
	}
	if(mapp(prop=ob->query("armor_prop"))&& stringp(ob->query("armor_type")) ) {
		if(!ob->query("equipped"))
			tmp+=TMI("mitem $U;wear "+id);
		else
			tmp+=TMI("mitem $U;remove "+id);
	}

	if(mapp(prop=ob->query("weapon_prop")) && stringp(ob->query("skill_type"))) {
		if(!ob->query("equipped"))
			tmp+=TMI("mitem װ$U;wield "+id);
		else
			tmp+=TMI("mitem װ$U;unwield "+id);
	}

	if(ob->query("skill"))
		tmp+=TMI("mitem $U;study "+id);
	tmp+=TMI("mendd");
	tell_object(me,tmp);
	return 1;
}


================================================================================================

//Ҫ֧QQ˽ģ븴һtellctellȻ󽫸ԷϢ޸һ
//TMI("ctell name="+my_name+";ID="+my_id+";icon="+me->query("icon")+";"+tell_out);  tell_outǸԷϢ

//֧Ϣѯqqinfo  /cmds/std/qqinfo.c
/*Ϣѯ
ѯĳ
ѯԼġ
*/

int main(object me,string arg)
{
	object obj;
	string str;
	if(!arg)
		obj=me;
	if(arg&&sscanf(arg,"set %s",arg))
	{
	        arg=replace_string(arg,"\"","");
	        arg=replace_string(arg,"'","");
	        arg=replace_string(arg,"\\","");
		me->set("qqinfo",arg);
		write(ALERT("ĸϢѾóɹ!\n"));
		return 1;
	}
	if(arg&&!objectp(obj))
		obj = UPDATE_D->global_find_player(arg);
	if(!objectp(obj)) return notify_fail(ALERT("޷ѯԷϢ"));
	if(stringp(str=obj->query("qqinfo")))
	{
		write(TMI("qqinfo"+((obj==me)?"0":"1")+" "+str));
		return 1;
	}
	write(TMI("qqinfo"+((obj==me)?"0":"1")+""));
	if(obj->query_temp("temp_loaded"))
		UPDATE_D->global_destruct_player(obj,0);
	return 1;
}

================================================================================================

//ҪûԼͷ icon.c /cmds/usr/icon.c
#include <ansi.h>

inherit F_CLEAN_UP;

int help();

int main(object me,string arg)
{
	mixed tmp;
	int ico;
	string str="",icon=HIR"գû"NOR;
	if( (tmp = me->query("icon")))
	{
		if( intp(tmp) )
		{
			icon = sprintf("%d",tmp);
			str=L_ICON(icon);
		}
		else if( stringp(tmp) )
		{
			icon = tmp;
			str=L_ICON(icon);
		}
	}

	str+=NOR+"ԭͷ"+HIY+icon+NOR+"\n";

	if(arg)
	{
		if(sscanf(arg,"%d",ico)!=1||ico<=0||ico>=MAX_ICONS)
			return help();
		icon=sprintf("%d",ico);
		while( sizeof(icon)<5 )	icon = "0" + icon;
		str+="Ѿ޸Ϊ"+HIG+icon+NOR+"ˣ\n";
		me->set("icon",icon);
	}
	else help();
	tell_object(me,str);
	return 1;
}

int help()
{
	write("ʽ"+HIY+"icon [ͼ]\n"+NOR+
		"    ñѯ޸Լͷš\n"+
		"    ȥ[http://www.qqchat.net]ѯѡԼͷͼš\n"+
		"    ĿǰͼѡΧ"+HIR+" 1 - "+MAX_ICONS+NOR+" \n");
	return 1;
}





