//  蝴蝶谷
int Rule = 1;
int RoundTime = 19;
int PlayerSpawn = 12;
int PlayerSpawnDir = 300;
int PlayerWeapon = 24;
int PlayerWeapon2 = 22;
int PlayerHP = 1500;

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 trg12 = 0;
int trg13 = 0;
int trg14 = 0;
int trg15 = 0;
int trg16 = 0;
int trg17 = 0;
int trg18 = 0;
int trg19 = 0;
int trg20 = 0;
int trg21 = 0;
int trg22 = 0;
int trg23 = 0;
int trg24 = 0;
int timer0 = 0;
int timer1 = 0;
int timer2 = 0;
int timer3 = 0;
int timer4 = 0;
int timer5 = 0;
int gameover = 0;

OnStart()
{
	AddNPC("npc06_01");
	AddNPC("npc06_02");
	AddNPC("npc06_03");
}

OnUpdate()
{
	int player = GetAnyChar("player");
	if (player < 0)
	{
		return 0;
	}
	if (gameover == 2)
	{
		return 0;
	}
	
	int c;
	int c2;
	int c3;
	int c4;
	int c5;
	int c6;
	int c7;
	int c8;
	int c9;
	int c10;
	int now = GetGameTime();

	if (trg0 == 0)
	{
		c = GetAnyChar("蝴蝶谷·钱多多");
		c2 = GetAnyChar("蝴蝶谷·雪凤凰");
		if (c>=0)
		{
			Perform(c2, "pause", 99999);

			Perform(c, "pause", 99999);

			trg0 = 1;
		}
	}
	if (trg0 == 1)
	{
		c = GetAnyChar("蝴蝶谷·钱多多");
		c2 = GetAnyChar("蝴蝶谷·雪凤凰");
		c3 = GetAnyChar("水云轩の蝶仙");
		SetTarget(0, "char", c);
		SetTarget(1, "char", player);
		if (c>=0 && Distance(0, 1)<250)
		{

			StopPerform(c);
			StopPerform(c2);

			Perform(c3, "pause", 99999);
			Perform(c3, "say", "老牛要考验你，你可不能让我失望、给人家看笑话呀！");
			Perform(c3, "pause", 2);
			Perform(c3, "say", "你早些回来啊，我和玉箫、霜降、天魂他们等你的。");
			Perform(c3, "pause", 2);
			Perform(c3, "say", "谁是“鬼精灵”呀？就你话多，我没耍脾气心里不舒服是吧？");
			Perform(c3, "pause", 2);
			Perform(c3, "say", "别这样，给人听见多不好呀！不害臊、没羞你。");
			Perform(c3, "pause", 4);
			Perform(c3, "say", "不要说了，一切都是我自愿的，没有什么“后悔”、“不后悔”。");
			Perform(c3, "pause", 4);
			Perform(c3, "faceto", c2);

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

			Perform(c, "pause", 99999);
                        Perform(c, "say", "雪凤凰，你准备一下吧！武学上的较量可不能放水的喔！");
                        Perform(c, "say", "很失礼呀，不过还请你多多指教，好吗？");
                        Perform(c, "say", "废话不多说，受冥王所托、考验你的剑法。");
			Perform(c, "pause", 4);
			Perform(c, "say", "至于我身边的这位呢，想必你也有所耳闻，他就是管理雪凤凰。");
			Perform(c, "pause", 16);
			Perform(c, "say", "你好，化蝶！我是蝴蝶谷的钱多多，这个你是知道的。");
			Perform(c, "pause", 6);
			Perform(c, "faceto", player);
                          Perofrm( "use", 3);
                        Perofrm( "use", 34);
                        Perofrm( "use", 5);
                        Perofrm( "use", 8);
			PlayerPerform("block", 0);
			PlayerPerform("pause", 5);
			PlayerPerform("say", "别、别、别，大小姐。你可别耍脾气，那会出人命的，你先回水云轩吧！");
			PlayerPerform("pause", 9);
			PlayerPerform("say", "唉，想不到你这个“鬼精灵”会对我这么死心塌地的，难得哦。");
			PlayerPerform("pause", 4);
			PlayerPerform("say", "谢谢你能够理解我，我能和你在一起真是好福气。");
			PlayerPerform("pause", 16);
                         PlayerPerform("say", "如果当初你留在销魂谷，而不随我加入冥界！也不会沦落到今天这个地步。");
                        PlayerPerform("say", "雪儿，跟我到了这里你会后悔吗？真是委屈你了、傻丫头。");
			PlayerPerform("say", "呵呵呵，好一个风景秀丽的蝴蝶谷，不知道谷主钱多多会想出什么鬼主意整我？");
			PlayerPerform("pause", 2);
			PlayerPerform("block", 1);

			timer0 = now + 22;
			timer2 = now + 26;
			trg0 = 2;
			trg1 = 1;
		}
	}

	if (trg0 == 2 && now>timer0)
	{
		c = GetAnyChar("蝴蝶谷·钱多多");
		if (c>=0)
		{
			RemoveNPC(c);

			trg0 = 3;
		}
	}

	if (trg1 == 1 && now>timer2)
	{
		c = GetAnyChar("水云轩の蝶仙");
		if (c>=0)
		{
			RemoveNPC(c);

			trg1 = 2;
		}
	}
	if (trg1 == 2)
	{
		c = GetAnyChar("蝴蝶谷·雪凤凰");
		if (c>=0)
		{

			StopPerform(c);

			PlayerPerform("block", 0);
			PlayerPerform("use", 9);
			PlayerPerform("say", "凤凰，讨教了。你也是用剑的，我们正好切磋一下。");
			PlayerPerform("pause",5);
			PlayerPerform("block", 1);

			trg1 = 3;
		}
	}
	if (trg1 == 3)
	{
		c = GetAnyChar("蝴蝶谷·雪凤凰");
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{
			Perform(c, "use", 16);
			Perform(c, "say", "化蝶，还坚持得住吗？不行就放弃吧！");

			PlayerPerform("say", "可恶，怎么会这样呢？为了雪儿，不能言败。");
			PlayerPerform("pause", 5);
			trg1 = 4;
		}	
	}
	
	if (trg1 == 4)
	{
		AddNPC("npc06_04");
		AddNPC("npc06_05");
		
		trg1 = 5;
	}
	if (trg1 == 5)
	{
		c = GetAnyChar("蝴蝶谷·雪凤凰");
		c2 = GetAnyChar("蝴蝶谷·左护卫");
		c3 = GetAnyChar("蝴蝶谷·右护卫");

		if (c>=0 && GetHP(c)<=0)
		{
			Perform(c3, "use", 35);

			Perform(c2, "use", 35);

			Say(c, "佩服，化蝶。你果然是【冥界】的得力助手，我死也甘心了。");


			PlayerPerform("say", "抱歉，兄弟。我无意取你性命，实在是你们逼我甚多呀。");
			PlayerPerform("pause", 5);

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

}
