• 🏆 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!

[JASS] Jass help - Trigger stops when using polledwait/TriggerSleepAction

Status
Not open for further replies.
Level 1
Joined
Jul 9, 2016
Messages
3
Hi, having had years of experience with GUI I've decided to finally learn to use JASS. Been using it for a few weeks now but ran into problems such as with the code below in which I want to make lightning spell. I can't figure out why after the PolledWait the trigger stops executing any actions and I've tried modifying different things but nothing seems to make it work. Could anyone help me out (I'm probably being very stupid).

Cheers,




JASS:
function Trig_Zap1_Actions takes nothing returns nothing      
    local unit shamzap
    local unit zaptar
    local effect z
    local lightning k          
        native AddSpecialEffectTarget       takes string modelName, widget targetWidget, string attachPointName returns effect
        native AddLightningEx               takes string codeName, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns lightning     

    set shamzap = GetTriggerUnit()
    set zaptar = GetSpellTargetUnit()  
    set z = AddSpecialEffectTarget ("units\\undead\\Abomination\\Abomination", zaptar, "origin")
    set k = AddLightningEx ( "CLPB" , false, GetUnitX (shamzap), GetUnitY (shamzap), 50, GetUnitX (zaptar), GetUnitY (zaptar), 50 )  
        call DisplayTextToForce(GetPlayersAll(), "Effects made, timer started 0.5 sec" )
        call PolledWait ( 0.5 )
        call DisplayTextToForce(GetPlayersAll(), "timer complete" )
        call DestroyEffect ( z )
        call DisplayTextToForce(GetPlayersAll(), "destroy effect")  
        call DestroyLightning ( k )
        call DisplayTextToForce(GetPlayersAll(), "destroy lightning")
            set z = null
            set k = null  
            set shamzap = null
            set zaptar= null
            call DisplayTextToForce(GetPlayersAll(), "Everything set to null")
           
endfunction                  
//=========================================================================== Conditions
                                                                         
function Trig_Zap1_Conditions takes nothing returns boolean
        if ( GetSpellAbilityId() == 'A000' ) then
            call Trig_Zap1_Actions()
        endif
        return false
endfunction



//=========================================================================== Events Below here
function InitTrig_Zap1 takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( t, Condition( function Trig_Zap1_Conditions))
set t = null
endfunction
 
Last edited:
Level 24
Joined
Jun 26, 2020
Messages
1,853
Why do you have this:

vJASS:
native AddSpecialEffectTarget       takes string modelName, widget targetWidget, string attachPointName returns effect
native AddLightningEx               takes string codeName, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns lightning
inside the function block?
Also, are you using JassHelper to do that? and it's not even necessary do that with those functions, only with those that are in the common.ai file.
 
Level 1
Joined
Jul 9, 2016
Messages
3
Yeah the lightning and effects are being created just not destroyed and the 'Effects made, timer started 0.5 sec' does print. I included the game messages just to help me debug it when testing. Ah I see I will remove the natives in that case, I think I included them after mis-interpreting some tutorials on it, cheers.
Still after the PolledWait the effects/lightning arent destroyed and none of the text is printed.
 
Status
Not open for further replies.
Top