// 洛阳城
int Rule      = 1;
int RoundTime = 350;
int PlayerSpawn    = 141;
int PlayerSpawnDir = 90;
int PlayerWeapon   = 10+Rand(20);
int PlayerWeapon2  = 14;
int PlayerHP       = 15000;

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 Spa1;
int Spa2;
int k1;
int k2;
int k3;
int k4;
int timer0 = 0;
int timer1 = 0;
int timer2 = 0;
int timer3 = 0;
int timer4 = 0;
int timer5 = 0;
int gameover = 0;
OnStart()
{
	AddNPC("4关黑衣6"); 
	AddNPC("4关黑衣1");
	AddNPC("4关黑衣2"); 
	AddNPC("4关黑衣3"); 
	AddNPC("4关黑衣4");
	AddNPC("4关黑衣5");
	AddNPC("4关黑衣8");
	AddNPC("4关黑衣7");
}

OnUpdate()
{
	int player = GetAnyChar("player");
	if (player < 0)
	{
		return 0;
	}
	if (gameover == 2)
	{
		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 now = GetGameTime();

	if (trg0 == 0)
	{
		c = GetChar("黑衣守关人");
		c1 = GetChar("黑衣杀手1");
		c2 = GetChar("黑衣杀手2");
		c3 = GetChar("黑衣杀手3");
		c4 = GetChar("黑衣杀手4");
                c5 = GetChar("黑衣杀手5");
	        c6 = GetChar("黑衣杀手6");
	        c7 = GetChar("黑衣杀手7");
		if (c>=0 && c2>=0 && c3>=0 && c4>=0 && c5>=0)
		{	
			Perform(c, "pause", 8);
			Perform(c, "aggress");
			Perform(c, "say", "我在这守着。你们去巡逻一下。");
			Perform(c, "pause", 1);
			Perform(c, "say", "伊人君在忘幽谷杀死了谷主！现在可能已经在洛阳！你们都要给我留心着点。");
			
			Perform(c2, "aggress");
			Perform(c2, "say", "是！");
			Perform(c2, "pause", 2);
							
			PlayerPerform("block", 0);
			PlayerPerform("say", "他们已经知道我在洛阳！看来要小心了，在这里说不定会知道谁是他们的老大。");
			PlayerPerform("pause", 5);
			PlayerPerform("block", 1);
		
			trg0 = 1;
		}				
           }


if (trg0 == 1 )
	{
		if (c4>=0 && GetEnemy(c4)==player)
		{
			ChangeBehavior(c4, "follow", player);
			ChangeBehavior(c1, "follow", player);
			Perform(c4, "say", "来个帮忙的！找到这家伙了！");

			trg0 = 2;
		}
	}


	
	if (trg1 == 0)
	{
		c = GetChar("黑衣杀手1");
		c1 = GetChar("黑衣守关人");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{
			ChangeBehavior(c, "follow", c1);
			Perform(c, "say", "你给我等着！！");
			Perform(c, "faceto", player);
			trg1 = 1;
		}
	}
	if (trg1 == 1 )
	{
		c = GetChar("黑衣杀手1");
		c1 = GetChar("黑衣守关人");
		SetTarget(0, "char", c);
		SetTarget(1, "char", c1);
		if (c>=0 &&  Distance(0, 1) < 50)
                {
			ChangeBehavior(c, "follow", player);
			ChangeBehavior(GetChar("黑衣杀手2"), "follow", player);
			ChangeBehavior(GetChar("黑衣杀手3"), "follow", player);
			ChangeBehavior(GetChar("黑衣杀手4"), "follow", player);
			ChangeBehavior(GetChar("黑衣杀手5"), "follow", player);
			ChangeBehavior(GetChar("黑衣杀手6"), "follow", player);
			ChangeBehavior(GetChar("黑衣杀手7"), "follow", player);
			Perform(c, "say", "是！！");
			Perform(c, "pause", 4);
			Perform(c, "say", "老大！发现那个家伙了，但是我打不过他。");
			Perform(c, "faceto", c1);

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

			trg1 = 2;
		}
	}
	if (trg2 == 0 )
	{

		c = GetChar("黑衣守关人");
		SetTarget(0, "char", c);
		SetTarget(1, "char", player);
		if (c>=0 &&  Distance(0, 1) < 300)
		{
			ChangeBehavior(GetChar("黑衣杀手1"), "follow", player);
			ChangeBehavior(GetChar("黑衣杀手2"), "follow", player);
			ChangeBehavior(GetChar("黑衣杀手3"), "follow", player);
			ChangeBehavior(GetChar("黑衣杀手4"), "follow", player);
			ChangeBehavior(GetChar("黑衣杀手5"), "follow", player);
			ChangeBehavior(GetChar("黑衣杀手6"), "follow", player);
			ChangeBehavior(GetChar("黑衣杀手7"), "follow", player);
			ChangeBehavior(c, "follow", player);
			Perform(c, "say", "我们上！");
			Perform(c, "faceto", player);
			Perform(c, "say", "想通过这里，先打败我们！！。不过看你有没有能耐了！！");
			Perform(c, "faceto", player);


			PlayerPerform("block", 0);
			PlayerPerform("say", "你们。哼哼！！不自量力...");
			PlayerPerform("pause", 5);
			PlayerPerform("block", 1);
                            trg2 = 1;

		}
          }

if (trg2 == 1)
	{
		c1 = GetAnyChar("黑衣杀手1"); 
		c2 = GetAnyChar("黑衣杀手2"); 
		c3 = GetAnyChar("黑衣杀手3");
		c4 = GetAnyChar("黑衣杀手4");
		c5 = GetAnyChar("黑衣杀手5"); 
		c6 = GetAnyChar("黑衣杀手6");
		c7 = GetAnyChar("黑衣杀手7");
		if (GetHP(c1)<=0 && GetHP(c2)<=0 && GetHP(c3)<=0 && GetHP(c4)<=0 &&  GetHP(c5)<=0 &&  GetHP(c6)<=0 &&  GetHP(c7)<=0 && player>=0 && GetHP(player)>0)
		{

		        RemoveNPC(c1);
		        RemoveNPC(c2);
		        RemoveNPC(c3);
		        RemoveNPC(c4);
		        RemoveNPC(c5);
		        RemoveNPC(c6);
		        RemoveNPC(c7);
			PlayerPerform("use", 15);
			PlayerPerform("use", 15);
			trg2 = 2;
		        timer0 = now + 5; 
		}
          }

	if (trg2 == 2  && now > timer0)
	{
	       AddNPC("4关");
               AddNPC("4关贴身1");
               AddNPC("4关贴身2");
               AddNPC("4关贴身3");
               AddNPC("4关贴身4");
               AddNPC("4关贴身5");
               RemoveNPC(GetAnyChar("黑衣守关人"));
		trg2 = 3;
	}


	if (trg3 == 0)
	{
		c = GetChar("洛阳首领");
		c1 = GetChar("洛阳贴身1");
		c2 = GetChar("洛阳贴身2");
		c3 = GetChar("洛阳贴身3");
		c4 = GetChar("洛阳贴身4");
                c5 = GetChar("洛阳贴身5");
		if (c>=0 && c2>=0 && c3>=0 && c4>=0 && c5>=0)
		{	
			Perform(c, "pause", 8);
			Perform(c, "aggress");
			Perform(c, "say", "看见那小子。一锤搞定他");
			Perform(c, "pause", 1);
			Perform(c, "say", "把伊人君给我抓过来。这家伙。真是厉害吗？");
			
			Perform(c2, "aggress");
			Perform(c2, "say", "是！你看着吧，首领！我提着他的人头来见你。");
			Perform(c2, "pause", 2);
							
			PlayerPerform("block", 0);
			PlayerPerform("say", "首领。出现了！！");
			PlayerPerform("pause", 5);
			PlayerPerform("block", 1);
		
			trg3 = 1;
		}				
           }
        if (trg3 == 1 )
	{
		c1 = GetChar("洛阳贴身1");
		if (c1>=0 && GetEnemy(c1)==player)
		{
			ChangeBehavior(c1, "follow", player);
			ChangeBehavior(GetChar("洛阳贴身2"), "follow", player);
			Perform(c1, "say", "找到这家伙了！快过来帮忙！！");

			trg3 = 2;
		}
	}
	if (trg3 == 2)
	{
		c = GetChar("洛阳贴身1");
		c1 = GetChar("洛阳首领");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{
			ChangeBehavior(c, "follow", c1);
			Perform(c, "say", "你这家伙！一会有你好戏看了！！");
			Perform(c, "faceto", player);
			trg3 = 3;
		}
	}
if (trg3 == 3 )
	{
		c = GetChar("洛阳贴身1");
		c1 = GetChar("洛阳首领");
		SetTarget(0, "char", c);
		SetTarget(1, "char", c1);
		if (c>=0 &&  Distance(0, 1) < 50)
                {
			ChangeBehavior(c, "follow", player);
			ChangeBehavior(GetChar("洛阳贴身2"), "follow", player);
			ChangeBehavior(GetChar("洛阳贴身3"), "follow", player);
			ChangeBehavior(GetChar("洛阳贴身4"), "follow", player);
			ChangeBehavior(GetChar("洛阳贴身5"), "follow", player);
			Perform(c, "say", "是！！");
			Perform(c, "pause", 4);
			Perform(c, "say", "！发现那个家伙了，。");
			Perform(c, "faceto", c1);

			ChangeBehavior(c1, "follow", player);
			Perform(c1, "say", "所有人都给我一起走！！。");
			Perform(c1, "pause", 3);
			Perform(c1, "faceto", c);

			trg3 = 4;
		}
	}

        if (trg5 == 0 )
	{
		c = GetChar("洛阳首领");
		if (c>=0 && GetEnemy(c)==player)
		{
			ChangeBehavior(c, "follow", player);
			ChangeBehavior(GetChar("洛阳贴身1"), "follow", player);
			ChangeBehavior(GetChar("洛阳贴身2"), "follow", player);
			ChangeBehavior(GetChar("洛阳贴身3"), "follow", player);
			ChangeBehavior(GetChar("洛阳贴身4"), "follow", player);
			ChangeBehavior(GetChar("洛阳贴身5"), "follow", player);
			Perform(c, "say", "你们是干什么吃的！都给我过来，这家伙在这！！");

			trg5 = 1;
		}
	}
	if (trg5 == 1)
	{
		c = GetChar("洛阳首领");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{
		        RemoveNPC(c);
			PlayerPerform("use", 15);
			PlayerPerform("say", "看来他只是洛阳的首领。而不是真正的老大");
			PlayerPerform("pause", 2);
			trg5 = 2;
			timer1 = now + 5;
		}
	}
	if (trg5 == 2  && now > timer1)
	{
               AddNPC("4关护法1");
               AddNPC("4关护法2");
               AddNPC("4关护法3");trg5 = 3;}


if (trg3 == 4)
	{
		c1 = GetAnyChar("洛阳贴身1"); 
		c2 = GetAnyChar("洛阳贴身2"); 
		c3 = GetAnyChar("洛阳贴身3");
		c4 = GetAnyChar("洛阳贴身4");
		c5 = GetAnyChar("洛阳贴身5"); 
if (GetHP(c1)<=0 && GetHP(c2)<=0 && GetHP(c3)<=0 && GetHP(c4)<=0 && GetHP(c5)<=0 && player>=0 && GetHP(player)>0)
		{

		        RemoveNPC(c1);
		        RemoveNPC(c2);
		        RemoveNPC(c3);
		        RemoveNPC(c4);
		        RemoveNPC(c5);

			trg3 = 5;
		}
	}

	if (trg4 == 0)
	{
		c = GetChar("护法2");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{
                        Perform(c,"use",15);
                        Perform(c,"use",15);
			Perform(c, "say", "果真是有一套！怪不得能闯入这里..");
			Perform(c, "faceto", player);
			trg4 = 1;
		}
              }

	if (trg4 == 1)
	{
		c = GetAnyChar("护法2");
		c1 = GetAnyChar("护法1");
		c2 = GetAnyChar("护法3");
if (GetHP(c)<=0 && GetHP(c1)<=0 && GetHP(c2)<=0 &&player>=0 && GetHP(player)>0)
	        {       RemoveNPC(c);
		        RemoveNPC(c1);
		        RemoveNPC(c2);
			PlayerPerform("use", 15);
			PlayerPerform("use", 15);
			trg4 = 2;
			timer0 = now + 5;
		}
	}
	if (trg4 == 2  && now > timer0)
	{
               AddNPC("4关1");
               AddNPC("4关2");
               AddNPC("4关3");trg4 = 3;}
	if (trg4 == 3)
	{
		c = GetChar("剑气");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{
			Perform(c, "aggress");
                        Perform(c,"use",15);
                        Perform(c,"use",15);
			Perform(c, "faceto", player);
			trg4 = 4;
		}
              }
	if (trg6 == 0)
	{
		c = GetChar("狂刀");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{
			Perform(c, "aggress");
                        Perform(c,"use",15);
                        Perform(c,"use",15);
			Perform(c, "faceto", player);
			trg6 = 1;
		       }
              }
	if (trg7 == 0)
	{
		c = GetChar("神抢");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{
			Perform(c, "aggress");
                        Perform(c,"use",15);
                        Perform(c,"use",15);
			Perform(c, "faceto", player);
			trg7 = 1;
		      }
              }


        if (trg7 == 1)
	{
		c1 = GetAnyChar("剑气"); 
		c2 = GetAnyChar("狂刀"); 
		c3 = GetAnyChar("神抢");
if (GetHP(c1)<=0 && GetHP(c2)<=0 && GetHP(c3)<=0 &&player>=0 && GetHP(player)>0)
		{

		        RemoveNPC(c1);
		        RemoveNPC(c2);
		        RemoveNPC(c3);
		        gameover = 1;
			trg7 = 2;
		}
        }
		if (now > timer5)
		{
			PlayerPerform("use", 5);
			PlayerPerform("use", 8);
			PlayerPerform("use", 41);
			timer5 = now + 30; 
		} 


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

}

