// よ皚
int Rule = 1;
int RoundTime = 99;
int PlayerSpawn = 5;
int PlayerSpawnDir = 340;
int PlayerWeapon = 9;
int PlayerWeapon2 = 47;
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 trg8 = 0;
int trg9 = 0;
int trg10 = 0;
int timer1 = 0;
int timer2 = 0;
int timer3 = 0;
int timer4 = 0;
int gameover = 0;
int reborn = -1;
string rebornName;


OnStart()
{
	AddNPC("npcX0601");
}

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

	if (trg0 == 0)
	{
		c = GetAnyChar("高寄萍");
		if (c>=0 && GetHP(player)>0)
		{
			Perform(c, "follow", player);
			Perform(c, "aggress");
			Perform(c, "say", "jint今天给你特别训练!");
			Perform(c, "pause", 4);
			Perform(c, "say", "如果不是堂堂正正的打败我可是通不过哦!");
			Perform(c, "use", 9);
			Perform(c, "faceto", player);

			PlayerPerform("use", 9);
			PlayerPerform("block", 0);
			PlayerPerform("pause", 13);
			PlayerPerform("block", 1);

			trg0 = 1;
		}
	}

	if (trg1 == 0)
	{
		c = GetAnyChar("高寄萍");
		if (c>=0 && GetEnemy(c)==player && GetHP(player)>0)
		{
			Perform(c, "follow", player);
			Perform(c, "say", "让我看看你真正的实力吧!");
			Perform(c, "faceto", player);

			trg1 = 1;
			timer3 = now + 10;
		}
	}
	if (trg1 == 1 && now>timer3)
	{
		c = GetAnyChar("高寄萍");
		if (c>=0 && GetEnemy(c)!=player && GetHP(player)>0)
		{
			ChangeBehavior(c, "patrol", 1,3,5,7,9,11,13,15,16,17);
			Perform(c, "say", "你只会躲避么？");
			Perform(c, "faceto", player);

			trg1 = 2;
		}
	}
	if (trg1 == 2)
	{
		c = GetAnyChar("高寄萍");
		if (c>=0 && GetEnemy(c)==player && GetHP(player)>0)
		{
			Perform(c, "follow", player);
			Perform(c, "say", "认真些吧!");
			Perform(c, "faceto", player);

			trg1 = 3;
			timer4 = now + 10;
		}
	}
	if (trg1 == 3 && now>timer4)
	{
		c = GetAnyChar("高寄萍");
		if (c>=0 && GetEnemy(c)!=player && GetHP(player)>0)
		{
			ChangeBehavior(c, "patrol", 1,3,5,7,9,11,13,15,16,17);
			Perform(c, "say", "………………或许当初应该把你训练成飞贼!");
			Perform(c, "faceto", player);

			trg1 = 0;
		}
	}

	if (trg2 == 0)
	{
		c = GetAnyChar("高寄萍");
		if (c>=0 && GetHP(c)>GetMaxHP(c)/2 && GetHP(player)>0 && GetHP(player)<=GetMaxHP(player)/5)
		{
			Perform(c, "follow", player);
			Perform(c, "block", 0);
			Perform(c, "aggress");
			Perform(c, "say", "好吧，再来一次，这次要认真些了!");
			Perform(c, "pause", 16);
			Perform(c, "say", "一对一你都胜不了，还指望杀范旋么？");
			Perform(c, "pause", 4);
			Perform(c, "block", 1);
			Perform(c, "faceto", player);

			PlayerPerform("block", 0);
			PlayerPerform("use", 15);
			PlayerPerform("pause", 10);
			PlayerPerform("say", "再给我一次机会吧!");
			PlayerPerform("pause", 16);
			PlayerPerform("block", 1);
			PlayerPerform("say", "不行了，你太强了，句多弓虽………………");

			trg2 = 1;
		}
	}

	if (trg3 == 0)
	{
		c = GetAnyChar("高寄萍");
		if (c>=0 && GetHP(c)>0  && GetHP(c)<=(GetMaxHP(c)/4)*3 && GetHP(player)>0)
		{
			Perform(c, "follow", player);
			Perform(c, "use", 7);
			Perform(c, "use", 9);
			Perform(c, "use", 5);
			Perform(c, "use", 8);
			Perform(c, "use", 4);
			Perform(c, "use", 19);
			Perform(c, "use", 3);
			Perform(c, "block", 0);
			Perform(c, "say", "我要认真战斗了哦!");
			Perform(c, "pause", 1);
			Perform(c, "say", "也许你真能完成这个任务!");
			Perform(c, "block", 1);
			Perform(c, "faceto", player);

			PlayerPerform("block", 0);
			PlayerPerform("pause", 7);
			PlayerPerform("block", 1);
			trg3 = 1;
		}
	}
	if (trg3 == 1)
	{
		c = GetAnyChar("高寄萍");
		if (c>=0 && GetHP(c)>0  && GetHP(c)<=GetMaxHP(c)/2 && GetHP(player)>0)
		{
			Perform(c, "follow", player);
			Perform(c, "say", "为了特训，我把快活林的人都叫来了哦，嘻嘻，大家一起上吧!");
			Perform(c, "pause", 6);
			Perform(c, "say", "好了，单挑游戏结束,团P开始了!");
			Perform(c, "faceto", player);

			PlayerPerform("say", "汗………………");
			PlayerPerform("pause", 15);
			PlayerPerform("say", "………………");
			PlayerPerform("pause", 3);

			trg3 = 2;
		}
	}
	if (trg3 == 2)
	{
		c = GetAnyChar("高寄萍");
		if (c>=0)
		{
			AddNPC("npcX0605");
			AddNPC("npcX0604");
			AddNPC("npcX0603");
			AddNPC("npcX0602");

			trg3 = 3;
		}
	}

	if (trg4==0 && trg3==3)
	{
		c2 = GetAnyChar("叶翔");
		if (c2>=0 && GetHP(c2)<=0)
		{
			reborn = c2;
			rebornName = "npcX0602";
			trg4 = 1;
			timer2 = now + 5;
		}
		c3 = GetAnyChar("小何");
		if (c3>=0 && GetHP(c3)<=0)
		{
			reborn = c3;
			rebornName = "npcX0603";
			trg4 = 1;
			timer2 = now + 5;
		}
		c4 = GetAnyChar("凤凰");
		if (c4>=0 && GetHP(c4)<=0)
		{
			reborn = c4;
			rebornName = "npcX0604";
			trg4 = 1;
			timer2 = now + 5;
		}
		c5 = GetAnyChar("石群");
		if (c5>=0 && GetHP(c5)<=0)
		{
			reborn = c5;
			rebornName = "npcX0605";
			trg4 = 1;
			timer2 = now + 5;
		}
	}				
	if (trg4==1 && now>timer2)
	{
		RemoveNPC(reborn);
		timer2 = now + 2;
		trg4 = 2;
	}
	if (trg4==2 && now>timer2)
	{
		AddNPC(rebornName);
		trg4 = 0;
	}

	if (trg5==0)
	{
		c = GetAnyChar("高寄萍");
		if (c>=0 && GetHP(c)>0 && GetHP(c)<=GetMaxHP(c)/10 && GetHP(player)>0)
		{
			Perform(c, "aggress");
			Perform(c, "block", 0);
			Perform(c, "pause", 4);
			Perform(c, "say", "走，我们回去庆贺一下吧!");
			Perform(c, "pause", 12);
			Perform(c, "say", "担心你嘛，没想到你都练到这种成度，杀范旋指日可待了!");
			Perform(c, "pause", 8);
			Perform(c, "say", "好了，训练到此结束，你通过了，嘻嘻!");
			Perform(c, "block", 1);
			Perform(c, "faceto", player);

			PlayerPerform("block", 0);
			PlayerPerform("pause", 20);
			PlayerPerform("say", "你们啊，连我也信不过了么!");
			PlayerPerform("pause", 10);
			PlayerPerform("say", "真有你们的，用不着都来吧，呵呵呵!");
			PlayerPerform("pause", 6);
			PlayerPerform("block", 1);

			Perform(c5, "use", 9);
			Perform(c4, "use", 9);
			Perform(c3, "use", 9);
			Perform(c2, "use", 9);

			trg5 = 1;
			timer1 = now + 25;

		}
	}

	if (trg6==0 && trg5==1)
	{
		RemoveNPC(c5);
		RemoveNPC(c4);
		RemoveNPC(c3);
		RemoveNPC(c2);

		trg6 = 1;
		gameover = 1;
	}
	if (trg6==1)
	{
		trg6 = 0;
	}

	if (trg7 == 0)
	{
		c = GetAnyChar("叶翔");
		if (c>=0 && GetEnemy(c)==player && GetHP(player)>0)
		{
			Perform(c, "follow", player);

			trg7 = 1;
		}
	}
	if (trg7 == 1)
	{
		c = GetAnyChar("叶翔");
		if (c>=0 && GetEnemy(c)!=player && GetHP(player)>0)
		{
			ChangeBehavior(c, "patrol", 1,3,5,7,9,11,13,15,16,17);

			trg7 = 2;
		}
	}
	if (trg7 == 2)
	{
		c = GetAnyChar("叶翔");
		if (c>=0 && GetEnemy(c)==player && GetHP(player)>0)
		{
			Perform(c, "follow", player);

			trg7 = 3;
		}
	}
	if (trg7 == 3)
	{
		c = GetAnyChar("叶翔");
		if (c>=0 && GetEnemy(c)!=player && GetHP(player)>0)
		{
			ChangeBehavior(c, "patrol", 17,16,15,13,11,9,7,5,3,1);

			trg7 = 0;
		}
	}

	if (trg8 == 0)
	{
		c = GetAnyChar("小何");
		if (c>=0 && GetEnemy(c)==player && GetHP(player)>0)
		{
			Perform(c, "follow", player);

			trg8 = 1;
		}
	}
	if (trg8 == 1)
	{
		c = GetAnyChar("小何");
		if (c>=0 && GetEnemy(c)!=player && GetHP(player)>0)
		{
			ChangeBehavior(c, "patrol", 17,16,15,13,11,9,7,5,3,1);

			trg8 = 2;
		}
	}
	if (trg8 == 2)
	{
		c = GetAnyChar("小何");
		if (c>=0 && GetEnemy(c)==player && GetHP(player)>0)
		{
			Perform(c, "follow", player);

			trg8 = 3;
		}
	}
	if (trg8 == 3)
	{
		c = GetAnyChar("小何");
		if (c>=0 && GetEnemy(c)!=player && GetHP(player)>0)
		{
			ChangeBehavior(c, "patrol", 1,3,5,7,9,11,13,15,16,17);

			trg8 = 0;
		}
	}

	if (trg9 == 0)
	{
		c = GetAnyChar("凤凰");
		if (c>=0 && GetEnemy(c)==player && GetHP(player)>0)
		{
			Perform(c, "follow", player);

			trg9 = 1;
		}
	}
	if (trg9 == 1)
	{
		c = GetAnyChar("凤凰");
		if (c>=0 && GetEnemy(c)!=player && GetHP(player)>0)
		{
			ChangeBehavior(c, "patrol", 1,3,5,7,9,11,13,15,16,17);

			trg9 = 2;
		}
	}
	if (trg9 == 2)
	{
		c = GetAnyChar("凤凰");
		if (c>=0 && GetEnemy(c)==player && GetHP(player)>0)
		{
			Perform(c, "follow", player);

			trg9 = 3;
		}
	}
	if (trg9 == 3)
	{
		c = GetAnyChar("凤凰");
		if (c>=0 && GetEnemy(c)!=player && GetHP(player)>0)
		{
			ChangeBehavior(c, "patrol", 17,16,15,13,11,9,7,5,3,1);

			trg9 = 0;
		}
	}

	if (trg10 == 0)
	{
		c = GetAnyChar("石群");
		if (c>=0 && GetEnemy(c)==player && GetHP(player)>0)
		{
			Perform(c, "follow", player);

			trg10 = 1;
		}
	}
	if (trg10 == 1)
	{
		c = GetAnyChar("石群");
		if (c>=0 && GetEnemy(c)!=player && GetHP(player)>0)
		{
			ChangeBehavior(c, "patrol", 17,16,15,13,11,9,7,5,3,1);

			trg10 = 2;
		}
	}
	if (trg10 == 2)
	{
		c = GetAnyChar("石群");
		if (c>=0 && GetEnemy(c)==player && GetHP(player)>0)
		{
			Perform(c, "follow", player);

			trg10 = 3;
		}
	}
	if (trg10 == 3)
	{
		c = GetAnyChar("石群");
		if (c>=0 && GetEnemy(c)!=player && GetHP(player)>0)
		{
			ChangeBehavior(c, "patrol", 1,3,5,7,9,11,13,15,16,17);

			trg10 = 0;
		}
	}


	if (gameover!=-1 && GetHP(player)<=0)
	{
		gameover = -1;
		timer1 = now + 2; 
	}
	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;
	}
}
