// 继承人
int Rule = 1;
int RoundTime = 990;
int PlayerSpawn = 30;
int PlayerSpawnDir = 270;
int PlayerWeapon = 47;
int PlayerWeapon2 = 4;
int PlayerHP = 20000;

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 trg12 = 0;
int trg13 = 0;
int trg14 = 0;
int trg15 = 0;
int timer0 = 0;
int timer1 = 0;
int timer2 = 0;
int timer3 = 0;
int timer4 = 0;
int gameover = 0;

OnStart()
{
	AddNPC("遗忘继承1");
	AddNPC("遗忘之谷1");
	AddNPC("遗忘之谷2");
	AddNPC("遗忘之谷3");
	AddNPC("遗忘之谷4");
	AddNPC("遗忘之谷5");
	AddNPC("遗忘之谷6");
	AddNPC("遗忘之谷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)
		{
			Perform(c, "guard", 50000);
                        Perform(c, "use", 19);
                        Perform(c, "use", 5);
                        Perform(c, "use", 34);
                        Perform(c, "use", 3);
                        Perform(c, "use", 33);
                        Perform(c, "use", 41);
			Perform(c, "say", "你们都去把伊人君给我抓回来..");
			ChangeBehavior(c1, "patrol", 5 , 6 , 7 , 8 , 9 , 10 , 37 , 22);
                        Perform(c1, "use", 19);
                        Perform(c1, "use", 5);

			ChangeBehavior(c2, "patrol", 5 , 6 , 7 , 8 , 9 , 10 , 37 , 22);
                        Perform(c2, "use", 19);
                        Perform(c2, "use", 5);
			ChangeBehavior(c3, "patrol", 5 , 6 , 7 , 8 , 9 , 10 , 37 , 22);
                        Perform(c3, "use", 19);
                        Perform(c3, "use", 5);
			ChangeBehavior(c4, "patrol", 5 , 6 , 7 , 8 , 9 , 10 , 37 , 22);
                        Perform(c4, "use", 19);
                        Perform(c4, "use", 5);
			ChangeBehavior(c5, "patrol", 5 , 6 , 7 , 8 , 9 , 10 , 37 , 22);
                        Perform(c5, "use", 19);
                        Perform(c5, "use", 5);
			ChangeBehavior(c6, "patrol", 5 , 6 , 7 , 8 , 9 , 10 , 37 , 22);
                        Perform(c6, "use", 19);
                        Perform(c6, "use", 5);
			ChangeBehavior(c7, "patrol", 5 , 6 , 7 , 8 , 9 , 10 , 37 , 22);
                        Perform(c7, "use", 19);
                        Perform(c7, "use", 5);

                        trg0 = 1;
		}
	}


if (trg1 == 0)
	{
		c = GetChar("遗忘之谷1");
		c1 = GetChar("遗忘之谷2");
		c2 = GetChar("遗忘之谷3");
		c3 = GetChar("遗忘之谷4");
		c4 = GetChar("遗忘之谷5");
		c5 = GetChar("遗忘之谷6");
		c6 = GetChar("遗忘之谷7");
		if (c>=0 && GetEnemy(c)==player)
		{

			ChangeBehavior(c, "follow", player);
			Perform(c, "say", "这家伙在这。！都过来...");
			Perform(c, "faceto", player);

		       ChangeBehavior(c1, "kill", player);
                        Perform(c1, "use", 19);
                        Perform(c1, "use", 5);
		       ChangeBehavior(c2, "kill", player);
                        Perform(c2, "use", 19);
                        Perform(c2, "use", 5);
		       ChangeBehavior(c3, "kill", player);
                        Perform(c3, "use", 19);
                        Perform(c3, "use", 5);
		       ChangeBehavior(c4, "kill", player);
                        Perform(c4, "use", 19);
                        Perform(c4, "use", 5);
		       ChangeBehavior(c5, "kill", player);
                        Perform(c5, "use", 19);
                        Perform(c5, "use", 5);
		       ChangeBehavior(c6, "kill", player);
                        Perform(c6, "use", 19);
                        Perform(c6, "use", 5);

			PlayerPerform("block", 0);
			PlayerPerform("use", 15);
			PlayerPerform("use", 15);
			PlayerPerform("say", "...找打！");
			PlayerPerform("pause", 3);
			PlayerPerform("block", 1);


			trg1 = 1;

		}		
	}

	if (trg1 == 1)
	{
		c = GetChar("遗忘之谷1");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{				
			ChangeBehavior(c, "wait");
			SetTarget(0, "waypoint", 1);
			ChangeBehavior(c, "attacktarget", 0);
						
			Perform(c, "say", "﹒﹒﹒你等着吧﹒﹒接下来就有你意想不到的好戏看了﹒﹒﹒");
			Perform(c, "faceto", player);
		
			c2 = GetChar("遗忘之谷2");
                        ChangeBehavior(c2, "follow", c);
			c2 = GetChar("遗忘之谷3");
                        ChangeBehavior(c2, "follow", c);
			c2 = GetChar("遗忘之谷4");
                        ChangeBehavior(c2, "follow", c);
			c2 = GetChar("遗忘之谷5");
                        ChangeBehavior(c2, "follow", c);
			c2 = GetChar("遗忘之谷6");
                        ChangeBehavior(c2, "follow", c);
			c2 = GetChar("遗忘之谷7");
                        ChangeBehavior(c2, "follow", c);
			
			trg1 = 2;	
		}
	}

	if (trg2 == 0)
	{
		c = GetAnyChar("继承人");
		c1 = GetAnyChar("遗忘之谷1");
		c2 = GetAnyChar("遗忘之谷2");
		c3 = GetAnyChar("遗忘之谷3");
		c4 = GetAnyChar("遗忘之谷4");
		c5 = GetAnyChar("遗忘之谷5");
		c6 = GetAnyChar("遗忘之谷6");
		c7 = GetAnyChar("遗忘之谷7");
		SetTarget(0, "char", c);
		SetTarget(1, "char", player);
		if (c>=0 && GetEnemy(c)==player && Distance(0, 1)<150)
		{
			StopPerform(player);
			StopPerform(c);

			Perform(c, "say", "你是看不出来的。手下见真章吧..。");
			Perform(c, "pause", 6);
			Perform(c, "say", "我就是要会会你有多厉害。。");
			Perform(c, "pause", 6);
			Perform(c, "say", "3年前，孙剑死在你的手下，还有2 3公子。以及高官，律香川...");
			Perform(c, "pause", 6);
			Perform(c, "say", "哈哈..算你聪明..我是孙剑身边的贴身..");
			Perform(c, "pause", 6);
			Perform(c, "faceto", player);
			Perform(c, "say", "你这家伙....给我站住.");
			Perform(c, "faceto", player);

                        ChangeBehavior(c1, "follow", c);
			Perform(c1, "pause", 25);
			Perform(c1, "faceto", c);
                        ChangeBehavior(c2, "follow", c);				
			Perform(c2, "pause", 25);
			Perform(c2, "faceto", c);	
                        ChangeBehavior(c3, "follow", c);
			Perform(c3, "pause", 25);
			Perform(c3, "faceto", c);
                        ChangeBehavior(c4, "follow", c);				
			Perform(c4, "pause", 25);
			Perform(c4, "faceto", c);		
                        ChangeBehavior(c5, "follow", c);			
			Perform(c5, "pause", 25);
			Perform(c5, "faceto", c);
			ChangeBehavior(c6, "follow", c);
			Perform(c6, "pause", 25);
			Perform(c6, "faceto", c);
                        ChangeBehavior(c7, "follow", c);
			Perform(c7, "pause", 25);
			Perform(c7, "faceto", c);

			PlayerPerform("say", "吃里爬外的家伙。受死吧....");
			PlayerPerform("pause", 8);
			PlayerPerform("say", "哼...就你....我看都看不起。");
			PlayerPerform("pause", 6);
			PlayerPerform("say", "不错？他们都死在我的手下，更何况你。");
			PlayerPerform("pause", 6);
			PlayerPerform("say", "我的任务就是铲除余党..。");
			PlayerPerform("pause", 6);
			PlayerPerform("say", "继承人。也是孙剑他们的余党");
			PlayerPerform("pause", 5);
			PlayerPerform("block", 1);

			trg2 = 1;
		}
	}
	if (trg2 == 1)
	{
		c = GetChar("继承人");
		if (GetHP(c) <= 0)
		{

			Say(c, "我不F......");

			trg2 = 2;
			timer0 = now + 2;
		}
	}

   if (trg2 == 2 && now>timer0)
	{
                RemoveNPC(GetAnyChar("遗忘之谷1"));
		RemoveNPC(GetAnyChar("遗忘之谷2"));
                RemoveNPC(GetAnyChar("遗忘之谷3"));
		RemoveNPC(GetAnyChar("遗忘之谷4"));
                RemoveNPC(GetAnyChar("遗忘之谷5"));
		RemoveNPC(GetAnyChar("遗忘之谷6"));
                RemoveNPC(GetAnyChar("遗忘之谷7"));
                RemoveNPC(GetAnyChar("继承人"));
			trg2 = 3;
			timer1 = now + 2;
		}

        if (trg2 == 3 && now>timer1)
	{
                    AddNPC("遗忘杀手1");
                    AddNPC("遗忘杀手2");
                    AddNPC("遗忘杀手3");
                    AddNPC("遗忘杀手4");
                    AddNPC("遗忘杀手5");
                    AddNPC("遗忘杀手6");
                    AddNPC("遗忘杀手7");
                    AddNPC("遗忘杀手8");
      	                trg2 = 4;        
      
		}

if (trg3 == 0)
	{
		c = GetChar("玉城_杀手1");
		c1 = GetChar("玉城_杀手2");
		c2 = GetChar("玉城_杀手3");
		c3 = GetChar("玉城_杀手4");
		c4 = GetChar("玉城_杀手5");
		c5 = GetChar("玉城_杀手6");
		c6 = GetChar("玉城_杀手7");
		c7 = GetChar("玉城_杀手8");
		
		if (c>=0 && GetEnemy(c)==player)
		{

			ChangeBehavior(c, "follow", player);
			Perform(c, "say", "好大的胆子！！给我杀了他。");
			Perform(c, "faceto", player);

		       ChangeBehavior(c1, "kill", player);
                        Perform(c1, "use", 19);
                        Perform(c1, "use", 5);
		       ChangeBehavior(c2, "kill", player);
                        Perform(c2, "use", 19);
                        Perform(c2, "use", 5);
		       ChangeBehavior(c3, "kill", player);
                        Perform(c3, "use", 19);
                        Perform(c3, "use", 5);
		       ChangeBehavior(c4, "kill", player);
                        Perform(c4, "use", 19);
                        Perform(c4, "use", 5);
		       ChangeBehavior(c5, "kill", player);
                        Perform(c5, "use", 19);
                        Perform(c5, "use", 5);
		       ChangeBehavior(c6, "kill", player);
                        Perform(c6, "use", 19);
                        Perform(c6, "use", 5);
		       ChangeBehavior(c7, "kill", player);
                        Perform(c7, "use", 19);
                        Perform(c7, "use", 5);

			PlayerPerform("block", 0);
			PlayerPerform("use", 15);
			PlayerPerform("use", 15);
			PlayerPerform("say", "......杀！！！...");
			PlayerPerform("pause", 3);
			PlayerPerform("block", 1);


			trg3 = 1;

		}		
	}

	if (trg3 == 1)
	{
		c = GetAnyChar("玉城_杀手1");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "say", "好棘手的家伙...");

			PlayerPerform("say", "哼哼～");
			PlayerPerform("pause", 2);
			trg3 = 2;
		}
	}
	if (trg3 == 2)
	{
		c = GetAnyChar("玉城_杀手1");
		if (GetHP(c) <= 0)
		{
			Say(c, "我不甘心阿....我不F....");
			trg3 = 3;
		}
	}	
	if (trg3 == 3)
	{
		c = GetAnyChar("玉城_杀手1");
		c1 = GetAnyChar("玉城_杀手2");
		c2 = GetAnyChar("玉城_杀手3");
		c3 = GetAnyChar("玉城_杀手4");
		c4 = GetAnyChar("玉城_杀手5");
		c5 = GetAnyChar("玉城_杀手6");
		c6 = GetAnyChar("玉城_杀手7");
		c7 = GetAnyChar("玉城_杀手8");
		
		if (GetHP(c)<=0 && 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)
		{



			PlayerPerform("say", "......小人也猖狂..！！");
			PlayerPerform("pause", 1);

			trg3 = 4;
			timer0 = now + 5;
		}
	}

   if (trg3 == 4 && now>timer0)
	{
                RemoveNPC(GetAnyChar("玉城_杀手1"));
		RemoveNPC(GetAnyChar("玉城_杀手2"));
                RemoveNPC(GetAnyChar("玉城_杀手3"));
		RemoveNPC(GetAnyChar("玉城_杀手4"));
                RemoveNPC(GetAnyChar("玉城_杀手5"));
		RemoveNPC(GetAnyChar("玉城_杀手6"));
                RemoveNPC(GetAnyChar("玉城_杀手7"));
                RemoveNPC(GetAnyChar("玉城_杀手8"));
			trg3 = 5;
			timer1 = now + 2;
		}

        if (trg3 == 5 && now>timer1)
	{
                    AddNPC("遗忘1");
                    AddNPC("遗忘2");
                    AddNPC("遗忘3");
                    AddNPC("遗忘4");
                    AddNPC("遗忘5");
                    AddNPC("遗忘6");
                    AddNPC("遗忘7");
                    AddNPC("遗忘8");
      	                trg3 = 6;        
      
		}

if (trg4 == 0)
	{
		c = GetChar("玉城 ！-！月姬");
		c1 = GetChar("玉城 ！-！日姬");
		c2 = GetChar("玉城 ！-！白姬");
		c3 = GetChar("玉城 ！-！黑姬");
		c4 = GetChar("玉城 ！-！剑");
		c5 = GetChar("玉城 ！-！匕");
		c6 = GetChar("玉城 ！-！忍");
		c7 = GetChar("玉城 ！-！指");
		
		if (c>=0 && GetEnemy(c)==player)
		{

			ChangeBehavior(c, "follow", player);
			Perform(c, "say", "我让你看看我们是怎么猖狂的..。");
			Perform(c, "faceto", player);

		       ChangeBehavior(c1, "kill", player);
                        Perform(c1, "use", 19);
                        Perform(c1, "use", 5);
		       ChangeBehavior(c2, "kill", player);
                        Perform(c2, "use", 19);
                        Perform(c2, "use", 5);
		       ChangeBehavior(c3, "kill", player);
                        Perform(c3, "use", 19);
                        Perform(c3, "use", 5);
		       ChangeBehavior(c4, "kill", player);
                        Perform(c4, "use", 19);
                        Perform(c4, "use", 5);
		       ChangeBehavior(c5, "kill", player);
                        Perform(c5, "use", 19);
                        Perform(c5, "use", 5);
		       ChangeBehavior(c6, "kill", player);
                        Perform(c6, "use", 19);
                        Perform(c6, "use", 5);
		       ChangeBehavior(c7, "kill", player);
                        Perform(c7, "use", 19);
                        Perform(c7, "use", 5);

			PlayerPerform("block", 0);
			PlayerPerform("use", 15);
			PlayerPerform("use", 15);
			PlayerPerform("say", ".......杀的你们片甲不留...");
			PlayerPerform("pause", 3);
			PlayerPerform("block", 1);


			trg4 = 1;
			timer0 = now + 20;
		}		
	}

if (trg4 == 1 && now>timer0)
	{
	    AddNPC("制作人2");

		trg4 = 2;
	}

 if (trg12 == 0)        
        {   

		c = GetChar("(兵兵)");
                if (c>0 && c1>0 )
                { 

			ChangeBehavior(c, "follow", player);
                        Perform(c, "use", 19);
                        Perform(c, "use", 5);
                        Perform(c, "use", 33);
                        Perform(c, "use", 34);
                        Perform(c, "use", 41);
                        Perform(c, "use", 3);
			Perform(c, "say", "无名的（AI）。。。受死吧..");
			Perform(c, "pause", 1);
			Perform(c, "say", "我来帮你。。任务不好闯.我当制作人的！不能袖手旁观呢。");
			Perform(c, "faceto", player);


			PlayerPerform("use", 34);
			PlayerPerform("use", 33);
			PlayerPerform("use", 19);
			PlayerPerform("use", 5);
                        PlayerPerform("say", "谢大侠相助了..。。");
                        PlayerPerform("pause", 4);
                        PlayerPerform("block", 1);

                        trg12 = 1;
		}
	}


	if (trg4 == 2)
	{
		c = GetAnyChar("玉城 ！-！月姬");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "say", "厉害......");

			PlayerPerform("say", "过奖～");
			PlayerPerform("pause", 2);
			trg4 = 3;
		}
	}
	if (trg4 == 3)
	{
		c = GetAnyChar("玉城 ！-！月姬");
		if (GetHP(c) <= 0)
		{
			Say(c, "我会回来找你的....");
			trg4 = 4;
		}
	}
	if (trg5 == 0)
	{
		c = GetAnyChar("玉城 ！-！日姬");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "say", "好久没这么痛快的打过了。..");

			trg5 = 1;
		}
	}
	if (trg5 == 1)
	{
		c = GetAnyChar("玉城 ！-！日姬");
		if (GetHP(c) <= 0)
		{
			Say(c, "你行......");
			trg5 = 2;
		}
	}
	if (trg6 == 0)
	{
		c = GetAnyChar("玉城 ！-！白姬");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "say", "没想到你这么厉害..怪不得这么猖狂");

			trg6 = 1;
		}
	}
	if (trg6 == 1)
	{
		c = GetAnyChar("玉城 ！-！白姬");
		if (GetHP(c) <= 0)
		{
			Say(c, "我竟然会死在你的手里。.");
			trg6 = 2;
		}
	}
	if (trg7 == 0)
	{
		c = GetAnyChar("玉城 ！-！黑姬");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "say", "死也要让你死的难受一点。");

			trg7 = 1;
		}
	}
	if (trg7 == 1)
	{
		c = GetAnyChar("玉城 ！-！黑姬");
		if (GetHP(c) <= 0)
		{
			Say(c, "这是我。黑姬.的下场吗？");
			trg7 = 2;
		}
	}

	if (trg8 == 0)
	{
		c = GetAnyChar("玉城 ！-！剑");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "say", "对女人温柔一点..");

			trg8 = 1;
		}
	}
	if (trg8 == 1)
	{
		c = GetAnyChar("玉城 ！-！剑");
		if (GetHP(c) <= 0)
		{
			Say(c, "真冷漠！！！");
			trg8 = 2;
		}
	}

	if (trg9 == 0)
	{
		c = GetAnyChar("玉城 ！-！匕");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "say", "好酷....");

			trg9 = 1;
		}
	}
	if (trg9 == 1)
	{
		c = GetAnyChar("玉城 ！-！匕");
		if (GetHP(c) <= 0)
		{
			Say(c, "真无情阿！！");
			trg9 = 2;
		}
	}

	if (trg10 == 0)
	{
		c = GetAnyChar("玉城 ！-！指");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "say", "好酷...我好喜欢...");

			trg10 = 1;
		}
	}
	if (trg10 == 1)
	{
		c = GetAnyChar("玉城 ！-！指");
		if (GetHP(c) <= 0)
		{
			Say(c, "你也会杀女人阿！！");
			trg10 = 2;
		}
	}

	if (trg11 == 0)
	{
		c = GetAnyChar("玉城 ！-！忍");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "say", "真有一套....");

			trg11 = 1;
		}
	}
	if (trg11 == 1)
	{
		c = GetAnyChar("玉城 ！-！忍");
		if (GetHP(c) <= 0)
		{
			Say(c, "无情的家伙！！！我狠死你了。");
			trg11 = 2;
		}
	}

	if (trg11 == 2)
	{
		c = GetAnyChar("玉城 ！-！忍");
		c1 = GetAnyChar("玉城 ！-！匕");
		c2 = GetAnyChar("玉城 ！-！指");
		c3 = GetAnyChar("玉城 ！-！剑");
		c4 = GetAnyChar("玉城 ！-！月姬");
		c5 = GetAnyChar("玉城 ！-！日姬");
		c6 = GetAnyChar("玉城 ！-！白姬");
		c7 = GetAnyChar("玉城 ！-！黑姬");
		
		if (GetHP(c)<=0 && 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)
		{



			trg11 = 3;
		        gameover = 1;
			timer0 = now + 5;
		}
	}

	if (trg12 == 0)
	{
		c = GetAnyChar("(兵兵)");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "say", "小兄弟。.支援我.");

			trg12 = 1;
		}
	}
	if (trg12 == 1)
	{
		c = GetAnyChar("(兵兵)");
		if (GetHP(c) <= 0)
		{
			Say(c, "不用灰心.我们在来");
			trg12 = 2;
		       timer0 = now + 2; 
		}
	}
        if (trg12 == 2 && now>timer0)
	{

		        gameover = -1;
			trg12 = 3;

	}


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

}
