Stasis Trap v1
200
lvl: 2

ID:

13

Author:

Boekie

Rarity:

unique

Status:

Approved

Description:

This trap is used by the orcs to stun their enemies. It's not very reliable though.

Latest Upload Comment:

Restored from 1.10
Activate Trap
Every 8 seconds this trap stuns 3 creeps in 1000 range for 0.5 seconds.

Level Bonus:
+0.5 seconds stun at level 25
Download

Toggle Triggers

Header

goldcost: 0
    globals
    Unit array resultArray //Instead of numResults, use a resultArray so you only have to iterate once.
    endglobals
    
    //Do not remove or rename this function!
    //Put your initialization tasks here, this function will be called on map init
    private function init takes nothing returns nothing
    endfunction

Periodic

PERIODIC_period: 8 goldcost: 200
function periodic takes Item itm returns nothing
    local Tower tower = itm.getCarrier()
    local integer lvl = tower.getLevel()
    local Iterate inRange = Iterate.overUnitsInRangeOfCaster(tower,TARGET_TYPE_CREEPS,1000) //Can set this at the start.
    local Unit next //Used as next during the iterate and the unit to affect during the other loop.
    local integer indexCounter = 0
    local integer loopCounter = 3

      
    loop
        set next=inRange.next()
        exitwhen next==0
        set resultArray[indexCounter] = next
        set indexCounter = indexCounter+1
    endloop
   
    if(indexCounter > 0) then //Commented lines here are for setting the period to a low time when no creeps are around,
                              //remove them if you don't want this to happen. Also if these lines are used, the On Level
                              //Up code isn't needed.
        loop
            set loopCounter = loopCounter - 1
            set next = resultArray[GetRandomInt(0,indexCounter-1)]
            
            if tower.getLevel() == 25 then
                call cb_stun.applyOnlyTimed(tower, next, 1.0) 
            else
                call cb_stun.applyOnlyTimed(tower, next, 0.5) 
            endif
            
            call SFXAtUnit("Abilities\\Spells\\Orc\\FeralSpirit\\feralspirittarget.mdl",next.getUnit())
            exitwhen loopCounter == 0
        endloop
    endif
        
endfunction