// 第三章
int Rule = 1;
int RoundTime = 50;
int PlayerSpawn = 0;
int PlayerSpawnDir = 180;
int PlayerWeapon = 43;
int PlayerWeapon2 = 0;
int PlayerHP = 4000;

int q=0;
int qc1=0;
int cd=0;
int qb=0;
int qbfw=0;
int qbsj=0;
int qbg=0;
int qbg2=0;
int qws=0;
int hp1=0;
int hp2=0;
int hp3=0;
int hp4=0;
int qhx=1;
int qzc=0;
int qzc1=0;
int q1=0;
int q2=0;
int q3=0;
int q4=0;
int q5=0;
int qfs=0;
int t=0;
int t1=0;
int tbfw=0;
int tbsj=0;
int tbg=0;
int tbg2=0;
int thx=0;
int tws=0;
int tzc=0;
int tfs=0;
int t5=0;
int v= 0;

Save(string SFile, int s)
{
	int f = OpenFile(SFile,"w");
	WriteFile(f,s);
	CloseFile(f);
	return 1;
}
Load(string SFile)
{
	int f = OpenFile(SFile,"r");
	return ReadFile(f);
	CloseFile(f);
}

OnUpdate()
{
	int player = GetAnyChar("player");
	if (player < 0)
	{
		return 0;
	}
	
	int c = GetAnyChar("汤 怀");
	int c2 = GetAnyChar("张 显");
	int c3 = GetAnyChar("王 贵");
	int c4 = GetAnyChar("洪先"); 
	int c5 = GetAnyChar("校场守卫·甲");
	int c6 = GetAnyChar("校场守卫·乙");
	int c7 = GetAnyChar("校场守卫·丙");
	int c8 = GetAnyChar("校场守卫·丁");
	int c9 = GetAnyChar("校场守卫·戊");
	int c10 = GetAnyChar("校场守卫·己");
	int c11 = GetAnyChar("李知县");
	int c12 = GetAnyChar("侍卫·甲");
	int c13 = GetAnyChar("侍卫·乙");
	int c14 = GetAnyChar("校场考官");
	int c15 = GetAnyChar("武生·甲");
	int c16 = GetAnyChar("武生·乙");
	int c17 = GetAnyChar("武生·丙");
	int c18 = GetAnyChar("武生·丁");
	int c19 = GetAnyChar("武生·戊");
	int c20 = GetAnyChar("武生·己");
	int c21 = GetAnyChar("武生·庚");
	int c22 = GetAnyChar("武生·辛");
	int c23 = GetAnyChar("【飞镖】");
	int c24 = GetAnyChar("【子】");
	int c25 = GetAnyChar("【丑】");
	int c26 = GetAnyChar("【寅】");
	int c27 = GetAnyChar("【卯】");
	int c28 = GetAnyChar("【辰】");
	int c29 = GetAnyChar("【巳】");
	int c30 = GetAnyChar("【午】");
	int c31 = GetAnyChar("【未】");
	int c32 = GetAnyChar("【申】");
	int c33 = GetAnyChar("【酉】");
	int c34 = GetAnyChar("【戌】");
	int c35 = GetAnyChar("【亥】");
	int c36 = GetAnyChar("【乾三连】");
	int c37 = GetAnyChar("【坤六断】");
	int c38 = GetAnyChar("【震仰盂】");
	int c39 = GetAnyChar("【艮覆碗】");
	int c40 = GetAnyChar("【离中虚】");
	int c41 = GetAnyChar("【坎中满】");
	int c42 = GetAnyChar("【兑上缺】");
	int c43 = GetAnyChar("【巽下断】");
	int now=GetGameTime();
	int gameover = 0;
	
	if(cd==0)
	{
		if(Load("Level\sa03.sav")==0)
		{
			cd=9;
			q=0;
			t=now+1;
		}
		if(Load("Level\sa03.sav")==1)
		{
			cd=9;
			q=26;
			t=now+1;
		}
		if(Load("Level\sa03.sav")==2)
		{
			cd=9;
			q=34;
			t=now+1;
		}
		
	}
	if (q==0)
	{
		AddNPC("3-1");
	    AddNPC("3-2");
	    AddNPC("3-3");
	    AddNPC("3-4");
	    AddNPC("3-5");
	    AddNPC("3-6");
	    AddNPC("3-7");
	    AddNPC("3-8");
		AddNPC("3-9");
	    AddNPC("3-10");
		q=1;		
	}
	if(q==1&&c>=0&&c2>=0&&c3>=0&&c4>=0&&c5>=0&&c6>=0&&c7>=0&&c8>=0&&c9>=0&&c10>=0)
	{
		Perform(c10,"guard",3);
		Perform(c9,"guard",3);
		Perform(c8,"guard",3);
		Perform(c7,"guard",3);
		Perform(c6,"guard",3);
		Perform(c5,"guard",3);
		Perform(c4,"guard",3);
		Perform(c2,"guard",3);
		Perform(c,"guard",3);
			
		Perform(c3,"say", "贼厮鸟，着爷爷的斧罢！");
		Perform(c3,"pause", 3);
		
		Perform(c4,"say", "来呀！给我拿下他们！");
		Perform(c4,"pause", 1);
			
		Perform(c10, "faceto", player);
		Perform(c9, "faceto", player);
		Perform(c8, "faceto", player);
		Perform(c7, "faceto", player);
		Perform(c6, "faceto", player);
		Perform(c5, "faceto", player);
		Perform(c4, "faceto", player);
		Perform(c, "faceto", c4);
		Perform(c3, "faceto", c4);
		Perform(c2, "faceto", c4);
		
		PlayerPerform("say", "中军大人，草民等无意冲撞，还请罢手吧！");
		PlayerPerform("pause", 30);
		PlayerPerform("say", "中军大人，还请息怒！");
		PlayerPerform("pause", 3);
		PlayerPerform("say", "诸位兄弟切莫莽撞！");
		PlayerPerform("pause", 6);
		PlayerPerform("block", 0);
		PlayerPerform("pause", 2);
		PlayerPerform("block", 1);
		q=2;
		qhx=1;
	}	
	if(q==2&&GetHP(c4)>0&&GetHP(c5)<=0&&GetHP(c6)<=0&&GetHP(c7)<=0&&GetHP(c8)<=0&&GetHP(c9)<=0&&GetHP(c10)<=0)
	{
		AddNPC("3-11");
		AddNPC("3-12");
		AddNPC("3-13");
		q=3;
	}
	if(q==3&&c11>=0&&c12>=0&&c13>=0)
	{
		Perform(c11,"say", "都给我住手！");
		q=4;
		t=now+2;
	}
	if(q==4&&now>t)
	{
		ChangeBehavior(c4, "idle");
		SetTarget(0, "waypoint", 23);
		ChangeBehavior(c4, "attacktarget", 0);
		
		ChangeBehavior(c, "idle");
		SetTarget(1, "waypoint", 0);
		ChangeBehavior(c, "attacktarget", 1);
		
		ChangeBehavior(c2, "idle");
		SetTarget(2, "waypoint", 2);
		ChangeBehavior(c2, "attacktarget", 2);
		
		ChangeBehavior(c3, "idle");
		SetTarget(3, "waypoint", 3);
		ChangeBehavior(c3, "attacktarget", 3);
		q=5;
	}
	if(q==5)
	{
		SetTarget(0, "waypoint", 11);
		SetTarget(1, "char", player);
		if (Distance(0, 1) <=200)
		{
			Perform(c3,"say", "贼厮鸟！还敢胡说！俺撕烂你的嘴！");
			Perform(c3,"pause", 24);
			
			Perform(c,"say", "胡说八道！");
			Perform(c,"pause", 6);
			
			Perform(c4,"say", "大人！！……是……");
			Perform(c4,"pause", 9);
			Perform(c4,"say", "大人，实情并非如此……");
			Perform(c4,"pause", 18);
			Perform(c4,"say", "大人，这几个贼子意图破坏考场，下官正要擒拿。");
			Perform(c4,"pause", 3);
			
			Perform(c11,"say", "都住口！洪先，你先退下！");
			Perform(c11,"pause", 9);
			Perform(c11,"say", "三日后乡试已然结束。洪先，他们说的可属实？");
			Perform(c11,"pause", 18);
			Perform(c11,"say", "何人如此大胆，竟敢扰乱校场！");
			
			PlayerPerform("say", "草民与他说情，他却要拿了草民。");
		    PlayerPerform("pause", 3);
			PlayerPerform("say", "只因未曾送来常利，中军大人便要草民等三日后再来。");
		    PlayerPerform("pause", 3);
			PlayerPerform("say", "禀大人，草民岳飞等兄弟四人，原也是来应试的武生，");
			PlayerPerform("pause", 9);
			PlayerPerform("block", 1);
			
			Perform(c11, "faceto", c4);
			Perform(c, "faceto", c11);
			Perform(c2, "faceto", c11);
			Perform(c3, "faceto", c11);
			Perform(c4, "faceto", c11);
			q=6;
			t=now+25;
		}
	}
	if(q==6&&now>t)
	{
		RemoveNPC(c4);
		RemoveNPC(c5);
		RemoveNPC(c6);
		RemoveNPC(c7);
		RemoveNPC(c8);
		RemoveNPC(c9);
		RemoveNPC(c10);
		q=7;
		t=now+2;
	}
	if(q==7&&now>t)
	{
		Perform(c11,"say", "岳飞，考试结束之后，无论结果如何，你即来见本县。");
		Perform(c11,"pause", 6);
		Perform(c11,"say", "罢了，你们先行应考，余事暂且搁下。");
		Perform(c11,"pause", 3);
		Perform(c11,"say", "你手中的兵器……");
		Perform(c11,"pause", 6);
		Perform(c11,"say", "你等便是岳家村的考生岳飞汤怀等人？");
		Perform(c11, "faceto", player);
		
		PlayerPerform("block", 0);
		PlayerPerform("say", "谨遵台命。");
		PlayerPerform("pause", 6);
		PlayerPerform("say", "谢大人！");
		PlayerPerform("pause", 9);
		PlayerPerform("say", "回大人，正是草民兄弟四人。");
		PlayerPerform("pause", 3);
		PlayerPerform("block", 1);
		q=8;
		t=now+15;
	}
	if(q==8&&now>t)
	{
		RemoveNPC(c11);
		RemoveNPC(c12);
		RemoveNPC(c13);
		q=9;
	}
	if(q==9)
	{
		SetTarget(0, "waypoint", 0);
		SetTarget(1, "char", player);
		if (Distance(0, 1) <=100)
		{
			Perform(c,"say", "岳大哥，你自去专心应考，兄弟们在场外掠阵。");
		    Perform(c,"pause", 18);
			
			Perform(c3,"say", "他要敢使坏，俺就再让他尝尝板斧的滋味！");
		    Perform(c3,"pause", 12);
			
			Perform(c2,"say", "只是适才一番争斗，唯恐那中军官会暗中使坏。");
		    Perform(c2,"pause", 3);
			Perform(c2,"say", "岳大哥既如此说，兄弟们自当照办。");
		    Perform(c2,"pause", 6);
			
			PlayerPerform("say", "有劳！");
		    PlayerPerform("pause", 6);
			PlayerPerform("say", "王兄弟，所谓冤家宜解不宜结，日后行事须得谨慎为先。");
		    PlayerPerform("pause", 12);
			PlayerPerform("say", "这第一场便由愚兄先考，也好探探虚实。");
		    PlayerPerform("pause", 3);
			PlayerPerform("say", "诸位兄弟，今日乡试武生云集。");
			PlayerPerform("block", 1);
			
			Perform(c, "faceto", player);
			Perform(c2, "faceto", player);
			Perform(c3, "faceto", player);
			q=10;
			t=now+18;
		}
	}
	if(q==10&&now>t)
	{
		RemoveNPC(c);
		RemoveNPC(c2);
		RemoveNPC(c3);
		q=11;
		t=now+1;
	}
	if(q==11&&now>t)
	{
		AddNPC("3-14");
		q=12;
	}
	if(q==12&&c14>=0)
	{
		PlayerPerform("block", 0);
		PlayerPerform("say", "【提示：请进入内场。】");
		PlayerPerform("say", "【提示：请进入内场。】");
		PlayerPerform("pause", 3);
		PlayerPerform("block", 1);
		PlayerPerform("use", 15);
		
		Perform(c14,"say", "时辰已到，请众武生入场！");
		q=13;
	}
	if(q==13)
	{
		SetTarget(0, "waypoint", 56);
		SetTarget(1, "char", player);
		if (Distance(0, 1) <=200)
		{
			AddNPC("3-15");
			AddNPC("3-16");
			AddNPC("3-17");
			AddNPC("3-18");
			AddNPC("3-19");
			AddNPC("3-20");
			AddNPC("3-21");
			AddNPC("3-22");
			q=14;
		}
	}
	if(q==14&&c15>=0&&c16>=0&&c17>=0&&c18>=0&&c19>=0&&c20>=0&&c21>=0&&c22>=0)
	{
		SetTarget(0, "waypoint", 14);
		SetTarget(1, "char", player);
		if (Distance(0, 1) <=180)
		{
			Perform(c14,"say", "【考生岳飞请准备！】");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "第一场由【岳家村岳飞】应考，余人请退场！");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "众考生可都听清楚了？");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "第三场为【角斗】，战场之上刀剑无眼，艺高胆大可保百战不殆。");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "第二场为【突围】，万军丛中来去自如，机变迅猛方能斩旗夺帅。");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "第一场为【暗器】，百步穿杨箭无虚发，千尺之外亦可取敌首级。");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "本次武考【共分三场】。");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "比武切磋之际，不可挟带私怨！违令者取消参考资格！");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "本次考试，旨在为朝廷选拔栋梁，请众考生务必遵守考场规则！");
			
			PlayerPerform("block", 1);
			
			Perform(c14, "faceto", player);
			Perform(c15, "faceto", c14);
			Perform(c16, "faceto", c14);
			Perform(c17, "faceto", c14);
			Perform(c18, "faceto", c14);
			Perform(c19, "faceto", c14);
			Perform(c20, "faceto", c14);
			Perform(c21, "faceto", c14);
			Perform(c22, "faceto", c14);
			q=15;
			t=now+28;
		}
	}
	if(q==15&&now>t)
	{
		RemoveNPC(c15);
		RemoveNPC(c16);
		RemoveNPC(c17);
		RemoveNPC(c18);
		RemoveNPC(c19);
		RemoveNPC(c20);
		RemoveNPC(c21);
		RemoveNPC(c22);
		q=16;
		t=now+1;
	}
	if(q==16&&now>t)
	{
		AddNPC("3-23");
		q=17;
	}
	if(q==17&&c23>=0)
	{
		Perform(c14,"say", "岳考生，请【换取飞镖】。");
		
		PlayerPerform("block", 0);
		PlayerPerform("pause", 1);
		PlayerPerform("block", 1);
		Perform(c23, "faceto", player);
		q=18;
		t=now+1;
	}
	if(q==18&&now>t)
	{
		Perform(c23,"use", 35);
		q=19;
		t=now+1;
	}
	if(q==19&&now>t)
	{
		RemoveNPC(c23);
		q=20;
		t=now+2;
	}
	if(q==20&&now>t)
	{
		Perform(c14,"say", "【提示：走到【四根石柱中央位置，移动范围千万不可过大】！】。");
		Perform(c14,"pause", 4);
		Perform(c14,"say", "【考生听清楚后，【请准备】！】。");
		Perform(c14,"pause", 4);
		Perform(c14,"say", "【当标靶出现后，即为计时开始】。");
		Perform(c14,"pause", 4);
		Perform(c14,"say", "【切记！标靶出现后，【只能在所站位置三步之内移动，超出即为不合格】！】");
		Perform(c14,"pause", 4);
		Perform(c14,"say", "【考生移步至【四根石柱】中央位置，在时限内【用飞镖击中标靶】。】");
		Perform(c14,"pause", 4);
		Perform(c14,"say", "本场规则：【换取飞镖后，场地周围高处会出现标靶】。");
		Perform(c14,"pause", 4);
		Perform(c14,"say", "岳考生，【换好飞镖】后，稍安勿动，【请仔细听规则】！");
		Perform(c14, "faceto", player);
		
		PlayerPerform("block", 0);
		PlayerPerform("pause", 12);
		PlayerPerform("block", 1);
		PlayerPerform("pause", 2);
		PlayerPerform("block", 1);
		PlayerPerform("pause", 2);
		PlayerPerform("block", 1);
		PlayerPerform("pause", 2);
		PlayerPerform("block", 1);
		PlayerPerform("pause", 2);
		PlayerPerform("block", 1);
		PlayerPerform("pause", 2);
		PlayerPerform("block", 1);
		q=21;
	}
	if(q==21)
	{
		SetTarget(0, "waypoint", 58);
		SetTarget(1, "char", player);
		if (Distance(0, 1) <=15)
		{
			PlayerPerform("block", 0);
		    PlayerPerform("say", "【切记！移动超过三步，或者时间耗尽，均为任务失败！】");
		    PlayerPerform("pause", 4);
		    PlayerPerform("say", "【提示：共有12个标靶，都在看得见的范围内，限时90秒！】");
		    PlayerPerform("block", 1);
			q=22;
			t=now+5;
		}
	}
	if(q==22&&now>t)
	{
		AddNPC("3-24");
		AddNPC("3-25");
		AddNPC("3-26");
		AddNPC("3-27");
		AddNPC("3-28");
		AddNPC("3-29");
		AddNPC("3-30");
		AddNPC("3-31");
		AddNPC("3-32");
		AddNPC("3-33");
		AddNPC("3-34");
		AddNPC("3-35");
		q=23;
	}
	if(q==23&&c24>=0&&c25>=0&&c26>=0&&c27>=0&&c28>=0&&c29>=0&&c30>=0&&c31>=0&&c32>=0&&c33>=0&&c34>=0&&c35>=0)
	{
		PlayerPerform("say", "【计时开始！】");
		PlayerPerform("say", "【计时开始！】");
		Perform(c24, "use", 47);
		Perform(c25, "use", 47);
		Perform(c26, "use", 47);
		Perform(c27, "use", 47);
		Perform(c28, "use", 47);
		Perform(c29, "use", 47);
		Perform(c30, "use", 47);
		Perform(c31, "use", 47);
		Perform(c32, "use", 47);
		Perform(c33, "use", 47);
		Perform(c34, "use", 47);
		Perform(c35, "use", 47);
		Perform(c24, "use", 19);
		Perform(c25, "use", 19);
		Perform(c26, "use", 19);
		Perform(c27, "use", 19);
		Perform(c28, "use", 19);
		Perform(c29, "use", 19);
		Perform(c30, "use", 19);
		Perform(c31, "use", 19);
		Perform(c32, "use", 19);
		Perform(c33, "use", 19);
		Perform(c34, "use", 19);
		Perform(c35, "use", 19);
		Perform(c24, "faceto", player);
		Perform(c25, "faceto", player);
		Perform(c26, "faceto", player);
		Perform(c27, "faceto", player);
		Perform(c28, "faceto", player);
		Perform(c29, "faceto", player);
		Perform(c30, "faceto", player);
		Perform(c31, "faceto", player);
		Perform(c32, "faceto", player);
		Perform(c33, "faceto", player);
		Perform(c34, "faceto", player);
		Perform(c35, "faceto", player);
		q=99;
		qb=1;
		qbfw=1;
		qbsj=1;
		tbsj=now+10;
	}
	if(q==24)
	{
	    PlayerPerform("say", "【提示：请走到校场考官面前。】");
		PlayerPerform("pause", 3);
		
		Perform(c14,"say", "很好，第一场合格，岳考生准备应考第二场。");
		q=25;
	}
	if(q==25)
	{
		SetTarget(0, "waypoint", 14);
		SetTarget(1, "char", player);
		if (Distance(0, 1) <=200)
		{
			Perform(c14,"say", "考生听清楚后，【请走到门洞下准备】！");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "【注意！会有其他武生干扰，但你不可伤及他们！】");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "在【时限内打破石像】方为合格。【限时15分钟】。");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "第二场【突围战】，校场周围共有【八尊石像】，分两批出现。");
			
			PlayerPerform("block", 0);
		    PlayerPerform("pause", 12);
		    PlayerPerform("block", 1);
			q=26;
			t=now+10;
		}
	}
	if(q==26&&now>t)
	{
		RemoveNPC(c14);
		RemoveNPC(c24);
		RemoveNPC(c25);
		RemoveNPC(c26);
		RemoveNPC(c27);
		RemoveNPC(c28);
		RemoveNPC(c29);
		RemoveNPC(c30);
		RemoveNPC(c31);
		RemoveNPC(c32);
		RemoveNPC(c33);
		RemoveNPC(c34);
		RemoveNPC(c35);
		q=99;
		qc1=1;
		Save("Level\sa03.sav",1);
	}
	if(qc1==1)
	{
		PlayerPerform("say", "【提示：请走到门洞下，开始挑战！】");
		PlayerPerform("pause", 2);
		PlayerPerform("say", "存档已生成...");
		PlayerPerform("pause", 1);
		PlayerPerform("say", "存档已生成...");
		PlayerPerform("pause", 2);
		PlayerPerform("block", 0);
		PlayerPerform("say", "正在存档...");
		PlayerPerform("pause", 1);
		PlayerPerform("say", "正在存档...");
		PlayerPerform("block", 1);
		qc1=9;
		q=27;
	}
	if(q==27)
	{
		SetTarget(0, "waypoint", 28);
		SetTarget(1, "char", player);
		if (Distance(0, 1) <=100)
		{
			AddNPC("3-36");
		    AddNPC("3-37");
		    AddNPC("3-38");
		    AddNPC("3-39");
			AddNPC("3-18");
			AddNPC("3-19");
			AddNPC("3-20");
			AddNPC("3-21");
			q=28;
		}
	}
	if(q==28&&c36>=0&&c37>=0&&c38>=0&&c39>=0&&c18>=0&&c19>=0&&c20>=0&&c21>=0)
	{
		PlayerPerform("say", "【限时15分钟，计时开始！】");
		PlayerPerform("pause", 4);
		PlayerPerform("say", "【注意！其余武生会攻击你，但你不能反击！否则任务失败！】");
		PlayerPerform("pause", 4);
		PlayerPerform("say", "【提示：第一批【四尊石像】已出现，在【中场四角位置】，快速击破！】");
		PlayerPerform("pause", 1);
		
		Perform(c36, "use", 47);
		Perform(c37, "use", 47);
		Perform(c38, "use", 47);
		Perform(c39, "use", 47);
		Perform(c36, "faceto", c37);
		Perform(c37, "faceto", c36);
		Perform(c38, "faceto", c39);
		Perform(c39, "faceto", c38);
		Perform(c18,"use", 43);
		Perform(c19,"use", 43);
		Perform(c20,"use", 43);
		Perform(c21,"use", 43);
		q=29;
		t=now+1;
	}
	if(q==29&&now>t)
	{
		ChangeBehavior(c18,"follow", player);
		ChangeBehavior(c19,"follow", player);
		ChangeBehavior(c20,"follow", player);
		ChangeBehavior(c21,"follow", player);
		q=99;
		qbg=1;
		qbg2=1;
		qws=1;
		tbg=now+60;
	}
	if(q==30)
	{
		AddNPC("3-14");
		q=31;
	}
	if(q==31&&c14>=0)
	{
		ChangeBehavior(c21,"idle");
		ChangeBehavior(c20,"idle");
		ChangeBehavior(c19,"idle");
		ChangeBehavior(c18,"idle");
		PlayerPerform("block", 1);
		q=32;
	}
	if(q==32)
	{
		Perform(c14,"say", "余人请退场，【岳考生请返回内场】。");
		Perform(c14,"pause", 3);
		Perform(c14,"say", "岳考生连过两关，可喜可贺！");
		Perform(c14, "faceto", player);
		
		PlayerPerform("block", 0);
		PlayerPerform("pause", 3);
		PlayerPerform("block", 1);
		q=33;
		t=now+2;
	}
	if(q==33&&now>t)
	{
		RemoveNPC(c14);
		RemoveNPC(c18);
		RemoveNPC(c19);
		RemoveNPC(c20);
		RemoveNPC(c21);
		q=34;
		t=now+1;
	}
	if(q==34&&now>t)
	{
		PlayerPerform("say", "【提示：请返回内场！】");
		PlayerPerform("pause", 2);
		PlayerPerform("say", "存档已生成...");
		PlayerPerform("pause", 1);
		PlayerPerform("say", "存档已生成...");
		PlayerPerform("pause", 2);
		PlayerPerform("block", 0);
		PlayerPerform("say", "正在存档...");
		PlayerPerform("pause", 1);
		PlayerPerform("say", "正在存档...");
		PlayerPerform("block", 1);
		q=35;
		t=now+2;
		Save("Level\sa03.sav",2);
	}
	if(q==35&&now>t)
	{
		AddNPC("3-14");
		q=36;
	}
	if(q==36)
	{
		SetTarget(0, "waypoint", 14);
		SetTarget(1, "char", player);
		if (c14>=0&&Distance(0, 1) <=200)
		{
			Perform(c14,"say", "考生【请准备】！");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "下场为【防守战】，在【规定区域、规定时间内接受五名武生围攻，并存活下来】。");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "上场为【车轮战】，依次战胜三名武生。");
		    Perform(c14,"pause", 4);
			Perform(c14,"say", "第三场为【角斗】，分为上下两场。");
		    Perform(c14,"pause", 4);
		    Perform(c14,"say", "岳考生果乃人中龙凤，请准备应考第三场！");
			Perform(c14, "faceto", player);
		
		    PlayerPerform("block", 0);
			PlayerPerform("use", 15);
		    PlayerPerform("pause", 16);
		    PlayerPerform("block", 1);
			q=37;
			t=now+16;
		}
	}
	if(q==37&&now>t)
	{
		RemoveNPC(c14);
		q=38;
		t=now+1;
	}
	if(q==38&&now>t)
	{
		AddNPC("3-15");
		q=39;
	}
	if(q==39&&c15>=0)
	{
		Perform(c15,"say", "兄台请赐教！");
		Perform(c15, "faceto", player);
		
		PlayerPerform("say", "请！");
		PlayerPerform("pause", 3);
		q=40;
		t=now+2;
	}
	if(q==40&&now>t)
	{
		ChangeBehavior(c15,"follow", player);
		q=41;
	}
	if(q==41&&GetHP(c15)<=1000)
	{
		ChangeBehavior(c15,"idle");
		q=42;
	}
	if(q==42)
	{
		Perform(c15,"guard",10);
		Perform(c15,"say", "哼！");
		Perform(c15, "faceto", player);
		
		PlayerPerform("block", 0);
		PlayerPerform("say", "承让！");
		PlayerPerform("pause", 3);
		PlayerPerform("block", 1);
		q=43;
		t=now+3;
	}
	if(q==43&&now>t)
	{
		RemoveNPC(c15);
		q=44;
		t=now+1;
	}
	if(q==44&&now>t)
	{
		AddNPC("3-16");
		q=45;
	}
	if(q==45&&c16>=0)
	{
		Perform(c16,"say", "你休想过我这关！");
		Perform(c16, "faceto", player);
		
		PlayerPerform("say", "试试便知！");
		PlayerPerform("pause", 3);
		q=46;
		t=now+2;
	}
	if(q==46&&now>t)
	{
		ChangeBehavior(c16,"follow", player);
		q=47;
	}
	if(q==47&&GetHP(c16)<=1000)
	{
		ChangeBehavior(c16,"idle");
		q=48;
	}
	if(q==48)
	{
		Perform(c16,"guard",10);
		Perform(c16,"say", "好小子！今天算你走运！");
		Perform(c16, "faceto", player);
		
		PlayerPerform("block", 0);
		PlayerPerform("say", "承让！");
		PlayerPerform("pause", 3);
		PlayerPerform("block", 1);
		q=49;
		t=now+3;
	}
	if(q==49&&now>t)
	{
		RemoveNPC(c16);
		q=50;
		t=now+1;
	}
	if(q==50&&now>t)
	{
		AddNPC("3-17");
		q=51;
	}
	if(q==51&&c17>=0)
	{
		Perform(c17,"say", "俺叫李朝宗，兄台，得罪了。");
		Perform(c17, "faceto", player);
		
		PlayerPerform("say", "兄台请赐招。");
		PlayerPerform("pause", 3);
		q=52;
		t=now+2;
	}
	if(q==52&&now>t)
	{
		ChangeBehavior(c17,"follow", player);
		q=53;
	}
	if(q==53&&GetHP(c17)<=1000)
	{
		ChangeBehavior(c17,"idle");
		q=54;
	}
	if(q==54)
	{
		Perform(c17,"guard",10);
		Perform(c17,"say", "……果然好身手！");
		Perform(c17, "faceto", player);
		
		PlayerPerform("say", "兄台承让了！");
		PlayerPerform("pause", 3);
		PlayerPerform("block", 1);
		q=55;
		t=now+3;
	}
	if(q==55&&now>t)
	{
		RemoveNPC(c17);
		q=56;
		t=now+1;
	}
	if(q==56&&now>t)
	{
		PlayerPerform("block", 0);
		PlayerPerform("use", 16);
		PlayerPerform("say", "【下场即将开始！请移步四根石柱中央准备。】");
		q=57;
		t=now+3;
	}
	if(q==57)
	{
		SetTarget(0, "waypoint", 58);
		SetTarget(1, "char", player);
		if (Distance(0, 1) <=80&&now>t)
		{
			PlayerPerform("block", 0);
			PlayerPerform("say", "【请准备，即将开始！】");
		    PlayerPerform("pause", 4);
			PlayerPerform("say", "【在围攻下【存活五分钟】，即为胜利。】");
		    PlayerPerform("pause", 4);
			PlayerPerform("say", "【试图登上城墙，或是离开本院，即视为认输！】");
		    PlayerPerform("pause", 4);
			PlayerPerform("say", "【注意！战斗局域只能在本院内！】");
		    PlayerPerform("pause", 4);
			PlayerPerform("say", "【可以进行反击，敌人血量降到100以下将会离场。】");
		    PlayerPerform("pause", 4);
			PlayerPerform("say", "【下场为【防守战】，将由五名武生同时进攻。】");
			PlayerPerform("block", 1);
			q=58;
			t=now+18;
		}
	}
	if(q==58&&now>t)
	{
		AddNPC("3-18");
		AddNPC("3-19");
		AddNPC("3-20");
		AddNPC("3-21");
		AddNPC("3-22");
		q=59;
	}
	if(q==59&&c18>=0&&c19>=0&&c20>=0&&c21>=0&&c22>=0)
	{
		ChangeBehavior(c18,"follow", player);
		ChangeBehavior(c19,"follow", player);
		ChangeBehavior(c20,"follow", player);
		ChangeBehavior(c21,"follow", player);
		ChangeBehavior(c22,"follow", player);
		q=60;
		qzc=1;
		q1=1;
		q2=1;
		q3=1;
		q4=1;
		q5=1;
		qfs=1;
		t=now+60;
	}
	if(q==60&&now>t)
	{
		PlayerPerform("say", "【再坚持4分钟】。");
		q=61;
		t=now+60;
	}
	if(q==61&&now>t)
	{
		PlayerPerform("say", "【再坚持3分钟】。");
		q=62;
		t=now+60;
	}
	if(q==62&&now>t)
	{
		PlayerPerform("say", "【再坚持2分钟】。");
		q=63;
		t=now+60;
	}
	if(q==63&&now>t)
	{
		PlayerPerform("say", "【再坚持1分钟】。");
		q=64;
		t=now+60;
	}
	if(q==64&&now>t)
	{
		PlayerPerform("say", "【时间到！】");
		q=65;
		t=now+1;
	}
	if(q==65&&now>t)
	{
		ChangeBehavior(c18,"idle");
		ChangeBehavior(c19,"idle");
		ChangeBehavior(c20,"idle");
		ChangeBehavior(c21,"idle");
		ChangeBehavior(c22,"idle");
		q=66;
	}
	if(q==66)
	{
		AddNPC("3-14");
		q=67;
		t=now+1;
	}
	if(q==67&&now>t)
	{
		Perform(c14,"say", "恭喜岳考生夺得今科乡试解元！");
		Perform(c14, "faceto", player);
		q=68;
		t=now+5;
		Save("Level\sa03.sav",0);
	}
	if(q==68&&now>t)
	{
		v=2;
	}
	if(qfs==1&&c18<0&&c19<0&&c20<0&&c21<0&&c22<0)
	{
		qfs=2;
		q=99;
		tfs=now+2;
	}
	if(qfs==2&&now>tfs)
	{
		AddNPC("3-14");
		qfs=3;
	}
	if(qfs==3&&c14>=0)
	{
		Perform(c14,"say", "恭喜岳考生夺得今科乡试解元！");
		Perform(c14, "faceto", player);
		qfs=4;
		tfs=now+5;
		Save("Level\sa03.sav",0);
	}
	if(qfs==4&&now>tfs)
	{
		v=2;
	}
	
	if(q1==1&&GetHP(c18)<=1000)
	{
		Perform(c18,"guard",3);
		Perform(c18,"say", "兄台好武艺！");
		q1=2;
		t1=now+2;
	}
	if(q1==2&&now>t1)
	{
		RemoveNPC(c18);
		q1=9;
	}
	if(q2==1&&GetHP(c19)<=1000)
	{
		Perform(c19,"guard",3);
		Perform(c19,"say", "好功夫！在下佩服！");
		q2=2;
		t1=now+2;
	}
	if(q2==2&&now>t1)
	{
		RemoveNPC(c19);
		q2=9;
	}
	if(q3==1&&GetHP(c20)<=1000)
	{
		Perform(c20,"guard",3);
		Perform(c20,"say", "技不如人，奈若何！");
		q3=2;
		t1=now+2;
	}
	if(q3==2&&now>t1)
	{
		RemoveNPC(c20);
		q3=9;
	}
	if(q4==1&&GetHP(c21)<=1000)
	{
		Perform(c21,"guard",3);
		Perform(c21,"say", "五人围攻尚不能取胜，我再回家练上三年罢！");
		q4=2;
		t1=now+2;
	}
	if(q4==2&&now>t1)
	{
		RemoveNPC(c21);
		q4=9;
	}
	if(q5==1&&GetHP(c22)<=1000)
	{
		Perform(c22,"guard",3);
		Perform(c22,"say", "今科武状元非此人莫属！");
		q5=2;
		t1=now+2;
	}
	if(q5==2&&now>t1)
	{
		RemoveNPC(c22);
		q5=9;
	}
	if(qzc==1)
	{
		SetTarget(0, "waypoint", 58);
		SetTarget(1, "char", player);
		if (Distance(0, 1) >=400)
		{
			PlayerPerform("say", "【出界了！快返回战场！】");
			PlayerPerform("say", "【出界了！快返回战场！】");
			qzc=2;
			qzc1=1;
			tzc=now+3;
		}
	}
	if(qzc==2)
	{
		SetTarget(0, "waypoint", 58);
		SetTarget(1, "char", player);
		if (Distance(0, 1) <=400)
		{
			qzc=1;
			qzc1=9;
		}
	}
	if(qzc1==1&&now>tzc)
	{
		PlayerPerform("say", "【很遗憾，你逃离了战场。】");
		qzc1=2;
		tzc=now+3;
	}
	if(qzc1==2&&now>tzc)
	{
		v=1;
	}
	if(qbg2==1&&GetHP(c36)<=0&&GetHP(c37)<=0&&GetHP(c38)<=0&&GetHP(c39)<=0)
	{
		qbg2=2;
		tbg2=now+1;
	}
	if(qbg2==2&&now>tbg2)
	{
		RemoveNPC(c36);
		RemoveNPC(c37);
		RemoveNPC(c38);
		RemoveNPC(c39);
		qbg2=3;
	}
	if(qbg2==3)
	{
		AddNPC("3-40");
		AddNPC("3-41");
		AddNPC("3-42");
		AddNPC("3-43");
		qbg2=4;
	}
	if(qbg2==4&&c40>=0&&c41>=0&&c42>=0&&c43>=0)
	{
		PlayerPerform("say", "【提示：第二批【四尊石像】已出现，在【外场四角位置】，快速击破！】");
		PlayerPerform("pause", 1);
		PlayerPerform("say", "【提示：第二批【四尊石像】已出现，在【外场四角位置】，快速击破！】");
		qbg2=5;
	}
	if(qbg2==5&&GetHP(c40)<=0&&GetHP(c41)<=0&&GetHP(c42)<=0&&GetHP(c43)<=0)
	{
		Perform(c40, "use", 47);
		Perform(c41, "use", 47);
		Perform(c42, "use", 47);
		Perform(c43, "use", 47);
		qbg=99;
		qws=99;
		qbg2=6;
		tbg2=now+1;
	}
	if(qbg2==6&&now>tbg2)
	{
		RemoveNPC(c40);
		RemoveNPC(c41);
		RemoveNPC(c42);
		RemoveNPC(c43);
		qbg2=99;
		q=30;
	}
	if(qhx==1&&GetHP(c4)<=3000)
	{
		PlayerPerform("say", "【提示：不能杀死洪先！否则任务失败！】");
		PlayerPerform("pause", 3);
		PlayerPerform("say", "（我与他无冤无仇，不可伤其性命。）");
		PlayerPerform("pause", 4);
		Perform(c22,"say", "好贼子！胆敢伤了本官！");
		qhx=2;
	}
	if(qhx=2&&GetHP(c4)<=0)
	{
		PlayerPerform("say", "（如此焉能参加武考！）");
		PlayerPerform("pause", 3);
		PlayerPerform("say", "（不好！竟失手伤了他性命！）");
		ChangeBehavior(c,  "idle");
		ChangeBehavior(c2,  "idle");
		ChangeBehavior(c3,  "idle");
		PlayerPerform("block", 1);
		qhx=3;
		thx=now+3;
	}
	if(qhx==3&&now>thx)
	{
		v=1;
	}
	if(qws==1)
	{
		if(GetHP(c18)<3000||GetHP(c19)<3000||GetHP(c20)<3000||GetHP(c21)<3000)
		{
			PlayerPerform("say", "【失手伤人，警告一次！】");
		    PlayerPerform("pause", 1);
		    PlayerPerform("say", "【失手伤人，警告一次！】");
			hp1=GetHP(c18);
		    hp2=GetHP(c19);
		    hp3=GetHP(c20);
		    hp4=GetHP(c21);
		    qws=2;
		}
	}
	if(qws==2&&(GetHP(c18)<hp1||GetHP(c19)<hp2||GetHP(c20)<hp3||GetHP(c21)<hp4))
	{
		PlayerPerform("say", "【失手伤人，再次警告！】");
		PlayerPerform("pause", 1);
		PlayerPerform("say", "【失手伤人，再次警告！】");
        hp1=GetHP(c18);
		hp2=GetHP(c19);
		hp3=GetHP(c20);
		hp4=GetHP(c21);
		qws=3;
	}
	if(qws==3&&(GetHP(c18)<hp1||GetHP(c19)<hp2||GetHP(c20)<hp3||GetHP(c21)<hp4))
	{
		PlayerPerform("say", "【屡次伤人，违反规则，考试不合格！】");
		PlayerPerform("pause", 2);
		PlayerPerform("block", 1);
			
		ChangeBehavior(c21,"idle");
		ChangeBehavior(c20,"idle");
		ChangeBehavior(c19,"idle");
		ChangeBehavior(c18,"idle");
		qws=4;
        tws=now+4;
	}
	if(qws==4&&now>tws)
	{
		v=1;
	}
	if(qbg==1&&now>tbg)
	{
		PlayerPerform("say", "【还剩14分钟】。");
		qbg=2;
		tbg=now+60;
	}
	if(qbg==2&&now>tbg)
	{
		PlayerPerform("say", "【还剩13分钟】。");
		qbg=3;
		tbg=now+60;
	}
	if(qbg==3&&now>tbg)
	{
		PlayerPerform("say", "【还剩12分钟】。");
		qbg=4;
		tbg=now+60;
	}
	if(qbg==4&&now>tbg)
	{
		PlayerPerform("say", "【还剩11分钟】。");
		qbg=5;
		tbg=now+60;
	}
	if(qbg==5&&now>tbg)
	{
		PlayerPerform("say", "【还剩10分钟】。");
		qbg=6;
		tbg=now+60;
	}
	if(qbg==6&&now>tbg)
	{
		PlayerPerform("say", "【还剩9分钟】。");
		qbg=7;
		tbg=now+60;
	}
	if(qbg==7&&now>tbg)
	{
		PlayerPerform("say", "【还剩8分钟】。");
		qbg=8;
		tbg=now+60;
	}
	if(qbg==8&&now>tbg)
	{
		PlayerPerform("say", "【还剩7分钟】。");
		qbg=9;
		tbg=now+60;
	}
	if(qbg==9&&now>tbg)
	{
		PlayerPerform("say", "【还剩6分钟】。");
		qbg=10;
		tbg=now+60;
	}
	if(qbg==10&&now>tbg)
	{
		PlayerPerform("say", "【还剩5分钟】。");
		qbg=11;
		tbg=now+60;
	}
	if(qbg==11&&now>tbg)
	{
		PlayerPerform("say", "【还剩4分钟】。");
		qbg=12;
		tbg=now+60;
	}
	if(qbg==12&&now>tbg)
	{
		PlayerPerform("say", "【还剩3分钟】。");
		qbg=13;
		tbg=now+60;
	}
	if(qbg==13&&now>tbg)
	{
		PlayerPerform("say", "【还剩2分钟】。");
		qbg=14;
		tbg=now+60;
	}
	if(qbg==14&&now>tbg)
	{
		PlayerPerform("say", "【还剩1分钟】。");
		qbg=15;
		tbg=now+30;
	}
	if(qbg==15&&now>tbg)
	{
		PlayerPerform("say", "【还剩30秒】。");
		qbg=16;
		tbg=now+15;
	}
	if(qbg==16&&now>tbg)
	{
		PlayerPerform("say", "【还剩15秒】。");
		qbg=17;
		tbg=now+5;
	}
	if(qbg==17&&now>tbg)
	{
		PlayerPerform("say", "【还剩10秒】。");
		qbg=18;
		tbg=now+5;
	}
	if(qbg==18&&now>tbg)
	{
		PlayerPerform("say", "【还剩5秒】。");
		qbg=19;
		tbg=now+5;
	}
	if(qbg==19&&now>tbg)
	{
		PlayerPerform("say", "时间耗尽，任务失败！");
		PlayerPerform("say", "时间耗尽，任务失败！");
		qbg=20;
		tbg=now+3;
	}
	if(qbg==20&&now>tbg)
	{
		v=1;
	}
	
	if(qb==1&&GetHP(c24)<=0&&GetHP(c25)<=0&&GetHP(c26)<=0&&GetHP(c27)<=0&&GetHP(c28)<=0&&GetHP(c29)<=0&&GetHP(c30)<=0&&GetHP(c31)<=0&&GetHP(c32)<=0&&GetHP(c33)<=0&&GetHP(c34)<=0&&GetHP(c35)<=0)
	{
		qb=99;
		qbsj=99;
		qbfw=99;
		qws=99;
		q=24;
	}
	if(qbsj==1&&now>tbsj)
	{
		Perform(c14,"say", "【还剩80秒】！");
		qbsj=2;
		tbsj=now+10;
	}
	if(qbsj==2&&now>tbsj)
	{
		Perform(c14,"say", "【还剩70秒】！");
		qbsj=3;
		tbsj=now+10;
	}
	if(qbsj==3&&now>tbsj)
	{
		Perform(c14,"say", "【还剩60秒】！");
		qbsj=4;
		tbsj=now+10;
	}
	if(qbsj==4&&now>tbsj)
	{
		Perform(c14,"say", "【还剩50秒】！");
		qbsj=5;
		tbsj=now+10;
	}
	if(qbsj==5&&now>tbsj)
	{
		Perform(c14,"say", "【还剩40秒】！");
		qbsj=6;
		tbsj=now+10;
	}
	if(qbsj==6&&now>tbsj)
	{
		Perform(c14,"say", "【还剩30秒】！");
		qbsj=7;
		tbsj=now+10;
	}
	if(qbsj==7&&now>tbsj)
	{
		Perform(c14,"say", "【还剩20秒】！");
		qbsj=8;
		tbsj=now+10;
	}
	if(qbsj==8&&now>tbsj)
	{
		Perform(c14,"say", "【还剩10秒】！");
		qbsj=9;
		tbsj=now+5;
	}
	if(qbsj==9&&now>tbsj)
	{
		Perform(c14,"say", "【还剩5秒】！");
		qbsj=10;
		tbsj=now+5;
	}
	if(qbsj==10&&now>tbsj)
	{
		Perform(c14,"say", "时间到！考试不合格！请退场！");
		qbsj=11;
		tbsj=now+3;
	}
	if(qbsj==11&&now>tbsj)
	{
		v=1;
	}
	if(qbfw==1)
	{
		SetTarget(0, "waypoint", 58);
		SetTarget(1, "char", player);
		if (Distance(0, 1) >50)
		{
			Perform(c14,"say", "岳考生移动范围过大，考试不合格！请退场！");
			qbfw=2;
			tbfw=now+3;
		}
	}
	if(qbfw==2&&now>tbfw)
	{
		v=1;
	}
	if(v==0&&GetHP(player)==0)
	{
		PlayerPerform("say", "师父……徒儿学艺不精……甘领责罚！");
		v=1;
		t5=now+4;
	}
	if(v==0&&GetHP(c)==0)
	{
		Say(c, "岳大哥……我先走……一步了……");
		v=1;
		t5=now+3;
	}
	
	if(v==0&&GetHP(c2)==0)
	{
		Say(c2, "岳大哥……我……不行了……");
		v=1;t5=now+3;
	}
	
	if(v==0&&GetHP(c3)==0)
	{
		Say(c3, "岳大哥……给俺……报仇……");
		v=1;t5=now+3;
	}
	
    if(v==2&&now>=t5)
	{
		gameover = 1;
		
	}
	if(v==1&&now>=t5)
	{
		gameover = -1;
		
	}
	if ((gameover==1 || gameover==-1))
	{
		GameOver(gameover);
		gameover = 2;
	}
}


