• 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.

Directly adding a buff to a unit

Status
Not open for further replies.
Level 12
Joined
May 22, 2015
Messages
1,051
Is it possible?

At some point, I noticed that buffs are managed using the ability functions in JASS, so I was wondering if I could directly add a buff to a unit. It doesn't need to do anything, but if it shows the icon with the text and stuff, that would be super cool.

EDIT:
It would be like: call UnitAddAbility(myUnit, 'B007')
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
Not really.
You can make an ability based of Tornado Aura (Slow), set targets to self, invulnerable, vulnerable, AoE to 1 and give that one the buff.

You can then add the buff by adding the ability and removing the buff by removing both the ability AND the buff.
Be aware that you wont be able to dispell the buff as it will be returned to the unit almost immediately.

Also, normal dispells dont dispell an aura buff.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Not really.
You can make an ability based of Tornado Aura (Slow), set targets to self, invulnerable, vulnerable, AoE to 1 and give that one the buff.

You can then add the buff by adding the ability and removing the buff by removing both the ability AND the buff.
Be aware that you wont be able to dispell the buff as it will be returned to the unit almost immediately.

Also, normal dispells dont dispell an aura buff.

Ya I have done this for other things. Is it an issue if you have a lot of these auras? It just feels like it would have to calculate a lot of stuff to maintain auras - I worry that having a lot of these can cause some lag.
 
Level 12
Joined
May 22, 2015
Messages
1,051
I'll go with the tornado aura solution.

It is a buff so that the information is there for players to see. In my map, there are lots of mind control / zombify / vampirism / etc effects which take control of the regular units in the castle you help defend (you play a hero). Some special units have what I named "Corruption Protection" which just marks the unit for my triggers. Those triggers ignore units with that ability. I will just replace that ability with the tornado aura so it also displays a buff for players so that it isn't just some hidden knowledge you have to just know about to make optimal decisions (ex: purposely denying a strong unit when a vampire boss is coming). I think it would have just been cleaner to add the buff directly if it was possible and I was worried about spamming auras on many units.

Knowing that the tornado aura (and I guess auras in general) are quite safe to spam is good information. +rep to both of you.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Oh ya I remembered what bugged me a lot about the tornado aura. For some reason, when I add the ability to a unit, the unit deals 0 damage to itself and I have no idea why. Maybe it is a bug from some other trigger? It doesn't make sense though because you can't detect when an ability is added. I will maybe test it in a clean map.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
If you could see the source code of the game, you would realize that buffs and such are applied together with damage.
I found this when applying a normal stun on a unit when the DDS I used back then was spamming 0dmg attacks.

However, even though the unit is damaged, it shouldnt change anything in your game.
 
Level 12
Joined
May 22, 2015
Messages
1,051
If you could see the source code of the game, you would realize that buffs and such are applied together with damage.
I found this when applying a normal stun on a unit when the DDS I used back then was spamming 0dmg attacks.

However, even though the unit is damaged, it shouldnt change anything in your game.

Good to know! It doesn't cause problems, but it did worry me. I was worried that it would be spamming damage events for no reason or something. I would +rep, but already did recently lol. Thanks.
 
Level 7
Joined
Nov 19, 2015
Messages
283
I remember reading somewhere that Auras have a sticky duration so even after you remove the ability, the buff still remains. Would you have to remove the ability and then also remove the buff to fix this?

Also does the unit get the buff straight away or is there also a delay?
 
Level 12
Joined
May 22, 2015
Messages
1,051
Nah, for this instance, I want it to never be removed. Making it green text is a pretty important factor though.

I will have to manage removing these kinds of buffs separately. I'll probably just have a custom "remove buffs" function that also removes ones added by the tornado aura or buffs that don't even appear on the unit. A lot of them have effects that are not actually attached to the buff, so they have to be manually removed in the triggers.
 
Status
Not open for further replies.
Top