-- 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 objectives = TimeSpaceObjective.Create()
    .WithGoToExit()

local map_0_8 = Map.Create().WithMapId(4203).SetMapCoordinates(0, 8).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None)
) -- start
local map_0_9 = Map.Create().WithMapId(4207).SetMapCoordinates(0, 9).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None).WithOnStartDialog(6083)
)
local map_1_9 = Map.Create().WithMapId(4213).SetMapCoordinates(1, 9).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None)
)
local map_1_10 = Map.Create().WithMapId(4201).SetMapCoordinates(1, 10).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_17_TEXT_0").WithOnFinishDialog(6084)
)
local map_2_9 = Map.Create().WithMapId(4211).SetMapCoordinates(2, 9).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None)
)
local map_2_8 = Map.Create().WithMapId(4203).SetMapCoordinates(2, 8).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_17_TEXT_1").WithOnStartDialog(6085).WithOnFinishDialog(6086)
)
local map_3_9 = Map.Create().WithMapId(4209).SetMapCoordinates(3, 9).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None)
)
local map_3_10 = Map.Create().WithMapId(4206).SetMapCoordinates(3, 10).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_17_TEXT_2").WithOnStartDialog(6087).WithOnFinishDialog(6088)
)

local portal_0_8_to_0_9 = Portal.Create(PortalType.TsNormal).From(map_0_8, 14, 28).To(map_0_9, 14, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_0_9_to_0_8 = Portal.Create(PortalType.TsNormal).From(map_0_9, 14, 1).To(map_0_8, 14, 28).MinimapOrientation(PortalMinimapOrientation.North)
local portal_0_9_to_1_9 = Portal.Create(PortalType.TsNormal).From(map_0_9, 28, 15).To(map_1_9, 1, 15).MinimapOrientation(PortalMinimapOrientation.East)
local portal_1_9_to_2_9 = Portal.Create(PortalType.Locked).From(map_1_9, 28, 15).To(map_2_9, 1, 15).MinimapOrientation(PortalMinimapOrientation.East)
local portal_1_9_to_1_10 = Portal.Create(PortalType.TsNormal).From(map_1_9, 14, 28).To(map_1_10, 14, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_1_9_to_0_9 = Portal.Create(PortalType.TsNormal).From(map_1_9, 1, 15).To(map_0_9, 28, 15).MinimapOrientation(PortalMinimapOrientation.West)
local portal_1_10_to_1_9 = Portal.Create(PortalType.Locked).From(map_1_10, 14, 1).To(map_1_9, 14, 28).MinimapOrientation(PortalMinimapOrientation.North)
local portal_2_9_to_2_8 = Portal.Create(PortalType.TsNormal).From(map_2_9, 14, 1).To(map_2_8, 14, 28).MinimapOrientation(PortalMinimapOrientation.North)
local portal_2_9_to_3_9 = Portal.Create(PortalType.Locked).From(map_2_9, 29, 15).To(map_3_9, 1, 15).MinimapOrientation(PortalMinimapOrientation.East)
local portal_2_9_to_1_9 = Portal.Create(PortalType.TsNormal).From(map_2_9, 1, 15).To(map_1_9, 28, 15).MinimapOrientation(PortalMinimapOrientation.West)
local portal_2_8_to_2_9 = Portal.Create(PortalType.Locked).From(map_2_8, 14, 28).To(map_2_9, 14, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_3_9_to_3_10 = Portal.Create(PortalType.TsNormal).From(map_3_9, 14, 28).To(map_3_10, 14, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_3_9_to_2_9 = Portal.Create(PortalType.TsNormal).From(map_3_9, 1, 15).To(map_2_9, 29, 15).MinimapOrientation(PortalMinimapOrientation.West)
local portal_3_10_to_3_9 = Portal.Create(PortalType.TsNormal).From(map_3_10, 14, 1).To(map_3_9, 14, 28).MinimapOrientation(PortalMinimapOrientation.North)
local portal_3_10_to_UNKNOWN = Portal.Create(PortalType.TSEndClosed).From(map_3_10, 14, 28).To(map_3_10, 14, 28).MinimapOrientation(PortalMinimapOrientation.South)

map_0_8.AddPortal(portal_0_8_to_0_9)
map_0_9.AddPortal(portal_0_9_to_0_8)
map_0_9.AddPortal(portal_0_9_to_1_9)
map_1_9.AddPortal(portal_1_9_to_2_9)
map_1_9.AddPortal(portal_1_9_to_1_10)
map_1_9.AddPortal(portal_1_9_to_0_9)
map_1_10.AddPortal(portal_1_10_to_1_9)
map_2_9.AddPortal(portal_2_9_to_2_8)
map_2_9.AddPortal(portal_2_9_to_3_9)
map_2_9.AddPortal(portal_2_9_to_1_9)
map_2_8.AddPortal(portal_2_8_to_2_9)
map_3_9.AddPortal(portal_3_9_to_3_10)
map_3_9.AddPortal(portal_3_9_to_2_9)
map_3_10.AddPortal(portal_3_10_to_3_9)
map_3_10.AddPortal(portal_3_10_to_UNKNOWN)

--- Map 0_8
map_0_8.OnMapJoin({
    Event.TryStartTaskForMap(map_0_8),
})
---

--- Map 0_9
map_0_9.OnMapJoin({
    Event.TryStartTaskForMap(map_0_9),
})
---

--- Map 1_9
map_1_9.OnMapJoin({
    Event.TryStartTaskForMap(map_1_9),
})
---

--- Map 1_10
map_1_10.AddMonsters({
    Monster.CreateWithVnum(66).At(17, 13).Facing(5), -- Tired Thornwalker [16:29:16]
    Monster.CreateWithVnum(66).At(9, 15).Facing(7), -- Tired Thornwalker [16:29:16]
})
map_1_10.AddNpcs({
    MapNpc.CreateNpcWithVnum(318).At(11, 15).Facing(3), -- Tom [16:29:16]
})
map_1_10.OnMapJoin({
    Event.TryStartTaskForMap(map_1_10),
})
map_1_10.OnTaskFinish({
    Event.OpenPortal(portal_1_10_to_1_9),
    Event.OpenPortal(portal_1_9_to_2_9),
    Event.AddTime(120),
})
---

--- Map 2_8
map_2_8.AddMonsters({
    Monster.CreateWithVnum(318).At(14, 12).Facing(4).OnHalfHp({
        Event.DespawnAllMobsInRoom(map_2_8),
    }), -- Tom [16:29:50]
})
map_2_8.AddObjects({
    MapObject.CreateOldBox().At(24, 14), -- [16:29:48]
    MapObject.CreateOldBox().At(5, 13), -- [16:29:48]
})
map_2_8.OnMapJoin({
    Event.TryStartTaskForMap(map_2_8),
})
map_2_8.OnTaskFinish({
    Event.OpenPortal(portal_2_8_to_2_9),
    Event.OpenPortal(portal_2_9_to_3_9),
    Event.AddTime(120),
})
---

--- Map 2_9
map_2_9.AddMonsters({
    Monster.CreateWithVnum(58).At(27, 12).Facing(0), -- Fire Vampie [16:29:31]
    Monster.CreateWithVnum(58).At(18, 9).Facing(2), -- Fire Vampie [16:29:31]
    Monster.CreateWithVnum(58).At(12, 6).Facing(7), -- Fire Vampie [16:29:31]
    Monster.CreateWithVnum(58).At(6, 14).Facing(5).SpawnAfterMobsKilled(1), -- Fire Vampie [16:29:34]
    Monster.CreateWithVnum(58).At(12, 20).Facing(2).SpawnAfterMobsKilled(2), -- Fire Vampie [16:29:35]
    Monster.CreateWithVnum(66).At(20, 17).Facing(4).SpawnAfterMobsKilled(4), -- Tired Thornwalker [16:29:38]
    Monster.CreateWithVnum(66).At(11, 17).Facing(3).SpawnAfterMobsKilled(5), -- Tired Thornwalker [16:29:40]
    Monster.CreateWithVnum(66).At(16, 13).Facing(3).SpawnAfterMobsKilled(5), -- Tired Thornwalker [16:29:40]
})
map_2_9.OnMapJoin({
    Event.TryStartTaskForMap(map_2_9),
})
---

--- Map 3_9
map_3_9.AddMonsters({
    Monster.CreateWithVnum(58).At(23, 11).Facing(5), -- Fire Vampie [16:30:02]
    Monster.CreateWithVnum(58).At(10, 6).Facing(3), -- Fire Vampie [16:30:02]
    Monster.CreateWithVnum(58).At(17, 19).Facing(1), -- Fire Vampie [16:30:02]
    Monster.CreateWithVnum(58).At(7, 14).Facing(2).SpawnAfterMobsKilled(1), -- Fire Vampie [16:30:04]
    Monster.CreateWithVnum(58).At(10, 10).Facing(3).SpawnAfterMobsKilled(1), -- Fire Vampie [16:30:04]
    Monster.CreateWithVnum(66).At(19, 18).Facing(5).SpawnAfterMobsKilled(4), -- Tired Thornwalker [16:30:11]
    Monster.CreateWithVnum(66).At(16, 12).Facing(2).SpawnAfterMobsKilled(5), -- Tired Thornwalker [16:30:12]
    Monster.CreateWithVnum(66).At(12, 12).Facing(1).SpawnAfterMobsKilled(6), -- Tired Thornwalker [16:30:13]
})
map_3_9.OnMapJoin({
    Event.TryStartTaskForMap(map_3_9),
})
---

--- Map 3_10
map_3_10.AddMonsters({
    Monster.CreateWithVnum(318).At(12, 16).Facing(6), -- Tom [16:30:21]
})
map_3_10.OnMapJoin({
    Event.TryStartTaskForMap(map_3_10),
})
map_3_10.OnTaskFinish({
    Event.OpenPortal(portal_3_10_to_UNKNOWN),
})
---

local ts = TimeSpace.Create(17)  -- TimeSpace ID
    .SetMaps({map_0_8, map_0_9, map_1_9, map_1_10, map_2_9, map_2_8, map_3_9, map_3_10})
    .SetSpawn(Location.InMap(map_0_8).At(7, 11))
    .SetLives(2)
    .SetObjectives(objectives)
    .SetDurationInSeconds(140)
    .SetBonusPointItemDropChance(5000)
return ts
