• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Spell Advice Needed

Status
Not open for further replies.
Level 13
Joined
Nov 22, 2006
Messages
1,260
Note: this is for JASSers.

I have a hero that has 5 different spells. When I was testing them all at once, I noticed that some of the spells weren't working properly. First I was surprised, because there were all working when I tested them one by one. Then I was trying to find the problem when I realized what happened. Before that, I want to make sure that everyone knows how to create a channeling JASS spell: attach stuff to the caster, mostly timer(s), then in the trigger that fires if/when the caster stops channeling, get that stuff from the caster you previously attached and destroy timer(s) etc. But here is the problem: If I attach stuff to the caster in more than one spell, FlushHandleLocals(caster) from one spell would mess up the other one's attached stuff. Does anybody know how to fix this problem?
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Thanks.

Oh, and don't forget to destroy your triggeraction!

It's not what you think, it's like this:

JASS:
function InitTrig_Venom_Fury takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    set gg_trg_Venom_Fury = CreateTrigger()
    loop
        call TriggerRegisterPlayerUnitEvent(gg_trg_Venom_Fury, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition(gg_trg_Venom_Fury, Condition(function Trig_Venom_Fury_Conditions))
    call TriggerAddAction(gg_trg_Venom_Fury, function Trig_Venom_Fury_Actions)
    set i = 0
    loop
        call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_ENDCAST, null)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition(t, Condition(function VenomFury_StopConditions))
    call TriggerAddAction(t, function VenomFury_StopActions)
    set t = null
endfunction

So the trigger that stops the spell when stop channeling exists all the time.

Is it better to create a trigger, then destroy it each time? I'm saying that because this way, it's kinda hard/impossible to attach the stuff to that other (local) trigger. And don't worry about triggeractions/triggerconditions, I destroy them each time. (I had to add GetHandleTriggerAction/GetHandleTriggerCondition :p)
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
>_>, obvious script flaw on your part :p

JASS:
function InitTrig_Venom_Fury takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    set gg_trg_Venom_Fury = CreateTrigger()
    loop
        call TriggerRegisterPlayerUnitEvent(gg_trg_Venom_Fury, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_ENDCAST, null)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition(gg_trg_Venom_Fury, Condition(function Trig_Venom_Fury_Conditions))
    call TriggerAddAction(gg_trg_Venom_Fury, function Trig_Venom_Fury_Actions)
    call TriggerAddCondition(t, Condition(function VenomFury_StopConditions))
    call TriggerAddAction(t, function VenomFury_StopActions)
    set t = null
endfunction

Oh, and grab local triggers with GetTriggeringTrigger() if you plan on cleaning them within said trigger's actions.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
No, I meant flushing the trigger from said trigger's actions, nothing to do with triggeractions here :p

Silvenon said:
Is it better to create a trigger, then destroy it each time? I'm saying that because this way, it's kinda hard/impossible to attach the stuff to that other (local) trigger. And don't worry about triggeractions/triggerconditions, I destroy them each time. (I had to add GetHandleTriggerAction/GetHandleTriggerCondition :p)
Oh, sorry, you were complaining about the performance about that "global" trigger (right?) (aka the trigger used for all the spells). Well, it wouldn't matter anyways, since you'd run into your initial problem again with one overall trigger.
 
Status
Not open for further replies.
Top