-- TimeSpace Script generated by friends111's python script. Replace all %TODO% values accordingly, check for errors (packet-generation isn't perfect), and modify things if needed.
local Map = require('Map')
local Monster = require('Monster')
local Event = require('Event')
local MapObject = require('MapObject')
local MapNpc = require('MapNpc')
local Portal = require('Portal')
local Location = require('Location')
local TimeSpace = require('TimeSpace')
local PortalType = require("PortalType")
local PortalMinimapOrientation = require('PortalMinimapOrientation')
local TimeSpaceObjective = require('TimeSpaceObjective')
local TimeSpaceTaskType = require('TimeSpaceTaskType')
local TimeSpaceTask = require('TimeSpaceTask')
local MonsterWave = require('MonsterWave')

local objectives = TimeSpaceObjective.Create()
    .WithGoToExit()
    .WithProtectNPC()

-- Grid min:(0, 5) ~ max:(7, 9) (width: 7, height: 4)
--     [ 0][ 1][ 2][ 3][ 4][ 5][ 6][ 7][ 8][ 9][10]
-- [ 0][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
-- [ 1][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
-- [ 2][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
-- [ 3][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
-- [ 4][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
-- [ 5][  ][  ][  ][  ][XX][XX][  ][  ][  ][  ][  ]
-- [ 6][OO][OO][XX][XX][OO][OO][XX][OO][  ][  ][  ]
-- [ 7][  ][  ][  ][  ][XX][XX][  ][XX][  ][  ][  ]
-- [ 8][  ][  ][  ][  ][  ][  ][  ][OO][  ][  ][  ]
-- [ 9][  ][  ][  ][  ][  ][OO][XX][XX][  ][  ][  ]
-- [10][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]

local map_0_6 = Map.Create().WithMapId(4418).SetMapCoordinates(0, 6).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None)
) -- start
local map_1_6 = Map.Create().WithMapId(4411).SetMapCoordinates(1, 6).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None).WithOnStartDialog(6208)
)
local map_2_6 = Map.Create().WithMapId(4411).SetMapCoordinates(2, 6).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_33_TEXT_0")
)
local map_3_6 = Map.Create().WithMapId(4411).SetMapCoordinates(3, 6).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_33_TEXT_0")
)
local map_4_6 = Map.Create().WithMapId(4400).SetMapCoordinates(4, 6).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None)
)
local map_5_6 = Map.Create().WithMapId(4400).SetMapCoordinates(5, 6).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None)
)
local map_6_6 = Map.Create().WithMapId(4411).SetMapCoordinates(6, 6).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_33_TEXT_0")
)
local map_7_6 = Map.Create().WithMapId(4405).SetMapCoordinates(7, 6).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None).WithOnStartDialog(6209).WithOnStartShout("TS_33_TEXT_1")
)
local map_4_7 = Map.Create().WithMapId(4413).SetMapCoordinates(4, 7).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_33_TEXT_0")
)
local map_4_5 = Map.Create().WithMapId(4419).SetMapCoordinates(4, 5).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_33_TEXT_0")
)
local map_5_5 = Map.Create().WithMapId(4419).SetMapCoordinates(5, 5).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_33_TEXT_0")
)
local map_5_7 = Map.Create().WithMapId(4413).SetMapCoordinates(5, 7).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_33_TEXT_0")
)
local map_7_7 = Map.Create().WithMapId(4410).SetMapCoordinates(7, 7).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_33_TEXT_0")
)
local map_7_8 = Map.Create().WithMapId(4410).SetMapCoordinates(7, 8).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None).WithOnStartDialog(6210)
)
local map_7_9 = Map.Create().WithMapId(4406).SetMapCoordinates(7, 9).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_33_TEXT_0")
)
local map_6_9 = Map.Create().WithMapId(4411).SetMapCoordinates(6, 9).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.Survive, 180).WithTaskText("TS_33_TEXT_2").WithOnStartDialog(6211).WithOnStartShout("TS_33_TEXT_3").WithOnFinishDialog(6212)
)
local map_5_9 = Map.Create().WithMapId(4411).SetMapCoordinates(5, 9).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None).WithOnStartDialog(6213)
)

local portal_0_6_to_1_6 = Portal.Create(PortalType.TsNormal).From(map_0_6, 23, 12).To(map_1_6, 1, 11).MinimapOrientation(PortalMinimapOrientation.East)
local portal_1_6_to_2_6 = Portal.Create(PortalType.TsNormal).From(map_1_6, 23, 11).To(map_2_6, 1, 11).MinimapOrientation(PortalMinimapOrientation.East)
local portal_1_6_to_0_6 = Portal.Create(PortalType.TsNormal).From(map_1_6, 1, 11).To(map_0_6, 23, 12).MinimapOrientation(PortalMinimapOrientation.West)
local portal_2_6_to_3_6 = Portal.Create(PortalType.Locked).From(map_2_6, 23, 11).To(map_3_6, 1, 11).MinimapOrientation(PortalMinimapOrientation.East)
local portal_2_6_to_1_6 = Portal.Create(PortalType.Locked).From(map_2_6, 1, 11).To(map_1_6, 23, 11).MinimapOrientation(PortalMinimapOrientation.West)
local portal_3_6_to_4_6 = Portal.Create(PortalType.Locked).From(map_3_6, 23, 11).To(map_4_6, 1, 12).MinimapOrientation(PortalMinimapOrientation.East)
local portal_3_6_to_2_6 = Portal.Create(PortalType.Locked).From(map_3_6, 1, 11).To(map_2_6, 23, 11).MinimapOrientation(PortalMinimapOrientation.West)
local portal_4_6_to_4_5 = Portal.Create(PortalType.Locked).From(map_4_6, 12, 1).To(map_4_5, 12, 23).MinimapOrientation(PortalMinimapOrientation.North)
local portal_4_6_to_5_6 = Portal.Create(PortalType.Locked).From(map_4_6, 23, 12).To(map_5_6, 1, 12).MinimapOrientation(PortalMinimapOrientation.East)
local portal_4_6_to_4_7 = Portal.Create(PortalType.Locked).From(map_4_6, 12, 23).To(map_4_7, 12, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_4_6_to_3_6 = Portal.Create(PortalType.Locked).From(map_4_6, 1, 12).To(map_3_6, 23, 11).MinimapOrientation(PortalMinimapOrientation.West)
local portal_4_5_to_4_6 = Portal.Create(PortalType.Locked).From(map_4_5, 12, 23).To(map_4_6, 12, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_4_7_to_4_6 = Portal.Create(PortalType.Locked).From(map_4_7, 12, 1).To(map_4_6, 12, 23).MinimapOrientation(PortalMinimapOrientation.North)
local portal_5_6_to_5_5 = Portal.Create(PortalType.Locked).From(map_5_6, 12, 1).To(map_5_5, 12, 23).MinimapOrientation(PortalMinimapOrientation.North)
local portal_5_6_to_6_6 = Portal.Create(PortalType.Locked).From(map_5_6, 23, 12).To(map_6_6, 1, 11).MinimapOrientation(PortalMinimapOrientation.East)
local portal_5_6_to_5_7 = Portal.Create(PortalType.Locked).From(map_5_6, 12, 23).To(map_5_7, 12, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_5_6_to_4_6 = Portal.Create(PortalType.Locked).From(map_5_6, 1, 12).To(map_4_6, 23, 12).MinimapOrientation(PortalMinimapOrientation.West)
local portal_5_5_to_5_6 = Portal.Create(PortalType.Locked).From(map_5_5, 12, 23).To(map_5_6, 12, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_5_7_to_5_6 = Portal.Create(PortalType.Locked).From(map_5_7, 12, 1).To(map_5_6, 12, 23).MinimapOrientation(PortalMinimapOrientation.North)
local portal_6_6_to_7_6 = Portal.Create(PortalType.Locked).From(map_6_6, 23, 11).To(map_7_6, 1, 12).MinimapOrientation(PortalMinimapOrientation.East)
local portal_6_6_to_5_6 = Portal.Create(PortalType.Locked).From(map_6_6, 1, 11).To(map_5_6, 23, 12).MinimapOrientation(PortalMinimapOrientation.West)
local portal_7_6_to_7_7 = Portal.Create(PortalType.TsNormal).From(map_7_6, 12, 23).To(map_7_7, 12, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_7_6_to_6_6 = Portal.Create(PortalType.TsNormal).From(map_7_6, 1, 12).To(map_6_6, 23, 11).MinimapOrientation(PortalMinimapOrientation.West)
local portal_7_7_to_7_6 = Portal.Create(PortalType.Locked).From(map_7_7, 12, 1).To(map_7_6, 12, 23).MinimapOrientation(PortalMinimapOrientation.North)
local portal_7_7_to_7_8 = Portal.Create(PortalType.Locked).From(map_7_7, 12, 23).To(map_7_8, 12, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_7_8_to_7_7 = Portal.Create(PortalType.TsNormal).From(map_7_8, 12, 1).To(map_7_7, 12, 23).MinimapOrientation(PortalMinimapOrientation.North)
local portal_7_8_to_7_9 = Portal.Create(PortalType.TsNormal).From(map_7_8, 12, 23).To(map_7_9, 12, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_7_9_to_7_8 = Portal.Create(PortalType.Locked).From(map_7_9, 12, 1).To(map_7_8, 12, 23).MinimapOrientation(PortalMinimapOrientation.North)
local portal_7_9_to_6_9 = Portal.Create(PortalType.Locked).From(map_7_9, 1, 12).To(map_6_9, 23, 11).MinimapOrientation(PortalMinimapOrientation.West)
local portal_6_9_to_7_9 = Portal.Create(PortalType.Locked).From(map_6_9, 23, 11).To(map_7_9, 1, 12).MinimapOrientation(PortalMinimapOrientation.East)
local portal_6_9_to_5_9 = Portal.Create(PortalType.Locked).From(map_6_9, 1, 11).To(map_5_9, 23, 11).MinimapOrientation(PortalMinimapOrientation.West)
local portal_5_9_to_6_9 = Portal.Create(PortalType.TsNormal).From(map_5_9, 23, 11).To(map_6_9, 1, 11).MinimapOrientation(PortalMinimapOrientation.East)
local portal_5_9_to_UNKNOWN = Portal.Create(PortalType.TSEnd).From(map_5_9, 1, 11).To(map_5_9, 1, 11).MinimapOrientation(PortalMinimapOrientation.West)

map_0_6.AddPortal(portal_0_6_to_1_6)
map_1_6.AddPortal(portal_1_6_to_2_6)
map_1_6.AddPortal(portal_1_6_to_0_6)
map_2_6.AddPortal(portal_2_6_to_3_6)
map_2_6.AddPortal(portal_2_6_to_1_6)
map_3_6.AddPortal(portal_3_6_to_4_6)
map_3_6.AddPortal(portal_3_6_to_2_6)
map_4_6.AddPortal(portal_4_6_to_4_5)
map_4_6.AddPortal(portal_4_6_to_5_6)
map_4_6.AddPortal(portal_4_6_to_4_7)
map_4_6.AddPortal(portal_4_6_to_3_6)
map_4_5.AddPortal(portal_4_5_to_4_6)
map_4_7.AddPortal(portal_4_7_to_4_6)
map_5_6.AddPortal(portal_5_6_to_5_5)
map_5_6.AddPortal(portal_5_6_to_6_6)
map_5_6.AddPortal(portal_5_6_to_5_7)
map_5_6.AddPortal(portal_5_6_to_4_6)
map_5_5.AddPortal(portal_5_5_to_5_6)
map_5_7.AddPortal(portal_5_7_to_5_6)
map_6_6.AddPortal(portal_6_6_to_7_6)
map_6_6.AddPortal(portal_6_6_to_5_6)
map_7_6.AddPortal(portal_7_6_to_7_7)
map_7_6.AddPortal(portal_7_6_to_6_6)
map_7_7.AddPortal(portal_7_7_to_7_6)
map_7_7.AddPortal(portal_7_7_to_7_8)
map_7_8.AddPortal(portal_7_8_to_7_7)
map_7_8.AddPortal(portal_7_8_to_7_9)
map_7_9.AddPortal(portal_7_9_to_7_8)
map_7_9.AddPortal(portal_7_9_to_6_9)
map_6_9.AddPortal(portal_6_9_to_7_9)
map_6_9.AddPortal(portal_6_9_to_5_9)
map_5_9.AddPortal(portal_5_9_to_6_9)
map_5_9.AddPortal(portal_5_9_to_UNKNOWN)

--- Map 0_6
map_0_6.OnMapJoin({
    Event.TryStartTaskForMap(map_0_6),
})
---

--- Map 1_6
map_1_6.OnMapJoin({
    Event.TryStartTaskForMap(map_1_6),
})
---

--- Map 2_6
map_2_6.AddMonsters({
    Monster.CreateWithVnum(148).At(14, 11).Facing(7), -- Rookie Kenko Spearman [15:51:29]
    Monster.CreateWithVnum(148).At(9, 12).Facing(1), -- Rookie Kenko Spearman [15:51:29]
    Monster.CreateWithVnum(148).At(8, 9).Facing(5), -- Rookie Kenko Spearman [15:51:29]
    Monster.CreateWithVnum(151).At(12, 14).Facing(6).SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:51:33]
    Monster.CreateWithVnum(151).At(18, 14).Facing(3).SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:51:33]
    Monster.CreateWithVnum(151).At(11, 7).Facing(7).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:51:34]
    Monster.CreateWithVnum(151).At(15, 9).Facing(6).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:51:34]
    Monster.CreateWithVnum(152).At(16, 15).Facing(1).SpawnAfterMobsKilled(6), -- Kenko Raider [15:51:37]
})
map_2_6.OnMapJoin({
    Event.TryStartTaskForMap(map_2_6),
})
map_2_6.OnTaskFinish({
    Event.OpenPortal(portal_2_6_to_3_6),
})
---

--- Map 3_6
map_3_6.AddMonsters({
    Monster.CreateWithVnum(148).At(12, 12).Facing(2), -- Rookie Kenko Spearman [15:51:44]
    Monster.CreateWithVnum(148).At(9, 12).Facing(0), -- Rookie Kenko Spearman [15:51:44]
    Monster.CreateWithVnum(148).At(8, 9).Facing(7), -- Rookie Kenko Spearman [15:51:44]
    Monster.CreateWithVnum(151).At(12, 14).Facing(3).SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:51:48]
    Monster.CreateWithVnum(151).At(18, 14).Facing(1).SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:51:48]
    Monster.CreateWithVnum(151).At(11, 7).Facing(4).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:51:49]
    Monster.CreateWithVnum(151).At(15, 9).Facing(7).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:51:49]
    Monster.CreateWithVnum(152).At(16, 15).Facing(7).SpawnAfterMobsKilled(6), -- Kenko Raider [15:51:52]
})
map_3_6.OnMapJoin({
    Event.TryStartTaskForMap(map_3_6),
})
map_3_6.OnTaskFinish({
    Event.OpenPortal(portal_3_6_to_4_6),
})
---

--- Map 4_6
map_4_6.AddObjects({
    MapObject.CreateLever().At(12, 12).OnSwitch({
        Event.TogglePortal(portal_4_6_to_4_5),
        Event.TogglePortal(portal_4_6_to_4_7),
    }), -- [15:51:58]
})
map_4_6.OnMapJoin({
    Event.TryStartTaskForMap(map_4_6),
    Event.CheckForTasksCompleted({map_4_5, map_4_7}, {
        Event.OpenPortal(portal_4_6_to_5_6),
    }),
})
---

--- Map 5_6
map_5_6.AddObjects({
    MapObject.CreateLever().At(12, 12).OnSwitch({
        Event.TogglePortal(portal_5_6_to_5_5),
        Event.TogglePortal(portal_5_6_to_5_7),
    }), -- [15:52:48]
})
map_5_6.OnMapJoin({
    Event.TryStartTaskForMap(map_5_6),
    Event.CheckForTasksCompleted({map_5_5, map_5_7}, {
        Event.OpenPortal(portal_5_6_to_6_6),
    }),
})
---

--- Map 6_6
map_6_6.AddMonsters({
    Monster.CreateWithVnum(148).At(8, 9).Facing(4).SpawnAfterTaskStart(), -- Rookie Kenko Spearman [15:53:42]
    Monster.CreateWithVnum(148).At(9, 12).Facing(4).SpawnAfterTaskStart().SpawnAfterMobsKilled(1), -- Rookie Kenko Spearman [15:53:43]
    Monster.CreateWithVnum(151).At(11, 7).Facing(4).SpawnAfterTaskStart().SpawnAfterMobsKilled(2), -- Rookie Kenko Raider [15:53:45]
    Monster.CreateWithVnum(151).At(12, 14).Facing(0).SpawnAfterTaskStart().SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:53:46]
    Monster.CreateWithVnum(147).At(13, 7).Facing(5).SpawnAfterTaskStart().SpawnAfterMobsKilled(4), -- Elite Kenko Swordsman [15:53:47]
    Monster.CreateWithVnum(148).At(14, 11).Facing(0).SpawnAfterTaskStart().SpawnAfterMobsKilled(5), -- Rookie Kenko Spearman [15:53:48]
    Monster.CreateWithVnum(151).At(15, 9).Facing(5).SpawnAfterTaskStart().SpawnAfterMobsKilled(5), -- Rookie Kenko Raider [15:53:48]
    Monster.CreateWithVnum(149).At(18, 8).Facing(2).SpawnAfterTaskStart().SpawnAfterMobsKilled(6), -- Kenko Spearman [15:53:50]
})
map_6_6.AddObjects({
    MapObject.CreateLever().At(12, 5).OnTrigger({
        Event.TryStartTaskForMap(map_6_6),
    }), -- [15:53:37]
})
map_6_6.OnTaskFinish({
    Event.OpenPortal(portal_6_6_to_7_6),
    Event.AddTime(300),
})
---

--- Map 7_6
map_7_6.AddNpcs({
    MapNpc.CreateNpcWithVnum(316).At(13, 15).Facing(5), -- Kenko Flailman [15:53:56]
    MapNpc.CreateNpcWithVnum(253).At(7, 16).Facing(4), -- Ugly Spearman [15:53:56]
})
map_7_6.OnMapJoin({
    Event.TryStartTaskForMap(map_7_6),
})
---

--- Map 4_7
map_4_7.AddMonsters({
    Monster.CreateWithVnum(148).At(9, 12).Facing(4), -- Rookie Kenko Spearman [15:52:26]
    Monster.CreateWithVnum(148).At(10, 7).Facing(2), -- Rookie Kenko Spearman [15:52:26]
    Monster.CreateWithVnum(148).At(14, 11).Facing(1).SpawnAfterMobsKilled(1), -- Rookie Kenko Spearman [15:52:28]
    Monster.CreateWithVnum(151).At(12, 14).Facing(6).SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:52:30]
    Monster.CreateWithVnum(151).At(11, 7).Facing(2).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:52:32]
    Monster.CreateWithVnum(151).At(15, 9).Facing(4).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:52:32]
    Monster.CreateWithVnum(152).At(16, 15).Facing(0).SpawnAfterMobsKilled(6), -- Kenko Raider [15:52:35]
    Monster.CreateWithVnum(151).At(18, 14).Facing(0).SpawnAfterMobsKilled(6), -- Rookie Kenko Raider [15:52:35]
    Monster.CreateWithVnum(152).At(16, 8).Facing(5).SpawnAfterMobsKilled(7), -- Kenko Raider [15:52:37]
    Monster.CreateWithVnum(149).At(18, 8).Facing(0).SpawnAfterMobsKilled(8), -- Kenko Spearman [15:52:38]
})
map_4_7.OnMapJoin({
    Event.TryStartTaskForMap(map_4_7),
})
map_4_7.OnTaskFinish({
    Event.OpenPortal(portal_4_7_to_4_6),
})
---

--- Map 4_5
map_4_5.AddMonsters({
    Monster.CreateWithVnum(148).At(9, 12).Facing(6), -- Rookie Kenko Spearman [15:52:06]
    Monster.CreateWithVnum(148).At(8, 9).Facing(6), -- Rookie Kenko Spearman [15:52:06]
    Monster.CreateWithVnum(148).At(14, 11).Facing(4).SpawnAfterMobsKilled(1), -- Rookie Kenko Spearman [15:52:07]
    Monster.CreateWithVnum(151).At(15, 9).Facing(4).SpawnAfterMobsKilled(2), -- Rookie Kenko Raider [15:52:09]
    Monster.CreateWithVnum(149).At(18, 8).Facing(0).SpawnAfterMobsKilled(4), -- Kenko Spearman [15:52:13]
    Monster.CreateWithVnum(151).At(18, 14).Facing(3).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:52:13]
    Monster.CreateWithVnum(152).At(16, 15).Facing(7).SpawnAfterMobsKilled(6), -- Kenko Raider [15:52:15]
    Monster.CreateWithVnum(152).At(16, 8).Facing(5).SpawnAfterMobsKilled(7), -- Kenko Raider [15:52:17]
    Monster.CreateWithVnum(147).At(13, 7).Facing(5).SpawnAfterMobsKilled(8), -- Elite Kenko Swordsman [15:52:18]
})
map_4_5.AddObjects({
    MapObject.CreateRegularBox().At(12, 5), -- [15:52:06]
})
map_4_5.OnMapJoin({
    Event.TryStartTaskForMap(map_4_5),
})
map_4_5.OnTaskFinish({
    Event.OpenPortal(portal_4_5_to_4_6),
})
---

--- Map 5_5
map_5_5.AddMonsters({
    Monster.CreateWithVnum(148).At(9, 12).Facing(2), -- Rookie Kenko Spearman [15:52:55]
    Monster.CreateWithVnum(148).At(8, 9).Facing(0), -- Rookie Kenko Spearman [15:52:55]
    Monster.CreateWithVnum(148).At(14, 11).Facing(0).SpawnAfterMobsKilled(1), -- Rookie Kenko Spearman [15:52:57]
    Monster.CreateWithVnum(151).At(12, 14).Facing(6).SpawnAfterMobsKilled(2), -- Rookie Kenko Raider [15:52:58]
    Monster.CreateWithVnum(151).At(18, 14).Facing(5).SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:53:00]
    Monster.CreateWithVnum(151).At(11, 7).Facing(6).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:53:01]
    Monster.CreateWithVnum(151).At(15, 9).Facing(5).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:53:01]
    Monster.CreateWithVnum(149).At(18, 8).Facing(4).SpawnAfterMobsKilled(7), -- Kenko Spearman [15:53:06]
})
map_5_5.OnMapJoin({
    Event.TryStartTaskForMap(map_5_5),
})
map_5_5.OnTaskFinish({
    Event.OpenPortal(portal_5_5_to_5_6),
})
---

--- Map 5_7
map_5_7.AddMonsters({
    Monster.CreateWithVnum(148).At(14, 11).Facing(7), -- Rookie Kenko Spearman [15:53:18]
    Monster.CreateWithVnum(148).At(8, 9).Facing(1), -- Rookie Kenko Spearman [15:53:18]
    Monster.CreateWithVnum(152).At(16, 8).Facing(7).SpawnAfterMobsKilled(1), -- Kenko Raider [15:53:20]
    Monster.CreateWithVnum(151).At(18, 14).Facing(6).SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:53:23]
    Monster.CreateWithVnum(149).At(18, 8).Facing(1).SpawnAfterMobsKilled(4), -- Kenko Spearman [15:53:24]
    Monster.CreateWithVnum(151).At(15, 9).Facing(2).SpawnAfterMobsKilled(5), -- Rookie Kenko Raider [15:53:26]
    Monster.CreateWithVnum(152).At(16, 15).Facing(1).SpawnAfterMobsKilled(5), -- Kenko Raider [15:53:26]
})
map_5_7.AddObjects({
    MapObject.CreateRegularBox().At(13, 18), -- [15:53:18]
})
map_5_7.OnMapJoin({
    Event.TryStartTaskForMap(map_5_7),
})
map_5_7.OnTaskFinish({
    Event.OpenPortal(portal_5_7_to_5_6),
})
---

--- Map 7_7
map_7_7.AddMonsters({
    Monster.CreateWithVnum(148).At(9, 12).Facing(6), -- Rookie Kenko Spearman [15:54:01]
    Monster.CreateWithVnum(148).At(8, 9).Facing(0), -- Rookie Kenko Spearman [15:54:01]
    Monster.CreateWithVnum(148).At(14, 11).Facing(4).SpawnAfterMobsKilled(1), -- Rookie Kenko Spearman [15:54:03]
    Monster.CreateWithVnum(151).At(12, 14).Facing(2).SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:54:05]
    Monster.CreateWithVnum(151).At(18, 14).Facing(7).SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:54:05]
    Monster.CreateWithVnum(151).At(11, 7).Facing(7).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:54:07]
    Monster.CreateWithVnum(151).At(15, 9).Facing(1).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:54:07]
    Monster.CreateWithVnum(152).At(16, 15).Facing(6).SpawnAfterMobsKilled(6), -- Kenko Raider [15:54:09]
    Monster.CreateWithVnum(152).At(16, 8).Facing(4).SpawnAfterMobsKilled(7), -- Kenko Raider [15:54:11]
    Monster.CreateWithVnum(149).At(18, 8).Facing(0).SpawnAfterMobsKilled(8), -- Kenko Spearman [15:54:12]
    Monster.CreateWithVnum(153).At(16, 11).Facing(2).SpawnAfterMobsKilled(9), -- Elite Kenko Raider [15:54:13]
})
map_7_7.AddObjects({
    MapObject.CreateOldBox().At(6, 16), -- [15:54:01]
    MapObject.CreateOldBox().At(6, 13), -- [15:54:01]
})
map_7_7.OnMapJoin({
    Event.TryStartTaskForMap(map_7_7),
})
map_7_7.OnTaskFinish({
    Event.OpenPortal(portal_7_7_to_7_6),
    Event.OpenPortal(portal_7_7_to_7_8),
})
---

--- Map 7_8
map_7_8.AddNpcs({
    MapNpc.CreateNpcWithVnum(329).At(12, 6).Facing(2).WithCustomLevel(45), -- Kenel [15:54:35]
    MapNpc.CreateNpcWithVnum(307).At(10, 6).Facing(0).WithCustomLevel(47), -- Korrkoaren [15:54:35]
})
map_7_8.OnMapJoin({
    Event.TryStartTaskForMap(map_7_8),
})
---

--- Map 7_9
map_7_9.AddMonsters({
    Monster.CreateWithVnum(148).At(14, 11).Facing(1), -- Rookie Kenko Spearman [15:54:40]
    Monster.CreateWithVnum(148).At(8, 9).Facing(4), -- Rookie Kenko Spearman [15:54:40]
    Monster.CreateWithVnum(152).At(16, 15).Facing(4).SpawnAfterMobsKilled(2), -- Kenko Raider [15:54:43]
    Monster.CreateWithVnum(151).At(12, 14).Facing(2).SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:54:44]
    Monster.CreateWithVnum(151).At(18, 14).Facing(3).SpawnAfterMobsKilled(3), -- Rookie Kenko Raider [15:54:44]
    Monster.CreateWithVnum(151).At(15, 9).Facing(3).SpawnAfterMobsKilled(4), -- Rookie Kenko Raider [15:54:45]
    Monster.CreateWithVnum(149).At(18, 8).Facing(2).SpawnAfterMobsKilled(4), -- Kenko Spearman [15:54:45]
    Monster.CreateWithVnum(147).At(13, 7).Facing(0).SpawnAfterMobsKilled(7), -- Elite Kenko Swordsman [15:54:49]
    Monster.CreateWithVnum(153).At(16, 11).Facing(2).SpawnAfterMobsKilled(8), -- Elite Kenko Raider [15:54:50]
})
map_7_9.OnMapJoin({
    Event.TryStartTaskForMap(map_7_9),
})
map_7_9.OnTaskFinish({
    Event.OpenPortal(portal_7_9_to_7_8),
    Event.OpenPortal(portal_7_9_to_6_9),
})
---

--- Map 6_9
map_6_9.AddMonsterWaves({
    -- wave 1
    MonsterWave.CreateWithDelay(0 * 30).WithMonsters({
        Monster.CreateWithVnum(316).At(20, 10).Facing(2).WithCustomLevel(47), -- Kenko Flailman [15:54:56]
        Monster.CreateWithVnum(253).At(14, 5).Facing(6).WithCustomLevel(55), -- Ugly Spearman [15:54:56]
    }),
    -- wave 2
    MonsterWave.CreateWithDelay(1 * 30).WithMonsters({
    Monster.CreateWithVnum(253).At(16, 12).Facing(5).WithCustomLevel(55), -- Ugly Spearman [15:55:56]
    Monster.CreateWithVnum(253).At(19, 14).Facing(3).WithCustomLevel(55), -- Ugly Spearman [15:55:56]
    Monster.CreateWithVnum(253).At(8, 9).Facing(3).WithCustomLevel(55), -- Ugly Spearman [15:55:56]
    }),
    -- wave 3
    MonsterWave.CreateWithDelay(2 * 30).WithMonsters({
    Monster.CreateWithVnum(253).At(17, 9).Facing(0).WithCustomLevel(55), -- Ugly Spearman [15:56:27]
    Monster.CreateWithVnum(253).At(17, 5).Facing(5).WithCustomLevel(55), -- Ugly Spearman [15:56:27]
    Monster.CreateWithVnum(253).At(19, 10).Facing(2).WithCustomLevel(55), -- Ugly Spearman [15:56:27]
    }),
    -- wave 4
    MonsterWave.CreateWithDelay(3 * 30).WithMonsters({
    Monster.CreateWithVnum(253).At(7, 15).Facing(7).WithCustomLevel(55), -- Ugly Spearman [15:56:56]
    Monster.CreateWithVnum(253).At(14, 15).Facing(1).WithCustomLevel(55), -- Ugly Spearman [15:56:56]
    Monster.CreateWithVnum(253).At(10, 15).Facing(0).WithCustomLevel(55), -- Ugly Spearman [15:56:56]
    }),
    -- wave 5
    MonsterWave.CreateWithDelay(4 * 30).WithMonsters({
    Monster.CreateWithVnum(253).At(16, 8).Facing(5).WithCustomLevel(55), -- Ugly Spearman [15:57:26]
    Monster.CreateWithVnum(253).At(13, 7).Facing(3).WithCustomLevel(55), -- Ugly Spearman [15:57:26]
    Monster.CreateWithVnum(253).At(9, 8).Facing(4).WithCustomLevel(55), -- Ugly Spearman [15:57:26]
    }),
})
map_6_9.AddNpcs({
    MapNpc.CreateNpcWithVnum(315).At(20, 14).Facing(6).WithMustProtectAura().WithCustomLevel(45).WithHpMpMultiplier(2), -- Kenel [15:54:55]
    MapNpc.CreateNpcWithVnum(307).At(20, 12).Facing(5).WithMustProtectAura().WithCustomLevel(47).WithHpMpMultiplier(2), -- Korrkoaren [15:54:55]
})
map_6_9.OnMapJoin({
    Event.TryStartTaskForMap(map_6_9),
})
map_6_9.OnTaskFinish({
    Event.OpenPortal(portal_6_9_to_5_9),
    Event.OpenPortal(portal_6_9_to_7_9),
})
---

--- Map 5_9
map_5_9.OnMapJoin({
    Event.TryStartTaskForMap(map_5_9),
})
---

local ts = TimeSpace.Create(33)  -- TimeSpace ID
    .SetMaps({map_0_6, map_1_6, map_2_6, map_3_6, map_4_6, map_5_6, map_6_6, map_7_6, map_4_7, map_4_5, map_5_5, map_5_7, map_7_7, map_7_8, map_7_9, map_6_9, map_5_9})
    .SetSpawn(Location.InMap(map_0_6).At(12, 8))
    .SetLives(3)
    .SetObjectives(objectives)
    .SetDurationInSeconds(1200)
    .SetBonusPointItemDropChance(5000)
return ts
