HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to get in Jass an Ability??

08-07-2006, 01:50 PM#1
moyack
Hi:

I have a channeling spell (based on Blizzard), and I'm adding an effect via JASS that only will endure while the ability is being cast.

My question is: is there any way to see if the ability is still being cast while the loop is running?? Is there a function like GetAbilityBeingCast???
08-07-2006, 01:54 PM#2
Rising_Dusk
Nope.
You will have to create a dynamic trigger when the channeling starts with the following events.

Collapse JASS:
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_ORDER)
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_POINT_ORDER)
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_TARGET_ORDER)
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_SPELL_FINISH)

Then you know that when the trigger runs, the spell was ended.
Therefore you can work with it from there.

The way you explain it, it appears that you will have a timer running and that you should attach the timer to this trigger I mentioned above.
Then when the trigger runs, get the timer from the trigger and disable/destroy it later.
08-07-2006, 02:00 PM#3
Wyvernoid
Quote:
Originally Posted by Rising_Dusk
call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_ORDER)
call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_POINT_ORDER)
call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_TARGET_ORDER)
Why not use "call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_SPELL_EFFECT)", 'think it better to use that.
08-07-2006, 02:03 PM#4
Rising_Dusk
Uhm..
Because that detects the casting of a spell.
We want to know when the spell is ENDED or the caster STOPS CASTING.
08-07-2006, 02:13 PM#5
moyack
Yes, there's a timer. I was thinking in something like that:

Collapse JASS:
...
set t = CreateTimer()
call TimerStart(t, I2R(Waves)*SpellDuration, false, null)
loop
     set SpellDuration = TimerGetRemaining(t)
     if not GetAbilityStillBeingCast('A000') then // <= I want to create a function like that
          set SpellDuration = 0.0
     endif 
     exitwhen SpellDuration <= 0.00 
     ....
endloop

I don't know if the function that detect which ability is being cast in the trigger works fine inside the action trigger.

Collapse JASS:
function Trig_MyTrigger_Starts_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
I'll test it right now, probably it works :)
08-07-2006, 02:22 PM#6
Rising_Dusk
Collapse JASS:
function Blah_EndTrigger takes nothing returns nothing
    local unit u = GetTriggerUnit()             //Useful in case you need to do something to them
    local trigger trg = GetTriggeringTrigger()
    local timer tm = GetHandleTimer(trg, "tm")
    
    call PauseTimer(tm)
    call DestroyTimer(tm)
    call TriggerRemoveAction(trg, GetHandleTriggerAction(trg, "ta"))
    call DisableTrigger(trg)
    //You can then destroy the trigger later or now depending if the DestroyTrigger bug appears for you.
    
    set trg = null
    set tm = null
endfunction

function Blah_TimerStuff takes nothing returns nothing
    //Do your stuff while they're casting here
endfunction

function Blah_1 takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()
    local timer tm = CreateTimer()
    local trigger trg = CreateTrigger()
    local triggeraction ta = TriggerAddAction(trg, function Blah_EndTrigger)
    
    call TimerStart(tm, 1.0, true, function Blah_TimerStuff)
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_ORDER)
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_POINT_ORDER)
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_TARGET_ORDER)
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_SPELL_FINISH)
    call SetHandleHandle(trg, "ta", ta)
    call SetHandleHandle(trg, "tm", tm)
    
    set trg = null
    set ta = null
    set tm = null
    set u = null
endfunction

There, I wrote a perfectly working example of the system I was talking about.
Your method likely won't be as maliable or workable as you'd like, I suggest this method as an alternative.
08-07-2006, 03:10 PM#7
blu_da_noob
Just check the unit's orderid, if it's still the orderid of the ability then he is still casting it (as long as the cooldown is longer than duration otherwise a couple of issues can potentitally occur depending on triggers).
08-07-2006, 03:32 PM#8
moyack
I've tested adding this code to the loop:
Collapse JASS:
loop
        set SpellDuration = TimerGetRemaining(t)
        if GetSpellAbilityId() != 'A000' then  // This code checks if the ability is still being casted
            set SpellDuration = 0.00            // if not, kills the loop
        endif
        exitwhen SpellDuration <= 0.00 
        //<my code>
    endloop

And it works fantastic :D

Thanks for your help guys :) +rep for everybody
08-09-2006, 01:17 AM#9
moyack
Quote:
Originally Posted by Rising_Dusk
Collapse JASS:
function Blah_EndTrigger takes nothing returns nothing
    local unit u = GetTriggerUnit()             //Useful in case you need to do something to them
    local trigger trg = GetTriggeringTrigger()
    local timer tm = GetHandleTimer(trg, "tm")
    
    call PauseTimer(tm)
    call DestroyTimer(tm)
    call TriggerRemoveAction(trg, GetHandleTriggerAction(trg, "ta"))
    call DisableTrigger(trg)
    //You can then destroy the trigger later or now depending if the DestroyTrigger bug appears for you.
    
    set trg = null
    set tm = null
endfunction

function Blah_TimerStuff takes nothing returns nothing
    //Do your stuff while they're casting here
endfunction

function Blah_1 takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()
    local timer tm = CreateTimer()
    local trigger trg = CreateTrigger()
    local triggeraction ta = TriggerAddAction(trg, function Blah_EndTrigger)
    
    call TimerStart(tm, 1.0, true, function Blah_TimerStuff)
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_ORDER)
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_POINT_ORDER)
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_ISSUED_TARGET_ORDER)
    call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_SPELL_FINISH)
    call SetHandleHandle(trg, "ta", ta)
    call SetHandleHandle(trg, "tm", tm)
    
    set trg = null
    set ta = null
    set tm = null
    set u = null
endfunction

There, I wrote a perfectly working example of the system I was talking about.
Your method likely won't be as maliable or workable as you'd like, I suggest this method as an alternative.
I was looking carefully this code and I saw those orders related with handlers, what is a handler?? what can I do with handlers?? is there an tutorial about this??
08-09-2006, 02:16 AM#10
Wyvernoid
Well it's like "Pointers"(*p) in C, which can stand for any object you can think of. You can look for further information on sourceforge.net.
08-09-2006, 04:49 AM#11
Alevice
Quote:
Originally Posted by moyack
I was looking carefully this code and I saw those orders related with handlers, what is a handler?? what can I do with handlers?? is there an tutorial about this??

Local var handles, not handlers ;P

The "system": http://www.wc3jass.com/viewtopic.php?t=224
Pseudo explanation: http://www.wc3jass.com/viewtopic.php...ighlight=#6802