• 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.

[Trigger] Victory Trigger Help

Status
Not open for further replies.
Level 7
Joined
Jun 1, 2006
Messages
375
Okay so straight to it. In my map there are 8 teams, each team has 2 players. I need a trigger so that when all the other teams have 0 units left, the team with atleast 1 unit wins. Now im talking total team units, so if red whos is on team 1 has 1 unit, and blue who has 0 units is on reds team (team 1) they both achieve victory. Can anyone help?

Heres how in and ideal easy world it would look. (I know im using fake conditions and such, but this should give a better idea of what i need). Also in my fake trigger, team 1 is the victor.

Event: Every 0.05 seconds of game time.

Condition: Number of units owned by team 2 equal to 0.
Number of units owned by team 3 equal to 0.
Number of units owned by team 4 equal to 0.
Number of units owned by team 1 equal to atleast 1

Action: Victory for red
Victory for blue

You dont need the event to be every 0.05 seconds of game time, i just used that as a basis.

Additional info:
Team 1 is red and blue
Team 2 is teal and purple
Team 3 is yellow and orange
Team 4 is green and pink

I have playergroup variable for each team.

Oh yah I also have a defeat trigger which makes it so when one team has no units the get defeat.

Thanks! bai!
 
Level 7
Joined
Jun 1, 2006
Messages
375
Lol yah i cant fight a condition for the team obtaining victory. i need "Number of units owned by team 1 equal to atleast 1" but i cant find anything like it (i think it'd be in intergers but the closest i can find is random layer in playergroup). Can you write it :p
 
Level 35
Joined
Oct 9, 2006
Messages
6,394
Lol yah i cant fight a condition for the team obtaining victory. i need "Number of units owned by team 1 equal to atleast 1" but i cant find anything like it (i think it'd be in intergers but the closest i can find is random layer in playergroup). Can you write it :p

Sure :wink: Opening up WEU

JASS:
function Trig_Win_Condition_for_Team_1_Func003C takes nothing returns boolean
    if ( not ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(2))) == 0 ) ) then
        return false
    endif
    if ( not ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(3))) == 0 ) ) then
        return false
    endif
    if ( not ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(4))) == 0 ) ) then
        return false
    endif
    if ( not ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(5))) == 0 ) ) then
        return false
    endif
    if ( not ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(6))) == 0 ) ) then
        return false
    endif
    if ( not ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(7))) == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Win_Condition_for_Team_1_Conditions takes nothing returns boolean
    if ( not Trig_Win_Condition_for_Team_1_Func003C() ) then
        return false
    endif
    return true
endfunction

function Trig_Win_Condition_for_Team_1_Actions takes nothing returns nothing
    call CustomVictoryBJ( Player(0), true, true )
    call CustomVictoryBJ( Player(1), true, true )
endfunction

//===========================================================================
function InitTrig_Win_Condition_for_Team_1 takes nothing returns nothing
    set gg_trg_Win_Condition_for_Team_1 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Win_Condition_for_Team_1, 0.05 )
    call TriggerAddCondition( gg_trg_Win_Condition_for_Team_1, Condition( function Trig_Win_Condition_for_Team_1_Conditions ) )
    call TriggerAddAction( gg_trg_Win_Condition_for_Team_1, function Trig_Win_Condition_for_Team_1_Actions )
endfunction

And the Defeat trigger

JASS:
function Trig_Defeat_Condition_for_team_1_Func003C takes nothing returns boolean
    if ( not ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(0))) == 0 ) ) then
        return false
    endif
    if ( not ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(1))) == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Defeat_Condition_for_team_1_Conditions takes nothing returns boolean
    if ( not Trig_Defeat_Condition_for_team_1_Func003C() ) then
        return false
    endif
    return true
endfunction

function Trig_Defeat_Condition_for_team_1_Actions takes nothing returns nothing
    call CustomDefeatBJ( Player(0), "TRIGSTR_001" )
    call CustomDefeatBJ( Player(1), "TRIGSTR_002" )
endfunction

//===========================================================================
function InitTrig_Defeat_Condition_for_team_1 takes nothing returns nothing
    set gg_trg_Defeat_Condition_for_team_1 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Defeat_Condition_for_team_1, 0.05 )
    call TriggerAddCondition( gg_trg_Defeat_Condition_for_team_1, Condition( function Trig_Defeat_Condition_for_team_1_Conditions ) )
    call TriggerAddAction( gg_trg_Defeat_Condition_for_team_1, function Trig_Defeat_Condition_for_team_1_Actions )
endfunction

Made as text for easy copy...

Here is anormal view of them:
  • Win Conditions for Team 1
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • And - All (Conditions) are true
        • (Number of units in (Units in (Playable map area) owned by Player 3 (Teal))) Equal to 0
        • (Number of units in (Units in (Playable map area) owned by Player 4 (Purple))) Equal to 0
        • (Number of units in (Units in (Playable map area) owned by Player 5 (Yellow))) Equal to 0
        • (Number of units in (Units in (Playable map area) owned by Player 6 (Orange))) Equal to 0
        • (Number of units in (Units in (Playable map area) owned by Player 7 (Green))) Equal to 0
        • (Number of units in (Units in (Playable map area) owned by Player 8 (Pink))) Equal to 0
    • Actions
      • Game - Victory Player 1 (Red)(Show dialogs, Show scores)
      • Game - Victory Player 2 (Blue)(Show dialogs, Show scores)
  • Defeat Conditions for Team 1
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • And - All (Conditions) are true
        • (Number of units in (Units in (Playable map area) owned by Player 1 (Red))) Equal to 0
        • (Number of units in (Units in (Playable map area) owned by Player 2 (Blue))) Equal to 0
    • Actions
      • Game - Defeat Player 1 (Red) with the message: Defeat!
      • Game - Defeat Player 2 (Blue) with the message: Defeat!
That should do the trick, If not something almost similar can be done by using groups.
 
Status
Not open for further replies.
Top