Militia Watchtower v1
250
ID:
417
Family ID:
Author:
ShyGnome
Rarity:
uncommon
Element:
iron
Attack Type:
Physical
Attack Range:
850
Attack CD:
0.7
Damage:
71-71
Abil. Factor:
0.433
Status:
Approved

Description:

Militia guardians rain axes at the heads of the enemies. However, they are not very accurate, and afraid of undead and large creeps.

Latest Upload Comment:

Restored from 1.10
Specials:
-20% dmg to bosses (+0.6%/lvl)
-20% dmg to undead (+0.4%/lvl)
+20% dmg to nature (+0.4%/lvl)
Hail of Axes
Militia guardians throw axes to up to 3 enemies at once, but each attack has 33% chance to miss.  If there are less creeps than attacks, the remaining axes will hit the main target.

Level Bonus:
-1% chance to miss
+1 target at levels 15 and 25
Download

Toggle Triggers

Header

    globals
        //@export
        ProjectileType MilitiaAxe
    endglobals

    function MilitiaAxeHit takes Projectile p, Unit target returns nothing
   local Tower tower = p.getCaster()
   if tower.calcBadChance(0.33-0.01*tower.getLevel()) then
      call tower.getOwner().displayFloatingTextX("Miss",tower,255, 0, 0,255,0.05,0.0,2.0)
   else
      call tower.doAttackDamage(target,tower.getCurrentAttackDamageWithBonus(),tower.calcAttackCritNoBonus())
   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 MilitiaAxe = ProjectileType.createInterpolate("Abilities\\Weapons\\Axe\\AxeMissile.mdl",800)
            call MilitiaAxe.setEventOnInterpolationFinished(MilitiaAxeHit)
    endfunction

On Attack

ONATTACK_chance: 1.0 ONATTACK_chanceLevelAdd: 0.0
function onAttack takes Tower tower returns nothing
    local integer attacks = 2
    local boolean add = false
    local Unit maintarget = Event.getTarget()
    local Unit target
    local Iterate it = Iterate.overUnitsInRangeOfUnit(tower,TARGET_TYPE_CREEPS,maintarget,450)
    local real sidearc = 0.20
    local boolean itDestroyed = false
 
    if tower.getLevel() >= 15 then
        set attacks = attacks + 1
    endif

    if tower.getLevel() >= 25 then
        set attacks = attacks + 1
    endif
    
    loop
        exitwhen attacks == 0 // Exit when all attacks are fired
        
        // If the Iterate is not destroyed, get the next target
        if not itDestroyed then
            set target = it.next()
        
            // If there are no more targets
            if target == 0 then
                set itDestroyed = true // Iterate is destroyed (auto destroy)
                set target = maintarget // target is the maintarget now
            endif
        endif
  
        // If there are no more units, shoot at the maintarget (itDestroyed). If there are units then don't shoot at the maintarget
        if itDestroyed or target != maintarget then
            call Projectile.createBezierInterpolationFromUnitToUnit(MilitiaAxe,tower,0,0,tower,target,0,sidearc,0,true).setScale(0.40)
            set attacks = attacks - 1
            set sidearc = -sidearc
            if add then
                set sidearc = sidearc + 0.20
            endif
            set add = not add
        endif

    endloop
 
    // If the Iterate is not destroyed yet, destroy it
    if not itDestroyed then
        call it.destroy()
    endif  
endfunction

On Damage

ONDAMAGE_chance: 1.0 ONDAMAGE_chanceLevelAdd: 0.0
function onDamage takes Tower tower returns nothing
    if tower.calcBadChance(0.33-0.01*tower.getLevel()) then
        set Event.damage = 0
        call tower.getOwner().displayFloatingTextX("Miss",tower,255, 0, 0,255,0.05,0.0,2.0)
    endif
endfunction

On Tower Creation

function onCreate takes Tower tower returns nothing
    set tower.userInt = 1 // Save the family member (1 = first member)
    set tower.userInt2 = 0 // Used to save the buff (double linked list)
endfunction