// 洛阳城5
int Rule = 1;
int RoundTime = 600;
int PlayerSpawn = 3;
int PlayerSpawnDir = 180;
int PlayerWeapon = 48;
int PlayerWeapon2 =16;
int PlayerHP = 10000;

int trg0; 
int shi0; 
int trg1;
int trg2;
int now;  
int player;
int timer0;  
int gameover;

int z1;   
int za1; 
int z2;   
int za2; 
int z3;   
int za3; 
int z4;   
int za4; 
int z5;   
int za5; 

int yiren;  // 自己人的一个小函数//    自己人
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 anbu;  // 这个是暗部循环加血 // 敌人
int bossshi;  
int boss;   
int boss1;   // 豆豆

int ss;   
int ss1;  // 豆豆贴身

GetDistance(int k1,int k2)
{
   SetTarget(0, "char", k1);
   SetTarget(1, "char", k2);
   return Distance(0,1);
}
GetManPlaceDistance(int man,int place)
{
   SetTarget(0, "char", man);
   SetTarget(1, "waypoint", place);
   return Distance(0,1);
}
kuaihuolin(int za,int z) { // 快活林人死亡失败
 if (za>=0 && z<0) {
  GameOver(-1);}}

GetNPCChar() {
   z1=GetChar("伊人梦");
   za1=GetAnyChar("伊人梦");
   z2=GetChar("凤凤");
   za2=GetAnyChar("凤凤");
   z3=GetChar("小何");
   za3=GetAnyChar("小何"); // 自己人
   z4=GetChar("叶翔");
   za4=GetAnyChar("叶翔");
   z5=GetChar("石头大哥");
   za5=GetAnyChar("石头大哥");

   boss=GetChar("豆豆");
   boss1=GetAnyChar("豆豆");
   ss=GetChar("豆豆=贴身+侍卫");
   ss1=GetAnyChar("豆豆=贴身+侍卫"); // 关主

   c1=GetChar("蒙面杀手=1");
   ca1=GetAnyChar("蒙面杀手=1");
   c2=GetChar("蒙面杀手=2");
   ca2=GetAnyChar("蒙面杀手=2");

   c3=GetChar("暗部杀手=1");
   ca3=GetAnyChar("暗部杀手=1");
   c4=GetChar("暗部杀手=2");
   ca4=GetAnyChar("暗部杀手=2");
   c5=GetChar("暗部杀手=3");
   ca5=GetAnyChar("暗部杀手=3");
   c6=GetChar("暗部杀手=4");
   ca6=GetAnyChar("暗部杀手=4");
   c7=GetChar("暗部杀手=5");
   ca7=GetAnyChar("暗部杀手=5");
   c8=GetChar("暗部杀手=6");
   ca8=GetAnyChar("暗部杀手=6");

}
xunhuan(){
if (bossshi+50<=GetGameTime()) {
bossshi = GetGameTime();	
Perform(boss,"use",40);
Perform(boss,"use",41);
Perform(boss,"use",5);
Perform(boss,"use",3);	
Perform(boss,"use",4);
Perform(boss,"use",34);}}

scene1(){
if (trg0==0 && c1>=0 && c2>=0 && c3>=0 && c4>=0 && c5>=0 && c6>=0 && c7>=0 && c8>=0 && z1>=0 && z2>=0 && z3>=0 && z4>=0 && z5>=0 ){

ChangeBehavior(z1, "follow", c3);
ChangeBehavior(z2, "follow", c4);
ChangeBehavior(z3, "follow", c5);
ChangeBehavior(z4, "follow", c6);
ChangeBehavior(z5, "follow", c7);
ChangeBehavior(c3, "follow", z3);
ChangeBehavior(c4, "follow", z4);
ChangeBehavior(c5, "follow", z5);
ChangeBehavior(c6, "follow", z1);
ChangeBehavior(c7, "follow", z1);
ChangeBehavior(c8, "follow", z2);
Perform(c3,"pause",6);
Perform(c4,"pause",6);
Perform(c5,"pause",6);
Perform(c6,"pause",6);
Perform(c7,"pause",6);
Perform(c8,"pause",6);
Perform(z1,"pause",4);
Perform(z2,"pause",6);
Perform(z3,"pause",6);
Perform(z4,"pause",6);
Perform(z5,"pause",6);
PlayerPerform("use",5);
PlayerPerform("use",41);
PlayerPerform("use",19);
PlayerPerform("say"," 快去帮帮吧！要不然.恐怕快活林的人走不出洛阳！ ");  // 时刻:8
PlayerPerform("pause",8);
Perform(c1,"say","  很好！ 那你们就乖乖的受死吧！..");  // 时刻:6
Perform(c1,"pause",6);
Perform(z2,"say","  杀！！杀杀杀杀杀杀杀杀杀杀杀杀..");  // 时刻:4
Perform(z2,"pause",4);
Perform(z1,"say","  杀！！没想到兵兵会这样做！但是快活林的人不是怕死的！杀！就杀·死也要有价值！..");  // 时刻:2
Perform(z1,"pause",2);
Perform(c1,"say","  哈哈！又一次大血战！杀！....");  // 时刻:2
Perform(c1,"faceto",player);
trg0++;}

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

PlayerPerform("pause",2);
PlayerPerform("use", 35);
PlayerPerform("pause",2);
PlayerPerform("say","  我应该帮帮快活林的人离开这里！！.. ");  // 时刻:4
PlayerPerform("pause",2);
Perform(c1,"say","  你哈哈！连这里的同门师弟跟老婆都不管呢！那还玩什么阿。...");  // 时刻:2
Perform(c1,"faceto",player);
trg0++;}

if (trg0 == 1 &&  c2>=0 && GetDistance(player,c2)<=100 ){

PlayerPerform("pause",2);
PlayerPerform("use", 35);
PlayerPerform("pause",2);
PlayerPerform("say","  我应该帮帮快活林的人离开这里！！.. ");  // 时刻:4
PlayerPerform("pause",2);
Perform(c2,"say","  你哈哈！连这里的同门师弟跟老婆都不管呢！那还玩什么阿。...");  // 时刻:2
Perform(c2,"faceto",player);
trg0++;}

if (trg0 == 1 && c3<0  && c4<0 && c5<0 && c6<0 && c7<0 && c8<0){
ChangeBehavior(c1,"kill",z1);
ChangeBehavior(c2,"kill",z1);
Perform(c1,"use",19);Perform(c2,"use",19);
Perform(c1,"use",34);Perform(c2,"use",34);
Perform(c1,"use",40);Perform(c2,"use",40);
Perform(c1,"use",41);Perform(c2,"use",41);
Perform(c1,"say","  哈哈！别以为你们这么就算了！看看我们的厉害吧！...");  // 时刻:2
Perform(c1,"faceto",player);
RemoveNPC(ca3);RemoveNPC(ca4);
RemoveNPC(ca7);RemoveNPC(ca5);
RemoveNPC(ca8);RemoveNPC(ca6);
trg0++;timer0 = now + 10;}

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

if (trg0 == 3 && anbu+15<=GetGameTime()){anbu = GetGameTime();

ChangeBehavior(c1,"kill",z1);
ChangeBehavior(c2,"kill",z1);
ChangeBehavior(c3, "follow", z3);
ChangeBehavior(c4, "follow", z4);
ChangeBehavior(c5, "follow", z5);
ChangeBehavior(c6, "follow", z1);
ChangeBehavior(c7, "follow", z1);
ChangeBehavior(c8, "follow", z2);
Perform(c1,"use",36);Perform(c2,"use",36);
Perform(c3,"use",16);Perform(c6,"use",16);
Perform(c4,"use",16);Perform(c7,"use",16);
Perform(c5,"use",16);Perform(c8,"use",16);
}

if (yiren == 0 &&  z1>=0 && GetDistance(player,z1)<=300 ){

Perform(z1,"use",19);Perform(z1,"use",34);
Perform(z2,"use",19);Perform(z1,"use",41);
Perform(z3,"use",19);Perform(z1,"use",30);
Perform(z4,"use",19);Perform(z1,"use",40);
Perform(z5,"use",19);Perform(z1,"use",3);
PlayerPerform("say","  对！所以我们不要逃脱！我们今天就杀个痛快！.. ");  // 时刻:4
PlayerPerform("pause",2);
Perform(z1,"say","  嘿嘿！来了老公！。兵兵这样做，我们不要逃！咱也不是怕死的！就算死也要有点价值！...");  // 时刻:2
Perform(z1,"faceto",player);
yiren=1;}}


//    上面的结束

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

Perform(z1,"pause",55);
Perform(z2,"pause",55);
Perform(z3,"pause",55);
Perform(z4,"pause",55);
Perform(z5,"pause",55);
PlayerPerform("use",15);
PlayerPerform("use",15);
Perform(z2,"say","  那我们走吧！回去跟老大说一说今天的局面！.");  // 时刻:15
Perform(z2,"pause",15);
PlayerPerform("say"," 我知道！！不要说了，赶紧走吧，不行的话我会回到快活林的。不要担心我！ ");  // 时刻:12
PlayerPerform("pause",8);
Perform(z1,"say"," 对！兵兵制造了这一切！看来他要收回这一切！所以你要小心！败的几率很高的！我担心你！.");  // 时刻:10
Perform(z1,"pause",4);
Perform(z5,"say"," 毕竟所有的所有都是兵兵掌管的！所以你要小心！.");  // 时刻:8
Perform(z5,"pause",8);
Perform(z1,"say","  也好！那你自己要小心！不行的话我们会来帮你的！兵兵不是好对付的！.");  // 时刻:6
Perform(z1,"pause",6);
PlayerPerform("say"," 你们走吧-这里肯定还有人埋伏！要不然想走也走不了了！ ");  // 时刻:4
PlayerPerform("pause",2);
PlayerPerform("say","  没你说的那么简单！你们赶紧走吧！在这里很危险..  我还要找兵兵说个清楚！ ");  // 时刻:2
PlayerPerform("pause",2);
Perform(z1,"say","  嘿嘿！怎么样老公...   不见得我们就不是兵兵的对手！他的手下也不过如此！");  // 时刻:2
Perform(z1,"faceto",player);
Perform(z2,"faceto",player);
Perform(z3,"faceto",player);
Perform(z4,"faceto",player);
Perform(z5,"faceto",player);
RemoveNPC(ca1);RemoveNPC(ca2);
RemoveNPC(ca3);RemoveNPC(ca4);
RemoveNPC(ca7);RemoveNPC(ca5);
RemoveNPC(ca8);RemoveNPC(ca6);
trg1++;timer0 = now + 20;}

if (trg1==1 && now>timer0){

AddNPC("5关主");
AddNPC("5关主1");
RemoveNPC(za1);
RemoveNPC(za2);
RemoveNPC(za3);
RemoveNPC(za4);
RemoveNPC(za5);
trg1++;}

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

ChangeBehavior(ss,"kill",player);
SetTarget(0, "waypoint", 693);
ChangeBehavior(boss, "attacktarget", 0);
PlayerPerform("block",0);
Perform(boss,"use",19);
Perform(boss,"use",30);
Perform(ss,"use",19);
Perform(ss,"use",30);
Perform(ss,"use",4);
Perform(ss,"use",40);
Perform(boss,"pause",2);
Perform(ss,"pause",8);
PlayerPerform("say","  得罪了！ 两位一起上吧！ . ");  // 时刻:8
PlayerPerform("pause",4);
Perform(boss,"say","  算你聪明！哼！上....");  // 时刻:6
Perform(boss,"pause",4);
PlayerPerform("say","  所以你来替他收回！. ");  // 时刻:4
PlayerPerform("pause",4);
Perform(boss,"say","  这一切将不会在重演！兵兵要收回这一切！不过你现在还不配见到兵兵！..");  // 时刻:2
Perform(boss,"pause",2);
PlayerPerform("say"," 豆豆！. 兵兵现实的朋友，打架都是群欧！佩服！.. ." );  // 时刻:0
Perform(boss,"faceto",player);
Perform(ss,"faceto",player);
PlayerPerform("block",1);
trg1++;}

if (trg1==3 && GetManPlaceDistance(boss,693)<50) {

ChangeBehavior(boss,"kill",player);
ChangeBehavior(ss,"kill",player);
PlayerPerform("block",0);
Perform(boss,"say","  来吧！这里宽敞！可以让你死的快一点..");  // 时刻:2
Perform(boss,"faceto",player);
Perform(ss,"faceto",player);
PlayerPerform("block",1);
trg1++;}

if (boss>=0 && GetHP(boss)<8000 && trg1 == 4){

Perform(boss,"use",15);
Perform(boss,"use",15);
Perform(boss,"use",15);
Perform(ss,"use",15);
Perform(ss,"use",15);
Perform(ss,"use",15);
Perform(ss,"use",15);
PlayerPerform("use",15);
PlayerPerform("use",15);
PlayerPerform("block",0);
Perform(ss,"pause",2);
Perform(boss,"say","  哈哈！你以为这么容易吗？..");  // 时刻:2
Perform(boss,"pause",2);
PlayerPerform("say"," 还要打吗？！！. ." );  // 时刻:0
Perform(boss,"faceto",player);
Perform(ss,"faceto",player);
PlayerPerform("block",1);
trg1++;}

if (boss>=0 && GetHP(boss)<6000 && trg1 == 5){
Perform(ss,"use",15);
Perform(ss,"use",15);
Perform(ss,"use",15);
Perform(ss,"use",15);
PlayerPerform("block",0);
Perform(ss,"pause",2);
Perform(boss,"say","  那你就乖乖的受死吧！..");  // 时刻:2
Perform(boss,"pause",2);
PlayerPerform("say"," 这么打恐怕是分不出胜负的！." );  // 时刻:0
Perform(boss,"faceto",player);
Perform(ss,"faceto",player);
PlayerPerform("block",1);
trg1++;}

if (boss>=0 && GetHP(boss)<1000 && trg1 == 6){
Perform(ss,"use",15);
Perform(ss,"use",15);
Perform(ss,"use",15);
Perform(ss,"use",15);
PlayerPerform("block",0);
Perform(ss,"pause",200);
Perform(boss,"pause",30);
Perform(boss,"say","  你是见不到兵兵的！等着吧·....");  // 时刻:7
Perform(boss,"pause",4);
PlayerPerform("say","  我很想早早的跟兵兵做个了断！. ");  // 时刻:5
PlayerPerform("pause",5);
Perform(boss,"say","  你去（五雷塔）我们去那里比个高低怎么样！  哼！....");  // 时刻:3
Perform(boss,"pause",1);
Perform(boss,"say","  今天我累了！暂且先饶了你，不过你死是死定了！现在不是时候！..");  // 时刻:2
Perform(boss,"pause",2);
PlayerPerform("say"," 你不行了吗！呵呵！看来你不是我的对手！." );  // 时刻:0
Perform(boss,"faceto",player);
Perform(ss,"faceto",player);
PlayerPerform("block",1);
trg1++;timer0 = now + 10;}

if (trg1==7 && now>timer0){GameOver(1);}

if (boss<0 && trg1 == 7){GameOver(-1);}}

ziji(){
kuaihuolin(za1,z1);
kuaihuolin(za2,z2);
kuaihuolin(za3,z3);
kuaihuolin(za4,z4);
kuaihuolin(za5,z5);
if (GetHP(player)<=0) 
{ GameOver(-1);}}
OnStart(){
AddNPC("5关1");
AddNPC("5关2");
AddNPC("5关3");
AddNPC("5关4");
AddNPC("5关5");
AddNPC("5关6");
AddNPC("5关7");
AddNPC("5关8");
AddNPC("5关自己1");
AddNPC("5关自己2");
AddNPC("5关自己3");
AddNPC("5关自己4");
AddNPC("5关自己5");
}
OnUpdate()
{	
	player = GetAnyChar("player");
	if (player < 0){return 0;}
        now = GetGameTime();
        GetNPCChar() ; 
        xunhuan(); 
	ziji();
	scene1();
        scene2();
}