Nuclear Missile Launcher v1
3400
|
ID: 596
Family ID:
Author: Natac
Rarity: unique
Element: iron
Attack Type: Essence
Attack Range: 2400
Attack CD: 10
Damage: 17777-17778
Abil. Factor: 1.0
Status: Approved
|
Specials:
Attacks GROUND only Splash attack: 400 AoE: 100% damage 500 AoE: 75% damage 600 AoE: 50% damage |
Download
Toggle Triggers Header globals
BuffType natac_LauncherTarget_Buff
//@export
BuffType natac_cooldownBar_BuffType //COOLDOWN BAR: Buff
//COOLDOWN BAR: Globals
hashtable natac_cooldown_map = InitHashtable()
string BAR_TEXT = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" // x 60
integer TIMER = 0
integer TEXT_TAG = 1
integer BAR = 2
integer CURRENT_STEP = 3
integer TIMER_PERIOD = 4
// COOLDOWN BAR: End Globals
endglobals
// === COOLDOWN BAR: Code ===
// Used to have a cool bar that is showing the time left until the towers cooldown is ready.
// This function decreases the bar every time a step is over (=the timer expires)
function oneStepDone takes nothing returns nothing
local timer stepTimer = GetExpiredTimer()
local integer stepTimerId = GetHandleId(stepTimer) // The timers id, needed for the hash map
local texttag bar = LoadTextTagHandle(natac_cooldown_map, stepTimerId, BAR) // Get the floating text ifself
local integer currentStep = LoadInteger(natac_cooldown_map, stepTimerId, CURRENT_STEP) + 1
local real colorFactor = currentStep * 0.033 // This factor is used to change the red and green of the bar
if(currentStep < 30) then // Time left: shorten the bar
call SetTextTagText(bar, SubString(BAR_TEXT, 0, R2I(60-(currentStep*2))), 0.023) // Shorten bar
call SetTextTagColor(bar, IMinBJ(R2I((1-colorFactor)*510),255), IMinBJ(R2I(colorFactor*510),255), 0, 170) // Fade bar color from red to green
call SaveInteger(natac_cooldown_map, stepTimerId, CURRENT_STEP, currentStep) // Increase step count
call TimerStart(stepTimer, LoadReal(natac_cooldown_map, stepTimerId, TIMER_PERIOD), false, function oneStepDone) // Start timer again
else // Cooldown is ready: Clean up
call DestroyTextTag(bar)
call ReleaseTimer(stepTimer)
call RemoveSavedHandle(natac_cooldown_map, stepTimerId, BAR)
call RemoveSavedInteger(natac_cooldown_map, stepTimerId, CURRENT_STEP)
call RemoveSavedReal(natac_cooldown_map, stepTimerId, TIMER_PERIOD)
endif
set stepTimer = null
set bar = null
endfunction
// Used to have a cool bar that is showing the time left until the towers cooldown is ready.
// This function shows the bar and starts the timer for the first step
function onAttack_StartFirstSequence takes Buff b returns nothing
local texttag bar = CreateTextTag() // This becomes the bar
local timer stepTimer = NewTimer() // A timer, expiring everytime the next step will be done
local integer stepTimerId = GetHandleId(stepTimer)
local Tower tower = b.getBuffedUnit()
local real stepPeriod = tower.getCurrentAttackspeed() / 30 // The time between 2 steps
local real offset = 60 * 0.45 // The offset to center the bar above the unit
call SetTextTagText(bar, BAR_TEXT, 0.023)
call SetTextTagPermanent(bar, false)
call SetTextTagColor(bar, 255, 0, 0, 170) // Create bar with some transparency
call SetTextTagPos(bar, tower.getX()-offset, tower.getY(), 150) // Center bar above the unit
call SaveTextTagHandle(natac_cooldown_map, stepTimerId, BAR, bar) // Store the bar itself
call SaveInteger(natac_cooldown_map, stepTimerId, CURRENT_STEP, 0) // Store the current step (we start here, so its 0)
call SaveReal(natac_cooldown_map, stepTimerId, TIMER_PERIOD, stepPeriod) // Store the time between 2 steps
call TimerStart(stepTimer, stepPeriod, false, function oneStepDone) // Start timer
set bar = null
set stepTimer = null
endfunction
// === COOLDOWN BAR: End Code ===
// === Nuclear Missle Launcher - Code ===
function initalizeTargetCounter takes Buff b returns nothing
set b.userInt = 0
endfunction
function increaseTargetCounter takes Buff b returns nothing
set b.userInt = b.userInt + 1
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 natac_LauncherTarget_Buff = BuffType.create(-1.0, 0.0, false)
call natac_LauncherTarget_Buff.setBuffIcon('@@0@@')
call natac_LauncherTarget_Buff.addEventOnCreate(EventHandler.initalizeTargetCounter)
call natac_LauncherTarget_Buff.setEventOnRefresh(EventHandler.increaseTargetCounter)
// COOLDOWN BAR: Initialize Buff
set natac_cooldownBar_BuffType = BuffType.create(-1.0, 0, true)
call natac_cooldownBar_BuffType.addEventOnAttack(EventHandler.onAttack_StartFirstSequence, 1.0, 0.0)
// COOLDOWN BAR: End Initialize Buff
endfunction
On Attack
ONATTACK_chance: 1.0
ONATTACK_chanceLevelAdd: 0.0
function onAttack takes Tower tower returns nothing
call natac_LauncherTarget_Buff.apply(tower, Event.getTarget(), tower.getLevel())
endfunction
On Damage
ONDAMAGE_chance: 1.0
ONDAMAGE_chanceLevelAdd: 0.0
function onDamage takes Tower tower returns nothing
local Unit target = Event.getTarget()
local Buff targetBuff
local Effect targetEffect
if(Event.isMainTarget()) then
set targetEffect = Effect.createAnimatedScaled("Abilities\\Weapons\\Mortar\\MortarMissile.mdl",target.getX(),target.getY(),0.0,0,3.0)
call targetEffect.setAnimationSpeed(0.5)
call targetEffect.setLifetime(0.05)
set targetBuff = target.getBuffOfType(natac_LauncherTarget_Buff)
if(targetBuff != 0 and targetBuff.userInt <= 0) then
call targetBuff.removeBuff()
else
set targetBuff.userInt = targetBuff.userInt - 1
endif
endif
call SFXOnUnit("Abilities\\Spells\\Other\\AcidBomb\\BottleMissile.mdl", target.getUnit(), "origin")
endfunction
On Tower Creation function onCreate takes Tower tower returns nothing
call natac_cooldownBar_BuffType.apply(tower, tower, 1)
endfunction
|
Description:
Latest Upload Comment: