Back to Home

ESO Lua File v101043

ingame/skills/skillsdata_base.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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
-- Helper object for object pool data --
ZO_PooledSkillDataObject = ZO_InitializingObject:Subclass()
function ZO_PooledSkillDataObject:Reset()
    -- Can be overridden
end
function ZO_PooledSkillDataObject:BuildData(...)
    self:BuildStaticData(...)
end
ZO_PooledSkillDataObject:MUST_IMPLEMENT("BuildStaticData", ...)
function ZO_PooledSkillDataObject:RefreshDynamicData(...)
    -- Can be overridden
end
--[[
A ZO_SkillProgressionData_Base is an entry in a ZO_SkillData_Base. Each one describes a step in the progression for upgrading the skill.
--]]
-----------------------
-- Skill Progression --
-----------------------
ZO_SkillProgressionData_Base = ZO_PooledSkillDataObject:Subclass()
function ZO_SkillProgressionData_Base:New(...)
    return ZO_PooledSkillDataObject.New(self, ...)
end
function ZO_SkillProgressionData_Base:Reset()
    self.abilityId = nil
end
function ZO_SkillProgressionData_Base:BuildStaticData(skillData, skillProgressionKey)
    self.skillData, self.skillProgressionKey = skillData, skillProgressionKey
end
function ZO_SkillProgressionData_Base:GetIndices()
    local skillType, skillLineIndex, skillIndex = self.skillData:GetIndices()
    return skillType, skillLineIndex, skillIndex, self.skillProgressionKey
end
-- Actives and passives progress differently.
-- In actives, progression key corresponds to morph slots.
-- In passives, progression key corresponds to rank.
-- Crafted/Companion abilities don't progress at all, so the key is nil
function ZO_SkillProgressionData_Base:GetSkillProgressionKey()
    return self.skillProgressionKey
end
function ZO_SkillProgressionData_Base:GetSkillData()
    return self.skillData
end
function ZO_SkillProgressionData_Base:GetAbilityId()
    return self.abilityId
end
function ZO_SkillProgressionData_Base:SetAbilityId(abilityId)
    self.abilityId = abilityId
    self.name = GetAbilityName(abilityId)
    self.icon = GetAbilityIcon(abilityId)
end
function ZO_SkillProgressionData_Base:GetName()
    return self.name
end
function ZO_SkillProgressionData_Base:GetFormattedName(formatter)
    return ZO_CachedStrFormat(formatter or SI_ABILITY_NAME, self:GetName())
end
function ZO_SkillProgressionData_Base:GetDetailedName()
    return self:GetFormattedName()
end
function ZO_SkillProgressionData_Base:GetDetailedGamepadName()
    return self:GetDetailedName() -- can be overridden to change how the name is formatted in the gamepad UI
end
function ZO_SkillProgressionData_Base:GetIcon()
    return self.icon
end
function ZO_SkillProgressionData_Base:IsPassive()
    return self:GetSkillData():IsPassive()
end
function ZO_SkillProgressionData_Base:IsActive()
    return not self:IsPassive()
end
function ZO_SkillProgressionData_Base:IsUltimate()
    return self:GetSkillData():IsUltimate()
end
function ZO_SkillProgressionData_Base:IsUnlocked()
    return self.skillData:MeetsLinePurchaseRequirement()
end
function ZO_SkillProgressionData_Base:IsLocked()
    return not self:IsUnlocked()
end
-- abstract methods (must be overridden)
ZO_SkillProgressionData_Base:MUST_IMPLEMENT("IsAdvised")
ZO_SkillProgressionData_Base:MUST_IMPLEMENT("SetKeyboardTooltip")
-- Optional overrides
function ZO_SkillProgressionData_Base:HasRankData()
    return false
end
function ZO_SkillProgressionData_Base:TryPickup()
    -- returns true if the skill is picked up
    return false
end
--[[
A ZO_SkillData_Base is an entry in a ZO_SkillLineData. A skill can be upgraded to various levels, denoted by ZO_SkillProgressionData objects.
ZO_SkillData_Base, unlike some other skill data objects, is implemented as
a pure interface. avoid putting any logic in here, if you can avoid it.
--]]
-----------
-- Skill --
-----------
ZO_SkillData_Base = ZO_PooledSkillDataObject:Subclass()
-- abstract methods (must be overridden)
ZO_SkillData_Base:MUST_IMPLEMENT("Reset")
ZO_SkillData_Base:MUST_IMPLEMENT("BuildStaticData", skillLineData, skillIndex)
ZO_SkillData_Base:MUST_IMPLEMENT("RefreshDynamicData", refreshChildren)
ZO_SkillData_Base:MUST_IMPLEMENT("GetSkillLineData")
ZO_SkillData_Base:MUST_IMPLEMENT("IsPassive")
ZO_SkillData_Base:MUST_IMPLEMENT("IsActive")
ZO_SkillData_Base:MUST_IMPLEMENT("IsUltimate")
ZO_SkillData_Base:MUST_IMPLEMENT("MeetsLinePurchaseRequirement")
ZO_SkillData_Base:MUST_IMPLEMENT("IsPurchased")
ZO_SkillData_Base:MUST_IMPLEMENT("IsAdvised")
ZO_SkillData_Base:MUST_IMPLEMENT("HasPointsToClear", clearMorphsOnly)
ZO_SkillData_Base:MUST_IMPLEMENT("GetProgressionData", skillProgressionKey)
ZO_SkillData_Base:MUST_IMPLEMENT("GetHeaderText")
ZO_SkillData_Base:MUST_IMPLEMENT("GetNumPointsAllocated")
ZO_SkillData_Base:MUST_IMPLEMENT("GetCurrentSkillProgressionKey")
ZO_SkillData_Base:MUST_IMPLEMENT("GetCurrentProgressionData")
ZO_SkillData_Base:MUST_IMPLEMENT("GetPointAllocator")
ZO_SkillData_Base:MUST_IMPLEMENT("GetPointAllocatorProgressionData")
ZO_SkillData_Base:MUST_IMPLEMENT("HasUpdatedStatus")
ZO_SkillData_Base:MUST_IMPLEMENT("SetHasUpdatedStatus", hasUpdatedStatus)
ZO_SkillData_Base:MUST_IMPLEMENT("ClearUpdate")
ZO_SkillData_Base:MUST_IMPLEMENT("CanPointAllocationsBeAltered", isFullRespec)
ZO_SkillData_Base:STUB("GetLineRankNeededToPurchase") -- Only used for purchaseable skills
ZO_SkillData_Base:STUB("IsAutoGrant") -- Only matters for point allocation checks, not always needed
-- Optional overrides
function ZO_SkillData_Base:IsPlayerSkill()
    return false
end
function ZO_SkillData_Base:IsCompanionSkill()
    return false
end
function ZO_SkillData_Base:IsCraftedAbility()
    return false
end
function ZO_SkillData_Base:IsHidden()
    return false
end
-- convenience methods
function ZO_SkillData_Base:GetSlotOnCurrentHotbar()
    return ACTION_BAR_ASSIGNMENT_MANAGER:GetCurrentHotbar():FindSlotMatchingSkill(self)
end
function ZO_SkillData_Base:GetCurrentProgressionLink()
    if self:IsCraftedAbility() then
        local craftedAbilityId = self:GetCraftedAbilityId()
        local craftedAbilityData = SCRIBING_DATA_MANAGER:GetCraftedAbilityData(craftedAbilityId)
        return craftedAbilityData:GetActiveConfigurationLink()
    end
end
--[[
A ZO_SkillLineData_Base is an entry in ZO_SkillTypeData. A skill line has multiple skills to purchase and upgrade, denoted by ZO_SkillData objects.
--]]
----------------
-- Skill Line --
----------------
ZO_SkillLineData_Base = ZO_PooledSkillDataObject:Subclass()
function ZO_SkillLineData_Base:Initialize(dataManager)
    self.dataManager = dataManager
    self.skillsWithUpdatesCache = {}
end
-- abstract methods (must be overridden)
ZO_SkillLineData_Base:MUST_IMPLEMENT("BuildStaticData", skillTypeData, skillLineIndex)
ZO_SkillLineData_Base:MUST_IMPLEMENT("RefreshDynamicData", refreshChildren)
ZO_SkillLineData_Base:MUST_IMPLEMENT("GetName")
ZO_SkillLineData_Base:MUST_IMPLEMENT("GetUnlockText")
ZO_SkillLineData_Base:MUST_IMPLEMENT("GetOrderingIndex")
ZO_SkillLineData_Base:MUST_IMPLEMENT("IsDiscovered")
ZO_SkillLineData_Base:MUST_IMPLEMENT("IsActive")
ZO_SkillLineData_Base:MUST_IMPLEMENT("GetCurrentRank")
ZO_SkillLineData_Base:MUST_IMPLEMENT("GetLastRankXP")
ZO_SkillLineData_Base:MUST_IMPLEMENT("GetNextRankXP")
ZO_SkillLineData_Base:MUST_IMPLEMENT("GetCurrentRankXP")
ZO_SkillLineData_Base:MUST_IMPLEMENT("GetNumSkills")
ZO_SkillLineData_Base:MUST_IMPLEMENT("GetSkillDataByIndex", skillIndex)
ZO_SkillLineData_Base:MUST_IMPLEMENT("SkillIterator", skillFilterFunctions)
-- optional methods (can be overidden)
function ZO_SkillLineData_Base:IsPlayerSkillLine()
    return false
end
function ZO_SkillLineData_Base:IsCompanionSkillLine()
    return false
end
function ZO_SkillLineData_Base:IsAdvised()
    return false
end
-- additional state
function ZO_SkillLineData_Base:Reset()
    ZO_ClearTable(self.skillsWithUpdatesCache)
end
function ZO_SkillLineData_Base:InitializeNewState()
    self.isNew = false
    self.canMarkNew = false -- prevent the first refresh from marking a skill line as "new"
end
function ZO_SkillLineData_Base:IsNew()
    return self.isNew
end
function ZO_SkillLineData_Base:SetNew(isNew)
    if self.isNew ~= isNew then
        self.isNew = isNew
        self.dataManager:OnSkillLineNewStatusChanged(self)
    end
end
function ZO_SkillLineData_Base:TryMarkNew(isNew)
    if self.canMarkNew then
        self:SetNew(isNew)
    end
end
function ZO_SkillLineData_Base:AllowMarkingNew()
    self.canMarkNew = true
end
function ZO_SkillLineData_Base:ClearNew()
    self:SetNew(false)
end
function ZO_SkillLineData_Base:OnSkillDataUpdateStatusChanged(skillData)
    local hasUpdatedStatus = skillData:HasUpdatedStatus()
    self.skillsWithUpdatesCache[skillData] = hasUpdatedStatus or nil
    self.dataManager:OnSkillLineNewStatusChanged(self)
end
function ZO_SkillLineData_Base:AnySkillHasUpdatedStatus()
    return not ZO_IsTableEmpty(self.skillsWithUpdatesCache)
end
-- helpers
function ZO_SkillLineData_Base:GetId()
    return self.id
end
function ZO_SkillLineData_Base:GetAnnounceIcon()
end
function ZO_SkillLineData_Base:GetDetailedIcon()
    return GetSkillLineDetailedIconById(self.id)
end
function ZO_SkillLineData_Base:GetFormattedName()
    return ZO_CachedStrFormat(SI_SKILLS_ENTRY_LINE_NAME_FORMAT, self:GetName())
end
function ZO_SkillLineData_Base:IsAvailable()
    return self:IsDiscovered() and self:IsActive()
end
function ZO_SkillLineData_Base:IsAvailableOrAdvised()
    return self:IsAvailable() or self:IsAdvised()
end
function ZO_SkillLineData_Base:GetRankXPValues()
end
function ZO_SkillLineData_Base:IsSkillLineOrAbilitiesNew()
    return self:IsNew() or self:AnySkillHasUpdatedStatus()
end
--[[
A ZO_SkillTypeData is the overarching categorization of skill lines. A skill type can be subcategorized down into multiple skill lines, denoted by ZO_SkillLineData_Base objects.
--]]
----------------
-- Skill Type --
----------------
ZO_SkillTypeData = ZO_PooledSkillDataObject:Subclass()
function ZO_SkillTypeData:Initialize()
    self.orderedSkillLines = {}
end
function ZO_SkillTypeData:Reset()
    ZO_ClearNumericallyIndexedTable(self.orderedSkillLines)
    -- skill line datas should be released on the data manager level
end
do
    assert(SKILL_TYPE_MAX_VALUE == 9, "Update this table")
    local SKILL_TYPE_TO_ICON_PATH_QUALIFIER = 
    {
        [SKILL_TYPE_CLASS] = "class",
        [SKILL_TYPE_WEAPON] = "weapons",
        [SKILL_TYPE_ARMOR] = "armor",
        [SKILL_TYPE_WORLD] = "world",
        [SKILL_TYPE_GUILD] = "guilds",
        [SKILL_TYPE_AVA] = "ava",
        [SKILL_TYPE_RACIAL] = "race",
        [SKILL_TYPE_TRADESKILL] = "tradeskills",
    }
    function ZO_SkillTypeData:BuildStaticData(skillType)
        self.skillType = skillType
        self.name = GetString("SI_SKILLTYPE", skillType)
        local QUALIFIER = SKILL_TYPE_TO_ICON_PATH_QUALIFIER[skillType]
        if QUALIFIER then
            self.keyboardNormalIcon = string.format("EsoUI/Art/Progression/progression_indexIcon_%s_up.dds", QUALIFIER)
            self.keyboardPressedIcon = string.format("EsoUI/Art/Progression/progression_indexIcon_%s_down.dds", QUALIFIER)
            self.keyboardMousedOverIcon = string.format("EsoUI/Art/Progression/progression_indexIcon_%s_over.dds", QUALIFIER)
            self.announceIcon = string.format("EsoUI/Art/Progression/skills_announce_%s.dds", QUALIFIER)
        end
    end
end
function ZO_SkillTypeData:AddOrderedSkillLineData(skillLineData)
    table.insert(self.orderedSkillLines, skillLineData)
end
function ZO_SkillTypeData:RefreshDynamicData(refreshChildren)
    if refreshChildren then
        for _, skillLineData in ipairs(self.orderedSkillLines) do
            skillLineData:RefreshDynamicData(refreshChildren)
        end
    end
end
function ZO_SkillTypeData:GetSkillType()
    return self.skillType
end
function ZO_SkillTypeData:GetName()
    return self.name
end
function ZO_SkillTypeData:GetKeyboardIcons()
    return self.keyboardNormalIcon, self.keyboardPressedIcon, self.keyboardMousedOverIcon
end
function ZO_SkillTypeData:GetAnnounceIcon()
    return self.announceIcon
end
function ZO_SkillTypeData:GetSkillLineDataByIndex(skillLineIndex)
    return self.orderedSkillLines[skillLineIndex]
end
function ZO_SkillTypeData:SkillLineIterator(skillLineFilterFunctions)
    return ZO_FilteredNumericallyIndexedTableIterator(self.orderedSkillLines, skillLineFilterFunctions)
end
function ZO_SkillTypeData:AreAnySkillLinesNew()
    for _, skillLineData in self:SkillLineIterator({ ZO_SkillLineData_Base.IsNew }) do
        return true
    end
    return false
end
function ZO_SkillTypeData:AreAnySkillLinesOrAbilitiesNew()
    for _, skillLineData in self:SkillLineIterator({ ZO_SkillLineData_Base.IsSkillLineOrAbilitiesNew } ) do
        return true
    end
    return false
end