HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Need some help regarding control points

03-25-2009, 02:48 AM#1
Archean
Hi,
I'm working on a map with Control Points which need to be captured by players to acquire certain benefits.
I was trying to make the control points capturable by a certain unit type only (for simplicity's sake, let's say the Footman unit). In order to capture them, the units have to stand next to it for a certain amount of time (60 seconds).
If the unit leaves, the timer stops. If there are more enemy units in the area, the timer stops running for the player, but starts for the enemy. If the units die, the timer stops.

I've downloaded a few maps with similar systems to try and understand how to do it myself, but I really need help because I can't figure out the role of the components (integers, arrays, etc...) for such a trigger for the life of me.

If anyone could give me a hand, it would be most appreciated. Now, I'm not asking you to do it for me. I want to understand how it works and how to do it. If you can help me out with that, it would be great.
Thanks
03-25-2009, 03:41 AM#2
Blacktastic
If you are having trouble with basics, I highly don't suggest you make a map. Rather, make a large amount of small ideas or projects to learn how everything works, THEN make the map.

The world will thank you for it.


Also, are you working in GUI or JASS (If your answer to this question is what?, then hit up the tutorials section.)

Edit: How does one highly not suggest something?
03-25-2009, 05:09 AM#3
Archean
In my opinion there is no better way to learn how something works than by using it to achieve a specific goal. I'm using GUI, and have already created several small systems such as a squad system and a hero development system, which will be incorporated in the said map, and they work fine.
However, I'm having problems with *this* particular problem, and I wouldn't have posted on the forums if I hadn't already looked at several tutorials and downloaded templates. Problem is that most maps with such control points systems are protected, and therefore completely useless to me.

P.S: You can't highly not suggest to make a map, but you can highly suggest to not make a map...

EDIT: Here's what I have so far. The system is based off a template map I found on the Hive Workshop. I tried to get it to work, but to no avail.

Collapse JASS:
function Trig_Caps_Actions takes nothing returns nothing
    set udg_Control_Point[1] = gg_unit_n600_0000
    set udg_Control_Point[2] = gg_unit_n600_0002
    set udg_Control_Point[3] = gg_unit_n600_0004
    set udg_Control_Point[4] = gg_unit_n600_0005
    set udg_Number_CP = 4
    set bj_forLoopAIndex = 7
    set bj_forLoopAIndexEnd = 7
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call ForceAddPlayerSimple( ConvertedPlayer(GetForLoopIndexA()), udg_Goblin_Army )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set bj_forLoopAIndex = 12
    set bj_forLoopAIndexEnd = 12
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call ForceAddPlayerSimple( ConvertedPlayer(GetForLoopIndexA()), udg_Dwarven_Army )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = udg_Number_CP
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call SetUnitUserData( udg_Control_Point[GetForLoopIndexA()], GetForLoopIndexA() )
        set udg_Progress[GetForLoopIndexA()] = 50.00
        set udg_Captured_CP[GetForLoopIndexA()] = 0
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Caps takes nothing returns nothing
    set gg_trg_Caps = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Caps, function Trig_Caps_Actions )
endfunction


and

Collapse JASS:
function Trig_Caps_2_Func001Func002002003 takes nothing returns boolean
    return ( IsPlayerInForce(GetOwningPlayer(GetFilterUnit()), udg_Dwarven_Army) == true )
endfunction

function Trig_Caps_2_Func001Func003Func001C takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(GetEnumUnit()) == true ) ) then
        return false
    endif
    if ( not ( udg_Progress[GetForLoopIndexA()] < 100.00 ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetEnumUnit()) == 'h600' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Caps_2_Func001Func003A takes nothing returns nothing
    if ( Trig_Caps_2_Func001Func003Func001C() ) then
        set udg_Progress[GetForLoopIndexA()] = ( udg_Progress[GetForLoopIndexA()] + 1 )
    else
    endif
endfunction

function Trig_Caps_2_Func001Func005002003 takes nothing returns boolean
    return ( IsPlayerInForce(GetOwningPlayer(GetFilterUnit()), udg_Goblin_Army) == true )
endfunction

function Trig_Caps_2_Func001Func006Func001C takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(GetEnumUnit()) == true ) ) then
        return false
    endif
    if ( not ( udg_Progress[GetForLoopIndexA()] < 0.00 ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetEnumUnit()) == 'h602' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Caps_2_Func001Func006A takes nothing returns nothing
    if ( Trig_Caps_2_Func001Func006Func001C() ) then
        set udg_Progress[GetForLoopIndexA()] = ( udg_Progress[GetForLoopIndexA()] - 1 )
    else
    endif
endfunction

function Trig_Caps_2_Func001Func008Func001Func001Func001C takes nothing returns boolean
    if ( not ( udg_Progress[GetForLoopIndexA()] == 75.00 ) ) then
        return false
    endif
    if ( not ( udg_Captured_CP[GetForLoopIndexA()] >= 25 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Caps_2_Func001Func008Func001Func001Func002C takes nothing returns boolean
    if ( not ( udg_Progress[GetForLoopIndexA()] == 0.00 ) ) then
        return false
    endif
    if ( not ( udg_Captured_CP[GetForLoopIndexA()] != 2 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Caps_2_Func001Func008Func001Func001C takes nothing returns boolean
    if ( not ( udg_Progress[GetForLoopIndexA()] < 25.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Caps_2_Func001Func008Func001Func002C takes nothing returns boolean
    if ( not ( udg_Progress[GetForLoopIndexA()] == 100.00 ) ) then
        return false
    endif
    if ( not ( udg_Captured_CP[GetForLoopIndexA()] != 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Caps_2_Func001Func008Func001C takes nothing returns boolean
    if ( not ( udg_Progress[GetForLoopIndexA()] > 75.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Caps_2_Func001Func008C takes nothing returns boolean
    if ( not ( udg_Progress[GetForLoopIndexA()] == 50.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Caps_2_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = udg_Number_CP
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set udg_Temp_Point = GetUnitLoc(udg_Control_Point[GetForLoopIndexA()])
        set udg_Temp_Group = GetUnitsInRangeOfLocMatching(400.00, udg_Temp_Point, Condition(function Trig_Caps_2_Func001Func002002003))
        call ForGroupBJ( udg_Temp_Group, function Trig_Caps_2_Func001Func003A )
        call GroupClear( udg_Temp_Group )
        set udg_Temp_Group = GetUnitsInRangeOfLocMatching(400.00, udg_Temp_Point, Condition(function Trig_Caps_2_Func001Func005002003))
        call ForGroupBJ( udg_Temp_Group, function Trig_Caps_2_Func001Func006A )
        call GroupClear( udg_Temp_Group )
        if ( Trig_Caps_2_Func001Func008C() ) then
            call DestroyTextTag( udg_CP_Floating_Text[GetForLoopIndexA()] )
            call CreateTextTagLocBJ( "TRIGSTR_049", udg_Temp_Point, 0, 8.00, 100, 100, 100, 0 )
            call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
            set udg_CP_Floating_Text[GetForLoopIndexA()] = GetLastCreatedTextTag()
        else
            if ( Trig_Caps_2_Func001Func008Func001C() ) then
                if ( Trig_Caps_2_Func001Func008Func001Func002C() ) then
                    set udg_Captured_CP[GetForLoopIndexA()] = 1
                    call SetUnitColor( udg_Control_Point[GetForLoopIndexA()], PLAYER_COLOR_BROWN )
                    call DisplayTimedTextToForce( GetPlayersAll(), 10.00, ( "Dwarven Army has captured " + ( GetUnitName(udg_Control_Point[GetForLoopIndexA()]) + "." ) ) )
                    call DestroyTextTag( udg_CP_Floating_Text[GetForLoopIndexA()] )
                    call CreateTextTagLocBJ( ( "Dwarven Army" + ( I2S(R2I(( ( ( udg_Progress[GetForLoopIndexA()] - 50.00 ) / 50.00 ) * 100.00 ))) + "% Captured" ) ), udg_Temp_Point, 0, 8.00, 100, 100, 100, 0 )
                    call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
                    set udg_CP_Floating_Text[GetForLoopIndexA()] = GetLastCreatedTextTag()
                else
                    call DestroyTextTag( udg_CP_Floating_Text[GetForLoopIndexA()] )
                    call CreateTextTagLocBJ( ( "Dwarven Army" + ( I2S(R2I(( ( ( udg_Progress[GetForLoopIndexA()] - 50.00 ) / 50.00 ) * 100.00 ))) + "% Captured" ) ), udg_Temp_Point, 0, 8.00, 100, 100, 100, 0 )
                    call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
                    set udg_CP_Floating_Text[GetForLoopIndexA()] = GetLastCreatedTextTag()
                endif
            else
                if ( Trig_Caps_2_Func001Func008Func001Func001C() ) then
                    if ( Trig_Caps_2_Func001Func008Func001Func001Func002C() ) then
                        set udg_Captured_CP[GetForLoopIndexA()] = 2
                        call SetUnitColor( udg_Control_Point[GetForLoopIndexA()], PLAYER_COLOR_GREEN )
                        call DisplayTimedTextToForce( GetPlayersAll(), 10.00, ( "Goblin Army has captured " + ( GetUnitName(udg_Control_Point[GetForLoopIndexA()]) + "." ) ) )
                        call DestroyTextTag( udg_CP_Floating_Text[GetForLoopIndexA()] )
                        call CreateTextTagLocBJ( ( "Goblin Army" + ( I2S(R2I(( ( ( udg_Progress[GetForLoopIndexA()] - 50.00 ) / 50.00 ) * 100.00 ))) + "% Captured" ) ), udg_Temp_Point, 0, 8.00, 100, 100, 100, 0 )
                        call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
                        set udg_CP_Floating_Text[GetForLoopIndexA()] = GetLastCreatedTextTag()
                    else
                        call DestroyTextTag( udg_CP_Floating_Text[GetForLoopIndexA()] )
                        call CreateTextTagLocBJ( ( "Goblin Army" + ( I2S(R2I(( ( ( udg_Progress[GetForLoopIndexA()] - 50.00 ) / 50.00 ) * 100.00 ))) + "% Captured" ) ), udg_Temp_Point, 0, 8.00, 100, 100, 100, 0 )
                        call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
                        set udg_CP_Floating_Text[GetForLoopIndexA()] = GetLastCreatedTextTag()
                    endif
                else
                    if ( Trig_Caps_2_Func001Func008Func001Func001Func001C() ) then
                        call DestroyTextTag( udg_CP_Floating_Text[GetForLoopIndexA()] )
                        call CreateTextTagLocBJ( "TRIGSTR_048", udg_Temp_Point, 0, 8.00, 100, 100, 100, 0 )
                        call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
                        call SetUnitColor( udg_Control_Point[GetForLoopIndexA()], ConvertPlayerColor(12) )
                        set udg_CP_Floating_Text[GetForLoopIndexA()] = GetLastCreatedTextTag()
                        set udg_Captured_CP[GetForLoopIndexA()] = 0
                    else
                    endif
                endif
            endif
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Caps_2 takes nothing returns nothing
    set gg_trg_Caps_2 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Caps_2, 1.00 )
    call TriggerAddAction( gg_trg_Caps_2, function Trig_Caps_2_Actions )
endfunction

03-25-2009, 06:20 AM#4
Blacktastic
...what the..

What is with this GUI/JASS hybrid stuff you just posted o.O
03-25-2009, 07:57 AM#5
Archean
...actually I'm as surprised as you are... the code looks nothing like that in the editor. Hang on I'll try and fix it.
03-25-2009, 03:20 PM#6
Blacktastic
Why did you convert your GUI to JASS X_X. Just post the code as GUI, that is at least readable.

Perfect example of why GUI fails though :p.
03-25-2009, 08:37 PM#7
PurplePoot
Quote:
Collapse JASS:
    set bj_forLoopAIndex = 12
    set bj_forLoopAIndexEnd = 12
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call ForceAddPlayerSimple( ConvertedPlayer(GetForLoopIndexA()), udg_Dwarven_Army )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
Hmm? (See highlight)

Loop spam ftl. This applies to more than just this one.
03-25-2009, 09:03 PM#8
TriggerHappy
Quote:
Originally Posted by Archean
...actually I'm as surprised as you are... the code looks nothing like that in the editor. Hang on I'll try and fix it.

Nice excuse.
03-25-2009, 09:06 PM#9
Blacktastic
Quote:
Originally Posted by TriggerHappy187
Nice excuse.

No actually the original code he posted was JASS in a GUI format. It was wierd.

for some reason instead of using GUI tags he converted GUI to custom and posted it as-is.

I would have rather had the JASS/GUI hybrid X_X