Hello everybody, I'm new to scripting in JASS but I'm a Sophmore in Computer Science and have previous coding experience in Java and am looking to try my hand at JASS. The following code is what I hope to expand to be the movement code for a tower wars I'm creating.
JASS:
// Checks if the entering unit is not owned by a given player and if it is not unit u000
function Trig_Conditions takes nothing returns boolean
if ( GetOwningPlayer(GetEnteringUnit()) != Player(0) ) then
return false
endif
if ( GetUnitTypeId(GetEnteringUnit()) != 'u000' ) then
return false
endif
return true
endfunction
// Moves the unit from the start location to the provided rect and adds the custom value of the unit
// to the income array for the player
function Trig_Move_Start_Actions takes rect r returns nothing
if ( GetUnitTypeId(GetEnteringUnit()) != 'u000' ) then
call IssuePointOrderLoc( GetEnteringUnit(), "move", GetRectCenter(r) )
endif
if ( Trig_Conditions() ) then
set udg_Income[GetPlayerId(GetOwningPlayer(GetEnteringUnit()))] = ( udg_Income[GetPlayerId(GetOwningPlayer(GetEnteringUnit()))] + GetUnitUserData(GetEnteringUnit()) )
endif
endfunction
//Moves the unit from the rect it entered to the given rect
function Trig_Move_Actions takes rect r returns nothing
if ( GetUnitTypeId(GetEnteringUnit()) != 'u000' ) then
call IssuePointOrderLoc( GetEnteringUnit(), "move", GetRectCenter(r) )
endif
endfunction
//===========================================================================
function InitTrig_Move takes nothing returns nothing
// Initializes player 1's rects and sets them to listen for entering units
set gg_trg_P1S = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_P1S, gg_rct_P1S )
call TriggerAddAction( gg_trg_P1S, function Trig_Move_Start_Actions )
set gg_trg_P1M1 = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_P1M1, gg_rct_P1M1 )
call TriggerAddAction( gg_trg_P1M1, function Trig_Move_Actions)
endfunction
Last edited: