Skip to content
Snippets Groups Projects
Commit 70890549 authored by dg's avatar dg
Browse files

Most ToME NPCs now use distance map to pursue the player

git-svn-id: http://svn.net-core.org/repos/t-engine4@1042 51575b47-30f0-44d4-a5cc-537603b46e54
parent e58dfe38
No related branches found
No related tags found
No related merge requests found
Showing
with 30 additions and 26 deletions
......@@ -32,15 +32,16 @@ end)
newAI("move_dmap", function(self)
if self.ai_target.actor then
local a = self.ai_target.actor
if self:hasLOS(a) then return self:runAI("move_simple") end
if self:hasLOS(a.x, a.y) then return self:runAI("move_simple") end
local c = a:distanceMap(self.x, self.y)
if not c then return end
local dir = 5
for i = 1, 9 do
local cd = a:distanceMap(util.coordAddDir(self.x, self.y, i))
print("looking for dmap", dir, i, "::", c, cd)
if cd and cd > c then c = cd; dir = i end
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
end
return self:moveDirection(util.coordAddDir(self.x, self.y, dir))
......@@ -50,15 +51,15 @@ end)
newAI("flee_dmap", function(self)
if self.ai_target.actor then
local a = self.ai_target.actor
if self:hasLOS(a) then return self:runAI("move_simple") end
local c = a:distanceMap(self.x, self.y)
if not c then return end
local dir = 5
for i = 1, 9 do
local cd = a:distanceMap(util.coordAddDir(self.x, self.y, i))
print("looking for dmap", dir, i, "::", c, cd)
if cd and cd > c then c = cd; dir = i end
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 not cd or (cd < c and self:canMove(sx, sy)) then c = cd; dir = i end
end
return self:moveDirection(util.coordAddDir(self.x, self.y, dir))
......
......@@ -58,6 +58,9 @@ module(..., package.seeall, class.inherit(
-- Dont save the can_see_cache
_M._no_save_fields.can_see_cache = true
-- Use distance maps
_M.__do_distance_map = true
function _M:init(t, no_default)
-- Define some basic combat stats
self.combat_def = 0
......
......@@ -27,7 +27,7 @@ newEntity{
display = "a", color=colors.WHITE,
body = { INVEN = 10 },
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=1, },
stats = { str=12, dex=10, mag=3, con=13 },
energy = { mod=1 },
combat_armor = 1, combat_def = 1,
......
......@@ -27,7 +27,7 @@ newEntity{
display = "A", color=colors.WHITE,
body = { INVEN = 10 },
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=1, },
stats = { str=12, dex=10, mag=3, con=13 },
energy = { mod=1 },
combat_armor = 1, combat_def = 1,
......
......@@ -27,7 +27,7 @@ newEntity{
display = "U", color=colors.WHITE,
body = { INVEN = 10 },
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=1, },
stats = { str=12, dex=10, mag=3, con=13 },
energy = { mod=1 },
combat_armor = 1, combat_def = 1,
......
......@@ -30,7 +30,7 @@ newEntity{
max_stamina = 100,
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=5, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=5, },
energy = { mod=0.9 },
stats = { str=18, dex=13, mag=5, con=15 },
infravision = 20,
......
......@@ -35,7 +35,7 @@ newEntity{
size_category = 4,
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=2, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=2, },
energy = { mod=1 },
stats = { str=20, dex=52, mag=16, con=16 },
......
......@@ -33,7 +33,7 @@ newEntity{
infravision = 20,
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=2, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=2, },
energy = { mod=1.1 },
stats = { str=10, dex=17, mag=3, con=7 },
combat = { dammod={str=0.6} },
......
......@@ -35,7 +35,7 @@ newEntity{
size_category = 5,
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=2, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=2, },
energy = { mod=1 },
stats = { str=20, dex=20, mag=30, con=16 },
......
......@@ -34,7 +34,7 @@ newEntity{
size_category = 3,
autolevel = "dexmage",
ai = "dumb_talented_simple", ai_state = { talent_in=2, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=2, },
energy = { mod=1 },
stats = { str=10, dex=8, mag=6, con=16 },
......
......@@ -35,7 +35,7 @@ newEntity{
size_category = 5,
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=2, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=2, },
energy = { mod=1 },
stats = { str=20, dex=20, mag=30, con=16 },
......
......@@ -27,7 +27,7 @@ newEntity{
display = "U", color=colors.WHITE,
body = { INVEN = 10 },
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=1, },
stats = { str=22, dex=10, mag=20, con=13 },
energy = { mod=1 },
combat_armor = 1, combat_def = 1,
......
......@@ -27,7 +27,7 @@ newEntity{
display = "u", color=colors.WHITE,
body = { INVEN = 10 },
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=1, },
stats = { str=12, dex=10, mag=3, con=13 },
energy = { mod=1 },
life_rating = 7,
......
......@@ -41,7 +41,7 @@ newEntity{
open_door = true,
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=5, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=5, },
energy = { mod=1.2 },
stats = { str=15, dex=12, mag=6, cun=12, con=15 },
......
......@@ -34,7 +34,7 @@ newEntity{
size_category = 5,
autolevel = "drake",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=1, },
energy = { mod=1 },
stats = { str=20, dex=20, mag=30, con=16 },
......
......@@ -28,7 +28,7 @@ newEntity{
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=2, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=2, },
energy = { mod=0.8 },
stats = { str=14, dex=12, mag=10, con=12 },
infravision = 20,
......
......@@ -39,7 +39,7 @@ newEntity{
open_door = true,
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=1, },
energy = { mod=1.2 },
stats = { str=15, dex=15, mag=15, con=10 },
}
......
......@@ -28,7 +28,7 @@ newEntity{
desc = "It's colorful and it's oozing.",
body = { INVEN = 10 },
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=1, },
stats = { str=10, dex=15, mag=3, con=10 },
energy = { mod=0.7 },
combat_armor = 1, combat_def = 1,
......
......@@ -41,7 +41,7 @@ newEntity{
resolvers.sustains_at_birth(),
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=3, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, },
energy = { mod=1 },
stats = { str=20, dex=8, mag=6, con=16 },
}
......@@ -41,7 +41,7 @@ newEntity{
resolvers.sustains_at_birth(),
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=3, },
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, },
energy = { mod=1 },
stats = { str=20, dex=8, mag=6, con=16 },
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment