HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Local variables (GUI) inside loops

12-23-2006, 12:01 AM#1
Pyrogasm
I'm using the local point "Infusion_Move_Point" inside a loop. However, it keeps telling me "expected an endloop" when I try to enable the trigger. Can someone please inform me why?
Trigger:
Attack
Collapse Events
Unit - A unit Is attacked
Collapse Conditions
((Triggering unit) is A structure) Equal to False
Collapse Or - Any (Conditions) are true
Collapse Conditions
((Attacking unit) has buff Power Infusion (Level 1)) Equal to True
((Attacking unit) has buff Power Infusion (Level 2)) Equal to True
((Attacking unit) has buff Power Infusion (Level 3)) Equal to True
Collapse Actions
Set Infusion_Attack_Chance = (Random integer number between 1 and 100)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Attacking unit) has buff Power Infusion (Level 1)) Equal to True
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Infusion_Attack_Chance Less than or equal to 100
Collapse Then - Actions
Unit - Turn collision for (Triggering unit) Off
Collapse For each (Integer A) from 1 to 10, do (Actions)
Collapse Loop - Actions
Custom script: local point udg_Infusion_Move_Point
Set TempPoint = (Position of (Triggering unit))
Set Infusion_Move_Point = (TempPoint offset by 10.00 towards ((Facing of (Triggering unit)) - 180.00) degrees)
Custom script: call RemoveLocation( udg_TempPoint )
Unit - Move (Triggering unit) instantly to Infusion_Move_Point
Custom script: call RemoveLocation( udg_Infusion_Move_Point )
Wait 0.01 seconds
Custom script: set udg_Infusion_Move_Point = null
Unit - Turn collision for (Triggering unit) On
Collapse Else - Actions
Do nothing
Collapse Else - Actions
Do nothing
And converted to custom script:
Collapse JASS:
function Trig_Attack_Copy_Func004C takes nothing returns boolean
    if ( ( UnitHasBuffBJ(GetAttacker(), 'B001') == true ) ) then
        return true
    endif
    if ( ( UnitHasBuffBJ(GetAttacker(), 'B002') == true ) ) then
        return true
    endif
    if ( ( UnitHasBuffBJ(GetAttacker(), 'B000') == true ) ) then
        return true
    endif
    return false
endfunction

function Trig_Attack_Copy_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == false ) ) then
        return false
    endif
    if ( not Trig_Attack_Copy_Func004C() ) then
        return false
    endif
    return true
endfunction

function Trig_Attack_Copy_Func002Func002C takes nothing returns boolean
    if ( not ( udg_Infusion_Attack_Chance <= 100 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Attack_Copy_Func002C takes nothing returns boolean
    if ( not ( UnitHasBuffBJ(GetAttacker(), 'B001') == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Attack_Copy_Actions takes nothing returns nothing
    set udg_Infusion_Attack_Chance = GetRandomInt(1, 100)
    if ( Trig_Attack_Copy_Func002C() ) then
        if ( Trig_Attack_Copy_Func002Func002C() ) then
            call SetUnitPathing( GetTriggerUnit(), false )
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 10
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                local point udg_Infusion_Move_Point
                set udg_TempPoint = GetUnitLoc(GetTriggerUnit())
                set udg_Infusion_Move_Point = PolarProjectionBJ(udg_TempPoint, 10.00, ( GetUnitFacing(GetTriggerUnit()) - 180.00 ))
                call RemoveLocation( udg_TempPoint )
                call SetUnitPositionLoc( GetTriggerUnit(), udg_Infusion_Move_Point )
                call RemoveLocation( udg_Infusion_Move_Point )
                call TriggerSleepAction( 0.01 )
                set udg_Infusion_Move_Point = null
                set bj_forLoopAIndex = bj_forLoopAIndex + 1
            endloop
            call SetUnitPathing( GetTriggerUnit(), true )
        else
            call DoNothing(  )
        endif
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_Attack_Copy takes nothing returns nothing
    set gg_trg_Attack_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack_Copy, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Attack_Copy, Condition( function Trig_Attack_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Attack_Copy, function Trig_Attack_Copy_Actions )
endfunction

12-23-2006, 12:07 AM#2
Thunder_Eye
locals has to be defined at the top of the trigger
(before "Set Infusion_Attack_Chance = (Random integer number between 1 and 100)")
12-23-2006, 12:11 AM#3
PipeDream
  • Local variables can only be declared at the beginning of a function. Move it up.
  • Change "point" to "location"
  • PJASS should compile on mac no problem.