HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Blizzard functions seeming to return useless booleans?

03-15-2004, 03:43 AM#1
Narwanza
Okay, take the call UnitRemoveAbility() command. This is quoted from common.j

Quote:
Originally Posted by common.j
Code:
native UnitAddAbility               takes unit whichUnit, integer abilityId returns boolean
native UnitRemoveAbility            takes unit whichUnit, integer abilityId returns boolean

I see no reason why they return booleans. I thought I might actually be able to create a UnitHasAbility() function becuase they might return false if they were unable to remove ability. It seems they always return false whether unit has ability or no. It can't be just useless, can it?
03-15-2004, 08:05 AM#2
Cubasis
Quote:
Originally Posted by Alpha Disjunction
Weadder used those functions in his DT4 engine. He used it to check if a unit has an ability. It is more efficient to just use the GetAbilityLevel function, since remove ability removes it and returns a boolean, so you have to add the ability back.

These booleans are a must, and most good programmers include them in functions that have alot of conditional exits (security). They are in most order-functions too, and basicly...return wether it was successful in doing what it was supposed to do. F.ex., it can't successfully remove a ability if the unit doesn't have it.

Before 1.13, that was our only way to see if a unit had a certain ability. Now we have another function to check that. I myself submitted a fool-proof "UnitHasAbility" function to the jass vault at the time that had a series of tests that would effectively return if the unit had the ability or not (without changing anything in the result).

Cubasis
03-15-2004, 03:16 PM#3
Vexorian
Every function that returns a boolean does that for a good reason, learn XXXX ability returns true if the hero could learn it, the order functions will return false if it was impossible to issue the order, and there are some other good examples
03-15-2004, 10:33 PM#4
Narwanza
Hmmm.... wtf. All of the test I did on it proved that if the unit did or didn't have it it would always return false. Must have been a bugged test. I dunno, maybe it doesn't work with heros if they have the ability to learn that ability later. I will run some more tests.

edit, oh and cubasis i don't see your function at the vault.

Now I feel stupid because I got it to work.
03-16-2004, 09:21 AM#5
Cubasis
Quote:
Originally Posted by Narwanza
edit, oh and cubasis i don't see your function at the vault.

Lol, that's becouse a week later when I wrote it....version 1.13 came by...with this function in-built, so there was no need in it anymore. So yeah, I removed the function.

There was some trouble with hero-skills, i don't really remember what I did to sense them. Anyhow

Cubasis