//  ay-蒙面
int Rule = 3;
int RoundTime = 200;
int PlayerSpawn = 17;
int PlayerSpawnDir = 80;
int PlayerWeapon = 16;
int PlayerWeapon2 =17;
int PlayerHP = 4000;

int trg0;
int trg1;

int now;
int gameover;
int timer0;int timer1;
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 he;
int he1;

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

GetNPCChar() 
{
//
   c1=GetChar("城门总管");
   c2=GetChar("城门侍卫-1");
   c3=GetChar("城门侍卫-2");
   c4=GetChar("夺命AI-1");
   c5=GetChar("夺命AI-2");
   c6=GetChar("神炮AI-1");
   c7=GetChar("神炮AI-2");
   c8=GetChar("ay-蒙面");
   ca1=GetAnyChar("城门总管");
   ca2=GetAnyChar("城门侍卫-1");
   ca3=GetAnyChar("城门侍卫-2");
   ca4=GetAnyChar("夺命AI-1");
   ca5=GetAnyChar("夺命AI-2");
   ca6=GetAnyChar("神炮AI-1");
   ca7=GetAnyChar("神炮AI-2");
   ca8=GetAnyChar("ay-蒙面");//

   he=GetChar("JQ-小何");
   he1=GetAnyChar("JQ-小何");
}

AlwaysDo()
{
now = GetGameTime();

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


scene1(){

if (trg0==0 && he>=0  && c2>=0 && c3>=0){ 

ChangeBehavior(he,"follow",c2);
ChangeBehavior(c2,"follow",he);
ChangeBehavior(c3,"follow",he);
Perform(he, "pause", 2);
Perform(c3, "pause", 6);
Perform(he,"use",34);Perform(he,"use",4);Perform(he,"use",40);Perform(he,"use",41);
PlayerPerform("block", 0);
Perform(c2,"say","    好好。你们两个休想闯进去半步...  .那我们就先来看看你的身手.. ");  // 时刻:16
Perform(c2,"pause",6);
Perform(he,"say","  那正好让我教教你剑怎么用..看好了.. ");  // 时刻:14
Perform(he,"pause",8);
PlayerPerform("say","   哈哈..等会你不找我..我也要把你杀了..无用的小人..");  // 时刻:12
PlayerPerform("pause",4);
Perform(c2,"say","  伊人君..当我们不存在，你把（剑气）的手打伤了，这次一起把帐算了。 ");  // 时刻:10
Perform(c2, "faceto", he);
Perform(c3, "faceto", he);
Perform(c2,"pause",10);Perform(c3,"pause",10);
PlayerPerform("say","  你可不可以教我怎么用剑。你的剑气一向很好..");  // 时刻:8
PlayerPerform("pause",4);
Perform(he,"say","  那我们只有杀了。.. 杀死他们干脆，直接进入.. ");  // 时刻:6
Perform(he,"pause",4);
PlayerPerform("say","  但是这里的高手把守。好进去么...");  // 时刻:4
PlayerPerform("pause",4);
Perform(he,"say","  呵呵。 这里直接闯进城门就行了，别管那么多.. ");  // 时刻:2
Perform(he,"pause",2);
PlayerPerform("say","  小何。 我已经进入暗月的重点了..但是这里恐怕不好闯阿.. ");  // 时刻:0
PlayerPerform("block", 1);
Perform(he, "faceto", player);

trg0++;timer0 = now + 16;}

if (now>timer0 && trg0==1) {PlayerPerform("block", 1);}

if (trg0==1 && c2<0 ){
ChangeBehavior(c3,"follow",c1);
Perform(c3,"use",41);
PlayerPerform("block", 0);
Perform(he,"say","  别走..在这里等着他们.. ");  // 时刻:6
Perform(he,"pause",1);
Perform(he,"say","  好. 我们就在这里等着你们.. ");  // 时刻:6
Perform(he,"pause",4);
Perform(c3,"say","  你给我等着..");  // 时刻:2
PlayerPerform("block", 1);
Perform(c3,"use",15);
trg0++;}

if (trg0==2  && c1>=0 && GetDistance(c3,c1)<=100 ){ 
//
ChangeBehavior(c3,"follow",c1);
ChangeBehavior(c4,"follow",c1);
ChangeBehavior(c5,"follow",c1);
ChangeBehavior(c1,"follow",player);//
Perform(c1,"use",4);
Perform(c1,"use",41);
Perform(c1,"use",5);
Perform(c1,"use",34);
Perform(c1,"use",40);
Perform(c4,"use",34);
Perform(c5,"use",34);
Perform(c3,"use",34);
Perform(c5,"use",15);
Perform(he,"use",15);Perform(he,"use",40);Perform(he,"use",19);
Perform(he,"say","  用心了..他们老大来了.. ");  // 时刻:6
Perform(he,"pause",4);
Perform(c1,"say","  走.跟我去看看... ");  // 时刻:6
Perform(c1,"pause",2);
Perform(c3,"say","  老大.. 怪不得剑气都不是他的对手，他果然是很厉害 "); 

trg0++;}


if (trg0==3  && c1>=0 && GetDistance(player,c1)<=100 ){ 

//
ChangeBehavior(c3,"follow",c1);
ChangeBehavior(c4,"follow",c1);
ChangeBehavior(c5,"follow",c1);
ChangeBehavior(c1,"follow",player);//
Perform(c3,"pause",16);
Perform(c4,"pause",16);
Perform(c5,"pause",16);
Perform(he,"pause",2);
Perform(c1,"say","  有帮手. 管他那！一起杀了..  ");  // 时刻:16
Perform(c1,"pause",5);
//
Perform(he,"say","  别跟他废话..杀了他  ");  // 时刻:14
Perform(he,"pause",14);//
Perform(he, "faceto", player);

Perform(c1,"say","  口气好大！杀了他..暗月你是没有资格进去的.. ");  // 时刻:11
Perform(c1,"pause",5);
PlayerPerform("say"," 难道你想管嫌事. 做无谓的牺牲.. ");  // 时刻:8
PlayerPerform("pause",4);
Perform(c1,"say","  我不是暗月的！不过你也休想过去 ");  // 时刻:6
Perform(c1,"pause",6);
PlayerPerform("say"," 你也是暗月的人么...我要过去. ");  // 时刻:2
PlayerPerform("pause",4);
Perform(c1,"say","  果然是厉害阿....不知道你是不是我的对手. "); 
Perform(c1,"say","  就是你这小子.. 竟然把剑气都给打伤了.. ");  // 时刻:0
PlayerPerform("block",1);
Perform(c1, "faceto", player);

trg0++;}


if (trg0==4 && GetHP(c1)<4000) {

ChangeBehavior(c3,"follow",c8);
ChangeBehavior(c4,"follow",c8);
ChangeBehavior(c5,"follow",c8);
Perform(c1,"use",15);
/*
Perform(he,"say","  呵呵！有收获哦！..  ");  // 时刻:6
Perform(he,"pause",6);//
Perform(c1,"say","  告诉他说这小子闯近来了..非常的棘手 ");  // 时刻:6
Perform(c1,"pause",4);
Perform(c1,"say","  这小子还真是行 阿.. 去把暗月的代理人叫来..   ");  // 时刻:0
PlayerPerform("block",1);
*/
trg0++;}

if (trg0==5  && c8>=0 && GetDistance(c8,c5)<=100 ){ 

ChangeBehavior(c8,"follow",player);
ChangeBehavior(c3,"follow",player);
ChangeBehavior(c4,"follow",player);
ChangeBehavior(c5,"follow",player);
ChangeBehavior(c1,"follow",player);
ChangeBehavior(he,"follow",player);
/*
Perform(c8,"say","  我正想混混他！ ");  // 时刻:6
Perform(c8,"pause",4);
Perform(c5,"say","  那小子来了..非常棘手！麻烦你跟我们一起去解决他..   ");  // 时刻:0
*/
trg0++;}


if (trg1==0  && c8>=0 && GetDistance(player,c8)<=100 ){ 

ChangeBehavior(c8,"follow",player);
ChangeBehavior(c3,"follow",player);
ChangeBehavior(c4,"follow",player);
ChangeBehavior(c5,"follow",player);
ChangeBehavior(c1,"follow",player);
ChangeBehavior(he,"follow",player);
ChangeBehavior(c6,"follow",player);
ChangeBehavior(c7,"follow",player);
Perform(c8,"use",40);
Perform(c8,"use",41);
Perform(c8,"use",34);
Perform(c8,"use",19);
Perform(c8,"use",5);Perform(c8,"use",4);Perform(c8,"use",3);
Perform(c8,"say","  终于看见你了.. 切磋一下吧！    ");
PlayerPerform("use",15);
PlayerPerform("use",34);
trg1++;}

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

Perform(c8,"pause",50);Perform(he,"pause",50);
Perform(c8,"say","  好小子阿！你们两个给我记住！ ");  // 时刻:7
Perform(c8,"pause",5);
//
Perform(he,"say"," 不行了是吗？..  那就回去好好的养养伤，顺便报告一下，我们快闯入你们的组织了。  ");  // 时刻:4
Perform(he,"pause",4);//
Perform(c8,"say","  竟然连我也杀伤！. "); // =2
Perform(c8,"say","  好厉害的家伙.. 伤这么多的高手所在！  ");  // 时刻:0
PlayerPerform("block",1);
Perform(c8, "faceto", player);
trg1++;timer1 = now + 10;}

if (now>timer1 && trg1==2) {

RemoveNPC(ca8);
Perform(he,"say","  好了！我们破城而入吧！  "); 

trg1++;}}
OnStart()
{   
	AddNPC("3关1");
	AddNPC("3关2");
	AddNPC("3关3");
	AddNPC("3关4");
	AddNPC("3关5");
	AddNPC("3关6");
	AddNPC("3关7");
	AddNPC("3关");
	AddNPC("3关自己");
}

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

        GetNPCChar() ; 

	AlwaysDo();

	scene1();
}