Share Knowledge v1
350
lvl: 11

ID:

217

Author:

SternBogen

Rarity:

rare

Status:

Approved

Description:

Share your knowledge with others!

Latest Upload Comment:

Restored from 1.10
Share Knowledge
Every 15 seconds this tower loses 10 experience to teach other random towers in 400 range. Up to five towers in range gain an equal split of 8 experience, plus 1 experience for each tower affected. This ability doesn't work if the item carrier is not at least level 2 and is unaffected by tower exp ratios.
Download

Toggle Triggers

Periodic

PERIODIC_period: 15 goldcost: 350
function periodic takes Item itm returns nothing
    local Tower tower = itm.getCarrier() 
    local Tower next
    local Iterate in_range
    local integer count
    local real exp
    
    // test if tower is level 2 or higher
    if tower.getLevel() > 1 then
        // test, if there are towers in range
        set in_range = Iterate.overUnitsInRangeOfCaster(tower,TARGET_TOWERS,400)
        set count = IMinBJ(5, in_range.count())
        if count > 0 then 
            set exp = (8.0 + count) / count // (8 + number of towers) / number of towers
            call tower.removeExpFlat(10)
            loop
                set next = in_range.nextRandom()
                exitwhen next == 0
                call next.addExpFlat(exp)
                call SFXAtUnit("Abilities\\Spells\\Human\\Polymorph\\PolyMorphTarget.mdl",next.getUnit())
                set count = count - 1
                exitwhen count == 0
            endloop
            if next != 0 then
                call in_range.destroy()
            endif
        else
            call in_range.destroy()
        endif
    endif   
endfunction