// 金华城
int Rule = 1;
int RoundTime = 990;
int PlayerSpawn = 250;
int PlayerSpawnDir = Rand(200);
int PlayerWeapon = Rand(20);
int PlayerWeapon2 = 14;
int PlayerHP = 15000;


int player;
int trg0;
int trg1;
int trg2;
int k1;
int k2;
int k3;
int k4;
int k5;
int k6;
int k7;
int k8;
int k9;
int k10;
int win;
int timer0;
int timer1;
int timer2;
int timer3;
int gameover; 

OnStart()
{
	AddNPC("6关剑客1"); 
	AddNPC("6关剑客2");
	AddNPC("6关剑客3"); 
	AddNPC("6关剑客4");
	AddNPC("6关剑客5");  
}

OnUpdate()
{
	int player = GetAnyChar("player");
	if (player < 0)
	{
		return 0;
	}
	if (gameover == 2)
	{
		return 0;
	}
	int now = GetGameTime();

	if (trg0 == 0 && k1 ==0)
	{
		int c = GetChar("魔刀狂人");
		int c1 = GetChar("金华剑客1");
		int c2 = GetChar("金华剑客2");
		int c3 = GetChar("金华剑客3");
		int c4 = GetChar("金华剑客4");
		if (c1 > 0 )
		{		
                                ChangeBehavior(c1, "follow", player);
			        Perform(c1, "aggress");
			        Perform(c1, "say", "哼！看谁上西天吧！！");
			        Perform(c1, "guard", 6);	
			        Perform(c1, "say", "哈哈！！金华可不是好闯的..你死定了！！");
			        Perform(c1, "guard", 4);
                                Perform(c1, "say", "真没想到你能闯入这里！真是不简单");
				Perform(c1, "faceto", player);

                                ChangeBehavior(c2, "follow", player);
			        Perform(c2, "aggress");
			        Perform(c2, "pause", 12);
				Perform(c2, "faceto", player);

                                ChangeBehavior(c3, "follow", player);
			        Perform(c3, "aggress");
			        Perform(c3, "pause", 12);
				Perform(c3, "faceto", player);


                                ChangeBehavior(c4, "follow", player);
			        Perform(c4, "aggress");
			        Perform(c4, "pause", 12);
				Perform(c4, "faceto", player);

				PlayerPerform("block", 0);
			        PlayerPerform("say", "那我就送你上西天！！");
			        PlayerPerform("pause", 5);
			        PlayerPerform("say", "我不是说过！伊人君做事很利索，你们要是不想死就让开！！");
			        PlayerPerform("pause", 2);
				PlayerPerform("block", 1);
			        trg0 = 1;
			        k1 = 1;
		                }				
                       }
		      if (GetHP(c1) <= 0 && k1 ==1)
		       {
                                ChangeBehavior(c2, "follow", c);
                                ChangeBehavior(c3, "follow", c);
                                ChangeBehavior(c4, "follow", c);
                                Perform(c2, "say", "你等着..");
				Perform(c2, "faceto", player);
                                Perform(c3, "say", "你给我等着....");
				Perform(c3, "faceto", player);
                                Perform(c4, "say", "你等着..一会有你好戏看了..");
				Perform(c4, "faceto", player);
		                RemoveNPC(c1);
			        k1 = 2;
                                }

		SetTarget(0, "char", c2);
		SetTarget(1, "char", c);
		if (c2>=0 &&Distance(0, 1) < 150 && k1 ==2)
		{


                        ChangeBehavior(c2, "follow", c);
                        ChangeBehavior(c3, "follow", c);
                        ChangeBehavior(c4, "follow", c);
			Perform(c2, "say", "是！！");
			Perform(c2, "pause", 4);
			Perform(c2, "say", "老大！发现那个家伙了，但是他好厉害！我大哥已经死在他的手里。");
			Perform(c2, "faceto", c);
			Perform(c3, "say", " 发现那个家伙了。");
			Perform(c3, "faceto", c);
			Perform(c4, "say", "老大！发现那个家伙了..");
			Perform(c4, "faceto", c);

			ChangeBehavior(c, "follow", player);
			Perform(c, "say", "他妈的。所有人都给我一起上！！老子就不信他有多厉害。");
			Perform(c, "pause", 3);
			Perform(c, "faceto", c);
		        k1 = 3;
                        }

		SetTarget(0, "char",player);
		SetTarget(1, "char",c);
		if (GetEnemy(c) == player)
		{
			if (Distance(0, 1) < 200 && k2 == 0)
			{
                                ChangeBehavior(c1, "follow", c);
                                ChangeBehavior(c2, "follow", c);
                                ChangeBehavior(c3, "follow", c);
                                ChangeBehavior(c4, "follow", c);
				Perform(c, "say", "纳命来吧！！大家一起上吧！！哈哈。");
				Perform(c, "pause", 5);
				Perform(c, "say", "你竟敢瞧不起我！让你尝尝我的厉害！！");
				Perform(c, "pause", 3);
				Perform(c, "faceto", player);



				PlayerPerform("block", 0);
				PlayerPerform("pause", 3);
				PlayerPerform("say", "我看看你有多厉害！！");
				PlayerPerform("pause", 5);
				PlayerPerform("say", "魔刀？哼..不可取！！");
				PlayerPerform("block", 1);
				k2 = 1;
			}
		}

		if(GetHP(c) <= 5000 && k2 == 1)
		{
				Perform(c, "use", 15);
				Perform(c, "use", 15);
				Perform(c, "use", 15);
				Perform(c, "use", 15);
				Perform(c, "say", "哈哈！！你怎么可能是魔刀的对手！！");
				Perform(c, "faceto", player);


				PlayerPerform("block", 0);
			       PlayerPerform("use", 15);
			        PlayerPerform("use", 15);
				PlayerPerform("say", "怎么可能不是？就你这点功夫，受死！！");
				PlayerPerform("pause", 3);
				PlayerPerform("block", 1);
				k2 = 2;
			}
		if(GetHP(c) <= 0 && k2 == 2)
		{
		        RemoveNPC(c);
		        RemoveNPC(c1);
		        RemoveNPC(c2);
		        RemoveNPC(c3);
		        RemoveNPC(c4);
			Say(c,"可恶....我不甘...心...啊！！");
			k2 = 3;
			win++;
			}
              if (k2 ==3 && trg1 == 0)
              {

		     AddNPC("5关");
		     trg1 = 1;
		     }

                if (trg1 == 1)
                {
		   c = GetChar("光明顶长官");
                   SetTarget(0, "char",player);
		   SetTarget(1, "char",c);
		   if (GetEnemy(c) == player)
		   {
			if (Distance(0, 1) < 200 && k3 == 0)
			{
                                ChangeBehavior(c, "follow", player);
				Perform(c, "say", "哈哈！！我永远是你的对手！！（孙剑）这个人物！！");
				Perform(c, "pause", 5);
				Perform(c, "say", "挺聪明的吗！！哈哈！！怎么怕了？");
				Perform(c, "pause", 3);
				Perform(c, "faceto", player);


			PlayerPerform("use", 15);
				PlayerPerform("block", 0);
				PlayerPerform("pause", 3);
				PlayerPerform("say", "怕你就不是好汗！！");
				PlayerPerform("pause", 5);
				PlayerPerform("say", "我们又见面了是不是！！");
				PlayerPerform("block", 1);
				k3 = 1;
			}
		}
	}
	if(GetHP(c) <= 10000 && k3 == 1)
	{

				Perform(c, "use", 15);
				Perform(c, "use", 15);
				Perform(c, "use", 15);
				Perform(c, "use", 15);
				Perform(c, "use", 20);
				Perform(c, "say", "哈哈！！这次我不会失败了哦！");
				Perform(c, "faceto", player);
		        AddNPC("6关1");
		        AddNPC("6关2");
		        AddNPC("6关3");
		        AddNPC("6关4");
		        AddNPC("6关5");
		        AddNPC("6关6");


				PlayerPerform("block", 0);
				PlayerPerform("say", " 受死！！");
				PlayerPerform("pause", 3);
				PlayerPerform("block", 1);
				k3 = 2;
			        }
	if(GetHP(c) <= 0 && k3 == 2)
	{
			Say(c," 可恶....始终败给了你！！");
                        Say(player,"哼！！");
			gameover = 1;
			k3 = 3;
			}


              if (trg2 == 0)
              {
		int c5 = GetChar("指虎王1");
		int c6 = GetChar("指虎王2");
		int c7 = GetChar("乾坤王1");
		int c8 = GetChar("乾坤王2");
		int c9 = GetChar("怒忍王1");
		int c10 = GetChar("怒忍王2");
		if (c5 > 0 && c6 > 0)
		{

			ChangeBehavior(c5, "follow", player);
			ChangeBehavior(c6, "follow", player);
			ChangeBehavior(c7, "follow", player);
			ChangeBehavior(c8, "follow", player);
			ChangeBehavior(c9, "follow", player);
			ChangeBehavior(c10, "follow", player);

				Perform(c, "use", 15);
				Perform(c, "use", 15);
				Perform(c, "use", 15);
				Perform(c, "use", 20);
			       PlayerPerform("use", 15);
			        PlayerPerform("use", 15);
			       PlayerPerform("use", 15);
			        PlayerPerform("use", 15);
			Perform(c5, "say", "好样的！！....");


			trg2 = 1;
		   }
                }
		if (c5>=0 && GetEnemy(c5)==player && k4 == 0)
		{



				Perform(c5, "say", "看到底谁死吧！");
				Perform(c5, "pause", 3);
				Perform(c5, "faceto", player);

				PlayerPerform("block", 0);
				PlayerPerform("say", "又来了几个找死的...");
				PlayerPerform("block", 1);
				
				k4 = 1;
			}
	if(GetHP(c5) <= 0 && k4 == 1)
	{
			Say(c5,"  可恶.  啊！第一次失败阿。");
			k4 = 2;
			win++;
                 }
		if (now > timer2)
		{
			PlayerPerform("use", 5);
			PlayerPerform("use", 8);
			PlayerPerform("use", 41);
			timer2 = now + 30; 
		} 
	if (gameover!=-1 && GetHP(player)<=0 )
	{
		gameover = -1;
		timer1 = now + 2; 
	}
	if ((gameover==1 || gameover==-1) && now>timer1)
	{
		GameOver(gameover);
		gameover = 2;
	}

}