HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Some jass code that likes to crash

11-30-2004, 02:49 PM#1
Strategy Master
The following code likes to crash the editor whenever the jass trigger is enabled.

Code:
function Trig_Chanelling_Spells_Copy_Actions takes nothing returns nothing
    local unit udg_UNITBlizzardCaster
    local unit UNITDeathCaster
    local integer INTB
    local integer INTBend
    local integer INTD
    local integer INTDend
    local rect REGIONEffect
     
    if ( Trig_Chanelling_Spells_Copy_Func009C() ) then
        set REGIONEffect = RectFromCenterSizeBJ(GetSpellTargetLoc(), 512.00, 512.00)
        set udg_UNITBlizzardCaster = GetSpellAbilityUnit()
         
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 5
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            call CreateNUnitsAtLoc( 1, 'n008', Player(PLAYER_NEUTRAL_PASSIVE), GetRandomLocInRect(REGIONEffect), bj_UNIT_FACING )
            call SetUnitAnimationWithRarity( GetLastCreatedUnit(), "Stand", RARITY_FREQUENT )
            call UnitApplyTimedLifeBJ( 11.00, 'BTLF', GetLastCreatedUnit() )
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
         
        call TriggerSleepAction( 1.00 )
         
        set INTB = 1
        set INTBend = 10
        loop
        exitwhen INTB > INTBend
        if ( ( GetUnitStateSwap(UNIT_STATE_MANA, udg_UNITBlizzardCaster) >= 25.00 ) and ( GetUnitUserData(udg_UNITBlizzardCaster) == 8 ) ) then
        call SetUnitManaBJ( udg_UNITBlizzardCaster, ( GetUnitStateSwap(UNIT_STATE_MANA, udg_UNITBlizzardCaster) - 25.00 ) )
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 5
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            call CreateNUnitsAtLoc( 1, 'n008', Player(PLAYER_NEUTRAL_PASSIVE), GetRandomLocInRect(REGIONEffect), bj_UNIT_FACING )
            call SetUnitAnimationWithRarity( GetLastCreatedUnit(), "Stand", RARITY_FREQUENT )
            call UnitApplyTimedLifeBJ( 11.00, 'BTLF', GetLastCreatedUnit() )
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
        call TriggerSleepAction( 1.00 )
         
        else
        call IssueImmediateOrderBJ( udg_UNITBlizzardCaster, "stop" )
        endif
         
        set INTB = INTB + 1
        endloop
    else
         
         
         
        if ( Trig_Chanelling_Spells_Copy_Func009Func006C() ) then
            set REGIONEffect = RectFromCenterSizeBJ(GetSpellTargetLoc(), 512.00, 512.00)
            set UNITDeathCaster = GetSpellAbilityUnit()
             
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 5
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                call CreateNUnitsAtLoc( 1, 'n007', Player(PLAYER_NEUTRAL_PASSIVE), GetRandomLocInRect(REGIONEffect), bj_UNIT_FACING )
                call SetUnitAnimationWithRarity( GetLastCreatedUnit(), "Stand", RARITY_FREQUENT )
                call UnitApplyTimedLifeBJ( 11.00, 'BTLF', GetLastCreatedUnit() )
                set bj_forLoopAIndex = bj_forLoopAIndex + 1
            endloop
             
            call TriggerSleepAction( 1.00 )
             
             
            set INTD = 1
            set INTDend = 10
            loop
            exitwhen INTD > INTDend
            if ( ( GetUnitStateSwap(UNIT_STATE_MANA, UNITDeathCaster) >= 25.00 ) and ( GetUnitUserData(UNITDeathCaster) == 8 ) ) then
            call SetUnitManaBJ( UNITDeathCaster, ( GetUnitStateSwap(UNIT_STATE_MANA, UNITDeathCaster) - 25.00 ) )
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 5
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                call CreateNUnitsAtLoc( 1, 'n007', Player(PLAYER_NEUTRAL_PASSIVE), GetRandomLocInRect(REGIONEffect), bj_UNIT_FACING )
                call SetUnitAnimationWithRarity( GetLastCreatedUnit(), "Stand", RARITY_FREQUENT )
                call UnitApplyTimedLifeBJ( 11.00, 'BTLF', GetLastCreatedUnit() )
                set bj_forLoopAIndex = bj_forLoopAIndex + 1
            endloop
            call TriggerSleepAction( 1.00 )
             
            else
            call IssueImmediateOrderBJ( UNITDeathCaster, "stop" )
            endif
             
            INTD = INTD + 1
            endloop
        else
            call DoNothing(  )
        endif
    endif
endfunction 

Now i have another peice of code almost exactly the same as this. And this code does not crash.

Code:
function Trig_Chanelling_Spells_Copy_Actions takes nothing returns nothing
    local unit udg_UNITBlizzardCaster
    local unit UNITDeathCaster
    local integer INTC
    local integer INTCend
    local integer INTD
    local integer INTDend
    local rect REGIONDeath
    
    if ( Trig_Chanelling_Spells_Copy_Func009C() ) then
        set udg_UNITBlizzardCaster = GetSpellAbilityUnit()
        set REGIONDeath = RectFromCenterSizeBJ(GetSpellTargetLoc(), 512.00, 512.00)
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 5
        loop
           exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
           call CreateNUnitsAtLoc( 1, 'n008', Player(PLAYER_NEUTRAL_PASSIVE), GetRandomLocInRect(REGIONDeath), bj_UNIT_FACING )
           call SetUnitAnimationWithRarity( GetLastCreatedUnit(), "Stand", RARITY_FREQUENT )
           call UnitApplyTimedLifeBJ( 11.00, 'BTLF', GetLastCreatedUnit() )
           set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
        call TriggerSleepAction( 1 )
        set INTD = 1
        set INTDend = 10
        loop
            exitwhen INTD > INTDend
            if ( ( GetUnitStateSwap(UNIT_STATE_MANA, udg_UNITBlizzardCaster) >= 25.00 ) and ( GetUnitUserData(udg_UNITBlizzardCaster) == 8 ) ) then
                call SetUnitManaBJ( udg_UNITBlizzardCaster, ( GetUnitStateSwap(UNIT_STATE_MANA, udg_UNITBlizzardCaster) - 25.00 ) )
                set bj_forLoopAIndex = 1
                set bj_forLoopAIndexEnd = 5
                loop
                   exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                   call CreateNUnitsAtLoc( 1, 'n008', Player(PLAYER_NEUTRAL_PASSIVE), GetRandomLocInRect(REGIONDeath), bj_UNIT_FACING )
                   call SetUnitAnimationWithRarity( GetLastCreatedUnit(), "Stand", RARITY_FREQUENT )
                   call UnitApplyTimedLifeBJ( 11.00, 'BTLF', GetLastCreatedUnit() )
                   set bj_forLoopAIndex = bj_forLoopAIndex + 1
                endloop
                call TriggerSleepAction( 1 )
            else
                call IssueImmediateOrderBJ( udg_UNITBlizzardCaster, "stop" )
            endif
            set INTD = INTD + 1
        endloop
    else
        if ( Trig_Chanelling_Spells_Copy_Func009Func006C() ) then
            set UNITDeathCaster = GetSpellAbilityUnit()
            set REGIONDeath = RectFromCenterSizeBJ(GetSpellTargetLoc(), 512.00, 512.00)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 5
            loop
              exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
              call CreateNUnitsAtLoc( 1, 'n007', Player(PLAYER_NEUTRAL_PASSIVE), GetRandomLocInRect(REGIONDeath), bj_UNIT_FACING )
              call SetUnitAnimationWithRarity( GetLastCreatedUnit(), "Stand", RARITY_FREQUENT )
              call UnitApplyTimedLifeBJ( 11.00, 'BTLF', GetLastCreatedUnit() )
              set bj_forLoopAIndex = bj_forLoopAIndex + 1
            endloop
            call TriggerSleepAction( 1 )
            set INTC = 1
            set INTCend = 10
            loop
                exitwhen INTC > INTCend
                if ( ( GetUnitStateSwap(UNIT_STATE_MANA, UNITDeathCaster) >= 25.00 ) and ( GetUnitUserData(UNITDeathCaster) == 8 ) ) then
                    call SetUnitManaBJ( UNITDeathCaster, ( GetUnitStateSwap(UNIT_STATE_MANA, UNITDeathCaster) - 25.00 ) )
                    set bj_forLoopAIndex = 1
                    set bj_forLoopAIndexEnd = 5
                    loop
                       exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                       call CreateNUnitsAtLoc( 1, 'n007', Player(PLAYER_NEUTRAL_PASSIVE), GetRandomLocInRect(REGIONDeath), bj_UNIT_FACING )
                       call SetUnitAnimationWithRarity( GetLastCreatedUnit(), "Stand", RARITY_FREQUENT )
                       call UnitApplyTimedLifeBJ( 11.00, 'BTLF', GetLastCreatedUnit() )
                       set bj_forLoopAIndex = bj_forLoopAIndex + 1
                    endloop
                    call TriggerSleepAction( 1 )
                else
                    call IssueImmediateOrderBJ( UNITDeathCaster, "stop" )
                endif
                set INTC = INTC + 1
            endloop
        else
        endif
    endif
endfunction 

I tried to find what difference is causing editor to crash but cannot. If anyone can find it. I will be most appreciated.

EDIT - Cooler jass found a parse error in the first lot of code about line 90 - 92 Around INTD. Don't know what that means.
11-30-2004, 05:20 PM#2
KaTTaNa
Code:
            [color=Red]INTD = INTD + 1[/color]
            endloop
        else
            call DoNothing(  )
        endif
    endif
endfunction
You forgot the "set" keyword there.
11-30-2004, 06:06 PM#3
Strategy Master
lol. thanx.