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

Catching a deactivate ability action event

Status
Not open for further replies.
Level 6
Joined
Mar 20, 2008
Messages
208
Bascially, I can't seem to figure out how to catch an ability deactivation event

The current ability is mana shield. (Immolation would be a second example)


I can get the event when it is turned on by using EVENT_PLAYER_UNIT_SPELL_EFFECT

But I can't seem to get the reverse event.

This is the code, incase anyone has a suggestion to do it another way.

JASS:
function HBC takes nothing returns boolean
    return GetSpellAbilityId() == 'A012'
endfunction

function HBA takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()    
    local integer v = GetHeroLevel(u) 
    local integer h = 2*v                   //health counter
    local integer m = 1*v                  //mana counter
    
    loop
        exitwhen  GetUnitUserData(u) == 0  
//Custom data set, a deactivation trigger catching the deactivation would set
// to another number
        call TriggerSleepAction(1)
        call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE)-h)    
        call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA)+m)    
    endloop
//First one subtracts health
//Second one adds mana



    set u = null
endfunction

I've also tried a faster approach, but for the life of me can't seem to figure out what the hell blizzard means by "buff".

JASS:
function HBC takes nothing returns boolean
    return GetSpellAbilityId() == 'A012'
endfunction

function HBA takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()    
    local integer v = GetHeroLevel(u) 
    local integer h = 2*v                   //health counter
    local integer m = 1*v                  //mana counter
    
    loop
        exitwhen  UnitHasBuffBJ(u, 'B007')  
//'B007' Given to me by the world editor for my custom buff effect
//(GetUnitAbilityLevel(u, 'B007') > 0) which is essentially the Junction did not
//work either

        call TriggerSleepAction(1)
        call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE)-h)    
        call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA)+m)    
    endloop
//First one subtracts health
//Second one adds mana

    set u = null
endfunction

So I'm pretty much asking for some way to catch a deactivation event, or atleast figure out if my "buffcode" input is being used correctly.
 
Level 6
Joined
Mar 20, 2008
Messages
208
I'm also open to suggestions on other methods to get this to work

Its simply an on/off ability that converts health to mana =/
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Unit is issued an instant order(with no target).

Order is equal to manashieldoff or whatever the deactivate order string of your ability is.
 
Level 6
Joined
Mar 20, 2008
Messages
208
It works, thanks

Heres the code if anyone cares

JASS:
function HBC takes nothing returns boolean
    return 'Hkal' == GetUnitTypeId(GetOrderedUnit())
endfunction

function HBA takes nothing returns nothing
    local integer o = OrderId("manashieldon")
    local unit u = GetOrderedUnit()    
    local integer v = GetHeroLevel(u) 
    local integer h = 2*v
     
    if ( GetIssuedOrderId() == o ) then
        call SetUnitUserData(u,1)
        loop
          exitwhen  GetUnitUserData(u) == 0
          call TriggerSleepAction(1)
          call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE)-h)    
          call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA)+v)    
        endloop        
    else
        call SetUnitUserData(u,0)
    endif 
    set u = null          
endfunction

//===========================================================================
function InitTrig_Pyromancer_HeatedBlood takes nothing returns nothing
    set gg_trg_Pyromancer_HeatedBlood = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Pyromancer_HeatedBlood, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( gg_trg_Pyromancer_HeatedBlood, Condition( function HBC ) )
    call TriggerAddAction( gg_trg_Pyromancer_HeatedBlood, function HBA )
endfunction
 
Status
Not open for further replies.
Top