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

Is there a script that hook UnitAddAbility to some form of event?

I think the title gives it away. To be clear, I want to create an aura system which detects all forms of ability addition (SkillLearn, EnterMap, and UnitAddAbility). The first is accessible, the second can be done with Indexers/Events, but the last one is still on my confusion... Is there a way to know when a specific ability is being added to a unit via trigger and detect it as an event?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
You can hook in vJASS:
JASS:
function FuncA takes nothing returns nothing
  call BJDebugMsg("A")
endfunction

function FuncB takes nothing returns nothing
  call BJDebugMsg("B")
endfunction

hook FuncA FuncB //B is hooked when A is called
//...
call FuncA() //The output is B,A not A,B
It has limitations: the secondary function occurs before the function that was hooked into (so the unit wouldn't have the ability yet), cannot access return values of the function (though it can access arguments), and (I have been told) functions through a TriggerEvaluate call which is overall not preferable. Some of these may be issues for you.

Lua has much more versatile hooks that don't have the same limitations. I am not familiar with them.
 
Last edited:

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,112
As far as I know, not, but you could simply create global variable that tracks this and can then refer to this variable in events or other triggers. Similarly how you can refer to "Last Created Unit" or "Last Created Special Effect". In case you are using LUA, you could simply embed this into the UnitAddAbility() function itself.
 
Top