Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tome
Tales of MajEyal
Commits
74a644be
Commit
74a644be
authored
12 years ago
by
dg
Browse files
Options
Downloads
Patches
Plain Diff
fix
git-svn-id:
http://svn.net-core.org/repos/t-engine4@6100
51575b47-30f0-44d4-a5cc-537603b46e54
parent
1c72452b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game/engines/default/engine/ai/simple.lua
+7
-1
7 additions, 1 deletion
game/engines/default/engine/ai/simple.lua
game/modules/tome/ai/tactical.lua
+15
-10
15 additions, 10 deletions
game/modules/tome/ai/tactical.lua
with
22 additions
and
11 deletions
game/engines/default/engine/ai/simple.lua
+
7
−
1
View file @
74a644be
...
...
@@ -34,6 +34,11 @@ newAI("move_dmap", function(self)
local
a
=
self
.
ai_target
.
actor
local
ax
,
ay
=
self
:
aiSeeTargetPos
(
a
)
-- If we have a vision, go straight towards the target
if
self
:
hasLOS
(
ax
,
ay
)
then
return
self
:
runAI
(
"move_simple"
)
end
local
c
=
a
:
distanceMap
(
self
.
x
,
self
.
y
)
local
dir
=
5
...
...
@@ -42,7 +47,8 @@ newAI("move_dmap", function(self)
local
sx
,
sy
=
util
.
coordAddDir
(
self
.
x
,
self
.
y
,
i
)
local
cd
=
a
:
distanceMap
(
sx
,
sy
)
-- print("looking for dmap", dir, i, "::", c, cd)
if
cd
and
cd
>
c
and
self
:
canMove
(
sx
,
sy
)
then
c
=
cd
;
dir
=
i
end
local
tile_available
=
self
:
canMove
(
sx
,
sy
)
or
(
sx
==
ax
and
sy
==
ay
)
if
cd
and
cd
>
c
and
tile_available
then
c
=
cd
;
dir
=
i
end
end
return
self
:
moveDirection
(
util
.
coordAddDir
(
self
.
x
,
self
.
y
,
dir
))
else
...
...
This diff is collapsed.
Click to expand it.
game/modules/tome/ai/tactical.lua
+
15
−
10
View file @
74a644be
...
...
@@ -25,19 +25,22 @@ local canFleeDmapKeepLos = function(self)
if
self
.
never_move
then
return
false
end
-- Dont move, dont flee
if
self
.
ai_target
.
actor
then
local
act
=
self
.
ai_target
.
actor
local
c
=
act
:
distanceMap
(
self
.
x
,
self
.
y
)
if
not
c
then
return
end
local
dir
local
dir
,
c
if
self
:
hasLOS
(
act
.
x
,
act
.
y
)
then
dir
=
5
c
=
act
:
distanceMap
(
self
.
x
,
self
.
y
)
if
not
c
then
return
end
end
for
_
,
i
in
ipairs
(
util
.
adjacentDirs
())
do
local
sx
,
sy
=
util
.
coordAddDir
(
self
.
x
,
self
.
y
,
i
)
-- Check LOS first
if
self
:
hasLOS
(
act
.
x
,
act
.
y
,
nil
,
nil
,
sx
,
sy
)
then
local
cd
=
act
:
distanceMap
(
sx
,
sy
)
-- print("looking for dmap", dir, i, "::", c, cd)
if
not
cd
or
(
c
and
(
cd
<
c
and
self
:
canMove
(
sx
,
sy
))
)
then
c
=
cd
;
dir
=
i
end
if
not
cd
or
(
(
not
c
or
cd
<
c
)
and
self
:
canMove
(
sx
,
sy
))
then
c
=
cd
;
dir
=
i
end
end
end
if
dir
then
if
dir
and
dir
~=
5
then
local
dx
,
dy
=
util
.
dirToCoord
(
dir
,
self
.
x
,
self
.
y
)
return
true
,
self
.
x
+
dx
,
self
.
y
+
dy
else
...
...
@@ -393,12 +396,14 @@ newAI("tactical", function(self)
end
if
targeted
and
not
self
.
energy
.
used
then
local
moved
if
special_move
then
return
self
:
runAI
(
special_move
)
elseif
self
.
ai_tactic
.
safe_range
and
not
self
:
hasLOS
(
ax
,
ay
)
then
local
moved
=
self
:
runAI
(
"flee_dmap_keep_los"
)
return
self
:
runAI
(
self
.
ai_state
.
ai_move
or
"move_simple"
)
else
moved
=
self
:
runAI
(
special_move
)
end
if
not
moved
and
self
.
ai_tactic
.
safe_range
and
not
self
:
hasLOS
(
ax
,
ay
)
then
moved
=
self
:
runAI
(
"flee_dmap_keep_los"
)
end
if
not
moved
then
return
self
:
runAI
(
self
.
ai_state
.
ai_move
or
"move_simple"
)
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment