Skip to content

Commit

Permalink
database: add description string for friendly units
Browse files Browse the repository at this point in the history
  • Loading branch information
shagu committed Oct 31, 2023
1 parent 3a36b88 commit c47fb77
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion database.lua
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,19 @@ local bitclasses = {
-- make it public for extensions
pfDB.bitclasses = bitclasses

function pfDatabase:IsFriendly(id)
if id and units[id] and units[id].fac then
local faction = string.lower(UnitFactionGroup("player"))
faction = faction == "horde" and "H" or faction == "alliance" and "A" or "UNKNOWN"

if string.find(units[id].fac, faction) then
return true
end
end

return false
end

function pfDatabase:BuildQuestDescription(meta)
if not meta.title or not meta.quest or not meta.QTYPE then return end

Expand All @@ -358,7 +371,11 @@ function pfDatabase:BuildQuestDescription(meta)
elseif meta.QTYPE == "OBJECT_END" then
return string.format(pfQuest_Loc["Interact with |cff33ffcc%s|r to complete |cffffcc00[?]|cff33ffcc %s|r"], (meta.spawn or UNKNOWN), (meta.quest or UNKNOWN))
elseif meta.QTYPE == "UNIT_OBJECTIVE" then
return string.format(pfQuest_Loc["Kill |cff33ffcc%s|r"], (meta.spawn or UNKNOWN))
if pfDatabase:IsFriendly(meta.spawnid) then
return string.format(pfQuest_Loc["Talk to |cff33ffcc%s|r"], (meta.spawn or UNKNOWN))
else
return string.format(pfQuest_Loc["Kill |cff33ffcc%s|r"], (meta.spawn or UNKNOWN))
end
elseif meta.QTYPE == "UNIT_OBJECTIVE_ITEMREQ" then
return string.format(pfQuest_Loc["Use |cff33ffcc%s|r on |cff33ffcc%s|r"], (meta.itemreq or UNKNOWN), (meta.spawn or UNKNOWN))
elseif meta.QTYPE == "OBJECT_OBJECTIVE" then
Expand Down

0 comments on commit c47fb77

Please sign in to comment.