// 锺乳洞
int Rule = 5;
int RoundTime = 15;
int PlayerSpawn = 9;
int PlayerSpawnDir = 90;
int PlayerWeapon = 15;
int PlayerWeapon2 = 48;
int PlayerHP = 8000;

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

OnStart()
{
	AddNPC("npc01_01");
	AddNPC("npc01_02");
	AddNPC("npc01_03");
	AddNPC("npc01_04");
        AddNPC("npc01_05");

}


OnUpdate()
{
	int player = GetChar("player");
	if (player < 0)
	{
		return 0;
	}
	
	int c;
	int c2;
	int c3;
	int c4;
	int c5;
	int c6;
	int now = GetGameTime();

	if (trg0 == 0)
	{
		c = GetChar("守关黑衣人"); 
		c2 = GetChar("护卫﹒甲"); 
		c3 = GetChar("护卫﹒乙");
		c4 = GetChar("护卫﹒丙");
                c5 = GetChar("护卫﹒丁");
		if (c>=0 && c2>=0 && c3>=0 && c4>=0 && c5>=0)
		{

			                     ChangeBehavior(c,"follow",player);
			Perform(c, "faceto", player);	
			Perform(c, "say", "走，把伊人君抓起来，交给孙老大。我们有酒吃。。！");
			Perform(c, "faceto", c2);
			
                     ChangeBehavior(c2,"follow",player);
		        Perform(c2, "faceto", player);	
			Perform(c2, "say", "是！");
			Perform(c2, "pause", 1);
			Perform(c2, "faceto", c);
			
                     ChangeBehavior(c3,"follow",player);
			Perform(c3, "faceto", player);	
			Perform(c3, "say", "蛤。！");
			Perform(c3, "pause", 1);
			Perofrm(c3, "faceto", c);
                        
                     ChangeBehavior(c4,"follow",player);
		        Perform(c4, "faceto", player);	
			Perform(c4, "say", "我们走。！");
			Perform(c4, "pause", 1);
			Perofrm(c4, "faceto", c);

                      ChangeBehavior(c5,"follow",player);

			PlayerPerform("block", 0);
			PlayerPerform("say", "（希望不要有什么人.）");
			PlayerPerform("pause", 1);		
			PlayerPerform("say", "（我要赶快到一线天去.）");
			PlayerPerform("pause", 1);
			PlayerPerform("say", "（钟乳洞,可算是到了.）");
			PlayerPerform("pause", 2);
			PlayerPerform("block", 1);
			trg0 = 1;

			timer0 = now + 30;
		}
	}

       if (trg0 == 1 && now>timer0)
	{
               AddNPC("npc01_06");

		trg0 = 2;

	}

        if (trg0 == 2)
	{
		c = GetChar("伊人梦");
                if (c>=0)
		{
                     ChangeBehavior(c,"follow",player);
			Perform(c, "say", "西西，我不是光说阿，我还要打。嘿。.受死吧，你们。。。");
			Perform(c, "pause", 8);
			Perform(c, "say", "不是了，我好久没洗澡了，？只是洗了个藻，谁知道你已经出发了");
			Perform(c, "pause", 5);
			Perform(c, "faceto", player);
			Perform(c, "pause", 3);

			PlayerPerform("block", 0);
			PlayerPerform("say", "就你这张嘴阿，！！最能说了，我的宝贝。");
			PlayerPerform("pause", 6);
			PlayerPerform("say", "唉，也不管我自己闯关累不累阿。");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "梦，怎么现在才来阿？。 .");
			PlayerPerform("block", 1);

			trg0 = 3;
		}
	}	
		

	if (trg1 == 0)
	{
		c = GetChar("守关黑衣人");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{			
			Perform(c, "guard", 4);
			Perform(c, "say", "你这小子还真有两下子，来头可不小！！");
			Perform(c, "faceto", player);
			trg1 = 1;
		}
	}
	if (trg1 == 1)
	{
		c = GetAnyChar("守关黑衣人");
		if (GetHP(c) <= 0)
		{
			Say(c, "呜﹒﹒﹒你别以为﹒﹒你能够杀的了﹒﹒﹒﹒﹒﹒");
			trg1 = 2;
			timer1 = now + 2;
		}

	}

       if (trg1 == 2 && now>timer1)
	{
               AddNPC("npc01_07");
               AddNPC("npc01_08");
               AddNPC("npc01_09");


		trg1 = 3;

	}

	if (trg1 == 3)
	{
		c = GetChar("无名队长"); 
		c2 = GetChar("无名小人1"); 
		c3 = GetChar("无名小人2");
		if (c>=0 && GetEnemy(c)==player)
		{

			ChangeBehavior(c,"follow",player);
			Perform(c, "say", "那领教了。。。");
			Perform(c, "pause", 5);	
			Perform(c, "say", "这么厉害，伊人君，早就接到信说你要杀孙堂主，我想来先会会你。");
			Perform(c, "faceto", player);

			Perform(c2, "pause", 8);	
			Perform(c2, "faceto", player);

			Perform(c3, "pause", 8);
			Perform(c3, "faceto", player);

			PlayerPerform("say", "哦？那我也会会你。.");
			PlayerPerform("pause", 2);
			PlayerPerform("block", 1);

		trg1 = 4;

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