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

            [Art] => ReplaceableTextures\CommandButtons\BTNRedDragon.blp
            [turnRate] => 0.3
            [dmgplus1] => 5999
            [bldtm] => 1
            [goldcost] => 4800
            [sides1] => 1001
            [acquire] => 950
            [upgrades] => Array
                (
                )

            [Upgrade] => Array
                (
                )

            [Name] => Crimson Wyrm
            [weapTp1] => missile
            [MissileHoming] => 1
            [file] => units\creeps\RedDragon\RedDragon.mdl
            [uberSplat] => OSMA
            [Missileart] => Abilities\Weapons\RedDragonBreath\RedDragonMissile.mdl
            [Missilespeed] => 1500
            [dice1] => 1
            [RngBuff1] => 250
            [modelScale] => 0.6
            [rangeN1] => 950
            [backSw1] => 0.56
            [atkType1] => pierce
            [cool1] => 2
            [Ubertip] => Ancient and greedy Wyrm which takes away most of your goldgain.
            [abilList] => Array
                (
                )

            [moveHeight] => 100
            [dmgpt1] => 0.4
            [buildingShadow] => Array
                (
                )

            [targs1] => Array
                (
                )

            [weapsOn] => 1
        )

    [settings] => Array
        (
            [balanceTip] => |cffFFFF00+50% |rbounty collected (|cffFFFF00+3%|r/lvl)
            [abil_factor] => 0.5515
            [author] => SirCoqaLot.
            [alpha] => 255
            [authorDisplay] => SirCoqaLot.
            [version] => 1.0
            [element] => fire
            [rarity] => unique
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => 43.8158
                    [y] => -18.6112
                    [z] => -12.8
                    [scale] => 0.11
                    [rot] => 2.48783
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [1] => Array
                (
                    [x] => 52.9502
                    [y] => 3.80805
                    [z] => -12.8
                    [scale] => 0.1
                    [rot] => 2.95871
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [2] => Array
                (
                    [x] => 35.5477
                    [y] => 29.3164
                    [z] => -12.8
                    [scale] => 0.16
                    [rot] => 3.92858
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [3] => Array
                (
                    [x] => -35.7791
                    [y] => 13.8934
                    [z] => -12.8
                    [scale] => 0.14
                    [rot] => 5.19282
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [4] => Array
                (
                    [x] => -11.5449
                    [y] => 31.9103
                    [z] => -12.8
                    [scale] => 0.16
                    [rot] => 4.71763
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [5] => Array
                (
                    [x] => -33.1664
                    [y] => -13.7327
                    [z] => -12.8
                    [scale] => 0.13
                    [rot] => 0.106967
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [6] => Array
                (
                    [x] => -38.7329
                    [y] => -19.6022
                    [z] => 0
                    [scale] => 0.1
                    [rot] => 3.35914
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [7] => Array
                (
                    [x] => 47.3972
                    [y] => -23.8978
                    [z] => 0
                    [scale] => 0.1
                    [rot] => 6.16077
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [8] => Array
                (
                    [x] => -45.6312
                    [y] => -0.878968
                    [z] => 0
                    [scale] => 0.08
                    [rot] => 5.79228
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [9] => Array
                (
                    [x] => -33.8406
                    [y] => 30.0133
                    [z] => 0
                    [scale] => 0.07
                    [rot] => 4.12235
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [10] => Array
                (
                    [x] => 48.6376
                    [y] => 13.7844
                    [z] => 0
                    [scale] => 0.08
                    [rot] => 0.698132
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [11] => Array
                (
                    [x] => 37.1144
                    [y] => 42.5684
                    [z] => 0
                    [scale] => 0.08
                    [rot] => 4.15388
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [12] => Array
                (
                    [x] => 59.7888
                    [y] => 2.3768
                    [z] => 0
                    [scale] => 0.08
                    [rot] => 3.08773
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [13] => Array
                (
                    [x] => 35.7613
                    [y] => -32.059
                    [z] => 0
                    [scale] => 0.09
                    [rot] => 5.2006
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [14] => Array
                (
                    [x] => -33.0606
                    [y] => -28.5796
                    [z] => 0
                    [scale] => 0.08
                    [rot] => 5.86431
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [15] => Array
                (
                    [x] => 21.0768
                    [y] => 45.8649
                    [z] => 0
                    [scale] => 0.06
                    [rot] => 4.0224
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [16] => Array
                (
                    [x] => -18.3729
                    [y] => 35.4028
                    [z] => 0
                    [scale] => 0.06
                    [rot] => 4.66703
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [17] => Array
                (
                    [x] => -4.90729
                    [y] => 45.3737
                    [z] => 0
                    [scale] => 0.06
                    [rot] => 4.37306
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [18] => Array
                (
                    [x] => 8.84372
                    [y] => 44.7982
                    [z] => 0
                    [scale] => 0.06
                    [rot] => 0.525587
                    [file] => Doodads\Outland\Rocks\Outland_Spires\Outland_Spires1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => -0.5
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [19] => Array
                (
                    [x] => 8.74754
                    [y] => -4.10514
                    [z] => -12.8
                    [scale] => 0.7
                    [rot] => 5.46422
                    [file] => Doodads\Dungeon\Rocks\Cave_FieryCrator\Cave_FieryCrator.mdl
                    [red] => 255
                    [green] => 180
                    [blue] => 120
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [20] => Array
                (
                    [x] => 14.2536
                    [y] => 20.1608
                    [z] => 0
                    [scale] => 0.7
                    [rot] => 0.228613
                    [file] => Doodads\Barrens\Props\Barrens_Bones\Barrens_Bones6.mdl
                    [red] => 255
                    [green] => 150
                    [blue] => 150
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [21] => Array
                (
                    [x] => -8.31184
                    [y] => -20.4989
                    [z] => 0
                    [scale] => 0.65
                    [rot] => 1.79923
                    [file] => Doodads\Barrens\Props\Barrens_Bones\Barrens_Bones6.mdl
                    [red] => 255
                    [green] => 150
                    [blue] => 150
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

        )

    [dmgTable] => Array
        (
            [0] => Array
                (
                    [id] => MOD_BOUNTY_RECEIVED
                    [base] => 0.5
                    [add] => 0.03
                )

        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => On Attack
                    [code] => local integer level = tower.getLevel()
    
    // check if 0 attacks remain till fireballs
    if tower.userInt > 0 then                  
        set tower.userInt = tower.userInt - 1
    else    
        // setting minimum number of attacks before next fireballs
        if level == 25 then
            set tower.userInt = 5
        elseif level >= 15 then
            set tower.userInt = 6
        else
            set tower.userInt = 7
        endif
        // set +0,+1 or +2 attacks and release bolts afterwards
        set tower.userInt = tower.userInt + GetRandomInt(0,4) 
        // setting the number of fireballs
        if level >= 10 then
            call releaseFireballs(tower, 4)
        else
            call releaseFireballs(tower, 3)
        endif
        
    endif
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [ONATTACK_chance] => 1.0
                            [ONATTACK_chanceLevelAdd] => 0.0
                            [long_explain] => 
                        )

                )

            [1] => Array
                (
                    [name] => Header
                    [code] => globals
        MultiboardValues sir_wyrm_bonus
        ProjectileType sir_wyrm_projectile
    endglobals
    
    // function being called whenever the hoard is updated
    function sir_update takes Tower tower, real value returns nothing
		call tower.modifyProperty(MOD_DAMAGE_BASE_PERC, -tower.userReal / 10000)
		call tower.modifyProperty(MOD_SPELL_DAMAGE_DEALT, -tower.userReal / 10000)
        set tower.userReal = tower.userReal + value
		call tower.modifyProperty(MOD_DAMAGE_BASE_PERC, tower.userReal / 10000)
		call tower.modifyProperty(MOD_SPELL_DAMAGE_DEALT, tower.userReal / 10000)
    endfunction
    
    private function sir_wyrm_hit takes Projectile p, Unit u returns nothing
        local Tower t = p.getCaster()
        local integer l = t.getLevel()
        local real critmod 
        
        if l >= 20 then 
            set critmod = 0.1
        elseif l >= 5 and l < 20 then
            set critmod = 0.05
        else 
            set critmod = 0
        endif
        
        call t.doSpellDamageAoE(p.x,p.y,180,3750+l*150,t.calcSpellCrit(critmod,0),0)
    endfunction
    
    function releaseFireballs takes Tower tower, integer balls returns nothing
        local integer level = tower.getLevel()
        local Iterate it = Iterate.overUnitsInRangeOfCaster(tower,TARGET_CREEPS,950)
        local Unit target
        local Unit last = 0
        loop
            set target = it.nextRandom()
            exitwhen target == 0
            call Projectile.createBezierInterpolationFromUnitToUnit(sir_wyrm_projectile,tower,1,1,tower,target,0,GetRandomReal(-0.35,0.35),GetRandomReal(0.17,0.4),true).setScale(2.0)// gives the fireballs a slightly random trajectory
            set balls = balls - 1
            set last = target
            exitwhen balls == 0
        endloop
        if target != 0 then
            //Targets remain, so all balls must've been fired.
            call it.destroy()
        elseif balls > 0 then
            if last != 0 then
                //Shoot remaining balls at last target. (This is ALRIGHT, because there is a max of 4 balls all up.
                //So worst case scenario, there are two creeps in range: one of them is hit with one fireball, and the other with three.)
                loop
                    call Projectile.createBezierInterpolationFromUnitToUnit(sir_wyrm_projectile,tower,1,1,tower,last,0,GetRandomReal(-0.35,0.35),GetRandomReal(0.17,0.4),true).setScale(2.0)// gives the fireballs a slightly random trajectory
                    set balls = balls - 1
                    exitwhen balls == 0
                endloop
            else
                set tower.userInt = 0 //(shoot all fireballs on next attack.)
            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 sir_wyrm_bonus = MultiboardValues.create(3)
        call sir_wyrm_bonus.setKey(0,"Gold Hoarded")
        call sir_wyrm_bonus.setKey(1,"Bonus Damage")
        call sir_wyrm_bonus.setKey(2,"Atks to Fireballs")
        set sir_wyrm_projectile = ProjectileType.createInterpolate("Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl",700)
        call sir_wyrm_projectile.setEventOnInterpolationFinished(sir_wyrm_hit)
	endfunction
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNWallOfFire.blp
                            [name] => Flaming Inferno
                            [short_explain] => The Wyrm releases fireballs every few attacks, dealing AoE spelldamage.
                            [long_explain] => Every |cffffff807th-11th|r attack releases |cffffff803|r fireballs that fly towards random targets in |cffffff80950|r range, dealing |cffffff803750|r spelldamage in |cffffff80180|r AoE around the target on impact.|n|n|cffFF8000Level Bonus:|r|n|cffffff80+150|r spelldamage|n|cffffff80-1|r minimum and maximum attack needed at levels |cffffff8015|r and |cffffff8025|r|n|cffffff80+1|r fireball at level |cffffff8010|r|n|cffffff80+5%|r bonus crit chance at levels |cffffff805|r and |cffffff8020|r
                        )

                )

            [2] => Array
                (
                    [name] => On Tower Details
                    [code] => call sir_wyrm_bonus.setValue(0,formatFloat(tower.userReal,0))
    call sir_wyrm_bonus.setValue(1,formatFloat(tower.userReal/100,0)+"%")
    call sir_wyrm_bonus.setValue(2,I2S(tower.userInt))
    return sir_wyrm_bonus
                    [values] => Array
                        (
                            [0] => Array
                                (
                                    [_value] => 0
                                    [typ] => string
                                )

                        )

                )

            [3] => Array
                (
                    [name] => On Kill
                    [code] => local Creep creep() = Event.getTarget()
    local integer level = tower.getLevel()
    local real value = 0.75*creep.getBaseBountyValue()*creep.getProp_BountyGranted()*tower.getProp_BountyReceived()
    local real hoardSize = 30000+1200*level
    if tower.userReal >= hoardSize then
        set value = 0
    elseif tower.userReal + value > hoardSize then
        set value = hoardSize-tower.userReal
    endif
    if value != 0 then       
        call sir_update(tower,value)
        call tower.getOwner().giveGold(-value,tower.getUnit(), false, false)
        call SFXAtUnit("Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl",tower.getUnit())
    endif
                    [values] => Array
                        (
                            [visible] => true
                            [icon] => ReplaceableTextures\CommandButtons\BTNHowlOfTerror.blp
                            [name] => Dragon's Hoard
                            [short_explain] => Hoards a portion of the kill bounty to increase spelldamage and attackdamage.
                            [long_explain] => Whenever the Crimson Wyrm kills a creep it hoards |cffffff8075%|r of the bounty. The hoard has a maximum capacity of |cffffff8030000|r gold and grants |cffffff80[gold hoarded / 100]%|r spelldamage and base attackdamage. |n|n|cffffff80Hint:|r This ability is modified by both the creep's and this tower's bounty ratios. |n|n|cffFF8000Level Bonus:|r|n|cffffff80+1200|r maximum gold
                        )

                )

            [4] => Array
                (
                    [name] => On Tower Creation
                    [code] => local Tower preceding = Event.getPrecedingTower()
    set tower.userReal = 0
    if preceding.getUnitType() == tower.getUnitType() then //This is kind of obsolete, but whatever
        call sir_update(tower,preceding.userReal)   //Somebody might replace this tower with this tower
    endif
    set tower.userInt = 9// mediocre cd for first wave of fireballs
                    [values] => Array
                        (
                            [visible] => false
                            [icon] => 
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

        )

    [abilities] => Array
        (
        )

    [buffs] => Array
        (
        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

)