HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

local variables

07-02-2005, 04:08 PM#1
mogmiester
could someone tell me how to declare local units and points? I have this code, but it doesnt want to work
Code:
function Trig_Create_Monster_1_Actions takes nothing returns nothing
local unit created
local point create
local effect cool
    set create = GetRandomLocInRect(gg_rct_Monster_Spawn_Create1)
    call CreateNUnitsAtLoc( 1, 'ucs3', Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_create, bj_UNIT_FACING )
    set created = GetLastCreatedUnit()
    call AddSpecialEffectTargetUnitBJ( "origin", udg_created, "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl" )
    set cool = GetLastCreatedEffectBJ()
    call TriggerSleepAction( 2 )
    call DestroyEffectBJ( cool )
    call RemoveLocation( create )
endfunction

//===========================================================================
function InitTrig_Create_Monster_1 takes nothing returns nothing
    set gg_trg_Create_Monster_1 = CreateTrigger(  )
    call DisableTrigger( gg_trg_Create_Monster_1 )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Create_Monster_1, 3.00 )
    call TriggerAddAction( gg_trg_Create_Monster_1, function Trig_Create_Monster_1_Actions )
endfunction
07-02-2005, 05:34 PM#2
Guest
local variables aren't global, so you don't need the udg_ prefix. Delete those and your trigger should work fine.

Code:
function Trig_Create_Monster_1_Actions takes nothing returns nothing
local unit created
local point create
local effect cool
    set create = GetRandomLocInRect(gg_rct_Monster_Spawn_Create1)
    call CreateNUnitsAtLoc( 1, 'ucs3', Player(PLAYER_NEUTRAL_AGGRESSIVE), [color="Red"]udg_[/color]create, bj_UNIT_FACING )
    set created = GetLastCreatedUnit()
    call AddSpecialEffectTargetUnitBJ( "origin", [color="red"]udg_[/color]created, "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl" )
    set cool = GetLastCreatedEffectBJ()
    call TriggerSleepAction( 2 )
    call DestroyEffectBJ( cool )
    call RemoveLocation( create )
endfunction

//===========================================================================
function InitTrig_Create_Monster_1 takes nothing returns nothing
    set gg_trg_Create_Monster_1 = CreateTrigger(  )
    call DisableTrigger( gg_trg_Create_Monster_1 )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Create_Monster_1, 3.00 )
    call TriggerAddAction( gg_trg_Create_Monster_1, function Trig_Create_Monster_1_Actions )
endfunction
07-02-2005, 06:10 PM#3
mogmiester
oops lol... but now there are problems with this
Code:
function Trig_Create_Monster_1real_Actions takes nothing returns nothing
    local boolean vartrue = false
    local location create = GetRandomLocInRect(gg_rct_Monster_Spawn_Create1)
    local location attack = GetRectCenter(gg_rct_Monster_Spawn_1)
    local unit created = CreateNUnitsAtLoc( 1, 'ucs1', Player(PLAYER_NEUTRAL_AGGRESSIVE), create , bj_UNIT_FACING )
    local effect cool = AddSpecialEffectTargetUnitBJ( "origin", created, "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl" )
    call IssuePointOrderLocBJ( created, "attack", attack )
    set udg_MonsterCreated[0] = ( udg_MonsterCreated[0] + 1 )
    if ( udg_MonsterCreated[0] == 20 ) then
        set vartrue = true
    endif
    call TriggerSleepAction( 2 )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    if ( vartrue == true ) then
        call DestroyTrigger( gg_trg_Monster1on )
        call DestroyTrigger( gg_trg_Monster1off )
        call DestroyTrigger( gg_trg_Create_Monster_1real )
    endif
endfunction

//===========================================================================
function InitTrig_Create_Monster_1real takes nothing returns nothing
    set gg_trg_Create_Monster_1real = CreateTrigger(  )
    call DisableTrigger( gg_trg_Create_Monster_1real )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Create_Monster_1real, 3.00 )
    call TriggerAddAction( gg_trg_Create_Monster_1real, function Trig_Create_Monster_1real_Actions )
endfunction
07-02-2005, 07:48 PM#4
Guest
Code:
    local unit created = CreateNUnitsAtLoc( 1, 'ucs1', Player(PLAYER_NEUTRAL_AGGRESSIVE), create , bj_UNIT_FACING )
The problem is this: CreateNUnitsAtLoc() returns a group not a unit. Try replacing this line with:
Code:
    local unit created = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_AGGRESSIVE), 'ucs1', create , bj_UNIT_FACING )
That should fix it.
07-02-2005, 08:57 PM#5
mogmiester
ok, thx very much rep given