// 飞鹏堡
int Rule = 1;
int RoundTime = 99;
int PlayerSpawn = 42;
int PlayerSpawnDir = 80;
int PlayerWeapon = 17;
int PlayerWeapon2 = 50;
int PlayerHP = 15000;

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 timer0 = 0;
int timer1 = 0;
int timer2 = 0;
int timer3 = 0;
int timer4 = 0;
int gameover = 0;
int reborn = -1;
string rebornName;

OnStart()
{
	AddNPC("npc15_09");
	AddNPC("npc15_10");
	AddNPC("npc15_11");
	AddNPC("npc15_12");

}

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

                 	PlayerPerform("block", 0);
			PlayerPerform("use", 4);
			PlayerPerform("use", 5);
			PlayerPerform("say", "（﹒﹒﹒这家伙很狡猾，我要留心。。。﹒﹒）");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "（他出了什么主意？？）");
			PlayerPerform("pause", 1);
			PlayerPerform("say", "（孙剑说三天后会找我算帐，。！）");
			PlayerPerform("block", 1);
			
			trg0 = 1;
		
	
	}


	if (trg0 == 1)
	{
		c2 = GetChar("飞城宝侍卫1");
		c3 = GetChar("飞城宝侍卫2");
		
		if (c2>=0 && GetEnemy(c2)==player)
		{
			ChangeBehavior(c3, "follow", c2);
			Perform(c2, "say", "老子看见你了。跑。。来人阿。");
			Perform(c2, "faceto", player);
			trg0 = 2;
		}
		if (c3>=0 && GetEnemy(c3)==player)
		{
			ChangeBehavior(c2, "follow", c3);
			Perform(c3, "say", "老子看见你了。跑。。来人阿。");
			Perform(c3, "faceto", player);
			trg0 = 2;
		}		
	}

	if (trg0 == 2)
	{
		c2 = GetChar("飞城宝侍卫3");
		c3 = GetChar("飞城宝侍卫4");
		
		if (c2>=0 && GetEnemy(c2)==player)
		{
			ChangeBehavior(c3, "follow", c2);
			Perform(c2, "say", "伊人君，休想从这过去。");
			Perform(c2, "faceto", player);
			trg0 = 3;
		}
		if (c3>=0 && GetEnemy(c3)==player)
		{
			ChangeBehavior(c2, "follow", c3);
			Perform(c3, "say", "这小子在这，快来帮忙！");
			Perform(c3, "faceto", player);
			trg0 = 3;
		}		
	}

      if (trg0 == 3)
	{
		c = GetAnyChar("飞城宝侍卫1");
		c3 = GetAnyChar("飞城宝侍卫2");
		c4 = GetAnyChar("飞城宝侍卫3");
		c5 = GetAnyChar("飞城宝侍卫4");		
		if (GetHP(c)<=0 && GetHP(c4)<=0 && GetHP(c3)<=0 && GetHP(c5)<=0 && player>=0 && GetHP(player)>0)
		{

	                AddNPC("npc15_06");
	                AddNPC("npc15_07");
	                AddNPC("npc15_13");
	                AddNPC("npc15_14");
			RemoveNPC(c);
			RemoveNPC(c3);
			RemoveNPC(c4);
			RemoveNPC(c5);

			trg0 = 4;
		}		
	}


	if (trg0 == 4)
	{
		c2 = GetChar("无名忍者1");
		c3 = GetChar("无名忍者2");
		
		if (c2>=0 && GetEnemy(c2)==player)
		{
			ChangeBehavior(c3, "follow", c2);
			Perform(c2, "say", "呵呵。。我只是奉命行事。。。");
			Perform(c2, "faceto", player);
			trg0 = 5;
		}
		if (c3>=0 && GetEnemy(c3)==player)
		{
			ChangeBehavior(c2, "follow", c3);
			Perform(c3, "say", "发现他了。。快来帮忙！");
			Perform(c3, "faceto", player);
			trg0 = 5;
		}		
	}


      if (trg0 == 5)
	{	
		c = GetChar("无名忍者1");
		c1 = GetChar("无名忍者2");
		c2 = GetChar("守卫1");
		c3 = GetChar("守卫2");
if (GetHP(c)<=0 && GetHP(c1)<=0 && GetHP(c2)<=0 && GetHP(c3)<=0 &&  player>=0 && GetHP(player)>0)
		{

			PlayerPerform("say", "孙剑. .又搞什么鬼，这家伙。真狡猾，我要小心的点。");


			timer0 = now + 5;
			trg0 = 6;
		}
	}




if (trg0==6 && now>timer0)
	{

              AddNPC("npc15_01");
              AddNPC("npc15_08");
		trg0 = 7;


	}


if (trg0 == 7)
	{
		c = GetChar("孙剑");
		c2 = GetChar("高寄萍");
		SetTarget(0, "char", c);
		SetTarget(1, "char", player);
		if (c>=0 && GetEnemy(c)==player && Distance(0, 1)<200)
		{


			Perform(c, "pause", 10);
			Perform(c, "say", "能不能救你老大，就看你的了。。。");
			Perform(c, "pause", 2);
			Perform(c, "say", "我狠，这是你自找的，她已经被我下了毒，如果不紧救的话，你就等着为他收尸吧。");
			Perform(c, "pause", 2);
			Perform(c, "say", "不过我看你这么忠心。就给你有个救他的机会，但那要看你有没有能耐了。");
			Perform(c, "say", "我说过三天后会找你算帐，哈哈。。想不想看看你老大死的样子阿。");
			Perform(c, "say", "呵呵，。你老大在我手中。");
			Perform(c, "pause", 2);
			Perform(c, "faceto", player);

			SetTarget(0, "waypoint", 42);
			ChangeBehavior(c2, "attacktarget", 0);
			Perform(c2, "say", "快把我送回去。。。。");
			Perform(c2, "pause", 15);
			Perform(c2,"use", 11);
			Perform(c2,"use", 12);
			Perform(c2,"use", 13);
			Perform(c2,"use", 14);
			Perform(c2,"use", 18);
			Perform(c2, "faceto", player);


			PlayerPerform("block", 0);
			PlayerPerform("say", "是。。。");
			PlayerPerform("pause", 10);
			PlayerPerform("say", "你，，你。");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "阿？老大。。");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "你。。算你狠阿。。");
			PlayerPerform("pause", 6);
			PlayerPerform("block", 1);
			
			trg0 = 8;
			timer1 = now + 10;
		}
         }




if (trg0==8 && now>timer1)
	{

              AddNPC("npc15_02");
              AddNPC("npc15_03");
              AddNPC("npc15_04");
              AddNPC("npc15_05");
	      RemoveNPC(GetAnyChar("孙剑"));


	      trg0 = 9;

	}




if (trg0 == 9)
	{
		c = GetChar("魔刀守卫1");
		SetTarget(0, "char", c);
		SetTarget(1, "char", player);
		if (c>=0 && GetEnemy(c)==player && Distance(0, 1)<200)
		{
			Perform(c, "pause", 10);
			Perform(c, "say", "伊人君。。你乖乖的为你老大收尸吧哈哈。。");

			PlayerPerform("say", "就凭你们。。哼！");
			PlayerPerform("pause", 2);

	                  trg0 = 10;

	}

}



        if(trg0 == 10)
	{
		SetTarget(0, "char", c2);
		SetTarget(1, "waypoint", 42);
		if (GetHP(c2) > 0 && Distance(0, 1) < 200)
		{
			Say(c2,"辛苦你们了...我已经成功逃离了！");
			gameover = 1;
			timer2 = now + 1;
			trg0 = 11; 
		}
		if (GetHP(c2)<=0)
		{
			Say(c2,"唉！手底下的人果然都是饭桶，要保护我回去有那么难吗？");
			gameover = -1;
			timer2 = now + 2; 
			trg0 = 11; 
		}
		if (now > timer2)
		{
			Perform(c2,"use", 13);
			Perform(c2,"use", 14);
			timer2 = now + 20; 
		} 

           }
	c = GetAnyChar("高寄萍");
	if (gameover!=-1 && c>=0 && GetHP(c)<=0)
	{			
		gameover = -1;
		timer1 = now + 2; 
	}

	if ((gameover==1 || gameover==-1) && now>timer1)
	{
		GameOver(gameover);
		gameover = 2;
	}

}
