HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

test

05-30-2005, 07:05 AM#1
The_AwaKening
This trigger is to take control of allies units who have left the game. The map used to be 3v3v3, but I've changed it to 5v5. What needs to be changed to add in the other 2 allies? Sorry, but I never wrote this trigger to begin with since I'm not too good with jass.

Code:
function UnitsProvidingSupply takes nothing returns boolean
return ( GetUnitFoodMade(GetFilterUnit()) > 0 )
endfunction
function Trig_Take_Actions takes nothing returns nothing
local player playerTake = GetTriggerPlayer()
local integer playerTakeIndex = GetConvertedPlayerId(playerTake)
local integer teamNumber = ( ( ( ( playerTakeIndex - 1 ) - ModuloInteger(( playerTakeIndex - 1 ), 3) ) / 3 ) + 1 )
local integer AllyIndex1 = (teamNumber - 1) * 3 + ModuloInteger(playerTakeIndex, 3) + 1
local integer AllyIndex2 = (teamNumber - 1) * 3 + ModuloInteger(playerTakeIndex + 1, 3) + 1
local player Ally1 = ConvertedPlayer(AllyIndex1)
local player Ally2 = ConvertedPlayer(AllyIndex2)
local integer i
local integer j
local integer k = 1
local integer l
local player whichAlly
local integer numUnits
local unit whichUnit
local group allyUnits
local group farmGroup
local unit farm
if ( udg_teamLost[teamNumber] or udg_pureRacialBonus[playerTakeIndex] != 0 ) then
return
endif
loop
exitwhen k > 2
if ( k == 1 ) then
set whichAlly = Ally1
else
set whichAlly = Ally2
endif
if ( udg_playerLost[GetConvertedPlayerId(whichAlly)] == false ) then
call DoNothing()
else
set farmGroup = GetUnitsOfPlayerMatching(whichAlly, Condition(function UnitsProvidingSupply))
loop
exitwhen CountUnitsInGroup(farmGroup) == 0
set farm = GroupPickRandomUnit(farmGroup)
call SetUnitOwner( farm, playerTake, false )
call GroupRemoveUnitSimple( farm, farmGroup )
endloop
call TriggerSleepAction (0.01)
set allyUnits = GetUnitsOfPlayerAll(whichAlly)
set numUnits = CountUnitsInGroup(allyUnits)
if ( numUnits != 0 ) then
set i = 1
loop
exitwhen i > 4
if ( udg_townRacialBonus[(teamNumber-1)*4 + i] == GetConvertedPlayerId(whichAlly) ) then
set udg_townRacialBonus[(teamNumber-1)*4 + i] = playerTakeIndex
endif
set i = i + 1
endloop
endif
set i = 1
loop
exitwhen i > numUnits
set whichUnit = GroupPickRandomUnit(allyUnits)
if ( IsUnitType(whichUnit, UNIT_TYPE_HERO) or (GetUnitTypeId(whichUnit) == 'ewsp')) then
set udg_totalHeros[playerTakeIndex] = udg_totalHeros[playerTakeIndex] + 1
set udg_totalHeros[GetConvertedPlayerId(whichAlly)] = udg_totalHeros[GetConvertedPlayerId(whichAlly)] - 1
if ( GetUnitTypeId(whichUnit) == 'ewsp' ) then
if ( udg_heroReviveMatrix[playerTakeIndex*udg_heroReviveCount] == 0 ) then
call AddHeroToReviveList( playerTakeIndex, GetUnitUserData(whichUnit) )
endif
endif
endif  // END HERO ONLY ACTIONS
call SetUnitOwner( whichUnit, playerTake, false )
call GroupRemoveUnitSimple( whichUnit, allyUnits )
call TriggerSleepAction (0.01)
set i = i + 1
endloop
endif  // END PLAYER GONE ACTIONS
set k = k + 1 // goto next ally
endloop
endfunction
function InitTrig_Take takes nothing returns nothing
set gg_trg_Take = CreateTrigger(  )
call TriggerRegisterPlayerChatEvent( gg_trg_Take, Player(0), "-take", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Take, Player(1), "-take", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Take, Player(2), "-take", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Take, Player(3), "-take", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Take, Player(4), "-take", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Take, Player(5), "-take", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Take, Player(6), "-take", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Take, Player(7), "-take", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Take, Player(8), "-take", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Take, Player(11), "-take", true )
call TriggerAddAction( gg_trg_Take, function Trig_Take_Actions )
endfunction
06-22-2005, 08:29 PM#2
PitzerMike
I can write down a solution, if you tell me, which players belong to which team.

Is it like every odd player number is one team and every even player number the other team or how did you separate the teams?