// 皇天城
int Rule = 1;
int RoundTime = 99;
int PlayerSpawn = 83;
int PlayerSpawnDir = 80;
int PlayerWeapon = 15;
int PlayerWeapon2 = 50;
int PlayerHP = 25000;

int trg0 = 0;
int trg1 = 0;
int trg2 = 0;
int trg3 = 0;
int trg4 = 0;
int trg5 = 0;
int trg6 = 0;
int trg7 = 0;
int trg8 = 0;
int trg9 = 0;
int trg10 = 0;
int trg11 = 0;
int timer0 = 0;
int timer1 = 0;
int timer2 = 0;
int timer3 = 0;
int timer4 = 0;
int timer5 = 0;
int timer6 = 0;
int timer7 = 0;
int timer8 = 0;
int gameover = 0;
int reborn = -1;
string rebornName;

OnStart()
{
	AddNPC("npc05_01");
	AddNPC("npc05_02");
	AddNPC("npc05_03");
	AddNPC("npc05_04");
	AddNPC("npc05_05");
	AddNPC("npc05_06");
	AddNPC("npc05_07");
	AddNPC("npc05_08");
}
OnUpdate()
{
	int player = GetChar("player");
	if (player < 0)
	{
		return 0;
	}
	
	int c;
	int c1;
	int c2;
	int c3;
	int c4;
	int c5;
	int c6;
	int c7;
	int c8;
	int c9;
	int c10;
	int c11;
	int c12;
	int c13;
	int c14;
	int c15;
	int now = GetGameTime();
	
	if (trg0 == 0)
	{
		
		c = GetChar("黄天城队长");
		if (c>=0 && GetHP(player)>0)
		{

	
			PlayerPerform("block", 0);
			PlayerPerform("use", 4);
			PlayerPerform("use", 5);
			PlayerPerform("say", "（﹒。。。。﹒﹒我要小心应付。。）");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "（黄天城，这里可能都是孙剑身边的高手。）");
			PlayerPerform("pause", 1);
			PlayerPerform("say", "（终于来到这了。看来杀孙剑指日可待了。）");
			PlayerPerform("block", 1);
			
			trg0 = 1;
		}
	
	}
    if (trg0 == 1)
	{	
		c = GetChar("黄天城队长");
		c2 = GetChar("黄天城守卫1");
		c3 = GetChar("黄天城守卫2");
		c4 = GetChar("黄天城守卫3");
		c5 = GetChar("黄天城守卫4");
		c6 = GetChar("黄天城守卫5");
		c7 = GetChar("黄天城守卫6");
		c8 = GetChar("黄天城守卫7");
		if (c>=0)

                   {     
                     ChangeBehavior(c,"follow",player);
                        Perform(c, "say", "兄弟们，一起杀吧。。");
			Perform(c, "pause", 5);
			Perform(c, "say", "奉命行事，那就看我的刀剑同意不同意了。");
			Perform(c, "pause", 3);
			Perform(c, "say", "哼，我不会对你客气的。别以为黄天城的人都不可取..");
			Perform(c, "pause", 3);
			Perform(c, "say", "原来就是你想杀孙堂主。");
			Perform(c, "faceto", player);

                     ChangeBehavior(c2,"follow",player);
			        Perform(c2, "say", "是！");
				Perform(c2, "guard", 16);
				Perform(c2, "faceto", player);

                     ChangeBehavior(c3,"follow",player);
			        Perform(c3, "say", "是！");
				Perform(c3, "guard", 16);
				Perform(c3, "faceto", player);


                     ChangeBehavior(c4,"follow",player);
			Perform(c4, "say", "是！");
				Perform(c4, "guard", 16);
				Perform(c4, "faceto", player);


                     ChangeBehavior(c5,"follow",player);
			Perform(c5, "say", "是！");
				Perform(c5, "guard", 16);
				Perform(c5, "faceto", player);


                     ChangeBehavior(c6,"follow",player);
			Perform(c6, "say", "是！");
				Perform(c6, "guard", 16);
				Perform(c6, "faceto", player);


                     ChangeBehavior(c7,"follow",player);
			Perform(c7, "say", "是！");
				Perform(c7, "guard", 16);
				Perform(c7, "faceto", player);


                     ChangeBehavior(c8,"follow",player);
			Perform(c8, "say", "是！");
				Perform(c8, "guard", 16);
				Perform(c8, "faceto", player);

                     ChangeBehavior(c9,"follow",player);
			Perform(c9, "say", "是！");
				Perform(c9, "guard", 16);
				Perform(c9, "faceto", player);


			PlayerPerform("say", "那你们就一起上把。。");
			PlayerPerform("pause", 8);
			PlayerPerform("say", "那在下就不客气了。。");
			PlayerPerform("pause", 3);
			PlayerPerform("say", "我知道你们厉害，但是我只是奉命行事。。？");
			PlayerPerform("pause", 3);
			PlayerPerform("say", "哈，我要从这过去，请你们让开。");
			PlayerPerform("pause", 2);
			PlayerPerform("block", 1);
			
			trg0 = 2;
		}
	}


   if (trg0 == 2)
	{	
		c3 = GetChar("黄天城队长");
		c4 = GetChar("黄天城守卫1");
		c5 = GetChar("黄天城守卫2");
		c6 = GetChar("黄天城守卫3");
		c7 = GetChar("黄天城守卫4");
		c8 = GetChar("黄天城守卫5");
		c9 = GetChar("黄天城守卫6");
		c10 = GetChar("黄天城守卫7");

		if (GetHP(c3)<=0 && GetHP(c4)<=0 && GetHP(c5)<=0 && GetHP(c6)<=0 && GetHP(c7)<=0 && GetHP(c8)<=0 && GetHP(c9)<=0 && GetHP(c10)<=0 && player>=0 && GetHP(player)>0)
		{
			PlayerPerform("say", "他们都是条汉子，但是跟错了主人。");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "黄天城守卫.");


			timer0 = now + 6;
			trg0 = 3;
		}

      }
 if (trg0 == 3 && now>timer0)
	{
	AddNPC("npc05_09");
	AddNPC("npc05_10");
	AddNPC("npc05_11");
	AddNPC("npc05_12");
	AddNPC("npc05_13");
	AddNPC("npc05_14");
		RemoveNPC(GetAnyChar("黄天城队长"));
                RemoveNPC(GetAnyChar("黄天城守卫1"));
		RemoveNPC(GetAnyChar("黄天城守卫2"));
                RemoveNPC(GetAnyChar("黄天城守卫3"));
		RemoveNPC(GetAnyChar("黄天城守卫4"));
                RemoveNPC(GetAnyChar("黄天城守卫5"));
		RemoveNPC(GetAnyChar("黄天城守卫6"));
                RemoveNPC(GetAnyChar("黄天城守卫7"));
		trg0 = 4;
	}

  if (trg0==4)
	{
		c = GetChar("黄天城首领");
		c2 = GetChar("火炮兵1");
		c3 = GetChar("火炮兵2");
		c4 = GetChar("火炮兵3");
                c5 = GetChar("火炮兵4");
                c6 = GetChar("火炮兵5");
		SetTarget(0, "char", c);
		SetTarget(1, "char", player);
		if (c>=0 && GetEnemy(c)==player && Distance(0, 1)<200)
		{
                     ChangeBehavior(c,"follow",player);
			Perform(c, "pause", 3);
                 	Perform(c, "say", "。一起杀了他。！");
                        Perform(c, "faceto", player);
			Perform(c, "say", "我们终于能和你交手了，为什么要让开。。");
			Perform(c, "pause", 2);
			Perform(c, "say", "你真是厉害阿，？");
			Perform(c, "faceto", player);
			
                     ChangeBehavior(c2,"follow",player);
			Perform(c2, "say", "是！");
			Perform(c2, "pause", 8);
			Perform(c2, "faceto", player);
			
                     ChangeBehavior(c3,"follow",player);
			Perform(c3, "say", "是！");
			Perform(c3, "pause", 8);
			Perform(c3, "faceto", player);

                     ChangeBehavior(c4,"follow",player);
			Perform(c4, "say", "是！");
			Perform(c4, "pause", 8);
			Perform(c4, "faceto", player);

                     ChangeBehavior(c5,"follow",player);
			Perform(c5, "say", "是。。！");
			Perform(c5, "pause", 8);
			Perform(c5, "faceto", player);


                     ChangeBehavior(c6,"follow",player);
			Perform(c6, "say", "是！");
			Perform(c6, "pause", 8);
			Perform(c6, "faceto", player);

			
			PlayerPerform("use", 15);			
			PlayerPerform("say", "那我就不客气了，是你们自己找死。");
			PlayerPerform("pause", 9);			
			PlayerPerform("say", "我不想杀你们，请你们让开");
			PlayerPerform("pause", 2);			
			PlayerPerform("block", 1);
			trg0 = 5; 			
		}		
	}


	if (trg0 == 5)
	{
		c = GetAnyChar("黄天城首领");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "say", "你这小子还真有两下子..");
			trg0 = 6;
		}
	}


	if (trg0 == 6)
	{
		c = GetAnyChar("黄天城首领");
		if (GetHP(c) <= 0)
		{
			Say(c, "我，死不瞑目阿。。老大，剩下的。小子帮不了了。");
			trg0 = 7;
		}
	}


        if (trg0 == 7)
	{
		c = GetAnyChar("黄天城首领");
		c3 = GetAnyChar("火炮兵1");
		c4 = GetAnyChar("火炮兵2");
		c5 = GetAnyChar("火炮兵3");
		c6 = GetAnyChar("火炮兵4");
		c7 = GetAnyChar("火炮兵5");
		
if (GetHP(c)<=0 && GetHP(c4)<=0 && GetHP(c3)<=0 && GetHP(c5)<=0 && GetHP(c6)<=0 && GetHP(c7)<=0 && player>=0 && GetHP(player)>0)
		{

			PlayerPerform("say", "孙剑原来这么怕死，找这么多来来把守，想杀他还真不容易阿。");
			PlayerPerform("pause", 2);

			trg0 = 8;
			timer0 = now + 6;
		}
	}
     if (trg0 == 8 && now>timer0)
	{
	AddNPC("npc05_15");
	AddNPC("npc05_16");
	AddNPC("npc05_17");
	AddNPC("npc05_18");
	AddNPC("npc05_19");
	AddNPC("npc05_20");
		RemoveNPC(GetAnyChar("黄天城首领"));
                RemoveNPC(GetAnyChar("火炮兵1"));
		RemoveNPC(GetAnyChar("火炮兵2"));
                RemoveNPC(GetAnyChar("火炮兵3"));
		RemoveNPC(GetAnyChar("火炮兵4"));
                RemoveNPC(GetAnyChar("火炮兵5"));
		trg0 = 9;
	}


        if (trg0==9)
	{
		c = GetChar("皇宫总管");
		c2 = GetChar("宫内护卫1");
		c3 = GetChar("宫内护卫2");
		c4 = GetChar("宫内护卫3");
		c5 = GetChar("宫内护卫4");
		c6 = GetChar("宫内护卫5");
		if (c>=0 && GetEnemy(c)==player)
		{


                        ChangeBehavior(c,"follow",player);
			Perform(c, "say", "哼。。一起杀了他。");

                        ChangeBehavior(c2,"follow",player);
		        Perform(c2, "say", "是。。");
			Perform(c2, "pause", 1);

                        ChangeBehavior(c3,"follow",player);
		        Perform(c3, "say", "是。。");
			Perform(c3, "pause", 1);


				
                        ChangeBehavior(c4,"follow",player);
			Perform(c4, "say", "是。。");
			Perform(c4, "pause", 2);
	
			
                        ChangeBehavior(c5,"follow",player);
			Perform(c5, "say", "是。。");
			Perform(c5, "pause", 2);

			
                        ChangeBehavior(c6,"follow",player);
			Perform(c6, "say", "是。。");
			Perform(c6, "pause", 2);



			trg0 = 10;
		} 
           }
   
        if (trg1 == 0)
	{
		c2 = GetChar("宫内护卫1");
		c3 = GetChar("皇宫总管");
		
		if (c2>=0 && GetEnemy(c2)==player)
		{
			ChangeBehavior(c3, "follow", c2);
			Perform(c2, "say", "发现了！，大家快来帮忙！");
			Perform(c2, "faceto", player);
			trg1 = 1;
		}		
	}	
        if (trg2 == 0)
	{
		c2 = GetChar("宫内护卫2");
		c3 = GetChar("皇宫总管");
		
		if (c2>=0 && GetEnemy(c2)==player)
		{
			ChangeBehavior(c3, "follow", c2);
			Perform(c2, "say", "发现伊人君。快来帮忙！");
			Perform(c2, "faceto", player);
			trg2 = 1;
		}		
	}
        if (trg3 == 0)
	{
		c2 = GetChar("宫内护卫3");
		c3 = GetChar("皇宫总管");
		
		if (c2>=0 && GetEnemy(c2)==player)
		{
			ChangeBehavior(c3, "follow", c2);
			Perform(c2, "say", "发现了！，大家快来帮忙！");
			Perform(c2, "faceto", player);
			trg3 = 1;
		}		
	}

        if (trg4 == 0)
	{
		c2 = GetChar("宫内护卫4");
		c3 = GetChar("皇宫总管");
		
		if (c2>=0 && GetEnemy(c2)==player)
		{
			ChangeBehavior(c3, "follow", c2);
			Perform(c2, "say", "快来人阿，有人闯入了。");
			Perform(c2, "faceto", player);
			trg4 = 1;
		}		
	}


       if (trg0 == 10)
	{
		c = GetAnyChar("皇宫总管");
		c3 = GetAnyChar("宫内护卫1");
		c4 = GetAnyChar("宫内护卫2");
		c5 = GetAnyChar("宫内护卫3");
		c6 = GetAnyChar("宫内护卫4");
		c7 = GetAnyChar("宫内护卫5");
		
if (GetHP(c)<=0 && GetHP(c4)<=0 && GetHP(c3)<=0 && GetHP(c5)<=0 && GetHP(c6)<=0 && GetHP(c7)<=0 && player>=0 && GetHP(player)>0)
		{

			PlayerPerform("say", "呜..。。还有多少人啊，累死我了。。。");

			trg0 = 11;
			timer0 = now + 6;
		}
	}
  if (trg0 == 11 && now>timer0)
	{
	AddNPC("npc05_21");
	AddNPC("npc05_22");
	AddNPC("npc05_23");
	AddNPC("npc05_24");
	AddNPC("npc05_25");
	AddNPC("npc05_26");
	AddNPC("npc05_27");
	AddNPC("npc05_28");
		RemoveNPC(GetAnyChar("皇宫总管"));
                RemoveNPC(GetAnyChar("宫内护卫1"));
		RemoveNPC(GetAnyChar("宫内护卫2"));
                RemoveNPC(GetAnyChar("宫内护卫3"));
		RemoveNPC(GetAnyChar("宫内护卫4"));
                RemoveNPC(GetAnyChar("宫内护卫5"));
		trg0 = 12;
	}


    if (trg0 == 12)
	{
		c = GetAnyChar("孙剑");
                c1 = GetAnyChar("贴身护卫1");
                c2 = GetAnyChar("贴身护卫2");
                c3 = GetAnyChar("贴身护卫3");
                c4 = GetAnyChar("贴身护卫4");
                c5 = GetAnyChar("贴身护卫5");
                c6 = GetAnyChar("贴身护卫6");
                c7 = GetAnyChar("贴身护卫7");
		if (c>=0 && GetEnemy(c)==player)
		{

			
                        ChangeBehavior(c,"follow",player);			Perform(c, "pause", 5);
			Perform(c, "say", "他们是我的人，我想杀就杀。。出招吧。。");
			Perform(c, "pause", 5);
			Perform(c, "say", "脸红，今天我自己来收拾你。。你们都去死吧。。");
			Perform(c, "pause", 5);
			Perform(c, "say", "废话，今天就让你见识一下你爷爷的厉害。，");
			Perform(c, "pause", 4);
			Perform(c, "say", "哈哈。这不是给你玩玩吗？要不然还有什么意思。");
			Perform(c, "pause", 4);
			Perform(c, "say", "哈哈，你不要在装了。。你以为我是傻子阿。。");
			Perform(c, "pause", 4);
			Perform(c, "say", "呵呵，是不是打的非常累阿。");
			Perform(c, "faceto", player);


			Perform(c1, "say", "老大。为什么。我们一直都是很忠心的。");
                        Perform(c1, "use", 35);
			Perform(c1, "pause", 23);
			Perform(c1, "faceto", player);


			Perform(c2, "say", "老大，你...");
                        Perform(c2, "use", 35);
			Perform(c2, "pause", 23);
			Perform(c2, "faceto", player);


			Perform(c3, "say", "没想到，。我后悔认你做老大。。");
                        Perform(c3, "use", 35);
			Perform(c3, "pause", 23);
			Perform(c3, "faceto", player);

                        Perform(c4, "use", 35);
			Perform(c4, "pause", 23);
			Perform(c4, "faceto", player);

                        Perform(c5, "use", 35);
			Perform(c5, "pause", 23);
			Perform(c5, "faceto", player);

                        Perform(c6, "use", 35);
			Perform(c6, "pause", 23);
			Perform(c6, "faceto", player);

                        Perform(c7, "use", 35);
			Perform(c7, "pause", 23);
			Perform(c7, "faceto", player);


			PlayerPerform("use", 15);
			PlayerPerform("use", 15);
			PlayerPerform("use", 15);
			PlayerPerform("use", 15);
			PlayerPerform("use", 15);
			PlayerPerform("use", 15);

			PlayerPerform("block", 0);
			PlayerPerform("say", "你，我今天一定要杀了你，。没良心的家伙。");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "孙剑，你好狠的心阿，他们都是你的手下阿。。");
			PlayerPerform("pause", 3);
			PlayerPerform("say", "你说这话也不嫌脸红吗，哈哈，？在雪城不是败给我了吗？");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "其实我看吧，你什么都不是，就是有点小兵，哼。。");
			PlayerPerform("pause", 4);
			PlayerPerform("say", "孙剑，还说你不是懦夫，难道就不能给我公平打一场吗？每次都叫人。.");
			PlayerPerform("pause", 4);
			PlayerPerform("say", "哼，就凭你的手下，。。呜...");
			PlayerPerform("pause", 4);
			PlayerPerform("block", 1);

			trg0 = 13;
		}
	}

	if (trg0 == 13)
	{
		c = GetAnyChar("孙剑");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			

		        Perform(c, "pause", 30);
			Perform(c, "say", "那你就到那里等着吧。。。");
			Perform(c, "pause", 3);
			Perform(c, "say", "你到决死阵，我叫人把伊人梦送到。");
			Perform(c, "pause", 2);
			Perform(c, "say", "如果不想你的老婆有事，你就把我放了。。。");
			Perform(c, "pause", 2);
			Perform(c, "say", "你杀吧，你杀死我就救不了你的老婆了，哈哈。..");


			PlayerPerform("say", "好，如果到那里你不叫人把梦送来，我决不饶你。。");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "好，我放你，那你说。.梦在哪里。");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "梦，你把梦怎么了，她在哪里？..");
			PlayerPerform("pause", 1);
	                PlayerPerform("block", 1);

			trg0 = 14;
		        gameover = 1;
                        timer1 = now + 12;
		}
	}
       if (gameover!=-1 && GetHP(player)<=0)
	{
		gameover = -1;
		timer1 = now + 2; 
	}
	if ((gameover==1 || gameover==-1) && now>timer1)
	{
		GameOver(gameover);
		gameover = 2;
	}

}
