#include "../PScriptLib/AsHelper.as"

// 岩硫岛
int Rule = 10;
int RoundTime = 10;
int PlayerSpawn = 34;
int PlayerSpawnDir = 180;
int PlayerWeapon = 32;
int PlayerWeapon2 = 4;
int PlayerHP = 1000;

int trg0 = 0;
int trg1 = 0;
int trg2 = 0;
int trg3 = 0;
int trg4 = 0;
int trg5 = 0;
int trg6 = 0;
int trg7 = 0;
int trg8 = 0;
int trg9 = 0;
int trg10 = 0;
int trg11 = 0;
int trg12 = 0;
int trg13 = 0;
int timer0 = 0;
int timer1 = 0;
int timer2 = 0;
int timer3 = 0;
int timer4 = 0;
int timer5 = 0;
int timer6 = 0;
int gameover = 0;
int gameover1 = 0;
int gameover2 = 0;
int gameover3 = 0;
int gameover4 = 0;
int gameover5 = 0;
int gameover6 = 0;
int now = 0;
int damn =0; 
void OnStart()
{
	string voiceFolder = "UserData/Voice/sn14/";
	AsSoundCacheFolder(voiceFolder);
	AsSetChatVoiceFolder(voiceFolder);
	

	AddNPC("npc14_01");
	AddNPC("npc14_02");
}
// 游戏更新时
void OnUpdate()
{
	int player = GetChar("player");
	int c;
	int c2;
	int now = GetGameTime();
	
	
	//跳过剧情↓
	if(trg13 == 0&&now>timer6)
{
 Say(1,"提示：按下K键可以快速跳过剧情。");
 trg13=1;
 timer6=now+1;
 
}
if(trg13 == 1&&now>timer6&&trg0==1)
{
 if (AsIsKeyPressed(ImGuiKey_K))
 {
 ChangeBehavior(c2, "patrol", 16, 18, 19, 20, 21);
 trg0=1;
 timer0=now+1;
 trg13=99;
 timer6=now+1;
   StopPerform(2);
 StopPerform(3);
  StopPerform(4);
   StopPerform(5);
    StopPerform(6);
	 StopPerform(7);
	  StopPerform(8);
	   StopPerform(9);
	   PlayerPerform("block", 0);
 }
}
if(trg13 == 2&&now>timer6)
{
 if (AsIsKeyPressed(ImGuiKey_K))
 {
 trg0=2;
 timer0=now+1;
 trg13=3;
 timer6=now+1;
  Say(1,"提示：按下K键可以快速跳过剧情。");
   StopPerform(2);
 StopPerform(3);
  StopPerform(4);
   StopPerform(5);
    StopPerform(6);
	 StopPerform(7);
	  StopPerform(8);
	   StopPerform(9);
 }
}
if(trg13 == 3&&now>timer6)
{
 if (AsIsKeyPressed(ImGuiKey_K))
 {
 trg0=3;
 timer0=now+1;
 trg13=4;
 timer6=now+1;
  Say(1,"提示：按下K键可以快速跳过剧情。");
   StopPerform(2);
 StopPerform(3);
  StopPerform(4);
   StopPerform(5);
    StopPerform(6);
	 StopPerform(7);
	  StopPerform(8);
	   StopPerform(9);
 }
}
if(trg13 == 4&&now>timer6)
{
 if (AsIsKeyPressed(ImGuiKey_K))
 {
 trg0=4;
 timer0=now+1;
 trg13=5;
 timer6=now+1;
  Say(1,"提示：按下K键可以快速跳过剧情。");
   StopPerform(2);
 StopPerform(3);
  StopPerform(4);
   StopPerform(5);
    StopPerform(6);
	 StopPerform(7);
	  StopPerform(8);
	   StopPerform(9);
 }
}
if(trg13 == 5&&now>timer6)
{
 if (AsIsKeyPressed(ImGuiKey_K))
 {
 trg0=5;
 timer0=now+1;
 trg13=6;
 timer6=now+1;
 StopPerform(2);
 StopPerform(3);
  StopPerform(4);
   StopPerform(5);
    StopPerform(6);
	 StopPerform(7);
	  StopPerform(8);
	   StopPerform(9);
 }
}
//跳过剧情↑
	
	if (trg0 == 0)
	{
		c = GetChar("大刀哨兵");
		c2 = GetChar("铁枪哨兵");
		
		if (c>=0 && c2>=0)
		{		
			ChangeBehavior(c, "patrol", 0);
			AsPerform(c, "say", "好呗，我也懒得听你的冷笑话﹒﹒");
			AsPerform(c, "pause", 12);
			AsPerform(c, "say", "真的很冷耶﹒﹒");
			AsPerform(c, "pause", 9);
			AsPerform(c, "aggress");
			AsPerform(c, "say", "冷个屁呀？四周都是岩浆，热到爆了！真想喝口酒来解热呀！");
			AsPerform(c, "pause", 19);
			AsPerform(c, "say", "奇怪了，为啥老大会叫我们来这种鸟不生蛋的地方守！=.=");
			AsPerform(c, "faceto", c2);			
			
			
			ChangeBehavior(c2, "patrol", 16, 18, 19, 20, 21);
			AsPerform(c2, "pause", 1);
			AsPerform(c2, "say", "下次可能真被会被派到北方冰起来也说不定～");
			AsPerform(c2, "pause", 4);
			AsPerform(c2, "say", "我还是快回去守着，以免又被发现我们偷懒～");
			AsPerform(c2, "pause", 3);
			AsPerform(c2, "aggress", 10);
			AsPerform(c2, "say", "喂～我是在讲个冷笑话来解解闷，你不到你这呆头听不懂呀～");
			AsPerform(c2, "pause", 14);
			AsPerform(c2, "say", "才被分派到这种鸟地方把我们 '冷冻' 起来﹒﹒Ｘ滴！");
			AsPerform(c2, "pause", 6);
			AsPerform(c2, "say", "啊知～看样子是我们上次夜哨时偷溜出去喝酒被捉包！");
			AsPerform(c2, "pause", 7);
			AsPerform(c2, "faceto", c);
			
			PlayerPerform("say", "（这座岛上有好几处视野盲区......但是这两个人有点碍事！");
			PlayerPerform("pause", 1);
			PlayerPerform("block", 0);
			PlayerPerform("say", "（先调查一下岛上的情况，注意不要暴露或留下痕迹！！！）");
			PlayerPerform("pause", 4);
		    PlayerPerform("say", "（这是个刺杀范璇的机会吗？还是个诱饵？）");
		    PlayerPerform("pause", 4);
		    PlayerPerform("say", "（根据情报......紫麟金刀范璇将会和西洋红毛萧银鹏来此地视察......）");
		    PlayerPerform("pause", 5);
		    PlayerPerform("say", "（炎硫岛的硫磺是制作火器的重要物资......如今被飞鹏帮占据）");
			PlayerPerform("crouch", 1);
			PlayerPerform("block", 1);
			
			trg0 = 1;
			timer1 = 1;
		}
	}
	
    if (trg0 == 1 && now >= 36 && timer1 == 1)
	{
		PlayerPerform("say", "（将此二人推下岩浆，注意不要同时暴露在二人视野或留下痕迹！！！）");	
		trg0 = 2;
		timer1 =0;
	}
	
	if (trg1 == 0)
	{
		c = GetChar("大刀哨兵");
		if (c>=0 && GetEnemy(c)==player )
		{
			StopPerform(c);
			c2 = GetChar("铁枪哨兵");
			StopPerform(c2);
			
			AsPerform(c, "say", "好大的胆子竟敢乱闯禁地，没酒喝，火气正大，先拿你来开刀！");
			trg1 = 1;
		}
	}	
	if (trg1 == 1)
	{
		c = GetChar("大刀哨兵");
		if (c>=0 && GetEnemy(c)!=player)
		{
			AsPerform(c, "say", "跑到那儿去了！八成是跌入岩浆中了，哈哈哈哈！");
			trg1 = 2;
		}	
	}	
	if (trg1 == 2)
	{
		c = GetChar("大刀哨兵");
		if (c>=0 && GetEnemy(c)==player)
		{
			AsPerform(c, "say", "好小子，被我发现了吧！这下子你跑不掉了！");
			trg1 = 3;
		}
	}		
	if (trg1 == 3)
	{
		c = GetChar("大刀哨兵");
		if (c>=0 && GetEnemy(c)!=player)
		{
			AsPerform(c, "aggress");
			AsPerform(c, "say", "哼，又躲起来了！缩头乌龟一只！");
			trg1 = 4;
		}	
	}
	
	if (trg2 == 0)
	{
		c = GetChar("铁枪哨兵");
		if (c>=0 && GetEnemy(c)==player)
		{
			StopPerform(c);		
			c2 = GetAnyChar("大刀哨兵");
			StopPerform(c2);
			
			if (c2>=0 && GetHP(c2)>0)
			{
		AsPerform(c, "say", "大胡子！！快点过来！有入侵者呀！！");
		PlayerPerform("crouch", 1);
		PlayerPerform("block", 1);
		PlayerPerform("say", "（可恶，暴露了行踪！）");
		PlayerPerform("pause", 2);
		AsPerform(c,"guard", 5);	
        AsPerform(c,"aggress");	
		timer1 = now + 8;
		ChangeBehavior(c2, "follow", c);
		AsPerform(c, "say", "（信号弹升空）");
		trg6 = 5;	


			} else
			{
				ChangeBehavior(c, "follow", player);
				AsPerform(c, "attack");
				AsPerform(c, "say", "大胡子人呢？该不会是你把他给杀了！我要你连他的命一起赔上！受死！");				
			}				
			AsPerform(c, "pause", 5);
			AsPerform(c, "guard", 4);
			AsPerform(c, "say", "谁！你这生面孔八成不是什麽好东西，入侵者一律杀之！");
			AsPerform(c, "faceto", player);
			trg2 = 1;	
					
		}
	}

	if (trg5 == 0)
	{
		c = GetChar("铁枪哨兵");
		if (c>=0 && GetHP(c)<=500 && GetHP(c)>0)
		{
		PlayerPerform("pause", 2);
		AsPerform(c,"guard", 5);	
        AsPerform(c,"aggress");	
		AsPerform(c, "say", "（信号弹升空）");
		PlayerPerform("crouch", 1);
		PlayerPerform("block", 1);
		PlayerPerform("say", "（可恶，暴露了行踪！）");
		trg5 = 1;
		timer1 = now + 8;
			trg6 = 5;			
		}
	}	

	if (trg6 == 5 && now > timer1)
	{
	GameOver(-1);			
	}	
	if (trg3 == 0)
	{
		c = GetAnyChar("大刀哨兵");
		if (c>=0 && GetHP(c)<=500&&GetHP(c)>0)
		{
		trg3 = 8;
		PlayerPerform("crouch", 1);
		PlayerPerform("block", 1);
		PlayerPerform("say", "（可恶，暴露了行踪！）");
		PlayerPerform("pause", 2);
		AsPerform(c,"guard", 5);	
        AsPerform(c,"aggress");	
		AsPerform(c, "say", "呜......想不到你这小子还有两三下功夫......");			
		timer1 = now + 6;
			trg6 = 7;
		}						
	}
		if (trg6 == 7 && now >= timer1)
	{
		c = GetAnyChar("大刀哨兵");
		if (c>=0 && GetHP(c)<=500)
		{
		AsPerform(c, "say", "（信号弹升空）");			
			trg3 = 1;
			trg6 = 8;
			timer1 = now + 2;
		}						
	}
			if (trg6 == 8 && now > timer1)
	{
		c = GetAnyChar("大刀哨兵");
		if (c>=0 && GetHP(c)<=500)
		{
        GameOver(-1);			
			trg3 = 1;
		}						
	}
	

	if (trg6 == 3)
	{
		PlayerPerform("crouch", 1);
		PlayerPerform("block", 1);
		Say(c, "可恶......死人同样也会说话！我暴露了行踪！");
		PlayerPerform("pause", 2);
		timer1 = now + 8;
		trg6 = 4;	
	}
		if (trg6 == 4 && now > timer1)
	{
    GameOver(-1);
	}
	if (timer5 == 0)
	{
	c = GetAnyChar("大刀哨兵");
	    if (c>=0 && GetHP(c)<=0)
		   {
            AddNPC("npc14_03");
		    timer5 = 1;
		   }		

	}
	if (timer5 == 1)
	{c = GetAnyChar("无名");
	if (c>=0 && GetHP(c)>0)
	    {
         Perform (c, "use", 7);
		 AsPerform(c, "say", "这个蠢货！");
		 timer5 = 2;
		 timer2 = now + 3;
	    }		
	}
if (timer0 == 2)
{
    c = GetAnyChar("无名");
	if (c>=0&& timer2 == now)
	    {
		PlayerPerform("say", "（!!!有其他人？还是赶快动身为妙！）");
		 timer5 = 3;	
		 RemoveNPC(c);		 
	    }		
	}
}
void OnCharacterKill(int killerId, int beKilledId){
	trg6 = 3;
}

