-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCDGGatherer.lua
121 lines (100 loc) · 3.09 KB
/
CDGGatherer.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
local Player = {}
local SavedVars
local pin = {
level = 40,
texture = "ESOUI/art/crafting/blackcircle.dds",
size = 32,
-- insetX = 12,
-- insetY = 7,
}
local PinTooltipCreator = {
creator = function(pin)
InformationTooltip:AddLine( pin.m_PinTag[3] , "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
end,
tooltip = InformationTooltip,
}
local function AddCallbackCDGMapPin(pinManager)
if (GetMapType() == MAPTYPE_COSMIC) then
return
end
zone = GetUnitZone("player")
subzone = GetMapName()
for _, v in pairs(savedVars[zone][subzone]) do
for _, w in pairs(v) do
pinManager:CreatePin( _G["CDGMapPin"], w, w[1], w[2])
end
end
end
function doesNodeExist(zone,subzone,x,y,node)
local tolerance = 0.01
for _, v in pairs(savedVars[zone][subzone][node]) do
if ((x - tolerance) <= v[1]) and ((x + tolerance) >= v[1]) then
if ((y - tolerance) <= v[2]) and ((y + tolerance) >= v[2]) then
d("allready found this node before")
return true
end
end
end
return false
end
function CDGGathererInteractBusy()
if not Player.Harvesting then
if IsPlayerInteractingWithObject() then
if (GetInteractionType() == INTERACTION_HARVEST) then
Player.Harvesting = true
_, nodename, _, _, _ = GetGameCameraInteractableActionInfo()
SetMapToPlayerLocation()
x,y, _ = GetMapPlayerPosition("player")
zone = GetUnitZone("player")
subzone = GetMapName()
if not savedVars[zone] then
savedVars[zone] = {}
end
if not savedVars[zone][subzone] then
savedVars[zone][subzone] = {}
end
if not savedVars[zone][subzone][nodename] then
savedVars[zone][subzone][nodename] = {}
end
if not doesNodeExist(zone,subzone,x,y,nodename) then
table.insert( savedVars[zone][subzone][nodename], { x, y, nodename } )
end
d(string.format("Player harvesting %s @ %f,%f %s %s", nodename, x, y, zone, subzone))
-- ZO_WorldMap_AddCustomPin( "CDGMapPin", AddCallbackCDGMapPin, nil, pin, PinTooltipCreator )
-- ZO_WorldMap_SetCustomPinEnabled( _G["CDGMapPin"], true )
-- ZO_WorldMap_RefreshCustomPinsOfType(_G["CDGMapPin"])
end
end
end
end
function CDGGathererLootReceived(_, _, itemName, quantity, _, _, self)
if not self then
return
end
Player.Harvesting = false
end
function CDGGathererLootItemFailed()
if Player.Harvesting then
Player.Harvesting = false
end
end
function CDGGathererChatterEnd()
if Player.Harvesting then
Player.Harvesting = false
end
end
function CDGGathererAddOnLoaded (eventCode, addOnName)
if(addOnName == "CDGGatherer") then
savedVars = ZO_SavedVars:New("CDGGatherer_SavedVariables", 4, nil)
end
end
function CDGGatherer_OnInitialized()
Player.Harvesting = false
EVENT_MANAGER:RegisterForEvent("CDGGatherer",EVENT_CHATTER_END, CDGGathererChatterEnd)
EVENT_MANAGER:RegisterForEvent("CDGGatherer",EVENT_LOOT_ITEM_FAILED, CDGGathererLootItemFailed)
EVENT_MANAGER:RegisterForEvent("CDGGatherer",EVENT_LOOT_RECEIVED, CDGGathererLootReceived)
EVENT_MANAGER:RegisterForEvent("CDGGatherer",EVENT_ADD_ON_LOADED, CDGGathererAddOnLoaded)
end
function CDGGatherer_OnUpdate()
CDGGathererInteractBusy()
end