HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

TriggerRegisterEnterRegion freezes map

04-04-2007, 02:10 AM#1
Pyrogasm
For some reason, the event that triggers when a unit enters the map causes the map to lock up whenever it fires.

Essentially, the spell is supposed to freeze every unit on the map and deal damage to each one. The freeze lasts until the hero stops channeling. Additionally, units that enter the map (it's for a hero-defence style map) whilst the hero is still channeling should be slowed via a dummy slow ability.

At first I thought it was because of the sheer number of units being spawned, but it locks up the game even when only one unit is created. Any ideas why?

Collapse JASS:
//######################################################################
//                          Absolute Zero                              #
//                           By Pyrogasm                               #
//          Made for Gaist Heidegger's MG Huckleberry - TS Hell        #
//                                                                     #
//                    You need:                                        #
//                    Absolute_Zero_Caster  <Unit>                     #
//                    Absolute_Zero_Weather <Weather Effect>           #
//                    Absolute_Zero_Boolean <Boolean>                  #
//                    Absolute_Zero_Group   <Unit Group>               #
//                    "Absolute Zero"       <This Trigger              #
//                                                                     #
//######################################################################


//**********************************************************************
//                       Configuration Section                         *
//**********************************************************************

constant function Absolute_Zero_Ability_Id takes nothing returns integer
    return 'A002'
endfunction

constant function Absolute_Zero_Dummy_Stun_Id takes nothing returns integer
    return 'A000'
endfunction

constant function Absolute_Zero_Dummy_Slow_Id takes nothing returns integer
    return 'A001'
endfunction

constant function Absolute_Zero_Dummy_Stun_Buff_Id takes nothing returns integer
    return 'B000'
endfunction

constant function Absolute_Zero_Dummy_Slow_Buff_Id takes nothing returns integer
    return 'B001'
endfunction

constant function Absolute_Zero_Dummy_Id takes nothing returns integer
    return 'h000'
endfunction

constant function Absolute_Zero_Effect_Path takes nothing returns string
    return "Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl"
endfunction

constant function Absolute_Zero_Effect_Attach takes nothing returns string
    return "origin"
endfunction

constant function Absolute_Zero_Extra_Damage takes nothing returns real
    return 0.40
endfunction

//**********************************************************************
//                            End Config                               *
//**********************************************************************

function Absolute_Zero_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Absolute_Zero_Ability_Id()
endfunction

function Absolute_Zero_Death_Filter takes nothing returns boolean
    return IsUnitInGroup(GetFilterUnit(), udg_Absolute_Zero_Group) and (udg_Absolute_Zero_Boolean)
endfunction

function Absolute_Zero_Animation_Reset takes nothing returns nothing
    local unit U = GetTriggerUnit()
    call GroupRemoveUnit(udg_Absolute_Zero_Group, U)
    call SetUnitTimeScale(U, 1.00)
    set U = null
endfunction

function Absolute_Zero_Filter takes nothing returns boolean
    return (GetWidgetLife(GetFilterUnit()) > 0.405) and (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit()))) and (GetUnitTypeId(GetFilterUnit()) != 'nfgo')
    //Add additional boss-excluding conditions to the above action if necessary; I don't know all the bosses
endfunction

function Absolute_Zero_Start takes nothing returns nothing
    local boolexpr B = Condition(function Absolute_Zero_Filter)
    local group G = GetUnitsInRectMatching(GetPlayableMapRect(), B)
    local unit Caster = GetTriggerUnit()
    local unit U
    local unit U2
    local real X
    local real Y
    local integer Level = GetUnitAbilityLevel(Caster, Absolute_Zero_Ability_Id())

    if udg_Absolute_Zero_Weather == null then
        set udg_Absolute_Zero_Weather = AddWeatherEffect(GetPlayableMapRect(), 'SNbs')
    endif
    set udg_Absolute_Zero_Boolean = true
    set udg_Absolute_Zero_Caster = Caster
    loop
        set U = FirstOfGroup(G)
        exitwhen U == null
        call SetUnitTimeScale(U, 0.00)
        call DestroyEffect(AddSpecialEffectTarget(Absolute_Zero_Effect_Path(), U, Absolute_Zero_Effect_Attach()))
        set X = GetUnitX(U)
        set Y = GetUnitY(U)
        set U2 = CreateUnit(GetOwningPlayer(Caster), Absolute_Zero_Dummy_Id(), X, Y, 0)
        call UnitAddAbility(U2, Absolute_Zero_Dummy_Stun_Id())
        call SetUnitAbilityLevel(U2, Absolute_Zero_Dummy_Stun_Id(), Level)
        call IssueTargetOrder(U2, "thunderbolt", U)
        call UnitApplyTimedLife(U2, 'BTLF', 2.00)
        call GroupAddUnit(udg_Absolute_Zero_Group, U)
        call GroupRemoveUnit(G, U)
    endloop
    call EnableWeatherEffect(udg_Absolute_Zero_Weather, true)

    call DestroyGroup(G)
    set G = null
    set U = null
    set U2 = null
    call DestroyBoolExpr(B)
    set B = null
endfunction

function Absolute_Zero_Stop takes nothing returns nothing
    local unit U = GetTriggerUnit()
    local unit U2
    local boolexpr B = Condition(function Absolute_Zero_Filter)
    local group G = GetUnitsInRectMatching(GetPlayableMapRect(), B)

    call GroupClear(udg_Absolute_Zero_Group)
    loop
        set U2 = FirstOfGroup(G)
        exitwhen U2 == null
        call UnitRemoveAbility(U2, Absolute_Zero_Dummy_Stun_Buff_Id())
        call UnitRemoveAbility(U2, Absolute_Zero_Dummy_Slow_Buff_Id())
        call SetUnitTimeScale(U2, 1.00)
        call GroupRemoveUnit(G, U2)
    endloop
    call EnableWeatherEffect(udg_Absolute_Zero_Weather, false)
    set udg_Absolute_Zero_Boolean = false

    call DestroyGroup(G)
    call DestroyBoolExpr(B)
    set G = null
    set B = null
    set U = null
    set U2 = null
endfunction

function Absolute_Zero_Slow takes nothing returns nothing
    local unit U = GetTriggerUnit()
    local real X = GetUnitX(U)
    local real Y = GetUnitY(U)
    local unit U2 = CreateUnit(GetOwningPlayer(udg_Absolute_Zero_Caster), Absolute_Zero_Dummy_Id(), X, Y, 0)
    local integer Level = GetUnitAbilityLevel(udg_Absolute_Zero_Caster, Absolute_Zero_Ability_Id())

    call PolledWait(GetRandomReal(0.10, 2.00))
    call UnitAddAbility(U2, Absolute_Zero_Dummy_Slow_Id())
    call SetUnitAbilityLevel(U2, Absolute_Zero_Dummy_Slow_Id(), Level)
    call IssueTargetOrder(U2, "slow", U)
    call UnitApplyTimedLife(U2, 'BTLF', 5.00)

    set U = null
    set U2 = null
endfunction

//===========================================================================
function InitTrig_Absolute_Zero takes nothing returns nothing
    local region R = CreateRegion()
    local trigger T = CreateTrigger(  )

    call TriggerRegisterAnyUnitEventBJ(T, EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(T, Condition(function Absolute_Zero_Death_Filter))
    call TriggerAddAction(T, function Absolute_Zero_Animation_Reset)

    set gg_trg_Absolute_Zero = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Absolute_Zero, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Absolute_Zero, Condition(function Absolute_Zero_Conditions))
    call TriggerAddAction(gg_trg_Absolute_Zero, function Absolute_Zero_Start)

    set T = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(T, EVENT_PLAYER_UNIT_SPELL_ENDCAST)
    call TriggerRegisterAnyUnitEventBJ(T, EVENT_PLAYER_UNIT_SPELL_FINISH)
    call TriggerAddCondition(T, Condition(function Absolute_Zero_Conditions))
    call TriggerAddAction(T, function Absolute_Zero_Stop)

    set T = CreateTrigger(  )
    call RegionAddRect(R, GetPlayableMapRect())
    call TriggerRegisterEnterRegion(T, R, Condition(function Absolute_Zero_Filter))
    call TriggerAddAction(T, function Absolute_Zero_Slow)

    set T = null
endfunction
04-04-2007, 03:41 AM#2
Vexorian
This sounds as if the event was moving the unit out of the region and then into the region again over and over making the trigger run over and over.

If this happens turn off one of the triggers when you move the unit
04-04-2007, 03:48 AM#3
Pyrogasm
ROFLs. I found what I did. Turns out that I somehow combined the event/condition lines into this:
Collapse JASS:
call TriggerRegisterEnterRegion(T, R, Condition(function Absolute_Zero_Filter))

My question is: Why did WE parse that?


EDIT: WOW. Note to self: don't attempt to think in the evening. There's nothing wrong with that line. I'll look into what you're saying, Vex.
04-04-2007, 04:24 AM#4
Pyrogasm
Double-post:

Fix'd it. The condition on the enterrect event was getting all f'd up and I didn't realize it.

So no, there was not an infinite loop.
04-04-2007, 04:25 AM#5
Ammorth
Your not checking if the unit thats created is the dummy caster (atleast I think).
04-04-2007, 04:27 AM#6
Pyrogasm
That I was not, as I just realized.