- Joined
- Oct 9, 2019
- Messages
- 345
Hello hive,
I have the following function:
The only 2 previous lines in the trigger actions are enabling 2 triggers, though they will be enabled already once the spellbook levels should go to 2+, and then
The event is EVENT_PLAYER_HERO_LEVEL
The issue is that sometimes it fails to update the levels of the spells in the spell book. If it fails at level 18, it fails to update the levels for the rest of that session even if the conditions are met again at lvl24 and so on. However this only happens in live games and even when I try to re-create it in a test map it I can't. It has happened multiple times though.
I have the following function:
Lua:
function SetSpellBookAbilitesLevels(u, spellbookcode, lvl)
local spelllist = BlzGetAbilityStringLevelField(BlzGetUnitAbility(u, spellbookcode), ABILITY_SLF_SPELL_LIST, GetUnitAbilityLevel(u, spellbookcode - 1))
local startIndex = 0
local skillcode = nil
if spelllist ~= nil then
while true do
if startIndex + 3 >= StringLength(spelllist) then
break
end
skillcode = FourCC(SubString(spelllist, startIndex, startIndex + 4))
SetUnitAbilityLevel(u, skillcode, lvl)
startIndex = startIndex + 5
end
end
end
Lua:
function Level_Up_Spellbook_Conditions()
if (not (GetUnitAbilityLevelSwapped(FourCC("A0YI"), GetTriggerUnit()) > 0)) then
return false
end
if (not (GetHeroLevel(GetTriggerUnit()) >= 12)) then
return false
end
if (not (ModuloInteger(GetHeroLevel(GetTriggerUnit()), 6) == 0)) then
return false
end
return true
end
The only 2 previous lines in the trigger actions are enabling 2 triggers, though they will be enabled already once the spellbook levels should go to 2+, and then
Lua:
SetSpellBookAbilitesLevels(GetTriggerUnit(), FourCC("A0YI"), (GetHeroLevel(GetTriggerUnit()) // 6) - 1)
The event is EVENT_PLAYER_HERO_LEVEL
The issue is that sometimes it fails to update the levels of the spells in the spell book. If it fails at level 18, it fails to update the levels for the rest of that session even if the conditions are met again at lvl24 and so on. However this only happens in live games and even when I try to re-create it in a test map it I can't. It has happened multiple times though.
Last edited:
