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

            [Art] => ReplaceableTextures\CommandButtons\BTNArchimonde.blp
            [turnRate] => 0.5
            [bldtm] => 1
            [dmgplus1] => 1752
            [goldcost] => 2800
            [sides1] => 0
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Eredar Warlock
            [weapTp1] => missile
            [MissileHoming] => 1
            [file] => units\demon\Warlock\Warlock.mdl
            [uberSplat] => OSMA
            [Missileart] => Abilities\Weapons\DemonHunterMissile\DemonHunterMissile.mdl
            [Missilespeed] => 1500
            [dice1] => 1
            [RngBuff1] => 250
            [modelScale] => 0.6
            [rangeN1] => 890
            [backSw1] => 0.6
            [atkType1] => chaos
            [cool1] => 3
            [Ubertip] => Daemonic entity that will stun allied towers and temporarily steal their damage for itself and will threaten nearby units by occasionally releasing shadowboltwaves.
            [abilList] => Array
                (
                )

            [moveHeight] => 30
            [dmgpt1] => 0.5
            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

            [weapsOn] => 1
        )

    [settings] => Array
        (
            [balanceTip] => Array
                (
                )

            [abil_factor] => 0.15
            [author] => SirCoqaLot.
            [alpha] => 255
            [authorDisplay] => SirCoqaLot.
            [version] => 1.0
            [element] => darkness
            [rarity] => unique
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => 2.417
                    [y] => -10.4177
                    [z] => -51.2
                    [scale] => 0.63
                    [rot] => 0.261799
                    [file] => Doodads\Cityscape\Props\FountainRuined\FountainRuined.mdl
                    [red] => 50
                    [green] => 50
                    [blue] => 50
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [1] => Array
                (
                    [x] => 2.83392
                    [y] => 43.9445
                    [z] => 0
                    [scale] => 1
                    [rot] => 5.25186
                    [file] => Doodads\Outland\Props\Stake\Stake1.mdl
                    [red] => 100
                    [green] => 100
                    [blue] => 100
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [2] => Array
                (
                    [x] => -16.3077
                    [y] => 46.8446
                    [z] => 0
                    [scale] => 1
                    [rot] => 0.521991
                    [file] => Doodads\Outland\Props\Stake\Stake1.mdl
                    [red] => 100
                    [green] => 100
                    [blue] => 100
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [3] => Array
                (
                    [x] => -15.1974
                    [y] => 55.4579
                    [z] => 0
                    [scale] => 1.1
                    [rot] => 5.11855
                    [file] => Doodads\Outland\Props\Stake\Stake1.mdl
                    [red] => 100
                    [green] => 100
                    [blue] => 100
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [4] => Array
                (
                    [x] => -7.89373
                    [y] => 20.0263
                    [z] => 0
                    [scale] => 0.85
                    [rot] => 1.19757
                    [file] => Doodads\Outland\Props\Stake\Stake1.mdl
                    [red] => 100
                    [green] => 100
                    [blue] => 100
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [5] => Array
                (
                    [x] => -2.62863
                    [y] => 31.4012
                    [z] => 0
                    [scale] => 0.8
                    [rot] => 4.71239
                    [file] => Doodads\Outland\Props\Stake\Stake1.mdl
                    [red] => 100
                    [green] => 100
                    [blue] => 100
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [6] => Array
                (
                    [x] => -8.41224
                    [y] => 44.3421
                    [z] => 0
                    [scale] => 0.72
                    [rot] => 1.3439
                    [file] => Environment\UndeadBuildingFire\UndeadSmallBuildingFire2.mdl
                    [red] => 100
                    [green] => 100
                    [blue] => 100
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [7] => Array
                (
                    [x] => -41.3008
                    [y] => -36.0779
                    [z] => -19.2
                    [scale] => 0.31
                    [rot] => 0.174533
                    [file] => Doodads\Cityscape\Props\FountainRuined\FountainRuined.mdl
                    [red] => 50
                    [green] => 50
                    [blue] => 50
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [8] => Array
                (
                    [x] => 37.6973
                    [y] => -46.1291
                    [z] => -6.4
                    [scale] => 0.2
                    [rot] => 5.53269
                    [file] => Doodads\Cityscape\Props\FountainRuined\FountainRuined.mdl
                    [red] => 50
                    [green] => 50
                    [blue] => 50
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [9] => Array
                (
                    [x] => 49.7893
                    [y] => -22.4438
                    [z] => -6.4
                    [scale] => 0.2
                    [rot] => 1.3439
                    [file] => Doodads\Cityscape\Props\FountainRuined\FountainRuined.mdl
                    [red] => 50
                    [green] => 50
                    [blue] => 50
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [10] => Array
                (
                    [x] => 17.0711
                    [y] => -57.3048
                    [z] => -6.4
                    [scale] => 0.2
                    [rot] => 2.96706
                    [file] => Doodads\Cityscape\Props\FountainRuined\FountainRuined.mdl
                    [red] => 50
                    [green] => 50
                    [blue] => 50
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [11] => Array
                (
                    [x] => 30.1552
                    [y] => 18.9916
                    [z] => 0
                    [scale] => 0.6
                    [rot] => 3.7001
                    [file] => Doodads\Ashenvale\Props\ScorchedRemains\ScorchedRemains1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [12] => Array
                (
                    [x] => -24.3134
                    [y] => -11.1754
                    [z] => 0
                    [scale] => 0.8
                    [rot] => 3.90262
                    [file] => Doodads\Ashenvale\Props\ScorchedRemains\ScorchedRemains1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [13] => Array
                (
                    [x] => 41.5075
                    [y] => -49.886
                    [z] => 38.4
                    [scale] => 0.45
                    [rot] => 2.26893
                    [file] => Abilities\Spells\Other\BlackArrow\BlackArrowMissile.mdl
                    [red] => 100
                    [green] => 100
                    [blue] => 100
                    [alpha] => 255
                    [pitch] => -1.62
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [14] => Array
                (
                    [x] => 17.6511
                    [y] => -60.191
                    [z] => 38.4
                    [scale] => 0.45
                    [rot] => 2.26893
                    [file] => Abilities\Spells\Other\BlackArrow\BlackArrowMissile.mdl
                    [red] => 100
                    [green] => 100
                    [blue] => 100
                    [alpha] => 255
                    [pitch] => -1.62
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [15] => Array
                (
                    [x] => -42.4898
                    [y] => -39.1532
                    [z] => 0
                    [scale] => 0.6
                    [rot] => 1.43117
                    [file] => Environment\UndeadBuildingFire\UndeadSmallBuildingFire2.mdl
                    [red] => 100
                    [green] => 100
                    [blue] => 100
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [16] => Array
                (
                    [x] => 52.5029
                    [y] => -23.7988
                    [z] => 38.4
                    [scale] => 0.45
                    [rot] => 2.26893
                    [file] => Abilities\Spells\Other\BlackArrow\BlackArrowMissile.mdl
                    [red] => 100
                    [green] => 100
                    [blue] => 100
                    [alpha] => 255
                    [pitch] => -1.62
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

        )

    [dmgTable] => Array
        (
        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => Header
                    [code] => globals
    //@export
    ProjectileType sir_eredar_attackProj
    //@export
    ProjectileType sir_eredar_waveProj
    //@export
    BuffType sir_eredar_buff
    endglobals
   
    //@export
    function rollForShadowWave takes Tower t returns nothing
        local Projectile p
        local integer counter = 0
        local integer projCount
        local real angle
        local real x
        local real y
        local real z
        local Iterate it
       
        if (t.userInt == 0 and t.calcChance(0.20)) or (t.userInt == 1 and t.calcChance(0.40)) then   
            set t.userInt = 1
            // Check whether there's anything to shoot at before creating any projectiles.
            set it = Iterate.overUnitsInRangeOfCaster(t, TARGET_CREEPS, 1000)
            if it.count() == 0 then
                return
            endif
            call it.destroy()
            
            set projCount = t.userInt2
            set angle = 0
            set x = t.getX()
            set y = t.getY()
            set z = t.getZ()
            
            loop
                exitwhen projCount == 0
                set p = Projectile.createFromUnitToPoint(sir_eredar_waveProj, t, 1, 1, t, x+300*Cos(angle), y+300*Sin(angle), z, false, false)
                set angle = angle + 36 * bj_DEGTORAD
                set projCount = projCount - 1
            endloop
        else
            set t.userInt = 0
        endif
    endfunction
   
    public function sir_eredar_launch takes Projectile p returns nothing
        local Tower t = p.getCaster()
        local Iterate it
        
        if t != 0 then
            set it = Iterate.overUnitsInRangeOfCaster(t, TARGET_CREEPS, 1000)
            if it.count() != 0 then
                set p.explode = false // projectile will only explode if there are no targets around.
                call Projectile.createFromPointToUnit(sir_eredar_attackProj, t, 1, 1, p.x, p.y, p.z, it.nextRandom(), true, false, false)
                if it.count() != 0 then
                    call it.destroy()
                endif
            endif
        endif
    endfunction
   
    public function sir_eredar_hit takes Projectile p, Unit creep returns nothing
        local Tower tower = p.getCaster()
        call tower.doSpellDamage(creep, tower.userReal * (1+tower.getLevel()*0.02), tower.calcSpellCritNoBonus())
    endfunction
   
    public function sir_towerstun takes Buff b returns nothing       
        local Tower eredar = b.getCaster()
        local Tower attacker = b.getBuffedUnit()
        local Unit target = Event.getTarget()
        local real dmg = attacker.getCurrentAttackDamageWithBonus()/attacker.getCurrentAttackspeed() * 3
        call cb_stun.applyOnlyTimed(eredar,attacker,2.5-eredar.getLevel()*0.02)
        call eredar.doAttackDamage(target,dmg,eredar.calcSpellCritNoBonus())
        call Effect.createSimple("Abilities\\Spells\\Undead\\Impale\\ImpaleHitTarget.mdl",attacker.getX(),attacker.getY()).destroy()
        call eredar.getOwner().displayFloatingTextX(I2S(R2I(dmg)), target, 255, 0, 150, 255, 0.05, 0.0, 2.0)
        call Effect.createSimple("Abilities\\Spells\\Undead\\Impale\\ImpaleHitTarget.mdl",target.getX(),target.getY()).destroy()
    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_eredar_buff = BuffType.create(5,0,true) 
        call sir_eredar_buff.setBuffIcon('@@0@@')       
        set sir_eredar_waveProj = ProjectileType.createRanged("Abilities\\Spells\\Other\\BlackArrow\\BlackArrowMissile.mdl", 300, 600)
        call sir_eredar_waveProj.setEventOnExpiration(ProjectileEvent.sir_eredar_launch)
        set sir_eredar_attackProj = ProjectileType.create("Abilities\\Spells\\Other\\BlackArrow\\BlackArrowMissile.mdl", 4, 1000)
        call sir_eredar_attackProj.enableHoming(ProjectileTargetEvent.sir_eredar_hit,0)       
        call sir_eredar_buff.addEventOnAttack(sir_towerstun,1,0)
   endfunction
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNOrbofSlowness.blp
                            [name] => Shadowbolt Wave
                            [short_explain] => On casting this tower sometimes releases a Shadowbolt Wave dealing damage to multiple.
                            [long_explain] => Every autocast of this tower has a |cffffff8020%|r chance to release |cffffff8010|r shadowbolts. Every shadowbolt flies towards a random target in |cffffff801000|r range and deals |cffffff801050|r spell damage. This Spell has a |cffffff8040%|r chance to trigger if the last autocast released a shadowboltwave.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+21|r spell damage
                        )

                )

            [1] => Array
                (
                    [name] => Autocast
                    [code] => local Tower target = Event.getTarget()
    call sir_eredar_buff.apply(tower,target,1)
    call rollForShadowWave(tower)
                    [values] => Array
                        (
                            [AUTOCAST_cooldown] => 2.5
                            [AUTOCAST_autoRange] => 400
                            [AUTOCAST_manacost] => 0
                            [icon] => ReplaceableTextures\CommandButtons\BTNPossession.blp
                            [AUTOCAST_range] => 400
                            [AUTOCAST_targetType] => TARGET_TYPE_TOWERS
                            [AUTOCAST_numBuffsBeforeIdle] => 1
                            [caster_art] => 
                            [long_explain] => Casts a buff on a nearby tower, if that tower tries to attack in the next |cffffff805|r seconds it will be stunned for |cffffff802.5|r seconds and this tower will deal |cffffff80[stunned tower's DPS x 3]|r as essence damage to the target of the buffed tower. |n|n|cffFF8000Level Bonus:|r|n|cffFFFF80-0.02|r seconds stun duration
                            [target_art] => 
                            [AUTOCAST_autocastType] => AC_TYPE_ALWAYS_BUFF
                            [AUTOCAST_buffType] => 0
                            [AUTOCAST_isExtended] => true
                            [name] => Siphon Essence
                            [AUTOCAST_targetSelf] => false
                            [short_explain] => This tower will stun a nearby tower for a short period of time and deal its damage as essence damage to the buffed tower's target.
                        )

                )

            [2] => Array
                (
                    [name] => On Tower Creation
                    [code] => set tower.userInt = 0 // stores whether last autocast triggered shadowbolts
    set tower.userInt2 = 10 // stores num shadowbolts to release
    set tower.userReal = 1050 // stores base shadowbolt damage
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => BUim
                    [oeValues] => Array
                        (
                            [EditorName] => Dark Surge
                            [EffectArt] => Array
                                (
                                )

                            [Buffubertip] => The next attack of this unit will stun it for a short period of time.
                            [TargetArt] => Array
                                (
                                )

                            [Bufftip] => Dark Surge
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNPossession.blp
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
            [0] => Array
                (
                    [export] => true
                    [category] => global
                    [typ] => ProjectileType
                    [name] => sir_eredar_attackProj
                )

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

            [2] => Array
                (
                    [export] => true
                    [category] => global
                    [typ] => BuffType
                    [name] => sir_eredar_buff
                )

        )

)