BlzUnitDisableAbility

Parameters
whichUnit unit

Unit to apply this to.

abilId integer

Rawcode of ability.

flag boolean

isDisabled: true to disable (cannot click), false to enable ability.

hideUI boolean

isHidden: true to completely hide the icon, false to show icon. Icons are different for disabled/enabled abilities.

comment

Enables/disables and hides/unhides an ability for a unit. A visible disabled ability is shown as deactivated, an invisible ability disappears from the grid.

Example (Lua):

-- assume u is Human Peasant, AHbu is ability for Human building.
-- keep enabled, but hide icon
BlzUnitDisableAbility(u, FourCC"AHbu", false, true)
bug

(1.32.10 confirmed) The game counts isDisabled and hideUI internally as integers(?) If you called 5 times "hideUI = true" to hide an icon then you'll need to multiple times "hideUI = false" to show it again. I do not exactly understand how it's counted. https://www.hiveworkshop.com/threads/blzunithideability-and-blzunitdisableability-dont-work.312477/

note

All different building ability codes like 'AHbu', 'ANbu' are considered equivalent. For example, disabling 'AHbu' on a unit with only 'ANbu' would disable 'ANbu' instead. See GetUnitAbilityLevel.

patch

1.29.2.9231

Source
common.j
return type
nothing
Source code
native BlzUnitDisableAbility                       takes unit whichUnit, integer abilId, boolean flag, boolean hideUI returns nothing