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

            [Art] => ReplaceableTextures\CommandButtons\BTNDivineAegis.blp
            [turnRate] => 3
            [dmgplus1] => 86
            [bldtm] => 1
            [goldcost] => 250
            [unitSound] => Priest
            [sides1] => 1
            [Missilearc] => 0.1
            [acquire] => 1000
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Devout Falconer
            [weapTp1] => missile
            [MissileHoming] => 1
            [file] => units\creeps\Medivh\Medivh.mdl
            [uberSplat] => YTDO
            [Missileart] => war3mapImported\SerpentWardMissileHoly.mdl
            [Missilespeed] => 1400
            [dice1] => 1
            [RngBuff1] => 250
            [modelScale] => 0.55
            [rangeN1] => 1000
            [atkType1] => normal
            [cool1] => 1.8
            [Ubertip] => A hunter of the faith, guided by a radiant wing.
            [scaleBull] => 0
            [abilList] => Array
                (
                )

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

            [targs1] => Array
                (
                )

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

    [settings] => Array
        (
            [balanceTip] => |cffFFFF005%|r spell crit chance (|cffFFFF00+0.5%|r/lvl)
            [abil_factor] => 0.19
            [author] => Ashbringer
            [alpha] => 255
            [authorDisplay] => |cffff6600Ashbringer|r
            [version] => 1.0
            [element] => astral
            [rarity] => uncommon
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => -0.0713139
                    [y] => 0.0101136
                    [z] => 0
                    [scale] => 0.2
                    [rot] => 3.92699
                    [file] => Doodads\Ruins\Props\Ruins_NagaCircle\Ruins_NagaCircle.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 205
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [1] => Array
                (
                    [x] => 0.0459353
                    [y] => -0.0628024
                    [z] => -96
                    [scale] => 1
                    [rot] => 4.71239
                    [file] => Doodads\Ruins\Props\RuinsPillar\RuinsPillar2.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [2] => Array
                (
                    [x] => -0.232761
                    [y] => 46.4132
                    [z] => -6.4
                    [scale] => 0.35
                    [rot] => 0.566104
                    [file] => Doodads\Ruins\Props\RuinsPillar\RuinsPillar3.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [3] => Array
                (
                    [x] => -32.1503
                    [y] => 31.8375
                    [z] => -6.4
                    [scale] => 0.35
                    [rot] => 0
                    [file] => Doodads\Ruins\Props\RuinsPillar\RuinsPillar2.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [4] => Array
                (
                    [x] => 31.075
                    [y] => 32.4769
                    [z] => -6.4
                    [scale] => 0.35
                    [rot] => 0
                    [file] => Doodads\Ruins\Props\RuinsPillar\RuinsPillar4.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

            [5] => Array
                (
                    [x] => -0.046063
                    [y] => 0.0342374
                    [z] => -12.8
                    [scale] => 1.2
                    [rot] => 1.11701
                    [file] => war3mapImported\GeneralAuraTargetWhite.mdl
                    [red] => 255
                    [green] => 225
                    [blue] => 1
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

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

        )

    [dmgTable] => Array
        (
            [0] => Array
                (
                    [id] => MOD_SPELL_CRIT_CHANCE
                    [base] => 0.0375
                    [add] => 0.005
                )

        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => On Attack
                    [code] => local Projectile p = tower.userInt
    set tower.userReal = tower.userReal + (0.5 + (tower.getLevel() * 0.02))
    call Effect.create("Abilities\\Spells\\Items\\StaffOfPurification\\PurificationTarget.mdl", p.x, p.y, p.z, 270)
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNAbility_paladin_blessedmending.blp
                            [name] => Sacred Bond
                            [short_explain] => Chance on attack to empower Sunwing.
                            [ONATTACK_chance] => 0.15
                            [ONATTACK_chanceLevelAdd] => 0.006
                            [long_explain] => Attacks have a |cffffff8015%|r chance to increase the spell damage of Sunwing's next attack by |cffffff8050%|r. This effect can stack.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+0.6%|r chance|n|cffFFFF80+2%|r damage
                        )

                )

            [1] => Array
                (
                    [name] => Header
                    [code] => globals
        //@export
        ProjectileType ashbringer_spirit_missile
    endglobals

    function AngleDifference takes real a, real b returns real
        local real diff = a - b
        loop
            exitwhen diff <= 180 and diff >= -180
            if diff > 180 then
                set diff = diff - 360
            elseif diff < -180 then
                set diff = diff + 360
            endif
        endloop
        return diff
    endfunction
    
    function ashbringer_spirit_attack takes Tower tower, Projectile p returns nothing
        local Iterate i = Iterate.overUnitsInRangeOfCaster(tower, TARGET_TYPE_CREEPS, tower.getRange())
        local Unit next = i.nextRandom()
        
        if next !=0 then
            call i.destroy()
            call p.disablePeriodic()
            set p.speed = 900
            set p.accelerate = 10
            call p.aimAtUnit(next, true, false, false)
        else
            set p.userInt = 0
        endif
    endfunction
    
    function ashbringer_spirit_update takes Projectile p returns nothing
        local Tower tower = p.getCaster()
        local real ox = tower.getX()
        local real oy = tower.getY()

        local real currentFacing = p.direction
        local real desiredAngle
        local real angleDiff
        local real distance
        local real z

        local real turnRate
        local real maxTurn = 12.0
        
        local real wanderJitter = 1.5
        local real wanderInfluence = 1.1

        set p.userReal = p.userReal + 0.2
        
        if p.userInt == 2 then
            if p.userReal >= 0.5 then
                set p.speed = 350
                set p.userInt = 0
                set p.userReal = 0
                set p.zangle = 0
                call p.setZSpeed(0)
            endif
        elseif p.userReal >= 2.6 then
            set p.remainingLifetime = 5000
            set p.userReal = 0
            set p.userInt = 1
            call ashbringer_spirit_attack(tower, p)
        elseif p.userInt == 0 then
            set z = p.getAbsoluteZ()
            if z >=450 and z <=600 then
                call p.setZSpeed(0)
            elseif p.z < 450 then
                call p.setZSpeed(2)
            elseif p.z > 600 then
                call p.setZSpeed(-2)
            endif
        
            set p.userReal2 = Game.getGameTime()
            set distance = SquareRoot((p.x - ox)*(p.x - ox) + (p.y - oy)*(p.y - oy))

            set desiredAngle = AngleBetweenPoints(Location(p.x, p.y), Location(ox, oy))

            set angleDiff = AngleDifference(desiredAngle, currentFacing)
            
            set p.userReal3 = p.userReal3 + GetRandomReal(-wanderJitter, wanderJitter)

            if p.userReal3 > 3.0 then
                set p.userReal3 = 3.0
            elseif p.userReal3 < -3.0 then
                set p.userReal3 = -3.0
            endif

            if distance > 1000.0 then
                set turnRate = angleDiff * 0.25
            elseif distance > 750.0 then
                set turnRate = angleDiff * 0.10 + p.userReal3 * 0.3
            else
                set turnRate = p.userReal3 * wanderInfluence
            endif

            if turnRate > maxTurn then
                set turnRate = maxTurn
            elseif turnRate < -maxTurn then
                set turnRate = -maxTurn
            endif

            set p.rotation = turnRate
        endif
    endfunction
    
    function ashbringer_spirit_hit takes Projectile p, Unit target returns nothing
        local Tower tower = p.getCaster()
        local real x = p.x + (900 / 3) * Cos(Deg2Rad(p.direction))
        local real y = p.y + (900 / 3) * Sin(Deg2Rad(p.direction))
        
        call p.avertDestruction()
        set p.userInt = 2
        set p.speed = 900
        set p.accelerate = 0
        call p.enablePeriodic(R2I(0.2*25.0+0.5))
        call p.aimAtPoint(x, y, 300, false, false)
        
        if target != 0 then
            call tower.doSpellDamage(target, (tower.userReal2 + (tower.getLevel() * tower.userReal3)) * tower.userReal, tower.calcSpellCritNoBonus())
            call Effect.createSimpleOnUnit("Abilities\\Weapons\\SorceressMissile\\SorceressMissile.mdl", target, "chest").destroy()
            set tower.userReal = 1
        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
        local Modifier mod = Modifier.create()
        
        set ashbringer_spirit_missile = ProjectileType.create("Abilities\\Weapons\\SorceressMissile\\SorceressMissile.mdl", 3000, 350)
        call ashbringer_spirit_missile.enablePeriodic(ProjectileEvent.ashbringer_spirit_update, 0.2)
        call ashbringer_spirit_missile.enableHoming(ProjectileTargetEvent.ashbringer_spirit_hit, 0.0)
    endfunction
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNAvenging_Crusader.blp
                            [name] => Sunwing
                            [short_explain] => A celestial spirit roams the skies, swooping down to deal spell damage to enemies.
                            [long_explain] => A celestial spirit roams the skies, swooping at a random enemy within the tower's attack range every |cffffff803|r seconds to deal |cffffff80400|r spell damage.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+16|r spell damage
                        )

                )

            [2] => Array
                (
                    [name] => On Tower Destruction
                    [code] => local Projectile p = tower.userInt
    
    call p.destroy()
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [3] => Array
                (
                    [name] => Periodic
                    [code] => local Projectile p = tower.userInt
    local real current_time = Game.getGameTime()
    
    //check if birb is broken and respawn
    if (current_time - p.userReal2) / 25 > 15 then
        call p.destroy()
        set p = Projectile.createFromUnit(ashbringer_spirit_missile, tower, tower, 270, 0, 0)
        set tower.userInt = p
    endif
                    [values] => Array
                        (
                            [visible] => false
                            [PERIODIC_period] => 60
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [4] => Array
                (
                    [name] => On Tower Creation
                    [code] => local Projectile p = Projectile.createFromUnit(ashbringer_spirit_missile, tower, tower, 270, 0, 0)
    
    call AddUnitAnimationProperties(tower.getUnit(), "alternate", false)
    call p.setScale(1.3)
    set p.z = 300
    set p.userInt = 0
    set tower.userInt = p
    set tower.userReal = 1
    set tower.userReal2 = 400
    set tower.userReal3 = 16
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
        )

    [buffs] => Array
        (
        )

    [units] => Array
        (
        )

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

        )

    [lightning] => Array
        (
        )

)