From 6d3a323e23b1accf933121ace550d6ee2d31ae54 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Tue, 9 Mar 2010 22:41:37 +0000 Subject: [PATCH] bg health warning git-svn-id: http://svn.net-core.org/repos/t-engine4@391 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engine/Birther.lua | 18 ++-- game/engine/FlyingText.lua | 11 ++- game/engine/generator/map/Roomer.lua | 20 ++++ game/engine/generator/map/Static.lua | 9 +- game/modules/tome/class/Game.lua | 2 +- game/modules/tome/class/Player.lua | 10 +- .../tome/data/birth/{ => classes}/archer.lua | 4 +- .../tome/data/birth/{ => classes}/mage.lua | 8 +- .../tome/data/birth/{ => classes}/rogue.lua | 2 +- .../tome/data/birth/{ => classes}/warrior.lua | 2 +- game/modules/tome/data/birth/descriptors.lua | 8 +- .../data/maps/zones/tower-amon-sul-last.lua | 99 ++++++++++--------- 12 files changed, 115 insertions(+), 78 deletions(-) rename game/modules/tome/data/birth/{ => classes}/archer.lua (98%) rename game/modules/tome/data/birth/{ => classes}/mage.lua (98%) rename game/modules/tome/data/birth/{ => classes}/rogue.lua (99%) rename game/modules/tome/data/birth/{ => classes}/warrior.lua (99%) diff --git a/game/engine/Birther.lua b/game/engine/Birther.lua index 1456c0649f..fd191abcdf 100644 --- a/game/engine/Birther.lua +++ b/game/engine/Birther.lua @@ -119,6 +119,15 @@ function _M:apply() print("[BIRTH] Applying descriptor "..d.name) self.actor.descriptor[d.type] = d.name + if d.copy then + -- Append array part + while #d.copy > 0 do + local f = table.remove(d.copy) + table.insert(self.actor, f) + end + -- Copy normal data + table.merge(self.actor, d.copy, true) + end -- Change stats if d.stats then for stat, inc in pairs(d.stats) do @@ -150,15 +159,6 @@ function _M:apply() self.actor.body = d.body self.actor:initBody() end - if d.copy then - -- Append array part - while #d.copy > 0 do - local f = table.remove(d.copy) - table.insert(self.actor, f) - end - -- Copy normal data - table.merge(self.actor, d.copy, true) - end end end diff --git a/game/engine/FlyingText.lua b/game/engine/FlyingText.lua index ce441a6f0e..b6e65f877f 100644 --- a/game/engine/FlyingText.lua +++ b/game/engine/FlyingText.lua @@ -4,25 +4,28 @@ module(..., package.seeall, class.make) function _M:init(fontname, fontsize) self.font = core.display.newFont(fontname or "/data/font/Vera.ttf", fontsize or 12) + self.bigfont = core.display.newFont(fontname or "/data/font/VeraBd.ttf", fontsize or 18) self.font_h = self.font:lineSkip() self.flyers = {} end -function _M:add(x, y, duration, xvel, yvel, str, color) +function _M:add(x, y, duration, xvel, yvel, str, color, bigfont) assert(x, "no x flyer") assert(y, "no y flyer") assert(str, "no str flyer") color = color or {255,255,255} - local s = core.display.drawStringNewSurface(self.font, str, color[1], color[2], color[3]) + local s = core.display.drawStringNewSurface(bigfont and self.bigfont or self.font, str, color[1], color[2], color[3]) if not s then return end - self.flyers[{ + local f = { x=x, y=y, duration=duration or 10, xvel = xvel or 0, yvel = yvel or 0, s = s - }] = true + } + self.flyers[f] = true + return f end function _M:empty() diff --git a/game/engine/generator/map/Roomer.lua b/game/engine/generator/map/Roomer.lua index 7b02674706..f5cde30ad6 100644 --- a/game/engine/generator/map/Roomer.lua +++ b/game/engine/generator/map/Roomer.lua @@ -323,6 +323,26 @@ function _M:generate(lev, old_lev) end end + -- Forced tunnels + if self.data.force_tunnels then + for _, t in ipairs(self.data.force_tunnels) do + local sx, sy, ex, ey + if type(t[1]) == "string" then + local i = rng.range(1, #rooms) + sx, sy = rooms[i].cx, rooms[i].cy + else + sx, sy = t[1][1], t[1][2] + end + if type(t[2]) == "string" then + local i = rng.range(1, #rooms) + ex, ey = rooms[i].cx, rooms[i].cy + else + ex, ey = t[2][1], t[2][2] + end + self:tunnel(sx, sy, ex, ey, t.id) + end + end + -- Find out "interresting" spots local spots = {} for i, r in ipairs(rooms) do diff --git a/game/engine/generator/map/Static.lua b/game/engine/generator/map/Static.lua index 71a2e39cb3..f3b8a03ea3 100644 --- a/game/engine/generator/map/Static.lua +++ b/game/engine/generator/map/Static.lua @@ -58,6 +58,8 @@ function _M:loadMap(file) m.startx = g.startx or math.floor(m.w / 2) m.starty = g.starty or math.floor(m.h / 2) + m.endx = g.endx or math.floor(m.w / 2) + m.endy = g.endy or math.floor(m.h / 2) self.gen_map = m self.tiles = t @@ -113,11 +115,14 @@ function _M:generate(lev, old_lev) self.level, data ) - generator:generate(lev, old_lev) + local ux, uy, dx, dy = generator:generate(lev, old_lev) self.map:import(map, g.x, g.y) map:close() + + if g.define_up then self.gen_map.startx, self.gen_map.starty = ux + g.x, uy + g.y end + if g.define_down then self.gen_map.endx, self.gen_map.endy = dx + g.x, dy + g.y end end - return self.gen_map.startx, self.gen_map.starty, self.gen_map.startx, self.gen_map.starty + return self.gen_map.startx, self.gen_map.starty, self.gen_map.endx, self.gen_map.endy end diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 556bf0ba55..2453ed6dc4 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -335,7 +335,7 @@ function _M:setupCommands() { TACTICAL_DISPLAY = function() self:targetMode(false, false) end, ACCEPT = function() self:targetMode(false, false) end, - EXCIT = function() + EXIT = function() self.target.target.entity = nil self.target.target.x = nil self.target.target.y = nil diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 41b6a3812e..e098fa6278 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -98,7 +98,13 @@ end function _M:onTakeHit(value, src) self:runStop("taken damage") self:restStop("taken damage") - return mod.class.Actor.onTakeHit(self, value, src) + local ret = mod.class.Actor.onTakeHit(self, value, src) + if self.life < self.max_life * 0.3 and (not self.last_life_warning or self.last_life_warning < game.turn) then + local sx, sy = game.level.map:getTileToScreen(self.x, self.y) + game.flyers:add(sx, sy, 30, (rng.range(0,2)-1) * 0.5, 2, "LOW HEALTH!", {255,0,0}, true) + self.last_life_warning = game.turn + end + return ret end function _M:die() @@ -270,7 +276,7 @@ function _M:playerUseItem(object, item) o.multicharge = o.multicharge - 1 else self:removeObject(self:getInven(self.INVEN_INVEN), item) - game.log("You have no more "..o:getName()) + game.log("You have no more "..o:getName{no_count=true}) self:sortInven() end end diff --git a/game/modules/tome/data/birth/archer.lua b/game/modules/tome/data/birth/classes/archer.lua similarity index 98% rename from game/modules/tome/data/birth/archer.lua rename to game/modules/tome/data/birth/classes/archer.lua index d6fb48b869..4261e2873e 100644 --- a/game/modules/tome/data/birth/archer.lua +++ b/game/modules/tome/data/birth/classes/archer.lua @@ -14,8 +14,8 @@ newBirthDescriptor{ }, }, copy = { - max_life = 95, - life_rating = 9, + max_life = 110, + life_rating = 10, }, } diff --git a/game/modules/tome/data/birth/mage.lua b/game/modules/tome/data/birth/classes/mage.lua similarity index 98% rename from game/modules/tome/data/birth/mage.lua rename to game/modules/tome/data/birth/classes/mage.lua index b4365c7808..9d25629dc2 100644 --- a/game/modules/tome/data/birth/mage.lua +++ b/game/modules/tome/data/birth/classes/mage.lua @@ -52,8 +52,8 @@ newBirthDescriptor{ [ActorTalents.T_PHASE_DOOR] = 1, }, copy = { - max_life = 80, - life_rating = 7, + max_life = 90, + life_rating = 10, resolvers.equip{ id=true, {type="weapon", subtype="staff", name="elm staff", autoreq=true}, {type="armor", subtype="cloth", name="robe", autoreq=true} @@ -98,8 +98,8 @@ newBirthDescriptor{ [ActorTalents.T_WEAPON_COMBAT] = 1, }, copy = { - max_life = 90, - life_rating = 8, + max_life = 100, + life_rating = 9, mana_rating = 8, stamina_rating = 8, resolvers.equip{ id=true, diff --git a/game/modules/tome/data/birth/rogue.lua b/game/modules/tome/data/birth/classes/rogue.lua similarity index 99% rename from game/modules/tome/data/birth/rogue.lua rename to game/modules/tome/data/birth/classes/rogue.lua index 9076cf9d37..ed9c3f5dbb 100644 --- a/game/modules/tome/data/birth/rogue.lua +++ b/game/modules/tome/data/birth/classes/rogue.lua @@ -16,7 +16,7 @@ newBirthDescriptor{ }, copy = { max_life = 100, - life_rating = 9, + life_rating = 10, equipment = resolvers.equip{ id=true, {type="weapon", subtype="dagger", name="iron dagger", autoreq=true}, {type="weapon", subtype="dagger", name="iron dagger", autoreq=true}, diff --git a/game/modules/tome/data/birth/warrior.lua b/game/modules/tome/data/birth/classes/warrior.lua similarity index 99% rename from game/modules/tome/data/birth/warrior.lua rename to game/modules/tome/data/birth/classes/warrior.lua index 652cb6a785..ff58d1c993 100644 --- a/game/modules/tome/data/birth/warrior.lua +++ b/game/modules/tome/data/birth/classes/warrior.lua @@ -15,7 +15,7 @@ newBirthDescriptor{ }, copy = { max_life = 120, - life_rating = 10, + life_rating = 12, }, } diff --git a/game/modules/tome/data/birth/descriptors.lua b/game/modules/tome/data/birth/descriptors.lua index b1d5119942..7ec6d33113 100644 --- a/game/modules/tome/data/birth/descriptors.lua +++ b/game/modules/tome/data/birth/descriptors.lua @@ -33,7 +33,7 @@ load("/data/birth/races/dwarf.lua") load("/data/birth/sexes.lua") -- Classes -load("/data/birth/warrior.lua") -load("/data/birth/archer.lua") -load("/data/birth/rogue.lua") -load("/data/birth/mage.lua") +load("/data/birth/classes/warrior.lua") +load("/data/birth/classes/archer.lua") +load("/data/birth/classes/rogue.lua") +load("/data/birth/classes/mage.lua") diff --git a/game/modules/tome/data/maps/zones/tower-amon-sul-last.lua b/game/modules/tome/data/maps/zones/tower-amon-sul-last.lua index 1bf08c7ce7..66dfe65c15 100644 --- a/game/modules/tome/data/maps/zones/tower-amon-sul-last.lua +++ b/game/modules/tome/data/maps/zones/tower-amon-sul-last.lua @@ -8,64 +8,67 @@ subGenerator{ generator = "engine.generator.map.Roomer", data = { nb_rooms = 10, - edge_entrances = {8,2}, rooms = {"simple", "pilar"}, ['.'] = "FLOOR", ['#'] = "WALL", up = "UP", door = "DOOR", + force_tunnels = { + {"random", {26, 43}, id=-500}, + }, }, + define_up = true, } return { -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], -[[..................................................]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], +[[ ]], [[#########################+########################]], +[[##..............#...#........#...#..............##]], +[[#.............#...#...#....#...#...#.............#]], +[[#.........##############################.........#]], [[#................................................#]], -[[#................................................#]], -[[#................................................#]], -[[#................................................#]], -[[#........................s.......................#]], +[[##.......................s......................##]], [[##################################################]] } -- GitLab