Merging 3 triggers into one

Charapanga

New Member
Reaction score
46
Hi!
I made a spell, with 3 triggers, then converted to jass, added some special effects, etc.
Well now i want to know how to make them fit into one trigger, if possible, i have been told to use countdown timers, but i have no idea how to impliment them into a code...
Here are the codes:
JASS:
function Trig_AirstrikeCast_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A01F' ) ) then
        return false
    endif
    return true
endfunction

function Trig_AirstrikeCast_Actions takes nothing returns nothing
    set udg_AirCaster = GetTriggerUnit()
    set udg_AirCasterPos = GetUnitLoc(udg_AirCaster)
    set udg_AirTargetPoint = GetSpellTargetLoc()
    set udg_AirDummyPos = PolarProjectionBJ(udg_AirTargetPoint, 1000.00, AngleBetweenPoints(udg_AirTargetPoint, udg_AirCasterPos))
    set udg_AirMoveTarget = PolarProjectionBJ(udg_AirTargetPoint, 1000.00, AngleBetweenPoints(udg_AirCasterPos, udg_AirTargetPoint))
    call CreateNUnitsAtLocFacingLocBJ( 1, 'o005', GetOwningPlayer(udg_AirCaster), udg_AirDummyPos, udg_AirMoveTarget )
    set udg_AirDummy = GetLastCreatedUnit()
    call MoveRectToLoc( gg_rct_AirstrikeRegion, udg_AirMoveTarget )
endfunction

//===========================================================================
function InitTrig_AirstrikeCast takes nothing returns nothing
    set gg_trg_AirstrikeCast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_AirstrikeCast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_AirstrikeCast, Condition( function Trig_AirstrikeCast_Conditions ) )
    call TriggerAddAction( gg_trg_AirstrikeCast, function Trig_AirstrikeCast_Actions )
endfunction

JASS:
function Trig_AirstrikeMove_Conditions takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(udg_AirDummy) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_AirstrikeMove_Func005C takes nothing returns boolean
    if ( not ( RectContainsUnit(gg_rct_AirstrikeRegion, udg_AirDummy) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_AirstrikeMove_Actions takes nothing returns nothing
    set udg_AirDummyPos = GetUnitLoc(udg_AirDummy)
    set udg_AirMovePoint = PolarProjectionBJ(udg_AirDummyPos, 5.00, AngleBetweenPoints(udg_AirTargetPoint, udg_AirMoveTarget))
    call SetUnitPositionLoc( udg_AirDummy, udg_AirMovePoint )
    if ( Trig_AirstrikeMove_Func005C() ) then
        call KillUnit( udg_AirDummy )
        call RemoveLocation(udg_AirCasterPos)
        call RemoveLocation(udg_AirMoveTarget)
        call RemoveLocation(udg_AirDummyPos)
        call RemoveLocation(udg_AirMovePoint)
        call RemoveLocation(udg_AirTargetPoint)
    else
    endif
endfunction

//===========================================================================
function InitTrig_AirstrikeMove takes nothing returns nothing
    set gg_trg_AirstrikeMove = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_AirstrikeMove, 0.02 )
    call TriggerAddCondition( gg_trg_AirstrikeMove, Condition( function Trig_AirstrikeMove_Conditions ) )
    call TriggerAddAction( gg_trg_AirstrikeMove, function Trig_AirstrikeMove_Actions )
endfunction

JASS:
function Trig_AirstrikeDropBomb_Conditions takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(udg_AirDummy) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_AirstrikeDropBomb_Func008Func001C takes nothing returns boolean
    if ( not ( GetDestructableTypeId(GetEnumDestructable()) == 'NTtw' ) ) then
        return false
    endif
    return true
endfunction

function Trig_AirstrikeDropBomb_Func008A takes nothing returns nothing
    if ( Trig_AirstrikeDropBomb_Func008Func001C() ) then
        call KillDestructable( GetEnumDestructable() )
    else
    endif
endfunction

function Trig_AirstrikeDropBomb_Actions takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, 'h00I', GetOwningPlayer(udg_AirCaster), udg_AirDummyPos, bj_UNIT_FACING )
    call UnitAddAbilityBJ( 'A01E', GetLastCreatedUnit() )
    call UnitApplyTimedLifeBJ( 1.00, 'BTLF', GetLastCreatedUnit() )
    call IssuePointOrderLoc( GetLastCreatedUnit(), "clusterrockets", udg_AirMovePoint )
    call AddSpecialEffectLocBJ( udg_AirMovePoint, "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl" )
    call DestroyEffect( GetLastCreatedEffectBJ() )
    call EnumDestructablesInCircleBJ( 200.00, udg_AirMovePoint, function Trig_AirstrikeDropBomb_Func008A )
endfunction

//===========================================================================
function InitTrig_AirstrikeDropBomb takes nothing returns nothing
    set gg_trg_AirstrikeDropBomb = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_AirstrikeDropBomb, 1.00 )
    call TriggerAddCondition( gg_trg_AirstrikeDropBomb, Condition( function Trig_AirstrikeDropBomb_Conditions ) )
    call TriggerAddAction( gg_trg_AirstrikeDropBomb, function Trig_AirstrikeDropBomb_Actions )
endfunction
Thanx,
Chara
 

Romek

Super Moderator
Reaction score
963
Here:
JASS:
function Trig_AirstrikeCast_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A01F' ) ) then
        return false
    endif
    return true
endfunction

function Trig_AirstrikeCast_Actions takes nothing returns nothing
    set udg_AirCaster = GetTriggerUnit()
    set udg_AirCasterPos = GetUnitLoc(udg_AirCaster)
    set udg_AirTargetPoint = GetSpellTargetLoc()
    set udg_AirDummyPos = PolarProjectionBJ(udg_AirTargetPoint, 1000.00, AngleBetweenPoints(udg_AirTargetPoint, udg_AirCasterPos))
    set udg_AirMoveTarget = PolarProjectionBJ(udg_AirTargetPoint, 1000.00, AngleBetweenPoints(udg_AirCasterPos, udg_AirTargetPoint))
    call CreateNUnitsAtLocFacingLocBJ( 1, 'o005', GetOwningPlayer(udg_AirCaster), udg_AirDummyPos, udg_AirMoveTarget )
    set udg_AirDummy = GetLastCreatedUnit()
    call MoveRectToLoc( gg_rct_AirstrikeRegion, udg_AirMoveTarget )
endfunction

function Trig_AirstrikeMove_Conditions takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(udg_AirDummy) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_AirstrikeMove_Func005C takes nothing returns boolean
    if ( not ( RectContainsUnit(gg_rct_AirstrikeRegion, udg_AirDummy) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_AirstrikeMove_Actions takes nothing returns nothing
    set udg_AirDummyPos = GetUnitLoc(udg_AirDummy)
    set udg_AirMovePoint = PolarProjectionBJ(udg_AirDummyPos, 5.00, AngleBetweenPoints(udg_AirTargetPoint, udg_AirMoveTarget))
    call SetUnitPositionLoc( udg_AirDummy, udg_AirMovePoint )
    if ( Trig_AirstrikeMove_Func005C() ) then
        call KillUnit( udg_AirDummy )
        call RemoveLocation(udg_AirCasterPos)
        call RemoveLocation(udg_AirMoveTarget)
        call RemoveLocation(udg_AirDummyPos)
        call RemoveLocation(udg_AirMovePoint)
        call RemoveLocation(udg_AirTargetPoint)
    else
    endif
endfunction

function Trig_AirstrikeDropBomb_Conditions takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(udg_AirDummy) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_AirstrikeDropBomb_Func008Func001C takes nothing returns boolean
    if ( not ( GetDestructableTypeId(GetEnumDestructable()) == 'NTtw' ) ) then
        return false
    endif
    return true
endfunction

function Trig_AirstrikeDropBomb_Func008A takes nothing returns nothing
    if ( Trig_AirstrikeDropBomb_Func008Func001C() ) then
        call KillDestructable( GetEnumDestructable() )
    else
    endif
endfunction

function Trig_AirstrikeDropBomb_Actions takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, 'h00I', GetOwningPlayer(udg_AirCaster), udg_AirDummyPos, bj_UNIT_FACING )
    call UnitAddAbilityBJ( 'A01E', GetLastCreatedUnit() )
    call UnitApplyTimedLifeBJ( 1.00, 'BTLF', GetLastCreatedUnit() )
    call IssuePointOrderLoc( GetLastCreatedUnit(), "clusterrockets", udg_AirMovePoint )
    call AddSpecialEffectLocBJ( udg_AirMovePoint, "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl" )
    call DestroyEffect( GetLastCreatedEffectBJ() )
    call EnumDestructablesInCircleBJ( 200.00, udg_AirMovePoint, function Trig_AirstrikeDropBomb_Func008A )
endfunction

//===========================================================================
//===========================================================================
function InitTrig_CombinedTrigger takes nothing returns nothing // Change the "CombinedTrigger" to the name of the trigger in the WE.
//===========================================================================
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEventPeriodic( t, 1.00 )
    call TriggerAddCondition( t, Condition( function Trig_AirstrikeDropBomb_Conditions ) )
    call TriggerAddAction( t, function Trig_AirstrikeDropBomb_Actions )
    
    set t = CreateTrigger()
    call TriggerRegisterTimerEventPeriodic( t, 0.02 )
    call TriggerAddCondition( t, Condition( function Trig_AirstrikeMove_Conditions ) )
    call TriggerAddAction( t, function Trig_AirstrikeMove_Actions )
    
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_AirstrikeCast_Conditions ) )
    call TriggerAddAction( t, function Trig_AirstrikeCast_Actions )
endfunction


Change the:
Code:
function InitTrig_>> CombinedTrigger << takes nothing returns nothing
To the name of the trigger in the WE. (I put loads of comments around the line :))

Alternatively, you could use initializers if you have Newgen.
 

Charapanga

New Member
Reaction score
46
Thanx romek!
I thought calling other functions would work, though wasnt sure about the multiple events...
 

Romek

Super Moderator
Reaction score
963
Thanx romek!
I thought calling other functions would work, though wasnt sure about the multiple events...
As long as you merge the Init functions, the rest will be fine. Just put the functions into 1 script. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top