Skip to content

Commit

Permalink
Fix many bugs in 7.29 (#44)
Browse files Browse the repository at this point in the history
Fix rune mode;
Add battle power evaluation of illusion;
Change ability building tree of Chen, Dazzle, Kotl, Dazzle;
Implement Life_stealer, Dragon_knight, Leshrac, Magnataur, Phantom_assassin;
Try to improve Kunkka’s x-mark combo;
Fix bugs in Alchemist, Bane, Kunkka;

Co-authored-by: adamqqq <[email protected]>
  • Loading branch information
AaronSong321 and adamqqqplay authored Apr 23, 2021
1 parent cfceab3 commit 7e5c352
Show file tree
Hide file tree
Showing 159 changed files with 2,884 additions and 926 deletions.
23 changes: 9 additions & 14 deletions ability_item_usage_abaddon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Consider[1]=function() -- TODO: lv 25 AOE mist coil

local HeroHealth=10000
local CreepHealth=10000
local allys = npcBot:GetNearbyHeroes( CastRange+300, false, BOT_MODE_NONE );
local allys = npcBot:GetNearbyHeroes( CastRange+150, false, BOT_MODE_NONE );
for _,hero in pairs (allys)
do
if (hero==npcBot)
Expand All @@ -128,7 +128,7 @@ Consider[1]=function() -- TODO: lv 25 AOE mist coil
end
end
local WeakestAlly,AllyHealth=utility.GetWeakestUnit(allys)
local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE)
local enemys = npcBot:GetNearbyHeroes(CastRange+150,true,BOT_MODE_NONE)
local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys)
local creeps = npcBot:GetNearbyCreeps(CastRange+300,true)
local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps)
Expand All @@ -149,18 +149,7 @@ Consider[1]=function() -- TODO: lv 25 AOE mist coil
end
end
end

-- If we're seriously retreating, try to suicide
if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH )
then
if ( #enemys>=1 and npcBot:WasRecentlyDamagedByAnyHero(2.0) and npcBot:GetHealth() <= SelfDamage)
then
if ( CanCast[abilityNumber]( enemys[1] ))
then
return BOT_ACTION_DESIRE_HIGH, enemys[1];
end
end
end

--------------------------------------
-- Mode based usage
--------------------------------------
Expand All @@ -186,6 +175,12 @@ Consider[1]=function() -- TODO: lv 25 AOE mist coil
end
end
end

if npcBot:HasModifier("modifier_abaddon_borrowed_time") then
if WeakestEnemy ~= nil then
return BOT_ACTION_DESIRE_MODERATE, WeakestEnemy
end
end

-- If we're going after someone
if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or
Expand Down
8 changes: 5 additions & 3 deletions ability_item_usage_alchemist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ end
--------------------------------------
local cast={} cast.Desire={} cast.Target={} cast.Type={}
local Consider ={}
local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast,utility.CanCastNoTarget}
local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast,utility.CanCastNoTarget,utility.NCanCast}
local enemyDisabled=utility.enemyDisabled

function GetComboDamage()
Expand Down Expand Up @@ -109,7 +109,9 @@ Consider[1]=function()
--------------------------------------

local ability=AbilitiesReal[abilityNumber];

if not ability:IsFullyCastable() then
return 0
end
local CastRange = ability:GetCastRange();
local Damage = ability:GetAbilityDamage();
local Radius = ability:GetAOERadius()
Expand Down Expand Up @@ -518,7 +520,7 @@ Consider[6]=function()
for _,npcEnemy in pairs( enemys )do
if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) then
if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) then
if (GetUnitToUnitDistance(npcBot,npcEnemy)>CastRange-100 and GetUnitToUnitDistance(npcBot,npcEnemy)<CastRange) or (TimeSinceCast>3 and TimeSinceCast<5)
if (GetUnitToUnitDistance(npcBot,npcEnemy)>CastRange-100 and GetUnitToUnitDistance(npcBot,npcEnemy)<CastRange) or (TimeSinceCast>2 and TimeSinceCast<5)
or npcEnemy:GetHealth()/npcEnemy:GetMaxHealth() <= 0.2 then
return BOT_ACTION_DESIRE_HIGH,npcEnemy
end
Expand Down
2 changes: 1 addition & 1 deletion ability_item_usage_ancient_apparition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ Consider[3]=function()
--------------------------------------
local ability=AbilitiesReal[abilityNumber];

if not ability:IsFullyCastable() then
if not ability:IsFullyCastable() or AbilityExtensions:IsPhysicalOutputDisabled(npcBot) then
return BOT_ACTION_DESIRE_NONE, 0;
end

Expand Down
11 changes: 10 additions & 1 deletion ability_item_usage_antimage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ local utility = require( GetScriptDirectory().."/utility" )
require(GetScriptDirectory() .. "/ability_item_usage_generic")
local AbilityExtensions = require(GetScriptDirectory().."/util/AbilityAbstraction")

-- for k,v in pairs(GetUnitList(UNIT_LIST_ALLIED_WARDS)) do
-- print("unit: "..v:GetUnitName()..", "..AbilityExtensions:ToStringVector(v:GetLocation()))
-- end
-- for k,v in pairs(GetUnitList(UNIT_LIST_ENEMY_WARDS)) do
-- print("unit: "..v:GetUnitName()..", "..AbilityExtensions:ToStringVector(v:GetLocation()))
-- end
-- for k,v in pairs(GetUnitList(UNIT_LIST_ENEMY_HEROES)) do
-- print("unit: "..v:GetUnitName()..", "..AbilityExtensions:ToStringVector(v:GetLocation()))
-- end

local debugmode=false
local npcBot = GetBot()
Expand Down Expand Up @@ -95,7 +104,7 @@ Consider[2]=function()
--------------------------------------
local ability=AbilitiesReal[abilityNumber];

if not ability:IsFullyCastable() then
if not ability:IsFullyCastable() or not AbilityExtensions:CanMove(npcBot) then
return BOT_ACTION_DESIRE_NONE, 0;
end

Expand Down
34 changes: 20 additions & 14 deletions ability_item_usage_arc_warden.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,17 @@ Consider[1]=function()
--------------------------------------
--protect myself
local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE );
--[[ If we're seriously retreating, see if we can land a stun on someone who's damaged us recently
if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0)
then
for _,npcEnemy in pairs( enemys )
do
if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400)
then
return BOT_ACTION_DESIRE_HIGH, npcEnemy;
end
end
end]]
-- --[[ If we're seriously retreating, see if we can land a stun on someone who's damaged us recently
-- if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0)
-- then
-- for _,npcEnemy in pairs( enemys )
-- do
-- if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400)
-- then
-- return BOT_ACTION_DESIRE_HIGH, npcEnemy;
-- end
-- end
-- end]]

-- If my mana is enough,use it at enemy
if ( npcBot:GetActiveMode() == BOT_MODE_LANING )
Expand Down Expand Up @@ -475,18 +475,24 @@ Consider[4]=function()
local CastPoint = ability:GetCastPoint();

local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE );
local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE)
local enemys = npcBot:GetNearbyHeroes(800,true,BOT_MODE_NONE)
local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys)
local creeps = npcBot:GetNearbyCreeps(CastRange+300,true)
local creeps = npcBot:GetNearbyCreeps(800,true)
local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps)
--------------------------------------
-- Global high-priorty usage
--------------------------------------

-- Stop making a huge bounty for the enemy
if (npcBot:GetHealth() <= 450 or HealthPercentage <= 0.3) and (npcBot:WasRecentlyDamagedByAnyHero(1.5) or AbilityExtensions:CanHardlyMove(npcBot) or not AbilityExtensions:CanMove(npcBot)) and not AbilityExtensions:Outnumber(allys, enemys) then
return 0
end

-- If we're in a teamfight, use it on the scariest enemy
local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK );
if ( #tableNearbyAttackingAlliedHeroes >= 2 )
then
return BOT_ACTION_DESIRE_HIGH, npcMostDangerousEnemy;
return BOT_ACTION_DESIRE_HIGH
end
--------------------------------------
-- Mode based usage
Expand Down
1 change: 0 additions & 1 deletion ability_item_usage_axe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ local TalentTree={

-- check skill build vs current level
utility.CheckAbilityBuild(AbilityToLevelUp)
AbilityExtensions:DebugArray(AbilityToLevelUp)

function AbilityLevelUpThink()
ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree)
Expand Down
46 changes: 42 additions & 4 deletions ability_item_usage_bane.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ local Talents ={}
local Abilities ={}
local AbilitiesReal ={}

ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents)
ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents)

local AbilityToLevelUp=
{
Expand Down Expand Up @@ -233,7 +233,7 @@ Consider[2]=function()

local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE );
local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE)
local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys)
local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(AbilityExtensions:Filter(enemys, function(t) return not AbilityExtensions:HasAbilityRetargetModifier(t) end))
local creeps = npcBot:GetNearbyCreeps(CastRange+300,true)
local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps)
--------------------------------------
Expand Down Expand Up @@ -454,7 +454,7 @@ Consider[4]=function()
-- Check for a channeling enemy
for _,npcEnemy in pairs( enemys )
do
if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy ))
if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy ) and not AbilityExtensions:HasAbilityRetargetModifier(npcEnemy))
then
return BOT_ACTION_DESIRE_HIGH, npcEnemy
end
Expand Down Expand Up @@ -523,6 +523,10 @@ Consider[4]=function()
end
end
end]]

if AbilityExtensions:IsRetreating(npcBot) and #enemys == 0 and not AbilityExtensions:HasAbilityRetargetModifier(enemys[1]) then
return BOT_ACTION_DESIRE_HIGH, enemys[0]
end

-- If we're going after someone
if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or
Expand All @@ -541,12 +545,46 @@ Consider[4]=function()
end
end

local disabledAllies = AbilityExtensions:Filter(allys, function(t) return AbilityExtensions:IsSeverlyDisabled(t) and not t:IsChanneling() end)
disabledAllies = AbilityExtensions:SortByMinFirst(disabledAllies, function(t) return t:GetHealth() end)
if #disabledAllies ~= 0 then
return BOT_ACTION_DESIRE_MODERATE, disabledAllies[1]
end

disabledAllies = AbilityExtensions:Filter(allys, function(t)
local b = t:GetIncomingTrackingProjectiles()
return AbilityExtensions:Any(b, function(s)
return GetUnitToLocationDistance(t, s.location) <= 400 and not s.is_attack
end)
end)
if disabledAllies ~= 0 then
disabledAllies = AbilityExtensions:SortByMinFirst(disabledAllies, function(t) return t:GetHealth() end)
return BOT_ACTION_DESIRE_MODERATE, disabledAllies[1]
end

return BOT_ACTION_DESIRE_NONE, 0;

end

Consider[5]=function()
return BOT_ACTION_DESIRE_NONE, 0;
local enemies = AbilityExtensions:GetNearbyNonIllusionHeroes(npcBot, 1200, true, BOT_MODE_NONE)
local nightmaredEnemies = AbilityExtensions:Filter(enemies, function(t) return t:HasModifier("modifier_bane_nightmare") end)
local friends = AbilityExtensions:GetNearbyNonIllusionHeroes(npcBot, 1200, false, BOT_MODE_NONE)
local nightmaredFriends = AbilityExtensions:Filter(friends, function(t) return t:HasModifier("modifier_bane_nightmare") end)
if #nightmaredEnemies ~= 0 then
if #enemies == 1 and #friends >= 2 and AbilityExtensions:GetModifierRemainingDuration(nightmaredFriends[1], "modifier_bane_nightmare") <= 4
or AbilityExtensions:All(nightmaredEnemies, function(t) return AbilityExtensions:GetHealthPercent(t) <= 0.3 and AbilityExtensions:GetModifierRemainingDuration(nightmaredFriends[1], "modifier_bane_nightmare") <= 4 end) and AbilityExtensions:All(friends, function(t) return AbilityExtensions:GetHealthPercent(t) >= 0.5 end) then
return BOT_ACTION_DESIRE_HIGH
end
end
if #nightmaredFriends ~= 0 then
if AbilityExtensions:All(nightmaredFriends, function(t)
return AbilityExtensions:GetHealthPercent(t) >= 0.3
end) or AbilityExtensions:All(nightmaredFriends, function(t) return #t:GetIncomingTrackingProjectiles() == 0 end) and #enemies == 0 then
return BOT_ACTION_DESIRE_HIGH
end
end
return BOT_ACTION_DESIRE_NONE
end

AbilityExtensions:AutoModifyConsiderFunction(npcBot, Consider, AbilitiesReal)
Expand Down
21 changes: 20 additions & 1 deletion ability_item_usage_bristleback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,26 @@ Consider[1]=function()
local creeps = npcBot:GetNearbyCreeps(CastRange+300,true)
local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps)


if npcBot:HasScepter() then
local enemies = npcBot:GetNearbyHeroes(CastRange, true, BOT_MODE_NONE)
enemies = AbilityExtensions:Filter(enemies, function(t)
local m = t:GetModifierByName("modifier_bristleback_viscous_nasal_goo")
if m ~= -1 and t:GetModifierStackCount(m) >= 6 and t:GetModifierRemainingDuration(m) >= 2.5 then
return false
end
return true
end)
if AbilityExtensions:IsAttackingEnemies(npcBot) or AbilityExtensions:IsRetreating(npcBot) then
if #enemies == 0 then
return 0
end
return #enemies >= 2 and AbilityExtensions:GetManaPercent(npcBot) >= 0.3
or #enemies == 1 and AbilityExtensions:GetManaPercent(npcBot) >= 0.6
or npcBot:WasRecentlyDamagedByAnyHero(1.5)
end
return 0
end

-- If we're in a teamfight, use it on the scariest enemy
local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK );
if ( #tableNearbyAttackingAlliedHeroes >= 2 )
Expand Down
Loading

0 comments on commit 7e5c352

Please sign in to comment.