Strange Item v3
256
lvl: 16

ID:

233

Author:

Deemzul

Rarity:

common

Status:

Approved

Description:

This item has a strange smell.

Latest Upload Comment:

Where is the bald man?
Duplication
This item duplicates after being carried for 12 waves. The duplicate will be 6 waves slower to duplicate.
Download

Toggle Triggers

On Item Creation

goldcost: 0
function onCreate takes Item itm returns nothing
            
set itm.userInt2 = 12
    set itm.userInt = itm.userInt2
    call itm.setCharges(itm.userInt)
        
endfunction

On Item Drop

goldcost: 0
function onDrop takes Item itm returns nothing
            
    local Item new
    local Tower tower
    local integer curLevel = itm.getOwner().getTeam().getLevel()
    if curLevel > itm.userInt3 then
        set itm.userInt = itm.userInt - (curLevel-itm.userInt3)
        set itm.userInt3 = curLevel
        
        if itm.userInt <= 0 then
            set tower = itm.getCarrier()
            set new = Item.create(tower.getOwner(),itm.getItemType(),tower.getX(),tower.getY())
            set new.userInt2 = itm.userInt2 + 6
            set new.userInt = new.userInt2
            call new.setCharges(new.userInt)
            set itm.userInt = itm.userInt + itm.userInt2
            call new.flyToStash(0.0)
        endif
        call itm.setCharges(itm.userInt)
    endif
        
endfunction

On Item Pickup

goldcost: 0
function onPickup  takes Item itm returns nothing
            
set itm.userInt3 = itm.getOwner().getTeam().getLevel()
    call itm.setCharges(itm.userInt)
        
endfunction

Periodic

PERIODIC_period: 5 goldcost: 256
function periodic takes Item itm returns nothing
            
local Item new
    local Tower tower
    local integer curLevel = itm.getOwner().getTeam().getLevel()
    local integer temp
    if curLevel > itm.userInt3 then
        set itm.userInt = itm.userInt - (curLevel-itm.userInt3)
        set itm.userInt3 = curLevel
        if itm.userInt <= 0 then
            set tower = itm.getCarrier()
            set new = Item.create(tower.getOwner(),itm.getItemType(),tower.getX(),tower.getY())
            
            set new.userInt2 = itm.userInt2 + 6
            set new.userInt = new.userInt2
            call new.setCharges(new.userInt)
            set itm.userInt = itm.userInt + itm.userInt2
            
            if not new.pickup(tower) then
                call new.flyToStash(0.0)
            endif
        endif
        call itm.setCharges(itm.userInt)
    endif
    if curLevel > Game.getMaxLevel() then
        call itm.drop()
        call itm.flyToStash(0.0)
    endif
        
endfunction