// 大战谷主
int Rule = 1;
int RoundTime = 450;
int PlayerSpawn = 46;
int PlayerSpawnDir = 270;
int PlayerWeapon = 35;
int PlayerWeapon2 = 18;
int PlayerHP = 8000;

int trg0 = 0;
int trg1 = 0;
int trg2 = 0;
int trg3 = 0;
int trg4 = 0;
int trg5 = 0;
int trg6 = 0;
int Spa1;
int Spa2;
int timer0;
int timer1;
int timer2;
int gameover = 0;

OnStart()
{
	AddNPC("3关小人1");
	AddNPC("3关小人2");
	AddNPC("3关小人3");
	AddNPC("3关小人4");
	AddNPC("3关小人5");
	AddNPC("3关刺客1");
	AddNPC("3关刺客2");
	AddNPC("3关刺客3");
}


OnUpdate()
{
	int player = GetChar("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)
	{
		PlayerPerform("block", 0);
		PlayerPerform("crouch", 0);
		PlayerPerform("say", "（执行任务！！）");
		PlayerPerform("pause", 2);
		PlayerPerform("say", "（忽忽..也许这是任务！！）");
		PlayerPerform("pause", 2);
		PlayerPerform("say", "（这里是什么地方，﹒我这是到哪里了。）");
		PlayerPerform("crouch", 1);
		PlayerPerform("block", 1);
		trg0 = 1;
	}

	if (trg1 == 0)
	{
		c = GetChar("蒙面刺客1");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "guard", 4);			
			Say(c, "小子有点门道. . . . .");
			Perform(c, "faceto", player);
			trg1 = 1;
		}
	}
	if (trg1 == 1)
	{
		c = GetAnyChar("蒙面刺客1");
		if (GetHP(c) <= 0)
		{
		       if (Spa1 == 0){AddNPC("3关");Spa1=1;}
		        RemoveNPC(c);
			Say(c, "本尊服了. . . . .");
			trg1 = 2;
		}
	}	
	if (trg2 == 0)
	{
		c = GetChar("蒙面刺客2");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "guard", 4);			
			Say(c, "可恶. . . . .");
			Perform(c, "faceto", player);
			trg2 = 1;
		}
	}
	if (trg2 == 1)
	{
		c = GetAnyChar("蒙面刺客2");
		if (GetHP(c) <= 0)
		{
			Say(c, "我会记住你的﹒﹒﹒﹒﹒﹒");
		        RemoveNPC(c);
			trg2 = 2;
		}
	}	
	if (trg3 == 0)
	{
		c = GetChar("蒙面刺客3");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "guard", 4);			
			Say(c, "小子有点来头啊. . . . .");
			Perform(c, "faceto", player);
			trg3 = 1;
		}
	}
	if (trg3 == 1)
	{
		c = GetAnyChar("蒙面刺客3");
		if (GetHP(c) <= 0)
		{
			Say(c, "想不到真是天外有天，人外有人啊﹒﹒﹒﹒﹒﹒");
		        RemoveNPC(c);
			trg3 = 2;
		}
	}	

	if (trg4 == 0 )
	{

		c = GetChar("谷主");
		SetTarget(0, "char", c);
		SetTarget(1, "char", player);
		if (c>=0 &&  Distance(0, 1) < 300)
		{

                        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);
			ChangeBehavior(GetChar("蒙面刺客2"), "follow", player);
			ChangeBehavior(GetChar("蒙面刺客3"), "follow", player);
                        Perform(c,"use",19);
                        Perform(c,"use",34);
                        Perform(c,"use",3);
                        Perform(c,"use",40);
			Perform(c, "say", "你休想离开这了！所有人上吧！");
			Perform(c, "pause", 3);
			Perform(c, "say", "哼哼！很明显能看出来是什么事...");
			Perform(c, "pause", 3);
			Perform(c, "say", "你就是伊人君，！很不错，今天我就来会会你。");
			Perform(c, "faceto", player);
			
			PlayerPerform("block", 0);
			PlayerPerform("say", "哦..那不客气了！！");
			PlayerPerform("pause", 3);
			PlayerPerform("say", "你是谁..引我到这里来有何事");
			PlayerPerform("pause", 2);
			PlayerPerform("block", 1);

			trg4 = 1;
		}
	}
	if (trg5 == 0)
	{
		c = GetChar("谷主");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "guard", 4);			
			Say(c, "小子有点来头啊. . . . .");
			Perform(c, "faceto", player);
			trg5 = 1;
		}
	}
       if (trg5 == 1)
	{
		c = GetAnyChar("谷主");
		if (GetHP(c) <= 0)
		{
			Say(c, "你以为我真的败给你了吗﹒﹒﹒");

			PlayerPerform("say", "难道还有假，，靠！！去西天吧你。");
			PlayerPerform("pause", 2);
			trg5 = 2;
			timer0 = now + 5;
		}
	}
if (trg5 == 2 && now>timer0)
	{

                RemoveNPC(GetAnyChar("谷足1"));
                RemoveNPC(GetAnyChar("谷足2"));
                RemoveNPC(GetAnyChar("谷足3"));
                RemoveNPC(GetAnyChar("谷足4"));
                RemoveNPC(GetAnyChar("谷足5"));
                RemoveNPC(GetAnyChar("蒙面刺客2"));
                RemoveNPC(GetAnyChar("蒙面刺客3"));
	                trg5 = 3;    
		timer1 = now + 1;}
if (trg5 ==3 && now>timer1){AddNPC("3关1");trg5 = 4;}
if (trg6 == 0 )
	{
		c = GetChar("孙谷主");
		c1 = GetChar("谷主");
		SetTarget(0, "char", c);
		SetTarget(1, "char", c1);
		if (c>=0 &&  Distance(0, 1) < 2000)
                {
                        Perform(c,"use",19);
                        Perform(c,"use",34);
                        Perform(c,"use",3);
                        Perform(c,"use",40);
			Perform(c, "say", "你叫我老头就行了..看招！！.");
			Perform(c, "pause", 4);
			Perform(c, "say", "你这家伙。杀死我最忠心的守身，我要让你偿命。");
			Perform(c, "faceto", player);
			Perform(c, "pause", 3);
			Perform(c, "say", "怎么会这样！！");
			Perform(c, "faceto", c1);
			ChangeBehavior(c, "follow" , c1);

		        PlayerPerform("block", 0);
			PlayerPerform("say", "你是谁。在下伊人君！！请问您是？");
			PlayerPerform("pause", 3);
			PlayerPerform("say", "什么人！！？怎么都不曾见过。");
			PlayerPerform("pause", 2);
			PlayerPerform("block", 1);


			trg6 = 1;
		        timer0 = now + 10;}}
if (trg6 ==1 && now>timer0){AddNPC("3关刺客1");AddNPC("3关刺客2");AddNPC("3关刺客3");trg6 = 2;timer1 = now + 5;}
if (trg6 == 2&& now>timer1)
	{
		c = GetChar("孙谷主");
		c1 = GetChar("蒙面刺客1");
		c2 = GetChar("蒙面刺客2");
		c3 = GetChar("蒙面刺客3");
		if (c>=0 )
                {

			ChangeBehavior(c, "follow" , player);
			ChangeBehavior(c1, "follow" , player);
			ChangeBehavior(c2, "follow" , player);
			ChangeBehavior(c3, "follow" , player);
                        Perform(c1,"use",15);
                        Perform(c1,"use",15);
                        Perform(c1,"use",15);
                        Perform(c1,"use",20);
                        Perform(c2,"use",15);
                        Perform(c2,"use",15);
                        Perform(c2,"use",15);
                        Perform(c2,"use",20);
                        Perform(c3,"use",15);
                        Perform(c3,"use",15);
                        Perform(c3,"use",15);
                        Perform(c3,"use",20);
                        Perform(c,"use",15);
                        Perform(c,"use",20);

      	                trg6 = 3;        
      
		}
           }
       if (trg6 == 3)
	{
		c = GetAnyChar("孙谷主");
		if (GetHP(c) <= 0 && gameover != 1)
		{
			Say(c, "你行阿﹒﹒");

			PlayerPerform("say", "哼...。");
			PlayerPerform("pause", 2);
			trg6 = 4;
			gameover = 1;
			timer2 = now + 5;
		}
	}

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

}