• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

UnitRemoveAbility returning false

Status
Not open for further replies.
Level 14
Joined
Oct 18, 2013
Messages
724
Hi, I'm having trouble removing an ability from a unit. Can someone describe circumstances in which an alive unit cannot have an ability removed? Thanks.
 
Level 14
Joined
Oct 18, 2013
Messages
724
psuedo-code;
if abilityStacks == 0 then
if not(UnitRemoveAbility(u,id)) then
call echo("Can't remove ability?")
endif
endif

@Pwnica, the unit is alive and the ability won't be removed.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,896
What ability are you trying to remove?

Also, why even bother having this:
vJASS:
if not(UnitRemoveAbility(u,id)) then
call echo("Can't remove ability?")
endif

When you can just remove it the normal way:
vJASS:
call UnitRemoveAbility(u,id)
Trying to remove an ability that doesn't exist won't cause any issues as far as I know.

You can also check the Level of the ability. If it's 0 then the unit doesn't have the ability.
vJASS:
if (GetUnitAbilityLevel(u,id) != 0 then
call UnitRemoveAbility(u,id)
else
call echo
endif
And are you positive that it's even running in the first place? Is abilityStacks reaching 0?
 
Level 14
Joined
Oct 18, 2013
Messages
724
Im calling it as a condition to see what the function returns, and the echo displaying ingame demonstrating that the code DOES indeed run. The ability is a copy of tornado slow debuff iirc, the base ID= 'Aasl'. There is another instance in my map of a buff that *should* get removed but doesn't. I will have to double check on that one. I'll add code to see when the ability is added to see if thats the issue.

edit: Unless there is some other bit of code referencing this ability ID and adding the ability on a loop (which I 99% positive isn't the case), this ability is really just sticky to the unit. It's only added once in the bit I wrote to add the abil.
 
Last edited:
Level 14
Joined
Oct 18, 2013
Messages
724
all I know if you get 'false' means there are no ability on the unit

Interesting. I know you wrote a blog post about bugged IDs, Could you link that?

Anyways, I found the problem was a duplicate buff I had that I was incorrectly referencing when trying to debug the problem. Thanks guys!
 
Status
Not open for further replies.
Top