1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] Counting buffs

Discussion in 'World Editor Help Zone' started by Watcher, Mar 7, 2018.

  1. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    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: Mar 7, 2018
  2. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    • Set i = (Number of All buffs considered Magic or physical on (Triggering unit) (Include expiration timers, Include auras))

    You can find it under Integer, Unit - Count Buffs by type ...
     
  3. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    How about counting specific buffs?

    For example count Cripple and Curse, but not Slow, as all of them are negative buffs.
     
  4. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    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.
     
  5. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Big thanks m8!

    Thank you for clarification. :D

    +rep