Skip to content

Commit

Permalink
Fix many ability usage issues in the 7.30 version (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronSong321 authored Aug 28, 2021
1 parent 69bbb03 commit ba4738f
Show file tree
Hide file tree
Showing 93 changed files with 3,949 additions and 1,185 deletions.
4 changes: 2 additions & 2 deletions ability_item_usage_abaddon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ local TalentTree={
return Talents[1]
end,
function()
return Talents[4]
return Talents[3]
end,
function()
return Talents[6]
end,
function()
return Talents[7]
return Talents[8]
end
}
--------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions ability_item_usage_abyssal_underlord.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ local AbilityToLevelUp=
Abilities[2],
Abilities[1],
Abilities[2],
Abilities[4],
Abilities[5],
"talent",
Abilities[2],
Abilities[4],
Abilities[5],
Abilities[3],
Abilities[3],
"talent",
Abilities[3],
"nil",
Abilities[4],
Abilities[5],
"nil",
"talent",
"nil",
Expand Down 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}
local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast,utility.UCanCast}
local enemyDisabled=utility.enemyDisabled

function GetComboDamage()
Expand Down Expand Up @@ -351,9 +351,9 @@ local darkRiftOriginalTarget
local trackOriginalTargetPosition
local darkRiftChosenTarget

Consider[4]=function()
Consider[5]=function()

local abilityNumber=4
local abilityNumber=5
--------------------------------------
-- Generic Variable Setting
--------------------------------------
Expand Down Expand Up @@ -407,8 +407,8 @@ Consider[4]=function()
end

local darkRiftCancelRange = 1200^2
Consider[5] = function()
local ability = AbilitiesReal[5]
Consider[6] = function()
local ability = AbilitiesReal[6]
if not ability:IsFullyCastable() or ability:IsHidden() then
return 0
end
Expand Down
22 changes: 12 additions & 10 deletions ability_item_usage_alchemist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ local TalentTree={
return Talents[4]
end,
function()
return Talents[6]
return Talents[5]
end,
function()
return Talents[7]
Expand Down Expand Up @@ -550,15 +550,17 @@ Consider[6]=function()
end
end

if TimeSinceCast >= 4 or TimeSinceCast >= 3 and enemys[1]:GetStunDuration(true) >= 2 then
return BOT_ACTION_DESIRE_VERYHIGH,enemys[1]
end
if TimeSinceCast >= 2.5 then
local silencer = AbilityExtensions:Count(enemys, function(t)
return AbilityExtensions:MayNotBeIllusion(t) and t:HasSilence()
end)
if silencer > 0 then
return BOT_ACTION_DESIRE_HIGH, enemys[1]
if #enemys > 0 then
if TimeSinceCast >= 4 or TimeSinceCast >= 3 and enemys[1]:GetStunDuration(true) >= 2 then
return BOT_ACTION_DESIRE_VERYHIGH,enemys[1]
end
if TimeSinceCast >= 2.5 then
local silencer = AbilityExtensions:Count(enemys, function(t)
return AbilityExtensions:MayNotBeIllusion(npcBot, t) and t:HasSilence()
end)
if silencer > 0 then
return BOT_ACTION_DESIRE_HIGH, enemys[1]
end
end
end

Expand Down
6 changes: 3 additions & 3 deletions ability_item_usage_ancient_apparition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ local TalentTree={
return Talents[2]
end,
function()
return Talents[4]
return Talents[3]
end,
function()
return Talents[6]
return Talents[5]
end,
function()
return Talents[7]
return Talents[8]
end
}

Expand Down
8 changes: 4 additions & 4 deletions ability_item_usage_antimage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ local AbilityToLevelUp = {
local TalentTree = {
function() return Talents[1] end,
function() return Talents[4] end,
function() return Talents[6] end,
function() return Talents[8] end,
function() return Talents[2] end,
function() return Talents[3] end,
function() return Talents[5] end,
function() return Talents[7] end,
function() return Talents[2] end,
function() return Talents[3] end,
function() return Talents[6] end,
function() return Talents[8] end,
}

utility.CheckAbilityBuild(AbilityToLevelUp)
Expand Down
20 changes: 4 additions & 16 deletions ability_item_usage_arc_warden.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ local AbilityToLevelUp=
Abilities[3],
Abilities[1],
Abilities[1],
Abilities[3],
Abilities[2],
Abilities[1],
Abilities[4],
Abilities[1],
Abilities[3],
Abilities[3],
"talent",
Abilities[2],
Abilities[3],
Abilities[4],
Abilities[2],
Abilities[2],
Expand Down Expand Up @@ -373,22 +373,10 @@ Consider[3]=function()
-- Mode based usage
--------------------------------------
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:GetExtrapolatedLocation(CastPoint+Delay);
end
end
end]]

-- If my mana is enough,use it at enemy

if ( npcBot:GetActiveMode() == BOT_MODE_LANING )
then
if(ManaPercentage>0.6)
if ManaPercentage>0.7 or ManaPercentage >= 0.4 and ability:GetLevel() >= 2
then
if (WeakestEnemy~=nil)
then
Expand Down
29 changes: 20 additions & 9 deletions ability_item_usage_axe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ local AbilityToLevelUp=

local TalentTree={
function()
return Talents[2]
return Talents[1]
end,
function()
return Talents[3]
Expand Down Expand Up @@ -377,7 +377,7 @@ Consider[4]=function()
end
else -- only kill illusions when there are no real heroes
local weakEnemy = AbilityExtensions:First(enemys, IsWeak)
if AbilityExtensions:GetHealthPercent(npcBot) <= 0.3 and AbilityExtensions:GetManaPercent(npcBot) >= 0.5 + AbilitiesReal[4]:GetManaCost() and not npcBot:HasModifier("modifier_axe_culling_blade_boost") and weakEnemy then
if AbilityExtensions:GetHealthPercent(npcBot) <= 0.3 and AbilityExtensions:GetManaPercent(npcBot) >= 0.5 + AbilitiesReal[4]:GetManaCost() and not npcBot:HasModifier("modifier_axe_culling_blade_boost") and weakEnemy and npcBot:GetMana() > npcBot:GetMaxMana() * 0.4 + ability:GetManaCost() then
return BOT_ACTION_DESIRE_MODERATE, weakEnemy
end
end
Expand All @@ -389,28 +389,39 @@ end

AbilityExtensions:AutoModifyConsiderFunction(npcBot, Consider, AbilitiesReal)

local roarLosingTarget
local cullingBladeTarget

function AbilityUsageThink()

if roarLosingTarget ~= nil then
print(roarLosingTarget)
end
-- Check if we're already using an ability
if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() )
then
if npcBot:IsCastingAbility() then
if npcBot:GetCurrentActiveAbility() == AbilitiesReal[1] then
if not AbilityExtensions:IsFarmingOrPushing(npcBot) then
local nearbyEnemies = AbilityExtensions:GetNearbyHeroes(npcBot, AbilitiesReal[1]:GetAOERadius())
nearbyEnemies = AbilityExtensions:Filter(nearbyEnemies, CanCast[1])
local nearbyEnemies = AbilityExtensions:GetNearbyHeroes(npcBot, AbilitiesReal[1]:GetAOERadius()*1.15):Filter(CanCast[1])
if #nearbyEnemies == 0 then
npcBot:Action_ClearActions()
if roarLosingTarget == nil then
roarLosingTarget = DotaTime()
elseif DotaTime() - roarLosingTarget > 0.15 then
npcBot:Action_ClearActions(true)
end
return
end
end
elseif npcBot:GetCurrentActiveAbility() == AbilitiesReal[4] and cullingBladeTarget then
if cullingBladeTarget:GetHealth() > AbilitiesReal[4]:GetSpecialValueInt("kill_threshold") then
npcBot:Action_ClearActions()
else
if npcBot:GetCurrentActiveAbility() == AbilitiesReal[4] and cullingBladeTarget then
if cullingBladeTarget:CanBeSeen() and cullingBladeTarget:GetHealth() > AbilitiesReal[4]:GetSpecialValueInt("kill_threshold") then
print(cullingBladeTarget:GetHealth())
npcBot:Action_ClearActions(true)
end
end
end
end
roarLosingTarget = nil
return
end

Expand Down
34 changes: 17 additions & 17 deletions ability_item_usage_bane.lua
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,23 @@ Consider[3]=function()
end
end

local disabledAllies = AbilityExtensions:Filter(allys, function(t) return AbilityExtensions:IsSeverelyDisabled(t) and not t:IsChanneling() and not AbilityExtensions:DontInterruptAlly(t) 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
Expand Down Expand Up @@ -551,23 +568,6 @@ Consider[4]=function()
end
end

local disabledAllies = AbilityExtensions:Filter(allys, function(t) return AbilityExtensions:IsSeverelyDisabled(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
Expand Down
2 changes: 1 addition & 1 deletion ability_item_usage_batrider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ Consider[4]=function()
then
local npcEnemy = npcBot:GetTarget();

if npcEnemy ~= nil and npcEnemy:IsHero() and AbilityExtensions:MayNotBeIllusion(npcEnemy) then
if npcEnemy ~= nil and npcEnemy:IsHero() and AbilityExtensions:MayNotBeIllusion(npcBot, npcEnemy) then
if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys)
then
return BOT_ACTION_DESIRE_MODERATE, npcEnemy
Expand Down
2 changes: 1 addition & 1 deletion ability_item_usage_beastmaster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ Consider[6]=function() --Target Ability Example
then
for _,npcEnemy in pairs( enemys )
do
if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) and not AbilityExtensions:HasDamageRetargetModifier(npcEnemy)
if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) and not AbilityExtensions:HasAbilityRetargetModifier(npcEnemy)
then
return BOT_ACTION_DESIRE_HIGH, npcEnemy;
end
Expand Down
8 changes: 4 additions & 4 deletions ability_item_usage_bounty_hunter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ local TalentTree={
return Talents[1]
end,
function()
return Talents[4]
return Talents[3]
end,
function()
return Talents[5]
end,
function()
return Talents[8]
return Talents[7]
end
}

Expand Down Expand Up @@ -303,7 +303,7 @@ Consider[3]=function()

end

local EnlargeCastRange = AbilityExtensions:EveryManySeconds(0.5, function() CastRange = AbilitiesReal[4]:GetCastRange() end)
-- local EnlargeCastRange = AbilityExtensions:EveryManySeconds(0.5, function() CastRange = AbilitiesReal[4]:GetCastRange() end)

CanCast[4] = function(t)
return AbilityExtensions:NormalCanCast(t, false, DAMAGE_TYPE_PHYSICAL, true, true) and t:IsHero()
Expand All @@ -326,7 +326,7 @@ Consider[4]=function()
end

local CastRange = Clamp(ability:GetCastRange(), 0, 1599)
local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE)
local enemys = npcBot:GetNearbyHeroes(CastRange,true,BOT_MODE_NONE)
local realEnemies = AbilityExtensions:GetNearbyNonIllusionHeroes(npcBot, CastRange)
realEnemies = AbilityExtensions:Filter(realEnemies, CanCast[4])
realEnemies = AbilityExtensions:Map(realEnemies, function(t)
Expand Down
12 changes: 10 additions & 2 deletions ability_item_usage_brewmaster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ Consider[4]=function()

end

local slamLosingTarget

AbilityExtensions:AutoModifyConsiderFunction(npcBot, Consider, AbilitiesReal)
function AbilityUsageThink()

Expand All @@ -519,12 +521,18 @@ function AbilityUsageThink()
if npcBot:GetCurrentActiveAbility() == AbilitiesReal[1] then
if not AbilityExtensions:IsFarmingOrPushing(npcBot) then
local nearbyEnemies = AbilityExtensions:GetNearbyEnemyUnits(npcBot, AbilitiesReal[1]:GetAOERadius() + 40)
if AbilityExtensions:Count(nearbyEnemies, CanCast[1]) then
npcBot:Action_ClearActions()
if AbilityExtensions:Count(nearbyEnemies, CanCast[1]) == 0 then
if slamLosingTarget == nil then
slamLosingTarget = DotaTime()
return
elseif DotaTime() - slamLosingTarget > 0.15 then
npcBot:Action_ClearActions(false)
end
end
end
end
end
slamLosingTarget = nil
return
end

Expand Down
Loading

0 comments on commit ba4738f

Please sign in to comment.