From 3acb88dfc44a80dc6112eb376b263c90a8604587 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Thu, 4 Feb 2010 15:41:09 +0000 Subject: [PATCH] air capacity; when it reaches 0 you die being in a wall means you cant breath and thus suffocates you sandwall tunnels can come crushing down on your git-svn-id: http://svn.net-core.org/repos/t-engine4@317 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/modules/tome/class/Actor.lua | 20 +++++++++++++++++-- game/modules/tome/class/PlayerDisplay.lua | 10 +++++++++- game/modules/tome/class/interface/Combat.lua | 2 +- .../modules/tome/data/general/grids/basic.lua | 1 + game/modules/tome/data/general/grids/sand.lua | 8 ++++++++ game/modules/tome/data/zones/maze/grids.lua | 1 + game/modules/tome/load.lua | 1 + 7 files changed, 39 insertions(+), 4 deletions(-) diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index 42036c10e5..dcacc97924 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -63,9 +63,10 @@ function _M:init(t, no_default) t.resists = t.resists or {} -- Default regen + t.air_regen = t.air_regen or 3 t.mana_regen = t.mana_regen or 0.5 - t.stamina_regen = t.stamina_regen or 0.4 -- Stamina regens slower than mana - t.life_regen = t.life_regen or 0.3 -- Life regen real slow + t.stamina_regen = t.stamina_regen or 0.3 -- Stamina regens slower than mana + t.life_regen = t.life_regen or 0.25 -- Life regen real slow -- Default melee barehanded damage self.combat = { dam=1, atk=1, apr=0, dammod={str=1} } @@ -97,6 +98,10 @@ function _M:act() t.do_storm(self, t) end + -- Suffocate ? + local air_level = game.level.map:checkEntity(self.x, self.y, Map.TERRAIN, "air_level") + if air_level then self:suffocate(-air_level, self) end + -- Still enough energy to act ? if self.energy.value < game.energy_to_act then return false end @@ -474,6 +479,17 @@ function _M:worthExp(target) return self.level * mult * self.exp_worth end +--- Suffocate a bit, lose air +function _M:suffocate(value, src) + self.air = self.air - value + if self.air <= 0 and not self:attr("no_breath") then + game.logSeen(self, "%s suffocates to death!", self.name:capitalize()) + game.level:removeEntity(self) + self.dead = true + return self:die(src) + end +end + --- Can the actor see the target actor -- This does not check LOS or such, only the actual ability to see it.<br/> -- Check for telepathy, invisibility, stealth, ... diff --git a/game/modules/tome/class/PlayerDisplay.lua b/game/modules/tome/class/PlayerDisplay.lua index 3771ce8a3c..2b93165b5c 100644 --- a/game/modules/tome/class/PlayerDisplay.lua +++ b/game/modules/tome/class/PlayerDisplay.lua @@ -32,17 +32,25 @@ function _M:display() h = h + self.font_h self.surface:drawColorString(self.font, "Level: #00ff00#"..game.player.level, 0, h, 255, 255, 255) h = h + self.font_h self.surface:drawColorString(self.font, ("Exp: #00ff00#%2d%%"):format(100 * cur_exp / max_exp), 0, h, 255, 255, 255) h = h + self.font_h + h = h + self.font_h + + if game.player:getAir() < game.player.max_air then + self.surface:drawColorString(self.font, ("Air level: %d/%d"):format(game.player:getAir(), game.player.max_air), 0, h, 255, 0, 0) h = h + self.font_h + h = h + self.font_h + end + self.surface:drawColorString(self.font, ("#c00000#Life: #00ff00#%d/%d"):format(game.player.life, game.player.max_life), 0, h, 255, 255, 255) h = h + self.font_h if game.player:knowTalent(game.player.T_MANA_POOL) then self.surface:drawColorString(self.font, ("#7fffd4#Mana: #00ff00#%d/%d"):format(game.player:getMana(), game.player.max_mana), 0, h, 255, 255, 255) h = h + self.font_h end if game.player:knowTalent(game.player.T_SOUL_POOL) then - self.surface:drawColorString(self.font, ("#777777#Soul: #00ff00#%d/%d"):format(game.player:getSoul(), game.player.max_soul), 0, h, 255, 255, 255) h = h + self.font_h + self.surface:drawColorString(self.font, ("#777777#Soul: #00ff00#%d/%d"):format(game.player:getSoul(), game.player.max_soul), 0, h, 255, 255, 255) h = h + self.font_h end if game.player:knowTalent(game.player.T_STAMINA_POOL) then self.surface:drawColorString(self.font, ("#ffcc80#Stamina: #00ff00#%d/%d"):format(game.player:getStamina(), game.player.max_stamina), 0, h, 255, 255, 255) h = h + self.font_h end + h = h + self.font_h self.surface:drawColorString(self.font, ("STR: #00ff00#%3d"):format(game.player:getStr()), 0, h, 255, 255, 255) h = h + self.font_h self.surface:drawColorString(self.font, ("DEX: #00ff00#%3d"):format(game.player:getDex()), 0, h, 255, 255, 255) h = h + self.font_h diff --git a/game/modules/tome/class/interface/Combat.lua b/game/modules/tome/class/interface/Combat.lua index 8309ed9f5f..6c8810903e 100644 --- a/game/modules/tome/class/interface/Combat.lua +++ b/game/modules/tome/class/interface/Combat.lua @@ -114,7 +114,7 @@ end --- Attacks with one weapon function _M:attackTargetWith(target, weapon, damtype, mult) - damtype = damtype or DamageType.PHYSICAL + damtype = damtype or weapon.damtype or DamageType.PHYSICAL mult = mult or 1 -- Does the blow connect? yes .. complex :/ diff --git a/game/modules/tome/data/general/grids/basic.lua b/game/modules/tome/data/general/grids/basic.lua index edaac4646c..168c025f59 100644 --- a/game/modules/tome/data/general/grids/basic.lua +++ b/game/modules/tome/data/general/grids/basic.lua @@ -39,6 +39,7 @@ newEntity{ always_remember = true, block_move = true, block_sight = true, + air_level = -20, dig = "FLOOR", } diff --git a/game/modules/tome/data/general/grids/sand.lua b/game/modules/tome/data/general/grids/sand.lua index 36120ae079..bda73521a7 100644 --- a/game/modules/tome/data/general/grids/sand.lua +++ b/game/modules/tome/data/general/grids/sand.lua @@ -11,6 +11,7 @@ newEntity{ always_remember = true, block_move = true, block_sight = true, + air_level = -10, -- Dig only makes unstable tunnels dig = function(src, x, y, old) local sand = require("engine.Object").new{ @@ -24,6 +25,13 @@ newEntity{ game.level.map(self.x, self.y, engine.Map.TERRAIN, self.old_feat) game:removeEntity(self) game.logSeen(self, "The unstable sand tunnel collapses!") + + local a = game.level.map(self.x, self.y, engine.Map.ACTOR) + if a then + game.logPlayer(a, "You are crushed by the collapsing tunnel! You suffocate!") + a:suffocate(30, self) + DamageType:get(DamageType.PHYSICAL).projector(self, self.x, self.y, DamageType.PHYSICAL, a.life / 2) + end end end } diff --git a/game/modules/tome/data/zones/maze/grids.lua b/game/modules/tome/data/zones/maze/grids.lua index 840f331d9e..1dd2247813 100644 --- a/game/modules/tome/data/zones/maze/grids.lua +++ b/game/modules/tome/data/zones/maze/grids.lua @@ -19,4 +19,5 @@ newEntity{ display = '#', color_r=255, color_g=255, color_b=255, block_move = true, block_sight = true, + air_level = -20, } diff --git a/game/modules/tome/load.lua b/game/modules/tome/load.lua index fee71a29de..9bdf2a6024 100644 --- a/game/modules/tome/load.lua +++ b/game/modules/tome/load.lua @@ -42,6 +42,7 @@ ActorTalents:loadDefinition("/data/talents.lua") ActorTemporaryEffects:loadDefinition("/data/timed_effects.lua") -- Actor resources +ActorResource:defineResource("Air", "air", nil, "air_regen", "Air capacity in your lungs. Entities that need not to breath are not affected.") ActorResource:defineResource("Mana", "mana", ActorTalents.T_MANA_POOL, "mana_regen", "Mana represents your reserve of magical energies. Each spell cast consumes mana and each sustained spell reduces your maximun mana.") ActorResource:defineResource("Stamina", "stamina", ActorTalents.T_STAMINA_POOL, "stamina_regen", "Stamina represents your physical fatigue. Each physical ability used reduces it.") ActorResource:defineResource("Soul", "soul", ActorTalents.T_SOUL_POOL, "soul_regen", "Soul represents the amount of life energies/souls you have stolen. Each Necromantic spell requires some.") -- GitLab