// 洛阳城
int Rule = 5;
int RoundTime = 30;
int PlayerSpawn = 141;
int PlayerSpawnDir = 90;
int PlayerWeapon = 5;
int PlayerWeapon2 = 0;
int PlayerHP = 3500;
OnStart()
{
	AddNPC("npc19_03");
	AddNPC("npc19_02");
	AddNPC("npc19_01");
}
int player;
int trg0;
int trg1;
int trg2;
int timer0;
int timer1;
int timer2;
int timer3;
int s1;
int s2;
int s3;
int s4;
int k1;
int k2;
int k3;
int con;
int gameover; 
OnUpdate()
{	
	int player = GetAnyChar("player");
	if (player < 0)
	{
		return 0;
	}
	if (gameover == 2)
	{
		return 0;
	}
	int now = GetGameTime();
	if (trg1==0)
	{
		Perform(4, "use",19);
		Perform(4, "use",32);
		trg1=1;
	}	
	if (trg0==0)
	{
		int c = GetChar("小何");
		int p1 = GetChar("冷燕");
		if (GetHP(c) >0 && GetHP(p1)>0)
		{
			ChangeBehavior(c, "kill", player);
			Perform(c, "say", "啍啍！一趟任务下来，还能结一个相好的？看了就令我生气！");
			Perform(c, "guard", 7);
			Perform(c, "say", "啍啍！我从以前就看你不顺眼，我是不是无可救药！手底下见真章吧！");
			Perform(c, "pause", 5);
			Perform(c, "say", "那又怎样..反正事情已发生了，我去解决这一切就好了！");
			Perform(c, "pause", 5);
			Perform(c, "say", "啍啍！多事的家伙，我不是说我会善后，没你插手的余地！");
			Perform(c, "pause", 5);
			Perform(c, "say", "..你没必要知道..我会处理好这件事的！");
			Perform(c, "pause", 5);
			Perform(c, "say", "孟星魂！？");
			Perform(c, "pause", 2);
			Perform(c, "faceto", player);
			
			ChangeBehavior(p1, "follow", player);
			Perform(p1, "say", "我来帮你！");
			Perform(p1, "pause", 30);

			PlayerPerform("block", 0);
			PlayerPerform("say", "是你！");
			PlayerPerform("pause", 7);
			PlayerPerform("say", "无可救药的家伙！");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "如果不是你在酒馆打伤孙玉伯，高老大怎么会下落不明？");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "你这是什么意思？");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "快活林的各位兄弟现在怎样了！？高老大在哪？");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "单机-血战洛阳开始");
			PlayerPerform("block", 1);
			
			trg0 = 1;
			s1 = 1;
		}
	}
	if (trg0==1)
	{
		if (GetHP(c) <=0)
		{
			Say(c,"..我终究不是你的对手吗？可恨啊！石群他们..在街道上被围攻..去救他们吧！");
			PlayerPerform("use", 16);
			Perform(p1,"use", 16);
			timer0 = now + 5;
			trg0 = 2;
		}
	}
	if (trg0 == 2 && now > timer0)
	{
		AddNPC("npc19_04");
		AddNPC("npc19_05");
		AddNPC("npc19_06");
		AddNPC("npc19_07");
		RemoveNPC(c);
		trg0 = 3;
	}
	if (trg0==3)
	{
		int p2 = GetChar("石群");
		int c1 = GetChar("待卫长");
		int c2 = GetChar("待卫兵·甲");
		int c3 = GetChar("待卫兵·乙");
		SetTarget(0, "char", p2);
		SetTarget(1, "char", player);
		if (GetHP(p2) >0 && Distance(0, 1) < 300)
		{
			Say(p2,"孟星魂？快点帮我击退他们吧！");
			Say(player,"我这不就来了么？");
			ChangeBehavior(p2, "follow", player);
			ChangeBehavior(c1, "follow", player);
			ChangeBehavior(c2, "follow", player);
			ChangeBehavior(c3, "follow", player);
			trg0 = 4;
			s2 = 1;
			timer0 = now + 5;
		}
	}
	if (trg0==4 && now > timer0)
	{
		if (GetHP(p2+1) <=0 && GetHP(p2+2) <=0 && GetHP(p2+3)<=0)
		{
			RemoveNPC(p2+1);
			RemoveNPC(p2+2);
			RemoveNPC(p2+3);
			Say(p2,"叶翔他现在也被围攻中..快去帮他吧！");	
			PlayerPerform("use", 16);
			Perform(p1,"use", 16);
			Perform(p2,"use", 16);
			timer0 = now + 3;
			trg0 = 5;
		}
	}
	if (trg0 == 5 && now > timer0)
	{
		AddNPC("npc19_08");
		AddNPC("npc19_09");
		AddNPC("npc19_10");
		AddNPC("npc19_11");
		AddNPC("npc19_12");
		trg0 = 6;
	}
	if (trg0==6)
	{
		int p3 = GetChar("叶翔");
		c1 = GetChar("巡守队长");
		c2 = GetChar("大锤巡守");
		c3 = GetChar("长枪巡守");
		int c4 = GetChar("剑兵巡守");
		SetTarget(0, "char", p3);
		SetTarget(1, "char", player);
		if (GetHP(p3) >0 && Distance(0, 1) < 300)
		{
			Say(p3,"啊！孟星魂？快点支援我吧！");
			Say(player,"这是当然的！");
			ChangeBehavior(p3, "follow", player);
			ChangeBehavior(c1, "follow", player);
			ChangeBehavior(c2, "follow", player);
			ChangeBehavior(c3, "follow", player);
			ChangeBehavior(c4, "follow", player);
			trg0 = 7;
			s3 = 1;
			timer0 = now + 5;
		}
	}
	if (trg0<7)
	{
		con = GetChar("覆面");
		SetTarget(0, "char", con);
		SetTarget(1, "char", player);
		if (GetHP(con) < GetMaxHP(con)/2 && Distance(0, 1) < 300)
		{
			ChangeBehavior(con, "follow", player);
			Perform(con, "say", "我就是国宝！就是这样！对不起！你Gme Over了..打我打的很爽啊XD！");
			Perform(con, "pause", 5);
			Perform(con, "say", "贯彻以剧本情节过关的理念！英俊又潇洒的制作人员！");
			Perform(con, "pause", 5);
			Perform(con, "say", "为了防止过关条件被破坏！为了守护关卡的运行！");
			Perform(con, "pause", 5);
			Perform(con, "say", "既然你诚心诚意的发问了！我就大发慈悲的告诉你！");
			Perform(con, "pause", 5);
			Perform(con, "say", "真想夸奖你一下..但是我不是这剧本中的人物，你这攻击行为已惹恼我了！！");
			Perform(con, "faceto", player);

			PlayerPerform("block", 0);
			PlayerPerform("use", 35);
			PlayerPerform("pause", 3);
			PlayerPerform("say", "哪有这样的！？");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "？？？？？？？？？？？？？");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "........= =|||");
			PlayerPerform("pause", 5);
			PlayerPerform("say", ".....！");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "....？你是？");
			PlayerPerform("pause", 3);
			PlayerPerform("block", 1);

			trg0 = 886;
			timer0 = now + 30;
		}
	}
	if (trg0 == 886 && now > timer0)
	{
		gameover = -1;
		timer0 = now + 3;
	}
	if (trg0 == 7 && now > timer0)
	{
		if (GetHP(c1) <=0 && GetHP(c2) <=0 && GetHP(c3)<=0 && GetHP(c4)<=0)
		{
			RemoveNPC(c1);
			RemoveNPC(c2);
			RemoveNPC(c3);
			RemoveNPC(c4);
			Say(p3,"凤凤她现在闯进孙玉伯所在的塔里了..快去帮她吧！");	
			PlayerPerform("use", 16);
			Perform(p1,"use", 16);
			Perform(p2,"use", 16);
			Perform(p3,"use", 16);
			timer0 = now + 3;
			trg0 = 8;
		}
	}
	if (trg0 == 8 && now > timer0)
	{
		AddNPC("npc19_13");
		AddNPC("npc19_14");
		AddNPC("npc19_15");
		AddNPC("npc19_16");
		AddNPC("npc19_17");
		RemoveNPC(GetChar("覆面"));
		trg0 = 9;
	}
	if (trg0 == 9)
	{
		int p4 = GetChar("凤凤");
		c = GetChar("孙玉伯");
		c1 = GetChar("暗杀队长");
		c2 = GetChar("暗杀队员·甲");
		c3 = GetChar("暗杀队员·乙");
		SetTarget(0, "char", p4);
		SetTarget(1, "char", player);
		if (GetHP(p4) >0 && Distance(0, 1) < 300)
		{
			Say(p4,"啊！孟星魂？孙玉伯把高老大囚禁了！我们必需打倒他才能问出高老大的下落！");
			Say(player,"知道了！我们闯进去找孙玉伯吧！");
			ChangeBehavior(p4, "follow", player);
			ChangeBehavior(c, "patrol", 231);
			ChangeBehavior(c1, "follow", player);
			ChangeBehavior(c2, "follow", player);
			ChangeBehavior(c3, "follow", player);
			trg0 = 10;
			s4 = 1;
		}
	}
	if (trg0 >= 10 && trg0 <= 11)
	{
		if (GetHP(c1)<=0 && k1 == 0 && now > timer3)
		{
			RemoveNPC(c1);
			k1 = 1;
			timer3 = now + 2;
		}
		if (GetHP(c2)<=0 && k2 == 0 && now > timer3)
		{
			RemoveNPC(c2);
			k2 = 1;
			timer3 = now + 2;
		}
		if (GetHP(c3)<=0 && k3 == 0 && now > timer3)
		{
			RemoveNPC(c3);
			k3 = 1;
			timer3 = now + 2;
		}
		if(k1 == 1 && now > timer3)
		{
			if (GetChar("暗杀队长")<=0){AddNPC("npc19_15");}
			c1=GetChar("暗杀队长");
			ChangeBehavior(c1, "follow", player);
			k1=0;
			timer3 = now + 3;
		}
		if(k2 == 1 && now > timer3)
		{
			if (GetChar("暗杀队员·甲")<=0){AddNPC("npc19_16");}
			c2=GetChar("暗杀队员·甲");
			ChangeBehavior(c2, "follow", player);
			k2=0;
			timer3 = now + 3;
		}
		if(k3 == 1 && now > timer3)
		{
			if (GetChar("暗杀队员·乙")<=0){AddNPC("npc19_17");}
			k3 = 0;
			timer3 = now + 3;
			c3=GetChar("暗杀队员·乙");
			ChangeBehavior(c3, "follow", player);
		}
		SetTarget(0, "char", c);
		SetTarget(1, "char", player);
		if (GetHP(c) > 0 && GetEnemy(c)==player && Distance(0, 1) < 300 && trg0 == 10)
		{
			Perform(p1, "guard", 30);

			Perform(p2, "guard", 30);

			Perform(p3, "guard", 30);

			Perform(p4, "guard", 30);

			Perform(c1, "guard", 30);

			Perform(c2, "guard", 30);

			Perform(c3, "guard", 30);

			ChangeBehavior(c, "follow", player);
			Perform(c, "say", "放马过来吧！");
			Perform(c, "pause", 5);
			Perform(c, "say", "想看到她..先打倒我吧！！");
			Perform(c, "pause", 5);
			Perform(c, "say", "哈哈！就算他不来打扰我..我也早就想灭了快活林！");
			Perform(c, "pause", 5);
			Perform(c, "say", "我上次不过去酒馆喝个酒，快活林的杀手居然来打扰我！我岂有不报复之理？");
			Perform(c, "pause", 2);
			Perform(c, "faceto", player);

			PlayerPerform("block", 0);
			PlayerPerform("pause", 5);
			PlayerPerform("say", "那我就不客气了！");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "可恶!高老大呢！？");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "那纯脆是小何的个人行为！");
			PlayerPerform("pause", 5);
			PlayerPerform("say", "孙老伯！你为什么要致我们于死地？");
			PlayerPerform("block", 1);

			trg0 = 11;
		}
		if (GetHP(c) <= 0 && trg0 == 11 && GetChar("高寄萍")<=0)
		{
			Say(c,"没想到会被你们打败！暗杀者们..快去杀了高寄萍这厮，别让她活命！");
			AddNPC("npc19_18");
			c = GetChar("高寄萍");
			Say(c1,"是！");
		}
		if(GetChar("高寄萍")>0)
		{
			if (GetChar("高寄萍") != c){c = GetChar("高寄萍");}
			if (GetChar("高寄萍") == c){trg0 = 12;timer0 = now + 3;}
			ChangeBehavior(c1, "follow", c);
			ChangeBehavior(c2, "follow", c);
			ChangeBehavior(c3, "follow", c);
		}
	}
	if (trg0 == 12 && now > timer0)
	{
		ChangeBehavior(c1, "follow", c);
		ChangeBehavior(c2, "follow", c);
		ChangeBehavior(c3, "follow", c);
		SetTarget(0, "char", c);
		SetTarget(1, "char", player);
		if (GetHP(c) > 0 && Distance(0, 1) < 300)
		{
			Say(player,"高老大！属下孟星魂等来救你了！你跟我们回去吧！");
			Say(c,"辛苦你们了...为我开路..让我回去吧！");
			SetTarget(0, "waypoint", 141);
			ChangeBehavior(c, "attacktarget", 0);
			trg0 = 13;
		}
	}
	if (trg0 >= 12 && now > timer0)
	{
		if (GetHP(c1)<=0 && k1 == 0 && now > timer3)
		{
			RemoveNPC(c1);
			k1 = 1;
			timer3 = now + 2;
		}
		if (GetHP(c2)<=0 && k2 == 0 && now > timer3)
		{
			RemoveNPC(c2);
			k2 = 1;
			timer3 = now + 2;
		}
		if (GetHP(c3)<=0 && k3 == 0 && now > timer3)
		{
			RemoveNPC(c3);
			k3 = 1;
			timer3 = now + 2;
		}
		if(k1 == 1 && now > timer3)
		{
			if (GetChar("暗杀队长")<=0){AddNPC("npc19_15");}
			c1=GetChar("暗杀队长");
			ChangeBehavior(c1, "follow", c);
			Perform(c1,"use", 41);
			k1=0;
			timer3 = now + 3;
		}
		if(k2 == 1 && now > timer3)
		{
			if (GetChar("暗杀队员·甲")<=0){AddNPC("npc19_16");}
			c2=GetChar("暗杀队员·甲");
			ChangeBehavior(c2, "follow", c);
			Perform(c2,"use", 41);
			k2=0;
			timer3 = now + 3;
		}
		if(k3 == 1 && now > timer3)
		{
			if (GetChar("暗杀队员·乙")<=0){AddNPC("npc19_17");}
			c3=GetChar("暗杀队员·乙");
			ChangeBehavior(c3, "follow", c);
			Perform(c3,"use", 41);
			k3=0;
			timer3 = now + 3;
		}
	}
	if(trg0 == 13)
	{
		SetTarget(0, "char", c);
		SetTarget(1, "waypoint", 141);
		if (GetHP(c) > 0 && Distance(0, 1) < 200)
		{
			Say(c,"辛苦你们了...我已经成功逃离了！大家现在回八方总部养伤");
			gameover = 1;
			timer1 = now + 1;
			trg0 = 14; 
		}
		if (GetHP(c)<=0)
		{
			Say(c,"唉！手底下的人果然都是饭桶，要保护我回去有那么难吗？");
			gameover = -1;
			timer1 = now + 2; 
			trg0 = 14; 
		}
		if (now > timer2)
		{
			Perform(c,"use", 13);
			Perform(c,"use", 14);
			timer2 = now + 50; 
		} 
	}
	if (s1 == 1)
	{
		if (GetHP(p1) <=0)
		{
			Say(p1,"对不起！我只能帮到这了！");
			s1 = 0;
		}
	} 
	if (s2 == 1)
	{
		if (GetHP(p2) <=0)
		{
			Say(p2,"对不起！我不行了，接下来靠你了！");
			s2 = 0;
		}
	}
	if (s3 == 1)
	{
		if (GetHP(p3) <=0)
		{
			Say(p3,"唔！我已经不行了！全靠你了！");
			s3 = 0;
		}
	}
	if (s4 == 1)
	{
		if (GetHP(p4) <=0)
		{
			Say(p4,"可恨啊！我已经不行了！一切都拜托你了！");
			s4 = 0;
		}
	}
	if (gameover!=-1 && GetHP(player)<=0)
	{
		gameover = -1;
		timer1 = now + 2; 
	}
	if ((gameover==1 || gameover==-1) && now>timer1)
	{
		GameOver(gameover);
		gameover = 2;
	}
 
}