Skip to content
Snippets Groups Projects
Commit 20775d04 authored by dg's avatar dg
Browse files

map can define obscure and shown color tint

Ringil can throw a burst of ice
Amulet of the fish (water braething)
flooded cave is underwater


git-svn-id: http://svn.net-core.org/repos/t-engine4@564 51575b47-30f0-44d4-a5cc-537603b46e54
parent 776030a1
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,8 @@ OBJECT = 1000
--- The order of display for grid seen
searchOrder = { TERRAIN, TRAP, OBJECT, ACTOR }
obscure = { 0.6, 0.6, 0.6, 1 }
color_shown = { 1, 1, 1, 1 }
color_obscure = { 0.6, 0.6, 0.6, 1 }
--- Sets the viewport size
-- Static
......@@ -62,9 +63,17 @@ end
--- Defines the "obscure" factor of unseen map
-- By default it is 0.6, 0.6, 0.6, 1
function _M:setObscure(r, g, b, a)
self.obscure = {r, g, b, a}
self.color_obscure = {r, g, b, a}
-- If we are used on a real map, set it localy
if self._map then self._map:setObscure(unpack(self.obscure)) end
if self._map then self._map:setObscure(unpack(self.color_obscure)) end
end
--- Defines the "shown" factor of seen map
-- By default it is 1, 1, 1, 1
function _M:setShown(r, g, b, a)
self.color_shown= {r, g, b, a}
-- If we are used on a real map, set it localy
if self._map then self._map:setShown(unpack(self.color_shown)) end
end
--- Create the tile repositories
......@@ -120,7 +129,8 @@ function _M:loaded()
self.particle = core.display.loadImage("/data/gfx/particle.png"):glTexture()
self._map = core.map.newMap(self.w, self.h, self.mx, self.my, self.viewport.mwidth, self.viewport.mheight, self.tile_w, self.tile_h, self.multidisplay)
self._map:setObscure(unpack(self.obscure))
self._map:setObscure(unpack(self.color_obscure))
self._map:setShown(unpack(self.color_shown))
self._fovcache =
{
block_sight = core.fov.newCache(self.w, self.h),
......
......@@ -447,6 +447,10 @@ function _M:newLevel(level_data, lev, old_lev, game)
generator:generate()
end
-- Adjust shown & obscure colors
if level_data.color_shown then map:setShown(unpack(level_data.color_shown)) end
if level_data.color_obscure then map:setObscure(unpack(level_data.color_obscure)) end
-- Delete the room_map, now useless
map.room_map = nil
......
......@@ -52,7 +52,9 @@ end
function _M:useObject(who)
if self.use_power then
if self.power >= self.use_power.power then
local ret, no_power = self.use_power.use(self, who)
local co = coroutine.create(function() return self.use_power.use(self, who) end)
local ok, ret, no_power = coroutine.resume(co)
if not ok and ret then error(ret) end
if not no_power then self.power = self.power - self.use_power.power end
return ret
else
......@@ -63,7 +65,9 @@ function _M:useObject(who)
end
end
elseif self.use_simple then
local ret = self.use_simple.use(self, who)
local co = coroutine.create(function() return self.use_simple.use(self, who) end)
local ok, ret = coroutine.resume(co)
if not ok and ret then error(ret) end
return ret
end
end
......@@ -89,6 +89,7 @@ function _M:init(t, no_default)
t.melee_project = t.melee_project or {}
t.can_pass = t.can_pass or {}
t.move_project = t.move_project or {}
t.can_breath = t.can_breath or {}
-- Resistances
t.resists = t.resists or {}
......@@ -144,8 +145,10 @@ function _M:act()
if self:attr("stunned") then self.energy.value = 0 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
local air_level, air_condition = game.level.map:checkEntity(self.x, self.y, Map.TERRAIN, "air_level"), game.level.map:checkEntity(self.x, self.y, Map.TERRAIN, "air_condition")
if air_level then
if not air_condition or not self.can_breath[air_condition] then self:suffocate(-air_level, self) end
end
-- Regain natural balance?
local equilibrium_level = game.level.map:checkEntity(self.x, self.y, Map.TERRAIN, "equilibrium_level")
......@@ -781,8 +784,9 @@ end
--- Suffocate a bit, lose air
function _M:suffocate(value, src)
if self:attr("no_breath") then return end
self.air = self.air - value
if self.air <= 0 and not self:attr("no_breath") then
if self.air <= 0 then
game.logSeen(self, "%s suffocates to death!", self.name:capitalize())
return self:die(src)
end
......
......@@ -108,3 +108,12 @@ newEntity{
esp = {range=10},
},
}
newEntity{
name = " of the fish",
level_range = {25, 50},
rarity = 10,
cost = 10,
wielder = {
can_breath = {water=1},
},
}
......@@ -41,4 +41,14 @@ newEntity{ base = "BASE_LONGSWORD",
inc_damage = { [DamageType.COLD] = 20 },
melee_project={[DamageType.ICE] = 15},
},
max_power = 18, power_regen = 1,
use_power = { name = "generate a burst of ice", power = 8,
use = function(self, who)
local tg = {type="ball", range=0, radius=4, friendlyfire=false}
who:project(tg, who.x, who.y, engine.DamageType.ICE, {dur=2, dam=10 + (who:getMag() + who:getWil()) / 2}, {type="freeze"})
game:playSoundNear(who, "talents/ice")
game.logSeen(who, "%s invokes the power of his icy sword!", who.name:capitalize())
return true
end
},
}
......@@ -23,6 +23,7 @@ newEntity{
define_as = "WATER_FLOOR",
name = "underwater", image = "terrain/water_floor.png",
display = '.', color=colors.LIGHT_BLUE,
air_level = -5, air_condition="water",
}
newEntity{
......@@ -33,4 +34,5 @@ newEntity{
can_pass = {pass_wall=1},
does_block_move = true,
block_sight = true,
air_level = -20,
}
......@@ -25,10 +25,13 @@ return {
decay = {300, 800},
actor_adjust_level = function(zone, level, e) return zone.base_level + e:getRankLevelAdjust() + level.level-1 + rng.range(-1,2) end,
width = 50, height = 50,
-- all_remembered = true,
all_remembered = true,
all_lited = true,
persistant = "zone",
-- persistant = "zone",
ambiant_music = "elven_town.ogg",
-- Apply a bluish tint to all the map
color_shown = {0.5, 1, 0.8, 1},
color_obscure = {0.5*0.6, 1*0.6, 0.8*0.6, 1},
generator = {
map = {
class = "engine.generator.map.Roomer",
......@@ -55,7 +58,7 @@ return {
trap = {
class = "engine.generator.trap.Random",
-- nb_object = {6, 9},
nb_object = {0, 0},
nb_trap = {0, 0},
},
},
levels =
......
No preview for this file type
......@@ -45,6 +45,8 @@ static int map_new(lua_State *L)
map->obscure_r = map->obscure_g = map->obscure_b = 0.6f;
map->obscure_a = 1;
map->shown_r = map->shown_g = map->shown_b = 1;
map->shown_a = 1;
map->multidisplay = multidisplay;
map->w = w;
......@@ -134,6 +136,20 @@ static int map_set_obscure(lua_State *L)
return 0;
}
static int map_set_shown(lua_State *L)
{
map_type *map = (map_type*)auxiliar_checkclass(L, "core{map}", 1);
float r = luaL_checknumber(L, 2);
float g = luaL_checknumber(L, 3);
float b = luaL_checknumber(L, 4);
float a = luaL_checknumber(L, 5);
map->shown_r = r;
map->shown_g = g;
map->shown_b = b;
map->shown_a = a;
return 0;
}
static int map_set_grid(lua_State *L)
{
map_type *map = (map_type*)auxiliar_checkclass(L, "core{map}", 1);
......@@ -252,7 +268,7 @@ static int map_to_screen(lua_State *L)
{
if (map->grids_seens[i][j])
{
glColor4f(1, 1, 1, 1);
glColor4f(map->shown_r, map->shown_g, map->shown_b, map->shown_a);
if (map->multidisplay)
{
......@@ -374,6 +390,7 @@ static const struct luaL_reg map_reg[] =
{
{"__gc", map_free},
{"close", map_free},
{"setShown", map_set_shown},
{"setObscure", map_set_obscure},
{"setGrid", map_set_grid},
{"cleanSeen", map_clean_seen},
......
......@@ -36,6 +36,7 @@ typedef struct {
// Map parameters
float obscure_r, obscure_g, obscure_b, obscure_a;
float shown_r, shown_g, shown_b, shown_a;
// Map size
int w;
......
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