diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/AI/ActorAI.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/AI/ActorAI.class new file mode 100644 index 000000000..181602438 Binary files /dev/null and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/AI/ActorAI.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/AIControlled.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/AIControlled.class index 410ac4e2b..b8a774720 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/AIControlled.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/AIControlled.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/NPCIntelligentBase.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/NPCIntelligentBase.class index e557896f4..e8be17dee 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/NPCIntelligentBase.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/NPCIntelligentBase.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Game.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Game.class index aaf52e7a3..2d8a40a78 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Game.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Game.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapLantern.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapLantern.class index ca2dec3d0..98d6c49fe 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapLantern.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapLantern.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.class index cdf37ae70..eaeb09cef 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapCamera.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapCamera.class index 62846ee1a..2d9f26f09 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapCamera.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapCamera.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/TileProp.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/TileProp.class index 4b29fcf72..9b4e2bd9c 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/TileProp.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/TileProp.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/TilePropCodex.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/TilePropCodex.class index e075da801..81dc0ccf6 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/TilePropCodex.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/TilePropCodex.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/propdata.csv b/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/propdata.csv index 988a3c4e6..ca21bdb5e 100644 --- a/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/propdata.csv +++ b/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileProperties/propdata.csv @@ -1,46 +1,46 @@ - "id";"name" ;"opacity";"strength";"fluid";"viscosity";"solid";"wall";"lumcolor";"drop";"fall";"friction" -# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky | Opacity/Lumcolor: 40-step RGB - "0";"TILE_AIR" ; "1641"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "0";"16" - "1";"TILE_STONE" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "0"; "1"; "0";"16" - "2";"TILE_DIRT" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "2"; "0";"16" - "3";"TILE_GRASS" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "2"; "0";"16" - "4";"TILE_PLANK_NORMAL" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "4"; "0";"16" - "5";"TILE_PLANK_EBONY" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "5"; "0";"16" - "6";"TILE_PLANK_BIRCH" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "6"; "0";"16" - "7";"TILE_PLANK_BLOODROSE" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "7"; "0";"16" - "8";"TILE_TRUNK_NORMAL" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "8"; "0";"16" - "9";"TILE_TRUNK_EBONY" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "9"; "0";"16" - "10";"TILE_TRUNK_BIRCH" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "10"; "0";"16" - "11";"TILE_TRUNK_BLOODROSE" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "11"; "0";"16" - "12";"TILE_STONE_QUARRIED" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "0"; "12"; "0";"16" - "13";"TILE_SAND" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "13"; "1";"16" - "14";"TILE_GRAVEL" ; "8205"; "6"; "0"; "N/A"; "1"; "0"; "0"; "14"; "1";"16" + "id";"name" ;"opacity";"strength";"fluid";"viscosity";"solid";"wall";"lumcolor";"opaque";"drop";"fall";"friction" +# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky | Opacity/Lumcolor: 40-step RGB | Opaque: whether the tile completely hides wall behind + "0";"TILE_AIR" ; "1641"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "0"; "0";"16" + "1";"TILE_STONE" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "0"; "1"; "1"; "0";"16" + "2";"TILE_DIRT" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "1"; "2"; "0";"16" + "3";"TILE_GRASS" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "1"; "2"; "0";"16" + "4";"TILE_PLANK_NORMAL" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "1"; "4"; "0";"16" + "5";"TILE_PLANK_EBONY" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "1"; "5"; "0";"16" + "6";"TILE_PLANK_BIRCH" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "1"; "6"; "0";"16" + "7";"TILE_PLANK_BLOODROSE" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "1"; "7"; "0";"16" + "8";"TILE_TRUNK_NORMAL" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "1"; "8"; "0";"16" + "9";"TILE_TRUNK_EBONY" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "1"; "9"; "0";"16" + "10";"TILE_TRUNK_BIRCH" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "1"; "10"; "0";"16" + "11";"TILE_TRUNK_BLOODROSE" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "1"; "11"; "0";"16" + "12";"TILE_STONE_QUARRIED" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "0"; "1"; "12"; "0";"16" + "13";"TILE_SAND" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "1"; "13"; "1";"16" + "14";"TILE_GRAVEL" ; "8205"; "6"; "0"; "N/A"; "1"; "0"; "0"; "1"; "14"; "1";"16" - "15";"TILE_ORE_MALACHITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "15"; "0";"16" - "16";"TILE_ORE_HEMATITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "16"; "0";"16" - "17";"TILE_ORE_NATURAL_GOLD" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "17"; "0";"16" - "18";"TILE_ORE_NATURAL_SILVER" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "18"; "0";"16" - "19";"TILE_ORE_RUTILE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "19"; "0";"16" - "20";"TILE_ORE_AURICHALCUMITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "20"; "0";"16" - "21";"TILE_GEM_RUBY" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "21"; "0";"16" - "22";"TILE_GEM_EMERALD" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "22"; "0";"16" - "23";"TILE_GEM_SAPPHIRE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "23"; "0";"16" - "24";"TILE_GEM_TOPAZ" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "24"; "0";"16" - "25";"TILE_GEM_DIAMOND" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "25"; "0";"16" - "26";"TILE_GEM_AMETHYST" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "26"; "0";"16" + "15";"TILE_ORE_MALACHITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "15"; "0";"16" + "16";"TILE_ORE_HEMATITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "16"; "0";"16" + "17";"TILE_ORE_NATURAL_GOLD" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "17"; "0";"16" + "18";"TILE_ORE_NATURAL_SILVER" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "18"; "0";"16" + "19";"TILE_ORE_RUTILE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "19"; "0";"16" + "20";"TILE_ORE_AURICHALCUMITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "20"; "0";"16" + "21";"TILE_GEM_RUBY" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "21"; "0";"16" + "22";"TILE_GEM_EMERALD" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "22"; "0";"16" + "23";"TILE_GEM_SAPPHIRE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "23"; "0";"16" + "24";"TILE_GEM_TOPAZ" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "24"; "0";"16" + "25";"TILE_GEM_DIAMOND" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "25"; "0";"16" + "26";"TILE_GEM_AMETHYST" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "26"; "0";"16" - "27";"TILE_SNOW" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "27"; "0";"16" - "28";"TILE_ICE_FRAGILE" ; "3282"; "1"; "0"; "N/A"; "1"; "0"; "0"; "28"; "0";"16" - "29";"TILE_ICE_NATURAL" ; "6564"; "25"; "0"; "N/A"; "1"; "1"; "0"; "29"; "0"; "8" - "30";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "5009"; "30"; "0"; "8" + "27";"TILE_SNOW" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "1"; "27"; "0";"16" + "28";"TILE_ICE_FRAGILE" ; "3282"; "1"; "0"; "N/A"; "1"; "0"; "0"; "0"; "28"; "0";"16" + "29";"TILE_ICE_NATURAL" ; "6564"; "25"; "0"; "N/A"; "1"; "1"; "0"; "1"; "29"; "0"; "8" + "30";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "5009"; "0"; "30"; "0"; "8" # see scandinavian name set female of this tile id! - "31";"TILE_PLATFORM_STONE" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "31"; "0";"16" - "32";"TILE_PLATFORM_WOODEN" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "32"; "0";"16" - "33";"TILE_PLATFORM_EBONY" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "33"; "0";"16" - "34";"TILE_PLATFORM_BIRCH" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "34"; "0";"16" - "35";"TILE_PLATFORM_BLOODROSE" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "35"; "0";"16" + "31";"TILE_PLATFORM_STONE" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "31"; "0";"16" + "32";"TILE_PLATFORM_WOODEN" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "32"; "0";"16" + "33";"TILE_PLATFORM_EBONY" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "33"; "0";"16" + "34";"TILE_PLATFORM_BIRCH" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "34"; "0";"16" + "35";"TILE_PLATFORM_BLOODROSE" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "35"; "0";"16" - "36";"TILE_TORCH" ; "0"; "0"; "0"; "N/A"; "0"; "0";"63412"; "36"; "0";"16" + "36";"TILE_TORCH" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "63412"; "0"; "36"; "0";"16" # 63412 (ffa44e) : real candlelight colour taken from properly configured camera. -"239";"TILE_WATER" ; "6522"; "100"; "1"; "2"; "0"; "0"; "0"; "239"; "0";"16" -"255";"TILE_LAVA" ; "62358"; "100"; "1"; "2"; "0"; "0";"48320"; "239"; "0";"16" +"239";"TILE_WATER" ; "6522"; "100"; "1"; "2"; "0"; "0"; "0"; "0"; "239"; "0";"16" +"255";"TILE_LAVA" ; "62358"; "100"; "1"; "2"; "0"; "0"; "48320"; "0"; "239"; "0";"16" diff --git a/res/graphics/sprites/test_player.png b/res/graphics/sprites/test_player.png index e50d61a9a..c2e35e191 100644 Binary files a/res/graphics/sprites/test_player.png and b/res/graphics/sprites/test_player.png differ diff --git a/src/com/Torvald/Terrarum/Actors/AI/ActorAI.java b/src/com/Torvald/Terrarum/Actors/AI/ActorAI.java new file mode 100644 index 000000000..a9fed8b0d --- /dev/null +++ b/src/com/Torvald/Terrarum/Actors/AI/ActorAI.java @@ -0,0 +1,7 @@ +package com.Torvald.Terrarum.Actors.AI; + +/** + * Created by minjaesong on 16-03-02. + */ +public interface ActorAI { +} diff --git a/src/com/Torvald/Terrarum/Actors/AIControlled.java b/src/com/Torvald/Terrarum/Actors/AIControlled.java index af4c2a575..aeda95cc8 100644 --- a/src/com/Torvald/Terrarum/Actors/AIControlled.java +++ b/src/com/Torvald/Terrarum/Actors/AIControlled.java @@ -1,10 +1,12 @@ package com.Torvald.Terrarum.Actors; +import com.Torvald.Terrarum.Actors.AI.ActorAI; + /** * Created by minjaesong on 16-01-31. */ public interface AIControlled { - void attachAI(); + void attachAI(ActorAI ai); } diff --git a/src/com/Torvald/Terrarum/Actors/NPCIntelligentBase.java b/src/com/Torvald/Terrarum/Actors/NPCIntelligentBase.java index 9b35bc87b..9d597c374 100644 --- a/src/com/Torvald/Terrarum/Actors/NPCIntelligentBase.java +++ b/src/com/Torvald/Terrarum/Actors/NPCIntelligentBase.java @@ -1,5 +1,6 @@ package com.Torvald.Terrarum.Actors; +import com.Torvald.Terrarum.Actors.AI.ActorAI; import com.Torvald.Terrarum.Actors.Faction.Faction; import com.Torvald.Terrarum.GameItem.InventoryItem; import com.Torvald.Terrarum.Terrarum; @@ -14,19 +15,18 @@ import java.util.HashSet; public class NPCIntelligentBase extends ActorWithBody implements AIControlled, Pocketed, CanBeStoredAsItem, Factionable, Landholder { - private InventoryItem itemData; - // private ActorAI ai; + private InventoryItem itemData; // keep it for extendibility, like Carriers in SC1 + private ActorAI ai; private ActorInventory inventory; private HashSet factionSet = new HashSet<>(); + /** + * Absolute tile index. index(x, y) = y * map.width + x
+ * The arraylist will be saved in JSON format with GSON. + */ private ArrayList houseTiles = new ArrayList<>(); - @Override - public void attachAI() { - - } - @Override public void assignFaction(Faction f) { factionSet.add(f); @@ -143,4 +143,9 @@ public class NPCIntelligentBase extends ActorWithBody implements AIControlled, P public void overwriteInventory(ActorInventory inventory) { this.inventory = inventory; } + + @Override + public void attachAI(ActorAI ai) { + this.ai = ai; + } } diff --git a/src/com/Torvald/Terrarum/Game.java b/src/com/Torvald/Terrarum/Game.java index 55a02232d..d3e858eeb 100644 --- a/src/com/Torvald/Terrarum/Game.java +++ b/src/com/Torvald/Terrarum/Game.java @@ -156,7 +156,7 @@ public class Game extends BasicGameState { } } ); - + MapDrawer.update(gc, delta_t); MapCamera.update(gc, delta_t); diff --git a/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.java b/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.java index 958d8b68f..b2dae6e75 100644 --- a/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.java +++ b/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.java @@ -108,33 +108,35 @@ public class LightmapRenderer { //System.out.println(for_x_start); //System.out.println(for_x_end); - for (int y = for_y_start; y < for_y_end; y++) { - for (int x = for_x_start; x < for_x_end; x++) { - staticLightMap[y][x] = calculate(x, y); + try { + for (int y = for_y_start; y < for_y_end; y++) { + for (int x = for_x_start; x < for_x_end; x++) { + staticLightMap[y][x] = calculate(x, y); + } + } + + // Round 4 + for (int y = for_y_end - 1; y > for_y_start; y--) { + for (int x = for_x_start; x < for_x_end; x++) { + staticLightMap[y][x] = calculate(x, y); + } + } + + // Round 3 + for (int y = for_y_end - 1; y > for_y_start; y--) { + for (int x = for_x_end - 1; x >= for_x_start; x--) { + staticLightMap[y][x] = calculate(x, y); + } + } + + // Round 2 + for (int y = for_y_start; y < for_y_end; y++) { + for (int x = for_x_end - 1; x >= for_x_start; x--) { + staticLightMap[y][x] = calculate(x, y); + } } } - - // Round 4 - for (int y = for_y_end - 1; y > for_y_start; y--) { - for (int x = for_x_start; x < for_x_end; x++) { - staticLightMap[y][x] = calculate(x, y); - } - } - - // Round 3 - for (int y = for_y_end - 1; y > for_y_start; y--) { - for (int x = for_x_end - 1; x >= for_x_start; x--) { - staticLightMap[y][x] = calculate(x, y); - } - } - - // Round 2 - for (int y = for_y_start; y < for_y_end; y++) { - for (int x = for_x_end - 1; x >= for_x_start; x--) { - staticLightMap[y][x] = calculate(x, y); - } - } - + catch (ArrayIndexOutOfBoundsException e) {} } public static void draw(Graphics g) { @@ -256,94 +258,88 @@ public class LightmapRenderer { } private static char calculate(int x, int y){ - if (!outOfBounds(x, y)){ + char lightLevelThis = 0; + int thisTerrain = Terrarum.game.map.getTileFromTerrain(x, y); + int thisWall = Terrarum.game.map.getTileFromWall(x, y); + char thisTileLuminosity = TilePropCodex.getProp(thisTerrain).getLuminosity(); + char thisTileOpacity = TilePropCodex.getProp(thisTerrain).getOpacity(); + char sunLight = Terrarum.game.map.getGlobalLight(); - char lightLevelThis = 0; - int thisTerrain = Terrarum.game.map.getTileFromTerrain(x, y); - int thisWall = Terrarum.game.map.getTileFromWall(x, y); - char thisTileLuminosity = TilePropCodex.getProp(thisTerrain).getLuminosity(); - char thisTileOpacity = TilePropCodex.getProp(thisTerrain).getOpacity(); - char sunLight = Terrarum.game.map.getGlobalLight(); - - // MIX TILE - // open air - if (thisTerrain == AIR && thisWall == AIR) { - lightLevelThis = sunLight; - } - // luminous tile transparent (allows sunlight to pass) - else if (thisWall == AIR && thisTileLuminosity > 0) { - char darkenSunlight = darkenColoured(sunLight, thisTileOpacity); - lightLevelThis = screenBlend(darkenSunlight, thisTileLuminosity); - } - // luminous tile (opaque) - else if (thisWall != AIR && thisTileLuminosity > 0) { - lightLevelThis = thisTileLuminosity; - } - // END MIX TILE - - // mix lantern - for (LightmapLantern lantern : lanterns) { - if (lantern.getX() == x && lantern.getY() == y) { - lightLevelThis = screenBlend(lightLevelThis, lantern.getIntensity()); - break; - } - } - - // mix luminous actor - // test player TODO for all actor.Luminous in the game - int tileX = Math.round(Terrarum.game.getPlayer().getHitbox().getPointedX() / TSIZE); - int tileY = Math.round(Terrarum.game.getPlayer().getHitbox().getPointedY() / TSIZE) - - 1; - char actorLuminosity = Terrarum.game.getPlayer().getLuminance(); - if (x == tileX && y == tileY) { - lightLevelThis = screenBlend(lightLevelThis, actorLuminosity); - } - - - // calculate ambient - char ambient = 0; char nearby = 0; - findNearbyBrightest: - for (int yoff = -1; yoff <= 1; yoff++) { - for (int xoff = -1; xoff <= 1; xoff++) { - /** - * filter for 'v's as: - * +-+-+-+ - * |a|v|a| - * +-+-+-+ - * |v| |v| - * +-+-+-+ - * |a|v|a| - * +-+-+-+ - */ - if (xoff != yoff && -xoff != yoff) { // 'v' tiles - if (!outOfMapBounds(x + xoff, y + yoff)) { - nearby = staticLightMap[y + yoff][x + xoff]; - } - } - else if (xoff != 0 && yoff != 0) { // 'a' tiles - if (!outOfMapBounds(x + xoff, y + yoff)) { - nearby = darkenUniformInt(staticLightMap[y + yoff][x + xoff] - , 2); //2 - // mix some to have more 'spreading' - // so that light spreads in a shape of an octagon instead of a diamond - } - } - else { - nearby = 0; // exclude 'me' tile - } - - ambient = maximiseRGB(ambient, nearby); // keep base value as brightest nearby - } - } - - ambient = darkenColoured(ambient, thisTileOpacity); // get real ambient by appling opacity value - - // mix and return lightlevel and ambient - return maximiseRGB(lightLevelThis, ambient); + // MIX TILE + // open air + if (thisTerrain == AIR && thisWall == AIR) { + lightLevelThis = sunLight; } - else { - throw new IllegalArgumentException("Out of bounds of lightMap"); + // luminous tile transparent (allows sunlight to pass) + else if (thisWall == AIR && thisTileLuminosity > 0) { + char darkenSunlight = darkenColoured(sunLight, thisTileOpacity); + lightLevelThis = screenBlend(darkenSunlight, thisTileLuminosity); } + // luminous tile (opaque) + else if (thisWall != AIR && thisTileLuminosity > 0) { + lightLevelThis = thisTileLuminosity; + } + // END MIX TILE + + // mix lantern + for (LightmapLantern lantern : lanterns) { + if (lantern.getX() == x && lantern.getY() == y) { + lightLevelThis = screenBlend(lightLevelThis, lantern.getIntensity()); + break; + } + } + + // mix luminous actor + // test player TODO for all actor.Luminous in the game + int tileX = Math.round(Terrarum.game.getPlayer().getHitbox().getPointedX() / TSIZE); + int tileY = Math.round(Terrarum.game.getPlayer().getHitbox().getPointedY() / TSIZE) + - 1; + char actorLuminosity = Terrarum.game.getPlayer().getLuminance(); + if (x == tileX && y == tileY) { + lightLevelThis = screenBlend(lightLevelThis, actorLuminosity); + } + + + // calculate ambient + char ambient = 0; char nearby = 0; + findNearbyBrightest: + for (int yoff = -1; yoff <= 1; yoff++) { + for (int xoff = -1; xoff <= 1; xoff++) { + /** + * filter for 'v's as: + * +-+-+-+ + * |a|v|a| + * +-+-+-+ + * |v| |v| + * +-+-+-+ + * |a|v|a| + * +-+-+-+ + */ + if (xoff != yoff && -xoff != yoff) { // 'v' tiles + if (!outOfMapBounds(x + xoff, y + yoff)) { + nearby = staticLightMap[y + yoff][x + xoff]; + } + } + else if (xoff != 0 && yoff != 0) { // 'a' tiles + if (!outOfMapBounds(x + xoff, y + yoff)) { + nearby = darkenUniformInt(staticLightMap[y + yoff][x + xoff] + , 2); //2 + // mix some to have more 'spreading' + // so that light spreads in a shape of an octagon instead of a diamond + } + } + else { + nearby = 0; // exclude 'me' tile + } + + ambient = maximiseRGB(ambient, nearby); // keep base value as brightest nearby + } + } + + ambient = darkenColoured(ambient, thisTileOpacity); // get real ambient by appling opacity value + + // mix and return lightlevel and ambient + return maximiseRGB(lightLevelThis, ambient); } /** diff --git a/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java b/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java index 638ebab33..2ce042e5c 100644 --- a/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java +++ b/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java @@ -4,6 +4,7 @@ import com.Torvald.Terrarum.*; import com.Torvald.Terrarum.Actors.Player; import com.Torvald.Terrarum.GameMap.GameMap; import com.Torvald.Terrarum.GameMap.MapLayer; +import com.Torvald.Terrarum.TileProperties.TilePropCodex; import com.jme3.math.FastMath; import org.lwjgl.opengl.GL11; import org.newdawn.slick.*; @@ -398,7 +399,7 @@ public class MapCamera { } private static boolean isOpaque(int x) { - return !(x == GRASS || x == AIR); + return TilePropCodex.getProp(x).isOpaque(); } public static int getCameraX() { diff --git a/src/com/Torvald/Terrarum/TileProperties/TileProp.java b/src/com/Torvald/Terrarum/TileProperties/TileProp.java index 14207596b..aabe80637 100644 --- a/src/com/Torvald/Terrarum/TileProperties/TileProp.java +++ b/src/com/Torvald/Terrarum/TileProperties/TileProp.java @@ -8,7 +8,7 @@ public class TileProp { private int id; private String name; - private char opacity; + private char opacity; // colour attenuation private int strength; @@ -19,6 +19,8 @@ public class TileProp { private boolean wallable; + private boolean opaque; // hides wall or not + private char luminosity; private int drop; @@ -129,4 +131,12 @@ public class TileProp { void setFriction(int friction) { this.friction = friction; } + + public boolean isOpaque() { + return opaque; + } + + public void setOpaque(boolean opaque) { + this.opaque = opaque; + } } diff --git a/src/com/Torvald/Terrarum/TileProperties/TilePropCodex.java b/src/com/Torvald/Terrarum/TileProperties/TilePropCodex.java index 4061ef708..fb2e73f35 100644 --- a/src/com/Torvald/Terrarum/TileProperties/TilePropCodex.java +++ b/src/com/Torvald/Terrarum/TileProperties/TilePropCodex.java @@ -66,8 +66,9 @@ public class TilePropCodex { prop.setSolid(boolVal(record, "solid")); prop.setWallable(boolVal(record, "wall")); prop.setFallable(boolVal(record, "fall")); + prop.setOpaque(boolVal(record, "opaque")); - if (prop.isFluid()) prop.setViscocity(intVal(record, "opacity")); + if (prop.isFluid()) prop.setViscocity(intVal(record, "viscosity")); System.out.print(prop.getId()); System.out.println("\t" + prop.getName()); diff --git a/src/com/Torvald/Terrarum/TileProperties/propdata.csv b/src/com/Torvald/Terrarum/TileProperties/propdata.csv index 988a3c4e6..246027201 100644 --- a/src/com/Torvald/Terrarum/TileProperties/propdata.csv +++ b/src/com/Torvald/Terrarum/TileProperties/propdata.csv @@ -1,46 +1,49 @@ - "id";"name" ;"opacity";"strength";"fluid";"viscosity";"solid";"wall";"lumcolor";"drop";"fall";"friction" -# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky | Opacity/Lumcolor: 40-step RGB - "0";"TILE_AIR" ; "1641"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "0";"16" - "1";"TILE_STONE" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "0"; "1"; "0";"16" - "2";"TILE_DIRT" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "2"; "0";"16" - "3";"TILE_GRASS" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "2"; "0";"16" - "4";"TILE_PLANK_NORMAL" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "4"; "0";"16" - "5";"TILE_PLANK_EBONY" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "5"; "0";"16" - "6";"TILE_PLANK_BIRCH" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "6"; "0";"16" - "7";"TILE_PLANK_BLOODROSE" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "7"; "0";"16" - "8";"TILE_TRUNK_NORMAL" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "8"; "0";"16" - "9";"TILE_TRUNK_EBONY" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "9"; "0";"16" - "10";"TILE_TRUNK_BIRCH" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "10"; "0";"16" - "11";"TILE_TRUNK_BLOODROSE" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "11"; "0";"16" - "12";"TILE_STONE_QUARRIED" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "0"; "12"; "0";"16" - "13";"TILE_SAND" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "13"; "1";"16" - "14";"TILE_GRAVEL" ; "8205"; "6"; "0"; "N/A"; "1"; "0"; "0"; "14"; "1";"16" + "id";"name" ;"opacity";"strength";"fluid";"viscosity";"solid";"wall";"lumcolor";"opaque";"drop";"fall";"friction" + "0";"TILE_AIR" ; "1641"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0";"16" + "1";"TILE_STONE" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "1"; "0";"16" + "2";"TILE_DIRT" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "0";"16" + "3";"TILE_GRASS" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "0";"16" + "4";"TILE_PLANK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "4"; "0";"16" + "5";"TILE_PLANK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "0";"16" + "6";"TILE_PLANK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "6"; "0";"16" + "7";"TILE_PLANK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "7"; "0";"16" + "8";"TILE_TRUNK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "0";"16" + "9";"TILE_TRUNK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "9"; "0";"16" + "10";"TILE_TRUNK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "10"; "0";"16" + "11";"TILE_TRUNK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "11"; "0";"16" + "12";"TILE_STONE_QUARRIED" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "12"; "0";"16" + "13";"TILE_SAND" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "13"; "1";"16" + "14";"TILE_GRAVEL" ; "8205"; "6"; "0"; "0"; "1"; "0"; "0"; "1"; "14"; "1";"16" - "15";"TILE_ORE_MALACHITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "15"; "0";"16" - "16";"TILE_ORE_HEMATITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "16"; "0";"16" - "17";"TILE_ORE_NATURAL_GOLD" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "17"; "0";"16" - "18";"TILE_ORE_NATURAL_SILVER" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "18"; "0";"16" - "19";"TILE_ORE_RUTILE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "19"; "0";"16" - "20";"TILE_ORE_AURICHALCUMITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "20"; "0";"16" - "21";"TILE_GEM_RUBY" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "21"; "0";"16" - "22";"TILE_GEM_EMERALD" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "22"; "0";"16" - "23";"TILE_GEM_SAPPHIRE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "23"; "0";"16" - "24";"TILE_GEM_TOPAZ" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "24"; "0";"16" - "25";"TILE_GEM_DIAMOND" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "25"; "0";"16" - "26";"TILE_GEM_AMETHYST" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "26"; "0";"16" + "15";"TILE_ORE_MALACHITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "15"; "0";"16" + "16";"TILE_ORE_HEMATITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "16"; "0";"16" + "17";"TILE_ORE_NATURAL_GOLD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "17"; "0";"16" + "18";"TILE_ORE_NATURAL_SILVER" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "18"; "0";"16" + "19";"TILE_ORE_RUTILE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "19"; "0";"16" + "20";"TILE_ORE_AURICHALCUMITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "20"; "0";"16" + "21";"TILE_GEM_RUBY" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "21"; "0";"16" + "22";"TILE_GEM_EMERALD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "22"; "0";"16" + "23";"TILE_GEM_SAPPHIRE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "23"; "0";"16" + "24";"TILE_GEM_TOPAZ" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "24"; "0";"16" + "25";"TILE_GEM_DIAMOND" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "25"; "0";"16" + "26";"TILE_GEM_AMETHYST" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "26"; "0";"16" - "27";"TILE_SNOW" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "27"; "0";"16" - "28";"TILE_ICE_FRAGILE" ; "3282"; "1"; "0"; "N/A"; "1"; "0"; "0"; "28"; "0";"16" - "29";"TILE_ICE_NATURAL" ; "6564"; "25"; "0"; "N/A"; "1"; "1"; "0"; "29"; "0"; "8" - "30";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "5009"; "30"; "0"; "8" + "27";"TILE_SNOW" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "27"; "0";"16" + "28";"TILE_ICE_FRAGILE" ; "3282"; "1"; "0"; "0"; "1"; "0"; "0"; "0"; "28"; "0";"16" + "29";"TILE_ICE_NATURAL" ; "6564"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "29"; "0"; "8" + "30";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "0"; "1"; "1"; "5009"; "0"; "30"; "0"; "8" # see scandinavian name set female of this tile id! - "31";"TILE_PLATFORM_STONE" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "31"; "0";"16" - "32";"TILE_PLATFORM_WOODEN" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "32"; "0";"16" - "33";"TILE_PLATFORM_EBONY" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "33"; "0";"16" - "34";"TILE_PLATFORM_BIRCH" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "34"; "0";"16" - "35";"TILE_PLATFORM_BLOODROSE" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "35"; "0";"16" + "31";"TILE_PLATFORM_STONE" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "31"; "0";"16" + "32";"TILE_PLATFORM_WOODEN" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "32"; "0";"16" + "33";"TILE_PLATFORM_EBONY" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "33"; "0";"16" + "34";"TILE_PLATFORM_BIRCH" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "34"; "0";"16" + "35";"TILE_PLATFORM_BLOODROSE" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "35"; "0";"16" - "36";"TILE_TORCH" ; "0"; "0"; "0"; "N/A"; "0"; "0";"63412"; "36"; "0";"16" + "36";"TILE_TORCH" ; "0"; "0"; "0"; "0"; "0"; "0"; "63412"; "0"; "36"; "0";"16" # 63412 (ffa44e) : real candlelight colour taken from properly configured camera. -"239";"TILE_WATER" ; "6522"; "100"; "1"; "2"; "0"; "0"; "0"; "239"; "0";"16" -"255";"TILE_LAVA" ; "62358"; "100"; "1"; "2"; "0"; "0";"48320"; "239"; "0";"16" +"239";"TILE_WATER" ; "6522"; "100"; "1"; "16"; "0"; "0"; "0"; "0"; "239"; "0";"16" +"255";"TILE_LAVA" ; "62358"; "100"; "1"; "16"; "0"; "0"; "48320"; "0"; "239"; "0";"16" +# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky +# Opacity/Lumcolor: 40-step RGB +# Opaque: whether the tile completely hides wall behind +# Viscosity: (walkspeedmax) * (1 + (n/16)) \ No newline at end of file diff --git a/work_files/Tools/b24_col_to_40step_col.py b/work_files/Tools/b24_col_to_40step_col.py index bc46bf745..223c58f5f 100644 --- a/work_files/Tools/b24_col_to_40step_col.py +++ b/work_files/Tools/b24_col_to_40step_col.py @@ -34,3 +34,4 @@ def colFromNum(raw): print(colFromNum(9979)) print(intFromRGB24(255, 164, 78)) +print(intFromCol(6, 10, 18))