I am so confused with this trigger...

ZakkWylde-

New Member
Reaction score
14
JASS:
private function Trig takes nothing returns nothing
    local integer a = 0
    local integer b = 3
    //local real system = 45.00
    local real x
    local real y
    local integer kill = 0
    local unit u = GetEnumUnit()
    local real unitx = GetUnitX (u)
    local real unity = GetUnitY (u)
    local effect e
    if GetUnitState(u, UNIT_STATE_LIFE) >= 1 then
        loop
            exitwhen a > b
            set x =  unitx + TerrainKillSlide_system * Cos(( 90.00 * I2R(a) ) * bj_DEGTORAD)
            set y =  unity + TerrainKillSlide_system * Sin(( 90.00 * I2R(a) ) * bj_DEGTORAD)
            if GetTerrainType(x, y) == udg_DeathTerVines then
                set kill = ( kill + 1 )
            endif
            set a = a + 1
        endloop
        if kill == 4 and GetUnitFlyHeight(u) <= 0.01 then
            call SetUnitMoveSpeed(u, 521)
            call PauseUnit(u, true)
            if GetUnitMoveSpeed(u)==521 then
                call BJDebugMsg("Effect.")
                set e = AddSpecialEffect("Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl", unitx, unity)        
                call SetUnitMoveSpeed(u, 520)
                call BJDebugMsg("Done.")
                call TriggerSleepAction(2.0)
                call BJDebugMsg("Sleep Over.")
            endif
            call SetUnitExploded(u, true)
            call KillUnit(u)
            call PauseUnit(u, false)
            call SetUnitMoveSpeed(u, 522)
            call DestroyEffect(e)
            set e = null
        endif
    endif
    set u = null
endfunction


So if you can follow that trigger through...maybe someone can explain to me WHY as SOON as I step on the vines, it starts making entangling roots effects CONSTANTLY--non-stop...until I type -kill red to kill my unit. It eventually gets to the point of fps drastically falling (because of the myriad effects all at once). When I run the trigger, the messages displayed are
Effect.
Done.
Effect.(x10239812309)
Done. (x10239812309)

and it keeps on running those messages.
It doesn't even get to doing anything else... i.e. my unit's movement speed (put in as test tracker) is never set to 520 or 522 after its initially being set to 521 in the trigger.

I would LOVE some help...(I have even tried timers...but maybe I implemented it incorrectly). If someone could give me a drop-dead easy example of a timer working in this format, that would GREAT!!! :D:D (Or any working example for that matter :p)
 

ZakkWylde-

New Member
Reaction score
14
Hrmm...You're right...it's a terrain kill that repeatedly checks....so heres the whole code:

JASS:
scope TerrainKillVines initializer Init

private function Trig takes nothing returns nothing
    local integer a = 0
    local integer b = 3
    //local real system = 45.00
    local real x
    local real y
    local integer kill = 0
    local unit u = GetEnumUnit()
    local real unitx = GetUnitX (u)
    local real unity = GetUnitY (u)
    local effect e
    if GetUnitState(u, UNIT_STATE_LIFE) >= 1 then
        loop
            exitwhen a > b
            set x =  unitx + TerrainKillSlide_system * Cos(( 90.00 * I2R(a) ) * bj_DEGTORAD)
            set y =  unity + TerrainKillSlide_system * Sin(( 90.00 * I2R(a) ) * bj_DEGTORAD)
            if GetTerrainType(x, y) == udg_DeathTerVines then
                set kill = ( kill + 1 )
            endif
            set a = a + 1
        endloop
        if kill == 4 and GetUnitFlyHeight(u) <= 0.01 then
            call SetUnitMoveSpeed(u, 521)
            call PauseUnit(u, true)
            if GetUnitMoveSpeed(u)==521 then
                call BJDebugMsg("Effect.")
                set e = AddSpecialEffect("Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl", unitx, unity)        
                call SetUnitMoveSpeed(u, 520)
                call BJDebugMsg("Done.")
                call TriggerSleepAction(2.0)
                call BJDebugMsg("Sleep Over.")
            endif
            call SetUnitExploded(u, true)
            call KillUnit(u)
            call PauseUnit(u, false)
            call SetUnitMoveSpeed(u, 522)
            call DestroyEffect(e)
            set e = null
        endif
    endif
    set u = null
endfunction

private function Actions takes nothing returns nothing
    local group   Units = CreateGroup()
    local group   g      = CreateGroup()
    local integer index
    local integer i = 1
    set index = 0
    loop
        set bj_groupEnumTypeId = 'Edem'
        call GroupClear(g)
        call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
        set bj_groupAddGroupDest = Units
        call ForGroup( g , function GroupAddGroupEnum)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call DestroyGroup(g)
    call ForGroup( Units, function Trig )
    call DestroyGroup(Units)
    set Units = null
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterTimerEvent( t, 0.10, true )
    call BJDebugMsg("TerrainKillVines works.")
    call TriggerAddAction( t, function Actions )
endfunction

endscope


Kind of odd, considering that the roots effect isn't in the loop.
The loop is essentially a way to make terrain kill a little less terrain-kill-ish...you can control the leeway using the system the loop uses...
The killing actually happens once the loop is done.
 

ZakkWylde-

New Member
Reaction score
14
/facepalm :banghead:
Duh....lol I'm an idiot.

Now, do you have any ideas as to how I could do that?
...Maybe disable the trigger?!??!(and enable it 2 seconds later) I think I got it... =D

Thanks for that bonk on the head.
 
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