Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
dota2-ai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
JoyJ
dota2-ai
Commits
7725cdd2
Commit
7725cdd2
authored
Apr 21, 2023
by
JoyJ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve centaur W and Q
parent
1e0b77f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
41 deletions
+85
-41
BotLib/hero_centaur.lua
BotLib/hero_centaur.lua
+28
-20
BotLib/hero_grimstroke.lua
BotLib/hero_grimstroke.lua
+1
-1
FunLib/aba_ability.lua
FunLib/aba_ability.lua
+9
-12
FunLib/jmz_func.lua
FunLib/jmz_func.lua
+47
-8
No files found.
BotLib/hero_centaur.lua
View file @
7725cdd2
...
...
@@ -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
...
...
BotLib/hero_grimstroke.lua
View file @
7725cdd2
...
...
@@ -9,7 +9,7 @@
--- mid, mage, priest
----------------------------------------------------------------------------------------------------
local
X
=
{}
local
bDebugMode
=
(
1
0
==
10
)
local
bDebugMode
=
(
1
==
10
)
local
bot
=
GetBot
()
local
J
=
require
(
GetScriptDirectory
()
..
'/FunLib/jmz_func'
)
...
...
FunLib/aba_ability.lua
View file @
7725cdd2
...
...
@@ -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
)
...
...
FunLib/jmz_func.lua
View file @
7725cdd2
...
...
@@ -3472,6 +3472,13 @@ function J.FilterGroup(nList,func)
return
newGroup
end
function
J
.
MergeGroup
(
nList
,
...
)
local
args
=
{
...
}
for
a
in
arg
do
table.insert
(
nList
,
a
)
end
end
function
J
.
Not
(
f
)
return
function
(
...
)
return
not
f
(
...
)
...
...
@@ -3479,7 +3486,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 +3498,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 +3510,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
.
GetDistance
FromXYToXY
(
x1
,
y1
,
x2
,
y2
)
return
math.sqrt
((
x1
-
x2
)
*
(
x1
-
x2
)
+
(
y1
-
y2
)
*
(
y1
-
y2
))
end
...
...
@@ -3523,15 +3534,15 @@ function J.GetAngleFromVectorToVector(v1, v2)
end
function
J
.
GetDistanceFromVectorToXY
(
v
,
x
,
y
)
return
J
.
GetDistance
(
v
.
x
,
v
.
y
,
x
,
y
)
return
J
.
GetDistance
FromXYToXY
(
v
.
x
,
v
.
y
,
x
,
y
)
end
function
J
.
GetDistanceFromXYToVector
(
x
,
y
,
v
)
return
J
.
GetDistance
(
x
,
y
,
v
.
x
,
v
.
y
)
return
J
.
GetDistance
FromXYToXY
(
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
.
GetDistance
FromXYToXY
(
v1
.
x
,
v1
.
y
,
v2
.
x
,
v2
.
y
)
end
function
J
.
GetAngleFromUnitToXY
(
unit
,
x
,
y
)
...
...
@@ -3593,7 +3604,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
.
GetDistance
FromXYToXY
(
(
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 +3624,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 +3659,33 @@ function J.DebugMessage(str,b)
end
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
enemyHeroes
=
bot
:
GetNearbyHeroes
(
range
,
true
,
BOT_MODE_NONE
)
local
creeps
=
bot
:
GetNearbyLaneCreeps
(
range
+
nRadius
,
true
)
--AOE
local
most
=
0
local
nAoeLoc
for
i
=
1
,
36
do
local
angle
=
10
*
i
local
hitEnemy
=
J
.
FilterGroup
(
nEnemyHeroesInRange
,
function
(
u
)
return
J
.
IsValidHero
(
u
)
and
not
u
:
IsMagicImmune
()
and
J
.
PointInRectangle
(
u
:
GetLocation
(),
bot
:
GetLocation
(),
angle
,
nCastRange
,
nRadius
)
end
)
if
#
hitEnemy
>
most
then
most
=#
hitEnemy
nAoeLoc
=
J
.
GetVectorFromVectorToAngleWithDistance
(
bot
:
GetLocation
(),
angle
,
nCastRange
-
100
)
end
end
end
return
J
--[[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment