// Snow Town
int Rule = 3;
int RoundTime = 20;
int PlayerSpawn = 15;
int PlayerSpawnDir = 250;
int PlayerWeapon = 16;
int PlayerWeapon2 = 13;
int PlayerHP = 2000;


int trg0 = 0;
int trg1 = 0;
int trg2 = 0;
int trg3 = 0;
int now = 0;
int survivor = -1;
int gameover = 0;
int timer0 = 0;

OnStart()
{
	AddNPC("npc04_01");
	AddNPC("npc04_02");
	AddNPC("npc04_03");
	AddNPC("npc04_04");
	AddNPC("npc04_05");
	AddNPC("npc04_06");
	AddNPC("npc04_07");
}

OnUpdate()
{
	int player = GetAnyChar("player");
	if (player < 0)
	{
		return 0;
	}
	
	int c;
	int c2;
	int c3;
	int c4;
	int c5;
	
	if (trg0 == 0)
	{
		c = GetChar("Imperial official");
		c2 = GetChar("Imperial guard A");
		c3 = GetChar("Imperial guard B");
		c4 = GetChar("Guard A");
		c5 = GetChar("Guard B");
		
		if (c>=0 && c2>=0 && c3>=0 && c4>=0 && c5>=0)
		{
			Perform(c, "say", "Others go get the guy who wanna break through here£¡");
			Perform(c, "say", "Pay attention, watch here cautiously£¡");
			Perform(c, "faceto", c3);
			
			Perform(c2, "say", "Yes, sir£¡");
			Perform(c2, "pause", 3);
			Perform(c2, "faceto", c);
			
			Perform(c3, "say", "Yes, sir£¡");
			Perform(c3, "pause", 3);
			Perform(c3, "faceto", c);			
			
			Perform(c4, "pause", 3);
			Perform(c4, "faceto", c);
			
			Perform(c5, "pause", 3);
			Perform(c5, "faceto", c);
				
			PlayerPerform("block", 0);
			PlayerPerform("say", "£¨©q©q©q©qDon't care too much©q©q©qbreak through this gate first©q©q£©");
			PlayerPerform("pause", 1);
			PlayerPerform("say", "£¨©q©qAny implicate©q©q©qwith that girl?©q©q©q£©");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "£¨©q©q©q©q©q©q£©");
			PlayerPerform("say", "£¨All right,I'm gonna straightly break through here£¡");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "£¨Fortunately, Boss Gao has many plans for me to break through this gate£¡£©");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "£¨I can't go through here safely by pledge now, I need to find another way£¡£©");
			PlayerPerform("pause", 1);
			PlayerPerform("say", "£¨©q©q©q©q©q©q£©");
			PlayerPerform("pause", 1);
			PlayerPerform("say", "£¨©q©qOr©q©q©q©q£¿£¿£©");
			PlayerPerform("pause", 1);
			PlayerPerform("say", "£¨Isn't that Night Owl doing anything on the pledge£¿£©");
			PlayerPerform("pause", 1);
			PlayerPerform("say", "£¨It should be this as Boss Gao said, right£¿£©");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "£¨©q©q©qUnexpectedly,that is a fake©q©q£©");
			PlayerPerform("pause", 2);
			PlayerPerform("say", "£¨©q©q©q©qFake©q©q©q£©");
			PlayerPerform("pause", 7);
			PlayerPerform("block", 1);
			
			trg0 = 1;
		}		
	}
	
	if (trg0 == 1)
	{
		c2 = GetChar("Imperial guard A");
		c3 = GetChar("Imperial guard B");
		
		if (c2>=0 && GetEnemy(c2)==player)
		{
			ChangeBehavior(c3, "follow", c2);
			Perform(c2, "say", "I find the guy here,help£¡");
			Perform(c2, "faceto", player);
			trg0 = 2;
		}
		if (c3>=0 && GetEnemy(c3)==player)
		{
			ChangeBehavior(c2, "follow", c3);
			Perform(c3, "say", "I find the guy here, help£¡");
			Perform(c3, "faceto", player);
			trg0 = 2;
		}		
	}	
	if (trg0 == 2)
	{
		c2 = GetAnyChar("Imperial guard A");
		c3 = GetAnyChar("Imperial guard B");
		survivor = -1;
		if (c2>=0 && GetHP(c2)<=0)
		{
			survivor = c3;
		}
		if (c3>=0 && GetHP(c3)<=0)
		{
			survivor = c2;
		}
		
		if (GetHP(survivor) > 0)
		{
			c = GetChar("Imperial official");
			if (c >= 0)
			{
				ChangeBehavior(survivor, "follow", c);
				Perform(survivor, "say", "Shit! Stay here£¡");
				Perform(survivor, "faceto", player);
				trg0 = 3;
			}
		}				
	}
	
	if (trg0 == 3)
	{
		c = GetChar("Imperial official");		
		if (c>=0 && GetHP(survivor)>0)
		{
			SetTarget(0, "char", c);
			SetTarget(1, "char", survivor);
			if (Distance(0, 1) < 150)
			{
				Perform(survivor, "say", "Sir, I find that guy£¡");
				Perform(survivor, "faceto", c);
				
				ChangeBehavior(c, "follow", player);
				Perform(c, "say", "Go! Everybody moves£¡");
				Perform(c, "pause", 3);
				Perform(c, "faceto", survivor);
				
				c2 = GetChar("Guard A");
				if (c2 >= 0)
				{
					ChangeBehavior(c2, "follow", c);
					Perform(c2, "faceto", c);
				}
				c2 = GetChar("Guard B");
				if (c2 >= 0)
				{
					ChangeBehavior(c2, "follow", c);
					Perform(c2, "faceto", c);
				}
				trg0 = 4;												
			}
		}		
	}
	
	if (trg1 == 0)
	{
		c = GetChar("Imperial official");		
		if (c>=0 && GetEnemy(c)==player)
		{
			Perform(c, "aggress");
			Perform(c, "say", "I am here,and you are not going any where£¡£¡");
			Perform(c, "faceto", player);
			if (trg0 != 4)
			{		
				c2 = GetChar("Guard A");
				if (c2 >= 0)
				{
					ChangeBehavior(c2, "follow", c);
					Perform(c2, "guard", 5);
					Perform(c2, "faceto", player);
				}
				c2 = GetChar("Guard B");
				if (c2 >= 0)
				{
					ChangeBehavior(c2, "follow", c);
					Perform(c2, "guard", 5);
					Perform(c2, "faceto", player);
				}
				trg0 = 4;
			}
			trg1 = 1;
		}
	}	
	
	if (trg1 == 1)
	{
		c = GetChar("Imperial official");		
		if (c>=0 && GetHP(c)<GetMaxHP(c)/2)
		{	
			c3 = -1;
			c2 = GetChar("Guard A");
			if (c2 >= 0)
			{
				c3 = c2;
			}
			c2 = GetChar("Guard B");
			if (c2 >= 0)
			{
				c3 = c2;
			}
			c2 = GetChar("Imperial guard A");
			if (c2 >= 0)
			{
				c3 = c2;
			}
			c2 = GetChar("Imperial guard B");
			if (c2 >= 0)
			{
				c3 = c2;
			}
			
			if (GetHP(c3) > 0)
			{
				Perform(c, "say", "Go get more people£¡£¡");
				SetTarget(0, "waypoint", 1);
				ChangeBehavior(c3, "attacktarget", 0);
				
				c4 = GetChar("Soldier A");
				if (c4 >= 0)
				{
					ChangeBehavior(c4, "kill", player);
				}
				c4 = GetChar("Soldier B");
				if (c4 >= 0)
				{
					ChangeBehavior(c4, "kill", player);
				}
			}
		
			Perform(c, "say", "All right, let see how to deal with you£¡");
			Perform(c," faceto", player);
		
			trg1 = 2;
		}		
	}
	

	now = GetGameTime();	
	if (gameover==0 && GetHP(player)<=0)
	{
		gameover = -1;
		timer0 = now + 2; 
	}
	if ((gameover==1 || gameover==-1) && now>timer0)
	{
		GameOver(gameover);
		gameover = 2;
	}	
}