- Joined
- Sep 2, 2005
- Messages
- 1,029
JASS:
function Trig_Hes_Baaaaack_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'e008' ) and not ( GetUnitTypeId(GetTriggerUnit()) == 'e007' ) and not ( GetUnitTypeId(GetTriggerUnit()) == 'e006' ) and not ( GetUnitTypeId(GetTriggerUnit()) == 'e005' )) then
return false
endif
return true
endfunction
function Trig_Hes_Baaaaack_Actions takes nothing returns nothing
local player whichPlayer= GetTriggerPlayer()
local group roots
local unit root
local integer id = GetUnitTypeId(root)
local location rootLoc
local real rootX
local real rootY
set roots = GetUnitsOfPlayerAndTypeId(whichPlayer, 'e00D')
call GroupAddGroup(GetUnitsOfPlayerAndTypeId(whichPlayer, 'e00G'), roots)
call GroupAddGroup(GetUnitsOfPlayerAndTypeId(whichPlayer, 'e00R'), roots)
call GroupAddGroup(GetUnitsOfPlayerAndTypeId(whichPlayer, 'e00Q'), roots)
set root = GroupPickRandomUnit(roots)
set rootLoc = GetUnitLoc(root)
set rootX=GetLocationX(rootLoc)
set rootY=GetLocationY(rootLoc)
if (id == 'e00D') then
call CreateUnitAtLoc(whichPlayer, 'e001', rootLoc, bj_UNIT_FACING)
call SelectUnitForPlayerSingle( FirstOfGroup(GetUnitsOfPlayerAndTypeId(whichPlayer, 'e001')), whichPlayer )
call SetCameraPositionForPlayer(whichPlayer, rootX, rootY)
call SetCameraQuickPositionForPlayer(whichPlayer, rootX, rootY)
elseif (id == 'e00G') then
call CreateUnitAtLoc(whichPlayer, 'e002', rootLoc, bj_UNIT_FACING)
call SelectUnitForPlayerSingle( FirstOfGroup(GetUnitsOfPlayerAndTypeId(whichPlayer, 'e002')), whichPlayer )
call SetCameraPositionForPlayer(whichPlayer, rootX, rootY)
call SetCameraQuickPositionForPlayer(whichPlayer, rootX, rootY)
elseif (id == 'e00R') then
call CreateUnitAtLoc(whichPlayer, 'e003', rootLoc, bj_UNIT_FACING)
call SelectUnitForPlayerSingle( FirstOfGroup(GetUnitsOfPlayerAndTypeId(whichPlayer, 'e003')), whichPlayer )
call SetCameraPositionForPlayer(whichPlayer, rootX, rootY)
call SetCameraQuickPositionForPlayer(whichPlayer, rootX, rootY)
elseif (id == 'e00Q') then
call CreateUnitAtLoc(whichPlayer, 'e004', rootLoc, bj_UNIT_FACING)
call SelectUnitForPlayerSingle( FirstOfGroup(GetUnitsOfPlayerAndTypeId(whichPlayer, 'e004')), whichPlayer )
call SetCameraPositionForPlayer(whichPlayer, rootX, rootY)
call SetCameraQuickPositionForPlayer(whichPlayer, rootX, rootY)
endif
//cleanup
call KillUnit(root)
call RemoveUnit(root)
set root = null
call DestroyGroup(roots)
set roots= null
endfunction
//===========================================================================
function InitTrig_Hes_Baaaaack takes nothing returns nothing
set gg_trg_Hes_Baaaaack = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Hes_Baaaaack, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Hes_Baaaaack, Condition( function Trig_Hes_Baaaaack_Conditions ) )
call TriggerAddAction( gg_trg_Hes_Baaaaack, function Trig_Hes_Baaaaack_Actions )
endfunction
It compiles fine, but in game, when the script is called, it says that root is not initialized. Isn't that what I did when I declared it and then set it with this? "set root = GroupPickRandomUnit(roots)"