Trigger help constructing structure dissapears toghetter with builder

Nina

New Member
Reaction score
8
I have a trigger that when a unit starts construction of a windmill that it must just keep constructing it and deduct some values from variables but if they variable values arent high enough it should cancel the construction and remove the structure. Ingame, (the variables are high enough and it deducts them(i see that in multiboard) but when it starts building the unit dissapears its unselectable or anything but i put the builder in a unit groupt with ctrl+1 but if i select it it looks like its still constructing but in an inexisting building. Someone please help me, this is my trigger:

JASS:

function Trig_windmill_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetConstructingStructure()) == 'h002' ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func002C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(0) ) ) then
        return false
    endif
    if ( not ( udg_lumber[1] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[1] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[1] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[1] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[1] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func003C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(1) ) ) then
        return false
    endif
    if ( not ( udg_lumber[2] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[2] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[2] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[2] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[2] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func004C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(2) ) ) then
        return false
    endif
    if ( not ( udg_lumber[3] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[3] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[3] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[3] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[3] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func005C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(3) ) ) then
        return false
    endif
    if ( not ( udg_lumber[4] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[4] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[4] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[4] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[4] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func006C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(4) ) ) then
        return false
    endif
    if ( not ( udg_lumber[5] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[5] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[5] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[5] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[5] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func007C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(5) ) ) then
        return false
    endif
    if ( not ( udg_lumber[6] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[6] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[6] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[6] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[6] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func008C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(6) ) ) then
        return false
    endif
    if ( not ( udg_lumber[7] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[7] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[7] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[7] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[7] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func009C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(7) ) ) then
        return false
    endif
    if ( not ( udg_lumber[8] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[8] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[8] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[8] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[8] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func010C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(8) ) ) then
        return false
    endif
    if ( not ( udg_lumber[9] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[9] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[9] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[9] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[9] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func011C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(9) ) ) then
        return false
    endif
    if ( not ( udg_lumber[10] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[10] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[10] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[10] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[10] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func012C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(10) ) ) then
        return false
    endif
    if ( not ( udg_lumber[11] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[11] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[11] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[11] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[11] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Func013C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetConstructingStructure()) == Player(11) ) ) then
        return false
    endif
    if ( not ( udg_lumber[12] >= 60 ) ) then
        return false
    endif
    if ( not ( udg_stone[12] >= 40 ) ) then
        return false
    endif
    if ( not ( udg_iron[12] >= 30 ) ) then
        return false
    endif
    if ( not ( udg_clay[12] >= 20 ) ) then
        return false
    endif
    if ( not ( udg_food[12] >= 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_windmill_Actions takes nothing returns nothing
    if ( Trig_windmill_Func002C() ) then
        set udg_lumber[1] = ( udg_lumber[1] - 60 )
        set udg_stone[1] = ( udg_stone[1] - 40 )
        set udg_iron[1] = ( udg_iron[1] - 30 )
        set udg_clay[1] = ( udg_clay[1] - 20 )
        set udg_food[1] = ( udg_food[1] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
    if ( Trig_windmill_Func003C() ) then
        set udg_lumber[2] = ( udg_lumber[2] - 60 )
        set udg_stone[2] = ( udg_stone[2] - 40 )
        set udg_iron[2] = ( udg_iron[2] - 30 )
        set udg_clay[2] = ( udg_clay[2] - 20 )
        set udg_food[2] = ( udg_food[2] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
    if ( Trig_windmill_Func004C() ) then
        set udg_lumber[3] = ( udg_lumber[3] - 60 )
        set udg_stone[3] = ( udg_stone[3] - 40 )
        set udg_iron[3] = ( udg_iron[3] - 30 )
        set udg_clay[3] = ( udg_clay[3] - 20 )
        set udg_food[3] = ( udg_food[3] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
    if ( Trig_windmill_Func005C() ) then
        set udg_lumber[4] = ( udg_lumber[4] - 60 )
        set udg_stone[4] = ( udg_stone[4] - 40 )
        set udg_iron[4] = ( udg_iron[4] - 30 )
        set udg_clay[4] = ( udg_clay[4] - 20 )
        set udg_food[4] = ( udg_food[4] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
    if ( Trig_windmill_Func006C() ) then
        set udg_lumber[5] = ( udg_lumber[5] - 60 )
        set udg_stone[5] = ( udg_stone[5] - 40 )
        set udg_iron[5] = ( udg_iron[5] - 30 )
        set udg_clay[5] = ( udg_clay[5] - 20 )
        set udg_food[5] = ( udg_food[5] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
    if ( Trig_windmill_Func007C() ) then
        set udg_lumber[6] = ( udg_lumber[6] - 60 )
        set udg_stone[6] = ( udg_stone[6] - 40 )
        set udg_iron[6] = ( udg_iron[6] - 30 )
        set udg_clay[6] = ( udg_clay[6] - 20 )
        set udg_food[6] = ( udg_food[6] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
    if ( Trig_windmill_Func008C() ) then
        set udg_lumber[7] = ( udg_lumber[7] - 60 )
        set udg_stone[7] = ( udg_stone[7] - 40 )
        set udg_iron[7] = ( udg_iron[7] - 30 )
        set udg_clay[7] = ( udg_clay[7] - 20 )
        set udg_food[7] = ( udg_food[7] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
    if ( Trig_windmill_Func009C() ) then
        set udg_lumber[8] = ( udg_lumber[8] - 60 )
        set udg_stone[8] = ( udg_stone[8] - 40 )
        set udg_iron[8] = ( udg_iron[8] - 30 )
        set udg_clay[8] = ( udg_clay[8] - 20 )
        set udg_food[8] = ( udg_food[8] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
    if ( Trig_windmill_Func010C() ) then
        set udg_lumber[9] = ( udg_lumber[9] - 60 )
        set udg_stone[9] = ( udg_stone[9] - 40 )
        set udg_iron[9] = ( udg_iron[9] - 30 )
        set udg_clay[9] = ( udg_clay[9] - 20 )
        set udg_food[9] = ( udg_food[9] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
    if ( Trig_windmill_Func011C() ) then
        set udg_lumber[10] = ( udg_lumber[10] - 60 )
        set udg_stone[10] = ( udg_stone[10] - 40 )
        set udg_iron[10] = ( udg_iron[10] - 30 )
        set udg_clay[10] = ( udg_clay[10] - 20 )
        set udg_food[10] = ( udg_food[10] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
    if ( Trig_windmill_Func012C() ) then
        set udg_lumber[11] = ( udg_lumber[11] - 60 )
        set udg_stone[11] = ( udg_stone[11] - 40 )
        set udg_iron[11] = ( udg_iron[11] - 30 )
        set udg_clay[11] = ( udg_clay[11] - 20 )
        set udg_food[11] = ( udg_food[11] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
    if ( Trig_windmill_Func013C() ) then
        set udg_lumber[12] = ( udg_lumber[12] - 60 )
        set udg_stone[12] = ( udg_stone[12] - 40 )
        set udg_iron[12] = ( udg_iron[12] - 30 )
        set udg_clay[12] = ( udg_clay[12] - 20 )
        set udg_food[12] = ( udg_food[12] - 0 )
    else
        call RemoveUnit( GetConstructingStructure() )
    endif
endfunction

//===========================================================================
function InitTrig_windmill takes nothing returns nothing
    set gg_trg_windmill = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_windmill, EVENT_PLAYER_UNIT_CONSTRUCT_START )
    call TriggerAddCondition( gg_trg_windmill, Condition( function Trig_windmill_Conditions ) )
    call TriggerAddAction( gg_trg_windmill, function Trig_windmill_Actions )
endfunction


Thanks in advance!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top