Array
(
    [scriptVersion] => 7
    [oeValues] => Array
        (
            [RngBuff1] => 250
            [MissileHoming] => 1
            [Upgrade] => Array
                (
                )

            [targs1] => Array
                (
                )

            [animProps] => small
            [goldcost] => 2500
            [weapsOn] => 1
            [dice1] => 1
            [Missilespeed] => 1500
            [file] => Abilities\Spells\Undead\FreezingBreath\FreezingBreathTargetArt.mdl
            [atkType1] => pierce
            [modelScale] => 0.6
            [weapTp1] => missile
            [acquire] => 800
            [rangeN1] => 800
            [upgrades] => Array
                (
                )

            [cool1] => 1.4
            [Ubertip] => The frozen king of all ice and snow.
            [abilList] => Array
                (
                )

            [Name] => Lich King
            [Missileart] => Abilities\Weapons\LichMissile\LichMissile.mdl
            [Art] => ReplaceableTextures\CommandButtons\BTNLament.blp
            [buildingShadow] => Array
                (
                )

            [unitSound] => Frostmourne
            [sides1] => 100
            [uberSplat] => OSMA
            [auto] => Array
                (
                )

            [dmgplus1] => 2196
            [bldtm] => 1
        )

    [settings] => Array
        (
            [author] => Natac
            [element] => ice
            [authorDisplay] => Natac
            [alpha] => 255
            [balanceTip] => Array
                (
                )

            [rarity] => unique
            [version] => 1.0
            [abil_factor] => 0.5
        )

    [effects] => Array
        (
            [0] => Array
                (
                    [x] => 14.5468
                    [y] => -24.6643
                    [z] => 32
                    [scale] => 0.25
                    [rot] => 5.48068
                    [file] => doodads\cinematic\lichking\lichking.mdl
                    [red] => 175
                    [green] => 175
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [1] => Array
                (
                    [x] => -0.707791
                    [y] => 2.33899
                    [z] => -6.4
                    [scale] => 0.38
                    [rot] => 3.54386
                    [file] => Doodads\Icecrown\Rocks\Glacier\Glacier0.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [2] => Array
                (
                    [x] => -49.9794
                    [y] => -2.84339
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 0.122173
                    [file] => Doodads\Icecrown\Props\IceCrownPillar\IceCrownPillar0.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [3] => Array
                (
                    [x] => -38.0706
                    [y] => -22.2272
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 0.122173
                    [file] => Doodads\Icecrown\Props\IceCrownPillar\IceCrownPillar0.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [4] => Array
                (
                    [x] => -18.3507
                    [y] => -32.2668
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 0.122173
                    [file] => Doodads\Icecrown\Props\IceCrownPillar\IceCrownPillar0.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [5] => Array
                (
                    [x] => 24.9899
                    [y] => 37.5404
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 0.122173
                    [file] => Doodads\Icecrown\Props\IceCrownPillar\IceCrownPillar0.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [6] => Array
                (
                    [x] => 6.39579
                    [y] => 50.1842
                    [z] => 0
                    [scale] => 0.15
                    [rot] => 0.122173
                    [file] => Doodads\Icecrown\Props\IceCrownPillar\IceCrownPillar0.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [7] => Array
                (
                    [x] => 25.9438
                    [y] => -53.6991
                    [z] => -32
                    [scale] => 0.3
                    [rot] => 0.122173
                    [file] => Doodads\Icecrown\Props\IceCrownPillar\IceCrownPillar0.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [8] => Array
                (
                    [x] => 54.9935
                    [y] => -27.0411
                    [z] => -32
                    [scale] => 0.3
                    [rot] => 0.122173
                    [file] => Doodads\Icecrown\Props\IceCrownPillar\IceCrownPillar0.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [9] => Array
                (
                    [x] => -6.11301
                    [y] => 8.34484
                    [z] => -19.2
                    [scale] => 0.4
                    [rot] => 5.48942
                    [file] => Doodads\Icecrown\Terrain\IceCrownWall90\IceCrownWall901.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [10] => Array
                (
                    [x] => 55.469
                    [y] => -26.6387
                    [z] => 38.4
                    [scale] => 0.15
                    [rot] => 4.71332
                    [file] => Doodads\Icecrown\Props\IceCrownObelisk\IceCrownObelisk1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [11] => Array
                (
                    [x] => 26.1625
                    [y] => -53.3067
                    [z] => 38.4
                    [scale] => 0.15
                    [rot] => 4.63724
                    [file] => Doodads\Icecrown\Props\IceCrownObelisk\IceCrownObelisk1.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [12] => Array
                (
                    [x] => -25.2574
                    [y] => -23.429
                    [z] => -6.4
                    [scale] => 0.75
                    [rot] => 4.73979
                    [file] => Doodads\Icecrown\Water\IceEdge\IceEdge2.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [13] => Array
                (
                    [x] => 33.8814
                    [y] => -38.6983
                    [z] => -6.4
                    [scale] => 0.6
                    [rot] => 6.11618
                    [file] => Doodads\Icecrown\Water\IceEdge\IceEdge2.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [14] => Array
                (
                    [x] => -38.7522
                    [y] => 43.5783
                    [z] => -6.4
                    [scale] => 0.5
                    [rot] => 4.8183
                    [file] => Doodads\Icecrown\Water\IceEdge\IceEdge2.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

            [15] => Array
                (
                    [x] => 30.179
                    [y] => 22.9163
                    [z] => -6.4
                    [scale] => 0.75
                    [rot] => 3.9474
                    [file] => Doodads\Icecrown\Water\IceEdge\IceEdge2.mdl
                    [red] => 255
                    [green] => 255
                    [blue] => 255
                    [alpha] => 255
                    [pitch] => 0
                    [advanced] => false
                    [animation] => Array
                        (
                        )

                    [aniSpeed] => 50
                )

        )

    [dmgTable] => Array
        (
        )

    [triggers] => Array
        (
            [0] => Array
                (
                    [name] => On Tower Creation
                    [code] => set tower.userReal = 0 // Damage stored for creeps dying under the auras effect.
                    [values] => Array
                        (
                            [icon] => 
                            [visible] => false
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [1] => Array
                (
                    [name] => On Damage
                    [code] => call natac_icyCurse_BuffType.apply(tower, Event.getTarget(), tower.getLevel())
                    [values] => Array
                        (
                            [ONDAMAGE_chance] => 1.0
                            [icon] => ReplaceableTextures\CommandButtons\BTNFrostmourne.blp
                            [visible] => true
                            [name] => Icy Curse
                            [short_explain] => Applies a curse on damaged creeps lowering their debuff resistance.
                            [ONDAMAGE_chanceLevelAdd] => 0.0
                            [long_explain] => Curses creeps it damages for |cffFFFF805|r seconds, lowering their debuff resistance by |cffFFFF8030%|r.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80-0.8%|r debuff resistance
                        )

                )

            [2] => Array
                (
                    [name] => On Tower Details
                    [code] => call   natac_storedDamage_MuliboardValue.setValue(0, formatFloat(tower.userReal,0))
    return natac_storedDamage_MuliboardValue
                    [values] => Array
                        (
                        )

                )

            [3] => Array
                (
                    [name] => Header
                    [code] => globals
        BuffType         natac_icyCurse_BuffType
        BuffType         natac_kingsPresent_Aura
        MultiboardValues natac_storedDamage_MuliboardValue
    endglobals
    
    function initAuraBuff takes Buff b returns nothing
        set b.userInt  = Game.getGameTime() // The time at which the buff was applied
        set b.userInt2 = b.getLevel()  // The max dps of this buff*
        set b.userInt3 = b.getCaster() // The king, ruling over this unit*
        set b.userReal = 0.0 // Stored damage, if the creep leaves the range of an enraged king*
        //*) only needed if you have 2 kings in a row and no CleanUp event is fired, cause the units 
        //   directly enter the aura of the 2nd king.
    endfunction
    
    function enterNewArea takes Buff b returns nothing
        local integer newDps      = b.getLevel()
        local Tower   oldKing     = b.userInt3 // The king who has ruled over this unit until now.
        // The damage the unit would have suffered from the old king, if it werent entering a new area now.
        local real    oldWrathDmg = oldKing.userReal*(0.5+oldKing.getLevel()*0.04)
        
        set oldKing.userReal = 0.0      // Reset stored damage of the old king
        set b.userReal3 = b.getCaster() // Set to the new king, ruling over this unit now
        
        // Store the max dps, if the dps of the new area is higher 
        if(newDps > b.userInt2) then 
            set b.userInt2 = newDps
        endif
        
        // Attach wrath dmg of the old king, to deal the dmg later
        if(oldWrathDmg > 0.0) then 
            set b.userReal = b.userReal + oldWrathDmg
        endif
    endfunction
    
    function doDamage takes Buff b returns nothing
        local Unit    target = b.getBuffedUnit()
        local Unit    caster = b.getCaster()
        
        // (1) Calculate time gone since the buff was applied
        // (2) multiply by 0.04 to get seconds 
        // (3) finally multiply with max dmg per second to get overall damage
        local real damage = (Game.getGameTime()-b.userInt)*0.04*b.userInt2
        
        // (4) Add the stored damage, other kings would have done to this unit
        set damage = damage + b.userReal
        
        if(GetUnitState(target.getUnit(), UNIT_STATE_LIFE) > 0 ) then   
            // Creep is alive: Add all stored damage to the normal dealt damage
            if(caster.userReal > 0) then
                call  caster.getTeam().displayFloatingText("Feel the Wrath!", caster, 15,15,200)
                // Add stored damage
                set   damage = damage + (caster.userReal*(0.5+caster.getLevel()*0.04)) 
                set   caster.userReal = 0.0 // Reset stored damage
            endif
            call  SFXAtUnit("Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl", target.getUnit())  
            call  caster.doSpellDamage(b.getBuffedUnit(), damage, caster.calcSpellCritNoBonus())
            call  caster.getTeam().displayFloatingText(I2S(R2I(damage)), target,15,15,200) //Show at TARGET
        else
            // Creep is dead: Store damage for the next alive creep
            set   caster.userReal = caster.userReal + damage
            call  caster.getTeam().displayFloatingText("+"+I2S(R2I(damage)), caster,15,15,200) //Show at CASTER
        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 icyCurseMod  = Modifier.create()
        call  icyCurseMod.addModification(MOD_DEBUFF_RESISTANCE, -0.30, -0.008)
        set   natac_icyCurse_BuffType = BuffType.create(5, 0.0, false)
        call  natac_icyCurse_BuffType.setBuffModifier(icyCurseMod)
        call  natac_icyCurse_BuffType.setBuffIcon('@@0@@')
    
        set   natac_kingsPresent_Aura = BuffType.createAuraEffectType(false)
        call  natac_kingsPresent_Aura.addEventOnCreate (EventHandler.initAuraBuff)
        call  natac_kingsPresent_Aura.setEventOnRefresh(EventHandler.enterNewArea)
        call  natac_kingsPresent_Aura.addEventOnCleanup(EventHandler.doDamage)
        call  natac_kingsPresent_Aura.setBuffIcon('@@1@@')
        
        set  natac_storedDamage_MuliboardValue = MultiboardValues.create(1)
        call natac_storedDamage_MuliboardValue.setKey(0, "Stored Damage")
	endfunction
                    [values] => Array
                        (
                            [icon] => 
                            [visible] => false
                            [name] => 
                            [short_explain] => 
                            [long_explain] => 
                        )

                )

            [4] => Array
                (
                    [name] => Tower Aura
                    [code] => Array
                        (
                        )

                    [values] => Array
                        (
                            [icon] => ReplaceableTextures\CommandButtons\BTNRevenant.blp
                            [visible] => true
                            [AURA_auraEffect] => natac_kingsPresent_Aura
                            [AURA_power] => 500
                            [long_explain] => The Lich King rules over every creep in |cffFFFF80900|r range. Every creep leaving this range will be punished with |cffFFFF80500|r spelldamage for every second it was under this aura's effect.|nIf a creep dies in this area of authority, the spelldamage that didn't get dealt is stored. The next creep to then leave the Lich King's area will be punished with |cffFFFF80[stored damage x 0.5]|r spelldamage.|n|n|cffFF8000Level Bonus:|r|n|cffFFFF80+20|r damage per second|n|cffFFFF80+[stored damage x 0.04]|r spelldamage
                            [AURA_level] => 500
                            [AURA_auraRange] => 900
                            [AURA_targetType] => TARGET_TYPE_CREEPS
                            [AURA_levelAdd] => 20
                            [AURA_powerAdd] => 20
                            [name] => King's Authority
                            [AURA_targetSelf] => false
                            [short_explain] => Units leaving the aura around this tower will suffer damage.
                        )

                )

        )

    [abilities] => Array
        (
        )

    [buffs] => Array
        (
            [0] => Array
                (
                    [id] => @@0@@
                    [derivedFrom] => Bslo
                    [oeValues] => Array
                        (
                            [Bufftip] => Cursed
                            [Targetattach] => origin
                            [Buffubertip] => This unit has been cursed by a Lich King; buffs placed on this unit will last longer than usual.
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNFrostmourne.blp
                            [TargetArt] => Abilities\Spells\Other\Drain\ManaDrainTarget.mdl
                            [EditorName] => Cursed
                        )

                )

            [1] => Array
                (
                    [id] => @@1@@
                    [derivedFrom] => Bslo
                    [oeValues] => Array
                        (
                            [Bufftip] => Ruled
                            [Targetattach] => origin
                            [Buffubertip] => A Lich King rules over this unit; it will suffer damage if it leaves the king's area of authority.
                            [Buffart] => ReplaceableTextures\CommandButtons\BTNRevenant.blp
                            [TargetArt] => Abilities\Weapons\ZigguratFrostMissile\ZigguratFrostMissile.mdl
                            [EditorName] => Ruled
                        )

                )

        )

    [units] => Array
        (
        )

    [references] => Array
        (
        )

)