forked from cdmichaelb/Outfitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OutfitterItemStats.lua
799 lines (627 loc) · 21.2 KB
/
OutfitterItemStats.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
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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
----------------------------------------
-- Stat categories
----------------------------------------
Outfitter.StatCategories = {}
function Outfitter:GetCategoryByID(pCategoryID)
for _, vCategory in ipairs(Outfitter.StatCategories) do
if vCategory.CategoryID == pCategoryID then
return vCategory
end
end
end
function Outfitter:GetStatByID(pStatID)
for _, vCategory in ipairs(Outfitter.StatCategories) do
local vNumStats = vCategory:GetNumStats()
for vStatIndex = 1, vNumStats do
local vStat = vCategory:GetIndexedStat(vStatIndex)
if vStat.ID == pStatID then
return vStat
end
end
end
end
function Outfitter:GetStatIDName(pStatID)
local vStat = self:GetStatByID(pStatID)
return vStat and vStat.Name
end
function Outfitter:GetStatConfigName(pStatConfig)
if not pStatConfig then
return
end
local vName
for _, vStatConfig in ipairs(pStatConfig) do
local vStat = self:GetStatByID(vStatConfig.StatID)
if not vStat then
return -- One of the stats is missing, return nothing
end
if not vName then
vName = vStat.Name
else
vName = vName..", "..vStat.Name
end
end
return vName
end
function Outfitter:CalcOutfitScore(pOutfit, pStat)
if pStat.GetOutfitScore then
return pStat:GetOutfitScore(pOutfit)
elseif pStat.GetItemScore then
local vTotalScore = 0
local vItems = pOutfit:GetItems()
for _, vItem in pairs(vItems) do
local vItemScore = pStat:GetItemScore(vItem)
if vItemScore then
vTotalScore = vTotalScore + vItemScore
end
end
return vTotalScore
else
return 0
end
end
function Outfitter:ConstrainScore(pScore, pStatInfo)
if pStatInfo.MinValue then
-- If the score doesn't meet the minimum then set it to zero
-- so that it doesn't affect the final outfit
if pScore < pStatInfo.MinValue then
pScore = 0
-- Set it to the minimum so that higher scores aren't better
-- This keeps the score as close to minValue as possible
else
pScore = pStatInfo.MinValue
end
elseif pStatInfo.MaxValue then
-- If the score is more than the max then set it to zero
-- so that it doesn't affect the final outfit
if pScore > pStatInfo.MaxValue then
pScore = 0
end
end
return pScore
end
function Outfitter:GetMultiStatScore(pOutfit, pParams)
local vCombiScores = {}
for vIndex, vStatInfo in ipairs(pParams) do
vCombiScores[vIndex] = self:CalcOutfitScore(pOutfit, vStatInfo.Stat) or 0
end
return vCombiScores
end
----------------------------------------
Outfitter._SimpleStatCategory = {}
----------------------------------------
function Outfitter._SimpleStatCategory:GetNumStats()
return #self.Stats
end
function Outfitter._SimpleStatCategory:GetIndexedStat(pIndex)
return self.Stats[pIndex]
end
Outfitter._SimpleStatCategoryMetaTable = {__index = Outfitter._SimpleStatCategory}
----------------------------------------
Outfitter._SimpleStat = {}
----------------------------------------
function Outfitter._SimpleStat:GetItemScore(pItem)
local vScore
-- Try to use a cached value
if pItem.ScoreCache then
vScore = pItem.ScoreCache[self]
end
-- Calculate the value if the cache wasn't available
if not vScore then
vScore = self:GetUncachedItemScore(pItem) or 0
-- Create the cache table if necessary
if not pItem.ScoreCache then
pItem.ScoreCache = {}
setmetatable(pItem.ScoreCache, {__mode = "k"}) -- use weak keys
end
-- Remember the score
pItem.ScoreCache[self] = vScore
end
-- Done
return vScore
end
function Outfitter._SimpleStat:GetUncachedItemScore(pItem)
-- Parse the stats
local vStats = Outfitter.ItemStatsLib:statsForLink(pItem.Link)
-- Leave if no stats
if not vStats then
return
end
-- Leave if the item is too high-level
if vStats.minLevel > UnitLevel("player") then
return
end
-- Total stats
if self.ID == "TOTAL_STATS" then
return (vStats.values.STA or 0)
+ (vStats.values.STR or 0)
+ (vStats.values.INT or 0)
+ (vStats.values.AGI or 0)
+ (vStats.values.MAS or 0)
+ (vStats.values.HAS or 0)
+ (vStats.values.CRI or 0)
+ (vStats.values.VER or 0)
+ (vStats.values.SPI or 0)
-- Static stat values
else
local value = tonumber(vStats.values[self.ID])
return value
end
end
Outfitter._SimpleStatMetaTable = {__index = Outfitter._SimpleStat}
----------------------------------------
-- Simple stats
----------------------------------------
Outfitter.SimpleStatCategories =
{
{
CategoryID = "Stat",
Name = PLAYERSTAT_BASE_STATS,
Stats =
{
{ID = "STA", Name = Outfitter.ItemStatsLib.strings.Stamina},
{ID = "STR", Name = Outfitter.ItemStatsLib.strings.Strength},
{ID = "INT", Name = Outfitter.ItemStatsLib.strings.Intellect},
{ID = "AGI", Name = Outfitter.ItemStatsLib.strings.Agility},
{ID = "SPI", Name = Outfitter.ItemStatsLib.strings.Spirit},
{ID = "HAS", Name = Outfitter.ItemStatsLib.strings.Haste},
{ID = "VER", Name = Outfitter.ItemStatsLib.strings.Versatility},
{ID = "MAS", Name = Outfitter.ItemStatsLib.strings.Mastery},
{ID = "CRI", Name = Outfitter.ItemStatsLib.strings.CriticalStrike},
{ID = "TOTAL_STATS", Name = Outfitter.cTotalStatsName},
{ID = "ITEM_LEVEL", Name = Outfitter.cItemLevelName},
},
},
{
CategoryID = "Melee",
Name = PLAYERSTAT_MELEE_COMBAT,
Stats =
{
--{ID = "MELEE_DMG"},
--{ID = "MELEE_HASTE_RATING"},
--{ID = "AP"},
--{ID = "RANGED_AP"},
{ID = ITEM_MOD_HIT_RATING_SHORT, Name = Outfitter.ItemStatsLib.strings.Hit},
--{ID = "MELEE_CRIT_RATING"},
--{ID = "EXPERTISE_RATING"},
--{ID = "ARMOR_PENETRATION_RATING"},
},
},
{
CategoryID = "Ranged",
Name = PLAYERSTAT_RANGED_COMBAT,
Stats =
{
--{ID = "RANGED_DMG"},
--{ID = "RANGED_HASTE_RATING"},
--{ID = "RANGED_AP"},
--{ID = "RANGED_HIT_RATING"},
--{ID = "RANGED_CRIT_RATING"},
},
},
{
CategoryID = "Spell",
Name = PLAYERSTAT_SPELL_COMBAT,
Stats =
{
--{ID = "SPELL_DMG"},
--{ID = "HEAL"},
{ID = ITEM_MOD_HIT_SPELL_RATING_SHORT, Name = Outfitter.ItemStatsLib.strings.SpellHit},
--{ID = "SPELL_CRIT_RATING"},
--{ID = "SPELL_HASTE_RATING"},
--{ID = "SPELLPEN"},
--{ID = "MANA"},
--{ID = "MANA_REG"},
},
},
-- {
-- CategoryID = "Defense",
-- Name = PLAYERSTAT_DEFENSES,
-- Stats =
-- {
-- {ID = "ARMOR"},
-- {ID = "DEFENSE_RATING"},
-- {ID = "DODGE_RATING"},
-- {ID = "PARRY_RATING"},
-- {ID = "BLOCK_RATING"},
-- {ID = "RESILIENCE_RATING"},
-- {ID = "HEALTH"},
-- {ID = "HEALTH_REG"},
-- },
-- },
{
CategoryID = "Resist",
Name = Outfitter.cResistCategory,
Stats =
{
{ID = RESISTANCE6_NAME, Name = Outfitter.ItemStatsLib.strings.ArcaneResist},
{ID = RESISTANCE2_NAME, Name = Outfitter.ItemStatsLib.strings.FireResist},
{ID = RESISTANCE4_NAME, Name = Outfitter.ItemStatsLib.strings.FrostResist},
{ID = ESISTANCE3_NAME, Name = Outfitter.ItemStatsLib.strings.NatureResist}, --Miv
{ID = RESISTANCE5_NAME, Name = Outfitter.ItemStatsLib.strings.ShadowResist},
},
},
-- {
-- CategoryID = "Trade",
-- Name = Outfitter.cTradeCategory,
-- Stats =
-- {
-- {ID = "FISHING"},
-- {ID = "HERBALISM"},
-- {ID = "MINING"},
-- {ID = "SKINNING"},
-- {ID = "RUN_SPEED"},
-- {ID = "MOUNT_SPEED"},
-- },
-- },
}
----------------------------------------
-- Install the simple stats
----------------------------------------
for _, vStatCategory in ipairs(Outfitter.SimpleStatCategories) do
setmetatable(vStatCategory, Outfitter._SimpleStatCategoryMetaTable)
for _, vStat in ipairs(vStatCategory.Stats) do
if not vStat.Name then
vStat.Name = vStat.ID
end
setmetatable(vStat, Outfitter._SimpleStatMetaTable)
end
table.insert(Outfitter.StatCategories, vStatCategory)
end
----------------------------------------
Outfitter.PawnScalesCategory =
----------------------------------------
{
Name = "Pawn",
CategoryID = "Pawn",
}
function Outfitter.PawnScalesCategory:GetNumStats()
local vScaleNames = PawnGetAllScales()
if self.Scales then
for vKey, _ in pairs(self.Scales) do
self.Scales[vKey] = nil
end
else
self.Scales = {}
end
for _, vScaleName in ipairs(vScaleNames) do
if PawnIsScaleVisible(vScaleName) then
local vScale =
{
Name = vScaleName,
ID = "Pawn_"..vScaleName,
}
setmetatable(vScale, Outfitter._PawnScaleStatMetaTable)
table.insert(self.Scales, vScale)
end
end
return #self.Scales
end
function Outfitter.PawnScalesCategory:GetIndexedStat(pIndex)
Outfitter:DebugTable(self.Scales[pIndex], "Stat "..pIndex)
return self.Scales[pIndex]
end
----------------------------------------
Outfitter._PawnScaleStat = {}
----------------------------------------
function Outfitter._PawnScaleStat:GetItemScore(pItem)
-- Ignore nil items
if not pItem or not pItem.Link then
return
end
-- Get the score
local vScore
-- Try to use a cached value
if pItem.ScoreCache then
vScore = pItem.ScoreCache[self]
end
-- Calculate the value if the cache wasn't available
if not vScore then
-- Parse the stats
local vStats = Outfitter.ItemStatsLib:statsForLink(pItem.Link)
-- Score zero if no stats
if not vStats then
vScore = 0
-- Ignore the item if it's too high level
elseif vStats.minLevel > UnitLevel("player") then
vScore = 0
-- Calculate the Pawn score
else
local vItemData = PawnGetItemData(pItem.Link)
-- Score is zero if no item data
if not vItemData then
vScore = 0
-- Search for the scale we're using
else
for _, vEntry in pairs(vItemData.Values) do
local vScaleName, vValue, UnenchantedValue = vEntry[1], vEntry[2], vEntry[3]
if vScaleName == self.Name then
vScore = vValue
break
end
end
end
end
-- Create the cache table if necessary
if not pItem.ScoreCache then
pItem.ScoreCache = {}
setmetatable(pItem.ScoreCache, {__mode = "k"}) -- use weak keys
end
-- Remember the score
pItem.ScoreCache[self] = vScore
end
-- Done
return vScore
end
Outfitter._PawnScaleStatMetaTable = {__index = Outfitter._PawnScaleStat}
----------------------------------------
-- Install Pawn scales
----------------------------------------
if IsAddOnLoaded("Pawn") then
table.insert(Outfitter.StatCategories, Outfitter.PawnScalesCategory)
else
Outfitter.EventLib:RegisterEvent("ADDON_LOADED", function (pEventID, pAddOnName)
if pAddOnName == "Pawn" then
table.insert(Outfitter.StatCategories, Outfitter.PawnScalesCategory)
end
end)
end
----------------------------------------
Outfitter.WeightsWatcherCategory =
----------------------------------------
{
Name = "WeightsWatcher",
CategoryID = "WW",
}
function Outfitter.WeightsWatcherCategory:GetNumStats()
local _, vClassID = UnitClass("player")
if not ww_vars.weightsList[vClassID] then
return 0
end
local vActiveWeights = ww_charVars.activeWeights[vClassID]
if not vActiveWeights then
return 0
end
if self.ActiveWeights then
wipe(self.ActiveWeights)
else
self.ActiveWeights = {}
end
for _, vWeightName in ipairs(vActiveWeights) do
local vWeight =
{
Name = vWeightName,
ID = "WW_"..vWeightName,
ClassID = vClassID,
Weight = vWeightName,
}
setmetatable(vWeight, Outfitter._WeightsWatcherStatMetaTable)
table.insert(self.ActiveWeights, vWeight)
end
return #self.ActiveWeights
end
function Outfitter.WeightsWatcherCategory:GetIndexedStat(pIndex)
return self.ActiveWeights[pIndex]
end
----------------------------------------
Outfitter._WeightsWatcherStat = {}
----------------------------------------
function Outfitter._WeightsWatcherStat:GetItemScore(pItem)
return ww_weightCache[self.ClassID][self.Weight][pItem.Link]
end
Outfitter._WeightsWatcherStatMetaTable = {__index = Outfitter._WeightsWatcherStat}
----------------------------------------
-- Install WeightsWatcher
----------------------------------------
if IsAddOnLoaded("WeightsWatcher") then
table.insert(Outfitter.StatCategories, Outfitter.WeightsWatcherCategory)
else
Outfitter.EventLib:RegisterEvent("ADDON_LOADED", function (pEventID, pAddOnName)
if pAddOnName == "WeightsWatcher" then
table.insert(Outfitter.StatCategories, Outfitter.WeightsWatcherCategory)
end
end)
end
----------------------------------------
Outfitter._MultiStat = {}
----------------------------------------
Outfitter._MultiStat.Name = "Multiple stats"
function Outfitter._MultiStat:GetFilterStats()
return self.FilterStats
end
function Outfitter._MultiStat:Begin(pInventoryCache)
for _, vStatInfo in ipairs(self.Config) do
if vStatInfo.Stat.Begin then
vStatInfo.Stat:Begin(pInventoryCache)
end
end
end
function Outfitter._MultiStat:Begin(pInventoryCache)
for _, vStatInfo in ipairs(self.Config) do
if vStatInfo.Stat.Begin then
vStatInfo.Stat:Begin(pInventoryCache)
end
end
end
function Outfitter._MultiStat:End(pInventoryCache)
for _, vStatInfo in ipairs(self.Config) do
if vStatInfo.Stat.End then
vStatInfo.Stat:End(pInventoryCache)
end
end
end
function Outfitter._MultiStat:GetOutfitScore(pOutfit, pStatParams)
return Outfitter:GetMultiStatScore(pOutfit, self.Config)
end
function Outfitter._MultiStat:CompareOutfits(pOldOutfit, pNewOutfit, pStatParams)
return Outfitter:MultiStatCompare(pPreviousOutfit, pNewOutfit, self.Config)
end
Outfitter._MultiStatMetaTable = {__index = Outfitter._MultiStat}
----------------------------------------
Outfitter.TankPointsCategory =
----------------------------------------
{
Name = "TankPoints",
CategoryID = "TankPoints",
Stats =
{
{Name = "Melee TankPoints", School = "MELEE"},
{Name = "Ranged TankPoints", School = "RANGED"},
{Name = "Holy TankPoints", School = "HOLY"},
{Name = "Fire TankPoints", School = "FIRE"},
{Name = "Nature TankPoints", School = "NATURE"},
{Name = "Frost TankPoints", School = "FROST"},
{Name = "Shadow TankPoints", School = "SHADOW"},
{Name = "Arcane TankPoints", School = "ARCANE"},
},
}
for _, vStat in ipairs(Outfitter.TankPointsCategory.Stats) do
vStat.ID = "TP_"..vStat.School
setmetatable(vStat, Outfitter._TankPointsStatMetaTable)
end
function Outfitter.TankPointsCategory:GetNumStats()
return #self.Stats
end
function Outfitter.TankPointsCategory:GetIndexedStat(pIndex)
return self.Stats[pIndex]
end
----------------------------------------
-- Install TankPoints
----------------------------------------
--[[
if IsAddOnLoaded("TankPoints") then
table.insert(Outfitter.StatCategories, Outfitter.TankPointsCategory)
else
Outfitter.EventLib:RegisterEvent("ADDON_LOADED", function (pEventID, pAddOnName)
if pAddOnName == "TankPoints" then
table.insert(Outfitter.StatCategories, Outfitter.TankPointsCategory)
end
end)
end
]]
----------------------------------------
-- Tank Points
----------------------------------------
function Outfitter.TankPoints_New()
local vTankPointData = {}
local vStatDistribution = Outfitter:GetPlayerStatDistribution()
if not vStatDistribution then
Outfitter:ErrorMessage("Missing stat distribution data for "..Outfitter.PlayerClass)
return
end
vTankPointData.PlayerLevel = UnitLevel("player")
vTankPointData.StaminaFactor = 1.0 -- Warlocks with demonic embrace = 1.15
-- Get the base stats
vTankPointData.BaseStats = {}
Outfitter.Stats_AddStatValue(vTankPointData.BaseStats, "Strength", UnitStat("player", 1))
Outfitter.Stats_AddStatValue(vTankPointData.BaseStats, "Agility", UnitStat("player", 2))
Outfitter.Stats_AddStatValue(vTankPointData.BaseStats, "Stamina", UnitStat("player", 3))
Outfitter.Stats_AddStatValue(vTankPointData.BaseStats, "Intellect", UnitStat("player", 4))
Outfitter.Stats_AddStatValue(vTankPointData.BaseStats, "Spirit", UnitStat("player", 5))
Outfitter.Stats_AddStatValue(vTankPointData.BaseStats, "Health", UnitHealthMax("player"))
vTankPointData.BaseStats.Health = vTankPointData.BaseStats.Health - vTankPointData.BaseStats.Stamina * 10
vTankPointData.BaseStats.Dodge = GetDodgeChance()
vTankPointData.BaseStats.Parry = GetParryChance()
vTankPointData.BaseStats.Block = GetBlockChance()
local vBaseDefense, vBuffDefense = UnitDefense("player")
Outfitter.Stats_AddStatValue(vTankPointData.BaseStats, "Defense", vBaseDefense + vBuffDefense)
-- Replace the armor with the current value since that already includes various factors
local vBaseArmor, vEffectiveArmor, vArmor, vArmorPosBuff, vArmorNegBuff = UnitArmor("player")
vTankPointData.BaseStats.Armor = vEffectiveArmor
Outfitter:DebugMessage("------------------------------------------")
Outfitter:DebugTable(vTankPointData, "vTankPointData")
-- Subtract out the current outfit
local vCurrentOutfitStats = Outfitter.TankPoints_GetCurrentOutfitStats(vStatDistribution)
Outfitter:DebugMessage("------------------------------------------")
Outfitter:DebugTable(vCurrentOutfitStats, "vCurrentOutfitStats")
Outfitter.Stats_SubtractStats(vTankPointData.BaseStats, vCurrentOutfitStats)
-- Calculate the buff stats (stuff from auras/spell buffs/whatever)
vTankPointData.BuffStats = {}
-- Reset the cumulative values
Outfitter.TankPoints_Reset(vTankPointData)
Outfitter:DebugMessage("------------------------------------------")
Outfitter:DebugTable(vTankPointData, "vTankPointData")
Outfitter:DebugMessage("------------------------------------------")
return vTankPointData
end
function Outfitter.TankPoints_Reset(pTankPointData)
pTankPointData.AdditionalStats = {}
end
function Outfitter.TankPoints_GetTotalStat(pTankPointData, pStat)
local vTotalStat = pTankPointData.BaseStats[pStat]
if not vTotalStat then
vTotalStat = 0
end
local vAdditionalStat = pTankPointData.AdditionalStats[pStat]
if vAdditionalStat then
vTotalStat = vTotalStat + vAdditionalStat
end
local vBuffStat = pTankPointData.BuffStats[pStat]
if vBuffStat then
vTotalStat = vTotalStat + vBuffStat
end
--
return vTotalStat
end
function Outfitter.TankPoints_CalcTankPoints(pTankPointData, pStanceModifier)
if not pStanceModifier then
pStanceModifier = 1
end
Outfitter:DebugTable(pTankPointData, "pTankPointData")
local vEffectiveArmor = Outfitter.TankPoints_GetTotalStat(pTankPointData, "Armor")
Outfitter:TestMessage("Armor: "..vEffectiveArmor)
local vArmorReduction = vEffectiveArmor / ((85 * pTankPointData.PlayerLevel) + 400)
vArmorReduction = vArmorReduction / (vArmorReduction + 1)
local vEffectiveHealth = Outfitter.TankPoints_GetTotalStat(pTankPointData, "Health")
Outfitter:TestMessage("Health: "..vEffectiveHealth)
Outfitter:TestMessage("Stamina: "..Outfitter.TankPoints_GetTotalStat(pTankPointData, "Stamina"))
--
local vEffectiveDodge = Outfitter.TankPoints_GetTotalStat(pTankPointData, "Dodge") * 0.01
local vEffectiveParry = Outfitter.TankPoints_GetTotalStat(pTankPointData, "Parry") * 0.01
local vEffectiveBlock = Outfitter.TankPoints_GetTotalStat(pTankPointData, "Block") * 0.01
local vEffectiveDefense = Outfitter.TankPoints_GetTotalStat(pTankPointData, "Defense")
-- Add agility and defense to dodge
-- defenseInputBox:GetNumber() * 0.04 + agiInputBox:GetNumber() * 0.05
Outfitter:TestMessage("Dodge: "..vEffectiveDodge)
Outfitter:TestMessage("Parry: "..vEffectiveParry)
Outfitter:TestMessage("Block: "..vEffectiveBlock)
Outfitter:TestMessage("Defense: "..vEffectiveDefense)
local vDefenseModifier = (vEffectiveDefense - pTankPointData.PlayerLevel * 5) * 0.04 * 0.01
Outfitter:TestMessage("Crit reduction: "..vDefenseModifier)
local vMobCrit = max(0, 0.05 - vDefenseModifier)
local vMobMiss = 0.05 + vDefenseModifier
local vMobDPS = 1
local vTotalReduction = 1 - (vMobCrit * 2 + (1 - vMobCrit - vMobMiss - vEffectiveDodge - vEffectiveParry)) * (1 - vArmorReduction) * pStanceModifier
Outfitter:TestMessage("Total reduction: "..vTotalReduction)
local vTankPoints = vEffectiveHealth / (vMobDPS * (1 - vTotalReduction))
return vTankPoints
--[[
Stats used in TankPoints calculation:
Health
Dodge
Parry
Block
Defense
Armor
]]--
end
function Outfitter.TankPoints_GetCurrentOutfitStats(pStatDistribution)
local vTotalStats = {}
for _, vSlotName in ipairs(Outfitter.cSlotNames) do
local vStats = Outfitter.ItemList_GetItemStats({SlotName = vSlotName})
if vStats then
Outfitter:TestMessage("--------- "..vSlotName)
for vStat, vValue in pairs(vStats) do
Outfitter.Stats_AddStatValue(vTotalStats, vStat, vValue)
end
end
end
return vTotalStats
end
function Outfitter.TankPoints_Test()
local vStatDistribution = Outfitter:GetPlayerStatDistribution()
local vTankPointData = Outfitter.TankPoints_New()
local vStats = Outfitter.TankPoints_GetCurrentOutfitStats(vStatDistribution)
Outfitter.Stats_AddStats(vTankPointData.AdditionalStats, vStats)
local vTankPoints = Outfitter.TankPoints_CalcTankPoints(vTankPointData)
Outfitter:TestMessage("TankPoints = "..vTankPoints)
end