//  路见不平
int Rule = 5;
int RoundTime = 500;
int PlayerSpawn = 0;
int PlayerSpawnDir = 30;
int PlayerWeapon = 6;
int PlayerWeapon2 = 47;
int PlayerHP = 8000;

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

int c1;            
int ca1;      
int c2;      
int ca2;   
int c3;   
int ca3; 
int c4;
int ca4;
int c5;
int ca5;
int c6;
int ca6;
int c7;
int ca7;
int c8;
int ca8;

int q;
int qa;

GetDistance(int k1,int k2)
{
   SetTarget(0, "char", k1);
   SetTarget(1, "char", k2);
   return Distance(0,1);
}

GetNPCChar() 
{
   c8=GetChar("上官金洪");
   c1=GetChar("官差1");
   c2=GetChar("官差2");
   c3=GetChar("官差3");
   c4=GetChar("枪兵1");
   c5=GetChar("枪兵2");
   c6=GetChar("枪兵3");
   c7=GetChar("复仇野猫");
   q=GetChar("屠夫");
   qa=GetAnyChar("屠夫");

   ca8=GetAnyChar("上官金洪");
   ca1=GetAnyChar("官差1");
   ca2=GetAnyChar("官差2");
   ca3=GetAnyChar("官差3");
   ca4=GetAnyChar("枪兵1");
   ca5=GetAnyChar("枪兵2");
   ca6=GetAnyChar("枪兵3");
   ca7=GetAnyChar("复仇野猫");
}
AlwaysDo()
{
now = GetGameTime();

if (GetHP(player)<=0) 
{ 
GameOver(-1); 
}} 

scene1()
{
if (trg0==0 && c1>=0)
{ 


ChangeBehavior(c1, "kill" , q);
ChangeBehavior(c2, "kill" , q);
ChangeBehavior(c3, "kill" , q);

Perform(c2, "pause", 15);
Perform(c3, "pause", 15);
Perform(c2, "faceto", q);
Perform(c3, "faceto", q);
Perform(c1, "say" , "天皇老子来了！你今天也休想活着出去！");
Perform(c1, "pause", 4); 
Perform(q , "say" , "多谢小兄弟相助！！");
Perform(q, "pause", 8);
Perform(c1, "say" , "又是你这个家伙！可恶！");
Perform(c1, "pause", 3); 
Perform(c1, "faceto", player);
PlayerPerform("say" , "哼！一个老人也欺负。今天我伊人君来收拾你们。");
PlayerPerform("pause" , 6);
Perform(c1, "say" , "杀了他"); // 时间 8
Perform(c1, "pause", 4);
Perform(q , "say" , "那老夫领教了！");
Perform(q, "pause", 3);
Perform(c1, "say" , "哈哈。今天你休想活着走出去了！拿命来吧！");
Perform(c1, "pause", 3);
PlayerPerform("say" , "阿！这些官差真是不知好歹，一个老头也欺负！。");
PlayerPerform("pause" , 2);
Perform(q , "say" , "就凭你们这几个烂蒜！也想跟老夫打斗！未免太看不起老夫了。");
Perform(q, "pause", 1);
Perform(q, "faceto", c1);
Perform(c1 , "say" , "你这个老家伙！今天看你还往哪跑！");
Perform(c1, "faceto", q);
PlayerPerform("block" , 1);trg0++;s1++;}


if (q>=0 && GetHP(q)<5000  && s1==0){

Perform(q , "say" , "老夫把你连累了，真的是·唉。。。");s1++;}

if (q<=0 && s1==1) 
{ 
 GameOver(-1); s1++;}


if (c1>=0 && GetHP(c1)<1000  && trg0==1)
{

ChangeBehavior(c1, "kill" , c8);
Perform(c1, "say", "（你给老子等着…）吗的！！");
trg0++;timer0 = now + 10;
}

if (trg0 == 2&& now>timer0)
{

ChangeBehavior(c1, "kill", player);
ChangeBehavior(c2, "kill", player);
ChangeBehavior(c3, "kill", player);
ChangeBehavior(c4, "kill", player);
ChangeBehavior(c5, "kill", player);
ChangeBehavior(c6, "kill", player);
ChangeBehavior(c7, "kill", player);
ChangeBehavior(c8, "follow", player);
Perform(c8, "say", "都给我一起上！吗的。。");
Perform(c8, "say", "靠！！伊人君这家伙，总是坏我好事！今天不杀死他，难解心头之恨。/");
trg0++;
}
if (c8>=0 && GetHP(c8)<5000  && trg0==3)
{

Perform(c8, "say", "靠！ 你这家伙！今天就算是在死一次，你也休想离开这里。 ");
PlayerPerform("block", 0);
PlayerPerform("say", "哼哼，那我看你有没有本事了。");
PlayerPerform("pause", 2);
PlayerPerform("block", 1);
trg0++;h1++;
}}

scene2()
{
if (trg0==4 && c1<=0 && c2<=0 && c3<=0 ) 
{

         	RemoveNPC(ca1);
		    RemoveNPC(ca2);
            RemoveNPC(ca3);trg0++; timer0 = now + 5;
}

    if (trg0 == 5 && now > timer0)
	    {
	AddNPC("1关1");
	AddNPC("1关2");
	AddNPC("1关3");
	trg0=4;}

		if (c8>=0 && GetHP(c8)<GetMaxHP(c8)/2 && h1 == 0)
		{
			Perform(c8, "aggress");
			Perform(c8, "say", "你行阿！哈哈。这老头是你什么，这么呵护！我就偏杀他。");
			Perform(c8, "faceto", player);
			h1++;
		}}
scene3()
{
if (trg1 == 0  && c4>=0 && GetDistance(player,c4)<=300 )
{

Perform(c4, "say", "阿。又是你！");
ChangeBehavior(c5, "kill", player);
ChangeBehavior(c6, "kill", player);
ChangeBehavior(c8, "kill", player);trg1++;}

if (trg2 == 0  && c8>=0 && GetDistance(player,c8)<=300 )
{

Perform(c8, "say", "哼。今天你跑不掉了！！");
ChangeBehavior(c5, "kill", player);
ChangeBehavior(c6, "kill", player);
ChangeBehavior(c4, "kill", player);trg2++;}

if (trg3 == 0  && c7>=0 && GetDistance(player,c7)<=300 )
{

Perform(c7, "say", "西西！我是回来报仇的！");trg3++;}}



OnStart()
{   
	AddNPC("1关");
	AddNPC("1关1");
	AddNPC("1关2");
	AddNPC("1关3");
	AddNPC("1关4");
	AddNPC("1关5");
	AddNPC("1关6");
	AddNPC("1关7");
	AddNPC("1关风");
}

OnUpdate()
{	
	player = GetAnyChar("player");
	now = GetGameTime();
	if (player < 0)
	{
		return 0;
	}

    GetNPCChar() ; 

	AlwaysDo();

	scene1();

	
	scene2();

	scene3();
}