//  初次见面
int Rule = 1;
int RoundTime = 900;
int PlayerSpawn = 132;
int PlayerSpawnDir = 270;
int PlayerWeapon = 15;
int PlayerWeapon2 = 14;
int PlayerHP = 9000;

int trg0;
int trg1;
int trg2;
int tiao0;
int tiao1;
int tiao2;
int j1;
int j2;
int j3;
int now;
int sj;
int gameover;
int timer0;
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 c9;            
int ca9;      
int c10;      
int ca10;   
int c11;   
int ca11; 
int c12;
int ca12;
int c13;
int ca13;
int c14;
int ca14;
int c15; 
int ca15;
int c16;
int ca16;

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 h;
int ha;

int g;
int ga;

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("城门总管1");
   c6=GetChar("城门总管2");
   c7=GetChar("城门总管3");
   c8=GetChar("城门总管4");
   c9=GetChar("宫内侍卫1");
   c10=GetChar("宫内侍卫2");
   c11=GetChar("宫内侍卫3");
   c12=GetChar("宫内侍卫4");
   c13=GetChar("宫内高手1");
   c14=GetChar("宫内高手2");
   c15=GetChar("宫内高手3");
   c16=GetChar("宫内高手4");

   ca1=GetAnyChar("皇宫忠臣1");
   ca2=GetAnyChar("皇宫忠臣2");
   ca3=GetAnyChar("皇宫忠臣3");
   ca4=GetAnyChar("皇宫忠臣4");
   ca5=GetAnyChar("城门总管1");
   ca6=GetAnyChar("城门总管2");
   ca7=GetAnyChar("城门总管3");
   ca8=GetAnyChar("城门总管4");
   ca9=GetAnyChar("宫内侍卫1");
   ca10=GetAnyChar("宫内侍卫2");
   ca11=GetAnyChar("宫内侍卫3");
   ca12=GetAnyChar("宫内侍卫4");
   ca13=GetAnyChar("宫内高手1");  // 是不是有点乱
   ca14=GetAnyChar("宫内高手2");
   ca15=GetAnyChar("宫内高手3");
   ca16=GetAnyChar("宫内高手4");

   e1=GetChar("叛党神秘人1");
   e2=GetChar("叛党神秘人2");
   e3=GetChar("叛党神秘人3");
   e4=GetChar("叛党神秘人4");
   e5=GetChar("叛党神秘人5");
   ea1=GetAnyChar("叛党神秘人1");
   ea2=GetAnyChar("叛党神秘人2");
   ea3=GetAnyChar("叛党神秘人3");
   ea4=GetAnyChar("叛党神秘人4");
   ea5=GetAnyChar("叛党神秘人5");
   h=GetChar("皇帝（耶律才）");
   ha=GetAnyChar("皇帝（耶律才）");
   g=GetChar("公主");
   ga=GetAnyChar("公主");
}
AlwaysDo()
{
        now = GetGameTime();

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

scene1()
{
if (trg0==0 && c5>=0 && c6>=0 && c7>=0 && c8>=0 && GetDistance(player,c5)<=200 )
{ 
ChangeBehavior(c5, "kill", player);
ChangeBehavior(c6, "kill", player);
ChangeBehavior(c7, "kill", player);
ChangeBehavior(c8, "kill", player);
Perform(c5, "aggress");
Perform(c6, "aggress");
Perform(c7, "aggress");
Perform(c8, "aggress");
Perform(c7, "pause", 7);
Perform(c8, "pause", 7);
Perform(c6, "pause", 7);
PlayerPerform("block", 0);
Perform(c5,"say","多说无意！受死吧！"); 
Perform(c5,"pause",4);
PlayerPerform("say","哈哈。这闺女已经报信了！");  
PlayerPerform("pause",3);
Perform(c5,"say","等你很久了！公主也敢欺负！今天定是你的葬日"); 
Perform(c5,"pause",2);
PlayerPerform("say","不想死的滚开！");  
PlayerPerform("block", 1);
Perform(c5, "faceto", player);
Perform(c6, "faceto", player);
Perform(c7, "faceto", player);
Perform(c8, "faceto", player);
trg0++;timer0 = now + 20;}

if (trg0 == 1 && now > timer0 && c1>=0 && c2>=0 && c3>=0 && c4>=0){
ChangeBehavior(c1, "kill", player);
ChangeBehavior(c2, "kill", player);
ChangeBehavior(c3, "kill", player);
ChangeBehavior(c4, "kill", player);
ChangeBehavior(c1, "kill", player);
ChangeBehavior(c2, "kill", player);
ChangeBehavior(c3, "kill", player);
ChangeBehavior(c4, "kill", player);
Perform(c2, "pause", 5);
Perform(c3, "pause", 5);
Perform(c4, "pause", 5);
Perform(c1,"say","那也值得！"); 
Perform(c1,"pause",5);
PlayerPerform("say","小心你们也败在我的手里。！");  
PlayerPerform("pause",3);
Perform(c1,"say","我来替公主出这口气！"); 
PlayerPerform("block", 1);
trg0++;}

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

   PlayerPerform("say","哼！。");  
   RemoveNPC(ca1);   RemoveNPC(ca2);
   RemoveNPC(ca3);   RemoveNPC(ca4);
   RemoveNPC(ca5);   RemoveNPC(ca6);
   RemoveNPC(ca7);   RemoveNPC(ca8);trg0++;timer0 = now + 5;}


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

if (trg0==4 && c9>=0 && GetDistance(player,c9)<=20000 )
{ 
ChangeBehavior(c9, "kill", player);
ChangeBehavior(c10, "kill", player);
ChangeBehavior(c11, "kill", player);
ChangeBehavior(c12, "kill", player);
ChangeBehavior(c13, "kill", player);
ChangeBehavior(c14, "kill", player);
ChangeBehavior(c15, "kill", player);
ChangeBehavior(c16, "kill", player);
Perform(c9, "aggress");
Perform(c10, "aggress");
Perform(c11, "aggress");
Perform(c12, "aggress");
Perform(c13, "aggress");
Perform(c14, "aggress");
Perform(c15, "aggress");
Perform(c16, "aggress");
Perform(c9, "pause", 7);
Perform(c10, "pause", 7);
Perform(c11, "pause", 7);
Perform(c12, "pause", 7);
Perform(c13, "pause", 7);
Perform(c14, "pause", 7);
Perform(c15, "pause", 7);
PlayerPerform("block", 0);
Perform(c9,"say","杀！"); 
Perform(c9,"pause",4);
PlayerPerform("say","来了又怎样！");  
PlayerPerform("pause",3);
Perform(c9,"say","好家伙！终于见到你了，是我们动手的时候了，敢闯入这里，免的我去找你。"); 
Perform(c9,"pause",2);
PlayerPerform("say","又来了！。");  
PlayerPerform("block", 1);
trg0++;timer0 = now + 20;}


if (trg0==5 && c9<0 && c10<0 && c11<0  && c12<0 && c13<0 && c14<0 && c15<0 && c16<0 )  
{ 

   PlayerPerform("say","自寻死路！。");  
   RemoveNPC(ca9);    RemoveNPC(ca13);
   RemoveNPC(ca10);   RemoveNPC(ca14);
   RemoveNPC(ca11);   RemoveNPC(ca15);
   RemoveNPC(ca12);   RemoveNPC(ca16);trg0++;timer0 = now + 5;}

if (trg0 == 6 && now>timer0)
{
	AddNPC("9关皇帝");
	AddNPC("9关");trg0++;}

if (trg0==7 && g>=0 && h>=0 && GetDistance(player,h)<=50 ){ 
ChangeBehavior(h, "kill", player);
ChangeBehavior(g, "kill", player);
Perform(h,"use",34);
Perform(h,"use",19);
Perform(h,"use",4);
Perform(h,"use",30);
Perform(g,"use",34);
Perform(g,"use",19);
Perform(g,"use",4);
Perform(g,"use",30);
Perform(h,"pause",2);
Perform(g,"say","给你点厉害尝尝！！！"); // 时间=13
Perform(g,"pause",9);
PlayerPerform("block", 0);
PlayerPerform("say","试试就知道了。拿你的人头回去领功！！");  // 时刻:13
PlayerPerform("pause",3);
Perform(h,"say","你觉得你杀的了我吗？我会这么容易死吗？"); // 时间=12
Perform(h,"pause",3);
PlayerPerform("say","废话那么多干什么，自己做过什么，做错什么比谁都清楚，我只杀人渣，不杀好人。");  // 时刻:10
PlayerPerform("pause",3);
Perform(h,"say","总的说出点理由吧！为什么要杀我？"); // 时间=9
Perform(h,"pause",6);
PlayerPerform("say","没说你们怕我！不过我此次来的任务就是我刚才所说的！");  // 时刻:7
PlayerPerform("pause",3);
Perform(g,"say","放肆！嘴巴放干净点你给我！别以为我们怕你。 "); // 时间= 5
Perform(g,"pause",4);
PlayerPerform("say","你怕？哼..奸贼！此次来是取你的人头！");  // 时刻:4
PlayerPerform("pause",4);
Perform(h,"say","请问你是谁，前来的目的是杀我？我何罪之有？会惹来杀身之祸！"); // 时间=3
Perform(h,"pause",1);
Perform(g, "faceto", player);Perform(h, "faceto", player);
Perform(h,"say","是吗！待你父皇跟他说！ "); 
Perform(h,"pause",2);
Perform(g,"say","父皇，就是他欺负我，他还奉什么之命来杀你的！"); 
Perform(h, "faceto", g);Perform(g, "faceto", h);
Perform(g,"pause",1);
PlayerPerform("say","终于见到目标了。决不能失手！");  
PlayerPerform("block", 1);
trg0++;}

if (trg0==8 && h>=0 && GetHP(h)<2000)
{
PlayerPerform("say","操！！失败！");
PlayerPerform("pause",3);
PlayerPerform("say","跑..！休想！");
PlayerPerform("pause",2);
Perform(h,"say","女儿！我们先走，改日在找他"); 
Perofrm(g, "faceto", h);Perofrm(h, "faceto", g);
trg0++;timer0 = now + 2;}

if (trg0 == 9 && now>timer0)
{
   RemoveNPC(ha);  
   RemoveNPC(ga); 
trg0++;timer0 = now + 10;}

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

if (trg0==11 && e1>=0 &&  e2>=0 &&  e3>=0 &&  e4>=0 &&  e5>=0 && GetDistance(player,e1)<=800 )
{


ChangeBehavior(e1, "kill", player);
ChangeBehavior(e2, "kill", player);
ChangeBehavior(e3, "kill", player);
ChangeBehavior(e4, "kill", player);
ChangeBehavior(e5, "kill", player);
Perform(e1, "aggress");
Perform(e2, "aggress");
Perform(e3, "aggress");
Perform(e4, "aggress");
Perform(e5, "aggress");
Perform(e1,"say","你玩够了..让我们把你收拾了吧！");
Perform(e1, "faceto", player);
trg0++;}

if (trg0==12 && e1<0 && e2<0 && e3<0  && e4<0 && e5<0)  
{
   PlayerPerform("say","我赶紧去找那奸贼吧！。");  
   RemoveNPC(ea1);   
   RemoveNPC(ea2);
   RemoveNPC(ea3);   
   RemoveNPC(ea4);
   RemoveNPC(ea5);  
   trg0++;timer0 = now + 2;}

if (trg0==13 && now>timer0){
GameOver(1); trg0++;}}

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

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

        GetNPCChar() ; 

	AlwaysDo();

	scene1();
}