diff --git a/out/production/Terrarum_renewed/com/Torvald/JsonGetter.class b/out/production/Terrarum_renewed/com/Torvald/JsonGetter.class new file mode 100644 index 000000000..5eb8b8a14 Binary files /dev/null and b/out/production/Terrarum_renewed/com/Torvald/JsonGetter.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/ActorWithBody.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/ActorWithBody.class index 5312491eb..263b9ac98 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/ActorWithBody.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/ActorWithBody.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/CreatureBuildFactory.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/CreatureBuildFactory.class index d28829271..69ebefc8a 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/CreatureBuildFactory.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/CreatureBuildFactory.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Faction/Faction.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Faction/Faction.class new file mode 100644 index 000000000..246529eaa Binary files /dev/null and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Faction/Faction.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Faction/FactionRelatorFactory.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Faction/FactionRelatorFactory.class new file mode 100644 index 000000000..79af8dc57 Binary files /dev/null and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Faction/FactionRelatorFactory.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Factionable.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Factionable.class new file mode 100644 index 000000000..c14e9f842 Binary files /dev/null and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Factionable.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/PBFSigrid.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/PBFSigrid.class index 46d4703b6..d91a30f10 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/PBFSigrid.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/PBFSigrid.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Player.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Player.class index e06bea4f3..d92925c4a 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Player.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Player.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/TestNPC$1.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/TestNPC$1.class index 41f3c681a..43d0dd135 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/TestNPC$1.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/TestNPC$1.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/TestNPC.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/TestNPC.class index f218c038f..f6f933136 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/TestNPC.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/TestNPC.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/GetAV.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/GetAV.class index ac5b9f356..c82979dcc 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/GetAV.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/GetAV.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetAV.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetAV.class index e3b3041de..51d08e613 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetAV.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetAV.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/GameMap/GameMap.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/GameMap/GameMap.class index e3df3243c..3370e940e 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/GameMap/GameMap.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/GameMap/GameMap.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 4ba8c6ee9..8b4524edd 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/MapGenerator/MapGenerator.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapGenerator/MapGenerator.class index 94f4f2c18..e49656468 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapGenerator/MapGenerator.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapGenerator/MapGenerator.class differ diff --git a/res/graphics/terrain/terrain.png b/res/graphics/terrain/terrain.png old mode 100755 new mode 100644 index 07c70a886..7b8b89233 Binary files a/res/graphics/terrain/terrain.png and b/res/graphics/terrain/terrain.png differ diff --git a/res/graphics/terrain/terrain_4.png b/res/graphics/terrain/terrain_4.png deleted file mode 100644 index 43a2b3f28..000000000 Binary files a/res/graphics/terrain/terrain_4.png and /dev/null differ diff --git a/res/graphics/terrain/terrain_8.png b/res/graphics/terrain/terrain_8.png deleted file mode 100755 index fdcc3f9b3..000000000 Binary files a/res/graphics/terrain/terrain_8.png and /dev/null differ diff --git a/res/graphics/terrain/terrain_old.png b/res/graphics/terrain/terrain_old.png new file mode 100755 index 000000000..07c70a886 Binary files /dev/null and b/res/graphics/terrain/terrain_old.png differ diff --git a/res/graphics/terrain/terrainplusplus.png b/res/graphics/terrain/terrainplusplus.png deleted file mode 100644 index 7b8b89233..000000000 Binary files a/res/graphics/terrain/terrainplusplus.png and /dev/null differ diff --git a/res/graphics/terrain/wall.png b/res/graphics/terrain/wall.png old mode 100755 new mode 100644 index 3881823a8..5c0c507fe Binary files a/res/graphics/terrain/wall.png and b/res/graphics/terrain/wall.png differ diff --git a/res/graphics/terrain/wall_4.png b/res/graphics/terrain/wall_4.png deleted file mode 100644 index 39438bf04..000000000 Binary files a/res/graphics/terrain/wall_4.png and /dev/null differ diff --git a/res/graphics/terrain/wall_8.png b/res/graphics/terrain/wall_8.png deleted file mode 100644 index 14afceff7..000000000 Binary files a/res/graphics/terrain/wall_8.png and /dev/null differ diff --git a/res/graphics/terrain/wall_old.png b/res/graphics/terrain/wall_old.png new file mode 100755 index 000000000..3881823a8 Binary files /dev/null and b/res/graphics/terrain/wall_old.png differ diff --git a/res/raw/CreatureHuman.json b/res/raw/CreatureHuman.json index ee06e0c89..faea38224 100644 --- a/res/raw/CreatureHuman.json +++ b/res/raw/CreatureHuman.json @@ -4,15 +4,15 @@ "baseheight" : 40, "basemass" : 60.0, - "toolsize" : 15, - "strength" : 1000, "strengthvariable" : [100,100,100,100,100,100,100], + "accel" : 0.2, + "speed" : 3.0, "speedvariable" : [100,100,100,100,100,100,100], - "jumppower" : 6.0, + "jumppower" : 5.5, "jumppowervariable" : [100,100,100,100,100,100,100], "scale" : 1, @@ -21,10 +21,12 @@ "speed" : 2.0, "speedvariable" : [100,100,100,100,100,100,100], - "jump" : 5.5, - "jumpvariable" : [100,100,100,100,100,100,100], + "physiquemult" : [100,100,100,100,100,100,100], "encumbrance" : 1000, - "basedefence" : "work in progress" + "basedefence" : "work in progress", + + "toolsize" : 15, + "intelligent" : true } \ No newline at end of file diff --git a/res/raw/FactionGenericPlayer.json b/res/raw/FactionGenericPlayer.json new file mode 100644 index 000000000..00642bfdf --- /dev/null +++ b/res/raw/FactionGenericPlayer.json @@ -0,0 +1,8 @@ +{ + "factionname" : "player", + + "factionamicable" : ["follower"], + "factionneutral" : [], + "factionhostile" : ["wildlifehostile"], + "factionfearful" : ["wildlifeflee"] +} \ No newline at end of file diff --git a/res/raw/FactionSigrid.json b/res/raw/FactionSigrid.json index 12b9fcbac..6b6b8a4e9 100644 --- a/res/raw/FactionSigrid.json +++ b/res/raw/FactionSigrid.json @@ -2,7 +2,7 @@ "factionname" : "sigrid", "factionamicable" : ["follower"], - "factionneutral" : ["controlledvillager"], + "factionneutral" : ["controlledvillager", "wildhamletcontroller"], "factionhostile" : ["wildlifehostile"], - "factionfearful" : ["peasant", "wildlifeflee"] + "factionfearful" : ["wildhamletvillager", "wildlifeflee"] } \ No newline at end of file diff --git a/res/raw/Faction_doc.txt b/res/raw/Faction_doc.txt new file mode 100644 index 000000000..43c3945b6 --- /dev/null +++ b/res/raw/Faction_doc.txt @@ -0,0 +1,35 @@ +{ + "factionname" : "player", + + "factionamicable" : ["follower"], + "factionneutral" : [], + "factionhostile" : ["wildlifehostile"], + "factionfearful" : ["wildlifeflee"] +} + +factionname : Identifier of the faction data + +factionamicable : Amicable faction. Players can give/take items of actors of this faction, in plus + to the ability of trading. Assigned actors (usually follower) will follow players + in game. + +factionneutral : Explicit neutrality. If the assigned actor is intelligent (NPC AV), players can + trade with them. Unassigned faction will be treated like neutral, but players can + not make any trade with them. + +factionhostile : Assigned faction will attack players on the sight. e.g. 'wildlifehostile' + +factionfearful : Assigned faction will flee from players on the sight. e.g. 'wildlifeflee' + + + + +== Generic faction information == + +* player : Self-explanatory +* follower : Self-explanatory +* controlledvillager : Villagers of your hamlet +* wildlifehostile : Hostile mobs, self-explanatory +* wildlifeflee : Fleeing mobs, self-explanatory +* wildhamletvillager : Generic villager of the pre-generated hamlets. +* wildhamletcontroller : Ruler of the pre-generated hamlets. diff --git a/src/com/Torvald/Terrarum/Actors/ActorWithBody.java b/src/com/Torvald/Terrarum/Actors/ActorWithBody.java index 52dcf9a85..72c9f6821 100644 --- a/src/com/Torvald/Terrarum/Actors/ActorWithBody.java +++ b/src/com/Torvald/Terrarum/Actors/ActorWithBody.java @@ -158,24 +158,16 @@ public class ActorWithBody implements Actor, Visible, Glowing { if (!playerNoClip()) { updateNextHitboxY(); updateVerticalPos(); + clampNextHitbox(); updateHitboxY(); updateNextHitboxX(); updateHorizontalPos(); + clampNextHitbox(); updateHitboxX(); } - /** - * clamp position - */ - hitbox.setPositionFromPoint( - clampW(hitbox.getPointedX()) - , clampH(hitbox.getPointedY()) - ); - nextHitbox.setPositionFromPoint( - clampW(nextHitbox.getPointedX()) - , clampH(nextHitbox.getPointedY()) - ); + clampHitbox(); } } @@ -453,22 +445,30 @@ public class ActorWithBody implements Actor, Visible, Glowing { ; i < Math.round((side % 2 == 0) ? nextHitbox.getWidth() : nextHitbox.getHeight()) ; i++) { // set tile positions - int tileX = 0, tileY = 0; + int tileX, tileY; if (side == CONTACT_AREA_BOTTOM) { - tileX = div16(Math.round(nextHitbox.getHitboxStart().getX()) + i + translateX); - tileY = div16(FastMath.floor(nextHitbox.getHitboxEnd().getY()) + translateY); + tileX = div16TruncateToMapWidth(Math.round(nextHitbox.getHitboxStart().getX()) + + i + translateX); + tileY = div16TruncateToMapHeight(FastMath.floor(nextHitbox.getHitboxEnd().getY()) + + translateY); } else if (side == CONTACT_AREA_TOP) { - tileX = div16(Math.round(nextHitbox.getHitboxStart().getX()) + i + translateX); - tileY = div16(FastMath.ceil(nextHitbox.getHitboxStart().getY()) + translateY); + tileX = div16TruncateToMapWidth(Math.round(nextHitbox.getHitboxStart().getX()) + + i + translateX); + tileY = div16TruncateToMapHeight(FastMath.ceil(nextHitbox.getHitboxStart().getY()) + + translateY); } else if (side == CONTACT_AREA_RIGHT) { - tileX = div16(FastMath.floor(nextHitbox.getHitboxEnd().getX()) + translateX); - tileY = div16(Math.round(nextHitbox.getHitboxStart().getY()) + i + translateY); + tileX = div16TruncateToMapWidth(FastMath.floor(nextHitbox.getHitboxEnd().getX()) + + translateX); + tileY = div16TruncateToMapHeight(Math.round(nextHitbox.getHitboxStart().getY()) + + i + translateY); } else if (side == CONTACT_AREA_LEFT) { - tileX = div16(FastMath.ceil(nextHitbox.getHitboxStart().getX()) + translateX); - tileY = div16(Math.round(nextHitbox.getHitboxStart().getY()) + i + translateY); + tileX = div16TruncateToMapWidth(FastMath.ceil(nextHitbox.getHitboxStart().getX()) + + translateX); + tileY = div16TruncateToMapHeight(Math.round(nextHitbox.getHitboxStart().getY()) + + i + translateY); } else { throw new IllegalArgumentException(String.valueOf(side) + ": Wrong side input"); @@ -483,6 +483,20 @@ public class ActorWithBody implements Actor, Visible, Glowing { return contactAreaCounter; } + private void clampHitbox() { + hitbox.setPositionFromPoint( + clampW(hitbox.getPointedX()) + , clampH(hitbox.getPointedY()) + ); + } + + private void clampNextHitbox() { + nextHitbox.setPositionFromPoint( + clampW(nextHitbox.getPointedX()) + , clampH(nextHitbox.getPointedY()) + ); + } + @Override public void drawGlow(GameContainer gc, Graphics g) { if (visible && spriteGlow != null) { @@ -553,31 +567,31 @@ public class ActorWithBody implements Actor, Visible, Glowing { public float topLeftPosX() { return hitbox.getPosX(); } public float topLeftPosY() { return hitbox.getPosY(); } - private static float clampW(float x) { - if (x < 0) { - return 0; + private float clampW(float x) { + if (x < TSIZE + nextHitbox.getWidth() / 2) { + return TSIZE + nextHitbox.getWidth() / 2; } - else if (x >= Terrarum.game.map.width * TSIZE) { - return Terrarum.game.map.width * TSIZE - 1; + else if (x >= Terrarum.game.map.width * TSIZE - TSIZE - nextHitbox.getWidth() / 2) { + return Terrarum.game.map.width * TSIZE - 1 - TSIZE - nextHitbox.getWidth() / 2; } else { return x; } } - private static float clampH(float x) { - if (x < 0) { - return 0; + private float clampH(float y) { + if (y < TSIZE + nextHitbox.getHeight()) { + return TSIZE + nextHitbox.getHeight(); } - else if (x >= Terrarum.game.map.height * TSIZE) { - return Terrarum.game.map.height * TSIZE - 1; + else if (y >= Terrarum.game.map.height * TSIZE - TSIZE - nextHitbox.getHeight()) { + return Terrarum.game.map.height * TSIZE - 1 - TSIZE - nextHitbox.getHeight(); } else { - return x; + return y; } } - private static int clampWtile(int x) { + private int clampWtile(int x) { if (x < 0) { return 0; } @@ -589,7 +603,7 @@ public class ActorWithBody implements Actor, Visible, Glowing { } } - private static int clampHtile(int x) { + private int clampHtile(int x) { if (x < 0) { return 0; } @@ -606,13 +620,25 @@ public class ActorWithBody implements Actor, Visible, Glowing { } private static int div16(int x) { - if (x < 0) { throw new IllegalArgumentException("div16: Positive integer only:" + if (x < 0) { throw new IllegalArgumentException("div16: Positive integer only: " + String.valueOf(x)); } return (x & 0x7FFF_FFFF) >> 4; } + private static int div16TruncateToMapWidth(int x) { + if (x < 0) return 0; + else if (x >= Terrarum.game.map.width << 4) return Terrarum.game.map.width - 1; + else return (x & 0x7FFF_FFFF) >> 4; + } + + private static int div16TruncateToMapHeight(int y) { + if (y < 0) return 0; + else if (y >= Terrarum.game.map.height << 4) return Terrarum.game.map.height - 1; + else return (y & 0x7FFF_FFFF) >> 4; + } + private static int mod16(int x) { - if (x < 0) { throw new IllegalArgumentException("mod16: Positive integer only:" + if (x < 0) { throw new IllegalArgumentException("mod16: Positive integer only: " + String.valueOf(x)); } return x & 0b1111; } diff --git a/src/com/Torvald/Terrarum/Actors/CreatureBuildFactory.java b/src/com/Torvald/Terrarum/Actors/CreatureBuildFactory.java index d4b42ee56..753fd1bb6 100644 --- a/src/com/Torvald/Terrarum/Actors/CreatureBuildFactory.java +++ b/src/com/Torvald/Terrarum/Actors/CreatureBuildFactory.java @@ -3,6 +3,7 @@ package com.Torvald.Terrarum.Actors; import com.Torvald.JsonGetter; import com.Torvald.Rand.Fudge3; import com.Torvald.Rand.HQRNG; +import com.Torvald.Terrarum.LangPack.Lang; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.newdawn.slick.SlickException; @@ -24,32 +25,43 @@ public class CreatureBuildFactory { String[] elementsString = { - "racename" + "racename" , "racenameplural" }; String[] elementsFloat = { - "baseheight" + "baseheight" , "basemass" + , "accel" , "toolsize" , "encumbrance" }; String[] elementsFloatVariable = { - "baseheight" - , "strength" + "strength" , "speed" , "jumppower" , "scale" , "speed" - , "jump" + }; + + String[] elementsBoolean = { + "intelligent" + }; + + String[] elementsMultiplyFromOne = { + "physiquemult" }; setAVStrings(actor, elementsString, jsonObj); setAVFloats(actor, elementsFloat, jsonObj); setAVFloatsVariable(actor, elementsFloatVariable, jsonObj); + setAVMultiplyFromOne(actor, elementsMultiplyFromOne, jsonObj); + setAVBooleans(actor, elementsBoolean, jsonObj); + actor.actorValue.set("accel", Player.WALK_ACCEL_BASE); + actor.actorValue.set("accelmult", 1f); actor.inventory = new ActorInventory((int) actor.actorValue.get("encumberance"), true); @@ -84,7 +96,8 @@ public class CreatureBuildFactory { */ private void setAVStrings(ActorWithBody p, String[] elemSet, JsonObject jsonObject) { for (String s : elemSet) { - p.actorValue.set(s, jsonObject.get(s).getAsString()); + String key = jsonObject.get(s).getAsString(); + p.actorValue.set(s, Lang.get(key)); } } @@ -99,4 +112,30 @@ public class CreatureBuildFactory { p.actorValue.set(s, jsonObject.get(s).getAsFloat()); } } + + /** + * Fetch and set actor values that should multiplier be applied to the base value of 1. + * E.g. physiquemult + * @param p + * @param elemSet + * @param jsonObject + */ + private void setAVMultiplyFromOne(ActorWithBody p, String[] elemSet, JsonObject jsonObject) { + for (String s : elemSet) { + float baseValue = 1f; + // roll fudge dice and get value [-3, 3] as [0, 6] + int varSelected = new Fudge3().create(new HQRNG()).roll() + 3; + // get multiplier from json. Assuming percentile + int multiplier = jsonObject.get(s).getAsJsonArray().get(varSelected).getAsInt(); + float realValue = baseValue * multiplier / 100f; + + p.actorValue.set(s, realValue); + } + } + + private void setAVBooleans(ActorWithBody p, String[] elemSet, JsonObject jsonObject) { + for (String s : elemSet) { + p.actorValue.set(s, jsonObject.get(s).getAsBoolean()); + } + } } diff --git a/src/com/Torvald/Terrarum/Actors/PBFSigrid.java b/src/com/Torvald/Terrarum/Actors/PBFSigrid.java index 70a56f1bd..c1ffeb875 100644 --- a/src/com/Torvald/Terrarum/Actors/PBFSigrid.java +++ b/src/com/Torvald/Terrarum/Actors/PBFSigrid.java @@ -33,7 +33,7 @@ public class PBFSigrid { p.actorValue.set("scale", 1.0f); p.actorValue.set("speed", 4.0f); p.actorValue.set("speedmult", 1.0f); - p.actorValue.set("accel", p.WALK_ACCEL_BASE); + p.actorValue.set("accel", Player.WALK_ACCEL_BASE); p.actorValue.set("accelmult", 1.0f); p.actorValue.set("jumppower", 6.5f); @@ -52,9 +52,11 @@ public class PBFSigrid { p.actorValue.set("name", "Sigrid"); + p.actorValue.set("intelligent", true); + p.setHitboxDimension(17, 47, 9, 0); - p.inventory = new ActorInventory((int) p.actorValue.get("encumbrance"), true); + p.inventory = new ActorInventory(0x7FFFFFFF, true); p.setPosition(4096 * 16, 300 * 16); diff --git a/src/com/Torvald/Terrarum/Actors/Player.java b/src/com/Torvald/Terrarum/Actors/Player.java index 08004e5a5..716073420 100644 --- a/src/com/Torvald/Terrarum/Actors/Player.java +++ b/src/com/Torvald/Terrarum/Actors/Player.java @@ -39,13 +39,13 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac private int prevVMoveKey = -1; private final int KEY_NULL = -1; - final float ACCEL_MULT_IN_FLIGHT = 0.45f; - final float WALK_STOP_ACCEL = 0.2f; - final float WALK_ACCEL_BASE = 0.2f; + static final float ACCEL_MULT_IN_FLIGHT = 0.45f; + static final float WALK_STOP_ACCEL = 0.2f; + static final float WALK_ACCEL_BASE = 0.2f; private boolean noClip = false; - public final long PLAYER_REF_ID = 0x51621D; + public static final long PLAYER_REF_ID = 0x51621D; private final float AXIS_POSMAX = 1.0f; private final int GAMEPAD_JUMP = 5; diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java b/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java index 01790014e..83f16a0ed 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java @@ -29,8 +29,12 @@ public class GetAV implements ConsoleCommand { printUsage(); } else if (args.length == 2) { - echo.execute("player." + args[1] + ": " + echo.execute("player." + args[1] + " = " + Terrarum.game.getPlayer().getActorValue().get(args[1]) + + " (" + + Terrarum.game.getPlayer().getActorValue().get(args[1]).getClass() + .getSimpleName() + + ")" ); } else if (args.length == 3) { diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java b/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java index 0977351c4..08af7ff54 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java @@ -29,7 +29,16 @@ class SetAV implements ConsoleCommand { try { val = new Float(args[2]); } // try for number catch (NumberFormatException e) { - val = new String(args[2]); // string if not number + + if (args[2].toLowerCase() == "true") { + val = new Boolean(true); + } + else if (args[2].toLowerCase() == "false") { + val = new Boolean(false); + } + else { + val = new String(args[2]); // string if not number + } } Terrarum.game.getPlayer().getActorValue().set(args[1], val); diff --git a/src/com/Torvald/Terrarum/GameMap/GameMap.java b/src/com/Torvald/Terrarum/GameMap/GameMap.java index c1aaa9563..4994dbd18 100644 --- a/src/com/Torvald/Terrarum/GameMap/GameMap.java +++ b/src/com/Torvald/Terrarum/GameMap/GameMap.java @@ -33,6 +33,10 @@ public class GameMap { public LinkedList houseDesignation; + public static final int WALL = 0; + public static final int TERRAIN = 1; + public static final int WIRE = 2; + //public World physWorld = new World( new Vec2(0, -TerrarumMain.game.gravitationalAccel) ); //physics @NotNull @@ -114,6 +118,13 @@ public class GameMap { return uint8ToInt32(layerWire.data[y][x]); } + public int getTileFrom(int mode, int x, int y) { + if (mode == TERRAIN) { return getTileFromTerrain(x, y); } + else if (mode == WALL) { return getTileFromWall(x, y); } + else if (mode == WIRE) { return getTileFromWire(x, y); } + else throw new IllegalArgumentException("illegal mode input: " + String.valueOf(mode)); + } + private int uint8ToInt32(byte x) { int ret; if ((x & 0b1000_0000) != 0) { diff --git a/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java b/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java index 6519e110f..73516a2da 100644 --- a/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java +++ b/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java @@ -29,9 +29,9 @@ public class MapCamera { private static SpriteSheet[] tilesetBook; - private static final int WALL = 0; - private static final int TERRAIN = 1; - private static final int WIRE = 2; + private static final int WALL = GameMap.WALL; + private static final int TERRAIN = GameMap.TERRAIN; + private static final int WIRE = GameMap.WIRE; private static int renderWidth; private static int renderHeight; @@ -114,7 +114,7 @@ public class MapCamera { , TSIZE ); - tilesTerrain = new SpriteSheet("./res/graphics/terrain/terrainplusplus.png" + tilesTerrain = new SpriteSheet("./res/graphics/terrain/terrain.png" , TSIZE , TSIZE ); @@ -124,7 +124,7 @@ public class MapCamera { , TSIZE ); - tilesetBook = new SpriteSheet[9]; + tilesetBook = new SpriteSheet[3]; tilesetBook[WALL] = tilesWall; tilesetBook[TERRAIN] = tilesTerrain; tilesetBook[WIRE] = tilesWire; @@ -188,7 +188,7 @@ public class MapCamera { ( ( // wall and not blocked - (mode == WALL) && (!isOpaque(thisTerrainTile)) + (mode == WALL) && isWallThatBeDrawn(x, y) ) || (mode == TERRAIN) @@ -205,48 +205,43 @@ public class MapCamera { // check if light level of this tile is zero, for y = 0 ((y == 0) && (LightmapRenderer.getValueFromMap(x, y) > 0) - )) - ) { + ))) { - if (mode == TERRAIN) { - int nearbyTilesInfo; - //if (thisTile == DIRT) { - // nearbyTilesInfo = getGrassInfo(x, y, GRASS); - //} - //else { - // nearbyTilesInfo = getNearbyTilesInfo(x, y, AIR); - //} + int nearbyTilesInfo; + //if (thisTile == DIRT) { + // nearbyTilesInfo = getGrassInfo(x, y, GRASS); + //} + //else { + // nearbyTilesInfo = getNearbyTilesInfo(x, y, AIR); + //} - if (isDarkenAir((byte) thisTile)) { - nearbyTilesInfo = getNearbyTilesInfo(x, y, AIR); - } - else if (isConnectSelf((byte) thisTile)) { - nearbyTilesInfo = getNearbyTilesInfo(x, y, thisTile); - } - else { - nearbyTilesInfo = 0; - } + if (isDarkenAir((byte) thisTile)) { + nearbyTilesInfo = getNearbyTilesInfo(x, y, mode, AIR); + } + else if (isConnectSelf((byte) thisTile)) { + nearbyTilesInfo = getNearbyTilesInfo(x, y, mode, thisTile); + } + else { + nearbyTilesInfo = 0; + } - int thisTileX = nearbyTilesInfo; - int thisTileY = thisTile; + int thisTileX = nearbyTilesInfo; + int thisTileY = thisTile; - if (drawModeTilesBlendMul) { - if (isBlendMul((byte) thisTile)) drawTile(TERRAIN, x, y, thisTileX, thisTileY); - } - else { - // currently it draws all the transparent tile and colour mixes - // on top of the previously drawn tile - // TODO check wether it works as intended when skybox is dark - // add instruction "if (!isBlendMul((byte) thisTile))" - drawTile(TERRAIN, x, y, thisTileX, thisTileY); + if (drawModeTilesBlendMul) { + if (isBlendMul((byte) thisTile)) { + drawTile(mode, x, y, thisTileX, thisTileY); } } else { - drawTile(mode, x, y, mod16(thisTile), div16(thisTile)); + // currently it draws all the transparent tile and colour mixes + // on top of the previously drawn tile + // TODO check wether it works as intended when skybox is dark + // add instruction "if (!isBlendMul((byte) thisTile))" + drawTile(mode, x, y, thisTileX, thisTileY); } } - } } @@ -263,19 +258,19 @@ public class MapCamera { * @param y * @return [0-15] 1: up, 2: right, 4: down, 8: left */ - private static int getNearbyTilesInfo(int x, int y, int mark) { + private static int getNearbyTilesInfo(int x, int y, int mode, int mark) { int[] nearbyTiles = new int[4]; if (x == 0) { nearbyTiles[NEARBY_TILE_KEY_LEFT] = 0xFF; } - else { nearbyTiles[NEARBY_TILE_KEY_LEFT] = map.getTileFromTerrain(x - 1, y); } + else { nearbyTiles[NEARBY_TILE_KEY_LEFT] = map.getTileFrom(mode, x - 1, y); } if (x == map.width - 1) { nearbyTiles[NEARBY_TILE_KEY_RIGHT] = 0xFF; } - else { nearbyTiles[NEARBY_TILE_KEY_RIGHT] = map.getTileFromTerrain(x + 1, y); } + else { nearbyTiles[NEARBY_TILE_KEY_RIGHT] = map.getTileFrom(mode, x + 1, y); } if (y == 0) { nearbyTiles[NEARBY_TILE_KEY_UP] = 0; } - else { nearbyTiles[NEARBY_TILE_KEY_UP] = map.getTileFromTerrain(x, y - 1); } + else { nearbyTiles[NEARBY_TILE_KEY_UP] = map.getTileFrom(mode, x, y - 1); } if (y == map.height - 1) { nearbyTiles[NEARBY_TILE_KEY_DOWN] = 0xFF; } - else { nearbyTiles[NEARBY_TILE_KEY_DOWN] = map.getTileFromTerrain(x, y + 1); } + else { nearbyTiles[NEARBY_TILE_KEY_DOWN] = map.getTileFrom(mode, x, y + 1); } // try for int ret = 0; @@ -387,12 +382,25 @@ public class MapCamera { return s.getSprite(i % 16, i / 16); } + private static boolean isWallThatBeDrawn(int x, int y) { + for (int i = 0; i < 9; i++) { + int tx = x + (i % 3 - 1); + int ty = y + (i / 3 - 1); + + if (tx < 0) tx = 0; + else if (tx >= map.width) tx = map.width; + if (ty < 0) ty = 0; + else if (ty >= map.width) ty = map.width; + + if (!isOpaque(map.getTileFromTerrain(tx, ty))) { + return true; + } + } + return false; + } + private static boolean isOpaque(int x) { - return (x >= 1 && x <= 38) - || (x >= 41 && x <= 44) - || (x >= 46 && x <= 47) - || (x >= 64 && x <= 86) - || (x >= 88 && x <= 116); + return !(x == GRASS || x == AIR); } public static int getCameraX() { diff --git a/src/com/Torvald/Terrarum/MapGenerator/MapGenerator.java b/src/com/Torvald/Terrarum/MapGenerator/MapGenerator.java index e8b682393..3ad9c5b93 100644 --- a/src/com/Torvald/Terrarum/MapGenerator/MapGenerator.java +++ b/src/com/Torvald/Terrarum/MapGenerator/MapGenerator.java @@ -108,12 +108,12 @@ public class MapGenerator { placeGlacierMount(heightMap); heightMapToObjectMap(heightMap); - /*carveByMap( + carveByMap( generate2DSimplexNoiseWorldSize(2.5f, 1.666f) , 1 , AIR , "Carving out cave..." - );*/ + ); /*fillByMapInverseGradFilter( generate2DSimplexNoiseWorldSize(2.5f, 2.5f) @@ -121,8 +121,8 @@ public class MapGenerator { , DIRT , STONE , "Planting stones on dirt layers..." - );*/ - /*fillByMapInverseGradFilter( + ); + fillByMapInverseGradFilter( generate2DSimplexNoiseWorldSize(2.5f, 2.5f) , 0.98f , STONE