diff --git a/game/engine/Map.lua b/game/engine/Map.lua index 60c87b2ec9d8704d201a5af94580a710ba96890e..fbbd905914f9b43dbc23169e9fd262999a4a4a50 100644 --- a/game/engine/Map.lua +++ b/game/engine/Map.lua @@ -65,6 +65,7 @@ end -- @param pos what kind of entity to set(Map.TERRAIN, Map.OBJECT, Map.ACTOR) -- @param entity the entity to set, if null it will return the current one function _M:call(x, y, pos, entity) + if x < 0 or y < 0 or x >= self.w or y >= self.h then return end if entity then self.map[x + y * self.w][pos] = entity self.changed = true diff --git a/game/engine/interface/BloodyDeath.lua b/game/engine/interface/BloodyDeath.lua new file mode 100644 index 0000000000000000000000000000000000000000..7d7794ec04de0524ba4fb7b1c9126abf19010e37 --- /dev/null +++ b/game/engine/interface/BloodyDeath.lua @@ -0,0 +1,23 @@ +require "engine.class" + +--- Interface to add a bloodyDeath() method to actords +-- When this method is called, the floor or walls around the late actor is covered in blood +module(..., package.seeall, class.make) + +--- Makes the bloody death happen +function _M:bloodyDeath() + if not self.has_blood then return end + local color = {255,0,100} + local done = 3 + if type(self.has_blood) == "table" then + done = self.has_blood.nb + color = self.has_blood.color + end + for i = 1, done do + local x, y = rng.range(self.x - 1, self.x + 1), rng.range(self.y - 1, self.y + 1) + if game.level.map(x, y, engine.Map.TERRAIN) then + -- Get the grid, clone it and alter its color + game.level.map(x, y, engine.Map.TERRAIN, game.level.map(x, y, engine.Map.TERRAIN):clone{color_r=color[1],color_g=color[2],color_b=color[3]}) + end + end +end diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index 80092ffcc0277cb710855670c4eb9d97df4a81f1..e917a5cac3b989750e066d1b2fa8a60be13f452d 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -2,8 +2,9 @@ require "engine.class" require "engine.Actor" require "engine.interface.ActorLife" require "engine.interface.ActorLevel" +require "engine.interface.BloodyDeath" -module(..., package.seeall, class.inherit(engine.Actor, engine.interface.ActorLife, engine.interface.ActorLevel)) +module(..., package.seeall, class.inherit(engine.Actor, engine.interface.ActorLife, engine.interface.ActorLevel, engine.interface.BloodyDeath)) function _M:init(t) engine.Actor.init(self, t) @@ -29,6 +30,7 @@ function _M:die(src) if src then src:gainExp(self:worthExp()) end + self:bloodyDeath() end function _M:levelup() diff --git a/game/modules/tome/data/zones/ancient_ruins/npcs.lua b/game/modules/tome/data/zones/ancient_ruins/npcs.lua index 77e7f4464e341e269bdc997e3d114041327e53cc..282723bc1dfdfb860f7c1025ef5d6b7e5bdb54f7 100644 --- a/game/modules/tome/data/zones/ancient_ruins/npcs.lua +++ b/game/modules/tome/data/zones/ancient_ruins/npcs.lua @@ -7,6 +7,7 @@ return { life = 20, mana = 1000, energy = { mod=0.8 }, + has_blood = true, }, { name = "baby dragon", @@ -15,6 +16,7 @@ return { life = 30, mana = 1000, energy = { mod=0.3 }, + has_blood = true, }, } \ No newline at end of file diff --git a/game/modules/tome/data/zones/ancient_ruins/zone.lua b/game/modules/tome/data/zones/ancient_ruins/zone.lua index 716a0e70c5421b0bb384327330a6303a9e9a8827..d3e90f78ab0e9936b6f963f1631e97f40f464aff 100644 --- a/game/modules/tome/data/zones/ancient_ruins/zone.lua +++ b/game/modules/tome/data/zones/ancient_ruins/zone.lua @@ -7,7 +7,7 @@ return { level_npcs = {5, 10}, generator = { map = { - class= "engine.generator.map.Empty", + class= "engine.generator.map.Rooms", floor = "FLOOR", wall = "WALL", up = "UP",