Skip to content

Commit

Permalink
add satanic helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Eroica-cpp committed Oct 31, 2020
1 parent 0044396 commit 3e1a7c3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions AutoUseItems.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ AutoUseItems.optionLotus = Menu.AddOption({"Item Specific"}, "Lotus Orb", "(For
AutoUseItems.optionCrest = Menu.AddOption({"Item Specific"}, "Medallion & Crest", "Auto use medallion & crest to save ally")
AutoUseItems.optionGlimmerCape = Menu.AddOption({"Item Specific"}, "Glimmer Cape", "Auto use Glimmer Cape when channeling spells or ally in danger")
AutoUseItems.optionGhost = Menu.AddOption({"Item Specific"}, "Ghost Scepter", "Auto use ghost scepter to avoid damage from physical cores")
AutoUseItems.optionSatanic = Menu.AddOption({"Item Specific"}, "Satanic", "Auto use Satanic when (i) legion or axe is around; or (ii) hp is low and my hero is attacking.")

function AutoUseItems.OnUpdate()
local myHero = Heroes.GetLocal()
Expand Down Expand Up @@ -70,6 +71,10 @@ function AutoUseItems.OnUpdate()
AutoUseItems.item_ghost(myHero)
end

if Menu.IsEnabled(AutoUseItems.optionSatanic) then
AutoUseItems.item_satanic(myHero)
end

-- ========================
-- Aggressive items
-- ========================
Expand Down Expand Up @@ -537,6 +542,30 @@ function AutoUseItems.item_ghost(myHero)
end
end

-- Auto use Satanic when (i) legion or axe is around; or (ii) hp is low and my hero is attacking.
function AutoUseItems.item_satanic(myHero)
local item = NPC.GetItem(myHero, "item_satanic", true)
if not item or not Ability.IsCastable(item, NPC.GetMana(myHero)) then return end

-- when hp is low and myHero is attacking
if Entity.GetHealth(myHero) <= 0.5 * Entity.GetMaxHealth(myHero) and NPC.IsAttacking(myHero) then
Ability.CastNoTarget(item)
return
end

-- when legion or axe is around
for i = 1, Heroes.Count() do
local enemy = Heroes.Get(i)
if enemy and not NPC.IsIllusion(enemy) and not Entity.IsSameTeam(myHero, enemy)
and not Utility.IsDisabled(enemy) and Utility.IsAxeOrLegion[NPC.GetUnitName(enemy)]
and NPC.IsEntityInRange(myHero, enemy, 300) then

Ability.CastNoTarget(item)
return
end
end
end

-- Auto cast Glimmer Cape to ally or yourself when channeling spell or need to be saved.
function AutoUseItems.item_glimmer_cape(myHero)
local item = NPC.GetItem(myHero, "item_glimmer_cape", true)
Expand Down
4 changes: 4 additions & 0 deletions Utility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Utility.AncientCreepNameList = {
"npc_dota_roshan"
}

Utility.IsAxeOrLegion = {}
Utility.IsAxeOrLegion["npc_dota_hero_legion_commander"] = true
Utility.IsAxeOrLegion["npc_dota_hero_axe"] = true

Utility.PhysicalCoreHeroes = {}
Utility.PhysicalCoreHeroes["npc_dota_hero_abaddon"] = true
Utility.PhysicalCoreHeroes["npc_dota_hero_alchemist"] = true
Expand Down

0 comments on commit 3e1a7c3

Please sign in to comment.