@@ -46,6 +46,18 @@ function ItemManager:constructor(owner, itemTable)

self.trinketTable = {}
self.relicTable = {}

self.weaponUpgradeListener = CustomGameEventManager:RegisterListener('TryUpgradeWeapon'..self.owner:GetPlayerID(), Context_Wrap( self, 'UpgradeWeapon'))
self.armorUpgradeListener = CustomGameEventManager:RegisterListener('TryUpgradeArmor'..self.owner:GetPlayerID(), Context_Wrap( self, 'UpgradeArmor'))
self.otherUpgradeListener = CustomGameEventManager:RegisterListener('TryUpgradeOther'..self.owner:GetPlayerID(), Context_Wrap( self, 'UpgradeOther'))

self.equipmentQueryListener = CustomGameEventManager:RegisterListener('QueryCurrentEquipment'..self.owner:GetPlayerID(), Context_Wrap( self, 'QueryCurrentEquipment'))
end

function ItemManager:QueryCurrentEquipment()
CustomGameEventManager:Send_ServerToPlayer(self.owner:GetPlayerOwner(), "raid_kings_open_inventory", { weapon = self:GetWeaponLevel(),
armor = self:GetArmorLevel(),
other = self:GetOtherLevel() })
end

function ItemManager:InitWearables(hero)
@@ -86,13 +98,18 @@ end
function ItemManager:UpgradeArmor()
if self.currentArmor < #self.armorTable then
if self:GetEquippedArmor() then
self:GetOwner():RemoveItem(self.armorTable[self:GetEquippedArmor()] )
self:GetOwner():RemoveItem( self.armorTable[self:GetEquippedArmor()] )
end
self.currentArmor = self.currentArmor + 1
self.equippedArmor = self:GetOwner():AddItemByName(self.armorTable[self.currentArmor])
local armor = CreateItem(self.armorTable[self.currentArmor], nil, nil)
self.equippedArmor = self:GetOwner():AddItem( armor )
self:GetOwner():SetArmorWearables( self.equippedArmor:GetWearables() )

CustomGameEventManager:Send_ServerToPlayer(self.owner:GetPlayerOwner(), "raid_kings_upgraded_equipment", { weapon = self:GetWeaponLevel(),
armor = self:GetArmorLevel(),
other = self:GetOtherLevel() })
else
return print("Armor is maxed")
return error("Armor is maxed")
end
end

@@ -160,10 +177,16 @@ function ItemManager:UpgradeWeapon()
self:GetOwner():RemoveItem(self.weaponTable[self:GetEquippedWeapon()] )
end
self.currentWeapon = self.currentWeapon + 1
self.equippedWeapon = self:GetOwner():AddItemByName(self.weaponTable[self.currentWeapon])
self:GetOwner():SetWeaponWearables( self.equippedWeapon:GetWearables() )

local weapon = CreateItem(self.weaponTable[self.currentWeapon], nil, nil)
self.equippedWeapon = self:GetOwner():AddItem( weapon )
self:GetOwner():SetWeaponWearables( weapon:GetWearables() )

CustomGameEventManager:Send_ServerToPlayer(self.owner:GetPlayerOwner(), "raid_kings_upgraded_equipment", { weapon = self:GetWeaponLevel(),
armor = self:GetArmorLevel(),
other = self:GetOtherLevel() })
else
return "Weapon is maxed"
return error("Weapon is maxed")
end
end

@@ -231,10 +254,15 @@ function ItemManager:UpgradeOther()
self:GetOwner():RemoveItem(self.otherTable[self:GetEquippedOther()] )
end
self.currentOther = self.currentOther + 1
self.equippedOther = self:GetOwner():AddItemByName(self.otherTable[self.currentOther])
local other = CreateItem(self.otherTable[self.currentOther], nil, nil)
self.equippedOther = self:GetOwner():AddItem( other )
self:GetOwner():SetOtherWearables( self.equippedOther:GetWearables() )

CustomGameEventManager:Send_ServerToPlayer(self.owner:GetPlayerOwner(), "raid_kings_upgraded_equipment", { weapon = self:GetWeaponLevel(),
armor = self:GetArmorLevel(),
other = self:GetOtherLevel() })
else
return "Other is maxed"
return error("Other is maxed")
end
end

@@ -289,7 +317,7 @@ function CDOTA_BaseNPC_Hero:SetOtherWearables( wearableTable )
end

function CDOTA_Item:GetWearables()
if GameRules.AbilityKV[self:GetName()]["Wearables"] then return GameRules.AbilityKV[self:GetName()]["Wearables"] end
if GameRules.AbilityKV[self:GetName()] and GameRules.AbilityKV[self:GetName()]["Wearables"] then return GameRules.AbilityKV[self:GetName()]["Wearables"] end
return {}
end

@@ -161,17 +161,11 @@ function SkillSelection:LoadHeroSkills(hero)
for i = 0, #hero.abilityIndexingList do
local index = self:FindNextAbilityIndex(hero)
local ability = hero.abilityIndexingList[i]
local talentIndex = self:FindNextTalentIndex(hero)

if ability and index and talentIndex then
if ability and index then
hero:RemoveAbility(hero:GetAbilityByIndex(index):GetName())
hero:AddAbilityPrecache(ability):SetAbilityIndex(index)

hero:RemoveAbility(hero:GetAbilityByIndex(talentIndex):GetName())
local talentName = ability.."_talent_1"
local talent = hero:AddAbility(talentName)
print(talentName)
talent:SetAbilityIndex(talentIndex)
print(ability)
end
end
end
@@ -184,14 +178,4 @@ function SkillSelection:FindNextAbilityIndex(hero)
end
end
end
end

function SkillSelection:FindNextTalentIndex(hero)
for i = 0, 23 do
if hero:GetAbilityByIndex(i) then
if string.match(hero:GetAbilityByIndex(i):GetName(), "generic_empty_talent") then
return i
end
end
end
end