// 峰火雷
int Rule = 3;
int RoundTime = 15;
int PlayerSpawn = 50;
int PlayerSpawnDir = 90;
int PlayerWeapon = 32;
int PlayerWeapon2 = 15;
int PlayerHP = 8000;

OnStart()
{
	AddNPC("npc12_01");
	AddNPC("npc12_02");
	AddNPC("npc12_03");
	AddNPC("npc12_04");
}
int player;
int trg0;
int trg1;
int trg2;
int k1;
int k2;
int k3;
int win;
int obj1;
int obj2;
int obj3;
int timer0;
int timer1;
int gameover; 
REadd()
{
	int p = GetChar("刀恶");
	SetTarget(0, "char",p);
	SetTarget(1, "waypoint",51);
	if (Distance(0, 1) > 100)
	{
		ChangeBehavior(p, "attacktarget", 1);
	}
}

OnUpdate()
{	
	int player = GetAnyChar("player");
	int now = GetGameTime();
	if (trg0 == 0)
	{
		int p = GetChar("刀恶");
		int c = GetChar("剑客の杨帆东");
		int c1 = GetChar("夜猫子");
		int c2 = GetChar("无名");
		if (p > 0 && c2>=0)
		{
		
			Perform(p, "pause", 5);
			Perform(p, "say", "这个自然！！我的武器都被你拿了..我也玩不出花样！！");
			Perform(p, "pause", 5);
			Perform(p, "say", "不管如何！你都要守住我跟这个药鼎..三个药鼎至少要保住一个，明白了吗？");
			Perform(p, "pause", 5);
			Perform(p, "say", "大爷你要注意！！要练那么多的解药...并不是容易的事！！");
			Perform(p, "faceto", player);
			
			PlayerPerform("block", 0);
			PlayerPerform("pause", 2);
			PlayerPerform("say", "希望如此！！");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "我知道了！！我会保护你跟药鼎的！！只是不要给我玩花样！");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "这个我明白！！");
			PlayerPerform("pause", 3);
			PlayerPerform("block", 1);
		
			trg0 = 1;
			timer0 = now + 15;
		}
	}
	if (trg0 == 1 && now > timer0)
	{
		
		ChangeBehavior(c, "patrol", 24, 21, 1, 11, 26, 0, 58, 46, 41, 42);			
		Perform(c, "pause", 5);
		Perform(c, "say", "好！那我们走吧！！去找他们的鼎！");
		Perform(c, "pause", 5);
		Perform(c, "say", "...不理人吗？？？");
		Perform(c, "pause", 3);
		Perform(c, "say", "另外这一位是...？？");
		Perform(c, "pause", 5);
		Perform(c, "say", "啊！虽然不知为什么！！你们可帮我，是最好啦！敌人的敌人就是朋友！");
		Perform(c, "faceto", c1);
			
		ChangeBehavior(c1, "follow", c);			
		Perform(c1, "pause", 2);
		Perform(c1, "say", "出发咯！！");
		Perform(c1, "pause", 5);
		Perform(c1, "say", "不管如何！去弄翻他们的鼎就对了！！");
		Perform(c1, "pause", 8);
		Perform(c1, "say", "嘻嘻！！我是来报仇的..上次让他在金华城跑掉了！！");
		Perform(c1, "pause", 3);
		Perform(c1, "faceto", c);

		ChangeBehavior(c2, "patrol", 51);			
		Perform(c2, "say", "抱歉！！我要自己一个人行动！！再见了！！");
		Perform(c2, "pause", 18);
		Perform(c2, "faceto", c);

		trg0 = 2;
		timer0 = now + 18;
	}
	REadd();
	if (trg0 == 2 && now > timer0)
	{
		SetTarget(0, "char",player);
		SetTarget(1, "char",c2);
		if (GetEnemy(c2) == player)
		{
			if (Distance(0, 1) < 200 && k1 == 0)
			{
				Perform(c2, "say", "纳命来吧！！");
				Perform(c2, "pause", 5);
				Perform(c2, "say", "对不起了！！这一次我一定要贯彻任务！！");
				Perform(c2, "pause", 3);
				Perform(c2, "faceto", player);
			
				Perform(c, "pause", 8);

				Perform(c1, "pause", 8);

				PlayerPerform("block", 0);
				PlayerPerform("pause", 3);
				PlayerPerform("say", "...！！");
				PlayerPerform("pause", 5);
				PlayerPerform("say", "你怎么又来了？");
				PlayerPerform("block", 1);
				
				k1 = 1;
			}
		}
		if(GetHP(c2) <= 2500 && k1 == 1)
		{
				Perform(c2, "use", 35);
				Perform(c2, "say", "你不要离开这里，以免...");
				Perform(c2, "pause", 3);
				Perform(c2, "say", "不了！！够了！！请仔细听完我的话！！");
				Perform(c2, "pause", 5);
				Perform(c2, "say", "哈哈！！果然令人佩服的实力！！");
				Perform(c2, "faceto", player);
			
				ChangeBehavior(c, "patrol", 58, 46, 41, 42, 50);			
				Perform(c, "pause", 15);

				Perform(c1, "pause", 15);

				PlayerPerform("block", 0);
				PlayerPerform("say", "怎么回事？是谁？给我滚出来啊！！");
				PlayerPerform("pause", 3);
				PlayerPerform("say", "...！！怎么了！！？");
				PlayerPerform("pause", 8);
				PlayerPerform("say", "还要再打吗？");
				PlayerPerform("pause", 3);
				PlayerPerform("block", 1);
				
				k1 = 2;
				win++;
		} 
		if(GetHP(c) <= 0 && k2 == 0)
		{
			Say(c,"可恶....我不甘...心...啊！！");
			k2++;
			win++;
		} 
		if(GetHP(c1) <= 0 && k3 == 0)
		{
			Say(c1,"又被打败了！！可恶！！");
			k3++;
			win++;
		} 
	}
	if (obj1 == 0)
	{
		SetTarget(0, "char",c);
		SetTarget(1, "waypoint",50);
		SetTarget(2, "waypoint",51);
		if (Distance(0, 1) < 50)
		{
			ChangeBehavior(c, "attacktarget", 2, 120);
			obj1 = 1;
			timer0 = now + 60;
		}
	}
	if (obj1 == 1 && now > timer0)
	{
		ChangeBehavior(c, "patrol", 58, 46, 41, 42, 50);
		obj1 = 0;
	}
	if (obj2 == 0)
	{
		SetTarget(0, "char",c);
		SetTarget(1, "waypoint",46);
		SetTarget(2, "waypoint",47);
		if (Distance(0, 1) < 50)
		{
			ChangeBehavior(c, "attacktarget", 2, 120);
			obj2 = 1;
			timer0 = now + 60;
		}
	}
	if (obj2 == 1 && now > timer0)
	{
		if(k1==2)
		{
			ChangeBehavior(c, "patrol", 41, 42, 50, 58, 46);
		}else
		{ChangeBehavior(c, "patrol", 41, 42, 58, 46);}
		obj2 = 0;
	}
	if (obj3 == 0)
	{
		SetTarget(0, "char",c);
		SetTarget(1, "waypoint",42);
		SetTarget(2, "waypoint",39);
		if (Distance(0, 1) < 50)
		{
			ChangeBehavior(c, "attacktarget", 2, 120);
			obj3 = 1;
			timer0 = now + 60;
		}
	}
	if (obj3 == 1 && now > timer0)
	{
		if(k1==2)
		{
			ChangeBehavior(c, "patrol", 50, 58, 46, 41, 42);
		}else
		{
			ChangeBehavior(c, "patrol", 58, 46, 41, 42);
		}
		obj3 = 0;
	}
	if (win == 3)
	{
		if (gameover != 1)
		{
			gameover = 1;
			timer1 = now + 2; 
		}
	}
	if (gameover!=-1 && p>=0 && GetHP(p)<=0)
	{			
		gameover = -1;
		timer1 = now + 2; 
	}	
	if ((gameover==1 || gameover==-1) && now>timer1)
	{
		GameOver(gameover);
		gameover = 2;
	}
}
