Warcraft III resources & community, 2003–2006 · archived

Jass Script Problem

4 posts
#1

Jass Script Problem

Ok im not quite sure how to use the actions "call toforce" and set function parameters. Im pretty sure im making some stupid mistake, but as im fairly inexperienced in jass, i would appreciate any help. the error im getting in the quoted lines are "expected '"



function random_hero takes rect selection returns
nothing
local player p = GetEnumPlayer()
local unit r = GroupPickRandomUnit(GetUnitsInRectOfPlayer(selection, Player(PLAYER_NEUTRAL_PASSIVE)))
if ( udg_Hero_Picking_Status[GetConvertedPlayerId(p)] == false ) then
set udg_Hero_Picking_Status[GetConvertedPlayerId(p)] = true
call SetUnitPositionLoc( r, GetPlayerStartLocationLoc(p) )
call SetUnitOwner( r, p, true )
call PanCameraToTimedLocForPlayer( p, GetUnitLoc(r), 0.50 )
set r = null
set p = null
else
endif
endfunction

function Trig_Hero_Selection_End_FuncRemoveUnit takes nothing returns nothing
call RemoveUnit( GetEnumUnit() )
endfunction

function Trig_Hero_Selection_End_Actions takes nothing returns nothing
call TriggerSleepAction( 1.00 )
call DestroyTimerDialogBJ( GetLastCreatedTimerDialogBJ() )

call ForForce( udg_Alliance, function random_hero (gg_rct_Allied_Region_Selection))
call ForForce( udg_Undead, function random_hero (gg_rct_Undead_Region_Selection))

call ForGroup( GetUnitsInRectAll(gg_rct_Allied_Region_Selection), function Trig_Hero_Selection_End_FuncRemoveUnit )
call ForGroup( GetUnitsInRectAll(gg_rct_Undead_Region_Selection), function Trig_Hero_Selection_End_FuncRemoveUnit )
call DestroyTrigger( gg_trg_Hero_Selection_1)
call DestroyTrigger( gg_trg_Hero_Selection_2)
call DestroyTrigger( GetTriggeringTrigger() )
endfunction

//===========================================================================
function InitTrig_Hero_Selection_End takes nothing returns nothing
set gg_trg_Hero_Selection_End = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Hero_Selection_End, udg_Hero_Selection_Timer )
call TriggerAddAction( gg_trg_Hero_Selection_End, function Trig_Hero_Selection_End_Actions )
endfunction
#2
i think i got where the error is.




if ( udg_Hero_Picking_Status[GetConvertedPlayerId(p)] == false ) then
set udg_Hero_Picking_Status[GetConvertedPlayerId(p)] = true
call SetUnitPositionLoc( r, GetPlayerStartLocationLoc(p) )
call SetUnitOwner( r, p, true )
call PanCameraToTimedLocForPlayer( p, GetUnitLoc(r), 0.50 )
set r = null
set p = null
else // here you tell to do else actions,but is empty!!! this could be the problem.
endif
#3
Thats not the problem, you dont have to tell it to do anything, if you leave it blank then nothing happens. Thanks for your reply though.
#4
call ForForce( udg_Alliance, function random_hero (gg_rct_Allied_Region_Selection))
call ForForce( udg_Undead, function random_hero (gg_rct_Undead_Region_Selection))


You can't use function that requires a parameter on ForForce, since ForForce expected a paramater as a code.

Oh, and it should be


if true then
....
....
endif


rather than,


if true then
....
....
else
endif


If you don't need 'else'.