diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java index cfe867b..d271ce0 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java @@ -4,9 +4,9 @@ import net.simon987.server.GameServer; import net.simon987.server.assembly.CpuHardware; import net.simon987.server.assembly.Status; import net.simon987.server.game.Action; +import net.simon987.server.game.Attackable; import net.simon987.server.game.GameObject; import net.simon987.server.game.InventoryHolder; -import net.simon987.server.game.Attackable; import org.json.simple.JSONObject; import java.awt.*; @@ -27,7 +27,7 @@ public class CubotLaser extends CpuHardware { private static final int LASER_DEPOSIT = 2; private static final int LASER_ATTACK = 3; - private static final int LASER_DAMAGE = 20; + private static final int LASER_DAMAGE = 25; public CubotLaser(Cubot cubot) { this.cubot = cubot; @@ -71,8 +71,8 @@ public class CubotLaser extends CpuHardware { } else if (a == LASER_DEPOSIT) { // TODO } else if (a == LASER_ATTACK) { - - if (cubot.spendEnergy(20)) { + + if (cubot.spendEnergy(70)) { //Get object directly in front of the Cubot Point frontTile = cubot.getFrontTile(); diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvesterNPC.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvesterNPC.java index bf27171..a62e537 100644 --- a/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvesterNPC.java +++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvesterNPC.java @@ -8,8 +8,8 @@ public class HarvesterNPC extends NonPlayerCharacter { public static final int ID = 10; - public static final int MAX_HEALTH = 100; - public static final int HEAL_RATE = 5; + public static final int MAX_HEALTH = GameServer.INSTANCE.getConfig().getInt("harvester_hp_max"); + public static final int HEAL_RATE = GameServer.INSTANCE.getConfig().getInt("harvester_regen"); public HarvesterNPC() { diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/NonPlayerCharacter.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/NonPlayerCharacter.java index 4a5cdef..c35c4be 100644 --- a/Plugin NPC/src/main/java/net/simon987/npcplugin/NonPlayerCharacter.java +++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/NonPlayerCharacter.java @@ -2,11 +2,7 @@ package net.simon987.npcplugin; import net.simon987.server.GameServer; import net.simon987.server.assembly.Util; -import net.simon987.server.game.Action; -import net.simon987.server.game.Direction; -import net.simon987.server.game.GameObject; -import net.simon987.server.game.Updatable; -import net.simon987.server.game.Attackable; +import net.simon987.server.game.*; import net.simon987.server.game.pathfinding.Node; import net.simon987.server.game.pathfinding.Pathfinder; import net.simon987.server.logging.LogManager; @@ -23,7 +19,7 @@ public abstract class NonPlayerCharacter extends GameObject implements Updatable // Set these just in case they aren't overridden in the subclass public static final int HP_MAX_DEFAULT = 100; - public static final int HP_REGEN_RATE_DEFAULT = 5; + public static final int HP_REGEN_RATE_DEFAULT = 0; //Unused int energy; diff --git a/Server/src/main/java/net/simon987/server/assembly/Assembler.java b/Server/src/main/java/net/simon987/server/assembly/Assembler.java index 89c8782..2bb4f47 100755 --- a/Server/src/main/java/net/simon987/server/assembly/Assembler.java +++ b/Server/src/main/java/net/simon987/server/assembly/Assembler.java @@ -23,7 +23,7 @@ public class Assembler { private InstructionSet instructionSet; private RegisterSet registerSet; - + private static final int MEM_SIZE = 0x10000; // Size in words public Assembler(InstructionSet instructionSet, RegisterSet registerSet, ServerConfiguration config) { @@ -208,11 +208,11 @@ public class Assembler { try { int factor = Integer.decode(valueTokens[0]); - + if (factor > MEM_SIZE) { throw new InvalidOperandException("Factor '"+factor+"' exceeds total memory size", currentLine); } - + String value = valueTokens[1].substring(4, valueTokens[1].lastIndexOf(')')); //Handle label @@ -359,9 +359,12 @@ public class Assembler { if (currentOffset >= MEM_SIZE) { throw new OffsetOverflowException(currentOffset, MEM_SIZE, currentLine); } - } catch (AssemblyException e) { + } catch (FatalAssemblyException e) { + //Don't bother parsing the rest of the code, since it will not be assembled anyway + break; + } catch (AssemblyException e1) { //Ignore error on pass 2 - //System.out.println(e); + } } @@ -389,11 +392,11 @@ public class Assembler { //Encode instruction byte[] bytes = parseInstruction(line, currentLine, result.labels, instructionSet); currentOffset += bytes.length / 2; - + if (currentOffset >= MEM_SIZE) { throw new OffsetOverflowException(currentOffset, MEM_SIZE, currentLine); } - + out.write(bytes); } catch (EmptyLineException | PseudoInstructionException e) { @@ -410,7 +413,26 @@ public class Assembler { } } - result.bytes = out.toByteArray(); + //If the code contains OffsetOverFlowException(s), don't bother writing the assembled bytes to memory + boolean writeToMemory = true; + for (Exception e : result.exceptions) { + if (e instanceof OffsetOverflowException) { + writeToMemory = false; + } + } + + if (writeToMemory) { + result.bytes = out.toByteArray(); + } else { + result.bytes = new byte[0]; + LogManager.LOGGER.fine("Skipping writing assembled bytes to memory. (OffsetOverflowException)"); + } + + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } LogManager.LOGGER.info("Assembled " + result.bytes.length + " bytes (" + result.exceptions.size() + " errors)"); for (AssemblyException e : result.exceptions) { diff --git a/Server/src/main/java/net/simon987/server/game/GameUniverse.java b/Server/src/main/java/net/simon987/server/game/GameUniverse.java index 77cb620..e8895ee 100644 --- a/Server/src/main/java/net/simon987/server/game/GameUniverse.java +++ b/Server/src/main/java/net/simon987/server/game/GameUniverse.java @@ -248,7 +248,7 @@ public class GameUniverse implements JSONSerialisable { public String getGuestUsername() { int i = 1; - while (i < 1000) { //todo get Max guest user cap from config + while (i < 10000) { //todo get Max guest user cap from config if (getUser("guest" + String.valueOf(i)) != null) { i++; continue; diff --git a/Server/src/main/resources/config.properties b/Server/src/main/resources/config.properties index bc55fcb..03fb53e 100644 --- a/Server/src/main/resources/config.properties +++ b/Server/src/main/resources/config.properties @@ -56,6 +56,10 @@ npc_lifetime=1024 npc_max_factory_distance=3 # Maximum NPC per Factory factory_max_npc_count=16 +# Harvester max hp +harvester_hp_max=100 +# Harvester hp regeneration per tick +harvester_regen=5 # ---------------------------------------------- # Minimum center point count for the WorldGenerator wg_centerPointCountMin=5