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

            [Art] => ReplaceableTextures\CommandButtons\BTNOrbOfDeath.blp
            [dmgplus1] => 105
            [bldtm] => 1
            [goldcost] => 200
            [sides1] => 1
            [launchZ] => 35
            [acquire] => 900
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Chaos Generator
            [weapTp1] => missile
            [MissileHoming] => 1
            [file] => .mdl
            [uberSplat] => YTDB
            [Missileart] => Abilities\Spells\NightElf\Immolation\ImmolationDamage.mdl
            [Missilespeed] => 1200
            [dice1] => 1
            [RngBuff1] => 250
            [rangeN1] => 900
            [atkType1] => magic
            [cool1] => 1.3
            [Ubertip] => Attempts to recreate the Soulflame Device have not been in vain.
            [scaleBull] => 0
            [abilList] => Array
                (
                )

            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

            [weapsOn] => 1
        )

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

            [abil_factor] => 0.4
            [author] => Ashbringer
            [alpha] => 0
            [authorDisplay] => |cffff6600Ashbringer|r
            [version] => 1.0
            [element] => darkness
            [rarity] => uncommon
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => 0.287265
                    [y] => 0.491576
                    [z] => 25.6
                    [scale] => 0.6
                    [rot] => 4.71239
                    [file] => Abilities\Weapons\DemonHunterMissile\DemonHunterMissile.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -4.71
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [1] => Array
                (
                    [x] => 0.917425
                    [y] => 4.10829
                    [z] => 32
                    [scale] => 1.37
                    [rot] => 0
                    [file] => Abilities\Spells\Items\OrbVenom\OrbVenom.mdl
                    [red] => 255
                    [green] => 185
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [2] => Array
                (
                    [x] => 1.02274
                    [y] => 3.20333
                    [z] => 0
                    [scale] => 0.6
                    [rot] => 4.71239
                    [file] => Doodads\Outland\Props\Grate\Grate1.mdl
                    [red] => 45
                    [green] => 155
                    [blue] => 25
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [3] => Array
                (
                    [x] => -0.0133527
                    [y] => 0.972618
                    [z] => 0
                    [scale] => 0.23
                    [rot] => 4.71239
                    [file] => Doodads\Ruins\Props\Ruins_NagaCircle\Ruins_NagaCircle.mdl
                    [red] => 15
                    [green] => 15
                    [blue] => 15
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [4] => Array
                (
                    [x] => -0.435861
                    [y] => -13.021
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 1.5708
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 25
                    [green] => 25
                    [blue] => 25
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [5] => Array
                (
                    [x] => 0.357966
                    [y] => 15.7318
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 25
                    [green] => 25
                    [blue] => 25
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [6] => Array
                (
                    [x] => -0.148344
                    [y] => 0.199712
                    [z] => 0
                    [scale] => 0.11
                    [rot] => 2.3562
                    [file] => Doodads\Underground\Structures\UndergroundArchway1\UndergroundArchway1.mdl
                    [red] => 35
                    [green] => 35
                    [blue] => 35
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [7] => Array
                (
                    [x] => -0.0763133
                    [y] => 0.846242
                    [z] => 0
                    [scale] => 0.11
                    [rot] => 0.785398
                    [file] => Doodads\Underground\Structures\UndergroundArchway1\UndergroundArchway1.mdl
                    [red] => 35
                    [green] => 35
                    [blue] => 35
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [8] => Array
                (
                    [x] => -0.297862
                    [y] => -8.16974
                    [z] => 6.4
                    [scale] => 0.1
                    [rot] => 1.5708
                    [file] => Doodads\Underground\Structures\UndergroundArchway1\UndergroundArchway1.mdl
                    [red] => 35
                    [green] => 35
                    [blue] => 35
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [9] => Array
                (
                    [x] => 0.387533
                    [y] => 10.4651
                    [z] => 6.4
                    [scale] => 0.1
                    [rot] => 4.71239
                    [file] => Doodads\Underground\Structures\UndergroundArchway1\UndergroundArchway1.mdl
                    [red] => 35
                    [green] => 35
                    [blue] => 35
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [10] => Array
                (
                    [x] => 10.3624
                    [y] => 0.836575
                    [z] => 6.4
                    [scale] => 0.1
                    [rot] => 3.14159
                    [file] => Doodads\Underground\Structures\UndergroundArchway1\UndergroundArchway1.mdl
                    [red] => 35
                    [green] => 35
                    [blue] => 35
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

            [11] => Array
                (
                    [x] => -10.9145
                    [y] => 1.18478
                    [z] => 6.4
                    [scale] => 0.1
                    [rot] => 0
                    [file] => Doodads\Underground\Structures\UndergroundArchway1\UndergroundArchway1.mdl
                    [red] => 35
                    [green] => 35
                    [blue] => 35
                    [alpha] => 255
                    [pitch] => -1.57
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                    [pcolor] => 255
                )

        )

    [dmgTable] => Array
        (
        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => On Attack
                    [code] => call ashbringer_chaos_trigger(tower, Event.getTarget(), 300, 12, 1, 5)
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNOrbOfDeath.blp
                            [name] => Chaos Orbs
                            [short_explain] => Attacks have a chance to release orbs which deal spell damage to enemies.
                            [ONATTACK_chance] => 0.1
                            [ONATTACK_chanceLevelAdd] => 0.004
                            [long_explain] => Attacks have a |cffffff8010%|r chance to release |cffffff801|r to |cffffff805|r chaos orbs which move unpredictably, dealing |cffffff80300|r spell damage in |cffffff80175|r AoE if they collide with an enemy.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.4%|r chance|n|cffFFFF80+12|r damage
                        )

                )

            [1] => Array
                (
                    [name] => Header
                    [code] => globals
        ProjectileType ashbringer_chaos_missile
    endglobals
    
    //@export
    function ashbringer_chaos_trigger takes Tower tower, Unit target, real dmg_base, real dmg_pl, integer p_min, integer p_max returns nothing
        local real damage = dmg_base + (tower.getLevel() * dmg_pl)
        local integer count = 0
        local integer spawn = GetRandomInt(p_min, p_max)
        local real tower_x = tower.getX()
        local real tower_y = tower.getY()
        local real angle = (bj_RADTODEG * Atan2(target.getY() - tower_y, target.getX() - tower_x)) - (spawn-1)*30/2
        local real turn
        local Projectile p
        
        loop
            exitwhen count==spawn
            set turn = GetRandomReal(-2, 2)
            set p = Projectile.create(ashbringer_chaos_missile, tower, 0, 0, tower_x, tower_y, 30, angle+(count*30))
            call p.setScale(0.4)
            set p.userReal = damage
            set p.rotation = turn
            set p.accelerate = 4
            if turn>0 then
                set p.userReal3 = turn
            else
                set p.userReal2 = -turn
            endif
            set count = count + 1
        endloop
    endfunction
    
    function ashbringer_chaos_hit takes Projectile p, Unit target returns nothing
        local Tower tower = p.getCaster()
        local Iterate i
        local Unit next
        local real crit = tower.calcSpellCritNoBonus()
        
        call Effect.createScaled("Abilities\\Weapons\\DemonHunterMissile\\DemonHunterMissile.mdl", p.x, p.y, p.z, 0, 2.25).destroy()
        if p.userInt == 1 then
            set i = Iterate.overUnitsInRange(tower, TARGET_TYPE_CREEPS, p.x, p.y, 175)
            call p.destroy()
        else
            set i = Iterate.overUnitsInRange(tower, TARGET_TYPE_CREEPS, target.getX(), target.getY(), 175)
        endif
        
        loop
            set next = i.next()
            exitwhen next == 0
            if not next.isImmune() then
                call tower.doSpellDamage(next, p.userReal, crit)
            endif
        endloop
    endfunction
    
    function ashbringer_chaos_home takes Projectile p, Unit target returns nothing
        local boolean detonate = false
        local real angle = bj_RADTODEG * Atan2(target.getY() - p.y, target.getX() - p.x)
        
        if angle > p.direction then
            if angle - p.direction > 75 then
                set detonate = true
            endif
        else
            if p.direction - angle > 75 then
                set detonate = true
            endif
        endif
        
        if detonate == true then
            set p.userInt = 1
            call ashbringer_chaos_hit(p, target)
        else
            set p.userInt = 0
            call p.disablePeriodic()
            call p.setCollisionEnabled(false)
            call p.setHomingTarget(target)
            set p.accelerate = 8
            set p.remainingLifetime = 3.00
        endif
    endfunction
    
    function ashbringer_chaos_periodic takes Projectile p returns nothing
        local real turn = GetRandomReal(1.5, 3)
        local real compare = GetRandomReal(0, p.userReal2+p.userReal3)
        
        if p.userReal3>p.userReal2 then
            if compare>p.userReal2 then
                set p.rotation = -turn
                set p.userReal2 = p.userReal2 + turn
            else
                set p.rotation = turn
                set p.userReal3 = p.userReal3 + turn
            endif
        else
            if compare>p.userReal3 then
                set p.rotation = turn
                set p.userReal3 = p.userReal3 + turn
            else
                set p.rotation = -turn
                set p.userReal2 = p.userReal2 + turn
            endif
        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 ashbringer_chaos_missile = ProjectileType.create("Abilities\\Weapons\\DemonHunterMissile\\DemonHunterMissile.mdl", 3, 425)
        call ashbringer_chaos_missile.enableCollision(ProjectileTargetEvent.ashbringer_chaos_home, 100, TARGET_CREEPS, false)
        call ashbringer_chaos_missile.enableHoming(ProjectileTargetEvent.ashbringer_chaos_hit, 0)
        call ashbringer_chaos_missile.enablePeriodic(ProjectileEvent.ashbringer_chaos_periodic, 0.3)
        call ashbringer_chaos_missile.disableExplodeOnHit()
    endfunction
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
        )

    [buffs] => Array
        (
        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

    [lightning] => Array
        (
        )

)