function SpellShop:BuyAbility(keys)
DeepPrintTable(keys)
local playerid = keys.playerid
if PlayerResource:HasSelectedHero(playerid) then
local hero = PlayerResource:GetSelectedHeroEntity(playerid)
local abilityid = keys.abid
local abilityname = spells[keys.abtype][abilityid]
local cost = cost[abilityname]
if cost == nil then
cost = 0
end
local requiredslots = keys.requiredslotsfotab
if keys.cost ~= cost then
end
if hero then
if cost <= _G.SPAndSlots[playerid]["SP"] and requiredslots <= _G.SPAndSlots[playerid]["Slots"] then
local ability = hero:AddAbility(abilityname)
if keys.replacedwith ~= "" then
hero:AddAbility(keys.replacedwith)
if keys.replacedwith == "shredder_return_chakram" then
hero:AddAbility("shredder_return_chakram_2")
end
print("REPLACEWITH")
end
if keys.withaghanim ~= "" then
hero:AddAbility(keys.withaghanim)
print("withaghanim")
end
if keys.addpanel1 ~= "" then
if keys.addpanel1 == "wisp_spirits_in" then
hero:AddAbility("wisp_empty1")
else
hero:AddAbility(keys.addpanel1)
end
print("addpanel1")
end
if keys.addpanel2 ~= "" then
if keys.addpanel2 == "wisp_spirits_out" then
hero:AddAbility("wisp_empty2")
else
hero:AddAbility(keys.addpanel2)
end
print("addpanel2")
end
ability:SetLevel(1)
EmitSoundOn("General.Buy",PlayerResource:GetPlayer(playerid))
_G.SPAndSlots[playerid]["SP"] = _G.SPAndSlots[playerid]["SP"] - cost
_G.SPAndSlots[playerid]["Slots"] = _G.SPAndSlots[playerid]["Slots"] - requiredslots
CustomGameEventManager:Send_ServerToPlayer(PlayerInstanceFromIndex(playerid+1),"SpellPointsNow",{sp = _G.SPAndSlots[playerid]["SP"]})
CustomGameEventManager:Send_ServerToPlayer(PlayerInstanceFromIndex(playerid+1),"SlotsNow",{sl = _G.SPAndSlots[playerid]["Slots"]})
end
end
end
end