// 最后一关
int Rule = 1;
int RoundTime = 990;
int PlayerSpawn = 141;
int PlayerSpawnDir = Rand(800);
int PlayerWeapon =10+Rand(10);
int PlayerWeapon2 =58;
int PlayerHP = 30000+5000;
int trg0;
int trg1;
int trg2; 
int trg3;
int trg4;
int trg5;
int trg6; 
int trg7;
int trg8;
int trg9;
int trg10; 
int trg11;//条件
int zjr;
int dy1;
int dy2;
int dy3;
int dy4;
int dy5;
int dy6;
int dy7;
int dy8;// 电脑代码
int c1;// 第2批 
int c2;
int c3;
int c4;
int c5;
int c6;
int c7;
int c8;
int san1;//第3批 
int san2;
int san3;
int san4;
int san5;
int wu1;//第5批 
int wu2;
int wu3;
int s1;
int s2;
int s3;// 死亡
int s4;
int s5;
int s6;// 死亡
int k1;
int k2;
int k3;
int k4;
int k5;
int k6;// 读写
int h1;
int h2;
int h3;// 2批命令
int gameover; // 胜利
int timer0;
int timer1;
int timer2;
int timer3;
int timer5;
OnStart()
{
	AddNPC("流星1"); 
               AddNPC("9关开场1");
               AddNPC("9关开场2");
               AddNPC("9关开场3");
               AddNPC("9关开场4");
               AddNPC("9关开场5");
               AddNPC("9关开场6");
               AddNPC("9关开场7");
               AddNPC("9关开场8");
}
OnUpdate()
{
	int player = GetAnyChar("player");
	if (player < 0)
	{
		return 0;
	}
	int now = GetGameTime();
if (now > timer5){PlayerPerform("use", 5);PlayerPerform("use", 8);PlayerPerform("use", 41);
PlayerPerform("use", 34);PlayerPerform("use", 19);timer5 = now + 30;} 
	if (trg0 == 0)
	{
		zjr = GetChar("『流星奇迹』_兵兵");
		SetTarget(0, "char", zjr);
		SetTarget(1, "char", player);
		if (GetHP(zjr) >0 && Distance(0, 1) < 300)
	         {
			    ChangeBehavior(zjr, "follow",  player);
				PlayerPerform("block", 0);
				PlayerPerform("say", "照办了！！");
				PlayerPerform("pause", 4);
				Perform(zjr, "say", "好了..不要说了，一起杀NPC（过瘾）");
				Perform(zjr, "pause", 1);
				Perform(zjr, "say", "用心！没有办不到的事情，知道吗/");
				Perform(zjr, "pause", 3);
				PlayerPerform("say", "可别这么说阿！！.我可不行哈哈哈！！你不帮我哪行阿");
				PlayerPerform("pause", 3);
				Perform(zjr, "say", "哈哈！真聪明哈！！");
				Perform(zjr, "pause", 2);
				PlayerPerform("say", "呵呵..我猜你也会来帮我的！前面只是试验我吧..");
				PlayerPerform("pause", 1);
				Perform(zjr, "say", "咱要并肩作战了！呵呵！！");
				Perform(zjr, "faceto", player);
				PlayerPerform("block", 1);
                                trg0++;
                                s1=0;
			        timer0 = now + 15; } }
if (zjr>=0 && GetHP(zjr)<GetMaxHP(zjr)/2 && s1==0){Perform(zjr, "say", "快来掩护我！");
Perform(zjr, "faceto", player);
PlayerPerform("say", "我马上去掩护！");
PlayerPerform("pause", 2);s1 = 1;}
if (GetHP(zjr) <= 0 && s1==1){
Say(zjr,"你真JB草蛋了！我不玩了..."); s1 = 2;}
 if ( trg0 == 1  && now > timer0)
        {
		dy1 = GetChar("终极杀手");
		dy2 = GetChar("职业杀手1");
		dy3 = GetChar("职业杀手2");
		dy4 = GetChar("职业杀手3");
		dy5 = GetChar("职业杀手4");
		dy6 = GetChar("骷颅头");
		dy7 = GetChar("骷颅1");
		dy8 = GetChar("骷颅2");
		if (dy1>=0)
		{
			Perform(dy1, "say", "还愣着干什么！快去巡逻一下！！");
			Perform(dy1, "pause", 2);
			Perform(dy1, "say", "我们第一次出面！！任务就是守住最后一关..");
			PlayerPerform("say", "出现了！");
			PlayerPerform("pause", 1);
                        trg0 = 2;h1 = 0;h2 = 0;} } 
if (dy1>=0 && GetHP(dy1)<GetMaxHP(dy1)/2 && h1==0)
	{	
			Perform(dy1, "say", "有两下子！！不过你死定了！！");
			Perform(dy1, "faceto", player);

			h1 = 1; }
if (GetHP(dy1) <= 0 && h1== 1)
{
			Say(dy1,"我怎么会败给你！...");
			ChangeBehavior(dy2, "follow",  player);
			ChangeBehavior(dy3, "follow",  player);
			ChangeBehavior(dy4, "follow",  player);
			ChangeBehavior(dy5, "follow",  player);
			ChangeBehavior(dy6, "follow",  player);
			ChangeBehavior(dy7, "follow",  player);
			ChangeBehavior(dy8, "follow",  player);
			h1 = 2; }
		if (dy2>=0 && GetEnemy(dy2)==player &&trg0 == 2)
		{
			ChangeBehavior(dy3, "follow", dy2);
			Perform(dy2, "say", "这小子在这，快来帮忙！");
			Perform(dy2, "faceto", player);
			trg0 = 3; }				
		if (dy7>=0 && GetEnemy(dy7)==player&& h2 == 0)
		{
			ChangeBehavior(dy8, "follow", dy7);
			Perform(dy7, "say", "这小子在这，快来帮忙！");
			Perform(dy7, "faceto", player);
			h2 = 1; }			
		if (dy1>=0 && GetEnemy(dy1)==player &&trg1 == 0)
		{
			ChangeBehavior(dy2, "follow", player);
			ChangeBehavior(dy3, "follow", player);
			ChangeBehavior(dy4, "follow", player);
			ChangeBehavior(dy5, "follow", zjr);
			Perform(dy1, "aggress");
			Perform(dy1, "say", "都给我过来杀了他！！");
			Perform(dy1, "faceto", player);		
	                trg1 = 1; }
		if (dy6>=0 && GetEnemy(dy6)==player &&trg2 == 0)
		{
			ChangeBehavior(dy7, "follow", player);
			ChangeBehavior(dy8, "follow", player);
			Perform(dy6, "aggress");
			Perform(dy6, "say", "初次见面！留下命来");
			Perform(dy6, "faceto", player);		
	                trg2 = 1; }
	        if (GetHP(dy6) <= 0 && trg2 == 1)
	        {
			Say(dy6,"怎么会这样！我一点不服！！...");
			ChangeBehavior(dy7, "follow", player);
			ChangeBehavior(dy8, "follow", player);
			trg2 = 2; }
if (GetHP(dy1)<=0 && GetHP(dy2)<=0 && GetHP(dy3)<=0 && GetHP(dy4)<=0 &&  GetHP(dy5)<=0 &&  GetHP(dy6)<=0 &&  GetHP(dy7)<=0 && GetHP(dy8)<=0 && player>=0 && GetHP(player)>0 && trg2 == 2)
	        {
		        RemoveNPC(dy1);
		        RemoveNPC(dy2);
		        RemoveNPC(dy3);
		        RemoveNPC(dy4);
		        RemoveNPC(dy5);
		        RemoveNPC(dy6);
		        RemoveNPC(dy7);
		        RemoveNPC(dy8);
			trg2 = 3;// 完毕
		        timer0 = now + 10;  }
	 if (trg2 == 3  && now > timer0) // 第2批
	 {
               AddNPC("9关2次1");
               AddNPC("9关2次2");
               AddNPC("9关2次3");
               AddNPC("9关2次4");
               AddNPC("9关2次5");
               AddNPC("9关2次6");
               AddNPC("9关2次7");
               AddNPC("9关2次8");
		trg2 = 4; }
        if ( trg3 == 0)
        {
		c1 = GetChar("归海一刀");
		c2 = GetChar("灵魂1");
		c3 = GetChar("灵魂2");
		c4 = GetChar("灵魂3");
		c5 = GetChar("灵魂4");
		c6 = GetChar("灵魂5");
		c7 = GetChar("灵魂6");
		c8 = GetChar("灵魂7");
		if (c1>=0)
		{
			Perform(zjr, "use", 15);
			Perform(zjr, "use", 15);
			Perform(zjr, "use", 15);
			Perform(zjr, "use", 20);
			Perform(zjr, "say", "今天就让本公子修理你们！！");
			Perform(zjr, "pause", 4);
			Perform(c2, "say", "是!属下马上去查这小子在哪??");
			Perform(c2, "pause", 2);
			Perform(c1, "say", "还不快去");
			Perform(c1, "pause", 2);
			Perform(c1, "say", "妈的...把这家伙给我剁成包子吃了.");
			PlayerPerform("say", "我自己去找你们...哼!!");
			PlayerPerform("pause", 3);
			PlayerPerform("say", "靠!!");
			PlayerPerform("pause", 1);
		        trg3 = 1; h1=0;} }
       if (c2>=0 && GetEnemy(c2)==player &&trg3 == 1)
		{
			ChangeBehavior(c1, "follow",  player);
			ChangeBehavior(c2, "follow",  player);
			Perform(c2, "say", " 阿！老大..老大！发现这家伙了");
			Perform(c2, "faceto", player);
			trg3 = 2; }
	if (c1>=0 && GetEnemy(c1)==player &&h1 == 0)
	{
			ChangeBehavior(c1, "follow",  player);
			ChangeBehavior(c2, "follow",  player);
			ChangeBehavior(c3, "follow",  player);
			ChangeBehavior(c4, "follow",  player);
			ChangeBehavior(c5, "follow",  player);
			ChangeBehavior(c6, "follow",  player);
			ChangeBehavior(c7, "follow",  player);
			ChangeBehavior(c8, "follow",  player);
			Perform(c1, "say", " 小子们.干掉他！！.");
			Perform(c1, "faceto", player);
			Perform(c1, "say", " 妈的.可让我找到你了..");
			Perform(c1, "faceto", player);
			h1 = 1;}
	        if (GetHP(c1) <= 0 && h1 == 1)
	        {
			Say(c1,"还会有很多的！...");
			h1 = 2; }
if (GetHP(c1)<=0 && GetHP(c2)<=0 && GetHP(c3)<=0 && GetHP(c4)<=0 &&  GetHP(c5)<=0 &&  GetHP(c6)<=0 &&  GetHP(c7)<=0 && GetHP(c8)<=0 && player>=0 && GetHP(player)>0 && trg3 == 2)
	        {  RemoveNPC(c1);
		   RemoveNPC(c2);
		        RemoveNPC(c3);
		        RemoveNPC(c4);
		        RemoveNPC(c5);
		        RemoveNPC(c6);
		        RemoveNPC(c7);
		        RemoveNPC(c8);
			trg3 = 3;
		        timer0 = now + 10; } 
	 if (trg3 == 3  && now > timer0) // 第2批完毕
	 {
               AddNPC("9关3次1");
               AddNPC("9关3次2");
               AddNPC("9关3次3");
               AddNPC("9关3次4");
               AddNPC("9关3次5");
	trg3 = 4; }
        if (trg4 == 0 )
        {
		san1 = GetChar("修罗女刹");
		san2 = GetChar("修罗女刹1");
		san3 = GetChar("修罗女刹2");
		san4 = GetChar("修罗女刹3");
		san5 = GetChar("修罗女刹4");
		if (san1>=0)
		{
			Perform(zjr, "use", 15);
			Perform(zjr, "use", 15);
			Perform(zjr, "use", 15);
			Perform(zjr, "use", 20);
			PlayerPerform("say", "哈哈！！！");
			PlayerPerform("pause", 4);
			Perform(zjr, "say", "这次的是妞O！下手要温柔点...");
			Perform(zjr, "pause", 4);
			Perform(san2, "say", "OK！！");
			Perform(san2, "pause", 2);
			Perform(san1, "say", "你们都给我看好点.看见那家伙，立即回报");
			PlayerPerform("say", "女人！！！");
			PlayerPerform("pause", 3);
		        trg4++;} } 
		SetTarget(0, "char",player);
		SetTarget(1, "char",san2);
		if (GetEnemy(san2) == player)
		{
			if (Distance(0, 1) < 500 && k1 == 0)
			{
	                   Perform(san2, "guard", 3);
			   ChangeBehavior(san3, "follow",  player);
			   ChangeBehavior(san4, "follow",  player);
			   Perform(san2, "say", "嘿嘿！终于见面了");
			   Perform(san2, "faceto", player);
			   k1++;}}
		SetTarget(0, "char",player);
		SetTarget(1, "char",san3);
		if (GetEnemy(san3) == player)
		{
			if (Distance(0, 1) < 500 && k2 == 0)
			{
	                   Perform(san3, "guard", 3);
			   ChangeBehavior(san2, "follow",  player);
			   ChangeBehavior(san4, "follow",  player);
			   Perform(san3, "say", "嘿嘿！终于见面了");
			   Perform(san3, "faceto", player);
			   k2++;}}	
		SetTarget(0, "char",player);
		SetTarget(1, "char",san1);
		if (GetEnemy(san1) == player)
		{
			if (Distance(0, 1) < 500 && k3 == 0)
			{
	                   Perform(san1, "guard", 3);
			   ChangeBehavior(san1, "follow",  player);
			   ChangeBehavior(san2, "follow",  player);
			   ChangeBehavior(san3, "follow",  player);
			   ChangeBehavior(san4, "follow",  player);
			   ChangeBehavior(san5, "follow",  player);
			   Perform(san1, "say", "你这小帅哥！终于看到的了！美女们！强奸他...");
			   Perform(san1, "faceto", player);
			   k3++;s1=0;}}
	        if (GetHP(san1) <= 0 && s1 == 0)
	        {
			Say(san1,"呵呵！我虽然死在你的手下，但是我很高兴！...");
			s1 = 1;}
if (GetHP(san1)<=0 && GetHP(san2)<=0 && GetHP(san3)<=0 && GetHP(san4)<=0 && GetHP(san5)<=0 && player>=0 && GetHP(player)>0 && trg4 == 1)
	        {       RemoveNPC(san1);
		        RemoveNPC(san2);
		        RemoveNPC(san3);
		        RemoveNPC(san4);
		        RemoveNPC(san5);
			trg4++;
		        timer0 = now + 10; } 

if (trg4 == 2  && now > timer0) // 第3批完毕
{
AddNPC("9关1");
Say(zjr,"你挺厉害的！竟能闯到这里，眼看就要结束了。我先撤了..");
trg4++;
timer1 = now + 5;}
if (trg4 == 3  && now > timer1) // 兵兵离开
{
RemoveNPC(zjr);
trg4++;}
if (trg5 == 0 ){wu1 = GetChar("关尾人");SetTarget(0, "char",player);SetTarget(1, "char",wu1);if (GetEnemy(wu1) == player){if (Distance(0, 1) < 200){		
ChangeBehavior(wu1, "follow",  player);
PlayerPerform("say", "那就先收拾你！！");
PlayerPerform("pause", 4);
Perform(wu1, "say", "多说无益..受死吧。。");
Perform(wu1, "pause", 1);
Perform(wu1, "say", "夸你两句，你就以为不是你了，想见BOSS还早着呢。");
Perform(wu1, "pause", 3);
PlayerPerform("say", "可别这么说阿！你怎么知道呢。");
PlayerPerform("pause", 3);
Perform(wu1, "say", "即使我不是！！你也休想打败我。。。");
Perform(wu1, "pause", 2);
PlayerPerform("say", "过奖！想必你不是最终BOSS.肯定还是另有其人吧.");
PlayerPerform("pause", 1);
Perform(wu1, "say", "原来你就是伊人君！不愧是杀手。果然是厉害！");
Perform(wu1, "faceto", player);
PlayerPerform("block", 1);trg5++;}}}
if (wu1>=0 && GetHP(wu1)<GetMaxHP(wu1)/2 && trg5 == 1){Perform(wu1,"use",15);Perform(wu1,"use",15);
Perform(wu1, "say", "妈的！真是把你老子惹怒了！");
Perform(wu1, "faceto", player);trg5++;}
if(GetHP(wu1) <= 0  && trg5 == 2){
Say(wu1,"  哈哈。你以为杀死我就没事了吗？？");
RemoveNPC(wu1);AddNPC("bing");trg5++;}
if (trg6 == 0 ){wu2 = GetChar("终极BOSS（狂风）");
SetTarget(0, "char",player);SetTarget(1, "char",wu2);
if (GetEnemy(wu2) == player){if (Distance(0, 1) < 200){
ChangeBehavior(wu2, "follow",  player);
PlayerPerform("say", "这是当然的！作弊是孙子！多谢你帮我恢复！");
PlayerPerform("pause", 8);
PlayerPerform("block", 1);
Perform(wu2, "aggress");
Perform(wu2, "say", "你的真气已经恢复！！就跟我公平的打一场吧！！");
Perform(wu2, "pause", 6);
PlayerPerform("use", 15);
PlayerPerform("use", 15);
PlayerPerform("use", 15);
PlayerPerform("use", 15);
PlayerPerform("say", "这是当然的！领教了！我很想看看你有多厉害！");
PlayerPerform("pause", 6);
PlayerPerform("block", 1);
Perform(wu2, "aggress");
Perform(wu2, "say", "有志气。！！！果真不愧为伊人君！");
Perform(wu2, "pause", 6);
PlayerPerform("say", "我绝对不会作弊。作弊是孙子！！全中国人鄙视！");
PlayerPerform("pause", 5);
PlayerPerform("block", 1);
Perform(wu2, "say", "我在告诉你一次，请你不要作弊，公平的给我打，看是不是我的对手。");
Perform(wu2, "pause", 4);
PlayerPerform("say", "哦，原来是这样，我不会作弊的，我也想看看把你研究的有多厉害。");
PlayerPerform("pause", 4);
PlayerPerform("block", 1);
Perform(wu2, "say", "我是兵兵精心研究的（NPC）论PK。。看你是不是我的对手。");
Perform(wu2, "pause", 1);
Perform(wu2, "say", "如果你现在作弊了。请你先把（外挂）关掉，公平的跟我来一场..");
Perform(wu2, "pause", 3);
PlayerPerform("say", "说什么..快说！");
PlayerPerform("pause", 3);
PlayerPerform("block", 1);
Perform(wu2, "say", "你怎么知道你就能打的过我。。先听我说。");
Perform(wu2, "pause", 2);
PlayerPerform("say", "哼.我不想跟垃圾的人打，浪费。。滚开。");
PlayerPerform("pause", 1);
PlayerPerform("block", 1);
Perform(wu2, "say", "呵呵！我也不是老大！不过我是你的对手。");
Perform(wu2, "faceto", player);
PlayerPerform("block", 1);trg6++;}}}
if (wu2>=0 && GetHP(wu2)<GetMaxHP(wu2)/2 && trg6 == 1){Perform(wu2,"use",15);Perform(wu2,"use",15);
Perform(wu2, "say", "不许作弊！");
Perform(wu2, "faceto", player);trg6++;}
if(GetHP(wu2) <= 0  && trg6 == 2){
Say(wu2,"  是人都知道你是怎么杀死我的，既然这样，那就让你跟最终的BOSS决斗吧！！");
RemoveNPC(wu2);AddNPC("zhongji");trg6++;}
if (trg7 == 0 ){wu3 = GetChar("终极BOSS+终极NPC");
SetTarget(0, "char",player);SetTarget(1, "char",wu3);
if (GetEnemy(wu3) == player){if (Distance(0, 1) < 200){
PlayerPerform("say", "------兵兵提示：如果现在你还杀不死他！那就证明你不是他的对手！觉悟吧！");
PlayerPerform("use", 15);
PlayerPerform("use", 15);
PlayerPerform("use", 34);
PlayerPerform("use", 40);
PlayerPerform("pause", 100);
PlayerPerform("use", 15);
PlayerPerform("use", 15);
PlayerPerform("pause", 100);
PlayerPerform("say", "------兵兵提示：这NPC是厉害！但是给自己设定了加血，请自己保持要公平！");
PlayerPerform("use", 15);
PlayerPerform("use", 15);
PlayerPerform("pause", 50);
ChangeBehavior(wu3, "follow",  player);
PlayerPerform("say", "那请您先出招吧！！");
PlayerPerform("pause", 8);
PlayerPerform("block", 1);
Perform(wu3, "aggress");
Perform(wu3, "pause", 2);
Perform(wu3, "say", "现在可以开始了！不过要让我先动手。因为我是NPC");
Perform(wu3, "pause", 6);
PlayerPerform("use", 15);
PlayerPerform("use", 15);
PlayerPerform("use", 15);
PlayerPerform("use", 15);
PlayerPerform("say", "哦！哈哈！多谢了！");
PlayerPerform("pause", 6);
PlayerPerform("block", 1);
Perform(wu3, "aggress");
Perform(wu3, "say", "有志气。！！！果真不愧为伊人君！公平来一场..我帮你加血");
Perform(wu3, "pause", 6);
PlayerPerform("say", "哦！这样好说，如果打不赢你我会一直闯这关！一直到胜利为止！");
PlayerPerform("pause", 5);
PlayerPerform("block", 1);
Perform(wu3, "say", "如果你打赢我了。裁图下来，发到兵兵的邮箱里。让他看一下他做的NPC有多么的笨。");
Perform(wu3, "pause", 4);
PlayerPerform("say", "这是当然的。放心吧..我绝对尊重你，作弊的是孙子。");
PlayerPerform("pause", 4);
PlayerPerform("block", 1);
Perform(wu3, "say", "兵兵把我研究出来。就是为了刺激。我毕竟是电脑。请你尊重一下");
Perform(wu3, "pause", 1);
Perform(wu3, "say", "好。.只要你把外挂关掉能跟我交手，我也不胜感激，玩的是刺激，你作弊还有什么意思。");
Perform(wu3, "pause", 3);
PlayerPerform("say", "是关于作弊的事情对不对！放心。绝对是公平竞争！");
PlayerPerform("pause", 3);
PlayerPerform("block", 1);
Perform(wu3, "say", "呵呵。好眼力，我先自我介绍一下，我是（兵兵）费心研究的，请你尊重一点。");
Perform(wu3, "pause", 2);
PlayerPerform("say", "哦！！。看上去也非常的像！本身就带一股煞气。");
PlayerPerform("pause", 1);
PlayerPerform("block", 1);
Perform(wu3, "say", "你行阿。没想到你能活着见到我，好样的！我就是结束游戏的人。");
Perform(wu3, "faceto", player);
PlayerPerform("block", 1);trg7++;}}}
if (wu3>=0 && GetHP(wu3)<GetMaxHP(wu3)/2 && trg7 == 1)
{Perform(wu3, "say", "不许作弊！作弊遭雷劈.");trg7++;}
if (trg7==2){if (GetHP(wu3) <=0 && gameover != 1)
{Say(wu3,"你是怎么打赢我的！告诉兵兵（QQ765739946）");
gameover = 1;timer1 = now + 5;trg7++;}}
if (trg8 == 0){if (GetHP(player)<GetMaxHP(player)/10){ PlayerPerform("use", 35);PlayerPerform("pause", 3);
PlayerPerform("say", "------兵兵提示：你不行了！重新来吧！");trg8++;}}
if (gameover!=-1 && GetHP(player)<=0 && player > 0){
gameover = -1;timer1 = now + 2; }
if ((gameover==1 || gameover==-1) && now>timer1){
GameOver(gameover);gameover = 2;}}