0.1.180: Tooltip-Zusatzinfos in Core und Codex, unabhaengig vom Quest-Modul

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9
This commit is contained in:
Lacustat
2026-10-29 16:47:37 +01:00
co-authored by Claude Sonnet 5.5
parent 0d511da8a6
commit 42938cb16b
3 changed files with 132 additions and 1 deletions
+104
View File
@@ -0,0 +1,104 @@
-- Freewood-Codex: Beutewert-Zeilen im Gegner-Tooltip (Einstellungen -> Tooltips)
-- Die Zeilen brauchen die Kill-Daten des Codex; die Schalter erscheinen im Core-Reiter "Tooltips", solange der Codex laeuft.
-- tipDropGold, tipDropVendor, tipDropAH (nur mit Auktionsmodul), tipDropHour, tipDropBest (+ tipDropBestN), tipDropKills
local FW = _G.Freewood
local T = FW and FW.Tooltips
if not FW or not T or not T.AddUnitLine or not T.RegisterOption then
return
end
local Tip = { Money = T.Money }
local function On(key) return T.Get(key) == true end
-- Kampfdauer einer Kreatur in Sekunden: eigene Klasse, sonst Durchschnitt aller Klassen
local function UnitSecs(u)
local CT = FW.Codex and FW.Codex.Time
if not (CT and CT.UnitAverage) then return nil end
local own = CT.UnitAverage(u)
if own and own > 0 then return own end
local list = CT.UnitClasses and CT.UnitClasses(u) or {}
if #list == 0 then return nil end
local sum = 0
for _, c in ipairs(list) do sum = sum + c.secs end
local avg = sum / #list
return avg > 0 and avg or nil
end
-- Durchschnittliche Beute je Leiche (Gold plus Items nach Drop-Chance), eigene und geteilte Daten.
-- Alle Zeilen einzeln schaltbar: tipDropGold, tipDropVendor, tipDropAH, tipDropHour, tipDropBest (+ tipDropBestN), tipDropKills
local function AddDrops(tt, name, npcID)
if not npcID or tt.fwDropID == npcID then return end
local wantG, wantV, wantA = On("tipDropGold"), On("tipDropVendor"), On("tipDropAH")
local wantH, wantB, wantK = On("tipDropHour"), On("tipDropBest"), On("tipDropKills")
if not (wantG or wantV or wantA or wantH or wantB or wantK) then return end
local C = FW.Codex
if not C or not C.V or not C.KillValue then return end
local ok, V = pcall(C.V)
local u = ok and V and V.units and V.units[npcID]
if not u or (u.k or 0) < 1 then return end
tt.fwDropID = npcID
local L = FW.L
local hasAH = C.AuctionProvider ~= nil
local vTotal, vCoin, _, vMissing = C.KillValue(u, false)
local aTotal, _, _, aMissing
if hasAH and (wantA or wantH) then aTotal, _, _, aMissing = C.KillValue(u, true) end
local star = function(m) return (m or 0) > 0 and "*" or "" end
if wantG and vCoin and vCoin > 0 then
tt:AddLine(string.format(L.CODEX_TIP_DROP_GOLD, Tip.Money(math.floor(vCoin + 0.5))), 1, 0.82, 0)
end
if wantV and vTotal and vTotal > 0 then
tt:AddLine(string.format(L.CODEX_TIP_DROP_VENDOR, Tip.Money(math.floor(vTotal + 0.5)) .. star(vMissing)), 1, 0.82, 0)
end
if wantA and hasAH and aTotal and aTotal > 0 then
tt:AddLine(string.format(L.CODEX_TIP_DROP_AH, Tip.Money(math.floor(aTotal + 0.5)) .. star(aMissing)), 0.6, 0.85, 1)
end
if wantH then
local secs = UnitSecs(u)
local val = (hasAH and aTotal and aTotal > 0) and aTotal or vTotal
if secs and secs > 0 and val and val > 0 then
tt:AddLine(string.format(L.CODEX_TIP_DROP_HOUR, Tip.Money(math.floor(val / secs * 3600 + 0.5)), secs), 0.7, 1, 0.7)
end
end
if wantB then
local n = tonumber(T.Get("tipDropBestN")) or 3
local rows, k = {}, u.k
for id, d in pairs(u.d or {}) do
if not d.qi then
local info = FW.Util.GetItem(id)
if info then
local v = info.sellPrice or 0
if hasAH then
local ah = C.AuctionPrice(id)
if ah and ah > v then v = ah end
end
local chance = (d.q or 0) / k
if v > 0 and chance > 0 then
rows[#rows + 1] = { name = info.name, quality = info.quality, chance = chance, value = chance * v }
end
end
end
end
table.sort(rows, function(x, y) return x.value > y.value end)
for i = 1, math.min(n, #rows) do
local r = rows[i]
local pct = r.chance * 100
local ptxt = pct >= 10 and string.format("%.0f%%", pct) or string.format("%.1f%%", pct)
tt:AddLine(string.format(L.CODEX_TIP_DROP_BEST, r.name or "?", ptxt, Tip.Money(math.floor(r.value + 0.5))), 0.9, 0.9, 0.9)
end
end
if wantK then
tt:AddLine(string.format(L.CODEX_TIP_DROP_KILLS, u.k), 0.6, 0.6, 0.6)
end
end
T.AddUnitLine(AddDrops)
T.RegisterOption("tipDropGold", "CODEX_OPT_TIPDROPG", { order = 38, default = false })
T.RegisterOption("tipDropVendor", "CODEX_OPT_TIPDROPV", { order = 40 })
T.RegisterOption("tipDropAH", "CODEX_OPT_TIPDROPA", { order = 50, available = function() return FW.Codex and FW.Codex.AuctionProvider ~= nil end })
T.RegisterOption("tipDropHour", "CODEX_OPT_TIPDROPH", { order = 60, default = false })
T.RegisterOption("tipDropBest", "CODEX_OPT_TIPDROPB", { order = 70, default = false })
T.RegisterOption("tipDropBestN", "CODEX_OPT_TIPDROPBN", { order = 71, default = 3, min = 1, max = 5, step = 1 })
T.RegisterOption("tipDropKills", "CODEX_OPT_TIPDROPK", { order = 80, default = false })
+2 -1
View File
@@ -3,7 +3,7 @@
## Notes: Learns quests, creatures and drops while you play: who gives and takes a quest, rewards, objectives, drop chances.
## Notes-deDE: Lernt beim Spielen Quests, Kreaturen und Beute: wer eine Quest vergibt und annimmt, Belohnungen, Ziele, Drop-Chancen.
## Author: Lacustat
## Version: 0.1.179
## Version: 0.1.180
## Dependencies: Freewood-OctoWoW-Core
## OptionalDeps: Freewood-OctoWoW-CodexData, Freewood-OctoWoW-ForeverData
@@ -39,3 +39,4 @@ CodexHints.lua
CodexFavUI.lua
CodexNameUI.lua
CodexShareUI.lua
CodexTooltips.lua
+26
View File
@@ -7,6 +7,19 @@ if not FW then
end
FW:AddLocale("enUS", {
CODEX_OPT_TIPDROPV = "Creature tooltip: average loot value (vendor)",
CODEX_OPT_TIPDROPA = "Creature tooltip: average loot value (auction, needs Auction module)",
CODEX_TIP_DROP_VENDOR = "Avg. loot (vendor): %s",
CODEX_TIP_DROP_AH = "Avg. loot (auction): %s",
CODEX_OPT_TIPDROPG = "Creature tooltip: average gold per kill (coins only)",
CODEX_OPT_TIPDROPH = "Creature tooltip: average value per hour (loot value / fight time)",
CODEX_OPT_TIPDROPB = "Creature tooltip: most valuable drops",
CODEX_OPT_TIPDROPBN = "Number of drops shown: %d",
CODEX_OPT_TIPDROPK = "Creature tooltip: number of kills the values are based on",
CODEX_TIP_DROP_GOLD = "Avg. gold per kill: %s",
CODEX_TIP_DROP_HOUR = "Avg. per hour: %s (fight %.0f s, no travel)",
CODEX_TIP_DROP_BEST = "Drop: %s (%s, avg. %s)",
CODEX_TIP_DROP_KILLS = "Based on %d kills",
CODEX_SEC_EFFECTS = "Effects",
CODEX_FX_SKILL = "Skill: %s",
CODEX_FX_FW_SWIM = "Swim speed (%)",
@@ -551,6 +564,19 @@ FW:AddLocale("enUS", {
})
FW:AddLocale("deDE", {
CODEX_OPT_TIPDROPV = "Gegner-Tooltip: Ø Beutewert (Händler)",
CODEX_OPT_TIPDROPA = "Gegner-Tooltip: Ø Beutewert (Auktion, braucht Auktionsmodul)",
CODEX_TIP_DROP_VENDOR = "Ø Beute (Händler): %s",
CODEX_TIP_DROP_AH = "Ø Beute (Auktion): %s",
CODEX_OPT_TIPDROPG = "Gegner-Tooltip: Ø Gold pro Kill (nur Münzen)",
CODEX_OPT_TIPDROPH = "Gegner-Tooltip: Ø Wert pro Stunde (Beutewert / Kampfdauer)",
CODEX_OPT_TIPDROPB = "Gegner-Tooltip: wertvollste Drops",
CODEX_OPT_TIPDROPBN = "Anzahl gezeigter Drops: %d",
CODEX_OPT_TIPDROPK = "Gegner-Tooltip: Anzahl Kills, auf denen die Werte beruhen",
CODEX_TIP_DROP_GOLD = "Ø Gold pro Kill: %s",
CODEX_TIP_DROP_HOUR = "Ø pro Stunde: %s (Kampf %.0f s, ohne Laufwege)",
CODEX_TIP_DROP_BEST = "Drop: %s (%s, Ø %s)",
CODEX_TIP_DROP_KILLS = "Basis: %d Kills",
CODEX_SEC_EFFECTS = "Effekte",
CODEX_FX_SKILL = "Fertigkeit: %s",
CODEX_FX_FW_SWIM = "Schwimmtempo (%)",