Skip to content
Snippets Groups Projects
Commit 3acb88df authored by dg's avatar dg
Browse files

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
parent 99579cf2
No related branches found
No related tags found
No related merge requests found
......@@ -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, ...
......
......@@ -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
......
......@@ -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 :/
......
......@@ -39,6 +39,7 @@ newEntity{
always_remember = true,
block_move = true,
block_sight = true,
air_level = -20,
dig = "FLOOR",
}
......
......@@ -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
}
......
......@@ -19,4 +19,5 @@ newEntity{
display = '#', color_r=255, color_g=255, color_b=255,
block_move = true,
block_sight = true,
air_level = -20,
}
......@@ -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.")
......
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