diff --git a/game/engine/interface/ActorAI.lua b/game/engine/interface/ActorAI.lua index cc898c0c7ad40ffb5c5713f5c7866b2e92076312..fdd8ebc2ff4113823f4b2825c97aa556b329699f 100644 --- a/game/engine/interface/ActorAI.lua +++ b/game/engine/interface/ActorAI.lua @@ -46,14 +46,30 @@ local coords = { [9] = { 8, 6, 7, 3 }, } +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 there is an otehr actor, check hostility, if hostile, we move to attack + local target = game.level.map(x, y, Map.ACTOR) + if target and self:reactionToward(target) < 0 then return true end + + -- If there is a target (not hostile) and we can move it, do so + if target and self:attr("move_body") then return true end + + return false +end + --- Move one step to the given target if possible -- This tries the most direct route, if not available it checks sides and always tries to get closer function _M:moveDirection(x, y) local l = line.new(self.x, self.y, x, y) local lx, ly = l() if lx and ly then + local target = game.level.map(lx, ly, Map.ACTOR) + -- if we are blocked, try some other way - if game.level.map:checkEntity(lx, ly, Map.TERRAIN, "block_move") then + if not self:aiCanPass(lx, ly) then local dirx = lx - self.x local diry = ly - self.y local dir = coord_to_dir[dirx][diry] @@ -63,7 +79,7 @@ function _M:moveDirection(x, y) -- Find posiblities for i = 1, #list do local dx, dy = self.x + dir_to_coord[list[i]][1], self.y + dir_to_coord[list[i]][2] - if not game.level.map:checkEntity(dx, dy, Map.TERRAIN, "block_move") then + if self:aiCanPass(dx, dy) then l[#l+1] = {dx,dy, (dx-x)^2 + (dy-y)^2} end end diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua index 9d217dc9614da6f262bddbcf2427939ab56a82cb..6cdf2f634ed20873236dd288826a29c08e7a3158 100644 --- a/game/modules/tome/data/damage_types.lua +++ b/game/modules/tome/data/damage_types.lua @@ -218,7 +218,7 @@ newDamageType{ -- Poisoning damage newDamageType{ name = "dig", type = "DIG", - projector = function(src, x, y, type, dam) + projector = function(src, x, y, typ, dam) local feat = game.level.map(x, y, Map.TERRAIN) if feat then if feat.dig then diff --git a/game/modules/tome/data/general/npcs/snake.lua b/game/modules/tome/data/general/npcs/snake.lua new file mode 100644 index 0000000000000000000000000000000000000000..a85b7f009ec7a1334a54e552cd231b6d6a557092 --- /dev/null +++ b/game/modules/tome/data/general/npcs/snake.lua @@ -0,0 +1,97 @@ +local Talents = require("engine.interface.ActorTalents") + +newEntity{ + define_as = "BASE_NPC_SNAKE", + type = "animal", subtype = "snake", + display = "J", color=colors.WHITE, + body = { INVEN = 10 }, + + max_stamina = 110, + + autolevel = "warrior", + ai = "dumb_talented_simple", ai_state = { talent_in=3, }, + energy = { mod=1.3 }, + stats = { str=5, dex=23, mag=5, con=5 }, + combat_armor = 1, combat_def = 1, +} + +newEntity{ base = "BASE_NPC_SNAKE", + name = "large brown snake", color=colors.UMBER, + desc = [[This large snake hisses at you, angry at being disturbed.]], + level_range = {1, 50}, exp_worth = 1, + rarity = 3, + max_life = resolvers.rngavg(20,30), + combat_armor = 1, combat_def = 3, + combat = { dam=2, atk=30, apr=10 }, +} + +newEntity{ base = "BASE_NPC_SNAKE", + name = "large white snake", color=colors.WHITE, + desc = [[This large snake hisses at you, angry at being disturbed.]], + level_range = {1, 50}, exp_worth = 1, + rarity = 3, + max_life = resolvers.rngavg(20,30), + combat_armor = 1, combat_def = 3, + combat = { dam=2, atk=30, apr=10 }, +} + +newEntity{ base = "BASE_NPC_SNAKE", + name = "copperhead snake", color=colors.SALMON, + desc = [[It has a copper head and sharp venomous fangs.]], + level_range = {2, 50}, exp_worth = 1, + rarity = 3, + max_life = resolvers.rngavg(30,40), + combat_armor = 2, combat_def = 5, + combat = { dam=3, atk=30, apr=10 }, + + talents = resolvers.talents{ [Talents.T_BITE_POISON]=1 }, +} + +newEntity{ base = "BASE_NPC_SNAKE", + name = "rattlesnake", color=colors.FIREBRICK, + desc = [[As you approach, the snake coils up and rattles its tail threateningly.]], + level_range = {4, 50}, exp_worth = 1, + rarity = 3, + max_life = resolvers.rngavg(30,50), + combat_armor = 2, combat_def = 8, + combat = { dam=5, atk=30, apr=10 }, + + talents = resolvers.talents{ [Talents.T_BITE_POISON]=1 }, +} + +newEntity{ base = "BASE_NPC_SNAKE", + name = "king cobra", color=colors.GREEN, + desc = [[It is a large snake with a hooded face.]], + level_range = {5, 50}, exp_worth = 1, + rarity = 6, + max_life = resolvers.rngavg(40,70), + combat_armor = 3, combat_def = 11, + combat = { dam=7, atk=30, apr=10 }, + + talents = resolvers.talents{ [Talents.T_BITE_POISON]=2 }, +} + +newEntity{ base = "BASE_NPC_SNAKE", + name = "black mamba", color=colors.BLACK, + desc = [[It has glistening black skin, a sleek body, and highly venomous fangs.]], + level_range = {7, 50}, exp_worth = 1, + rarity = 7, + max_life = resolvers.rngavg(50,80), + combat_armor = 4, combat_def = 12, + combat = { dam=10, atk=30, apr=10 }, + + talents = resolvers.talents{ [Talents.T_BITE_POISON]=3 }, +} + +newEntity{ base = "BASE_NPC_SNAKE", + name = "anaconda", color=colors.YELLOW_GREEN, + desc = [[You recoil in fear as you notice this huge, 10 meter long snake. It seeks to crush the life out of you.]], + level_range = {10, 50}, exp_worth = 1, + rarity = 11, + max_life = resolvers.rngavg(100,120), + combat_armor = 14, combat_def = 5, + combat = { dam=12, atk=10, apr=10 }, + energy = { mod=0.8 }, + + talents = resolvers.talents{ [Talents.T_STUN]=5 }, +} diff --git a/game/modules/tome/data/general/npcs/wolf.lua b/game/modules/tome/data/general/npcs/wolf.lua index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..25136b8db54d2d852e0922b49bc5035454c6cf51 100644 --- a/game/modules/tome/data/general/npcs/wolf.lua +++ b/game/modules/tome/data/general/npcs/wolf.lua @@ -0,0 +1,66 @@ +newEntity{ + define_as = "BASE_NPC_WOLF", + type = "animal", subtype = "wolf", + display = "C", color=colors.WHITE, + body = { INVEN = 10 }, + + max_stamina = 150, + + autolevel = "warrior", + ai = "dumb_talented_simple", ai_state = { talent_in=3, }, + energy = { mod=1.2 }, + stats = { str=10, dex=17, mag=3, con=7 }, + combat_armor = 1, combat_def = 1, +} + +newEntity{ base = "BASE_NPC_WOLF", + name = "wolf", color=colors.UMBER, + desc = [[Lean, mean and shaggy, it stares at you with hungry eyes.]], + level_range = {1, 50}, exp_worth = 1, + rarity = 4, + max_life = resolvers.rngavg(40,70), + combat_armor = 1, combat_def = 3, + combat = { dam=5, atk=15, apr=10 }, +} + +newEntity{ base = "BASE_NPC_WOLF", + name = "great wolf", color=colors.UMBER, + desc = [[Larger than a normal wolf, it prowls and snaps at you.]], + level_range = {3, 50}, exp_worth = 1, + rarity = 6, + max_life = resolvers.rngavg(60,90), + combat_armor =2, combat_def = 4, + combat = { dam=7, atk=15, apr=10 }, +} + +newEntity{ base = "BASE_NPC_WOLF", + name = "dire wolf", color=colors.DARK_UMBER, + desc = [[Easily as big as a horse, this wolf menaces you with its claws and fangs.]], + level_range = {4, 50}, exp_worth = 1, + rarity = 7, + max_life = resolvers.rngavg(80,110), + combat_armor = 3, combat_def = 5, + combat = { dam=13, atk=15, apr=10 }, +} + +newEntity{ base = "BASE_NPC_WOLF", + name = "white wolf", color=colors.WHITE, + desc = [[A large and muscled wolf from the northern wastes. Its breath is cold and icy and its fur coated in frost.]], + level_range = {4, 50}, exp_worth = 1, + rarity = 7, + max_life = resolvers.rngavg(70,100), + combat_armor = 3, combat_def = 4, + combat = { dam=8, atk=15, apr=10 }, + + resists = { [DamageType.FIRE] = -50, [DamageType.COLD] = 100 }, +} + +newEntity{ base = "BASE_NPC_WOLF", + name = "warg", color=colors.BLACK, + desc = [[It is a large wolf with eyes full of cunning.]], + level_range = {5, 50}, exp_worth = 1, + rarity = 7, + max_life = resolvers.rngavg(60,100), + combat_armor = 5, combat_def = 7, + combat = { dam=15, atk=17, apr=10 }, +} diff --git a/game/modules/tome/data/talents/misc/npcs.lua b/game/modules/tome/data/talents/misc/npcs.lua index d4ff1731604f1f76c62a97a9faf1e371ab89e0b0..38fed5fd515d85e33ec2141fe0ffb90bf7798c91 100644 --- a/game/modules/tome/data/talents/misc/npcs.lua +++ b/game/modules/tome/data/talents/misc/npcs.lua @@ -182,3 +182,22 @@ newTalent{ return ([[Hits the target with your weapon doing %d%% damage, if the atatck hits, the target is knocked back.]]):format(100 * (1.5 + self:getTalentLevel(t) / 10)) end, } + +newTalent{ + short_name = "BITE_POISON", + name = "Poisonous Bite", + type = {"physical/other", 1}, + points = 5, + message = "@Source@ bites poison into @target@.", + cooldown = 5, + range = 1, + action = function(self, t) + local x, y, target = self:getTarget() + if math.floor(core.fov.distance(self.x, self.y, x, y)) > 1 then return nil end + self:attackTarget(target, DamageType.POISON, 2 + self:getTalentLevel(t), true) + return true + end, + info = function(self) + return ([[Bites the target, infecting ti with poison.]]) + end, +} diff --git a/game/modules/tome/data/talents/spells/earth.lua b/game/modules/tome/data/talents/spells/earth.lua index e21e2a29a5349d5af09a63d584b3d5913151627b..744306c3b36da9dfb9acc6db8f568975c30e324c 100644 --- a/game/modules/tome/data/talents/spells/earth.lua +++ b/game/modules/tome/data/talents/spells/earth.lua @@ -82,12 +82,9 @@ newTalent{ action = function(self, t) local x, y = self.x, self.y if self:getTalentLevel(t) >= 4 then --- local tg = {type="bolt", range=self:getTalentRange(t), nolock=true} --- local x, y = self:getTarget(tg) --- if not x or not y then return nil end --- for i = 1, self:getTalentLevelRaw(t) do --- self:project(tg, x, y, DamageType.DIG, 1) --- end + local tg = {type="bolt", range=self:getTalentRange(t), nolock=true} + x, y = self:getTarget(tg) + if not x or not y then return nil end end for i = -1, 1 do for j = -1, 1 do if game.level.map:isBound(x + i, y + j) then diff --git a/game/modules/tome/data/zones/tower-amon-sul/npcs.lua b/game/modules/tome/data/zones/tower-amon-sul/npcs.lua index 666cb5521972e5ee8dd8dc55758cb4334aa7496c..46abce38bd71375f04a1fca1321295bb95fa312b 100644 --- a/game/modules/tome/data/zones/tower-amon-sul/npcs.lua +++ b/game/modules/tome/data/zones/tower-amon-sul/npcs.lua @@ -1,6 +1,7 @@ load("/data/general/npcs/vermin.lua") load("/data/general/npcs/molds.lua") load("/data/general/npcs/skeleton.lua") +load("/data/general/npcs/snake.lua") local Talents = require("engine.interface.ActorTalents") diff --git a/game/modules/tome/data/zones/trollshaws/npcs.lua b/game/modules/tome/data/zones/trollshaws/npcs.lua index 43bfe02e7e00f97cfc421e9c17576b73e7aec1b2..b107ab1ce4b00b272f8eafa6b61175846c22cf6a 100644 --- a/game/modules/tome/data/zones/trollshaws/npcs.lua +++ b/game/modules/tome/data/zones/trollshaws/npcs.lua @@ -1,6 +1,7 @@ load("/data/general/npcs/vermin.lua") load("/data/general/npcs/wolf.lua") load("/data/general/npcs/troll.lua") +load("/data/general/npcs/snake.lua") local Talents = require("engine.interface.ActorTalents")