Spell crashes the game

BlueMirage

Trust, but doubt.
Reaction score
39
The following spell crashes the game 1 second after it has been activated.

Spell description:
As long as the skill is toggled on, the hero gains a 15/25/35% MS boost (Done through adding an aura skill), regenerates 10% of its max mana each second, and loses 10% of its current health per second. Also, the hero has no cooldowns on its other skills.

JASS:
function Trig_Adrenaline_Rush_On_Conditions takes nothing returns boolean
    return GetIssuedOrderId() == OrderId("immolation")
endfunction

function Adrenaline_Off_Con takes nothing returns boolean
    return GetIssuedOrderId() == OrderId("unimmolation")
endfunction

function Adrenaline_Off_Actions takes nothing returns nothing
    local trigger trig = GetTriggeringTrigger()
    local integer i = GetHandleId(trig)
    local timer tim = LoadTimerHandle(udg_Hashtable, i, 0)
    local trigger trig2 = LoadTriggerHandle(udg_Hashtable, i, 3)

    call TriggerRemoveCondition(trig, LoadTriggerConditionHandle(udg_Hashtable, i, 1))
    call TriggerRemoveAction(trig, LoadTriggerActionHandle(udg_Hashtable, i, 2))

    call TriggerRemoveCondition(trig2, LoadTriggerConditionHandle(udg_Hashtable, i, 4))
    call TriggerRemoveAction(trig2, LoadTriggerActionHandle(udg_Hashtable, i, 5))

    call SetUnitAbilityLevel(LoadUnitHandle(udg_Hashtable, i, 6), 'A000', 1)

    call PauseTimer(tim)
    call DestroyTimer(tim)
    call FlushChildHashtable(udg_Hashtable, GetHandleId(tim))
    call DestroyTrigger(trig)
    call FlushChildHashtable(udg_Hashtable, i)
    call DestroyTrigger(trig2)
    set tim = null
    set trig = null
    set trig2 = null
endfunction

function Adrenaline_Cast_Con takes nothing returns boolean
    return GetSpellAbilityId() != 'A00G'
endfunction

function Adrenaline_Cast_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer spell = GetSpellAbilityId()
    local integer i = GetUnitAbilityLevel(u, spell)
    call UnitRemoveAbility(u, spell)
    call UnitAddAbility(u, spell)
    call SetUnitAbilityLevel(u, spell, i)
    set u = null
endfunction

function AdrenalineLoop takes nothing returns nothing
    local unit u = LoadUnitHandle(udg_Hashtable, GetHandleId(GetExpiredTimer()), 0)
    local real hp = GetUnitState(u, UNIT_STATE_LIFE)
    call SetUnitAbilityLevel(u, 'A000', GetUnitAbilityLevel(u, 'A00G') + 1)

    if hp > 10 then
        call SetUnitState(u, UNIT_STATE_LIFE, hp * 0.9)
    endif

    call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA) + GetUnitState(u, UNIT_STATE_MAX_MANA) * 0.10)

    set u = null
endfunction

function Trig_Adrenaline_Rush_On_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local trigger trig = CreateTrigger()
    local trigger trig2 = CreateTrigger()
    local timer tim = CreateTimer()
    local integer i = GetHandleId(trig)

    call TriggerRegisterUnitEvent(trig, u, EVENT_UNIT_ISSUED_ORDER)
    call SaveTriggerConditionHandle(udg_Hashtable, i, 1, TriggerAddCondition(trig, Condition(function Adrenaline_Off_Con)))
    call SaveTriggerActionHandle(udg_Hashtable, i, 2, TriggerAddAction(trig, function Adrenaline_Off_Actions))
    call SaveTimerHandle(udg_Hashtable, i, 0, tim)

    call TriggerRegisterUnitEvent(trig2, u, EVENT_UNIT_SPELL_CAST)
    call SaveTriggerHandle(udg_Hashtable, i, 3, trig2)
    call SaveTriggerConditionHandle(udg_Hashtable, i, 4, TriggerAddCondition(trig2, Condition(function Adrenaline_Cast_Con)))
    call SaveTriggerActionHandle(udg_Hashtable, i, 5, TriggerAddAction(trig2, function Adrenaline_Cast_Actions))

    call SaveUnitHandle(udg_Hashtable, i, 6, u)

    call TimerStart(tim, 1, true, function AdrenalineLoop)    
    call SaveUnitHandle(udg_Hashtable, GetHandleId(tim), 0, u)

    call UnitAddAbility(u, 'A000')
    call SetUnitAbilityLevel(u, 'A000', GetUnitAbilityLevel(u, 'A00G') + 1)
endfunction

//===========================================================================
function InitTrig_Adrenaline_Rush takes nothing returns nothing
endfunction


JASS:
function Start_Hero takes nothing returns nothing
    local trigger t = CreateTrigger()

     //Omitted trigger info

    //udg_TempUnit is set somewhere else.

    call TriggerRegisterUnitEvent(t4, udg_TempUnit, EVENT_UNIT_ISSUED_ORDER)
    call TriggerAddCondition(t4, Condition(function Trig_Adrenaline_Rush_On_Conditions))
    call TriggerAddAction(t4, function Trig_Adrenaline_Rush_On_Actions)

    call UnitAddAbility(udg_TempUnit, 'A000')
endfunction

function InitTrig_Start_Hero takes nothing returns nothing
endfunction
 

Bribe

vJass errors are legion
Reaction score
67
What kind of debugs have you performed?

If the hashtable isn't getting initialized, that might cause a problem.

Since this is vanilla JASS, you can have a wide range of problems that normal WE wouldn't catch, but NewGen would. My guess is the problem lies elsewhere.

I recommend using GetWidgetLife/SetWidgetLife for the health (faster).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top