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

            [Art] => ReplaceableTextures\CommandButtons\BTNSpellBreaker.blp
            [turnRate] => 3
            [dmgplus1] => 88
            [bldtm] => 1
            [goldcost] => 70
            [unitSound] => SpellBreaker
            [sides1] => 1
            [manaN] => 100
            [acquire] => 900
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Apprentice Spellblade
            [weapTp1] => missile
            [impactZ] => 60
            [file] => units\human\BloodElfSpellThief\BloodElfSpellThief.mdl
            [MissileHoming] => 1
            [uberSplat] => YTDG
            [Missilespeed] => 1400
            [Missileart] => Abilities\Weapons\BloodElfSpellThiefMISSILE\BloodElfSpellThiefMISSILE.mdl
            [dice1] => 1
            [RngBuff1] => 250
            [regenMana] => 2.5
            [animProps] => ready
            [modelScale] => 0.5
            [rangeN1] => 900
            [propWin] => 10
            [atkType1] => siege
            [cool1] => 1.6
            [Ubertip] => Has an aptitude for illusions.
            [scaleBull] => 0
            [abilList] => Array
                (
                )

            [moveHeight] => 35
            [customTeamColor] => 1
            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

            [weapsOn] => 1
            [teamColor] => 3
        )

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

            [abil_factor] => 0.75
            [author] => Ashbringer
            [alpha] => 255
            [authorDisplay] => |cffff6600Ashbringer|r
            [version] => 1.0
            [element] => arcane
            [rarity] => uncommon
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => -0.0436822
                    [y] => 0.156401
                    [z] => -6.4
                    [scale] => 0.35
                    [rot] => 1.5708
                    [file] => Doodads\Cityscape\Props\FountainRuined\FountainRuined.mdl
                    [red] => 55
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [1] => Array
                (
                    [x] => 0.438804
                    [y] => 13.6797
                    [z] => -6.4
                    [scale] => 0.1
                    [rot] => 4.71239
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 55
                    [green] => 25
                    [blue] => 75
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [2] => Array
                (
                    [x] => -0.446623
                    [y] => -13.0724
                    [z] => -6.4
                    [scale] => 0.1
                    [rot] => 1.5708
                    [file] => Doodads\Cityscape\Structures\City_ColumnSemiCircle\City_ColumnSemiCircle.mdl
                    [red] => 55
                    [green] => 25
                    [blue] => 75
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [3] => Array
                (
                    [x] => 0.533653
                    [y] => 18.2068
                    [z] => 12.8
                    [scale] => 0.13
                    [rot] => 4.71239
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 55
                    [green] => 25
                    [blue] => 75
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [4] => Array
                (
                    [x] => -0.776406
                    [y] => -17.8166
                    [z] => 12.8
                    [scale] => 0.13
                    [rot] => 1.5708
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 55
                    [green] => 25
                    [blue] => 75
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [5] => Array
                (
                    [x] => -1.09447
                    [y] => -0.000755712
                    [z] => 12.8
                    [scale] => 0.15
                    [rot] => 2.3562
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 255
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -4.71
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [6] => Array
                (
                    [x] => 1.44931
                    [y] => -0.133934
                    [z] => 12.8
                    [scale] => 0.15
                    [rot] => 5.49779
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 255
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -4.71
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [7] => Array
                (
                    [x] => -0.0451217
                    [y] => -1.16412
                    [z] => 12.8
                    [scale] => 0.15
                    [rot] => 3.92699
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 255
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -4.71
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [8] => Array
                (
                    [x] => 0.0880418
                    [y] => 1.37968
                    [z] => 12.8
                    [scale] => 0.15
                    [rot] => 0.785398
                    [file] => war3mapImported\City_ColumnSemiCircle2.mdl
                    [red] => 255
                    [green] => 55
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -4.71
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [9] => Array
                (
                    [x] => -0.0526432
                    [y] => 0.104051
                    [z] => -12.8
                    [scale] => 1.65
                    [rot] => 2.43138
                    [file] => Abilities\Spells\Other\GeneralAuraTarget\GeneralAuraTarget.mdl
                    [red] => 35
                    [green] => 35
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [10] => Array
                (
                    [x] => 0.0165171
                    [y] => 0.00232892
                    [z] => 6.4
                    [scale] => 1.2
                    [rot] => 2.43138
                    [file] => Abilities\Spells\Other\GeneralAuraTarget\GeneralAuraTarget.mdl
                    [red] => 35
                    [green] => 35
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

        )

    [dmgTable] => Array
        (
        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => On Level Up
                    [code] => set tower.userReal = 15 + (tower.getLevel() * 0.6)
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [1] => Array
                (
                    [name] => On Attack
                    [code] => if tower.userInt > 0 then
        set tower.userInt = tower.userInt - 1
        call ashbringer_image_start(tower, Event.getTarget(), 0.5 + (tower.getLevel() * 0.02), 8)
    endif
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [ONATTACK_chance] => 1.0
                            [ONATTACK_chanceLevelAdd] => 0.0
                            [long_explain] => 
                        )

                )

            [2] => Array
                (
                    [name] => Header
                    [code] => globals
        //@export
        BuffType ashbringer_brand_buff
        
        ProjectileType ashbringer_image_missile
    endglobals
    
    function ashbringer_image_tick takes Tower t, Effect e returns nothing
        local Iterate i
        local Creep next
        local real speed = (1 + t.getProp_Attackspeed())
        local real period = RMaxBJ(1.6 / RMinBJ(RMaxBJ(speed, 0.5), 5), 0.3)
        local real angle
        local real distance
        local real closest_distance = 9999
        local Creep closest = 0
        local real x = e.userReal
        local real y = e.userReal2
        local integer further_closer
        
        if (e.userReal3 + 0.1) > period and t.getUID() == e.userInt2 then
            set i = Iterate.overUnitsInRange(t, TARGET_TYPE_CREEPS, x, y, 900)
            loop
                set next = i.next()
                exitwhen next == 0
                set distance = DistanceBetweenPoints(Location(x, y), GetUnitLoc(next.getUnit()))
                if distance < closest_distance then
                    set closest_distance = distance
                    set closest = next
                endif
            endloop
            
            if closest != 0 then
                if closest_distance <= 600 then
                    call TriggerSleepAction(0.2)
                    set Projectile.createFromPointToUnit(ashbringer_image_missile, t, 0.0, 0.0, x, y, 30, closest, true, false, false).userInt3 = e.userInt3
                    set angle = bj_RADTODEG * Atan2(closest.getY() - y, closest.getX() - x)
                    call e.setFacing(angle)
                    call e.setAnimationSpeed(1.0/period)
                    call e.setAnimation("attack")
                    set e.userInt = 1
                
                    set e.userReal3 = e.userReal3 - period
                    call TriggerSleepAction(period-0.2)
                    call ashbringer_image_tick(t, e)
                else
                    set further_closer = GetRandomInt(0, 1)
                    if further_closer == 0 then
                        set further_closer = -1
                    endif
                    call Effect.createColored("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl", x, y, 0, 270, 0.5, 255, 255, 255, 165).setLifetime(2.0)
                    
                    set angle = bj_RADTODEG * Atan2(closest.getY() - y, closest.getX() - x)
                    call e.setFacing(angle)
                    
                    set x = closest.getX()
                    set y = closest.getY()
                    
                    set angle = bj_RADTODEG * Atan2(t.getY() - y, t.getX() - x)
                    set angle = ModuloReal(GetRandomReal(angle-20, angle+20), 360)

                    set x = x + (1 * GetRandomReal(75, 125)) * Cos(Deg2Rad(angle))
                    set y = y + (1 * GetRandomReal(75, 125)) * Sin(Deg2Rad(angle))
                    
                    call e.setPosition(x, y)
                    set e.userReal = x
                    set e.userReal2 = y
                    
                    call Effect.createColored("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", x, y, 0, 270, 0.5, 255, 255, 255, 165).setLifetime(2.0)
            
                    set e.userInt = 2
                    set e.userReal3 = e.userReal3 - 0.3
                    call TriggerSleepAction(0.3)
                    call ashbringer_image_tick(t, e)
                endif
            else
                if e.userInt > 0 then
                    call e.setAnimationSpeed(1.0)
                    call e.setAnimation("stand ready")
                endif
        
                set e.userInt = 0
                set e.userReal3 = e.userReal3 - period
                call TriggerSleepAction(period)
                call ashbringer_image_tick(t, e)
            endif
        else
            call e.setAnimationSpeed(1.0)
            call e.setAnimation("stand ready")
            call e.attachEffect("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", "chest")
            call TriggerSleepAction(0.3)
            call e.noDeathAnimation()
            call e.destroy()
        endif
    endfunction
    
    function ashbringer_image_hit takes Projectile p, Creep c returns nothing
        local Tower t = p.getCaster()
        local real damage = t.getCurrentAttackDamageWithBonus() * (I2R(p.userInt3) / 1000)
        local Buff b = c.getBuffOfType(ashbringer_brand_buff)
        
        call t.doAttackDamage(c, damage, t.calcAttackMulticrit(0, 0, 0))
        if b!=0 then
            call t.doSpellDamage(c, b.userReal, t.calcSpellCritNoBonus())
        endif
    endfunction
    
    //@export
    function ashbringer_image_start takes Tower tower, Creep target, real damage, real duration returns nothing
        local real x = target.getX()
        local real y = target.getY()
        local Effect e
        local real angle
        local integer further_closer = GetRandomInt(0, 1)
        
        if further_closer == 0 then
            set further_closer = -1
        endif
        
        set angle = bj_RADTODEG * Atan2(tower.getY() - y, tower.getX() - x)
        set angle = ModuloReal(GetRandomReal(angle-20, angle+20), 360)
        
        set duration = duration * tower.getProp_BuffDuration()

        set x = x + (I2R(further_closer) * GetRandomReal(75, 125)) * Cos(Deg2Rad(angle))
        set y = y + (I2R(further_closer) * GetRandomReal(75, 125)) * Sin(Deg2Rad(angle))
        set e = Effect.createAnimatedColored("units\\human\\BloodElfSpellThief\\BloodElfSpellThief.mdl", x, y, 0.0, 270.0, 0.5, 255, 255, 255, 165)
        call e.attachEffect("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", "chest")
        //call e.attachEffect("Abilities\\Weapons\\SpiritOfVengeanceMissile\\SpiritOfVengeanceMissile.mdl", "chest")
        //call e.setTeamcolor(4)
        set e.userInt = 1
        set e.userInt2 = tower.getUID()
        set e.userInt3 = R2I(damage * 1000)
        set e.userReal = x
        set e.userReal2 = y
        set e.userReal3 = duration
        //call e.setAnimationSpeed(1.06)
        call e.setAnimation("Stand Ready")
        call TriggerSleepAction(0.1)
        call ashbringer_image_tick(tower, e)
    endfunction
    
    function ashbringer_brand_oncreate takes Buff b returns nothing
        set b.userReal = b.getCaster().userReal
    endfunction
    
    function ashbringer_brand_ondamaged takes Buff b returns nothing
        local Tower tower = Event.getTarget()
        local Creep target = b.getBuffedUnit()
        
        call tower.doSpellDamage(target, b.userReal, tower.calcSpellCritNoBonus())
    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
        local Modifier mod = Modifier.create()
        
        set ashbringer_image_missile = ProjectileType.create("Abilities\\Weapons\\BloodElfSpellThiefMISSILE\\BloodElfSpellThiefMISSILE.mdl", 3.0, 1400)
        call ashbringer_image_missile.enableHoming(ashbringer_image_hit, 0.0)
        
        set ashbringer_brand_buff = BuffType.create(5.0, 0.0, false)
        call ashbringer_brand_buff.setBuffIcon('@@0@@')
        call ashbringer_brand_buff.addEventOnCreate(EventHandler.ashbringer_brand_oncreate)
        call ashbringer_brand_buff.addEventOnAttacked(EventHandler.ashbringer_brand_ondamaged, 1.0, 0.0)
        //call ashbringer_brand_buff.addPeriodicEvent(ashbringer_harvest_periodic, 1.0)
    endfunction
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [3] => Array
                (
                    [name] => On Damage
                    [code] => call ashbringer_brand_buff.apply(tower, Event.getTarget(), tower.getLevel())
                    [values] => Array
                        (
                            [ONDAMAGE_chance] => 0.1
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNMagicalSentry.blp
                            [name] => Brand of Deception
                            [short_explain] => Attacks have a chance to cause enemies to take additional damage when attacked.
                            [ONDAMAGE_chanceLevelAdd] => 0.004
                            [long_explain] => Attacks have a |cffFFFF8010%|r chance to brand the enemy on hit for |cffFFFF805.0|r seconds. The branded enemy takes |cffFFFF8015|r spell damage every time it is attacked by any tower or mirror image.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.4%|r chance|n|cffFFFF80+0.6|r spell damage
                        )

                )

            [4] => Array
                (
                    [name] => Autocast
                    [code] => set tower.userInt = tower.userInt + 1
    call Effect.createSimpleOnUnit("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", tower, "chest").setLifetime(2.0)
                    [values] => Array
                        (
                            [AUTOCAST_cooldown] => 4
                            [AUTOCAST_autoRange] => 900
                            [AUTOCAST_manacost] => 50
                            [icon] => ReplaceableTextures\CommandButtons\BTNInvisibility.blp
                            [AUTOCAST_range] => 900
                            [AUTOCAST_targetType] => 0
                            [AUTOCAST_numBuffsBeforeIdle] => 0
                            [caster_art] => 
                            [long_explain] => Causes the Spellblade's next attack to conjure a mirror image of himself that will attack enemies or teleport to enemies if none are in range. Mirror images deal |cffFFFF8050%|r of the attack damage and last |cffFFFF808|r seconds. Duration is increased by buff duration.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+2%|r of attack damage
                            [target_art] => 
                            [AUTOCAST_autocastType] => AC_TYPE_OFFENSIVE_IMMEDIATE
                            [AUTOCAST_buffType] => 0
                            [AUTOCAST_isExtended] => false
                            [name] => Mirror Image
                            [AUTOCAST_targetSelf] => false
                            [short_explain] => Summons a mirror image to attack enemies.
                        )

                )

            [5] => Array
                (
                    [name] => On Tower Creation
                    [code] => call SetUnitColor(tower.getUnit(), ConvertPlayerColor(3))
    
    set tower.userInt = 0
    set tower.userInt2 = 0
    set tower.userReal = 15 + (tower.getLevel() * 0.6)
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => BHab
                    [oeValues] => Array
                        (
                            [Targetattach] => overhead
                            [Buffubertip] => Taking spell damage when attacked.
                            [TargetArt] => war3mapImported\BrandBlue.mdx
                            [Bufftip] => Brand of Deception
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNMagicalSentry.blp
                        )

                )

        )

    [units] => Array
        (
        )

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

        )

    [lightning] => Array
        (
        )

)