| 04-10-2007, 04:30 AM | #1 | |
I'm making a spell trigger using an ability based on Channel, and I have all of the visual effects and damage working, but I haven't been able to do another thing I want. The spell is supposed to channel (as in, when you stop casting the spell will stop), but none of the things I've tried have resulted in the spell ceasing when the casting unit stops channeling. The code of the spell's trigger is this:
I've tried things such as checking each round to see if the casting unit is == null, but that didn't work (the results of a test I tried seemed to show that GetSpellAbilityUnit() always returns the same unit in the same trigger). Anyway, I'd like your help in devising some method to cancel the spell when the unit stops channeling the ability. I did look at some other spells listed on these forums that did this, but I couldn't figure out from reading them how they accomplished it. I already know how to stop and cancel the spell; what I need help with is how to detect if the unit is still channeling the Blizzard spell. |
| 04-10-2007, 04:40 AM | #2 |
without looking too deeply, the first thing that comes to mind is timers. 90% of my triggered channel spells use timers, and if I need an immediate stop I destroy the timer/s right then. |
| 04-11-2007, 12:28 AM | #3 |
Ah, perhaps I wasn't being clear enough. I do use timers for the effects of the spell. All I really need is a way to check if the unit is still channeling. I'll edit the first post to reflect this more. EDIT: I'd like to change the thread title to "Detect if a unit is channeling a certain spell." |
| 04-11-2007, 12:44 AM | #4 |
Set up your channel ability so it gives the casting unit a buff while channeling. Check if the unit has the buff before doing actions. |
| 04-11-2007, 12:49 AM | #5 |
You can edit a thread title. Second, you can check a unit's current order. Each spell/order has a specific OrderId, which you can find out by doing something like this: JASS:function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing call BJDebugMsg(I2S(GetIssuedOrderId())) endfunction //=========================================================================== function InitTrig_Untitled_Trigger_001 takes nothing returns nothing set gg_trg_Untitled_Trigger_001 = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_ISSUED_ORDER ) call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions ) endfunction You could also detect the end of a spellcast. EVENT_PLAYER_UNIT_SPELL_ENDCAST detects when a unit finishes casting the spell via the full length of the channel being done. EVENT_PLAYER_UNIT_SPELL_FINISH detects when a unit stops casting/channeling for any reason, be it stun, moving, etc. |
| 04-11-2007, 12:52 AM | #6 |
I would try something like that: JASS:local trigger t=CreateTrigger() call TriggerRegisterUnitEvent(t,GetTriggerUnit(),EVENT_UNIT_DEATH) //When Unit Dead= no channeling anymore ^^ call TriggerRegisterUnitEvent(t,GetTriggerUnit(),EVENT_UNIT_SPELL_ENDCAST) call TriggerRegisterPlayerUnitEventSimple(t,GetOwningPlayer(GetTriggerUnit()),EVENT_PLAYER_UNIT_SPELL_FINISH) call TriggerAddAction(t,function YourFunctionToStoptheSpell) //im to tired right now to really look at your function ...think of something for here for yourself |
| 04-11-2007, 01:32 AM | #7 |
Well, I've got it working the way I want it. I added these lines of code: JASS:local string t_table = I2S(CS_H2I( t )) local integer uO = GetUnitCurrentOrder( u ) local integer a1 JASS:set a1 = a1 + 1 if GetUnitCurrentOrder( u ) != uO then set a1 = a2 + 1 endif endloop One possible problem I thought of was that if they somehow managed to cast the spell again in a different location then it would allow them to cast both, but a sufficient cooldown period would easily prevent that. However, if it does become a problem, then I will use akolyt0r's suggestion. |
