View Single Post
12/06/17, 02:26 PM   #15
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Counting skill points is a bit hard.

I did a pretty good algorithm in superstar :

All you have to do is to maintain the list of given skill points. It could be a bit optimized with skillLinesId, but I still didn't did it since addition of those functions. It would eliminate craft localization issue and the Guild/World skilllines which have dynamic skilllines indices.

Lua Code:
  1. local SKILLTYPES_IN_SKILLBUILDER = 8
  2. local ABILITY_LEVEL_NONMORPHED = 0
  3.  
  4. function SuperStarSkills:GetAvailableSkillPoints()
  5.    
  6.     local skillPoints = 0
  7.    
  8.     -- SkillTypes (class, etc)
  9.     for skillType=1, SKILLTYPES_IN_SKILLBUILDER do
  10.        
  11.         -- SkillLine (Bow, etc)
  12.         for skillLineIndex=1, GetNumSkillLines(skillType) do
  13.            
  14.             for abilityIndex=1, GetNumSkillAbilities(skillType, skillLineIndex) do
  15.                 skillPoints = skillPoints + SuperStarSkills:GetPointsSpentInAbility(skillType, skillLineIndex, abilityIndex)
  16.             end
  17.            
  18.         end
  19.        
  20.     end
  21.    
  22.     SuperStarSkills.spentSkillPoints = skillPoints + GetAvailableSkillPoints()
  23.    
  24.     return SuperStarSkills.spentSkillPoints
  25.    
  26. end
  27.  
  28. function SuperStarSkills:GetPointsSpentInAbility(skillType, skillLineIndex, abilityIndex)
  29.    
  30.     local _, _, _, _, _, purchased, progressionIndex = GetSkillAbilityInfo(skillType, skillLineIndex, abilityIndex)
  31.    
  32.     if not purchased then
  33.         return 0
  34.     elseif progressionIndex then
  35.        
  36.         -- Active skills
  37.        
  38.         -- Skill has been purchased
  39.         local _, morph = GetAbilityProgressionInfo(progressionIndex)
  40.         local skillLineName = GetSkillLineInfo(skillType, skillLineIndex)
  41.         if morph > ABILITY_LEVEL_NONMORPHED then
  42.             return (2 - SuperStarSkills:GetExceptionsPointsSpentInAbility(skillType, skillLineIndex, skillLineName, abilityIndex))
  43.         else
  44.             return (1 - SuperStarSkills:GetExceptionsPointsSpentInAbility(skillType, skillLineIndex, skillLineName, abilityIndex))
  45.         end
  46.        
  47.     else
  48.    
  49.         -- Passive skills
  50.         local currentUpgradeLevel = GetSkillAbilityUpgradeInfo(skillType, skillLineIndex, abilityIndex)
  51.        
  52.         local skillLineName = GetSkillLineInfo(skillType, skillLineIndex)
  53.         if currentUpgradeLevel then
  54.             return (currentUpgradeLevel - SuperStarSkills:GetExceptionsPointsSpentInAbility(skillType, skillLineIndex, skillLineName, abilityIndex))
  55.         else
  56.             return (1 - SuperStarSkills:GetExceptionsPointsSpentInAbility(skillType, skillLineIndex, skillLineName, abilityIndex))
  57.         end
  58.        
  59.     end
  60.    
  61. end
  62.  
  63. function SuperStarSkills:GetExceptionsPointsSpentInAbility(skillType, skillLineIndex, skillLineName, abilityIndex)
  64.  
  65.     -- Using SkillLines because thoses skilllines can or cannot be unlocked
  66.    
  67.     local exceptionList = {}
  68.    
  69.     exceptionList[SKILL_TYPE_WORLD] = {}
  70.     exceptionList[SKILL_TYPE_WORLD][2] = {}
  71.     exceptionList[SKILL_TYPE_WORLD][2][2] = true -- Soul Magic SoulTrap
  72.     exceptionList[SKILL_TYPE_WORLD][4] = {}
  73.     exceptionList[SKILL_TYPE_WORLD][4][1] = true -- WW Ultimate
  74.    
  75.     exceptionList[SKILL_TYPE_GUILD] = {}
  76.     exceptionList[SKILL_TYPE_GUILD][1] = {}
  77.     exceptionList[SKILL_TYPE_GUILD][1][1] = true -- Blade of Woe
  78.     exceptionList[SKILL_TYPE_GUILD][4] = {}
  79.     exceptionList[SKILL_TYPE_GUILD][4][1] = true -- Finders keepers
  80.    
  81.     exceptionList[SKILL_TYPE_RACIAL] = {}
  82.     exceptionList[SKILL_TYPE_RACIAL][1] = {}
  83.     exceptionList[SKILL_TYPE_RACIAL][1][1] = true -- 1st Racial passive
  84.    
  85.     exceptionList[SKILL_TYPE_TRADESKILL] = {}
  86.    
  87.     exceptionList[SKILL_TYPE_TRADESKILL][1] = {}
  88.     exceptionList[SKILL_TYPE_TRADESKILL][1][1] = true -- 1st Alchemy passive
  89.    
  90.     exceptionList[SKILL_TYPE_TRADESKILL][4] = {}
  91.     exceptionList[SKILL_TYPE_TRADESKILL][4][1] = true -- 1st Enchanting passive
  92.     exceptionList[SKILL_TYPE_TRADESKILL][4][2] = true -- 2nd Enchanting passive
  93.    
  94.     exceptionList[SKILL_TYPE_TRADESKILL][6] = {}
  95.     exceptionList[SKILL_TYPE_TRADESKILL][6][1] = true -- 1st Woodworking passive
  96.    
  97.     local _, blackSmithing = GetCraftingSkillLineIndices(CRAFTING_TYPE_BLACKSMITHING)
  98.     if blackSmithing == 5 then -- FR, DE
  99.         exceptionList[SKILL_TYPE_TRADESKILL][2] = {}
  100.         exceptionList[SKILL_TYPE_TRADESKILL][2][1] = true -- 1st Clothing passive
  101.        
  102.         exceptionList[SKILL_TYPE_TRADESKILL][3] = {}
  103.         exceptionList[SKILL_TYPE_TRADESKILL][3][1] = true -- 1st Provisionning passive
  104.         exceptionList[SKILL_TYPE_TRADESKILL][3][2] = true -- 2nd Provisionning passive
  105.        
  106.         exceptionList[SKILL_TYPE_TRADESKILL][5] = {}
  107.         exceptionList[SKILL_TYPE_TRADESKILL][5][1] = true -- 1st Blacksmithing passive
  108.     else
  109.         exceptionList[SKILL_TYPE_TRADESKILL][3] = {}
  110.         exceptionList[SKILL_TYPE_TRADESKILL][3][1] = true -- 1st Clothing passive
  111.        
  112.         exceptionList[SKILL_TYPE_TRADESKILL][5] = {}
  113.         exceptionList[SKILL_TYPE_TRADESKILL][5][1] = true -- 1st Provisionning passive
  114.         exceptionList[SKILL_TYPE_TRADESKILL][5][2] = true -- 2nd Provisionning passive
  115.        
  116.         exceptionList[SKILL_TYPE_TRADESKILL][2] = {}
  117.         exceptionList[SKILL_TYPE_TRADESKILL][2][1] = true -- 1st Blacksmithing passive
  118.     end
  119.    
  120.     local skillLineConverter = {
  121.         [LSF:GetSkillLineInfo(SKILL_TYPE_WORLD, 2)] = 2,
  122.         [LSF:GetSkillLineInfo(SKILL_TYPE_WORLD, 4)] = 4,
  123.        
  124.         [LSF:GetSkillLineInfo(SKILL_TYPE_GUILD, 1)] = 1,
  125.         [LSF:GetSkillLineInfo(SKILL_TYPE_GUILD, 4)] = 4,
  126.     }
  127.    
  128.     if exceptionList[skillType] then
  129.         if skillType == SKILL_TYPE_GUILD or skillType == SKILL_TYPE_WORLD then
  130.             skillLineName = zo_strformat(SI_SKILLS_TREE_NAME_FORMAT, skillLineName)
  131.             if exceptionList[skillType][skillLineConverter[skillLineName]] then
  132.                 if exceptionList[skillType][skillLineConverter[skillLineName]][abilityIndex] then
  133.                     return 1
  134.                 end
  135.             end
  136.         else
  137.             if exceptionList[skillType][skillLineIndex] then
  138.                 if exceptionList[skillType][skillLineIndex][abilityIndex] then
  139.                     return 1
  140.                 end
  141.             end
  142.         end
  143.     end
  144.    
  145.     return 0
  146.    
  147. end
  Reply With Quote