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

Bosses now move with A* pathing

Monsters that can open door can now .. open doors :)


git-svn-id: http://svn.net-core.org/repos/t-engine4@717 51575b47-30f0-44d4-a5cc-537603b46e54
parent bf884538
No related branches found
No related tags found
No related merge requests found
Showing
with 30 additions and 13 deletions
......@@ -84,6 +84,7 @@ function _M:calc(sx, sy, tx, ty, use_has_seen, heuristic)
local came_from = {}
local cache = self.map._fovcache.path_caches[self.actor:getPathString()]
print("pathing using", self.actor:getPathString())
local checkPos
if cache then
checkPos = function(node, nx, ny)
......
......@@ -20,6 +20,8 @@
-- Defines a simple AI building blocks
-- Target nearest and move/attack it
local Astar = require "engine.Astar"
newAI("move_simple", function(self)
if self.ai_target.actor then
local tx, ty = self:aiSeeTargetPos(self.ai_target.actor)
......@@ -27,6 +29,19 @@ newAI("move_simple", function(self)
end
end)
newAI("move_astar", function(self)
if self.ai_target.actor then
local tx, ty = self:aiSeeTargetPos(self.ai_target.actor)
local a = Astar.new(game.level.map, self)
local path = a:calc(self.x, self.y, tx, ty)
if not path then
return self:runAI("move_simple")
else
return self:move(path[1].x, path[1].y)
end
end
end)
-- Find an hostile target
-- this requires the ActorFOV interface, or an interface that provides self.fov.actors*
newAI("target_simple", function(self)
......@@ -55,7 +70,7 @@ end)
newAI("simple", function(self)
if self:runAI("target_simple") then
return self:runAI("move_simple")
return self:runAI(self.ai_state.ai_move or "move_simple")
end
return false
end)
......@@ -72,7 +72,7 @@ local coords = {
function _M:aiCanPass(x, y)
-- Nothing blocks, just go on
if not game.level.map:checkAllEntities(x, y, "block_move", self) then return true end
if not game.level.map:checkAllEntities(x, y, "block_move", self, true) then return true end
-- If there is an otehr actor, check hostility, if hostile, we move to attack
local target = game.level.map(x, y, Map.ACTOR)
......
......@@ -38,6 +38,7 @@ newEntity{ define_as = "GREATER_MUMMY_LORD",
stats = { str=25, dex=10, cun=8, mag=35, wil=20, con=20 },
rank = 4,
size_category = 2,
open_door = true,
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, HEAD=1, },
equipment = resolvers.equip{
......@@ -67,7 +68,7 @@ newEntity{ define_as = "GREATER_MUMMY_LORD",
undead = 1,
autolevel = "warriormage",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { talent_in=1, ai_move="move_astar" },
}
-- Some mummy minions
......
......@@ -45,7 +45,7 @@ newEntity{ define_as = "UKLLMSWWIK",
},
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=4, },
ai = "dumb_talented_simple", ai_state = { talent_in=4, ai_move="move_astar", },
can_talk = "ukllmswwik",
}
......@@ -60,7 +60,7 @@ newEntity{ define_as = "MINOTAUR_MAZE",
},
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { talent_in=1, ai_move="move_astar", },
on_die = function(self, who)
game.player:resolveSource():grantQuest("starter-zones")
......
......@@ -73,7 +73,7 @@ newEntity{ define_as = "GOLBUG",
},
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=2, },
ai = "dumb_talented_simple", ai_state = { talent_in=2, ai_move="move_astar", },
on_acquire_target = function(self, who)
-- Doesnt matter who, jsut assume the player is there
......
......@@ -61,7 +61,7 @@ newEntity{ define_as = "OLD_MAN_WILLOW",
},
autolevel = "caster",
ai = "dumb_talented_simple", ai_state = { talent_in=3, },
ai = "dumb_talented_simple", ai_state = { talent_in=3, ai_move="move_astar", },
on_die = function(self, who)
game.player:resolveSource():grantQuest("starter-zones")
......
......@@ -83,7 +83,7 @@ newEntity{ define_as = "SANDWORM_QUEEN",
},
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=2, },
ai = "dumb_talented_simple", ai_state = { talent_in=2, ai_move="move_astar", },
on_die = function(self, who)
game.player:resolveSource():grantQuest("starter-zones")
......
......@@ -49,7 +49,7 @@ newEntity{ base="BASE_NPC_ORC", define_as = "UKRUK",
combat_atk = 1000,
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { talent_in=1, ai_move="move_astar", },
on_die = function(self, who)
game.player:resolveSource():hasQuest("staff-absorption"):killed_ukruk(game.player:resolveSource())
......
......@@ -77,7 +77,7 @@ newEntity{ define_as = "THE_MASTER",
},
autolevel = "warriormage",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
ai = "dumb_talented_simple", ai_state = { talent_in=1, ai_move="move_astar", },
on_die = function(self, who)
world:gainAchievement("VAMPIRE_CRUSHER", game.player:resolveSource())
......
......@@ -49,7 +49,7 @@ newEntity{ define_as = "SHADE_OF_ANGMAR",
},
autolevel = "warriormage",
ai = "dumb_talented_simple", ai_state = { talent_in=4, },
ai = "dumb_talented_simple", ai_state = { talent_in=4, ai_move="move_astar" },
on_die = function(self, who)
game.player:resolveSource():setQuestStatus("start-dunadan", engine.Quest.COMPLETED, "amon-sul")
......
......@@ -38,7 +38,7 @@ newEntity{ define_as = "SUN_PALADIN_AERYN",
open_door = true,
autolevel = "warriormage",
ai = "dumb_talented_simple", ai_state = { talent_in=2, },
ai = "dumb_talented_simple", ai_state = { talent_in=2, ai_move="move_astar", },
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
resolvers.drops{chance=100, nb=3, {ego_chance=100} },
......
......@@ -52,7 +52,7 @@ newEntity{ define_as = "TROLL_BILL",
},
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=4, },
ai = "dumb_talented_simple", ai_state = { talent_in=4, ai_move="move_astar", },
on_die = function(self, who)
game.player:resolveSource():setQuestStatus("start-dunadan", engine.Quest.COMPLETED, "trollshaws")
......
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