-- 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()

local map_0_8 = Map.Create().WithMapId(4202).SetMapCoordinates(0, 8).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None)
) -- start
local map_1_8 = Map.Create().WithMapId(4205).SetMapCoordinates(1, 8).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.Survive, 120).WithTaskText("TS_19_TEXT_0").WithOnStartDialog(6101).WithOnFinishShout("TS_19_TEXT_1")
)
local map_2_8 = Map.Create().WithMapId(4205).SetMapCoordinates(2, 8).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.Survive, 60).WithTaskText("TS_19_TEXT_2").WithOnStartDialog(6102).WithOnFinishShout("TS_19_TEXT_1")
)
local map_3_8 = Map.Create().WithMapId(4205).SetMapCoordinates(3, 8).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.Survive, 120).WithTaskText("TS_19_TEXT_0").WithOnFinishShout("TS_19_TEXT_1")
)
local map_4_8 = Map.Create().WithMapId(4205).SetMapCoordinates(4, 8).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None).WithOnStartDialog(6103)
)

local portal_0_8_to_1_8 = Portal.Create(PortalType.TsNormal).From(map_0_8, 28, 15).To(map_1_8, 1, 15).MinimapOrientation(PortalMinimapOrientation.East)
local portal_1_8_to_2_8 = Portal.Create(PortalType.Locked).From(map_1_8, 28, 15).To(map_2_8, 1, 15).MinimapOrientation(PortalMinimapOrientation.East)
local portal_1_8_to_0_8 = Portal.Create(PortalType.Locked).From(map_1_8, 1, 15).To(map_0_8, 28, 15).MinimapOrientation(PortalMinimapOrientation.West)
local portal_2_8_to_3_8 = Portal.Create(PortalType.Locked).From(map_2_8, 28, 15).To(map_3_8, 1, 15).MinimapOrientation(PortalMinimapOrientation.East)
local portal_2_8_to_1_8 = Portal.Create(PortalType.Locked).From(map_2_8, 1, 15).To(map_1_8, 28, 15).MinimapOrientation(PortalMinimapOrientation.West)
local portal_3_8_to_4_8 = Portal.Create(PortalType.Locked).From(map_3_8, 28, 15).To(map_4_8, 1, 15).MinimapOrientation(PortalMinimapOrientation.East)
local portal_3_8_to_2_8 = Portal.Create(PortalType.Locked).From(map_3_8, 1, 15).To(map_2_8, 28, 15).MinimapOrientation(PortalMinimapOrientation.West)
local portal_4_8_to_UNKNOWN = Portal.Create(PortalType.TSEnd).From(map_4_8, 28, 15).To(map_4_8, 28, 15).MinimapOrientation(PortalMinimapOrientation.East)
local portal_4_8_to_3_8 = Portal.Create(PortalType.TsNormal).From(map_4_8, 1, 15).To(map_3_8, 28, 15).MinimapOrientation(PortalMinimapOrientation.West)

map_0_8.AddPortal(portal_0_8_to_1_8)
map_1_8.AddPortal(portal_1_8_to_2_8)
map_1_8.AddPortal(portal_1_8_to_0_8)
map_2_8.AddPortal(portal_2_8_to_3_8)
map_2_8.AddPortal(portal_2_8_to_1_8)
map_3_8.AddPortal(portal_3_8_to_4_8)
map_3_8.AddPortal(portal_3_8_to_2_8)
map_4_8.AddPortal(portal_4_8_to_UNKNOWN)
map_4_8.AddPortal(portal_4_8_to_3_8)

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

--- Map 1_8
map_1_8.AddMonsterWaves({
    -- wave 1
    MonsterWave.CreateWithDelay(0 * 30).WithMonsters({
        Monster.CreateWithVnum(12).At(12, 9).Facing(1), -- Small Mufflon [16:50:19]
        Monster.CreateWithVnum(12).At(11, 14).Facing(4), -- Small Mufflon [16:50:19]
        Monster.CreateWithVnum(4).At(13, 6).Facing(5), -- Dusi-Fox [16:50:19]
        Monster.CreateWithVnum(140).At(14, 9).Facing(6), -- Small Mimic [16:50:19]
        Monster.CreateWithVnum(4).At(14, 22).Facing(0), -- Dusi-Fox [16:50:19]
        Monster.CreateWithVnum(140).At(15, 18).Facing(1), -- Small Mimic [16:50:19]
        Monster.CreateWithVnum(99).At(19, 18).Facing(6), -- Weak Poisonous Hamster [16:50:19]
    }),
    -- wave 2
    MonsterWave.CreateWithDelay(1 * 30).WithMonsters({
        Monster.CreateWithVnum(4).At(13, 6).Facing(2), -- Dusi-Fox [16:50:49]
        Monster.CreateWithVnum(140).At(14, 9).Facing(4), -- Small Mimic [16:50:49]
        Monster.CreateWithVnum(4).At(14, 22).Facing(0), -- Dusi-Fox [16:50:49]
        Monster.CreateWithVnum(140).At(15, 18).Facing(7), -- Small Mimic [16:50:49]
        Monster.CreateWithVnum(99).At(19, 18).Facing(4), -- Weak Poisonous Hamster [16:50:49]
    }),
    -- wave 3
    MonsterWave.CreateWithDelay(2 * 30).WithMonsters({
        Monster.CreateWithVnum(4).At(13, 6).Facing(6), -- Dusi-Fox [16:51:19]
        Monster.CreateWithVnum(140).At(14, 9).Facing(2), -- Small Mimic [16:51:19]
        Monster.CreateWithVnum(4).At(14, 22).Facing(0), -- Dusi-Fox [16:51:19]
        Monster.CreateWithVnum(140).At(15, 18).Facing(3), -- Small Mimic [16:51:19]
        Monster.CreateWithVnum(99).At(19, 18).Facing(2), -- Weak Poisonous Hamster [16:51:19]
    }),
    -- wave 4
    MonsterWave.CreateWithDelay(3 * 30).WithMonsters({
        Monster.CreateWithVnum(4).At(13, 6).Facing(5), -- Dusi-Fox [16:51:49]
        Monster.CreateWithVnum(140).At(14, 9).Facing(4), -- Small Mimic [16:51:49]
        Monster.CreateWithVnum(4).At(14, 22).Facing(4), -- Dusi-Fox [16:51:49]
        Monster.CreateWithVnum(140).At(15, 18).Facing(6), -- Small Mimic [16:51:49]
        Monster.CreateWithVnum(99).At(19, 18).Facing(0), -- Weak Poisonous Hamster [16:51:49]
    }),
})
map_1_8.OnMapJoin({
    Event.TryStartTaskForMap(map_1_8),
})
map_1_8.OnTaskFinish({
    Event.OpenPortal(portal_1_8_to_2_8),
    Event.AddTime(70),
    Event.DespawnAllMobsInRoom(map_1_8),
})
---

--- Map 2_8
map_2_8.AddMonsterWaves({
    -- wave 1
    MonsterWave.CreateWithDelay(0 * 30).WithMonsters({
        Monster.CreateWithVnum(140).At(15, 8).Facing(2), -- Small Mimic [16:52:21]
        Monster.CreateWithVnum(13).At(9, 10).Facing(4), -- Mufflon [16:52:21]
        Monster.CreateWithVnum(141).At(12, 18).Facing(6), -- Mimic [16:52:22]
        Monster.CreateWithVnum(13).At(16, 12).Facing(5), -- Mufflon [16:52:22]
        Monster.CreateWithVnum(140).At(16, 17).Facing(3), -- Small Mimic [16:52:22]
        Monster.CreateWithVnum(66).At(19, 14).Facing(5), -- Tired Thornwalker [16:52:22]
        Monster.CreateWithVnum(66).At(19, 20).Facing(5), -- Tired Thornwalker [16:52:22]
    }),
    -- wave 2
    MonsterWave.CreateWithDelay(1 * 30).WithMonsters({
        Monster.CreateWithVnum(141).At(12, 18).Facing(4), -- Mimic [16:52:52]
        Monster.CreateWithVnum(13).At(16, 12).Facing(5), -- Mufflon [16:52:52]
        Monster.CreateWithVnum(140).At(16, 17).Facing(6), -- Small Mimic [16:52:52]
        Monster.CreateWithVnum(66).At(19, 14).Facing(4), -- Tired Thornwalker [16:52:52]
        Monster.CreateWithVnum(66).At(19, 20).Facing(0), -- Tired Thornwalker [16:52:52]
    }),
})
map_2_8.AddMonsters({
})
map_2_8.OnMapJoin({
    Event.TryStartTaskForMap(map_2_8),
})
map_2_8.OnTaskFinish({
    Event.OpenPortal(portal_2_8_to_3_8),
    Event.AddTime(120),
    Event.DespawnAllMobsInRoom(map_2_8),
})
---

--- Map 3_8
map_3_8.AddMonsterWaves({
    -- wave 1
    MonsterWave.CreateWithDelay(0 * 30).WithMonsters({
        Monster.CreateWithVnum(66).At(12, 11).Facing(3), -- Tired Thornwalker [16:53:22]
        Monster.CreateWithVnum(141).At(13, 22).Facing(5), -- Mimic [16:53:22]
        Monster.CreateWithVnum(100).At(15, 13).Facing(4), -- Poisonous Hamster [16:53:22]
        Monster.CreateWithVnum(140).At(16, 21).Facing(3), -- Small Mimic [16:53:22]
        Monster.CreateWithVnum(140).At(17, 8).Facing(7), -- Small Mimic [16:53:22]
        Monster.CreateWithVnum(140).At(19, 12).Facing(0), -- Small Mimic [16:53:22]
        Monster.CreateWithVnum(140).At(18, 17).Facing(4), -- Small Mimic [16:53:22]
        Monster.CreateWithVnum(100).At(15, 16).Facing(0), -- Poisonous Hamster [16:53:22]
        Monster.CreateWithVnum(141).At(14, 7).Facing(3), -- Mimic [16:53:22]
        Monster.CreateWithVnum(66).At(11, 19).Facing(3), -- Tired Thornwalker [16:53:22]
    }),
    -- wave 2
    MonsterWave.CreateWithDelay(1 * 30).WithMonsters({
        Monster.CreateWithVnum(66).At(12, 11).Facing(7), -- Tired Thornwalker [16:53:52]
        Monster.CreateWithVnum(141).At(13, 22).Facing(2), -- Mimic [16:53:52]
        Monster.CreateWithVnum(100).At(15, 13).Facing(7), -- Poisonous Hamster [16:53:52]
        Monster.CreateWithVnum(140).At(16, 21).Facing(4), -- Small Mimic [16:53:52]
        Monster.CreateWithVnum(140).At(17, 8).Facing(3), -- Small Mimic [16:53:52]
        Monster.CreateWithVnum(140).At(19, 12).Facing(0), -- Small Mimic [16:53:52]
    }),
    -- wave 3
    MonsterWave.CreateWithDelay(2 * 30).WithMonsters({
        Monster.CreateWithVnum(66).At(12, 11).Facing(6), -- Tired Thornwalker [16:54:22]
        Monster.CreateWithVnum(141).At(13, 22).Facing(6), -- Mimic [16:54:22]
        Monster.CreateWithVnum(100).At(15, 13).Facing(0), -- Poisonous Hamster [16:54:22]
        Monster.CreateWithVnum(140).At(16, 21).Facing(4), -- Small Mimic [16:54:22]
        Monster.CreateWithVnum(140).At(17, 8).Facing(5), -- Small Mimic [16:54:22]
        Monster.CreateWithVnum(140).At(19, 12).Facing(3), -- Small Mimic [16:54:22]
    }),
    -- wave 4
    MonsterWave.CreateWithDelay(3 * 30).WithMonsters({
        Monster.CreateWithVnum(66).At(12, 11).Facing(4), -- Tired Thornwalker [16:54:52]
        Monster.CreateWithVnum(141).At(13, 22).Facing(6), -- Mimic [16:54:52]
        Monster.CreateWithVnum(100).At(15, 13).Facing(2), -- Poisonous Hamster [16:54:52]
        Monster.CreateWithVnum(140).At(16, 21).Facing(5), -- Small Mimic [16:54:52]
        Monster.CreateWithVnum(140).At(17, 8).Facing(4), -- Small Mimic [16:54:52]
        Monster.CreateWithVnum(140).At(19, 12).Facing(5), -- Small Mimic [16:54:52]
    }),
})
map_3_8.AddObjects({
    MapObject.CreateOldBox().At(10, 21), -- [16:53:22]
})
map_3_8.OnMapJoin({
    Event.TryStartTaskForMap(map_3_8),
})
map_3_8.OnTaskFinish({
    Event.OpenPortal(portal_3_8_to_4_8),
    Event.AddTime(10),
    Event.DespawnAllMobsInRoom(map_3_8),
})
---

--- Map 4_8
map_4_8.AddNpcs({
    MapNpc.CreateNpcWithVnum(318).At(14, 13).Facing(7), -- Tom [16:55:24]
})
map_4_8.OnMapJoin({
    Event.TryStartTaskForMap(map_4_8),
})
---

local ts = TimeSpace.Create(19)  -- TimeSpace ID
    .SetMaps({map_0_8, map_1_8, map_2_8, map_3_8, map_4_8})
    .SetSpawn(Location.InMap(map_0_8).At(14, 11))
    .SetLives(3)
    .SetObjectives(objectives)
    .SetDurationInSeconds(130)
    .SetBonusPointItemDropChance(5000)
return ts
