refereew.c

来自「C实现的MUD,对大家基本入门网络游戏很有帮助!」· C语言 代码 · 共 145 行

C
145
字号
// refereew.c
inherit NPC;
#include <ansi.h>;

int do_bihua(string arg);
int do_setname(string arg);
int do_setcan(string arg);
int clear_title(string arg);
void add_title(object me,string arg);
void clear();
string ask_home();
string ask_me();
string ask_candidate();
string ask_nowcan();
int do_halt();

void create()
{
	set_name("公平子", ({ "gongping zi", "zi", "referee" }) );
	set("gender", "男性");
	set("age", 35);
	set("long",
		"这是一位仙风道骨的中年道人,早年云游四方,性好任侠,公正无私。\n");

	set("combat_exp",60000);
                set("shen_type", 1);
	set("attitude", "friendly");

	set("apply/attack", 50);
	set("apply/defense", 50);

	set("max_qi", 800);
	set("max_jing", 800);
	set("max_neili", 800);

	set("win_times", 0);

	set_skill("force", 80);
	set_skill("unarmed", 80);
	set_skill("sword",80);
	set_skill("parry",80);
	set_skill("dodge", 80);
	set("inquiry", ([
		"比武大会"       : (: ask_me :),
		"候选人"       : (: ask_candidate :),
		"当前候选人"   : (: ask_nowcan:),
		"回家"   : (: ask_home:),
	]));
  
	setup();
	set("candidate",this_object());
        carry_object("/clone/misc/cloth")->wear();
        carry_object("/d/city/obj/changjian")->wield();
}


void init()
{
		::init();
		add_action("do_bihua", "fight");
		add_action("do_bihua", "hit");
		add_action("do_bihua", "kill");
		add_action("do_bihua", "bihua");
	        add_action("do_bihua", "bi");
		add_action("do_halt", "halt");
        add_action("do_setname", "setname");
        add_action("do_setcan", "setcan");
        add_action("do_clear", "clear");
}

string ask_me()
{
	object* ob;
	int i;
	ob = users();

	if ( !wizardp(this_player()) ) return "你无权召开比武大会!\n";
	command("chat 好,现在比武大会正式开始,全体集合!\n");
	for ( i=0;i<sizeof(ob); i++ ) 
	if(!wizardp(ob[i])) 
	{
	this_object()->set("candidate",ob[i]);
	break;
	}
	for ( i=sizeof(ob); i>0; i-- ) {
		ob[i-1]->move("/d/huashan/sheshen");
		if(!wizardp(ob[i-1]))
		if(ob[i-1]->query("combat_exp")>this_object()->query("candidate")->query("combat_exp"))
		set("candidate",ob[i-1]);
	}
	command("chat 现在, 天下第一的候选人是"+this_object()->query("candidate")->query("name")+"!\n");
	command("chat 大家可以自由挑战。\n任何人连胜五场或者无人再向其挑战即可获得天下第一的称号。\n");
	command("chat 任何战败或中途弃权者均只能争夺下一称号.\n");
	return("你可以用setname somebody 指定某人为当前胜者。\n"+
            "也可以用setcan somebody 指定某人为当前候选人。\n");
}

void do_clear()
{
	object* ob;
	int i;
	ob = users();

	for ( i=0;i<sizeof(ob); i++ ) 
	add_title(ob[i],"");
}

string ask_home()
{
	this_player()->move("/d/city/guangchang");
	return("好的,我送你回杨州吧。\n");
}


int do_bihua(string arg)
{     
	object ob1, ob2;
        object old_target;

	ob1 = this_player();
        
	if( !arg || arg=="" ) return 0;  

	if ( arg == "gongping zi" || arg == "zi" || arg == "referee" )
           {
             command("say " + "你不能跟我比划!\n");
             return 1;
            }

	if ( this_object()->query_temp("busy") ) 
		return notify_fail("每次只能有两人参加比武。\n");

        if (!ob2 = present(arg,environment(ob1)) ) 
		return notify_fail("你想跟谁比划?\n");
	if(wizardp(ob1)) return notify_fail("巫师瞎掺合个什么啊?\n");
        if (ob1 == ob2)    return notify_fail("你不能攻击自己。\n");

        if(ob1->query("name")!=query("candidate")->query("name"))
        if (ob2->query("name")!=query("candidate")->query("name"))
        return notify_fail("你只能向候选人挑战。\n");

	if (ob1->query_temp("lose")*5>query("win_times"))    return notify_fail("你已经输过一次了,只能向下一候选人挑战。\n");

	if( userp(ob2) && (object)ob2->query_temp("pending/fight") !=ob1 ) {
		message_vision("\n$N对着$n说道

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?