• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

UnitRemoveAbility returning false

Status
Not open for further replies.
Level 13
Joined
Oct 18, 2013
Messages
694
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 13
Joined
Oct 18, 2013
Messages
694
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 64
Joined
Aug 10, 2018
Messages
6,584
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 13
Joined
Oct 18, 2013
Messages
694
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 13
Joined
Oct 18, 2013
Messages
694
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