• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

What's wrong with this trigger?

Status
Not open for further replies.
Level 3
Joined
Sep 9, 2009
Messages
658

JASS:
globals
    hashtable = Omnihash
endglobals

function Omnislash_Loop takes nothing returns nothing
    //Variable Setup
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local unit u = LoadUnitHandle(Omnihash, id, 0)
    local unit uu = LoadUnitHandle(Omnihash, id, 1)
    local real HeroStr = LoadReal(Omnihash, id, 2)
    local integer count = LoadInteger(Omnihash, id, 3)
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real xx = GetUnitX(uu)
    local real yy = GetUnitY(uu)
    local real dx = xx - x
    local real dy = yy - y
    local real dist_check = (dx * dx) + (dy * dy)
    local real angle = 0.7854
    local integer i = 0
    local unit dummy
    local real px
    local real py
    
    call BJDebugMsg("Working!")
    
    if dist_check <= 100 * 100 then
        if count <= 100 then
            call SetUnitFacing(u, bj_RADTODEG * Atan2(dy, dx))
            call SetUnitX(u, x + 100 * Cos(0.349))
            call SetUnitY(u, x + 100 * Sin(0.349))
            set dummy = CreateUnit(GetOwningPlayer(u), 'e000', x, y, GetUnitFacing(u))
            call SetUnitTimeScale(dummy, 3.0)
            call SetUnitVertexColor(dummy, 255, 255, 255, 60)
            call SetUnitFlyHeight(dummy, GetUnitFlyHeight(u), 0)
            call SetUnitFlyHeight(u, GetUnitFlyHeight(u) + 5, 0)
            call SetUnitFlyHeight(uu, GetUnitFlyHeight(u) + 5, 0)
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", u, "origin"))
            call SetUnitAnimation(dummy, "attack")
            call SetUnitAnimation(u, "attack")
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl", uu, "chest"))
            call UnitApplyTimedLife(dummy, 'BTLF', 0.25)
        else
            if count == 101 then
                call SetUnitTimeScale(u, 1.0)
                call SetUnitAnimation(u, "attack alternate")
            elseif count == 116 then
                call SetUnitTimeScale(u, 0.0)
                call SetUnitX(u, x + 100 * Cos(GetUnitFacing(uu) * bj_DEGTORAD))
                call SetUnitY(u, x + 100 * Sin(GetUnitFacing(uu) * bj_DEGTORAD))
                call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", u, "chest"))
            elseif count == 151 then
                call SetUnitTimeScale(u, 1.0)
                call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl", uu, "chest"))
                call SetUnitFlyHeight(u, 0.0, 700)
                call SetUnitFlyHeight(uu, 0.0, 700)
            elseif count == 168 then
                call KillUnit(CreateUnit(GetOwningPlayer(u), 'e001', xx, yy, 270))
                
                loop
                    exitwhen i == 8
                    set i = i + 1
                    set px = xx + 350 * Cos(angle)
                    set py = yy + 350 * Sin(angle)
                    call DestroyEffect(AddSpecialEffect("WaterMagic.mdx", px, py))
                    call DestroyEffect(AddSpecialEffect("IceNova.mdx", px, py))
                    set angle = angle + 0.7854
                endloop
                
                call SetUnitInvulnerable(uu, false)
                call SetUnitPathing(u, true)
                call PauseUnit(u, false)
                call PauseUnit(uu, false)
                call SetUnitInvulnerable(u, false)
                call UnitDamageTarget(u, uu, HeroStr * 8, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null)
                call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl", uu, "chest"))
                call SetUnitAnimation(u, "stand")
                
                call PauseTimer(t)
                call DestroyTimer(t)
                call FlushChildHashtable(Omnihash, id)
            endif
        endif
        call SaveInteger(Omnihash, id, 3, count + 1)
    else
        call DestroyEffect(AddSpecialEffect("BlackBlink.mdx", x, y))
        set dummy = CreateUnit(GetOwningPlayer(u), 'e000', x, y, GetUnitFacing(u))
        call SetUnitTimeScale(dummy, 3.0)
        call SetUnitVertexColor(dummy, 255, 255, 255, 60)
        call SetUnitAnimation(dummy, "spell throw")
        call UnitApplyTimedLife(dummy, 'BTLF', 0.25)
        call SetUnitX(u, x + 20 * Cos(Atan2(dy, dx)))
        call SetUnitY(u, y + 20 * Cos(Atan2(dy, dx)))
    endif
    
    set t = null
    set u = null
    set uu = null
    set dummy = null
endfunction

function Omnislash_Actions takes nothing returns nothing
    //Variable Setup
    local timer t = CreateTimer()
    local integer id = GetHandleId(t)
    local unit u = GetTriggerUnit()
    local unit uu = GetSpellTargetUnit()
    local real HeroStr = GetHeroStr(u, true)
    
    call BJDebugMsg(I2S(GetHandleId(t)))
    
    call UnitAddAbility(u, 'Amrf')
    call UnitAddAbility(uu, 'Amrf')
    call UnitRemoveAbility(u, 'Amrf')
    call UnitRemoveAbility(uu, 'Amrf')
    call PauseUnit(u, true)
    call PauseUnit(uu, true)
    call SetUnitInvulnerable(u, true)
    call SetUnitInvulnerable(uu, true)
    call SetUnitPathing(u, false)
    call SetUnitTimeScale(u, 3.0)
    
    call SaveUnitHandle(Omnihash, id, 0, u)
    call SaveUnitHandle(Omnihash, id, 1, uu)
    call SaveReal(Omnihash, id, 2, HeroStr)
    call SaveInteger(Omnihash, id, 3, 0)
    
    call TimerStart(t, 0.03, true, function Omnislash_Loop)
    
    set t = null
    set u = null
    set uu = null
endfunction

function Omnislash_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A000' then
        call Omnislash_Actions()
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Omnislash takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Omnislash_Conditions ) )
    set t = null
endfunction

Leave optimization comments aside for now. There's a bigger problem I'd like to address.

The timer is created but I don't think it's calling Omnislash_Loop. I'm pretty sure there are no mistypes otherwise the map wouldn't save properly.

Anyway, why isn't Omnislash_Loop being called?

EDIT: I've found that after the values are saved in the hashtable, no other lines are read. Actually, I'm not even sure if the values are saved at the hashtable. The last line I've confirmed to work is SetUnitTimeScale(u, 3.0)

EDIT: Nevermind. I get why it's not working now. hashtable = Omnihash. My bad for missing this.
 
Status
Not open for further replies.
Top