mirror of
https://github.com/Lacustat/Freewood-OctoWoW-Codex.git
synced 2026-11-03 17:26:57 +00:00
0.1.219: Flugnetz und Weg zum Ziel im Levelplan (Version)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
fbbd324609
commit
e1b89f4843
+64
-5
@@ -301,17 +301,76 @@ function Taxi.PlannerOn()
|
||||
return not (db and db.settings and db.settings.taxiPlan == false)
|
||||
end
|
||||
|
||||
-- Namen der Flugpunkte, die dieser Charakter kennt: { [Name] = true }
|
||||
function Taxi.KnownNames()
|
||||
local out = {}
|
||||
local c = CharRec(false)
|
||||
for id in pairs(c and c.known or {}) do
|
||||
local nd = Taxi.Node(id)
|
||||
if nd and nd.n then out[nd.n] = true end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
local edgeCache
|
||||
|
||||
local function PlayerFac()
|
||||
local f = _G.UnitFactionGroup and _G.UnitFactionGroup("player")
|
||||
return f == "Horde" and "H" or f == "Alliance" and "A" or nil
|
||||
end
|
||||
|
||||
-- Ort eines Flugpunkts fuer den Levelplan: Karte (m, x, y) und/oder Zellraum cs = { Welt, x, y } (Yards)
|
||||
local function EndPoint(nd, seed)
|
||||
local p = {}
|
||||
if nd.m and nd.x and nd.y then p.m, p.x, p.y = nd.m, nd.x, nd.y end
|
||||
if nd.a and nd.b and nd.w then
|
||||
p.cs = { nd.w, nd.b, nd.a }
|
||||
elseif seed then
|
||||
p.cs = { seed[2], seed[3], seed[4] }
|
||||
end
|
||||
if not p.m and not p.cs then return nil end
|
||||
return p
|
||||
end
|
||||
|
||||
-- Fluege als Kanten { id, k, t, wait, est, from, to }, nur zwischen Flugpunkten, die dieser Charakter kennt.
|
||||
-- Gemessene Fluege gelten auch rueckwaerts (est = geschaetzt, bis selbst geflogen); dazu das mitgelieferte Flugnetz (Taxi.Seed)
|
||||
-- fuer Strecken, die noch nie geflogen wurden. Wege ueber mehrere Flugpunkte findet der Levelplan selbst.
|
||||
function Taxi.Edges()
|
||||
if not Taxi.PlannerOn() then return {} end
|
||||
local key = Codex.Trust and Codex.Trust.SelfKey and Codex.Trust.SelfKey() or "?"
|
||||
if edgeCache and edgeCache.rev == Taxi.rev and edgeCache.key == key then return edgeCache.list end
|
||||
local list = {}
|
||||
local list, have = {}, {}
|
||||
local seed = Taxi.Seed
|
||||
local fac = PlayerFac()
|
||||
local function Add(a, b, t, est)
|
||||
local na, nb = Taxi.Node(a), Taxi.Node(b)
|
||||
if not (na and nb and t) then return end
|
||||
local pa = EndPoint(na, seed and seed.n[na.n])
|
||||
local pb = EndPoint(nb, seed and seed.n[nb.n])
|
||||
if not (pa and pb) then return end
|
||||
have[a .. ">" .. b] = true
|
||||
list[#list + 1] = { id = (est and "s" or "f") .. a .. ">" .. b, k = "flight", t = t, wait = 20, est = est or nil, name = nb.n, fn = na.n,
|
||||
fa = a, fb = b, from = pa, to = pb }
|
||||
end
|
||||
for rid, r in pairs(Taxi.Routes()) do
|
||||
local na, nb = Taxi.Node(r.a), Taxi.Node(r.b)
|
||||
if na and nb and na.m and nb.m and r.t and Taxi.Known(r.a) and Taxi.Known(r.b) then
|
||||
list[#list + 1] = { id = "f" .. rid, k = "flight", t = r.t, wait = 20, name = nb.n, fa = r.a, fb = r.b,
|
||||
from = { m = na.m, x = na.x, y = na.y }, to = { m = nb.m, x = nb.x, y = nb.y } }
|
||||
if r.t and Taxi.Known(r.a) and Taxi.Known(r.b) then Add(r.a, r.b, r.t) end
|
||||
end
|
||||
for rid, r in pairs(Taxi.Routes()) do
|
||||
if r.t and Taxi.Known(r.a) and Taxi.Known(r.b) and not have[r.b .. ">" .. r.a] then Add(r.b, r.a, r.t, true) end
|
||||
end
|
||||
if seed then
|
||||
local c = CharRec(false)
|
||||
local byName = {}
|
||||
for id in pairs(c and c.known or {}) do
|
||||
local nd = Taxi.Node(id)
|
||||
if nd and nd.n then byName[nd.n] = id end
|
||||
end
|
||||
for _, e in ipairs(seed.e) do
|
||||
local a, b = byName[e[1]], byName[e[2]]
|
||||
if a and b and not have[a .. ">" .. b] then
|
||||
local fa, fb = seed.n[e[1]], seed.n[e[2]]
|
||||
if not (fac and ((fa and fa[1] and fa[1] ~= fac) or (fb and fb[1] and fb[1] ~= fac))) then Add(a, b, e[3], true) end
|
||||
end
|
||||
end
|
||||
end
|
||||
edgeCache = { rev = Taxi.rev, key = key, list = list }
|
||||
|
||||
Reference in New Issue
Block a user