simple trigger error

chukky-jr

Member
Reaction score
15
i have this trigger
JASS:
function Trig_Untitled_Trigger_001_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'AEim' ) and (GetOwningPlayer(GetSpellAbilityUnit())==Player(0))
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    call ConditionalTriggerExecute( gg_trg_Untitled_Trigger_002 )
endfunction

function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
local unit u
local unit u2 
local location y
    set u2 = GetSpellAbilityUnit()
    set y = GetUnitLoc(u2)
    set u = CreateUnitAtLoc(GetOwningPlayer(u2), 'h000',y, bj_UNIT_FACING )
    call UnitAddAbility(u,'A000')
    call IssueImmediateOrder(u,"fanofknives")
    call UnitApplyTimedLife(u,'BTLF',5.00)
    set u = null
    set u2 = null
    set y = null
    call RemoveLocation(y)
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_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Untitled_Trigger_001, Condition( function Trig_Untitled_Trigger_001_Conditions ) )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction

function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_002 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Untitled_Trigger_002, 1.0)
    call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction


well basically whenever a hero cast immolation, a dummy unit will be created in his position every 1 second, but this trigger returns undefined gg_trg_Untitled_Trigger_002 when saving, how do you make 1 trigger in JASS script that usually needs to be 2 in GUI? (in GUI i think this needs 2, unit cast spell, then that triggers runs another periodic trigger)
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
I suggest you to read the jass tutorials here.
You can start from the "Introduction to JASS " one.

JASS:
function spell_name_actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit dummy  = null
    
    loop
         exitwhen <condition to stop creating dummy units>

         set dummy = CreateUnit(GetOwningPlayer(caster), 'h000', GetUnitX(caster), GetUnitY(caster), bj_UNIT_FACING)
         call UnitAddAbility(dummy,'A000')
         call IssueImmediateOrder(dummy, "fanofknives")
         call UnitApplyTimedLife(dummy, 'BTLF', 5.00)

         call TriggerSleepAction(1) // wait one second and create the next dummy unit
    endloop
    

    set dummy  = null
    set caster = null
endfunction

function spell_name_conditions takes nothing returns boolean
    return GetSpellAbilityId(() == 'AEim' and GetOwningPlayer(GetTriggerUnit()) == Player(0)
endfunction

//===========================================================================
function InitTrig_spell_name takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function spell_name_condition))
    call TriggerAddAction(t, function spell_name_actions)
endfunction
 

chukky-jr

Member
Reaction score
15
JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit dummy  = null
    local boolean cond = GetIssuedOrderIdBJ() == String2OrderIdBJ("unimmolation")
    loop
        exitwhen cond == true
         set dummy = CreateUnit(GetOwningPlayer(caster), 'h000', GetUnitX(caster), GetUnitY(caster), bj_UNIT_FACING)
         call UnitAddAbility(dummy,'A000')
         call IssueImmediateOrder(dummy, "fanofknives")
         call UnitApplyTimedLife(dummy, 'BTLF', 5.00)
         call TriggerSleepAction(1) // wait one second and create the next dummy unit
    endloop
    set dummy  = null
    set caster = null
endfunction

function Trig_Untitled_Trigger_001_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == 'AEim' ) and (GetOwningPlayer(GetTriggerUnit())==Player(0))
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Trig_Untitled_Trigger_001_Conditions))
    call TriggerAddAction(t, function Trig_Untitled_Trigger_001_Actions)
endfunction


i use that as condition to end loop, but turning off immolation doesn't stop the dummy from spawning, does the condition wrong?
 

Dirac

22710180
Reaction score
147
Yes because you only set that variable before the loop, the warcraft doesn't keep track of variables once they change, you have to constantly update it. Example
JASS:
local boolean cond = GetIssuedOrderIdBJ() == String2OrderIdBJ("unimmolation") // -> cond = false
exitwhen cond == true // cond is equal to false, it will never end


Also, you're using waits inside loops. Your whole trigger is extremely broken.
Read the tutorial Sqgvur provided
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
chukky-jr:
1. i use that as condition to end loop, but turning off immolation doesn't stop the dummy from spawning, does the condition wrong?

1. That's because the event was EVENT_PLAYER_UNIT_SPELL_EFFECT and in that event there is no response "GetIssuedOrderIdBJ".


Try this but first declare a global array of type boolean with the name immolation_is_on (the size doesn't matter):
JASS:
function immolation_action takes nothing returns nothing
    local unit    caster = GetTriggerUnit()
    local unit    dummy  = null
    local integer p      = GetPlayerId(GetOwningPlayer(caster))
    
    loop
         exitwhen not udg_immolation_is_on[p]

         set dummy = CreateUnit(GetOwningPlayer(caster), 'h000', GetUnitX(caster), GetUnitY(caster), bj_UNIT_FACING)
         call UnitAddAbility(dummy,'A000')
         call IssueImmediateOrder(dummy, "fanofknives")
         call UnitApplyTimedLife(dummy, 'BTLF', 5.00)
         
         call TriggerSleepAction(1) // wait one second and create the next dummy unit
    endloop

    set dummy  = null
    set caster = null
endfunction

function immolation_condition takes nothing returns nothing
    local integer order_immolation_turn_on  = 852177
    local integer order_immolation_turn_off = 852178
    
    if GetIssuedOrderId() == order_immolation_turn_on then
        set udg_immolation_is_on[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = true
        call immolation_action()
    elseif GetIssuedOrderId() == order_immolation_turn_off then
        set udg_immolation_is_on[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = false
    endif

endfunction

//===========================================================================
function InitTrig_imolation takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
    call TriggerAddAction(t, function immolation_condition)
endfunction
 

Dirac

22710180
Reaction score
147
exitwhen only takes integer as condition?
[ljass]exitwhen[/ljass] takes anything as a condition, remember that in JASS a boolean can be expressed as [ljass]1==1[/ljass] which in that case returns true.
JASS:
local integer i=0
loop
    exitwhen (i==4)
    set i=i+1
endloop
Please follow Sgqvur's example and post your code
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top