Haunted Hand v1
342
lvl: 11

ID:

246

Author:

Sunken

Rarity:

rare

Status:

Approved

Description:

A haunted hand with a mind of it's own, it attacks with reckless fervor.

Latest Upload Comment:

Restored from 1.10
Haunted!
This item makes its carrier attack random targets.
Specials:
Specials:
+8% attackspeed (+0.2%/lvl)
Download

Toggle Triggers

Header

goldcost: 0
    globals
    endglobals
    
    function attackRandomUnit takes Tower tower returns nothing
        local Iterate it  = Iterate.overUnitsInRangeOfCaster(tower, TARGET_CREEPS, tower.getRange())
        local Creep creep = it.nextRandom()
        if creep != 0 then
            call it.destroy()
            call IssueTargetOrder(tower.getUnit(), "attack", creep.getUnit())
        endif
    endfunction
    
    function doIt takes nothing returns nothing
        local timer t = GetExpiredTimer()
        call attackRandomUnit(GetTimerData(t))
        call ReleaseTimer(t)
        set t = null
    endfunction
    
    //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

On Attack

goldcost: -50 ONATTACK_chance: 1.0 ONATTACK_chanceLevelAdd: 0.0
function onAttack takes Item itm returns nothing
    local Tower tower = itm.getCarrier()
    local timer t 
    if tower.typ.dmgpt > 0 then
        set t = NewTimer()
        call SetTimerData(t,tower)
        call TimerStart(t, pendingAttacksTimerStep, false, function doIt) 
        set t = null
    else
        call attackRandomUnit(tower)
    endif
endfunction