From b59ef9b17ed0848b06bb04b426449fbd8e77438e Mon Sep 17 00:00:00 2001 From: Tao Li Date: Mon, 26 Jun 2017 10:21:37 -0700 Subject: [PATCH] remove lua files by other authors --- .gitignore | 6 +- AbilityAlert.lua | 151 --------------------------------------- CooldownDisplay.lua | 167 -------------------------------------------- 3 files changed, 5 insertions(+), 319 deletions(-) delete mode 100644 AbilityAlert.lua delete mode 100644 CooldownDisplay.lua diff --git a/.gitignore b/.gitignore index ecbf039..b5216a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -test.lua \ No newline at end of file +test.lua + +# ignore lua files written by other authors +CooldownDisplay.lua +AbilityAlert.lua diff --git a/AbilityAlert.lua b/AbilityAlert.lua deleted file mode 100644 index ee117a3..0000000 --- a/AbilityAlert.lua +++ /dev/null @@ -1,151 +0,0 @@ -local AbilityAlert = {} - -AbilityAlert.option = Menu.AddOption({ "Awareness" }, "Ability Alert", "Alerts you when certain abilities are used.") -AbilityAlert.font = Renderer.LoadFont("Tahoma", 22, Enum.FontWeight.EXTRABOLD) -AbilityAlert.mapFont = Renderer.LoadFont("Tahoma", 16, Enum.FontWeight.NORMAL) - --- current active alerts. -AbilityAlert.alerts = {} - -AbilityAlert.ambiguous = -{ - { - name = "nyx_assassin_vendetta_start", - msg = "Nyx has used Vendetta", - duration = 15, - unique = true - }, - { - name = "smoke_of_deceit", - msg = "Smoke of Deceit has been used", - duration = 35, - unique = false - } -} - -AbilityAlert.teamSpecific = -{ - -- unique because this particle gets created for every enemy team hero. - { - name = "mirana_moonlight_recipient", - msg = "Mirana has used her ult", - duration = 15, - unique = true - } -} - --- Returns true if an alert was created, false otherwise. -function AbilityAlert.InsertAmbiguous(particle) - for i, enemyAbility in ipairs(AbilityAlert.ambiguous) do - if particle.name == enemyAbility.name then - local newAlert = { - index = particle.index, - name = enemyAbility.name, - msg = enemyAbility.msg, - endTime = os.clock() + enemyAbility.duration, - } - - table.insert(AbilityAlert.alerts, newAlert) - - return true - end - end - - return false -end - --- Returns true if an alert was created (or an existing one was extended), false otherwise. -function AbilityAlert.InsertTeamSpecific(particle) - local myHero = Heroes.GetLocal() - if not myHero then return false end - - if particle.entity == nil then return end - if Entity.IsSameTeam(myHero, particle.entity) then return end - - for i, enemyAbility in ipairs(AbilityAlert.teamSpecific) do - if particle.name == enemyAbility.name then - local newAlert = { - index = particle.index, - name = enemyAbility.name, - msg = enemyAbility.msg, - endTime = os.clock() + enemyAbility.duration, - } - - if not enemyAbility.unique then - table.insert(AbilityAlert.alerts, newAlert) - - return true - else - -- Look for an existing alert. - for k, alert in ipairs(AbilityAlert.alerts) do - if alert.msg == newAlert.msg then - alert.endTime = newAlert.endTime -- Just extend the existing time. - - return true - end - end - - -- Insert the new alert. - table.insert(AbilityAlert.alerts, newAlert) - - return true - end - end - end - - return false -end - --- --- Callbacks --- -function AbilityAlert.OnParticleCreate(particle) - --Log.Write(particle.name .. "=" .. string.format("0x%x", particle.particleNameIndex)) - - if not Menu.IsEnabled(AbilityAlert.option) then return end - - if not AbilityAlert.InsertAmbiguous(particle) then - AbilityAlert.InsertTeamSpecific(particle) - end -end - -function AbilityAlert.OnParticleUpdate(particle) - if particle.controlPoint ~= 0 then return end - - for k, alert in ipairs(AbilityAlert.alerts) do - if particle.index == alert.index then - alert.position = particle.position - end - end -end - -function AbilityAlert.OnDraw() - for i, alert in ipairs(AbilityAlert.alerts) do - local timeLeft = math.max(alert.endTime - os.clock(), 0) - - if timeLeft <= 0 then - table.remove(AbilityAlert.alerts, i) - else - -- Fade out the last 5 seconds of the alert. - local alpha = math.floor(255 * math.min(timeLeft / 5, 1)) - - -- Some really obnoxious color to grab your attention. - Renderer.SetDrawColor(255, 0, 255, alpha) - - local w, h = Renderer.GetScreenSize() - - Renderer.DrawTextCentered(AbilityAlert.font, w / 2, h / 2 + (i - 1) * 22, alert.msg, 1) - - if alert.position then - local x, y, onScreen = Renderer.WorldToScreen(alert.position) - - if onScreen then - Renderer.DrawTextCentered(AbilityAlert.mapFont, x, y, alert.name, 1) - --Renderer.DrawFilledRect(x - 5, y - 5, 10, 10) - end - end - end - end -end - -return AbilityAlert diff --git a/CooldownDisplay.lua b/CooldownDisplay.lua deleted file mode 100644 index 54ecaa9..0000000 --- a/CooldownDisplay.lua +++ /dev/null @@ -1,167 +0,0 @@ -local CooldownDisplay = {} - -CooldownDisplay.option = Menu.AddOption({ "Awareness", "Cooldown Display" }, "Cooldown Display", "Displays enemy hero cooldowns in an easy and intuitive way.") -CooldownDisplay.boxSizeOption = Menu.AddOption({ "Awareness", "Cooldown Display" }, "Cooldown Display Size", "", 21, 64, 1) -CooldownDisplay.needsInit = true -CooldownDisplay.spellIconPath = "resource/flash3/images/spellicons/" -CooldownDisplay.cachedIcons = {} - -CooldownDisplay.colors = {} - -function CooldownDisplay.InsertColor(alias, r_, g_, b_) - table.insert(CooldownDisplay.colors, { name = alias, r = r_, g = g_, b = b_}) -end - -CooldownDisplay.InsertColor("Green", 0, 255, 0) -CooldownDisplay.InsertColor("Yellow", 234, 255, 0) -CooldownDisplay.InsertColor("Red", 255, 0, 0) -CooldownDisplay.InsertColor("Blue", 0, 0, 255) -CooldownDisplay.InsertColor("White", 255, 255, 255) -CooldownDisplay.InsertColor("Black", 0, 0, 0) - -CooldownDisplay.levelColorOption = Menu.AddOption({ "Awareness", "Cooldown Display" }, "Cooldown Display Level Color", "", 1, #CooldownDisplay.colors, 1) - -for i, v in ipairs(CooldownDisplay.colors) do - Menu.SetValueName(CooldownDisplay.levelColorOption, i, v.name) -end - -function CooldownDisplay.InitDisplay() - CooldownDisplay.boxSize = Menu.GetValue(CooldownDisplay.boxSizeOption) - CooldownDisplay.innerBoxSize = CooldownDisplay.boxSize - 2 - CooldownDisplay.levelBoxSize = math.floor(CooldownDisplay.boxSize * 0.1875) - - CooldownDisplay.font = Renderer.LoadFont("Tahoma", math.floor(CooldownDisplay.innerBoxSize * 0.643), Enum.FontWeight.BOLD) -end - --- callback -function CooldownDisplay.OnMenuOptionChange(option, old, new) - if option == CooldownDisplay.boxSizeOption then - CooldownDisplay.InitDisplay() - end -end - -function CooldownDisplay.DrawDisplay(hero) - local pos = Entity.GetAbsOrigin(hero) - pos:SetY(pos:GetY() - 50.0) - - local x, y, vis = Renderer.WorldToScreen(pos) - - if not vis then return end - - local abilities = {} - - for i = 0, 24 do - local ability = NPC.GetAbilityByIndex(hero, i) - - if ability ~= nil and Entity.IsAbility(ability) and not Ability.IsHidden(ability) and not Ability.IsAttributes(ability) then - table.insert(abilities, ability) - end - end - - local startX = x - math.floor((#abilities / 2) * CooldownDisplay.boxSize) - - -- black background - Renderer.SetDrawColor(0, 0, 0, 150) - Renderer.DrawFilledRect(startX + 1, y - 1, (CooldownDisplay.boxSize * #abilities) + 2, CooldownDisplay.boxSize + 2) - - -- draw the actual ability squares now - for i, ability in ipairs(abilities) do - CooldownDisplay.DrawAbilitySquare(hero, ability, startX, y, i - 1) - end - - -- black border - Renderer.SetDrawColor(0, 0, 0, 255) - Renderer.DrawOutlineRect(startX + 1, y - 1, (CooldownDisplay.boxSize * #abilities) + 2, CooldownDisplay.boxSize + 2) -end - -function CooldownDisplay.DrawAbilitySquare(hero, ability, x, y, index) - local abilityName = Ability.GetName(ability) - local imageHandle = CooldownDisplay.cachedIcons[abilityName] - - if imageHandle == nil then - imageHandle = Renderer.LoadImage(CooldownDisplay.spellIconPath .. abilityName .. ".png") - CooldownDisplay.cachedIcons[abilityName] = imageHandle - end - - local realX = x + (index * CooldownDisplay.boxSize) + 2 - - local castable = Ability.IsCastable(ability, NPC.GetMana(hero), true) - - -- default colors = can cast - local imageColor = { 255, 255, 255 } - local outlineColor = { 0, 255 , 0 } - - if not castable then - if Ability.GetLevel(ability) == 0 then - imageColor = { 125, 125, 125 } - outlineColor = { 255, 0, 0 } - elseif Ability.GetManaCost(ability) > NPC.GetMana(hero) then - imageColor = { 150, 150, 255 } - outlineColor = { 0, 0, 255 } - else - imageColor = { 255, 150, 150 } - outlineColor = { 255, 0, 0 } - end - end - - Renderer.SetDrawColor(imageColor[1], imageColor[2], imageColor[3], 255) - Renderer.DrawImage(imageHandle, realX, y, CooldownDisplay.boxSize, CooldownDisplay.boxSize) - - Renderer.SetDrawColor(outlineColor[1], outlineColor[2], outlineColor[3], 255) - Renderer.DrawOutlineRect(realX, y, CooldownDisplay.boxSize, CooldownDisplay.boxSize) - - local cdLength = Ability.GetCooldownLength(ability) - - if not Ability.IsReady(ability) and cdLength > 0.0 then - local cooldownRatio = Ability.GetCooldown(ability) / cdLength - local cooldownSize = math.floor(CooldownDisplay.innerBoxSize * cooldownRatio) - - Renderer.SetDrawColor(255, 255, 255, 50) - Renderer.DrawFilledRect(realX + 1, y + (CooldownDisplay.innerBoxSize - cooldownSize) + 1, CooldownDisplay.innerBoxSize, cooldownSize) - - Renderer.SetDrawColor(255, 255, 255) - Renderer.DrawText(CooldownDisplay.font, realX + 1, y, math.floor(Ability.GetCooldown(ability)), 0) - end - - CooldownDisplay.DrawAbilityLevels(ability, realX, y) -end - -function CooldownDisplay.DrawAbilityLevels(ability, x, y) - local level = Ability.GetLevel(ability) - - x = x + 1 - y = ((y + CooldownDisplay.boxSize) - CooldownDisplay.levelBoxSize) - 1 - - local color = CooldownDisplay.colors[Menu.GetValue(CooldownDisplay.levelColorOption)] - - for i = 1, level do - Renderer.SetDrawColor(color.r, color.g, color.b, 255) - Renderer.DrawFilledRect(x + ((i - 1) * CooldownDisplay.levelBoxSize), y, CooldownDisplay.levelBoxSize, CooldownDisplay.levelBoxSize) - - Renderer.SetDrawColor(0, 0, 0, 255) - Renderer.DrawOutlineRect(x + ((i - 1) * CooldownDisplay.levelBoxSize), y, CooldownDisplay.levelBoxSize, CooldownDisplay.levelBoxSize) - end -end - -function CooldownDisplay.OnDraw() - if not Menu.IsEnabled(CooldownDisplay.option) then return end - - local myHero = Heroes.GetLocal() - - if not myHero then return end - - if CooldownDisplay.needsInit then - CooldownDisplay.InitDisplay() - CooldownDisplay.needsInit = false - end - - for i = 1, Heroes.Count() do - local hero = Heroes.Get(i) - - if not Entity.IsSameTeam(myHero, hero) and not Entity.IsDormant(hero) and not NPC.IsIllusion(hero) and Entity.IsAlive(hero) then - CooldownDisplay.DrawDisplay(hero) - end - end -end - -return CooldownDisplay \ No newline at end of file