• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Solved] Counting buffs

Status
Not open for further replies.
Level 4
Joined
Aug 31, 2011
Messages
88
Hi guys,

Can I somehow count how many buffs has a unit?

I know that I can check if unit has a specific buff, but can I somehow count them?

Can I count them by checking which buff it has and then setting the variable count to 1 or is there some easier workaround?
 
Last edited:
How about counting specific buffs?

For example count Cripple and Curse, but not Slow, as all of them are negative buffs.
 
The game cannot distinguish Cripple and Curse from Slow, because as you said, they are all negative.
Because of that, you will have to manully tell the game which buff needs to be counted, so you will count them manually.

If you wanted to count only Cripple and Curse, you would use:
set count = 0
if unit has buff cripple then
set count = count + 1
if unit has buff curse then
set count = count + 1

If you want to count all buffs except slow, you would use:
set count = 0
if unit has buff slow then
set count = count - 1

set count = count + CountAllBuffs


If the list is longer, it makes sense to use a loop and an array.
 
Status
Not open for further replies.
Back
Top