Array
(
    [scriptVersion] => 7
    [oeValues] => Array
        (
            [RngBuff1] => 250
            [scaleBull] => 0
            [MissileHoming] => 1
            [Upgrade] => Array
                (
                )

            [targs1] => Array
                (
                )

            [goldcost] => 500
            [weapsOn] => 1
            [dice1] => 1
            [Missilespeed] => 1200
            [file] => Doodads\Cityscape\Props\City_Oblisk\City_Oblisk.mdl
            [manaN] => 250
            [atkType1] => normal
            [modelScale] => 0.65
            [weapTp1] => missile
            [acquire] => 800
            [rangeN1] => 800
            [upgrades] => Array
                (
                )

            [cool1] => 3
            [Ubertip] => A rare tower which can store electricity for later use.
            [regenMana] => 2
            [abilList] => Array
                (
                )

            [launchZ] => 160
            [Name] => Storm Battery
            [Missileart] => Abilities\Weapons\FarseerMissile\FarseerMissile.mdl
            [launchY] => -3
            [launchX] => 6
            [Art] => ReplaceableTextures\CommandButtons\BTNOrbOfLightning.blp
            [sides1] => 1
            [auto] => Array
                (
                )

            [dmgplus1] => 821
            [bldtm] => 1
        )

    [settings] => Array
        (
            [author] => tolleder
            [element] => storm
            [authorDisplay] => tolleder
            [balanceTip] => |cffFFFF00+10 |rmana/lvl
            [rarity] => rare
            [version] => 1.0
            [abil_factor] => 0.4
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => 3.4514
                    [y] => -5.67645
                    [z] => 166.4
                    [scale] => 1
                    [rot] => 6.03884
                    [file] => Abilities\Spells\Items\AIlb\AIlbTarget.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

        )

    [dmgTable] => Array
        (
            [0] => Array
                (
                    [id] => MOD_MANA
                    [base] => 0
                    [add] => 10
                )

        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => On Tower Creation
                    [code] => set tower.userInt=0
    call SetUnitState(tower.getUnit(),UNIT_STATE_MANA,0)
                    [values] => Array
                        (
                            [icon] => 
                            [visible] => false
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [1] => Array
                (
                    [name] => On Damage
                    [code] => local integer towerLevel=tower.getLevel()
    //call slowAndDamage.apply(tower,Event.getTarget(),tower.getLevel())
    set Tolleder_StormBat_bT.applyCustomPower(tower,Event.getTarget(),R2I(1000.*(0.4+0.008*I2R(towerLevel))*(0.2+0.003*I2R(towerLevel))),towerLevel).userReal=0.4+0.008*I2R(towerLevel)+1.
                    [values] => Array
                        (
                            [ONDAMAGE_chance] => 1.0
                            [icon] => ReplaceableTextures\CommandButtons\BTNPurge.blp
                            [visible] => true
                            [name] => Electrify
                            [short_explain] => The creep has a chance to take extra damage.
                            [ONDAMAGE_chanceLevelAdd] => 0.0
                            [long_explain] => The Storm Battery's projectiles electrify their target for |cffFFFF809|r seconds. Every time an electrified creep is damaged by an attack or spell it has a chance of |cffFFFF8020%|r to take |cffFFFF8040%|r extra damage. |n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.3%|r chance|n|cffFFFF80+0.8%|r damage|n|cffFFFF80+0.3|r seconds duration
                        )

                )

            [2] => Array
                (
                    [name] => Header
                    [code] => globals
        //@export
        BuffType Tolleder_StormBat_bT
        //@export
        ProjectileType Tolleder_StormBat_pT
    endglobals
    
    public function hit takes Projectile p, Unit creep returns nothing
        local Tower tower=p.getCaster()
        local integer towerLevel=tower.getLevel()
        call tower.doSpellDamage(creep,p.userReal,tower.calcSpellCritNoBonus())
        //call slowAndDamage.apply(tower,creep,tower.getLevel())
        set Tolleder_StormBat_bT.applyCustomPower(tower,creep,R2I(1000.*(p.userReal2)*(0.2+0.003*I2R(towerLevel))),towerLevel).userReal=p.userReal2+1.
    endfunction
    
    public function onDamaged takes Buff b returns nothing
        local Tower tower=b.getCaster()
        local Playor plr=tower.getOwner()
        if tower.calcChance(0.2+I2R(b.getPower())*0.003) then
            set Event.damage=Event.damage*b.userReal //*(1.+0.4+0.008*b.getPower())
            call plr.displaySmallFloatingText(I2S(R2I(Event.damage)), b.getBuffedUnit(),128,255,255,20.)
        endif
    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
        set Tolleder_StormBat_bT=BuffType.create(9,0.3,false)
        call Tolleder_StormBat_bT.setBuffIcon('@@0@@')
        call Tolleder_StormBat_bT.addEventOnDamaged(EventHandler.onDamaged,1.,0.) //0.2,0.003)
        call Tolleder_StormBat_bT.setStackingGroup("StormBattery")
        //userReal=How many times the damage
        
        set Tolleder_StormBat_pT=ProjectileType.create("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl",10.0,1200.0)        
        call Tolleder_StormBat_pT.enableHoming(ProjectileTargetEvent.hit,0.0)
        //userReal=Damage on hit
        //userReal2=Bonus damage
	endfunction
                    [values] => Array
                        (
                            [icon] => 
                            [visible] => false
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [3] => Array
                (
                    [name] => Periodic
                    [code] => local unit towerUnit=tower.getUnit()
    local Iterate inRange
    local real numResults=0.0
    local Unit result
    local Unit next
    local Projectile p
    local PeriodicEvent pE
    
    // mana cost paying
    if tower.subtractMana(10,false) == 10 then
        //Random creep in range
        set inRange=Iterate.overUnitsInRangeOfCaster(tower,TARGET_CREEPS,1200)
        loop
            set next=inRange.next()
            exitwhen next==0
            
            set numResults=numResults+1.0 
            if GetRandomReal(0.0,1.0)<=1.0/numResults then
                set result=next
            endif
        endloop
        
        if numResults>0.5 then
            set p= Projectile.createFromPointToUnit(Tolleder_StormBat_pT,tower,1.0,1.0,GetUnitX(towerUnit)+3.0,GetUnitY(towerUnit)-6.0,160.0,result,true,false,false)
            set p.userReal=tower.getLevel()*12+300
            set p.userReal2=0.4+0.008*I2R(tower.getLevel())
            
            call p.setScale(0.5)
        endif
        
        // Manacost already payed
        // call SetUnitState(towerUnit,UNIT_STATE_MANA,GetUnitState(towerUnit,UNIT_STATE_MANA)-10)
    else
        set pE=Event.getCurrentPeriodicEvent()
        set tower.userInt=pE
        call pE.disable()
    endif
    set towerUnit = null
                    [values] => Array
                        (
                            [icon] => 
                            [visible] => false
                            [PERIODIC_period] => 0.2
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [4] => Array
                (
                    [name] => Autocast
                    [code] => local unit towerUnit=tower.getUnit()
    local PeriodicEvent pE
    call SetUnitState(towerUnit,UNIT_STATE_MANA,GetUnitState(towerUnit,UNIT_STATE_MANA)+100)
    if tower.userInt!=0 then
        set pE=tower.userInt
        call pE.enable()
    endif
    set towerUnit = null
                    [values] => Array
                        (
                            [caster_art] => 
                            [icon] => ReplaceableTextures\CommandButtons\BTNOrbOfLightning.blp
                            [AUTOCAST_cooldown] => 20.0
                            [AUTOCAST_numBuffsBeforeIdle] => 0
                            [visible] => true
                            [AUTOCAST_isExtended] => false
                            [long_explain] => The tower attacks creeps in a range of |cffFFFF801200|r every |cffFFFF800.2|r seconds till all mana is gone. Each attack (or try to attack) costs |cffFFFF8010|r mana, deals |cffFFFF80300|r spelldamage and electrifies the target.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+12|r damage
                            [AUTOCAST_autocastType] => AC_TYPE_OFFENSIVE_IMMEDIATE
                            [AUTOCAST_manacost] => 100
                            [AUTOCAST_range] => 1200
                            [name] => Battery Overload
                            [AUTOCAST_buffType] => 0
                            [AUTOCAST_targetSelf] => false
                            [short_explain] => Multiple attacks at a high rate for mana
                            [AUTOCAST_targetType] => 0
                            [target_art] => 
                            [AUTOCAST_autoRange] => 800
                        )

                )

        )

    [abilities] => Array
        (
        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => Bfro
                    [oeValues] => Array
                        (
                            [Bufftip] => Electrified
                            [Targetattach] => origin
                            [Buffubertip] => The creep has a chance to take extra damage.
                            [Targetattachcount] => 1
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNPurge.blp
                            [TargetArt] => Abilities\Spells\Orc\Purge\PurgeBuffTarget.mdl
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
            [0] => Array
                (
                    [export] => true
                    [category] => global
                    [typ] => BuffType
                    [name] => Tolleder_StormBat_bT
                )

            [1] => Array
                (
                    [export] => true
                    [category] => global
                    [typ] => ProjectileType
                    [name] => Tolleder_StormBat_pT
                )

        )

)