Commit e0490373 authored by JoyJ's avatar JoyJ

Merge branch 'master' of https://code.mycard.moe/JoyJ/dota2-ai

parents 32c5afd6 1da3f7e1
......@@ -155,7 +155,7 @@ function X.ConsiderQ()
local nManaCost = abilityQ:GetManaCost()
local nDamage = abilityQ:GetAbilityDamage()
local nDamageType = DAMAGE_TYPE_MAGICAL
local nInRangeEnemyList = bot:GetNearbyHeroes( nRadius, true, BOT_MODE_NONE )
local nInRangeEnemyList = bot:GetNearbyHeroes( nRadius + 300, true, BOT_MODE_NONE )
local hCastTarget
local sCastMotive
......@@ -175,17 +175,17 @@ function X.ConsiderQ()
--攻击敌人时
if J.IsGoingOnSomeone( bot )
then
local loc = J.GetCorrectLoc(botTarget, nCastPoint)
if J.IsValidHero( botTarget )
and J.IsInRange( botTarget, bot, nRadius - 90 )
and J.GetDistanceFromUnitToVector(bot, loc) < nRadius
and J.CanCastOnNonMagicImmune( botTarget )
and (not J.IsDisabled( botTarget ) or J.GetRemainStunTime(botTarget)<0.5)
and (not J.IsDisabled( botTarget ) or J.GetRemainStunTime(botTarget)< nCastPoint + 0.5)
then
hCastTarget = botTarget
sCastMotive = 'Q-先手'..J.Chat.GetNormName( hCastTarget )
return BOT_ACTION_DESIRE_HIGH, sCastMotive
end
end
--打肉时
if bot:GetActiveMode() == BOT_MODE_ROSHAN
......@@ -233,24 +233,30 @@ function X.ConsiderW()
return BOT_ACTION_DESIRE_HIGH, aTarget, "W-攻击当前目标"
end
if (J.IsPushing( bot ) or J.IsDefending( bot )) and nHP > 0.7
if (J.IsPushing( bot ) or J.IsDefending( bot ) or J.IsLaning(bot)) and nHP > 0.7
then
local creeps = bot:GetNearbyLaneCreeps( castRange, true )
if #creeps >= 2 and creeps[1] ~= nil and not creeps[1]:HasModifier( "modifier_fountain_glyph" )
then
return BOT_ACTION_DESIRE_HIGH, creeps[1], "W-推进"
local creeps = bot:GetNearbyLaneCreeps( castRange + 300, true )
local maxHit = 0
local maxHitCreep = nil
for creep in creeps do
local hit = 0
local kill = 0
for cr in creeps do
if cr~=creep and J.GetDistanceFromUnitToUnit(cr,creep) < nRadius then
hit = hit + 1
if creep:GetHealth() < nDamage then
kill = kill + 1
end
end
end
if maxHit < hit and kill > 0 then
maxHit = hit
maxHitCreep = creep
end
end
end
if J.IsLaning( bot ) and nHP > 0.5 then
local creeps = bot:GetNearbyLaneCreeps( castRange, true )
if #creeps > 1 then
for i=1, #creeps do
if J.WillMagicKillTarget(bot, creeps[i], nDamage, nCastPoint) then
return BOT_ACTION_DESIRE_HIGH, creeps[i], "W-对线"
end
end
end
if maxHitCreep then return BOT_ACTION_DESIRE_HIGH, maxHitCreep, "W-推进" end
end
if J.IsGoingOnSomeone( bot )
......@@ -295,6 +301,8 @@ function X.ConsiderR()
if npcAlly ~= nil
and npcAlly:IsAlive()
and nHP < 0.2 and npcAlly:WasRecentlyDamagedByAnyHero(2.0)
and not npcAlly:IsStunned()
and npcAlly:GetCurrentMovementSpeed() < 500
then
return BOT_ACTION_DESIRE_HIGH, "R-帮助队友逃跑"
end
......
......@@ -9,7 +9,7 @@
--- mid, mage, priest
----------------------------------------------------------------------------------------------------
local X = {}
local bDebugMode = ( 10 == 10 )
local bDebugMode = ( 1 == 10 )
local bot = GetBot()
local J = require( GetScriptDirectory()..'/FunLib/jmz_func' )
......
......@@ -699,8 +699,8 @@ function X.ConsiderGrimstrokeStrokeOfFate( bot )
local nAoeLoc = J.GetAoeEnemyHeroLocation( bot, nCastRange, nRadius, 2 )
if nAoeLoc ~= nil
and J.IsAllowedToSpam( bot, nManaCost * 0.72 )
and nMP > 0.38
and nSkillLV > 1
and J.IsAllowedToSpam( bot, nManaCost )
then
nTargetLocation = nAoeLoc
return BOT_ACTION_DESIRE_HIGH, nTargetLocation, "StrokeOfFate-Harass"
......@@ -710,9 +710,8 @@ function X.ConsiderGrimstrokeStrokeOfFate( bot )
then
nAoeLoc = J.GetAoeEnemyHeroLocation( bot, nCastRange, nRadius, 1 )
if nAoeLoc ~= nil
and J.IsAllowedToSpam( bot, nManaCost * 0.72 )
and nMP > 0.58
and not nEnemyHeroesInRange[1]:HasModifier( 'modifier_templar_assassin_refraction_absorb' )
and nSkillLV > 1
and nMP > 0.9
then
nTargetLocation = nAoeLoc
return BOT_ACTION_DESIRE_HIGH, nTargetLocation, "StrokeOfFate-Harass"
......@@ -748,9 +747,9 @@ function X.ConsiderGrimstrokeStrokeOfFate( bot )
end
if ( J.IsPushing( bot ) or J.IsDefending( bot ) or J.IsFarming( bot ) )
and J.IsAllowedToSpam( bot, nManaCost * 0.72 )
and nSkillLV >= 2 and DotaTime() > 8 * 60
if J.IsPushing( bot ) or J.IsDefending( bot ) or J.IsFarming( bot ) or (J.IsLaning(bot) and bot:GetAssignedLane() == LANE_MID)
and J.IsAllowedToSpam( bot, nManaCost )
and nSkillLV >= 2
then
local nEnemyCreeps = bot:GetNearbyLaneCreeps( nCastRange + nRadius, true )
if #nEnemyCreeps >= 3
......@@ -769,7 +768,7 @@ function X.ConsiderGrimstrokeStrokeOfFate( bot )
if J.IsFarming( bot )
and not ( J.IsPushing( bot ) or J.IsDefending( bot ) )
and J.IsAllowedToSpam( bot, nManaCost * 0.25 )
and J.IsAllowedToSpam( bot, nManaCost )
and nSkillLV >= 3
and #nEnemyHeroesInRange == 0
and #nAlliedHeroesInRange <= 2
......@@ -788,7 +787,6 @@ function X.ConsiderGrimstrokeStrokeOfFate( bot )
end
end
end
if bot:GetActiveMode() == BOT_MODE_ROSHAN
and nMP >= 0.78
......@@ -801,7 +799,6 @@ function X.ConsiderGrimstrokeStrokeOfFate( bot )
end
end
return BOT_ACTION_DESIRE_NONE, nil
end
......@@ -1019,11 +1016,11 @@ function X.ConsiderGrimstrokeDarkPortrait( bot )
if nMostDangerousEnemy ~= nil
and J.IsInRange( nMostDangerousEnemy, bot, nCastRange )
and J.IsGoingOnSomeone(bot)
then
return BOT_ACTION_DESIRE_HIGH, nMostDangerousEnemy, "DarkPortrait-Battle:"..J.Chat.GetNormName( nMostDangerousEnemy )
end
if J.IsGoingOnSomeone( bot )
then
if J.IsValidHero( botTarget )
......
......@@ -3472,6 +3472,14 @@ function J.FilterGroup(nList,func)
return newGroup
end
function J.MergeGroup(nList,...)
local args = {...}
for a in arg do
table.insert(nList,a)
end
return nList
end
function J.Not(f)
return function(...)
return not f(...)
......@@ -3479,7 +3487,7 @@ function J.Not(f)
end
function J.And(...)
local funcList=table.unpack(...)
local funcList={...}
return function(...)
for _,func in pairs(funcList) do
if not func(...) then
......@@ -3491,7 +3499,7 @@ function J.And(...)
end
function J.Or(...)
local funcList=table.unpack(...)
local funcList={...}
return function(...)
for _,func in pairs(funcList) do
if func(...) then
......@@ -3503,10 +3511,14 @@ function J.Or(...)
end
function J.GetAngle(x1,y1,x2,y2)
return math.deg(math.atan2( y2 - y1, x2 - x1 ))
if math.atan2 then
return math.deg(math.atan2( y2 - y1, x2 - x1 ))
else
return math.deg(math.atan( y2 - y1, x2 - x1 ))
end
end
function J.GetDistance(x1, y1, x2, y2)
function J.GetDistanceFromXYToXY(x1, y1, x2, y2)
return math.sqrt(( x1 - x2 )*( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ))
end
......@@ -3523,15 +3535,15 @@ function J.GetAngleFromVectorToVector(v1, v2)
end
function J.GetDistanceFromVectorToXY(v, x, y)
return J.GetDistance(v.x, v.y, x, y)
return J.GetDistanceFromXYToXY(v.x, v.y, x, y)
end
function J.GetDistanceFromXYToVector(x, y, v)
return J.GetDistance(x, y, v.x, v.y)
return J.GetDistanceFromXYToXY(x, y, v.x, v.y)
end
function J.GetDistanceFromVectorToVector(v1, v2)
return J.GetDistance(v1.x, v1.y, v2.x, v2.y)
return J.GetDistanceFromXYToXY(v1.x, v1.y, v2.x, v2.y)
end
function J.GetAngleFromUnitToXY(unit, x, y)
......@@ -3593,7 +3605,7 @@ function J.GetDistanceFromPointToLine(x, y, x1, y1, x2, y2)
elseif y1 == y2 then
return math.abs( x - x1 )
end
return J.GetDistance( ( y + ( x2 - x1 ) / ( y2 - y1 ) * x + ( y2 - y1 ) / ( x2 - x1 ) * x2 - y2 ) / ( ( y2 - y1 ) / ( x2 - x1 ) + ( x2 - x1 ) / ( y2 - y1 ) ), ( y2 - y1 ) / ( x2 - x1 ) * ( ( y + ( x2 - x1 ) / ( y2 - y1 ) * x + ( y2 - y1 ) / ( x2 - x1 ) * x2 - y2 ) / ( ( y2 - y1 ) / ( x2 - x1 ) + ( x2 - x1 ) / ( y2 - y1 ) ) ) + y2 - ( y2 - y1 ) / ( x2 - x1 ) * x2, x, y )
return J.GetDistanceFromXYToXY( ( y + ( x2 - x1 ) / ( y2 - y1 ) * x + ( y2 - y1 ) / ( x2 - x1 ) * x2 - y2 ) / ( ( y2 - y1 ) / ( x2 - x1 ) + ( x2 - x1 ) / ( y2 - y1 ) ), ( y2 - y1 ) / ( x2 - x1 ) * ( ( y + ( x2 - x1 ) / ( y2 - y1 ) * x + ( y2 - y1 ) / ( x2 - x1 ) * x2 - y2 ) / ( ( y2 - y1 ) / ( x2 - x1 ) + ( x2 - x1 ) / ( y2 - y1 ) ) ) + y2 - ( y2 - y1 ) / ( x2 - x1 ) * x2, x, y )
end
function J.PointInRectangle(p, p1, a, d, r)
......@@ -3613,6 +3625,7 @@ function J.GetVectorFromVectorToAngleWithDistance(v, a, d)
newV.y = v.y + math.sin(a) * d
return newV
end
function J.VectorToAngle(v)
return J.GetAngleFromVectorToVector(RandomVector(0.0), v)
end
......@@ -3647,6 +3660,48 @@ function J.DebugMessage(str,b)
end
end
function J.FindAoeLocationForLinearSkillFilter(u)
return not u:IsMagicImmune()
end
function J.FindAoeLocationForLinearSkill(data)
local range = data.range or 600
local radius = data.range or 200
local castPoint = data.castPoint or 0.5
local projSpeed = data.projSpeed or 1000
local onlyHero = data.onlyHero or true
local bot = GetBot()
local loc=data.loc or bot:GetLocation()
local enemies = bot:GetNearbyHeroes( range, true, BOT_MODE_NONE )
local creeps = bot:GetNearbyLaneCreeps( range + radius, true )
local filter = data.filter or J.FindAoeLocationForLinearSkillFilter
enemies = J.FilterGroup(enemies, function(u)
return J.IsValidHero(u)
end)
creeps = J.FilterGroup(creeps, function(u)
return J.IsValid(u)
end)
if not onlyHero then
enemies = J.MergeGroup(enemies, creeps)
end
local most=0
local nAoeLoc
for i=1,36 do
local angle = 10 * i
local hitEnemy = J.FilterGroup(enemies,filter)
if #hitEnemy>most then
most=#hitEnemy
nAoeLoc=J.GetVectorFromVectorToAngleWithDistance(loc, angle, nCastRange)
end
end
return nAoeLoc
end
return J
--[[
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment