Skip to content

Commit

Permalink
Fix courier system; Add ember_spirit; (#47)
Browse files Browse the repository at this point in the history
Forbid silence ability usage on item channeling enemies (meteor_hammer);
Change juggernaut ability level up;
Fix troll_warlord ultimate;
Forbid location ability usage on invulnerable units (ember_spirit, puck);

Fix arc_warden GetBot;
Fix bane, beastmaster, centaur, hoodwink abilities;
Decrease the frequency of bounty_hunter, treant querying enemies 1600 away from npcBot to reduce warning in the console;
Change chen, bounty_hunter ability;
Restrict occasions for casting winter_wyvern_cold_embrace;
Add puck draft;
Change CourierSystem.lua to let every bot get access to the courier;
Change some item purchase solution to save their money;

Commit local dictionary for dota vocabulary

Fix brewmaster cannot move while primal_split;

Use glyph when target is quickly losing health;
Forbid furion use sprout at himself while invisible and not attacked;
Forbid obsidian_destroyer, shadow_demon use imprisonment ability on severely disabled enemies;
Add beastmaster_hawk_bomb_dive;
Try not to use tango at trees inside enemy towers' attack range;

Add ember_spirit;
Add beastmaster_hawk_dive minion use;
Improve templar_assassin_psionic_trap;
Fix bots stuck because of repeatedly using ring_of_basilius or buckler;

Add pudge use rot when channeling;
Add shadow_demon_soul_catcher, provide shadow_demon better cast target of disruption and demonic_purge;

Fix newly-added glyph usage;

Fix drow_ranger use split_shot at target;
Fix bugs in omniknight shard ability;
Fix bugs in item purchase when reloading;
Remove consumable purchase for heros who want to buy bottle;
Enable skeleton_king buy Aghanim's shard when antimage is on enemy team;

Fix abilities in ember_spirit, pudge, hoodwink;

Recall courier when hero's inventory is full;

Fix tipos in change log

Add tide_hunter, magnataur cancel ultimate when there are no enemies around;

Forbid enchantress, drow_ranger, obsidian_destroyer, silencer cast attack ability on ethereal or magic immune targets or when totally blinded;
Fix bug when lich try to cast frost_armour on enemy;

Add armlet of mordiggian usage;
Don't heal target under ancient_apparition_ice_blast (including armlet and power treads);
Fix bugs in chen, leshrac, and omniknight;

Add bane cancel nightmare;

Fix errors when npcMostDangerousEnemy is unassigned;
Add tusk use snowball with friends and scroll before timeout;
Forbid winter_wyvern_cold_embrace cast on friends with time sensitive modifiers (e.g. bkb, fv_chronosphere), applies to snowball as well;

Add ability information of basic levels;
Antimage, ember_spirit now only dodge dodge-worth abilities (stun, strong disable, massive damage);
Add bane try to cancel brain_snap and ult when target has linken's sphere, lotus_orb, or antimage_counterspell active;
Heroes can use any blink (agi/str/int);
Add ursa use enrage when disabled;
Remove a pair of unused local;

Fix errors in magnataur, sniper;

Fix incorrect scepter usage of chen, clinkz, doom, enchantress;
Cancel axe_culling_blade when target gains health suddenly;

Add alchemist throw concoction earlier when enemies have stun or silence;
Improve antimage blink location when attacking enemies;
Improve winter_wyvern_cold_embrace target;
Temporarily remove all buckler and ring_of_basilius purchase;

Add announcement of discord;

Fix spectre try to use spectral_dagger at creeps;
Fix some errors in earth_spirit;

Avoid using ultimate abilities at non-hero units;
Add unerlord_dark_rift cancel and scepter;
Add alchemist use scepter;
[dev-only] Add coroutine-style consider call;
Add life_stealer scepter;
Add lina shard;
Better obsidian_destroyer_imprisonment behavior at allies;

Add fear, hynopsis, root detect, and forbid certain abilities at these negative modifiers;

Fix arc_warden_tempest_double try to use abilities while mana is not enough;
Fix treant_natures_grasp use at target unit (can only target location);

Co-authored-by: adamqqq <[email protected]>
  • Loading branch information
AaronSong321 and adamqqqplay authored May 8, 2021
1 parent 1df0e4d commit 29b832b
Show file tree
Hide file tree
Showing 212 changed files with 5,767 additions and 3,857 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ luac.out

LICENSE
.vscode
.DS_Store
.idea

167 changes: 161 additions & 6 deletions ability_item_usage_abaddon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ end
local cast={} cast.Desire={} cast.Target={} cast.Type={}
local Consider ={}


local attackRange
local health
local healthPercent
local mana
local manaPercent

local enemyDisabled=utility.enemyDisabled

function GetComboDamage()
Expand Down Expand Up @@ -117,8 +124,7 @@ Consider[1]=function() -- TODO: lv 25 AOE mist coil
local Damage = ability:GetAbilityDamage();
local SelfDamage = ability:GetSpecialValueInt("self_damage");

local HeroHealth=10000
local CreepHealth=10000

local allys = npcBot:GetNearbyHeroes( CastRange+150, false, BOT_MODE_NONE );
for _,hero in pairs (allys)
do
Expand Down Expand Up @@ -232,6 +238,150 @@ Consider[1]=function() -- TODO: lv 25 AOE mist coil

end


-- local function MistCoilAuxilliaryCanCast(t)
-- if AbilityExtensions:IsOnSameTeam(npcBot, t) then
-- return AbilityExtensions:AllyCanCast(t)
-- else
-- return AbilityExtensions:NormalCanCast(t, true, DAMAGE_TYPE_MAGICAL)
-- end
-- end

-- local function MistCoilPrimaryCanCast(t)
-- if AbilityExtensions:IsOnSameTeam(npcBot, t) then
-- return AbilityExtensions:AllyCanCast(t)
-- else
-- return AbilityExtensions:NormalCanCast(t, true, DAMAGE_TYPE_MAGICAL) and not AbilityExtensions:HasModifier("modifier_antimage_counterspell")
-- end
-- end

-- local function NormalMistCoil()
-- local ability=AbilitiesReal[1]

-- if not ability:IsFullyCastable() then
-- return BOT_ACTION_DESIRE_NONE
-- end

-- local abilityLevel = ability:GetLevel()
-- local castRange = ability:GetCastRange()
-- local castPoint = ability:GetCastPoint()
-- local manaCost = ability:GetManaCost()
-- local enemies = AbilityExtensions:GetNearbyHeroes(npcBot, castRange)
-- local realEnemies = AbilityExtensions:Filter(enemies, function(t) return AbilityExtensions:MayNotBeIllusion(npcBot, t) end)
-- local friends = AbilityExtensions:GetNearbyHeroes(npcBot, 1200, true)
-- local friendCount = AbilityExtensions:GetEnemyHeroNumber(npcBot, friends)
-- local targettableFriends = AbilityExtensions:Remove(friends, npcBot)

-- local hasBorrowedTime = npcBot:HasModifier("modifier_abaddon_borrowed_time")
-- local hasAphoticShield = npcBot:HasModifier("modifier_abaddon_aphotic_shield")

-- local damage = ability:GetDamage()
-- local selfDamage = npcBot:GetActualIncomingDamage(damage * ability:GetSpecialValueInt("self_damage") / 100, DAMAGE_TYPE_PURE)
-- local function ChangeDesireBasedOnMyBuff(desire)
-- if hasBorrowedTime then
-- if healthPercent <= 0.75 then
-- desire = desire * 2
-- else
-- desire = desire * 1.5
-- end
-- else
-- if hasAphoticShield and healthPercent >= 0.6 then
-- desire = desire * 1.2
-- else
-- desire = desire - RemapValClamped(health, selfDamage*1.1, selfDamage*4, 0.8, 0)
-- end
-- end
-- end

-- local function ProtectFriends()
-- local protectFriends = AbilityExtensions:Filter(targettableFriends, function(t) return AbilityExtensions:MayNotBeIllusion(t) and MistCoilPrimaryCanCast(t) and AbilityExtensions:GetMaxHealth(t) <= 0.7 and t:GetHealth() <= health * 2 end)
-- AbilityExtensions:ForEach(protectFriends, function(t)
-- local desire = RemapValClamped(t:GetHealth(), 100, 800, BOT_ACTION_DESIRE_HIGH, BOT_ACTION_DESIRE_VERYLOW)
-- desire = ChangeDesireBasedOnMyBuff(desire)
-- if AbilityExtensions:IsSeverelyDisabledOrSlowed(t) then
-- desire = desire * 1.5
-- end
-- coroutine.yield(Clamp(desire, 0, 0.8), t)
-- end)
-- end

-- if AbilityExtensions:IsAttackingEnemies(npcBot) then
-- AbilityExtensions:ForEach(realEnemies, function(t)
-- if AbilityExtensions:GetHealthPercent(t) <= 0.6 and MistCoilPrimaryCanCast(t) then
-- local actualDamage = t:GetActualIncomingDamage(damage, DAMAGE_TYPE_MAGICAL)
-- local desire = RemapValClamped(t:GetHealth(), actualDamage*1.1, actualDamage*8, BOT_ACTION_DESIRE_HIGH, BOT_ACTION_DESIRE_VERYLOW)
-- desire = ChangeDesireBasedOnMyBuff(desire)
-- coroutine.yield(Clamp(desire, 0, 0.8), t)
-- end
-- end)
-- ProtectFriends()
-- elseif AbilityExtensions:IsLaning(npcBot) then
-- if friendCount == 1 and health > selfDamage + 0.6 * npcBot:GetMaxHealth() and manaPercent > 0.3 + manaCost then
-- local enemyCreeps = AbilityExtensions:GetNearbyAttackableCreeps(npcBot, 900)
-- local weakCreeps = AbilityExtensions:Filter(enemyCreeps, function(t) return t:GetHealth() <= t:GetActualIncomingDamage(damage, DAMAGE_TYPE_MAGICAL) end)
-- weakCreeps = AbilityExtensions:Filter(weakCreeps, function(t) return t:WasRecentlyDamagedByCreep(1.7) and t:GetAttackRange() >= 450 and GetUnitToLocationDistanceSqr(npcBot, t) > 300^2 end)
-- AbilityExtensions:ForEach(weakCreeps, function(t)
-- coroutine.yield(BOT_ACTION_DESIRE_MODERATE, t)
-- end)
-- end
-- elseif AbilityExtensions:IsRetreating(npcBot) then
-- if not npcBot:WasRecentlyDamagedByAnyHero(0.7) and AbilityExtensions:IsSeverelyDisabledOrSlowed(npcBot) then
-- if npcBot:HasModifier("modifier_abaddon_borrowed_time") then
-- local attackEnemies = AbilityExtensions:Filter(realEnemies, function(t) return MistCoilPrimaryCanCast(t) and t:GetHealth() <= 800 end)
-- AbilityExtensions:ForEach(attackEnemies, function(t)
-- return RemapValClamped(t:GetHealth(), 100, 800, BOT_ACTION_DESIRE_VERYHIGH, BOT_ACTION_DESIRE_LOW)
-- end)
-- end
-- end
-- else
-- ProtectFriends()
-- end
-- return 0
-- end

-- local function AOEMistCoil()
-- local ability=AbilitiesReal[1]

-- if not ability:IsFullyCastable() then
-- return BOT_ACTION_DESIRE_NONE
-- end

-- local abilityLevel = ability:GetLevel()
-- local castRange = ability:GetCastRange()
-- local castPoint = ability:GetCastPoint()
-- local manaCost = ability:GetManaCost()
-- local damage = ability:GetDamage()
-- local selfDamage = npcBot:GetActualIncomingDamage(damage * ability:GetSpecialValueInt("self_damage") / 100, DAMAGE_TYPE_PURE)
-- local enemies = AbilityExtensions:GetNearbyHeroes(npcBot, castRange)
-- local realEnemies = AbilityExtensions:Filter(enemies, function(t) return AbilityExtensions:MayNotBeIllusion(npcBot, t) end)
-- local friends = AbilityExtensions:GetNearbyHeroes(npcBot, 1200, true)
-- local friendCount = AbilityExtensions:GetEnemyHeroNumber(npcBot, friends)
-- local targettableFriends = AbilityExtensions:Remove(friends, npcBot)
-- local enemyCreeps = AbilityExtensions:GetNearbyAttackableCreeps(npcBot, 900)
-- local friendCreeps = AbilityExtensions:GetNearbyAttackableCreeps(npcBot, npcBot:GetAttackRange()+150, false)
-- local weakCreeps = AbilityExtensions:Filter(enemyCreeps, function(t) return t:GetHealth() < t:GetActualIncomingDamage(damage, DAMAGE_TYPE_MAGICAL) end)
-- local weakestCreep = utility.GetWeakestUnit(weakCreeps)
-- local forbiddenCreeps = AbilityExtensions:Filter(enemyCreeps, function(t)
-- return t:GetHealth() > t:GetActualIncomingDamage(damage, DAMAGE_TYPE_MAGICAL) and t:GetHealth() <= t:GetActualIncomingDamage(damage, DAMAGE_TYPE_MAGICAL) + AbilityExtensions:AttackOnceDamage(npcBot, t) * (0.9+#enemyCreeps*0.1)
-- end)
-- if #friendCreeps == 0 then
-- forbiddenCreeps = {}
-- end

-- local hasBorrowedTime = npcBot:HasModifier("modifier_abaddon_borrowed_time")
-- local hasAphoticShield = npcBot:HasModifier("modifier_abaddon_aphotic_shield")

-- end

-- Consider[1] = function()
-- local ability25 = npcBot:GetAbilityByName("special_bonus_unique_abaddon_4")
-- if ability25:IsTrained() then
-- return NormalMistCoil()
-- else
-- return AOEMistCoil()
-- end
-- end

Consider[2]=function()
local abilityNumber=2
--------------------------------------
Expand All @@ -246,8 +396,7 @@ Consider[2]=function()
local CastRange = ability:GetCastRange();
local Damage = ability:GetAbilityDamage();

local HeroHealth=10000
local CreepHealth=10000

local allys = npcBot:GetNearbyHeroes( CastRange+300, false, BOT_MODE_NONE );
local WeakestAlly,AllyHealth=utility.GetWeakestUnit(allys)
local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE)
Expand All @@ -269,7 +418,7 @@ Consider[2]=function()
end
end
if( npcBot:GetActiveMode() == BOT_MODE_ATTACK or
npcBot:GetActiveMode() == BOT_DEFEND_ALLY or
npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or
ManaPercentage>0.4)
then
for _,npcTarget in pairs( allys )
Expand Down Expand Up @@ -403,7 +552,7 @@ Consider[4]=function()
--------------------------------------
local ability=AbilitiesReal[abilityNumber];

if not ability:IsFullyCastable() then
if not ability:IsFullyCastable() or npcBot:HasModifier("modifier_ice_blast") then
return BOT_ACTION_DESIRE_NONE, 0;
end

Expand All @@ -415,6 +564,7 @@ Consider[4]=function()

return BOT_ACTION_DESIRE_NONE
end

AbilityExtensions:AutoModifyConsiderFunction(npcBot, Consider, AbilitiesReal)

function AbilityUsageThink()
Expand All @@ -429,6 +579,11 @@ function AbilityUsageThink()
AttackRange=npcBot:GetAttackRange()
ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana()
HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth()
attackRange = npcBot:GetAttackRange()
health = npcBot:GetHealth()
healthPercent = AbilityExtensions:GetHealthPercent(npcBot)
mana = npcBot:GetMana()
manaPercent = AbilityExtensions:GetManaPercent(npcBot)

cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider)
---------------------------------debug--------------------------------------------
Expand Down
69 changes: 61 additions & 8 deletions ability_item_usage_abyssal_underlord.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,29 @@ Consider[2]=function() --Location AOE Example

end

local function FindNearbyTeleportTarget(target)
local isEnemy = not AbilityExtensions:IsOnSameTeam(npcBot, target)
local castDelay = AbilitiesReal[4]:GetSpecialValueInt("cast_delay")
local creeps = target:GetNearbyCreeps(600, isEnemy)
creeps = AbilityExtensions:Filter(creeps, function(t) return not t:WasRecentlyDamagedByAnyHero(3) and #t:GetNearbyHeroes(500, true, BOT_MODE_NONE) == 0 end)
creeps = AbilityExtensions:Max(creeps, function(t) return t:GetHealth() end)
local buildings = AbilityExtensions:Concat(target:GetNearbyTowers(700, isEnemy), target:GetNearbyBarracks(700, isEnemy))
buildings = AbilityExtensions:Filter(buildings, function(t) return t:HasModifier("modifier_backdoor_protection_active") and t:GetHealth() >= 100 or t:GetHealth() >= 300 and not t:WasRecentlyDamagedByAnyHero(castDelay-2) or t:GetHealth() >= 800 or t:HasModifier("modifier_fountain_glyph") end)
buildings = AbilityExtensions:Max(buildings, function(t) return AbilityExtensions:GetBuildingPhysicalHealth(t) end)
local hero
if AbilityExtensions:HasScepter(npcBot) then
local friends = target:GetNearbyHeroes(900, isEnemy, BOT_MODE_NONE)
friends = AbilityExtensions:Filter(friends, function(t) return t:NotRetreating(t) and AbilityExtensions:AllyCanCast(t) and AbilityExtensions:GetHealthPercent(t) >= 0.5 and not t:IsSeverelyDisabled(t) end)
friends = AbilityExtensions:FilterNot(friends, function(t) return t:IsIllusion() and t:GetModifierRemainingDuration("modifier_illusion") <= castDelay end)
hero = target:Max(friends, function(t) return t:GetHealth() end)
end
return buildings or hero or creeps
end

local darkRiftOriginalTarget
local trackOriginalTargetPosition
local darkRiftChosenTarget

Consider[4]=function()

local abilityNumber=4
Expand All @@ -336,7 +359,7 @@ Consider[4]=function()
--------------------------------------
local ability=AbilitiesReal[abilityNumber];

if not ability:IsFullyCastable() then
if not ability:IsFullyCastable() or npcBot:HasModifier("modifier_abyssal_underlord_dark_rift") then
return BOT_ACTION_DESIRE_NONE, 0;
end

Expand All @@ -351,12 +374,11 @@ Consider[4]=function()
local creeps = npcBot:GetNearbyCreeps(CastRange+300,true)
local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps)

-- 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 )
then
if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) )
if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) and AbilityExtensions:GetHealthPercent(npcBot) >= 0.25 )
then
return BOT_ACTION_DESIRE_MODERATE, GetAncient(GetTeam()):GetLocation();
return BOT_ACTION_DESIRE_MODERATE, GetAncient(GetTeam()):GetLocation(), "Location"
end
end

Expand All @@ -366,23 +388,54 @@ Consider[4]=function()
npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or
npcBot:GetActiveMode() == BOT_MODE_ATTACK)
then
local npcEnemy = npcBot:GetTarget();
local npcEnemy = AbilityExtensions:GetTargetIfGood(npcBot)

if ( npcEnemy ~= nil )
then
if ( #enemys==0 and #creeps==0 and #allys>=2 and GetUnitToUnitDistance( npcEnemy, npcBot ) > 3000 )
if ( #enemys==0 and #allys>=2 and GetUnitToUnitDistance( npcEnemy, npcBot ) > 3000 )
then
return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetExtrapolatedLocation(CastPoint);
local target = FindNearbyTeleportTarget(npcEnemy)
if target ~= nil then
darkRiftOriginalTarget = npcEnemy
return BOT_ACTION_DESIRE_HIGH, target, "Target"
end
end
end
end

return BOT_ACTION_DESIRE_NONE, 0;
end

local darkRiftCancelRange = 1200^2
Consider[5] = function()
local ability = AbilitiesReal[5]
if not ability:IsFullyCastable() or ability:IsHidden() then
return 0
end
local target = AbilityExtensions:GetTargetIfGood(npcBot)
if darkRiftChosenTarget then
if darkRiftOriginalTarget:IsAlive() then
if GetUnitToUnitDistanceSqr(darkRiftChosenTarget, darkRiftOriginalTarget) >= darkRiftCancelRange then
coroutine.yield(BOT_ACTION_DESIRE_MODERATE)
end
else
if GetUnitToLocationDistanceSqr(darkRiftChosenTarget, trackOriginalTargetPosition) >= darkRiftCancelRange and (target == nil or target:CanBeSeen() and GetUnitToLocationDistanceSqr(darkRiftChosenTarget, target) >= darkRiftCancelRange) then
coroutine.yield(BOT_ACTION_DESIRE_HIGH)
elseif AbilityExtensions:IsRetreating(npcBot) then
coroutine.yield(BOT_ACTION_DESIRE_MODERATE)
end
end
end
return 0
end

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

if npcBot:HasModifier("modifier_abyssal_underlord_dark_rift") then
if darkRiftOriginalTarget and darkRiftOriginalTarget:IsAlive() and darkRiftOriginalTarget:CanBeSeen() then
trackOriginalTargetPosition = darkRiftOriginalTarget:GetLocation()
end
end
-- Check if we're already using an ability
if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() )
then
Expand Down
Loading

0 comments on commit 29b832b

Please sign in to comment.