HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Event Query Regarding Variable Use

03-13-2006, 06:53 AM#1
Azazel_
Question
Will gg_trg_M242_Disassembly fire n times if I assemble and disassemble it n times, or just once as it should?

Collapse JASS:
call TriggerRegisterUnitEvent( gg_trg_M242_Disassembly, udg_M242Chaingun, EVENT_UNIT_SPELL_FINISH )

=========================================================

Collapse JASS:
function M242AssemblyConditions takes nothing returns boolean
    local integer i = GetItemTypeId(GetManipulatedItem())
    return (i=='I00Q' or i=='I00R' or i=='I00P' or i=='I00S')
endfunction

function M242Assembly takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local rect r
    local player p = GetOwningPlayer(u)
    local integer i = GetConvertedPlayerId(p)
    local integer A = 1
    if (blahblahblah) then
        call DisableTrigger(GetTriggeringTrigger())
        loop
            exitwhen A > 4
            call RemoveItem( GetItemOfTypeFromUnitBJ(u, udg_M242Components[A]) )
            set A = A + 1
        endloop
        set udg_M242Chaingun = CreateUnit(p,'h00D',x,y,0.0)
        call SetUnitState(udg_M242Chaingun, UNIT_STATE_MANA, udg_M242Rounds)
        set r = Rect( x-200, y-200, x+200, y+200 )
        call TriggerRegisterEnterRectSimple( gg_trg_M242_Operate, r )
        call TriggerRegisterLeaveRectSimple( gg_trg_M242_Stop, r )
        call TriggerRegisterUnitEvent( gg_trg_M242_Disassembly, udg_M242Chaingun, EVENT_UNIT_SPELL_FINISH )
        call StartSound(gg_snd_ALICEBeep)
        call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 10, "|cfff3ad00ALICE|r : M242 Chaingun assembled." )
        set udg_M242Operator = GetTriggerUnit()
        set udg_M242Active = true
        set udg_Reloading[i] = 4
        set udg_DMKills[1] = udg_DMKills[1] + 1
        if (udg_DMKills[1]==1 and udg_Mode==1) then
            set i = 1
            call StartSound(gg_snd_ALICEBeep)
            call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 10.00, "M242 Chaingun successfully built." )
            loop
                exitwhen i > udg_InitialPlayers
                set udg_Experience[udg_Sorted[i]] = udg_Experience[udg_Sorted[i]] + 100
                set i = i + 1
            endloop
        endif
        call EnableTrigger(gg_trg_M242_Ammunition_System)
        call EnableTrigger(gg_trg_M242_Ammunition_Feed)
    endif
endfunction

//===========================================================================
function InitTrig_M242_Assembly takes nothing returns nothing
    set gg_trg_M242_Assembly = CreateTrigger()
    call TriggerAddCondition( gg_trg_M242_Assembly, Condition( function M242AssemblyConditions ) )
    call TriggerAddAction( gg_trg_M242_Assembly, function M242Assembly )
endfunction

function M242Disassembly takes nothing returns nothing
    local real x = GetUnitX(udg_M242Chaingun)
    local real y = GetUnitY(udg_M242Chaingun)
    if (GetSpellAbilityId() == 'A053') then
        set udg_M242Rounds = GetUnitState(udg_M242Chaingun, UNIT_STATE_MANA)
        call CreateItem('I00Q',x,y)
        call CreateItem('I00R',x,y)
        call CreateItem('I00P',x,y)
        if (udg_EngineerPresent==false) then
            call CreateItem('I00S',x,y)
        endif
        call KillUnit(udg_M242Chaingun)
        call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 10, "M242 Chaingun disassembled." )
        set udg_M242Active = false
        set udg_M242Operator = null
        call EnableTrigger(gg_trg_M242_Assembly)
    endif
endfunction

//===========================================================================
function InitTrig_M242_Disassembly takes nothing returns nothing
    set gg_trg_M242_Disassembly = CreateTrigger()
    call TriggerAddAction( gg_trg_M242_Disassembly, function M242Disassembly )
endfunction