Back to Home

ESO Lua File v101042

ingame/skills/companionskillsdata.lua

[◄ back to folders ]
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
--[[
This file mirrors PlayerSkillsData.lua in many ways, before editing or
removing methods please ensure there is a stable interface between the two.
]]
--
local COMPANION_PROGRESSION_KEY = nil -- should we consider using a sentinel value instead?
-----------------------
-- Skill Progression --
-----------------------
ZO_CompanionSkillProgressionData = ZO_SkillProgressionData_Base:Subclass()
-- Begin overriding methods in ZO_SkillProgressionData_Base --
function ZO_CompanionSkillProgressionData:BuildStaticData(skillData)
    ZO_SkillProgressionData_Base.BuildStaticData(self, skillData, COMPANION_PROGRESSION_KEY)
    self:SetAbilityId(self.skillData:GetAbilityId())
end
function ZO_CompanionSkillProgressionData:IsUnlocked()
    -- unlocked and purchased are synonymous with companion skills
    return self.skillData:IsPurchased()
end
function ZO_CompanionSkillProgressionData:TryPickup()
end
-- End overriding methods in ZO_SkillProgressionData_Base --
-- Begin implementing methods in ZO_SkillProgressionData_Base --
function ZO_CompanionSkillProgressionData:IsAdvised()
    return false
end
function ZO_CompanionSkillProgressionData:SetKeyboardTooltip(tooltipControl, unusedShowSkillPointCost, unusedShowUpgradeText, unusedShowAdvised, unusedShowBadMorph)
    tooltipControl:SetCompanionSkill(self:GetAbilityId())
end
-- End implementing methods in ZO_SkillProgressionData_Base --
--[[
A ZO_CompanionSkillData is an entry in a ZO_SkillLineData. A skill can be upgraded to various levels, denoted by ZO_CompanionSkillProgressionData objects.
--]]
-----------
-- Skill --
-----------
ZO_CompanionSkillData = ZO_SkillData_Base:Subclass()
-- Begin implementing methods in ZO_SkillData_Base --
function ZO_CompanionSkillData:Reset()
    self.skillProgressionData = nil
end
function ZO_CompanionSkillData:BuildStaticData(skillLineData, skillIndex)
    self.skillLineData, self.skillIndex = skillLineData, skillIndex
    local skillLineId = self.skillLineData:GetId()
    self.abilityId = GetCompanionAbilityId(skillLineId, skillIndex)
    self.skillProgressionData = ZO_CompanionSkillProgressionData:New()
    self.skillProgressionData:BuildStaticData(self)
    -- Don't mark a skill new during init
    self.canBeMarkedAsUpdated = false
    self:SetHasUpdatedStatus(false)
end
function ZO_CompanionSkillData:RefreshDynamicData(refreshChildren)
    local wasPurchased = self.isPurchased
    self.isPurchased = IsCompanionAbilityUnlocked(self.abilityId)
    if self.canBeMarkedAsUpdated then
        if wasPurchased ~= self.isPurchased then
            self:SetHasUpdatedStatus(true)
        end
    end
    self.canBeMarkedAsUpdated = true
    if refreshChildren then
        self.skillProgressionData:RefreshDynamicData(refreshChildren)
    end
end
function ZO_CompanionSkillData:GetSkillLineData()
    return self.skillLineData
end
function ZO_CompanionSkillData:IsPassive()
    return IsAbilityPassive(self.abilityId)
end
function ZO_CompanionSkillData:IsActive()
    return not self:IsPassive()
end
function ZO_CompanionSkillData:IsUltimate()
    return IsAbilityUltimate(self.abilityId)
end
function ZO_CompanionSkillData:MeetsLinePurchaseRequirement()
    return true
end
function ZO_CompanionSkillData:IsPurchased()
    return self.isPurchased
end
function ZO_CompanionSkillData:IsAdvised()
    return false
end
function ZO_CompanionSkillData:HasPointsToClear()
    return false
end
function ZO_CompanionSkillData:GetProgressionData(skillProgressionKey)
    -- there's only one progression, so key is ignored
    return self.skillProgressionData
end
function ZO_CompanionSkillData:GetHeaderText()
    if self:IsUltimate() then
        return GetString(SI_SKILLS_ULTIMATE_ABILITIES)
    elseif self:IsPassive() then
        return GetString(SI_SKILLS_PASSIVE_ABILITIES)
    else
        return GetString(SI_SKILLS_ACTIVE_ABILITIES)
    end
end
function ZO_CompanionSkillData:GetNumPointsAllocated()
    return 0
end
function ZO_CompanionSkillData:GetCurrentSkillProgressionKey()
    return COMPANION_PROGRESSION_KEY
end
function ZO_CompanionSkillData:GetCurrentProgressionData()
end
function ZO_CompanionSkillData:GetPointAllocator()
    if not self.noActionsPointAllocator then
        self.noActionsPointAllocator = SKILL_POINT_ALLOCATION_MANAGER:GenerateNoActionsAllocator(self)
    end
    return self.noActionsPointAllocator
end
function ZO_CompanionSkillData:GetPointAllocatorProgressionData()
end
function ZO_CompanionSkillData:HasUpdatedStatus()
    return self.hasUpdatedStatus
end
function ZO_CompanionSkillData:SetHasUpdatedStatus(hasUpdatedStatus)
    if hasUpdatedStatus then
        -- we only use updated status for a single CSA, so we don't really need
        -- to keep this state around. we'll keep the flag to match the base skills
        -- API but we'll reset it immediately after triggering the callbacks we
        -- want.
        self.hasUpdatedStatus = true
        COMPANION_SKILLS_DATA_MANAGER:OnCompanionSkillUpdateStatusChanged(self)
        self.hasUpdatedStatus = false
    end
end
function ZO_CompanionSkillData:ClearUpdate()
    self:SetHasUpdatedStatus(false)
end
function ZO_CompanionSkillData:CanPointAllocationsBeAltered(isFullRespec)
    return false
end
function ZO_CompanionSkillData:IsCompanionSkill()
    return true
end
-- End implementing methods in ZO_SkillData_Base --
function ZO_CompanionSkillData:GetAbilityId()
    return self.abilityId
end
function ZO_CompanionSkillData:GetCompanionIndices()
    return self.skillLineData:GetId(), self:GetAbilityId()
end
function ZO_CompanionSkillData:GetSkillLineRankRequired()
    return GetCompanionAbilityRankRequired(self.abilityId)
end
--[[
A ZO_CompanionSkillLineData is an entry in ZO_SkillTypeData. A skill line has multiple skills to purchase and upgrade, denoted by ZO_CompanionSkillData objects.
--]]
----------------
-- Skill Line --
----------------
ZO_CompanionSkillLineData = ZO_SkillLineData_Base:Subclass()
-- Begin overriding methods in ZO_SkillLineData_Base --
function ZO_CompanionSkillLineData:Initialize()
    ZO_SkillLineData_Base.Initialize(self, COMPANION_SKILLS_DATA_MANAGER)
    self.orderedSkills = {}
    self.skillMetaPool = ZO_MetaPool:New(COMPANION_SKILLS_DATA_MANAGER:GetSkillObjectPool())
end
function ZO_CompanionSkillLineData:Reset()
    ZO_SkillLineData_Base.Reset(self)
    ZO_ClearNumericallyIndexedTable(self.orderedSkills)
    self.skillMetaPool:ReleaseAllObjects()
end
-- unique to Companion skill lines
function ZO_CompanionSkillLineData:IsCompanionSkillLine()
    return true
end
function ZO_CompanionSkillLineData:IsAdvised()
    -- all companion skill lines should either be available, (in which case they are visible as unlocked in the UI) or advised (so they're still in the UI, just with an unlock hint)
    -- some shared code assumes these are mutually exclusive so we'll only mark things as advised if they're not available
    return not self:IsAvailable()
end
-- End overriding methods in ZO_SkillLineData_Base --
-- Begin implementing methods in ZO_SkillLineData_Base --
function ZO_CompanionSkillLineData:BuildStaticData(skillTypeData, skillLineIndex)
    self.skillTypeData, self.skillLineIndex = skillTypeData, skillLineIndex
    self.id = GetCompanionSkillLineId(skillTypeData:GetSkillType(), skillLineIndex)
    self.unlockText = GetSkillLineUnlockTextById(self.id)
    for skillIndex = 1, GetNumAbilitiesInCompanionSkillLine(self.id) do
        local skillData = self.skillMetaPool:AcquireObject()
        skillData:BuildStaticData(self, skillIndex)
        self.dataManager:MapAbilityIdToSkill(skillData:GetAbilityId(), skillData)
        table.insert(self.orderedSkills, skillData)
    end
end
function ZO_CompanionSkillLineData:RefreshDynamicData(refreshChildren)
    local wasAvailable = self:IsAvailable()
    self.currentRank, self.isActive, self.isDiscovered = GetCompanionSkillLineDynamicInfo(self.id)
    self.lastRankXP, self.nextRankXP, self.currentXP = GetCompanionSkillLineXPInfo(self.id)
    local isAvailable = self:IsAvailable()
    if wasAvailable ~= isAvailable then
        self:TryMarkNew(isAvailable)
    end
    if refreshChildren then
        for _, skillData in ipairs(self.orderedSkills) do
            skillData:RefreshDynamicData(refreshChildren)
        end
    end
end
function ZO_CompanionSkillLineData:GetName()
    return self.name
end
function ZO_CompanionSkillLineData:GetUnlockText()
    return self.unlockText
end
function ZO_CompanionSkillLineData:GetOrderingIndex()
    return 0
end
function ZO_CompanionSkillLineData:IsDiscovered()
    return self.isDiscovered
end
function ZO_CompanionSkillLineData:IsActive()
    return self.isActive
end
function ZO_CompanionSkillLineData:GetCurrentRank()
    return self.currentRank
end
function ZO_CompanionSkillLineData:GetLastRankXP()
    return self.lastRankXP
end
function ZO_CompanionSkillLineData:GetNextRankXP()
    return self.nextRankXP
end
function ZO_CompanionSkillLineData:GetCurrentRankXP()
    return self.currentXP
end
function ZO_CompanionSkillLineData:GetNumSkills()
    return #self.orderedSkills
end
function ZO_CompanionSkillLineData:GetSkillDataByIndex(skillIndex)
    return self.orderedSkills[skillIndex]
end
function ZO_CompanionSkillLineData:SkillIterator(skillFilterFunctions)
    return ZO_FilteredNumericallyIndexedTableIterator(self.orderedSkills, skillFilterFunctions)
end
-- End implementing methods in ZO_SkillLineData_Base --
function ZO_CompanionSkillLineData:GetSkillTypeData()
    return self.skillTypeData
end
function ZO_CompanionSkillLineData:GetSkillLineIndex()
    return self.skillLineIndex
end
function ZO_CompanionSkillLineData:GetIndices()
    return self.skillTypeData:GetSkillType(), self.skillLineIndex
end