1 function QuestHelper
:CreateTeleportInfo()
2 local info
= self
:CreateTable()
3 info
.node
= self
:CreateTable()
4 info
.reag
= self
:CreateTable()
8 function QuestHelper
:ReleaseTeleportInfo(info
)
9 for _
, data
in pairs(info
.node
) do
10 self
:ReleaseTable(data
)
13 self
:ReleaseTable(info
.node
)
14 self
:ReleaseTable(info
.reag
)
15 self
:ReleaseTable(info
)
18 function QuestHelper
:TeleportInfoClear(info
)
19 for node
, data
in pairs(info
.node
) do
20 self
:ReleaseTable(data
)
24 for id
in pairs(info
.reag
) do
29 function QuestHelper
:SetTeleportInfoTarget(info
,
30 node
, -- The world graph node this will take us to.
31 start
, -- The last time this spell was used.
32 duration
, -- How long the spell cooldown is.
33 cast
, -- How long does the spell take to cast.
34 reagent_id
) -- What reagent is consumed by using the spell (can be nil)
35 local data
= info
.node
[node
]
36 if not data
then data
= self
:CreateTable() info
.node
[node
] = data
end
38 data
[1], data
[2], data
[3], data
[4] = start
, duration
, cast
, reagent_id
41 function QuestHelper
:SetTeleportInfoReagent(info
, reagent_id
, count
)
43 info
.reag
[reagent_id
] = count
45 info
.reag
[reagent_id
] = nil
49 function QuestHelper
:TeleportInfoUseNode(info
, node
, time_delta
)
50 local data
= info
.node
[node
]
52 self
:TextOut("Used "..(node
.name
or "unnamed node").." in path.")
54 data
[1] = GetTime()+time_delta
56 local count
= info
.reag
[data
[3]]
or 0
59 info
.reag
[data
[4]]
= count
61 info
.reag
[data
[4]]
= nil
67 function QuestHelper
:TeleportInfoTransfer(original
, dest
)
68 for key
in pairs(dest
.node
) do
69 if not original
.node
[key
] then
70 self
:ReleaseTable(dest
.node
[key
])
75 for key
, data
in pairs(original
.node
) do
76 local data2
= dest
.node
[key
]
78 data2
= self
:CreateTable()
79 dest
.node
[key
] = data2
81 data2
[1], data2
[2], data2
[3], data2
[4] = data
[1], data
[2], data
[3], data
[4]
84 for key
in pairs(dest
.reag
) do
85 if not original
.reag
[key
] then
90 for key
, value
in pairs(original
.reag
) do
91 dest
.reag
[key
] = value
95 function QuestHelper
:TeleportInfoAddGraphPoints(info
, graph
, end_list
, time_delta
)
96 for node
, data
in pairs(info
.node
) do
97 if data
[1]+data
[2] >= time_delta
+GetTime() and (not data
[4] or (data
[4] and info
.reag
[data
[4]]
)) then
98 self
:TextOut("Considering "..(node
.name
or "unnamed node").." for use in pathing.")
99 graph
:AddStartNode(node
, data
[3], end_list
)
104 QuestHelper
.teleport_info
= QuestHelper
:CreateTeleportInfo()