-- 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 TimeSpaceFinishType = require('TimeSpaceFinishType')
    
local objectives = TimeSpaceObjective.Create()
    .WithGoToExit()
    .WithProtectNPC()

local map_3_11 = Map.Create().WithMapId(4100).SetMapCoordinates(3, 11).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None).WithOnStartDialog(8004).WithOnStartShout("TS_0_TEXT_0")
) -- start
local map_3_10 = Map.Create().WithMapId(4105).SetMapCoordinates(3, 10).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.None).WithOnStartDialog(8005)
)
local map_3_9 = Map.Create().WithMapId(4114).SetMapCoordinates(3, 9).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_0_TEXT_1").WithOnStartDialog(8006).WithOnFinishDialog(8007)
)
local map_3_8 = Map.Create().WithMapId(4100).SetMapCoordinates(3, 8).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithOnStartDialog(8008).WithOnFinishDialog(8009).WithNoDialogTaskStart()
)
local map_3_7 = Map.Create().WithMapId(4101).SetMapCoordinates(3, 7).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters, 120).WithTaskText("TS_0_TEXT_2").WithOnStartDialog(8010)
)
local map_3_6 = Map.Create().WithMapId(4102).SetMapCoordinates(3, 6).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithTaskText("TS_0_TEXT_3").WithOnStartDialog(8013).WithOnFinishShout("TS_0_TEXT_4")
)
local map_3_5 = Map.Create().WithMapId(4103).SetMapCoordinates(3, 5).WithTask(
    TimeSpaceTask.Create(TimeSpaceTaskType.KillAllMonsters).WithOnStartDialog(8011).WithOnFinishDialog(8012)
)

local portal_3_11_to_3_10 = Portal.Create(PortalType.TsNormal).From(map_3_11, 14, 1).To(map_3_10, 14, 28).MinimapOrientation(PortalMinimapOrientation.North)
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_3_11 = Portal.Create(PortalType.TsNormal).From(map_3_10, 14, 28).To(map_3_11, 14, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_3_9_to_3_8 = Portal.Create(PortalType.Locked).From(map_3_9, 14, 1).To(map_3_8, 14, 28).MinimapOrientation(PortalMinimapOrientation.North)
local portal_3_9_to_3_10 = Portal.Create(PortalType.Locked).From(map_3_9, 14, 28).To(map_3_10, 14, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_3_8_to_3_7 = Portal.Create(PortalType.Locked).From(map_3_8, 14, 1).To(map_3_7, 14, 28).MinimapOrientation(PortalMinimapOrientation.North)
local portal_3_8_to_3_9 = Portal.Create(PortalType.Locked).From(map_3_8, 14, 28).To(map_3_9, 14, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_3_7_to_3_6 = Portal.Create(PortalType.Locked).From(map_3_7, 14, 1).To(map_3_6, 14, 28).MinimapOrientation(PortalMinimapOrientation.North)
local portal_3_7_to_3_8 = Portal.Create(PortalType.Locked).From(map_3_7, 14, 28).To(map_3_8, 14, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_3_6_to_3_5 = Portal.Create(PortalType.Locked).From(map_3_6, 14, 1).To(map_3_5, 14, 28).MinimapOrientation(PortalMinimapOrientation.North)
local portal_3_6_to_3_7 = Portal.Create(PortalType.Locked).From(map_3_6, 14, 28).To(map_3_7, 14, 1).MinimapOrientation(PortalMinimapOrientation.South)
local portal_3_5_to_UNKNOWN = Portal.Create(PortalType.TSEndClosed).From(map_3_5, 14, 1).To(map_3_5, 14, 1).MinimapOrientation(PortalMinimapOrientation.North)
local portal_3_5_to_3_6 = Portal.Create(PortalType.Locked).From(map_3_5, 14, 28).To(map_3_6, 14, 1).MinimapOrientation(PortalMinimapOrientation.South)

map_3_11.AddPortal(portal_3_11_to_3_10)
map_3_10.AddPortal(portal_3_10_to_3_9)
map_3_10.AddPortal(portal_3_10_to_3_11)
map_3_9.AddPortal(portal_3_9_to_3_8)
map_3_9.AddPortal(portal_3_9_to_3_10)
map_3_8.AddPortal(portal_3_8_to_3_7)
map_3_8.AddPortal(portal_3_8_to_3_9)
map_3_7.AddPortal(portal_3_7_to_3_6)
map_3_7.AddPortal(portal_3_7_to_3_8)
map_3_6.AddPortal(portal_3_6_to_3_5)
map_3_6.AddPortal(portal_3_6_to_3_7)
map_3_5.AddPortal(portal_3_5_to_UNKNOWN)
map_3_5.AddPortal(portal_3_5_to_3_6)

--- Map 3_11
map_3_11.OnMapJoin({
    Event.TryStartTaskForMap(map_3_11),
})
---

--- Map 3_10
map_3_10.AddMonsters({
    Monster.CreateWithVnum(24).At(13, 14).Facing(6), -- Baby Dander
    Monster.CreateWithVnum(24).At(17, 12).Facing(6).SpawnAfterMobsKilled(1), -- Baby Dander
})
map_3_10.OnMapJoin({
    Event.TryStartTaskForMap(map_3_10),
})
---

--- Map 3_9
map_3_9.AddMonsters({
    Monster.CreateWithVnum(333).At(12, 13).Facing(7), -- Chicken
})
map_3_9.OnMapJoin({
    Event.TryStartTaskForMap(map_3_9),
})
map_3_9.OnTaskFinish({
    Event.OpenPortal(portal_3_9_to_3_8),
})
---

--- Map 3_8
map_3_8.AddMonsters({
    Monster.CreateWithVnum(333).At(20, 15).Facing(6).SpawnAfterTaskStart(), -- Chicken
    Monster.CreateWithVnum(333).At(8, 15).Facing(5).SpawnAfterTaskStart(), -- Chicken
})
map_3_8.AddObjects({
    MapObject.CreateLever().At(14, 18).OnTrigger({
        Event.TryStartTaskForMap(map_3_8)
    }),
})
map_3_8.OnTaskFinish({
    Event.OpenPortal(portal_3_8_to_3_7),
})
---

--- Map 3_7
map_3_7.AddMonsters({
    Monster.CreateWithVnum(333).At(11, 14).Facing(1), -- Chicken
    Monster.CreateWithVnum(24).At(16, 17).Facing(1).SpawnAfterMobsKilled(1), -- Baby Dander
})
map_3_7.OnMapJoin({
    Event.TryStartTaskForMap(map_3_7),
})
map_3_7.OnTaskFinish({
    Event.OpenPortal(portal_3_7_to_3_6),
})
map_3_7.OnTaskFail({
    Event.FinishTimeSpace(TimeSpaceFinishType.TIME_IS_UP),
})
---

--- Map 3_6
map_3_6.AddMonsters({
    Monster.CreateWithVnum(25).At(15, 12).Facing(2), -- Dander
    Monster.CreateWithVnum(24).At(11, 14).Facing(6), -- Baby Dander
})
map_3_6.AddNpcs({
    MapNpc.CreateNpcWithVnum(320).At(16, 14).Facing(6).WithMustProtectAura(), -- Soldier of the NosVille Guards
})
map_3_6.OnMapJoin({
    Event.TryStartTaskForMap(map_3_6),
})
map_3_6.OnTaskFinish({
    Event.OpenPortal(portal_3_6_to_3_5),
})
---

--- Map 3_5
map_3_5.AddMonsters({
    Monster.CreateWithVnum(24).At(19, 12).Facing(0), -- Baby Dander
    Monster.CreateWithVnum(333).At(15, 17).Facing(6), -- Chicken
})
map_3_5.OnMapJoin({
    Event.TryStartTaskForMap(map_3_5),
})
map_3_5.OnTaskFinish({
    Event.OpenPortal(portal_3_5_to_UNKNOWN),
})
---

local ts = TimeSpace.Create(0)  -- TimeSpace ID
    .SetMaps({map_3_11, map_3_10, map_3_9, map_3_8, map_3_7, map_3_6, map_3_5})
    .SetSpawn(Location.InMap(map_3_11).At(8, 10))
    .SetLives(2)
    .SetObjectives(objectives)
    .SetDurationInSeconds(300)
    .SetBonusPointItemDropChance(5000)
return ts
