-
Notifications
You must be signed in to change notification settings - Fork 8
/
ReticleChanges.lua
104 lines (86 loc) · 3.31 KB
/
ReticleChanges.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
WritCreater = WritCreater or {}
function WritCreater.initializeReticleChanges()
if not WritCreater.langStationNames then return end
local stations = WritCreater.langStationNames()
local originalReticleFunction = ZO_ReticleContainerInteractContext.SetText
local deliverText = WritCreater.writCompleteStrings()["Deliver"]
local function isQuestComplete(questIndex, numConditions)
local numConditions = GetJournalQuestNumConditions(questIndex)
for i = 1, numConditions do
local cur, max = GetJournalQuestConditionValues(questIndex,1,i)
local s = GetJournalQuestConditionInfo(questIndex,1,i)
if string.find(s, deliverText) then return true
end
end
return false
end
local function setupReplacement(object, functionName)
local original = object[functionName]
object[functionName] = function(self, text)
-- If the setting is off exit
if not WritCreater:GetSettings().changeReticle then original(self, text) return end
-- if not a station exit
local craftingType = stations[text]
if not craftingType then original(self, text) return end
-- Otherwise, do we have a writ on?
local writs = WritCreater.writSearch()
if writs[craftingType] then
-- we have a writ. Do we need the reticle green or red
if isQuestComplete(writs[craftingType]) or GetJournalQuestIsComplete(writs[craftingType]) then
text = "|c66ff66"..text.."|r"
else
text = "|cff6666"..text.."|r"
end
original(self, text)
else
original(self, text)
end
end
end
setupReplacement(ZO_ReticleContainerInteractContext, "SetText")
end
local interactionManager = FISHING_MANAGER or INTERACTIVE_WHEEL_MANAGER
local oldInteract = interactionManager.StartInteraction
if oldInteract then
local function hook(...)
if WritCreater and WritCreater.GetSettings and WritCreater:GetSettings() and WritCreater:GetSettings().stealProtection and not NoAccidentalStealing then
local _, hasWrits = WritCreater.writSearch()
if not hasWrits then
return oldInteract(...)
end
local action, _, isBlocked, isOwned, additional,_,_,isCriminal = GetGameCameraInteractableActionInfo()
if isBlocked then
return oldInteract(...)
end
if isCriminal then
local isStealthed = GetUnitStealthState("player")
if isStealthed == 3 or isStealthed == 5 then
return oldInteract(...)
else
ZO_Alert(ERROR, SOUNDS.GENERAL_ALERT_ERROR ,"The Lazy Writ Crafter™ has saved you from stealing while doing writs!")
return isCriminal
end
end
return oldInteract(...)
end
return oldInteract(...)
end
interactionManager.StartInteraction = hook
end
local jewelryName =zo_strformat("<<1>>",GetItemLinkName("|H1:item:138799:6:1:0:0:0:24:255:5:325:28:0:0:0:0:0:0:0:0:0:4320001|h|h"))
local function dialogHook(...)
zo_callLater(function()
if ZO_Dialog1 and ZO_Dialog1.textParams and ZO_Dialog1.textParams.mainTextParams then
local itemName= ZO_Dialog1.textParams.mainTextParams[1]
if WritCreater.GetSettings and WritCreater:GetSettings() and WritCreater:GetSettings().EZJewelryDestroy and itemName and string.find(itemName ,jewelryName )then
for k, v in pairs(ZO_Dialog1.textParams.mainTextParams) do
if v == string.upper(v) then
ZO_Dialog1EditBox:SetText(v)
ZO_Dialog1EditBox:LoseFocus()
end
end
end
end
end, 10)
end
ZO_PreHook("ZO_Dialogs_ShowDialog", dialogHook)