• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] efficiency for a minigame

Status
Not open for further replies.
hello im making a minigame for my map it basically creates a horizontal and vertical line of lightning blue is safe red kills u now i have it works good just want to see if it can be more efficient also after a period of time if the players do not lose it makes more up to a total of 3 each going at different times umm here r the triggers now tht i listed the basics and thx to anyone tht helps

JASS:
globals 
    integer Random_Plus_Sign_Counter = 0
endglobals

function Trig_Plus_Sign_Random_1_Actions takes nothing returns nothing
    local rect randomloc1 = (gg_rct_Random_1_for_cross_random)
    local rect randomloc2 = (gg_rct_Random_2_for_cross_random)
    local real cross_center_y = GetRandomReal(GetRectMinY(randomloc1), GetRectMaxY(randomloc1)) // use for center
    local real cross_center_x = GetRandomReal(GetRectMinX(randomloc2), GetRectMaxX(randomloc2)) // use for center
    local real array cross1_rx
    local real array cross1_ry
    local lightning array LightningEffect
    set cross1_rx[0] = GetRandomReal(GetRectMinX(randomloc1), GetRectMaxX(randomloc1)) //used for gg_rct_Random_1a_for_cross_random
    set cross1_ry[0] = GetRandomReal(GetRectMinY(randomloc2), GetRectMaxY(randomloc2)) //used for gg_rct_Random_1a_for_cross_random
    call MoveRectTo( gg_rct_Random_1a_for_cross_random, cross1_rx[0], cross_center_y )
    call MoveRectTo( gg_rct_Random_1a_for_cross_random, cross_center_x, cross1_ry[0] )
    //  
    // offset units facing 0 degrees
    //  
    set cross1_rx[1] = cross1_rx[0] + 987.50 // east x value
    set cross1_rx[2] = cross1_rx[0] + 493.75 // east x value
    //  
    // offset units facing 180 degrees
    //  
    set cross1_rx[3] = cross1_rx[0] - 987.50 // west x value
    set cross1_rx[4] = cross1_rx[0] - 493.75 // west x value 
    //  
    // offset units facing 90 degrees
    //  
    set cross1_ry[1] = cross1_ry[0] + 987.50 // north y value
    set cross1_ry[2] = cross1_ry[0] + 493.75 // north y value
    //  
    // offset units facing 270 degrees
    //  
    set cross1_ry[3] = cross1_ry[0] - 987.50 // south y value
    set cross1_ry[4] = cross1_ry[0] - 493.75 // south y value
    //  
    // units at center
    //  
    // Making Units move to the random point selected w offseting specified above
    //  
    // unit offset moving units = 180 degrees
    //  
    call SetUnitPosition( LightningUnit[1], cross1_rx[3], cross_center_y )
    call IssuePointOrder( LightningUnit[1], "patrol", cross1_rx[4], cross_center_y )
    //  
    call SetUnitPosition( LightningUnit[2], cross1_rx[4], cross_center_y )
    call IssuePointOrder( LightningUnit[2], "patrol", cross1_rx[0], cross_center_y )
    //  
    // unit offset moving units = 0 degrees
    //  
    call SetUnitPosition( LightningUnit[3], cross1_rx[1], cross_center_y )
    call IssuePointOrder( LightningUnit[3], "patrol", cross1_rx[2], cross_center_y )
    //  
    call SetUnitPosition( LightningUnit[4], cross1_rx[2], cross_center_y )
    call IssuePointOrder( LightningUnit[4], "patrol", cross1_rx[0], cross_center_y )
    //  
    // unit offset moving units = 270 degrees
    //  
    call SetUnitPosition( LightningUnit[5], cross_center_x, cross1_ry[3] )
    call IssuePointOrder( LightningUnit[5], "patrol", cross_center_x, cross1_ry[4] )
    //  
    call SetUnitPosition( LightningUnit[6], cross_center_x, cross1_ry[4] )
    call IssuePointOrder( LightningUnit[6], "patrol", cross_center_x, cross1_ry[0] )
    //  
    // unit offset moving units = 90 degrees
    //  
    call SetUnitPosition( LightningUnit[7], cross_center_x, cross1_ry[1] )
    call IssuePointOrder( LightningUnit[7], "patrol", cross_center_x, cross1_ry[2] )
    //  
    call SetUnitPosition( LightningUnit[8], cross_center_x, cross1_ry[2] )
    call IssuePointOrder( LightningUnit[8], "patrol", cross_center_x, cross1_ry[0] )
    //  
    // starting lightning effects
    //  
    set LightningEffect[0] = AddLightning( "CLPB", true, cross1_rx[1], cross_center_y, cross1_rx[3], cross_center_y )
    set LightningEffect[1] = AddLightning( "CLPB", true, cross_center_x, cross1_ry[1], cross_center_x, cross1_ry[3] )
    call PolledWait( 3.00 )
    set udg_Lightning_Kill_Units_Boolean[1] = true
    call DestroyLightning( LightningEffect[0] )
    call DestroyLightning( LightningEffect[1] )
    set LightningEffect[0] = AddLightning("AFOD", true, cross1_rx[1], cross_center_y, cross1_rx[3], cross_center_y )
    set LightningEffect[1] = AddLightning("AFOD", true, cross_center_x, cross1_ry[1], cross_center_x, cross1_ry[3] )
    call PolledWait( 2.50 )
    set udg_Lightning_Kill_Units_Boolean[1] = false
    call DestroyLightning( LightningEffect[0] )
    call DestroyLightning( LightningEffect[1] )
    set Random_Plus_Sign_Counter = Random_Plus_Sign_Counter + 1
    if ( Random_Plus_Sign_Counter == 5 ) then
        call EnableTrigger( gg_trg_Plus_Sign_Random_2 )
    elseif ( Random_Plus_Sign_Counter == 10 ) then
        call EnableTrigger( gg_trg_Plus_Sign_Random_3 )
    endif
endfunction

//===========================================================================
function InitTrig_Plus_Sign_Random_1 takes nothing returns nothing
    set gg_trg_Plus_Sign_Random_1 = CreateTrigger(  )
    call DisableTrigger( gg_trg_Plus_Sign_Random_1 )
    call TriggerRegisterTimerEvent( gg_trg_Plus_Sign_Random_1, 6.00, true )
    call TriggerAddAction( gg_trg_Plus_Sign_Random_1, function Trig_Plus_Sign_Random_1_Actions )
endfunction
JASS:
function Trig_Plus_Sign_Random_2_Actions takes nothing returns nothing
    local rect randomloc1 = (gg_rct_Random_1_for_cross_random)
    local rect randomloc2 = (gg_rct_Random_2_for_cross_random)
    local real cross_center_y = GetRandomReal(GetRectMinY(randomloc1), GetRectMaxY(randomloc1)) // use for center
    local real cross_center_x = GetRandomReal(GetRectMinX(randomloc2), GetRectMaxX(randomloc2)) // use for center
    local real array cross1_rx
    local real array cross1_ry
    local lightning array LightningEffect
    set cross1_rx[0] = GetRandomReal(GetRectMinX(randomloc1), GetRectMaxX(randomloc1)) //used for gg_rct_Random_1a_for_cross_random
    set cross1_ry[0] = GetRandomReal(GetRectMinY(randomloc2), GetRectMaxY(randomloc2)) //used for gg_rct_Random_1a_for_cross_random
    call MoveRectTo( gg_rct_Random_1a_for_cross_random, cross1_rx[0], cross_center_y )
    call MoveRectTo( gg_rct_Random_1a_for_cross_random, cross_center_x, cross1_ry[0] )
    //  
    // offset units facing 0 degrees
    //  
    set cross1_rx[1] = cross1_rx[0] + 987.50 // east x value
    set cross1_rx[2] = cross1_rx[0] + 493.75 // east x value
    //  
    // offset units facing 180 degrees
    //  
    set cross1_rx[3] = cross1_rx[0] - 987.50 // west x value
    set cross1_rx[4] = cross1_rx[0] - 493.75 // west x value 
    //  
    // offset units facing 90 degrees
    //  
    set cross1_ry[1] = cross1_ry[0] + 987.50 // north y value
    set cross1_ry[2] = cross1_ry[0] + 493.75 // north y value
    //  
    // offset units facing 270 degrees
    //  
    set cross1_ry[3] = cross1_ry[0] - 987.50 // south y value
    set cross1_ry[4] = cross1_ry[0] - 493.75 // south y value
    //  
    // units at center
    //  
    // Making Units move to the random point selected w offseting specified above

    // unit offset moving units = 180 degrees
    //  
    call SetUnitPosition( LightningUnit[9], cross1_rx[3], cross_center_y )
    call IssuePointOrder( LightningUnit[9], "patrol", cross1_rx[4], cross_center_y )
    //  
    call SetUnitPosition( LightningUnit[10], cross1_rx[4], cross_center_y )
    call IssuePointOrder( LightningUnit[10], "patrol", cross1_rx[0], cross_center_y )
    //
    // unit offset moving units = 0 degrees
    //  
    call SetUnitPosition( LightningUnit[11], cross1_rx[1], cross_center_y )
    call IssuePointOrder( LightningUnit[11], "patrol", cross1_rx[2], cross_center_y )
    //  
    call SetUnitPosition( LightningUnit[12], cross1_rx[2], cross_center_y )
    call IssuePointOrder( LightningUnit[12], "patrol", cross1_rx[0], cross_center_y )
    //  
    // unit offset moving units = 270 degrees
    //  
    call SetUnitPosition( LightningUnit[13], cross_center_x, cross1_ry[3] )
    call IssuePointOrder( LightningUnit[13], "patrol", cross_center_x, cross1_ry[4] )
    //  
    call SetUnitPosition( LightningUnit[14], cross_center_x, cross1_ry[4] )
    call IssuePointOrder( LightningUnit[14], "patrol", cross_center_x, cross1_ry[0] )
    //  
    // unit offset moving units = 90 degrees
    //  
    call SetUnitPosition( LightningUnit[15], cross_center_x, cross1_ry[1] )
    call IssuePointOrder( LightningUnit[15], "patrol", cross_center_x, cross1_ry[2] )
    //  
    call SetUnitPosition( LightningUnit[16], cross_center_x, cross1_ry[2] )
    call IssuePointOrder( LightningUnit[16], "patrol", cross_center_x, cross1_ry[0] )
    //  
    // starting lightning effects
    //  
    set LightningEffect[0] = AddLightning( "CLPB", true, cross1_rx[1], cross_center_y, cross1_rx[3], cross_center_y )
    set LightningEffect[1] = AddLightning( "CLPB", true, cross_center_x, cross1_ry[1], cross_center_x, cross1_ry[3] )
    call PolledWait( 2.75 )
    set udg_Lightning_Kill_Units_Boolean[1] = true
    call DestroyLightning( LightningEffect[0] )
    call DestroyLightning( LightningEffect[1] )
    set LightningEffect[0] = AddLightning("AFOD", true, cross1_rx[1], cross_center_y, cross1_rx[3], cross_center_y )
    set LightningEffect[1] = AddLightning("AFOD", true, cross_center_x, cross1_ry[1], cross_center_x, cross1_ry[3] )
    call PolledWait( 2.25 )
    set udg_Lightning_Kill_Units_Boolean[1] = false
    call DestroyLightning( LightningEffect[0] )
    call DestroyLightning( LightningEffect[1] )
endfunction

//===========================================================================
function InitTrig_Plus_Sign_Random_2 takes nothing returns nothing
    set gg_trg_Plus_Sign_Random_2 = CreateTrigger(  )
    call DisableTrigger( gg_trg_Plus_Sign_Random_2 )
    call TriggerRegisterTimerEvent( gg_trg_Plus_Sign_Random_2, 5.50, true )
    call TriggerAddAction( gg_trg_Plus_Sign_Random_2, function Trig_Plus_Sign_Random_2_Actions )
endfunction
JASS:
function Trig_Plus_Sign_Random_3_Actions takes nothing returns nothing
    local rect randomloc1 = (gg_rct_Random_1_for_cross_random)
    local rect randomloc2 = (gg_rct_Random_2_for_cross_random)
    local real cross_center_y = GetRandomReal(GetRectMinY(randomloc1), GetRectMaxY(randomloc1)) // use for center
    local real cross_center_x = GetRandomReal(GetRectMinX(randomloc2), GetRectMaxX(randomloc2)) // use for center
    local real array cross1_rx
    local real array cross1_ry
    local lightning array LightningEffect
    set cross1_rx[0] = GetRandomReal(GetRectMinX(randomloc1), GetRectMaxX(randomloc1)) //used for gg_rct_Random_1a_for_cross_random
    set cross1_ry[0] = GetRandomReal(GetRectMinY(randomloc2), GetRectMaxY(randomloc2)) //used for gg_rct_Random_1a_for_cross_random
    call MoveRectTo( gg_rct_Random_1a_for_cross_random, cross1_rx[0], cross_center_y )
    call MoveRectTo( gg_rct_Random_1a_for_cross_random, cross_center_x, cross1_ry[0] )
    //  
    // offset units facing 0 degrees
    //  
    set cross1_rx[1] = cross1_rx[0] + 987.50 // east x value
    set cross1_rx[2] = cross1_rx[0] + 493.75 // east x value
    //  
    // offset units facing 180 degrees
    //  
    set cross1_rx[3] = cross1_rx[0] - 987.50 // west x value
    set cross1_rx[4] = cross1_rx[0] - 493.75 // west x value 
    //  
    // offset units facing 90 degrees
    //  
    set cross1_ry[1] = cross1_ry[0] + 987.50 // north y value
    set cross1_ry[2] = cross1_ry[0] + 493.75 // north y value
    //  
    // offset units facing 270 degrees
    //  
    set cross1_ry[3] = cross1_ry[0] - 987.50 // south y value
    set cross1_ry[4] = cross1_ry[0] - 493.75 // south y value
    //  
    // units at center
    //  
    // Making Units move to the random point selected w offseting specified above

    // unit offset moving units = 180 degrees
    //  
    call SetUnitPosition( LightningUnit[17], cross1_rx[3], cross_center_y )
    call IssuePointOrder( LightningUnit[17], "patrol", cross1_rx[4], cross_center_y )
    //  
    call SetUnitPosition( LightningUnit[18], cross1_rx[4], cross_center_y )
    call IssuePointOrder( LightningUnit[18], "patrol", cross1_rx[0], cross_center_y )
    //
    // unit offset moving units = 0 degrees
    //  
    call SetUnitPosition( LightningUnit[19], cross1_rx[1], cross_center_y )
    call IssuePointOrder( LightningUnit[19], "patrol", cross1_rx[2], cross_center_y )
    //  
    call SetUnitPosition( LightningUnit[20], cross1_rx[2], cross_center_y )
    call IssuePointOrder( LightningUnit[20], "patrol", cross1_rx[0], cross_center_y )
    //  
    // unit offset moving units = 270 degrees
    //  
    call SetUnitPosition( LightningUnit[21], cross_center_x, cross1_ry[3] )
    call IssuePointOrder( LightningUnit[21], "patrol", cross_center_x, cross1_ry[4] )
    //  
    call SetUnitPosition( LightningUnit[22], cross_center_x, cross1_ry[4] )
    call IssuePointOrder( LightningUnit[22], "patrol", cross_center_x, cross1_ry[0] )
    //  
    // unit offset moving units = 90 degrees
    //  
    call SetUnitPosition( LightningUnit[23], cross_center_x, cross1_ry[1] )
    call IssuePointOrder( LightningUnit[23], "patrol", cross_center_x, cross1_ry[2] )
    //  
    call SetUnitPosition( LightningUnit[24], cross_center_x, cross1_ry[2] )
    call IssuePointOrder( LightningUnit[24], "patrol", cross_center_x, cross1_ry[0] )
    //  
    // starting lightning effects
    //  
    set LightningEffect[0] = AddLightning( "CLPB", true, cross1_rx[1], cross_center_y, cross1_rx[3], cross_center_y )
    set LightningEffect[1] = AddLightning( "CLPB", true, cross_center_x, cross1_ry[1], cross_center_x, cross1_ry[3] )
    call PolledWait( 3.25 )
    set udg_Lightning_Kill_Units_Boolean[1] = true
    call DestroyLightning( LightningEffect[0] )
    call DestroyLightning( LightningEffect[1] )
    set LightningEffect[0] = AddLightning("AFOD", true, cross1_rx[1], cross_center_y, cross1_rx[3], cross_center_y )
    set LightningEffect[1] = AddLightning("AFOD", true, cross_center_x, cross1_ry[1], cross_center_x, cross1_ry[3] )
    call PolledWait( 2.75 )
    set udg_Lightning_Kill_Units_Boolean[1] = false
    call DestroyLightning( LightningEffect[0] )
    call DestroyLightning( LightningEffect[1] )
endfunction

//===========================================================================
function InitTrig_Plus_Sign_Random_3 takes nothing returns nothing
    set gg_trg_Plus_Sign_Random_3 = CreateTrigger(  )
    call DisableTrigger( gg_trg_Plus_Sign_Random_3 )
    call TriggerRegisterTimerEvent( gg_trg_Plus_Sign_Random_3, 6.50, true )
    call TriggerAddAction( gg_trg_Plus_Sign_Random_3, function Trig_Plus_Sign_Random_3_Actions )
endfunction
these next 3 r the kills triggers
JASS:
function Trig_Plus_Sign_Random_Kill_Trigger_1_Actions takes nothing returns nothing
    local real x
    local real y
    local integer Loop1 = 1
    local integer triggerplayer
    if ( (GetTriggerPlayer() == Player(0)) or (GetTriggerPlayer() == Player(1)) ) and (udg_Lightning_Kill_Units_Boolean[1] == true)  then
        set triggerplayer = GetPlayerId( GetTriggerPlayer())
        if ( triggerplayer == 0 ) then
            call DisplayTextToForce( GetPlayersAll(), "Player 2 Has Won The Minigame" )
        elseif ( triggerplayer == 1 ) then
            call DisplayTextToForce( GetPlayersAll(), "Player 1 Has Won The Minigame" )
        endif
        call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_1 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_2 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_3 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_1 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_2 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_3 )
        set x = GetRectCenterX(gg_rct_Hero_Spawn_P1)
        set y = GetRectCenterY(gg_rct_Hero_Spawn_P1)
        call SetUnitPosition( udg_Selected_Hero_Red, x, y )
        set x = GetRectCenterX(gg_rct_Hero_Spawn_P2)
        set y = GetRectCenterY(gg_rct_Hero_Spawn_P2)
        call SetUnitPosition( udg_Selected_Hero_Blue, x, y )
        call PolledWait( 7.00 )
        loop
            exitwhen Loop1 > 24
            call SetUnitPosition( LightningUnit[Loop1], LightningUnit_X[Loop1], LightningUnit_Y[Loop1] )
            set Loop1 = Loop1 + 1
        endloop
        set udg_Lightning_Kill_Units_Boolean[1] = false
        set udg_Lightning_Kill_Units_Boolean[2] = false
        set udg_Lightning_Kill_Units_Boolean[3] = false
        call ResumeTimer( udg_Random_Events_Timer )
        call TimerDialogDisplay( udg_Random_Events_Timer_Window, true )
    endif
endfunction

//===========================================================================
function InitTrig_Plus_Sign_Random_Kill_Trigger_1 takes nothing returns nothing
    set gg_trg_Plus_Sign_Random_Kill_Trigger_1 = CreateTrigger(  )
    call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_1 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_1, 125.00, gg_unit_h05F_0036 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_1, 125.00, gg_unit_h05F_0037 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_1, 125.00, gg_unit_h05F_0038 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_1, 125.00, gg_unit_h05F_0039 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_1, 125.00, gg_unit_h05F_0040 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_1, 125.00, gg_unit_h05F_0041 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_1, 125.00, gg_unit_h05F_0043 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_1, 125.00, gg_unit_h05F_0044 )
    call TriggerAddAction( gg_trg_Plus_Sign_Random_Kill_Trigger_1, function Trig_Plus_Sign_Random_Kill_Trigger_Actions )
endfunction
JASS:
function Trig_Plus_Sign_Random_Kill_Trigger_2_Actions takes nothing returns nothing
    local real x
    local real y
    local integer Loop1 = 1
    local integer triggerplayer
    if ( (GetTriggerPlayer() == Player(0)) or (GetTriggerPlayer() == Player(1)) ) and (udg_Lightning_Kill_Units_Boolean[2] == true)  then
        set triggerplayer = GetPlayerId( GetTriggerPlayer())
        if ( triggerplayer == 0 ) then
            call DisplayTextToForce( GetPlayersAll(), "Player 2 Has Won The Minigame" )
        elseif ( triggerplayer == 1 ) then
            call DisplayTextToForce( GetPlayersAll(), "Player 1 Has Won The Minigame" )
        endif
        call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_1 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_2 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_3 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_1 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_2 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_3 )
        set x = GetRectCenterX(gg_rct_Hero_Spawn_P1)
        set y = GetRectCenterY(gg_rct_Hero_Spawn_P1)
        call SetUnitPosition( udg_Selected_Hero_Red, x, y )
        set x = GetRectCenterX(gg_rct_Hero_Spawn_P2)
        set y = GetRectCenterY(gg_rct_Hero_Spawn_P2)
        call SetUnitPosition( udg_Selected_Hero_Blue, x, y )
        call PolledWait( 7.00 )
        loop
            exitwhen Loop1 > 24
            call SetUnitPosition( LightningUnit[Loop1], LightningUnit_X[Loop1], LightningUnit_Y[Loop1] )
            set Loop1 = Loop1 + 1
        endloop
        set udg_Lightning_Kill_Units_Boolean[1] = false
        set udg_Lightning_Kill_Units_Boolean[2] = false
        set udg_Lightning_Kill_Units_Boolean[3] = false
        call ResumeTimer( udg_Random_Events_Timer )
        call TimerDialogDisplay( udg_Random_Events_Timer_Window, true )
    endif
endfunction

//===========================================================================
function InitTrig_Plus_Sign_Random_Kill_Trigger_2 takes nothing returns nothing
    set gg_trg_Plus_Sign_Random_Kill_Trigger_2 = CreateTrigger(  )
    call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_2 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_2, 125.00, gg_unit_h05F_0045 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_2, 125.00, gg_unit_h05F_0046 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_2, 125.00, gg_unit_h05F_0047 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_2, 125.00, gg_unit_h05F_0048 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_2, 125.00, gg_unit_h05F_0049 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_2, 125.00, gg_unit_h05F_0050 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_2, 125.00, gg_unit_h05F_0051 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_2, 125.00, gg_unit_h05F_0052 )
    call TriggerAddAction( gg_trg_Plus_Sign_Random_Kill_Trigger_2, function Trig_Plus_Sign_Random_Kill_Trigger_Actions )
endfunction
JASS:
function Trig_Plus_Sign_Random_Kill_Trigger_3_Actions takes nothing returns nothing
    local real x
    local real y
    local integer Loop1 = 1
    local integer triggerplayer
    if ( (GetTriggerPlayer() == Player(0)) or (GetTriggerPlayer() == Player(1)) ) and (udg_Lightning_Kill_Units_Boolean[3] == true)  then
        set triggerplayer = GetPlayerId( GetTriggerPlayer())
        if ( triggerplayer == 0 ) then
            call DisplayTextToForce( GetPlayersAll(), "Player 2 Has Won The Minigame" )
        elseif ( triggerplayer == 1 ) then
            call DisplayTextToForce( GetPlayersAll(), "Player 1 Has Won The Minigame" )
        endif
        call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_1 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_2 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_3 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_1 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_2 )
        call DisableTrigger( gg_trg_Plus_Sign_Random_3 )
        set x = GetRectCenterX(gg_rct_Hero_Spawn_P1)
        set y = GetRectCenterY(gg_rct_Hero_Spawn_P1)
        call SetUnitPosition( udg_Selected_Hero_Red, x, y )
        set x = GetRectCenterX(gg_rct_Hero_Spawn_P2)
        set y = GetRectCenterY(gg_rct_Hero_Spawn_P2)
        call SetUnitPosition( udg_Selected_Hero_Blue, x, y )
        call PolledWait( 7.00 )
        loop
            exitwhen Loop1 > 24
            call SetUnitPosition( LightningUnit[Loop1], LightningUnit_X[Loop1], LightningUnit_Y[Loop1] )
            set Loop1 = Loop1 + 1
        endloop
        set udg_Lightning_Kill_Units_Boolean[1] = false
        set udg_Lightning_Kill_Units_Boolean[2] = false
        set udg_Lightning_Kill_Units_Boolean[3] = false
        call ResumeTimer( udg_Random_Events_Timer )
        call TimerDialogDisplay( udg_Random_Events_Timer_Window, true )
    endif
endfunction

//===========================================================================
function InitTrig_Plus_Sign_Random_Kill_Trigger_3 takes nothing returns nothing
    set gg_trg_Plus_Sign_Random_Kill_Trigger_3 = CreateTrigger(  )
    call DisableTrigger( gg_trg_Plus_Sign_Random_Kill_Trigger_3 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_3, 125.00, gg_unit_h05F_0053 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_3, 125.00, gg_unit_h05F_0054 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_3, 125.00, gg_unit_h05F_0055 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_3, 125.00, gg_unit_h05F_0056 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_3, 125.00, gg_unit_h05F_0058 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_3, 125.00, gg_unit_h05F_0059 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_3, 125.00, gg_unit_h05F_0060 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Plus_Sign_Random_Kill_Trigger_3, 125.00, gg_unit_h05F_0061 )
    call TriggerAddAction( gg_trg_Plus_Sign_Random_Kill_Trigger_3, function Trig_Plus_Sign_Random_Kill_Trigger_Actions )
endfunction
 
Last edited:
Level 7
Joined
Jan 28, 2012
Messages
266
call SetUnitPosition( LightningUnit[1], cross1_rx[3], cross_center_y )
you could use
JASS:
call SetUnitX(LightningUnit[1],cross1_rx[3])
call SetUnitY(LightningUnit[1],cross_center_y)

replace this
JASS:
        set udg_Temp_Spawn_RED_Hero_Spawn = GetRectCenter(gg_rct_Hero_Spawn__Blue)
        call SetUnitPositionLoc( udg_Selected_Hero_Red, udg_Temp_Spawn_Red_Hero_Spawn )
        call RemoveLocation( udg_Temp_Spawn_Red_Hero_Spawn )        
        set udg_Temp_Spawn_Blue_Hero_Spawn = GetRectCenter(gg_rct_Hero_Spawn__Blue)
        call SetUnitPositionLoc( udg_Selected_Hero_Blue, udg_Temp_Spawn_Blue_Hero_Spawn )
        call RemoveLocation( udg_Temp_Spawn_Blue_Hero_Spawn )
should be replaced with
with this
JASS:
local real x
local real y
//....
//...
set x = GetRectCenterX(udg_Temp_Spawn_Red_Hero_Spawn)
set y = GetRectCenterY(udg_Temp_Spawn_Red_Hero_Spawn)
call SetUnitX(udg_Selected_Hero_Red,x)
call SetUnitY(udg_Selected_Hero_Red,y)
set x = GetRectCenterX(udg_Temp_Spawn_Blue_Hero_Spawn)
set y = GetRectCenterY(udg_Temp_Spawn_Blue_Hero_Spawn)
call SetUnitX(udg_Selected_Hero_Blue,x)
call SetUnitY(udg_Selected_Hero_Blue,y)

you could replace this
call DisplayTextToForce( GetPlayersAll(), "Player 2 Has Won The Minigame" )
with this
call DisplayTextToPlayer( GetLocalPlayer(), "Player 2 Has Won The Minigame" )
 
JASS:
set udg_Temp_Spawn_RED_Hero_Spawn = GetRectCenter(gg_rct_Hero_Spawn__Blue)
        call SetUnitPositionLoc( udg_Selected_Hero_Red, udg_Temp_Spawn_Red_Hero_Spawn )
        call RemoveLocation( udg_Temp_Spawn_Red_Hero_Spawn )        
        set udg_Temp_Spawn_Blue_Hero_Spawn = GetRectCenter(gg_rct_Hero_Spawn__Blue)
        call SetUnitPositionLoc( udg_Selected_Hero_Blue, udg_Temp_Spawn_Blue_Hero_Spawn )
        call RemoveLocation( udg_Temp_Spawn_Blue_Hero_Spawn )

lol i wonder how i missed tht haha thx and call setunitx and call setunity is faster than call setunitposition ? i figured it would be slower since its 2 calls rather than 1 ? and as for this

JASS:
//you could replace this
call DisplayTextToForce( GetPlayersAll(), "Player 2 Has Won The Minigame" ) 
//with this
call DisplayTextToPlayer( GetLocalPlayer(), "Player 2 Has Won The Minigame" )

i want it to show to all players is there a better one for all players ?
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
JASS:
set udg_Temp_Spawn_RED_Hero_Spawn = GetRectCenter(gg_rct_Hero_Spawn__Blue)
        call SetUnitPositionLoc( udg_Selected_Hero_Red, udg_Temp_Spawn_Red_Hero_Spawn )
        call RemoveLocation( udg_Temp_Spawn_Red_Hero_Spawn )        
        set udg_Temp_Spawn_Blue_Hero_Spawn = GetRectCenter(gg_rct_Hero_Spawn__Blue)
        call SetUnitPositionLoc( udg_Selected_Hero_Blue, udg_Temp_Spawn_Blue_Hero_Spawn )
        call RemoveLocation( udg_Temp_Spawn_Blue_Hero_Spawn )

lol i wonder how i missed tht haha thx and call setunitx and call setunity is faster than call setunitposition ? i figured it would be slower since its 2 calls rather than 1 ? and as for this

JASS:
//you could replace this
call DisplayTextToForce( GetPlayersAll(), "Player 2 Has Won The Minigame" ) 
//with this
call DisplayTextToPlayer( GetLocalPlayer(), "Player 2 Has Won The Minigame" )

i want it to show to all players is there a better one for all players ?

what he posted will work for al players.

SetUnitPosition is slower than SetUnitX-Y because thats exactly what it does
think about it this way

I am code > I call Set Unit Position > SetUnitPosition calls SetUnitX and SetUnitY > goes on
I am code > I use SetUnitX and SetUnitY > goes on
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
No that doesn't make sense because we are talking about native functions.
If SetUnitPosition was just SetUnitX + SetUnitY, then calling SetUnitPosition would be faster because jass is interpreted.
SetUnitX/Y is faster than SetUnitPosition because there are no checks or at least much less (unit collision, pathing, ...)
 
No that doesn't make sense because we are talking about native functions.
If SetUnitPosition was just SetUnitX + SetUnitY, then calling SetUnitPosition would be faster because jass is interpreted.
SetUnitX/Y is faster than SetUnitPosition because there are no checks or at least much less (unit collision, pathing, ...)

thts what they said already lol they said setunitx and setunity is faster than setunitposition lol
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
No that doesn't make sense because we are talking about native functions.
If SetUnitPosition was just SetUnitX + SetUnitY, then calling SetUnitPosition would be faster because jass is interpreted.
SetUnitX/Y is faster than SetUnitPosition because there are no checks or at least much less (unit collision, pathing, ...)

idk i just tried to dumb it down as much as possible, i made up most of that statement
 
should be replaced with
with this
JASS:
local real x
local real y
//....
//...
set x = GetRectCenterX(udg_Temp_Spawn_Red_Hero_Spawn)
set y = GetRectCenterY(udg_Temp_Spawn_Red_Hero_Spawn)
call SetUnitX(udg_Selected_Hero_Red,x)
call SetUnitY(udg_Selected_Hero_Red,y)
set x = GetRectCenterX(udg_Temp_Spawn_Blue_Hero_Spawn)
set y = GetRectCenterY(udg_Temp_Spawn_Blue_Hero_Spawn)
call SetUnitX(udg_Selected_Hero_Blue,x)
call SetUnitY(udg_Selected_Hero_Blue,y)
Wouldn't it be more officiant if you just implement the reals strait into the actions as they are only being used on it once. This way you will be avoid using pointless cpu processing and ram(no matter how little).
JASS:
call SetUnitX(udg_Selected_Hero_Red, GetRectCenterX(udg_Temp_Spawn_Red_Hero_Spawn))
call SetUnitY(udg_Selected_Hero_Red, GetRectCenterY(udg_Temp_Spawn_Red_Hero_Spawn))
call SetUnitX(udg_Selected_Hero_Blue, GetRectCenterX(udg_Temp_Spawn_Blue_Hero_Spawn))
call SetUnitY(udg_Selected_Hero_Blue, GetRectCenterY(udg_Temp_Spawn_Blue_Hero_Spawn))
Unless you are just doing that as an explanation you should of mentioned that if you use a variable like this just cut the whole thing out and just implement it strait into the action unless being used on multiple actions.

edit: Oh and don't use arrayed variables unless you are going to be using them in any loops or else they are only going to be more inofficiant.
 
Status
Not open for further replies.
Top