From 66b30629b30b03bf8ae94e627d98740234e5a819 Mon Sep 17 00:00:00 2001
From: Jesusaves <cpntb1@ymail.com>
Date: Tue, 28 Apr 2020 16:06:49 -0300
Subject: Event timers firing

---
 npc/042-0/arthur.txt  | 13 +++++++++++--
 npc/042-1/_import.txt |  1 -
 npc/042-1/_warps.txt  |  3 ---
 npc/042-1/door.txt    | 27 ++++++++++++++++++++++++---
 4 files changed, 35 insertions(+), 9 deletions(-)
 delete mode 100644 npc/042-1/_warps.txt

diff --git a/npc/042-0/arthur.txt b/npc/042-0/arthur.txt
index 30e00890e..878502077 100644
--- a/npc/042-0/arthur.txt
+++ b/npc/042-0/arthur.txt
@@ -178,10 +178,19 @@ OnInstanceInit:
 
 OnTouch:
     .@g=getcharid(2);
-    if ($KAMELOT_QUEST[.@g] & 1)
+    if ($KAMELOT_QUEST[.@g] & 1) {
         warp "042-1@"+.@g, 55, 99;
-    else
+    } else {
         dispbottom l("The door is locked.");
+        end;
+    }
+
+    // Maybe event must be fired
+    if (!($KAMELOT_KEYMASK[.@g] & 16)) {
+        .@label$=instance_npcname("#KDoor0421", $@KAMELOT_ID[.@g])+"::OnArrival";
+        deltimer .@label$;
+        addtimer 15000, .@label$;
+    }
     end;
 }
 
diff --git a/npc/042-1/_import.txt b/npc/042-1/_import.txt
index 491ca4354..9e6aaffb1 100644
--- a/npc/042-1/_import.txt
+++ b/npc/042-1/_import.txt
@@ -1,4 +1,3 @@
 // Map 042-1: Camelot - Weapon Room
 // This file is generated automatically. All manually added changes will be removed when running the Converter.
-"npc/042-1/_warps.txt",
 "npc/042-1/door.txt",
diff --git a/npc/042-1/_warps.txt b/npc/042-1/_warps.txt
deleted file mode 100644
index 4e77e91b8..000000000
--- a/npc/042-1/_warps.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-// This file is generated automatically. All manually added changes will be removed when running the Converter.
-// Map 042-1: Camelot - Weapon Room warps
-042-1,55,100,0	warp	#042-1_55_100	0,0,042-0,69,25
diff --git a/npc/042-1/door.txt b/npc/042-1/door.txt
index 110a0321d..fd1386b6c 100644
--- a/npc/042-1/door.txt
+++ b/npc/042-1/door.txt
@@ -43,7 +43,7 @@ OnKillBoss:
     end;
 
 OnKillMob:
-    .@label$=instance_npcname(.name$)+"::OnKillMob");
+    .@label$=instance_npcname(.name$)+"::OnKillMob";
     // Oh noes! No player attached D:
     // This kill is meaningless, RESPAWN IT, RESPAWN IT
     if (!playerattached()) {
@@ -76,7 +76,7 @@ OnKillMob:
 
     // Maybe we should advance the wave
     if ($@KAMELOT_WAVE == 3) {
-        debugmes "Boss Spawn";
+        debugmes "Kamelot %d: Boss Spawn", .@g;
         initnpctimer;
         setd("$@GTEMP_"+getmap(), .@avg);
         .@mcount=.@gcount;
@@ -136,7 +136,7 @@ OnTimer5000:
     end;
 
 OnTimer10000:
-    .@label$=instance_npcname(.name$)+"::OnKillBoss");
+    .@label$=instance_npcname(.name$)+"::OnKillBoss";
     .@m$=instance_mapname("042-1");
     mapannounce .@m$, "I'll get rid of you myself!!", 0;
     .@mobId=any(CursedSoldier, CursedArcher);
@@ -168,5 +168,26 @@ OnTimer10000:
     setunitdata(.@mob, UDT_CRIT,     rand2(.@min, .@max));
     stopnpctimer;
     end;
+
+OnArrival:
+    if ($@KAMELOT_WAVE == 0)
+        goto OnKillMob;
+    end;
+}
+
+
+// Required exit
+042-1,55,100,0	script	#KDoor0421B	NPC_HIDDEN,0,0,{
+    end;
+
+OnTouch:
+    .@g=getcharid(2);
+    if ($KAMELOT_KEYMASK[.@g] & 16) {
+        dispbottom l("WARNING: If you walk out the main gate you WON'T be able to return!");
+        warp "042-0@"+.@g, 69, 25;
+    } else {
+        dispbottom l("Oh noes! The guards locked the door!");
+    }
+    end;
 }
 
-- 
cgit v1.2.3-70-g09d2