// 血洗洛阳
int Rule = 1;
int RoundTime = 600;
int PlayerSpawn = 141;
int PlayerSpawnDir = 0;
int PlayerWeapon = 6;
int PlayerWeapon2 = 0;
int PlayerHP = 8000;


int trg0;
int trg1;
int tiao0;
int tiao1;
int tiao2;

int now = 0;
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 e1;       
int ea1;      
int e2;      
int ea2;   
int e3;   
int ea3; 
int e4;
int ea4;
int e5;
int ea5;
int e6;
int ea6;
int e7;
int ea7;
int e8;
int ea8;

int l;
int la;

int sj;

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


GetNPCChar() 
{
   c1=GetChar("长枪侍卫1");
   c2=GetChar("长枪侍卫2");
   c3=GetChar("长枪侍卫3");
   c4=GetChar("长枪侍卫4");
   c5=GetChar("长枪侍卫5");
   c6=GetChar("铜锤护法1");
   c7=GetChar("铜锤护法2");
   c8=GetChar("铜锤护法3");
   ca1=GetAnyChar("长枪侍卫1");
   ca2=GetAnyChar("长枪侍卫2");
   ca3=GetAnyChar("长枪侍卫3");
   ca4=GetAnyChar("长枪侍卫4");
   ca5=GetAnyChar("长枪侍卫5");
   ca6=GetAnyChar("铜锤护法1");
   ca7=GetAnyChar("铜锤护法2");
   ca8=GetAnyChar("铜锤护法3");

   e1=GetChar("魔刀守卫1");
   e2=GetChar("魔刀守卫2");
   e3=GetChar("魔刀守卫3");
   e4=GetChar("魔刀守卫4");
   e5=GetChar("无名洛阳1");
   e6=GetChar("无名洛阳2");
   e7=GetChar("无名洛阳3");
   e8=GetChar("无名洛阳4");
   ea1=GetAnyChar("魔刀守卫1");
   ea2=GetAnyChar("魔刀守卫2");
   ea3=GetAnyChar("魔刀守卫3");
   ea4=GetAnyChar("魔刀守卫4");
   ea5=GetAnyChar("无名洛阳1");
   ea6=GetAnyChar("无名洛阳2");
   ea7=GetAnyChar("无名洛阳3");
   ea8=GetAnyChar("无名洛阳4");
   l=GetChar("堂主");
   la=GetAnyChar("堂主");
}

AlwaysDo()
{
        now = GetGameTime();

	    if (GetHP(player)>=0 && sj<now) 
		{
		   sj=sj+20;		
		PlayerPerform("use", 41);
		PlayerPerform("use", 34);
		} 
if (GetHP(player)<=0) 
{ 
GameOver(-1); 
}} 

scene1()
{
if (trg0==0 && c6>=0 && c7>=0 && c8>=0 && GetDistance(player,c6)<=150 )
{ 

ChangeBehavior(c6, "kill", player);
ChangeBehavior(c7, "kill", player);
ChangeBehavior(c8, "kill", player);

Perform(c7, "pause", 7);
Perform(c8, "pause", 7);
PlayerPerform("block", 0);
Perform(c6,"say","切磋谈不上！。重要的是要你的命！"); 
Perform(c6,"pause",4);
PlayerPerform("say","原来这样！想必你是想跟我切磋吧！。");  
PlayerPerform("pause",3);
Perform(c6,"say","你这家伙，老子在这等你半天了。听皇宫里的人说你敢来洛阳查看消息。老衲在这等候很久了！"); 
Perform(c6,"pause",2);
PlayerPerform("say","一出来竟看见敌人。真是悲哀！！");  
PlayerPerform("block", 1);
trg0++;}

if (tiao0==0 && c1>=0 && c2>=0 && c3>=0 && c4>=0 && c5>=0 && GetDistance(player,c1)<=200 )
{ 


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, "kill", player);

Perform(c2, "pause", 5);
Perform(c3, "pause", 5);
Perform(c4, "pause", 5);
Perform(c5, "pause", 5);
Perform(c6, "pause", 5);
Perform(c7, "pause", 5);
Perform(c8, "pause", 5);
PlayerPerform("block", 0);
Perform(c1,"say","不一起上怎么是你的对手。我们上！"); 
Perform(c1,"pause",4);
PlayerPerform("say","来吧。你们一起上吧！！"); 
PlayerPerform("pause",2);
Perform(c1,"say","你终于来了！我期待很久了！"); 
PlayerPerform("block", 1);
tiao0++;}

if (trg0==1 && c1<0 && c2<0 && c3<0  && c4<0 && c5<0 && c6<0 && c7<0 && c8<0 )  
{ 

   PlayerPerform("use", 16);
   PlayerPerform("use", 16);
   RemoveNPC(ca1);   RemoveNPC(ca2);
   RemoveNPC(ca3);   RemoveNPC(ca4);
   RemoveNPC(ca5);   RemoveNPC(ca6);
   RemoveNPC(ca7);   RemoveNPC(ca8);trg0++;timer0 = now + 5;}



if (trg0 == 2 && now>timer0)
{
	AddNPC("4关9");
	AddNPC("4关10");
	AddNPC("4关11");
	AddNPC("4关12");
	AddNPC("4关13");
	AddNPC("4关14");
	AddNPC("4关15");
	AddNPC("4关16");trg0++;}



if (tiao0==1 && e1>=0 && e2>=0 && e3>=0 && e4>=0 && e5>=0 && e6>=0 && e7>=0 && e8>=0 &&GetDistance(player,e1)<=300 )
{ 


ChangeBehavior(e1, "kill", player);
ChangeBehavior(e2, "kill", player);
ChangeBehavior(e3, "kill", player);
ChangeBehavior(e4, "kill", player);
ChangeBehavior(e5, "kill", player);
ChangeBehavior(e6, "kill", player);
ChangeBehavior(e7, "kill", player);
ChangeBehavior(e8, "kill", player);

Perform(e2, "pause", 5);
Perform(e3, "pause", 5);
Perform(e4, "pause", 5);
Perform(e5, "pause", 5);
Perform(e6, "pause", 5);
Perform(e7, "pause", 5);
Perform(e8, "pause", 5);
PlayerPerform("block", 0);
Perform(e1,"say","这么多人你能杀的了多少！");
Perform(e1,"pause",4);
PlayerPerform("say","挡我者死！");  
PlayerPerform("pause",2);
Perform(e1,"say","厉害！！！不过你休想离开洛阳半步！"); 
PlayerPerform("block", 1);
tiao0++;}


if (tiao0==2 && e1>=0 && GetHP(e1)<GetMaxHP(e1)/2)
{
        ChangeBehavior(e2, "follow", e1);
        ChangeBehavior(e3, "follow", e1);
        ChangeBehavior(e4, "follow", e1);
        ChangeBehavior(e5, "follow", e1);
        ChangeBehavior(e6, "follow", e1);
        ChangeBehavior(e7, "follow", e1);
        ChangeBehavior(e8, "follow", e1);
	SetTarget(0, "waypoint", 3);
	ChangeBehavior(e1, "attacktarget", 0);
        Perform(e1,"use",15);
	Perform(e1, "say", "待会就有你好戏看了..看我怎麽玩你！！ ");
	Perform(e1, "faceto", player);tiao0++;}

if (tiao0 == 3 && e1>=0)
{

SetTarget(0, "char", e1);
SetTarget(1, "waypoint", 3);
if (Distance(0, 1) < 80)
{

ChangeBehavior(e1, "kill", player);
ChangeBehavior(e2, "kill", player);
ChangeBehavior(e3, "kill", player);
ChangeBehavior(e4, "kill", player);
ChangeBehavior(e5, "kill", player);
ChangeBehavior(e6, "kill", player);
ChangeBehavior(e7, "kill", player);
ChangeBehavior(e8, "kill", player);
Perform(e1,"use",5);
Perform(e1,"use",41);
Perform(e1,"use",40);
Perform(e1,"use",15);
Perform(e2,"use",15);
Perform(e3,"use",15);
Perform(e4,"use",15);
Perform(e5,"use",15);
Perform(e6,"use",15);
Perform(e7,"use",15);
Perform(e8,"use",15);
Perform(e1,"use",34);
Perform(e1,"use",19);
Perform(e1,"use",7);
Perform(e2,"use",7);
Perform(e3,"use",7);
Perform(e4,"use",7);
Perform(e5,"use",7);
Perform(e6,"use",7);
Perform(e7,"use",7);
Perform(e8,"use",7);
		PlayerPerform("use", 41);
		PlayerPerform("use", 40);
		PlayerPerform("use", 15);
		PlayerPerform("use", 34);
Perform(e1, "say", "哈哈！这下你可没折了吧！ ");tiao0++;}}



if (tiao0 == 4 && e1<0 && e2<0 && e3<0  && e4<0 && e5<0 && e6<0 && e7<0 && e8<0 )  
{ 

   RemoveNPC(ea1);   RemoveNPC(ea2);
   RemoveNPC(ea3);   RemoveNPC(ea4);
   RemoveNPC(ea5);   RemoveNPC(ea6);
   RemoveNPC(ea7);   RemoveNPC(ea8);tiao0++;timer0 = now + 5;}

if (tiao0 == 5 && now>timer0)
{
	AddNPC("4关");tiao0++;}


if (trg0==3 && l>=0 && GetDistance(player,l)<=300 )
{ 
ChangeBehavior(l, "kill", player);
PlayerPerform("block", 0);
Perform(l,"say","小子真是猖狂！！看招！");  // 时刻:20
Perform(l,"pause",5);
PlayerPerform("say","速速告诉我。皇宫总管是谁，我饶你不死。。");  // 时刻:16
PlayerPerform("pause",4);
Perform(l,"say","反了你。。小小杀手竟敢说出如此荒唐的话，简直是不可取。");  // 时刻:14
Perform(l,"pause",4);
PlayerPerform("say","哼。污辱！里面我看都是贪官吧！没有一个正经的");  // 时刻:12
PlayerPerform("pause",4);
Perform(l,"say","奸细。。他叫什么？皇宫启能被你污辱？");  // 时刻:10
Perform(l,"pause",4);
PlayerPerform("say","我这次来不是来杀你们这些小人的。。我是来杀皇宫里的奸细！");  // 时刻:8
PlayerPerform("pause",4);
Perform(l,"say","这话怎么讲的。这事是你做的，怎么你这样问我呢！连公主都敢得罪，你真是厉害。");  // 时刻:6
Perform(l,"pause",4);
PlayerPerform("say","捣乱。是我捣乱还是你们自己给自己捣乱");  // 时刻:4
PlayerPerform("pause",4);
Perform(l,"say","现在是我的。你在我的地盘捣乱！哼哼...");  // 时刻:2
Perform(l,"pause",2);
PlayerPerform("say","堂主..洛阳的堂主以前不是孙玉伯的吗？");  // 时刻:0
PlayerPerform("block", 1);
Perform(l, "faceto", player);
trg0++;timer0 = now + 20;}

if (trg0 == 4 && now>timer0)
{
Perform(l,"say","来人。..给我杀了这小小伊人君！."); 
	AddNPC("4关1");
AddNPC("4关2");
AddNPC("4关3");
AddNPC("4关4");
AddNPC("4关5");trg0++;}

if (trg0 == 5 && c1>=0 && c2>=0 && c3>=0 && c4>=0 && c5>=0)
{ 
Perform(c1,"use",7);
Perform(c2,"use",7);
Perform(c3,"use",7);
Perform(c4,"use",7);
Perform(c5,"use",7);
Perform(l,"use",40);
Perform(l,"use",34);
Perform(l,"use",19);
Perform(l,"use",3);
Perform(l,"use",4);
ChangeBehavior(c1, "kill", player);
ChangeBehavior(c2, "kill", player);
ChangeBehavior(c3, "kill", player);
ChangeBehavior(c4, "kill", player);
ChangeBehavior(c5, "kill", player);trg0++;}

if (trg0==6 && c1<=0 && c2<=0 && c3<=0 && c4<=0 && c5<=0) 
{
         	    RemoveNPC(ca4);
		    RemoveNPC(ca5);
         	    RemoveNPC(ca1);
		    RemoveNPC(ca2);
                    RemoveNPC(ca3);trg0++; timer0 = now + 5;
}

    if (trg0 == 7 && now > timer0)
	    {
	AddNPC("4关1");
	AddNPC("4关2");
	AddNPC("4关3");	
        AddNPC("4关4");
	AddNPC("4关5");
	trg0++;}
if (trg0 == 8 && c1>=0 && c2>=0 && c3>=0 && c4>=0 && c5>=0)
{ 
Perform(l,"use",40);
Perform(l,"use",34);
Perform(l,"use",19);
Perform(l,"use",3);
Perform(l,"use",4);
ChangeBehavior(c1, "kill", player);
ChangeBehavior(c2, "kill", player);
ChangeBehavior(c3, "kill", player);
ChangeBehavior(c4, "kill", player);
ChangeBehavior(c5, "kill", player);trg0=6;}}



scene2()
{
if (tiao0 == 5  && l>=0 && GetHP(l)<5000  )
{
Perform(l, "aggress");
Perform(l,"use",34);
Perform(l, "say", "好家伙！果然棘手！");
tiao0++;timer0 = now + 20;}

if (tiao0 == 6 && now > timer0 && l>=0)
{


Perform(l, "aggress");
Perform(l,"use",16);
Perform(l, "say", "哈哈！来阿！老子先玩玩你。");tiao0++;timer0 = now + 20;}

if (tiao0 == 7 && now > timer0 && l>=0)
{

Perform(l, "aggress");
Perform(l,"use",16);
Perform(l, "say", "哼..你这个家伙，不知道天高地厚，当个杀手有什么了不起。");tiao0++;timer0 = now + 20;}

if (tiao0 == 8 && now > timer0 && l>=0)
{

Perform(l, "aggress");
Perform(l,"use",3);
Perform(l, "say", "我看你这家伙还能撑多久..");tiao0++;timer0 = now + 20;}


if (tiao0 == 9 && now > timer0 && l>=0)
{

Perform(l, "aggress");
Perform(l,"use",41);
Perform(l, "say", "哈哈！是不是快断气了，我不会这么容易让你死的。");tiao0++;timer0 = now + 20;}

if (tiao0 == 10 && now > timer0 && l>=0)
{

Perform(l, "aggress");
Perform(l,"use",40);
Perform(l, "say", "哎哟！还挣扎阿！哈哈。死期到了你。");tiao0=6;timer0 = now + 20;}}

scene3()
{
if (trg1 == 0  && l>=0 && GetHP(l)<2000)
{
Perform(l, "aggress");
Perform(l,"use",34);
Perform(l, "say", "我可不能败给你！我堂堂洛阳的堂主"); trg1++;}

if (trg1==1 && l<0 )
{
GameOver(1); trg1++;}}

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

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

    GetNPCChar() ; 

	AlwaysDo();

	scene1();
scene2();
scene3();
}

