- Joined
- Nov 30, 2007
- Messages
- 1,202
I tried replacing SetPlayerAbilityAvailable with the new natives and I get undesired behaviour with some abilities not being hidden properly. It works as intended when I use SetPlayerAbilityAvailable but not at all when I change.
Here the spells have been coppied, there is for instance two paladins and I don't know what else is going on here...

Here icons have been carried over from a previous menu into the new one, even though they should have changed?
View attachment 315480
If I change it back it looks normal again:
View attachment 315484
This is all very strange as the syntax between SetPlayerAbilityAvailable and BlzUnitHideAbility is practically the same yet it leads to a completely different outcome.
JASS:
native BlzUnitHideAbility takes unit whichUnit, integer abilId, boolean flag returns nothing
native BlzUnitDisableAbility takes unit whichUnit, integer abilId, boolean flag, boolean hideUI returns nothing
JASS:
private static method applyOptionToSpell takes PlayerMenu pmenu, SpellOption o, integer pos returns nothing
if o != 0 and not o.getLocalHidden(pmenu.pid) then
set text = o.getLocalText(pmenu.pid)
set timeRemaining = o.getCooldown(pmenu.pid)
if timeRemaining > 0 then
set text = text + "|n|n" + COOLDOWN_LABEL + FormatTime(timeRemaining) + "|r"
endif
if o.getLocalEnabled(pmenu.pid) then
call BlzUnitHideAbility(pmenu.u, active[pos], false)
call BlzUnitHideAbility(pmenu.u, passive[pos], true)
//call SetPlayerAbilityAvailable(pmenu.p, active[pos], true)
//call SetPlayerAbilityAvailable(pmenu.p, passive[pos], false)
set spell = active[pos]
set pmenu.spellTable[spell] = o // map option to spell-table
else
call BlzUnitHideAbility(pmenu.u, active[pos], true)
call BlzUnitHideAbility(pmenu.u, passive[pos], false)
//call SetPlayerAbilityAvailable(pmenu.p, active[pos], false)
//call SetPlayerAbilityAvailable(pmenu.p, passive[pos], true)
set spell = passive[pos]
endif
if GetLocalPlayer() == pmenu.p then // Update Displayed Ability
call BlzSetAbilityExtendedTooltip(spell, text, 1)
call BlzSetAbilityTooltip(spell, o.getLocalLabel(pmenu.pid) + " " + hotkey[pos], 1)
call BlzSetAbilityIcon(spell, o.getLocalIcon(pmenu.pid))
endif
else
call BlzUnitHideAbility(pmenu.u, active[pos], true)
call BlzUnitHideAbility(pmenu.u, passive[pos], true)
//call SetPlayerAbilityAvailable(pmenu.p, active[pos], false)
//call SetPlayerAbilityAvailable(pmenu.p, passive[pos], false)
endif
endmethod
method showPage takes player p, integer page returns nothing
local PlayerMenu pmenu = PlayerMenu(GetPlayerId(p))
local integer maxPages
local integer i = 0
local integer j = 0
local SpellOption o
if pmenu.currOpen == 0 then
return
endif
call visibleOptions.clear()
call UnwatchSpellOptions(pmenu.pid)
loop
exitwhen i == .options.length
set o = .options[i]
set lockedOption = lockedOptions[ModuloInteger(j, 11)] // TODO: replace modulo
if lockedOption != 0 and not lockedOption.getLocalHidden(pmenu.pid) then
call visibleOptions.add(j, lockedOption) // add locked option to presenter
if lockedOption != o then
set i = i - 1
endif
set j = j + 1
elseif not o.getLocalHidden(pmenu.pid) and not .isLocked(o) then
call visibleOptions.add(j, o) // add default option to presenter
set j = j + 1
endif
set i = i + 1
endloop
// Adjust current page
set maxPages = getPages(j)
if page > maxPages or page < 0 then
set pmenu.pageIndex = 0
else
set pmenu.pageIndex = page
endif
// Adjust Options
set j = pmenu.pageIndex*11
set i = 0
loop
exitwhen i == 12
if j < visibleOptions.length or (lockedOptions[i] != 0) then
if j < visibleOptions.length then
set o = visibleOptions[j]
set j = j + 1
else
set o = lockedOptions[i]
endif
call applyOptionToSpell(pmenu, o, i)
call WatchSpellOption(pmenu.pid, i, o)
else
call BlzUnitHideAbility(pmenu.u, active[i], true)
call BlzUnitHideAbility(pmenu.u, passive[i], true)
//call SetPlayerAbilityAvailable(pmenu.p, active[i], false)
//call SetPlayerAbilityAvailable(pmenu.p, passive[i], false)
endif
set i = i + 1
endloop
// If there are more than 12 options in the menu than the last button will always be 'Next'
if visibleOptions.size() > 12 then
call BlzUnitHideAbility(pmenu.u, active[i], true)
call BlzUnitHideAbility(pmenu.u, passive[i], true)
call BlzUnitHideAbility(pmenu.u, A_NEXT, false)
//call SetPlayerAbilityAvailable(pmenu.p, active[11], false)
//call SetPlayerAbilityAvailable(pmenu.p, passive[11], false)
//call SetPlayerAbilityAvailable(pmenu.p, A_NEXT, true)
else
call BlzUnitHideAbility(pmenu.u, A_NEXT, true)
//call SetPlayerAbilityAvailable(pmenu.p, A_NEXT, false)
endif
call BlzSetUnitName(pmenu.u, .name + " " + I2S(pmenu.pageIndex + 1) + "/" + I2S(maxPages + 1))
if GetLocalPlayer() == pmenu.p then
call ClearSelection()
call SelectUnit(pmenu.u, true)
endif
endmethod
Here the spells have been coppied, there is for instance two paladins and I don't know what else is going on here...

Here icons have been carried over from a previous menu into the new one, even though they should have changed?
View attachment 315480
If I change it back it looks normal again:
View attachment 315484
This is all very strange as the syntax between SetPlayerAbilityAvailable and BlzUnitHideAbility is practically the same yet it leads to a completely different outcome.
Last edited: