// 斩皇宫
int Rule = 1;
int RoundTime = 700;
int PlayerSpawn = 4;
int PlayerSpawnDir = 0;
int PlayerWeapon = 6;
int PlayerWeapon2 = 0;
int PlayerHP = 6000;

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 gameover = 0;
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 now = GetGameTime();



	if (trg0 == 0)
	{
					
                      
                        PlayerPerform("block", 0);
                        PlayerPerform("say", "这皇宫在哪？还是前去看看。");
                        PlayerPerform("pause", 2);
                        PlayerPerform("say", "（我竟然在金华惹起事来，会不会打草惊蛇…）");
                        PlayerPerform("pause", 2);
                        PlayerPerform("say", "此次前来，是为了刺杀皇宫内奸。");
                        PlayerPerform("block", 1);
                        
                        trg0 = 1;
			timer0 = now + 8;
		}      

	if (trg0 == 1 && now>timer0)
	{
           AddNPC("2关1");
           AddNPC("2关2");
           AddNPC("2关3");
           AddNPC("2关4");
                        PlayerPerform("block", 0);
                        PlayerPerform("say", "有动静！。");
                        PlayerPerform("block", 1);
		trg0++;
	}
	if (trg0 == 2)
	{
		c1 = GetChar("皇宫侍卫1"); 
		c2 = GetChar("皇宫侍卫2");
		c3 = GetChar("皇宫侍卫3");
		c4 = GetChar("皇宫侍卫4");
		if (c1>=0 && GetEnemy(c1)==player)
		{



			Perform(c1, "say", "杀了他。！！");
			Perform(c1, "pause", 4);
			Perform(c1, "say", "阿，可恶，自己来送死。");
			Perform(c1, "pause", 3);
			Perform(c1, "say", "你是谁…竟敢乱闯…");
			Perform(c1, "faceto", player);

			Perform(c2, "pause", 7);

			Perform(c3, "pause", 7);

			Perform(c4, "pause", 7);

			PlayerPerform("block", 0);
                        PlayerPerform("say", "哦，是吗？。那看看是谁死吧。"); 
			PlayerPerform("pause", 4);
                        PlayerPerform("say", "杀 手——————伊     人     君"); 
			PlayerPerform("pause", 2);
			PlayerPerform("block", 1);
			trg0++;
		}
	}



	if (trg0 == 3)
	{
		c1 = GetAnyChar("皇宫侍卫1"); 
		c2 = GetAnyChar("皇宫侍卫2");
		c3 = GetAnyChar("皇宫侍卫3");
		c4 = GetAnyChar("皇宫侍卫4");
if (GetHP(c1)<=0 && GetHP(c2)<=0 && GetHP(c3)<=0 && GetHP(c4)<=0  && player>=0 && GetHP(player)>0)
		{
			RemoveNPC(c1);
			RemoveNPC(c2);
			RemoveNPC(c4);
			RemoveNPC(c3);
		PlayerPerform("use", 16);
		PlayerPerform("use", 16);
		PlayerPerform("use", 16);
		PlayerPerform("use", 34);
                       PlayerPerform("say", "..........."); 
			trg0 = 4;
			timer0 = now + 3;
		}
	}  


	if (trg0 == 4 && now>timer0)
	{
		        AddNPC("2关");
		        trg0++;
	} 
if (trg1 == 0)
	{
		c = GetChar("耶律总官"); 
		if (c>=0 && GetEnemy(c)==player)
		{

			Perform(c, "say", "哼。...");
			Perform(c, "pause", 4);
			Perform(c, "say", "哦，知道是任务。。不过你到底有多大能耐，哼  ");
			Perform(c, "pause", 3);
			Perform(c, "say", "你就是伊人君… 我们从没跟你打过交道，但是你总是没事找事。 ");
			Perform(c, "faceto", player);

			PlayerPerform("block", 0);
                        PlayerPerform("say", "切磋一下就知道了。。"); 
			PlayerPerform("pause", 4);
                        PlayerPerform("say", "对不起，这是任务。"); 
			PlayerPerform("pause", 2);
			PlayerPerform("block", 1);
			trg1++;timer0 = now + 8;
		}
	}

	if (trg1 == 1 && now>timer0)
	{
		        AddNPC("2关5");AddNPC("2关6");AddNPC("2关7");
		        trg1++;
	} 

        if (trg1 == 2)
        {
                c = GetAnyChar("耶律总官");      
                if (c>=0 && GetHP(c)<2000)
                {
                        Perform(c, "say", "好身手！！！");
                        trg1 = 3;
		}
	} 

        if (trg1 == 3)
        {
                c = GetAnyChar("耶律总官");      
                if (c>=0 && GetHP(c)<=0)
                {
		        gameover = 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;
	}
}
     
