Distorted Idol v1
2750
lvl: 84

ID:

254

Author:

Deemzul

Rarity:

unique

Status:

Unapproved

Description:

Exists beyond reality.

Latest Upload Comment:

Restored from 1.10
Imitation
On pick up, this item copies the abilities and modifiers of every other item already on the tower, except other Distorted Idols and use-actives. The effects are lost when this item is dropped, or the carrier is upgraded or replaced.
Restriction
This item can only be picked up by a tower in a corner with cliffs on two sides.
Specials:
Specials:
-60% attackspeed
Download

Toggle Triggers

Header

goldcost: 2750
    globals
        constant real displayTime = 7
    endglobals
    struct copyList
        Item array items[6]
        static method create takes nothing returns copyList
            local copyList cl = copyList.allocate()
            local integer i = 0
            loop
                set cl.items[i] = 0
                set i = i + 1
                exitwhen i == 6
            endloop
            return cl
        endmethod
    endstruct
    //@export
    function deem_delayDrop takes nothing returns nothing //Should maybe make Item.drop() do this on default
        local timer t = GetExpiredTimer()
        call Item(GetTimerData(t)).drop()
        call ReleaseTimer(t)
    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 Item Creation

goldcost: 0
function onCreate takes Item itm returns nothing
    set itm.userInt = copyList.create()
    set itm.userInt2 = 0
endfunction

On Item Destruction

goldcost: 0
function onDestruct takes Item itm returns nothing
    call copyList(itm.userInt).destroy()
endfunction

On Item Drop

goldcost: 0
function onDrop takes Item itm returns nothing
    local copyList cl = itm.userInt
    local integer i = 0
    local Item cur_item
    if itm.userInt2 != 0 then
        loop
            set cur_item = cl.items[i]
            if cur_item != 0 then //the tower doesn't actually carry these items, they are hidden and at 0,0
                //Remove effects
                if cur_item.typ.effects != 0 then
                    call cur_item.currentEffect.remove()
                    set cur_item.currentEffect = 0
                endif
                call cur_item.destroy()
                set cl.items[i] = 0
            endif
            set i = i + 1
            exitwhen i == 6
        endloop
        set itm.userInt2 = 0
    endif
endfunction

On Item Pickup

goldcost: 0
function onPickup  takes Item itm returns nothing
    local Tower tower = itm.getCarrier()
    local integer i = 1 //itemslots start from 1 for whatever reason
    local Item tmpItm
    local ItemEventList cur_iel
    local Item dummy_itm
    local ItemType cur_ityp
    local copyList cur_copy_list
    local real x = tower.getX()
    local real y = tower.getY()
    local integer cliff = 0
    local timer t
    if IsTerrainPathable(x,y-96,PATHING_TYPE_BUILDABILITY) then
        set cliff = cliff + 1
    endif
    if IsTerrainPathable(x,y+96,PATHING_TYPE_BUILDABILITY) then
        set cliff = cliff + 1
    endif
    if IsTerrainPathable(x-96,y,PATHING_TYPE_BUILDABILITY) then
        set cliff = cliff + 1
    endif
    if IsTerrainPathable(x+96,y,PATHING_TYPE_BUILDABILITY) then
        set cliff = cliff + 1
    endif
    if cliff != 2 then //Is tower not next to 2 cliffs?
        set t = NewTimer()
        call SetTimerData(t,itm)
        call TimerStart(t,0,false,function deem_delayDrop) //can't drop immediately, because of execution order
    else
        loop
            set itm.userInt2 = tower
            exitwhen i > 6
            set tmpItm = tower.getHeldItem(i)
            if tmpItm != 0 then
                set cur_ityp = tmpItm.typ
                set cur_iel = cur_ityp .effects
                set cur_copy_list = itm.userInt
                if cur_iel != itm.typ.effects then
                    //Create fake items for userInts and such
                    set dummy_itm = Item.create(tower.getOwner(),cur_ityp,0,0)
                    set dummy_itm.currentCarrier = tower
                    call SetItemVisible(dummy_itm.theItem,false)
                    call ItemEffect.create(dummy_itm,tower)
                    set cur_copy_list.items[i-1] = dummy_itm //-1 because array starts at 0 and getHeldItem at 1
                endif
            endif
            set i = i + 1
        endloop
    endif
endfunction

On Tower Details

goldcost: 0
function onTowerDetails takes Item itm returns MultiboardValues
    local integer i = 0
    local Item tmpItm
    local item tmpitm
    local string s
    local Playor p = Event.getMBObserver()
    local integer i2  = 0
    local Tower t = itm.getCarrier()
    //Only want to view this when opening the multiboard
    if p.towerDisplay.curTower != t then
        set s = ""
        loop
            set tmpItm = copyList(itm.userInt).items[i]
            exitwhen i == 6
            if tmpItm != 0 then
                if i2 == 3 then
                    set s = s + "\n"
                elseif i2 > 0 then
                    set s = s + ", "
                endif
                set tmpitm = tmpItm.getItem()
                set s = s + GetItemName(tmpitm)
                set i2 = i2 + 1
            endif
            set i = i + 1
        endloop
        if i2 == 0 then
            call p.displayTimedText("|cffFF8000Distorted Idol is copying:|r Absolutely nothing",displayTime)
        else
            call p.displayTimedText("|cffFF8000Distorted Idol is copying the following items:|r",displayTime)
            call p.displayTimedText(s,displayTime)
        endif
        set tmpitm = null
    endif
    return 0
endfunction