Array
(
    [scriptVersion] => 7
    [oeValues] => Array
        (
            [auto] => Array
                (
                )

            [Art] => ReplaceableTextures\CommandButtons\BTNEarthquake.blp
            [dmgplus1] => 1965
            [bldtm] => 1
            [goldcost] => 2000
            [sides1] => 1001
            [acquire] => 800
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Meteor Totem
            [weapTp1] => msplash
            [MissileHoming] => 1
            [file] => Doodads\Barrens\Props\TaurenTotem\TaurenTotem0.mdl
            [uberSplat] => OSMA
            [Harea1] => 325
            [Missileart] => Abilities\Weapons\RedDragonBreath\RedDragonMissile.mdl
            [Missilespeed] => 1200
            [dice1] => 1
            [RngBuff1] => 250
            [Hfact1] => 0.5
            [modelScale] => 0.5
            [rangeN1] => 850
            [atkType1] => pierce
            [cool1] => 3.8
            [Ubertip] => A powerful Totem that causes other towers to release meteors that deal spell damage.
            [scaleBull] => 0
            [abilList] => Array
                (
                )

            [moveHeight] => 5
            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

            [weapsOn] => 1
        )

    [settings] => Array
        (
            [balanceTip] => |cffCCFF00Splash attack:|n   |cffFFFF00325|r AoE: |cffFFFF0050%|r damage|r
            [abil_factor] => 0.3
            [author] => SirCoqaLot.
            [alpha] => 255
            [authorDisplay] => SirCoqaLot.
            [version] => 1.0
            [element] => fire
            [rarity] => unique
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => -0.572722
                    [y] => 1.22803
                    [z] => -38.4
                    [scale] => 0.4
                    [rot] => 3.36775
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires0.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [1] => Array
                (
                    [x] => -5.9322
                    [y] => -1.95466
                    [z] => 0
                    [scale] => 0.65
                    [rot] => 4.03183
                    [file] => Doodads\Dungeon\Rocks\Cave_FieryCrator\Cave_FieryCrator.mdl
                    [red] => 255
                    [green] => 150
                    [blue] => 70
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [2] => Array
                (
                    [x] => 1.58666
                    [y] => 2.21495
                    [z] => -44.8
                    [scale] => 0.35
                    [rot] => 2.4135
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires0.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [3] => Array
                (
                    [x] => -3.85795
                    [y] => 1.25503
                    [z] => 0
                    [scale] => 0.9
                    [rot] => 4.36332
                    [file] => Environment\SmallBuildingFire\SmallBuildingFire2.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [4] => Array
                (
                    [x] => -3.72301
                    [y] => 3.37726
                    [z] => 38.4
                    [scale] => 1
                    [rot] => 2.07694
                    [file] => Abilities\Spells\Items\AIfb\AIfbTarget.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

        )

    [dmgTable] => Array
        (
        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => Header
                    [code] => globals
    BuffType sir_totem_buff
    BuffType sir_totem_debuff
    ProjectileType sir_meteor_projectile
    endglobals
    
    function sir_totem_event takes Buff b returns nothing // doing meteor stuff
       local Tower tower = b.getCaster()
       local Tower buffed = b.getBuffedUnit()
       local Iterate it = Iterate.overUnitsInRangeOfCaster(buffed,TARGET_CREEPS,1000)
       local Unit result = it.nextRandom()
       local integer level = tower.getLevel()
        //searching a target in 1k range around tower
        
       if result != 0 then // if the ability has found a creep in range
            if b.userInt == 1 then
                set Projectile.createBezierInterpolationFromPointToUnit(sir_meteor_projectile,buffed,1,1,buffed.getX(),buffed.getY(),buffed.getZ()+1200,result,0.0,0,0.0,true).userInt = 200 + 8 * level     // on atk
            else
                set Projectile.createBezierInterpolationFromPointToUnit(sir_meteor_projectile,buffed,1,1,buffed.getX(),buffed.getY(),buffed.getZ()+1200,result,0.0,0,0.0,true).userInt = 500 + 20 * level// on cast
            endif
            call it.destroy()
       endif
       
       call b.removeBuff()  // purging the buff
    endfunction
    
    
    
    function sir_meteor_hit takes Projectile p, Unit u returns nothing
    local Tower tower = p.getCaster()    
    call tower.doSpellDamageAoE(p.x,p.y,220,p.userInt,tower.calcSpellCritNoBonus(),0)
    //dealing the damage calculated before
    call SFXAtPoint("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl",p.x,p.y)
    endfunction
    
    
    function sir_totem_onatk takes Buff b returns nothing // doing stuff for meteor on attack
    local Tower buffed = b.getBuffedUnit()
    
    if buffed.calcChance(buffed.getBaseAttackspeed()*0.35) then
            set b.userInt = 1
            call sir_totem_event(b)
    endif
    
    endfunction
    
    function sir_totem_attack takes Buff b returns nothing  // doing stuff when the tower itself is attacking
    local Tower caster = b.getCaster()
    local real damage = Event.damage * (0.08 + caster.getLevel()*0.001)
    local Creep target = b.getBuffedUnit()
    
    if Event.damage >= 500 and Event.isSpellDamage() == false then
        call caster.doSpellDamage(target,damage,1)
        call caster.getOwner().displaySmallFloatingText(I2S(R2I(damage*caster.getProp_SpellDmgDealt())),target,255,150,150,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 sir_totem_buff = BuffType.create(0,0,true)
    call sir_totem_buff.addEventOnAttack(sir_totem_onatk,1,0)
    call sir_totem_buff.addEventOnSpellCast(sir_totem_event)
    call sir_totem_buff.setBuffIcon('@@0@@')
    
    set sir_totem_debuff = BuffType.create(0,0,false)
    call sir_totem_debuff.setBuffIcon('@@1@@')
    call sir_totem_debuff.addEventOnDamaged(sir_totem_attack,1,0)
    
    set sir_meteor_projectile = ProjectileType.create("Abilities\\Weapons\\LordofFlameMissile\\LordofFlameMissile.mdl",10,950)
    call sir_meteor_projectile.setEventOnInterpolationFinished(sir_meteor_hit)
    
	endfunction
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [1] => Array
                (
                    [name] => On Damage
                    [code] => call sir_totem_debuff.applyAdvanced(tower,Event.getTarget(),0,0,2.5+tower.getLevel()*0.05)// apllys the buff dealing x% additional damage
                    [values] => Array
                        (
                            [ONDAMAGE_chance] => 1.0
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNMarkOfFire.blp
                            [name] => Torture
                            [short_explain] => Targets damaged by this tower will receive additional spell damage whenever they receive sufficient attack damage.
                            [ONDAMAGE_chanceLevelAdd] => 0.0
                            [long_explain] => Targets damaged by this tower are debuffed for |cffffff802.5|r seconds. Whenever a debuffed creep is dealt at least |cffffff80500|r attackdamage it receives an additional |cffffff808%|r of that damage as spell damage. This ability cannot crit. |n|n|cffFF8000Level Bonus:|r|n|cffffff80+0.05|r seconds duration|n|cffffff80+0.1%|r damage as spell damage
                        )

                )

            [2] => Array
                (
                    [name] => Autocast
                    [code] => local Unit u 
local Iterate it = Iterate.overUnitsInRangeOfCaster(tower,TARGET_TOWERS,500) //iterating through towers in 500 range apllying the buff but not to itself
local integer number = 4 + R2I(tower.getLevel()/5)


    loop
        set u = it.nextRandom() 
        exitwhen u == 0 or number == 0
        if u != tower then
            set sir_totem_buff.applyAdvanced(tower,u,0,0,100).userInt = 0
            set number = number - 1 // substracting 1 
        endif
        
    endloop
    
    if u != 0 then
        call it.destroy()
    endif
                    [values] => Array
                        (
                            [AUTOCAST_cooldown] => 4
                            [AUTOCAST_autoRange] => 500
                            [AUTOCAST_manacost] => 0
                            [icon] => ReplaceableTextures\CommandButtons\BTNSpy.blp
                            [AUTOCAST_range] => 500
                            [AUTOCAST_targetType] => 0
                            [AUTOCAST_numBuffsBeforeIdle] => 0
                            [caster_art] => 
                            [long_explain] => This tower buffs |cffffff804|r towers in |cffffff80500|r range and gives them a |cffffff8035%|r attackspeed adjusted chance on attack to release a meteor dealing |cffffff80200|r spell damage, or a |cffffff80100%|r chance to release a meteor on spell cast dealing |cffffff80500|r spell damage. The Meteors fly towards a random target in |cffffff801000|r range and deal damage in |cffffff80220|r AoE around the main target. The buff lasts until a meteor is released. |n|n|cffFF8000Level Bonus:|r|n|cffffff80+1|r tower buffed every |cffffff805|r levels |n|cffffff80+8|r spell damage on attack |n|cffffff80+20|r spell damage on cast
                            [target_art] => 
                            [AUTOCAST_autocastType] => AC_TYPE_ALWAYS_BUFF
                            [AUTOCAST_buffType] => 0
                            [AUTOCAST_isExtended] => false
                            [name] => Attraction
                            [AUTOCAST_targetSelf] => true
                            [short_explain] => This tower buffs other towers causing them to release meteors dealing spell damge on attack or when casting a spell.
                        )

                )

        )

    [abilities] => Array
        (
        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => BHav
                    [oeValues] => Array
                        (
                            [EditorName] => Attraction
                            [Buffubertip] => This unit has a chance to attract a meteor on attack or when it casts a spell.
                            [Bufftip] => Attraction
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNSpy.blp
                        )

                )

            [1] => Array
                (
                    [id] => @@1@@
                    [derivedFrom] => BHav
                    [oeValues] => Array
                        (
                            [EditorName] => Torture
                            [Buffubertip] => This unit receives additional spell damage whenever it is damaged.
                            [Bufftip] => Torture
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNMarkOfFire.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

)