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

new grass/any transitions

git-svn-id: http://svn.net-core.org/repos/t-engine4@3654 51575b47-30f0-44d4-a5cc-537603b46e54
parent 9db1f3f3
No related branches found
No related tags found
No related merge requests found
Showing
with 110 additions and 90 deletions
......@@ -938,9 +938,14 @@ function _M:setupCommands()
self.key:addCommands{
[{"_a","ctrl"}] = function() if config.settings.cheat then game:registerDialog(require("mod.dialogs.debug.DebugMain").new()) end end,
[{"_d","ctrl"}] = function() if config.settings.cheat then
print(game.level.map(game.player.x, game.player.y, Map.TERRAIN).define_as, game.level.map(game.player.x, game.player.y, Map.TERRAIN).image)
local add = game.level.map(game.player.x, game.player.y, Map.TERRAIN).add_displays
if add then for i, e in ipairs(add) do print(" -", e.image) end end
local g = game.level.map(game.player.x, game.player.y, Map.TERRAIN)
print(g.define_as, g.image)
for i, a in ipairs(g.add_mos or {}) do print(" => ", a.image) end
local add = g.add_displays
if add then for i, e in ipairs(add) do
print(" -", e.image)
for i, a in ipairs(e.add_mos or {}) do print(" => ", a.image) end
end end
end end,
[{"_f","ctrl"}] = function() if config.settings.cheat then
self.nicer_tiles:updateAround(self.level, game.player.x, game.player.y)
......
......@@ -25,6 +25,7 @@ module(..., package.seeall, class.make)
function _M:init()
self.repo = {}
self.repl = {}
self.edits = {}
end
function _M:getTile(name)
......@@ -54,10 +55,15 @@ function _M:replace(i, j, g)
end
end
function _M:edit(i, j, e)
self.edits[#self.edits+1] = {i, j, add_display=e.add_display, add_mos=e.add_mos, min=e.min, max=e.max}
end
function _M:handle(level, i, j)
local g = level.map(i, j, Map.TERRAIN)
if g and Map.tiles.nicer_tiles and g.nice_tiler then
self["niceTile"..g.nice_tiler.method:capitalize()](self, level, i, j, g, g.nice_tiler)
if g and Map.tiles.nicer_tiles then
if g.nice_tiler then self["niceTile"..g.nice_tiler.method:capitalize()](self, level, i, j, g, g.nice_tiler) end
if g.nice_editer then self["editTile"..g.nice_editer.method:capitalize()](self, level, i, j, g, g.nice_editer) end
end
end
......@@ -67,6 +73,32 @@ function _M:replaceAll(level)
level.map(r[1], r[2], Map.TERRAIN, r[3])
end
self.repl = {}
for i = 1, #self.edits do
local e = self.edits[i]
local g = level.map(e[1], e[2], Map.TERRAIN)
local cloned = false
if not g.force_clone then g = g:clone() g.force_clone = true cloned = true end
if e.add_mos then
-- Edit the first add_display entity, or add a dummy if none
if not g.__edit_d then
g.add_displays = g.add_displays or {}
g.add_displays[#g.add_displays+1] = require(g.__CLASSNAME).new{image="invis.png", force_clone=true}
g.__edit_d = #g.add_displays
end
-- Add all the mos
g.add_displays[g.__edit_d].add_mos = g.add_displays[g.__edit_d].add_mos or {}
local mos = g.add_displays[g.__edit_d].add_mos
for i = 1, #e.add_mos do
mos[#mos+1] = e.add_mos[i]
mos[#mos].image = mos[#mos].image:format(rng.range(e.min, e.max))
end
g.add_displays[g.__edit_d]._mo = nil
end
g._mo = nil
level.map(e[1], e[2], Map.TERRAIN, g)
end
self.edits = {}
end
function _M:postProcessLevelTiles(level)
......@@ -217,6 +249,39 @@ function _M:niceTileOuterSpace(level, i, j, g, nt)
self:niceTileGenericBorders(level, i, j, g, nt, "rocks", {void=true})
end
--- Make water have nice transition to other stuff
function _M:editTileGenericBorders(level, i, j, g, nt, type, allow)
local g5 = level.map:checkEntity(i, j, Map.TERRAIN, "subtype") or type
local g8 = level.map:checkEntity(i, j-1, Map.TERRAIN, "subtype") or type
local g2 = level.map:checkEntity(i, j+1, Map.TERRAIN, "subtype") or type
local g4 = level.map:checkEntity(i-1, j, Map.TERRAIN, "subtype") or type
local g6 = level.map:checkEntity(i+1, j, Map.TERRAIN, "subtype") or type
local g7 = level.map:checkEntity(i-1, j-1, Map.TERRAIN, "subtype") or type
local g9 = level.map:checkEntity(i+1, j-1, Map.TERRAIN, "subtype") or type
local g1 = level.map:checkEntity(i-1, j+1, Map.TERRAIN, "subtype") or type
local g3 = level.map:checkEntity(i+1, j+1, Map.TERRAIN, "subtype") or type
-- Sides
if g5 ~= g8 then self:edit(i, j, nt["default".."8"]) end
if g5 ~= g2 then self:edit(i, j, nt["default".."2"]) end
if g5 ~= g4 then self:edit(i, j, nt["default".."4"]) end
if g5 ~= g6 then self:edit(i, j, nt["default".."6"]) end
-- Corners
if g5 ~= g7 and g5 == g4 and g5 == g8 then self:edit(i, j, nt["default".."7"]) end
if g5 ~= g9 and g5 == g6 and g5 == g8 then self:edit(i, j, nt["default".."9"]) end
if g5 ~= g1 and g5 == g4 and g5 == g2 then self:edit(i, j, nt["default".."1"]) end
if g5 ~= g3 and g5 == g6 and g5 == g2 then self:edit(i, j, nt["default".."3"]) end
-- Inner corners
if g5 ~= g7 and g5 ~= g4 and g5 ~= g8 then self:edit(i, j, nt["default".."7i"]) end
if g5 ~= g9 and g5 ~= g6 and g5 ~= g8 then self:edit(i, j, nt["default".."9i"]) end
if g5 ~= g1 and g5 ~= g4 and g5 ~= g2 then self:edit(i, j, nt["default".."1i"]) end
if g5 ~= g3 and g5 ~= g6 and g5 ~= g2 then self:edit(i, j, nt["default".."3i"]) end
end
function _M:editTileGrass(level, i, j, g, nt)
self:editTileGenericBorders(level, i, j, g, nt, "grass", {water=true})
end
-- This array is precomputed, it holds the possible combinations of walls and the nice tile they generate
-- The data is bit-encoded
local full_wall3d = {
......
......@@ -17,13 +17,32 @@
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
local grass_editer = { method="grass",
default8={add_mos={{image="terrain/grass/grass_2_%02d.png", display_y=-1}}, min=1, max=5},
default2={add_mos={{image="terrain/grass/grass_8_%02d.png", display_y=1}}, min=1, max=5},
default4={add_mos={{image="terrain/grass/grass_6_%02d.png", display_x=-1}}, min=1, max=5},
default6={add_mos={{image="terrain/grass/grass_4_%02d.png", display_x=1}}, min=1, max=4},
default1={add_mos={{image="terrain/grass/grass_9_%02d.png", display_x=-1, display_y=1}}, min=1, max=3},
default3={add_mos={{image="terrain/grass/grass_7_%02d.png", display_x=1, display_y=1}}, min=1, max=3},
default7={add_mos={{image="terrain/grass/grass_3_%02d.png", display_x=-1, display_y=-1}}, min=1, max=3},
default9={add_mos={{image="terrain/grass/grass_1_%02d.png", display_x=1, display_y=-1}}, min=1, max=3},
default1i={add_mos={{image="terrain/grass/grass_inner_1_%02d.png", display_x=-1, display_y=1}}, min=1, max=3},
default3i={add_mos={{image="terrain/grass/grass_inner_3_%02d.png", display_x=1, display_y=1}}, min=1, max=3},
default7i={add_mos={{image="terrain/grass/grass_inner_7_%02d.png", display_x=-1, display_y=-1}}, min=1, max=3},
default9i={add_mos={{image="terrain/grass/grass_inner_9_%02d.png", display_x=1, display_y=-1}}, min=1, max=3},
}
newEntity{
define_as = "GRASS",
type = "floor", subtype = "grass",
name = "grass", image = "terrain/grass.png",
display = '.', color=colors.LIGHT_GREEN, back_color={r=44,g=95,b=43},
grow = "TREE",
add_displays = {class.new{image="invis.png"}},
nice_tiler = { method="replace", base={"GRASS_PATCH", 70, 1, 15}},
nice_editer = grass_editer,
}
for i = 1, 12 do newEntity{ base = "GRASS", define_as = "GRASS_PATCH"..i, image = "terrain/grass"..(i<7 and "" or "2")..".png" } end
......@@ -39,6 +58,7 @@ newEntity{
block_sight = true,
dig = "GRASS",
nice_tiler = { method="replace", base={"TREE", 100, 1, 30}},
nice_editer = grass_editer,
}
for i = 1, 30 do newEntity{ base="TREE", define_as = "TREE"..i, image = "terrain/grass.png", add_displays = class:makeTrees("terrain/tree_alpha", 13, 9)} end
......@@ -53,49 +73,11 @@ newEntity{
block_sight = true,
block_sense = true,
block_esp = true,
nice_tiler = { method="replace", base={"HARDTREE", 100, 1, 30}},
nice_editer = grass_editer,
}
for i = 1, 30 do newEntity{ define_as = "HARDTREE"..i, image = "terrain/grass.png", add_displays = class:makeTrees("terrain/tree_alpha", 13, 9) } end
newEntity{
define_as = "GRASS_DARK1",
type = "floor", subtype = "grass",
name = "grass", image = "terrain/grass_dark1.png",
display = '.', color=colors.GREEN, back_color={r=44,g=95,b=43},
grow = "TREE_DARK",
}
for i = 1, 20 do
newEntity{
define_as = "TREE_DARK"..i,
type = "wall", subtype = "grass",
name = "tree", image = "terrain/grass_dark1.png",
force_clone = true,
add_displays = class:makeTrees("terrain/tree_dark_alpha"),
display = '#', color=colors.GREEN, back_color={r=44,g=95,b=43},
always_remember = true,
can_pass = {pass_tree=1},
does_block_move = true,
block_sight = true,
dig = "GRASS_DARK1",
}
end
for i = 1, 20 do
newEntity{
define_as = "HARDTREE_DARK"..i,
type = "wall", subtype = "grass",
name = "tall thick tree", image = "terrain/grass_dark1.png",
force_clone = true,
add_displays = class:makeTrees("terrain/tree_dark_alpha"),
display = '#', color=colors.GREEN, back_color={r=44,g=95,b=43},
always_remember = true,
does_block_move = true,
block_sight = true,
block_sense = true,
block_esp = true,
}
end
newEntity{
define_as = "FLOWER",
type = "floor", subtype = "grass",
......@@ -103,6 +85,7 @@ newEntity{
display = ';', color=colors.YELLOW, back_color={r=44,g=95,b=43},
grow = "TREE",
nice_tiler = { method="replace", base={"FLOWER", 100, 1, 1}},
nice_editer = grass_editer,
}
for i = 1, 1 do newEntity{ base = "FLOWER", define_as = "FLOWER"..i, image = "terrain/grass.png", add_mos = {{image = "terrain/flower0"..i..".png"}}} end
......@@ -119,21 +102,7 @@ newEntity{
door_player_check = "This rock is loose, you think you can move it away.",
door_opened = "GRASS",
dig = "GRASS",
}
newEntity{
define_as = "ROCK_VAULT_DARK",
type = "wall", subtype = "grass",
name = "huge loose rock", image = "terrain/grass.png", add_mos = {{image="terrain/huge_rock.png"}},
display = '+', color=colors.GREY, back_color={r=44,g=95,b=43},
notice = true,
always_remember = true,
block_sight = true,
block_sense = true,
block_esp = true,
door_player_check = "This rock is loose, you think you can move it away.",
door_opened = "GRASS_DARK1",
dig = "GRASS_DARK1",
nice_editer = grass_editer,
}
-----------------------------------------
......@@ -148,6 +117,7 @@ newEntity{
notice = true,
change_level = 1,
change_zone = "wilderness",
nice_editer = grass_editer,
}
newEntity{
......@@ -158,6 +128,7 @@ newEntity{
notice = true,
always_remember = true,
change_level = -1,
nice_editer = grass_editer,
}
newEntity{
define_as = "GRASS_UP2",
......@@ -167,6 +138,7 @@ newEntity{
notice = true,
always_remember = true,
change_level = -1,
nice_editer = grass_editer,
}
newEntity{
define_as = "GRASS_UP4",
......@@ -176,6 +148,7 @@ newEntity{
notice = true,
always_remember = true,
change_level = -1,
nice_editer = grass_editer,
}
newEntity{
define_as = "GRASS_UP6",
......@@ -185,6 +158,7 @@ newEntity{
notice = true,
always_remember = true,
change_level = -1,
nice_editer = grass_editer,
}
newEntity{
......@@ -195,6 +169,7 @@ newEntity{
notice = true,
always_remember = true,
change_level = 1,
nice_editer = grass_editer,
}
newEntity{
define_as = "GRASS_DOWN2",
......@@ -204,6 +179,7 @@ newEntity{
notice = true,
always_remember = true,
change_level = 1,
nice_editer = grass_editer,
}
newEntity{
define_as = "GRASS_DOWN4",
......@@ -213,6 +189,7 @@ newEntity{
notice = true,
always_remember = true,
change_level = 1,
nice_editer = grass_editer,
}
newEntity{
define_as = "GRASS_DOWN6",
......@@ -222,4 +199,5 @@ newEntity{
notice = true,
always_remember = true,
change_level = 1,
nice_editer = grass_editer,
}
......@@ -23,9 +23,6 @@ newEntity{
name = "sand", image = "terrain/sandfloor.png",
display = '.', color={r=203,g=189,b=72}, back_color={r=93,g=79,b=22},
grow = "SANDWALL_STABLE",
nice_tiler = { method="grassSand",
grass8={"SAND_GRASS_8", 100, 1, 1}, grass2={"SAND_GRASS_2", 100, 1, 1}, grass4={"SAND_GRASS_4", 100, 1, 1}, grass6={"SAND_GRASS_6", 100, 1, 1}, grass1={"SAND_GRASS_1", 100, 1, 1}, grass3={"SAND_GRASS_3", 100, 1, 1}, grass7={"SAND_GRASS_7", 100, 1, 1}, grass9={"SAND_GRASS_9", 100, 1, 1}, inner_grass1="SAND_GRASS_1I", inner_grass3="SAND_GRASS_3I", inner_grass7="SAND_GRASS_7I", inner_grass9="SAND_GRASS_9I",
},
}
newEntity{
......@@ -330,15 +327,3 @@ newEntity{
change_level = 1,
change_zone = "wilderness",
}
-----------------------------------------
-- Grass/sand
-----------------------------------------
for i = 1, 9 do for j = 1, 1 do
if i ~= 5 then newEntity{base="SAND", define_as = "SAND_GRASS_"..i..j, image="terrain/sand_grass_"..i.."_"..j..".png"} end
end end
newEntity{base="SAND", define_as = "SAND_GRASS_1I", image="terrain/sand_grass_1i_1.png"}
newEntity{base="SAND", define_as = "SAND_GRASS_3I", image="terrain/sand_grass_3i_1.png"}
newEntity{base="SAND", define_as = "SAND_GRASS_7I", image="terrain/sand_grass_7i_1.png"}
newEntity{base="SAND", define_as = "SAND_GRASS_9I", image="terrain/sand_grass_9i_1.png"}
......@@ -90,23 +90,10 @@ newEntity{
newEntity{ base="WATER_BASE",
define_as = "DEEP_WATER",
add_displays = class:makeWater(true),
nice_tiler = { method="water",
water="WATER_GRASS_5",
grass8={"WATER_GRASS_8", 100, 1, 2}, grass2={"WATER_GRASS_2", 100, 1, 2}, grass4={"WATER_GRASS_4", 100, 1, 2}, grass6={"WATER_GRASS_6", 100, 1, 2}, grass1={"WATER_GRASS_1", 100, 1, 2}, grass3={"WATER_GRASS_3", 100, 1, 2}, grass7={"WATER_GRASS_7", 100, 1, 2}, grass9={"WATER_GRASS_9", 100, 1, 2}, inner_grass1="WATER_GRASS_1I", inner_grass3="WATER_GRASS_3I", inner_grass7="WATER_GRASS_7I", inner_grass9="WATER_GRASS_9I",
sand8={"WATER_SAND_8", 100, 1, 1}, sand2={"WATER_SAND_2", 100, 1, 1}, sand4={"WATER_SAND_4", 100, 1, 1}, sand6={"WATER_SAND_6", 100, 1, 1}, sand1={"WATER_SAND_1", 100, 1, 1}, sand3={"WATER_SAND_3", 100, 1, 1}, sand7={"WATER_SAND_7", 100, 1, 1}, sand9={"WATER_SAND_9", 100, 1, 1}, inner_sand1="WATER_SAND_1I", inner_sand3="WATER_SAND_3I", inner_sand7="WATER_SAND_7I", inner_sand9="WATER_SAND_9I",
},
image="terrain/water_grass_5_1.png",
-- add_displays = class:makeWater(true),
}
newEntity{base="WATER_BASE", define_as = "WATER_GRASS_5", image="terrain/water_grass_5_1.png"}
for i = 1, 9 do for j = 1, 2 do
if i ~= 5 then newEntity{base="WATER_BASE", define_as = "WATER_GRASS_"..i..j, image="terrain/water_grass_"..i.."_"..j..".png"} end
end end
newEntity{base="WATER_BASE", define_as = "WATER_GRASS_1I", image="terrain/water_grass_1i_1.png"}
newEntity{base="WATER_BASE", define_as = "WATER_GRASS_3I", image="terrain/water_grass_3i_1.png"}
newEntity{base="WATER_BASE", define_as = "WATER_GRASS_7I", image="terrain/water_grass_7i_1.png"}
newEntity{base="WATER_BASE", define_as = "WATER_GRASS_9I", image="terrain/water_grass_9i_1.png"}
-----------------------------------------
-- Water(ocean)/grass
-----------------------------------------
......
game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_1_01.png

11 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_1_02.png

12 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_1_03.png

10.8 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_2_01.png

7.22 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_2_02.png

8.41 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_2_03.png

8.41 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_2_04.png

10.2 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_2_05.png

9.65 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_3_01.png

10.9 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_3_02.png

11.8 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_3_03.png

11 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_4_01.png

7.05 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_4_02.png

8.36 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_4_03.png

9.03 KiB

game/modules/tome/data/gfx/shockbolt/terrain/grass/grass_4_04.png

10.6 KiB

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