//  峨嵋山
int Rule = 1;
int RoundTime = 90;
int PlayerSpawn = 122;
int PlayerSpawnDir = 90;
int PlayerWeapon = 15;
int PlayerWeapon2 = 36;
int PlayerHP = 5000;

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 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 timer9 = 0;
int timer10 = 0;
int timer11 = 0;
int timer12 = 0;
int timer13 = 0;
int timer14 = 0;
int timer15 = 0;
int timer16 = 0;
int timer17 = 0;
int timer18 = 0;
int gameover = 0;
int now = 0;


OnStart()
{
	AddNPC("npc-03-00");
	AddNPC("npc-03-01");
	AddNPC("npc-03-02");
	AddNPC("npc-03-03");
	AddNPC("npc-03-04");
	AddNPC("npc-03-05");
	AddNPC("npc-03-06");
	AddNPC("npc-03-07");
}


OnUpdate()
{
	int player = GetAnyChar("player");
	if (player < 0)
	{
		return 0;
	}
	if (gameover == 2)
	{
		return 0;
	}
	int now = GetGameTime();

        int c;
	int c1;
	int c2;
        int c3;
        int c4;
        int c5;
        int c6;

        if (trg0 == 0)
        {          
                c = GetAnyChar("履面使");         
                if (c>=0)
                {         
                        Perform(c, "say", "恩！！！");
                        Perform(c, "pause", 6);
                        Perform(c, "say", "一起走……");
                        Perform(c, "pause", 10);
                        Perform(c, "say", "可惜这里马上要面临一场血斗了……");
                        Perform(c, "pause", 6);
			Perform(c, "faceto", player);			
			                        
			PlayerPerform("block", 0);
                        PlayerPerform("say", "好，动手吧！！！");
                        PlayerPerform("pause", 2);
                        PlayerPerform("say", "这样，都往左走，再去右边！！！");
                        PlayerPerform("pause", 2);
                        PlayerPerform("say", "恩，我也是这么想的……");
                        PlayerPerform("pause", 4);
                        PlayerPerform("say", "履面使，你说走那条比较好…………");
                        PlayerPerform("pause", 2); 
                        PlayerPerform("say", "此次上山有两条路……");
                        PlayerPerform("pause", 2);
                        PlayerPerform("say", "恩……");
                        PlayerPerform("pause", 4);
                        PlayerPerform("say", "不愧是峨嵋山！！");
                        PlayerPerform("pause", 2);
                        PlayerPerform("say", "好巍峨！！");
                        PlayerPerform("pause", 2);
                        PlayerPerform("block", 1);
                        
                        trg0 = 1;     
		}
	}  
	if (trg1==0)
	{
		c = GetChar("峨嵋弟子-丁");
		c2 = GetChar("峨嵋弟子-戊");
		c3 = GetChar("峨嵋弟子-己");
		c4 = GetChar("峨嵋弟子-甲");
		c1 = GetChar("履面使"); 
		c5 = GetChar("峨嵋弟子-乙");
		c6 = GetChar("峨嵋弟子-丙");
		if (c>=0 && GetEnemy(c)==player)
		{
			ChangeBehavior(c4, "kill", player);  
			Perform(c4, "pause", 2);
			Perform(c4, "say", "那就看我刀剑同不同意了！！！");
			Perform(c4, "pause", 2);
			Perform(c4, "say", "………");
			Perform(c4, "pause", 4);
			Perform(c4, "say", "前方是峨嵋山了，外人不得进入！！！");
			Perform(c4, "faceto", player);

			ChangeBehavior(c5, "kill", player);  
			Perform(c5, "pause", 10);

			ChangeBehavior(c6, "kill", player);  
			Perform(c6, "pause", 10);

                        PlayerPerform("say", "哼！！！"); 
			PlayerPerform("pause", 6);
                        PlayerPerform("say", "滚开！！"); 
			PlayerPerform("pause", 2);

			ChangeBehavior(c, "kill", player);  
			Perform(c, "pause", 10);

			ChangeBehavior(c2, "kill", player);  
			Perform(c2, "pause", 10);

			ChangeBehavior(c3, "kill", player);  
			Perform(c3, "pause", 10);

			trg1 = 1;
		}
	}
	if (trg1 == 1)
	{
		c = GetAnyChar("峨嵋弟子-丁");
		c1 = GetAnyChar("履面使"); 
		c2 = GetAnyChar("峨嵋弟子-戊");
		c3 = GetAnyChar("峨嵋弟子-己");
		c4 = GetAnyChar("峨嵋弟子-甲");
		c5 = GetAnyChar("峨嵋弟子-乙");
		c6 = GetAnyChar("峨嵋弟子-丙");
		if (GetHP(c)<=0 && GetHP(c2)<=0 && GetHP(c3)<=0 && GetHP(c4)<=0 && GetHP(c5)<=0 && GetHP(c6)<=0 && player>=0 && GetHP(player)>0)
		{
			RemoveNPC(c);
			RemoveNPC(c2);
			RemoveNPC(c6);
			RemoveNPC(c5);
			RemoveNPC(c4);
			RemoveNPC(c3);
			trg1 = 2;
			timer2 = now + 3;
		}
	}  
	if (trg1 == 2 && now>timer2)
	{
		        AddNPC("npc-03-11");
		        AddNPC("npc-03-12");
		        AddNPC("npc-03-13");
		        AddNPC("npc-03-10");
		        AddNPC("npc-03-08");
		        AddNPC("npc-03-09");
		        trg1 = 3;
	}   
	if (trg1 == 3)
	{
		c = GetChar("峨嵋男弟子-甲");
		c1 = GetChar("履面使"); 
		c2 = GetChar("峨嵋男弟子-乙");
		c3 = GetChar("峨嵋男弟子-丙");
		c4 = GetChar("峨嵋女弟子-甲");
		c5 = GetChar("峨嵋女弟子-乙");
		c6 = GetChar("峨嵋女弟子-丙");
		if (c>=0 && GetEnemy(c)==player)
		{
			ChangeBehavior(c, "kill", player);  
			Perform(c, "say", "大家上！！！抓住他！！！");
			Perform(c, "faceto", c1);

			Perform(c1, "say", "哼，来吧！！！");
			Perform(c1, "pause", 2);

			ChangeBehavior(c2, "kill", player);  
			Perform(c2, "pause", 3);

			ChangeBehavior(c3, "kill", player);  
			Perform(c3, "pause", 3);

			ChangeBehavior(c4, "kill", player);  
			Perform(c4, "pause", 3);

			ChangeBehavior(c5, "kill", player);  
			Perform(c5, "pause", 3);

			ChangeBehavior(c6, "kill", player);  
			Perform(c6, "pause", 3);
			trg1 = 4;
		}
	}   
	if (trg1 == 4)
	{
		c = GetAnyChar("峨嵋男弟子-甲");
		c1 = GetAnyChar("履面使"); 
		c2 = GetAnyChar("峨嵋男弟子-乙");
		c3 = GetAnyChar("峨嵋男弟子-丙");
		c4 = GetAnyChar("峨嵋女弟子-甲");
		c5 = GetAnyChar("峨嵋女弟子-乙");
		c6 = GetAnyChar("峨嵋女弟子-丙");
		if (GetHP(c)<=0 && GetHP(c2)<=0 && GetHP(c3)<=0 && GetHP(c4)<=0 && GetHP(c5)<=0 && GetHP(c6)<=0 && player>=0 && GetHP(player)>0)
		{
			RemoveNPC(c);
			RemoveNPC(c2);
			RemoveNPC(c6);
			RemoveNPC(c5);
			RemoveNPC(c4);
			RemoveNPC(c3);
			timer4 = now + 3;
			trg1 = 5;
		}
	}  
	if (trg1 == 5 && now>timer4)
	{
		        AddNPC("npc-03-14");
		        AddNPC("npc-03-17");
		        AddNPC("npc-03-16");
		        AddNPC("npc-03-15");
		        AddNPC("npc-03-19");
		        AddNPC("npc-03-18");
		        trg1 = 6;
	}   
	if (trg1 == 6)
	{
		c = GetChar("峨嵋女剑-甲");
		c1 = GetChar("履面使"); 
		c2 = GetChar("峨嵋女剑-乙");
		c3 = GetChar("峨嵋女剑-丙");
		c4 = GetChar("剑-峨嵋-甲");
		c5 = GetChar("剑-峨嵋-乙");
		c6 = GetChar("剑-峨嵋-丙");
		if (c>=0 && GetEnemy(c)==player)
		{
			ChangeBehavior(c, "kill", player);  
			Perform(c, "say", "杀了他，为大家报仇！！！");
			Perform(c, "faceto", c1);

			Perform(c1, "say", "哼，来吧！！！");
			Perform(c1, "pause", 2);

			ChangeBehavior(c2, "kill", player);  
			Perform(c2, "pause", 3);

			ChangeBehavior(c3, "kill", player);  
			Perform(c3, "pause", 3);

			ChangeBehavior(c4, "kill", player);  
			Perform(c4, "pause", 3);

			ChangeBehavior(c5, "kill", player);  
			Perform(c5, "pause", 3);

			ChangeBehavior(c6, "kill", player);  
			Perform(c6, "pause", 3);

                        PlayerPerform("say", "实力不高，口气到不小，就让你们知道什么叫厉害！！！"); 
			PlayerPerform("pause", 2);
			trg1 = 7;
		}
	}  
	if (trg1 == 7)
	{
		c = GetAnyChar("峨嵋女剑-甲");
		c1 = GetAnyChar("履面使"); 
		c2 = GetAnyChar("峨嵋女剑-乙");
		c3 = GetAnyChar("峨嵋女剑-丙");
		c4 = GetAnyChar("剑-峨嵋-甲");
		c5 = GetAnyChar("剑-峨嵋-乙");
		c6 = GetAnyChar("剑-峨嵋-丙");
		if (GetHP(c)<=0 && GetHP(c2)<=0 && GetHP(c3)<=0 && GetHP(c4)<=0 && GetHP(c5)<=0 && GetHP(c6)<=0 && player>=0 && GetHP(player)>0)
                {
			RemoveNPC(c);
			RemoveNPC(c2);
			RemoveNPC(c6);
			RemoveNPC(c5);
			RemoveNPC(c4);
			RemoveNPC(c3);
			trg1 = 8;
			timer8 = now + 3;
		}
	}  
	if (trg1 == 8 && now>timer8)
	{
		       AddNPC("npc-03-20");
		       AddNPC("npc-03-21");
		       trg1 = 9;
	}  
        if (trg3 == 0)
        {
                c = GetAnyChar("七星");      
                if (c>=0 && GetHP(c)<6000)
                {
                        Perform(c, "say", "…………");
                        trg3 = 1;
		}
	} 
        if (trg3 == 1)
        {
                c = GetAnyChar("七星");      
                if (c>=0 && GetHP(c)<2000)
                {
                        Perform(c, "say", "（他好厉害……）");
                        trg3 = 2;
		}
	}  
        if (trg2 == 0)
        {
                c = GetAnyChar("北斗");      
                if (c>=0 && GetHP(c)<6000)
                {
                        Perform(c, "say", "好身手！！！");
                        trg2 = 1;
		}
	} 
        if (trg2 == 1)
        {
                c = GetAnyChar("北斗");      
                if (c>=0 && GetHP(c)<2000)
                {
                        Perform(c, "say", "（想不到世上竟有如此高手）");
                        trg2 = 2;
		}
	}  
        if (trg4 == 0 && trg2 == 2 && trg3 == 2)
        {
                c = GetAnyChar("七星"); 
                c1 = GetAnyChar("北斗");      
                if (GetHP(c)<=0 && GetHP(c1)<=0)
                {
		        RemoveNPC(c);
		        RemoveNPC(c1);
                        trg4 = 1;
                        timer12 = now + 3;
		}
	} 
	if (trg4 == 1 && now>timer12)
	{
		        AddNPC("npc-03-22");
		        trg4 = 2;
	}  
        if (trg5 == 0)
        {
                c = GetAnyChar("峨嵋-易海兰");      
                if (c>=0 && GetHP(c)<10000)
                {
                        Perform(c, "say", "（果然厉害……）");
                        trg5 = 1;
		}
	} 
        if (trg5 == 1)
        {
                c = GetAnyChar("峨嵋-易海兰");      
                if (c>=0 && GetHP(c)<6000)
                {
                        Perform(c, "say", "（恩，我太小看他了……）");
                        trg5 = 2;
		}
	} 
        if (trg5 == 2)
        {
                c = GetAnyChar("峨嵋-易海兰");      
                if (c>=0 && GetHP(c)<4000)
                {
                        Perform(c, "say", "（可恶…………）");
                        trg5 = 3;
		}
	} 
        if (trg5 == 3)
        {
                c = GetAnyChar("峨嵋-易海兰");      
                if (c>=0 && GetHP(c)<2000)
                {
                        Perform(c, "say", "（完了…………）");
                        trg5 = 4;
		}
	} 
        if (trg5 == 4)
        {
                c = GetAnyChar("峨嵋-易海兰");      
                if (c>=0 && GetHP(c)<1000)
                {
                        Perform(c, "say", "（峨嵋要毁在我的手里了…………）");
                        trg5 = 5;
		        gameover = 1;
		}
	} 
	if (gameover!=-1 && GetHP(player)<=0)
	{
		gameover = -1;
		timer1 = now + 2; 
	}	
	if ((gameover==1 || gameover==-1) && now>timer1)
	{
		GameOver(gameover);
		gameover = 2;
	}
}


