From 0cde9de388e41c6c03874cf3e33d1218619d2e02 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 17 Jul 2023 04:06:06 -0400 Subject: [PATCH] Testing Zone set. --- src/engine/devcmd/cmds/GetZoneMobsCmd.java | 84 --------------------- src/engine/devcmd/cmds/ZoneSetCmd.java | 87 ++++++++++++++++++++++ src/engine/gameManager/DevCmdManager.java | 3 +- 3 files changed, 88 insertions(+), 86 deletions(-) delete mode 100644 src/engine/devcmd/cmds/GetZoneMobsCmd.java create mode 100644 src/engine/devcmd/cmds/ZoneSetCmd.java diff --git a/src/engine/devcmd/cmds/GetZoneMobsCmd.java b/src/engine/devcmd/cmds/GetZoneMobsCmd.java deleted file mode 100644 index aea5761f..00000000 --- a/src/engine/devcmd/cmds/GetZoneMobsCmd.java +++ /dev/null @@ -1,84 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.devcmd.cmds; - -import engine.devcmd.AbstractDevCmd; -import engine.gameManager.ZoneManager; -import engine.objects.AbstractGameObject; -import engine.objects.Mob; -import engine.objects.PlayerCharacter; -import engine.objects.Zone; - -public class GetZoneMobsCmd extends AbstractDevCmd { - - public GetZoneMobsCmd() { - super("getzonemobs"); - } - - @Override - protected void _doCmd(PlayerCharacter pcSender, String[] words, - AbstractGameObject target) { - if (pcSender == null) - return; - - int loadID = 0; - if (words.length == 1) { - try { - loadID = Integer.parseInt(words[0]); - } catch (Exception e) { - } - } - - //find the zone - Zone zone = null; - if (loadID != 0) { - zone = ZoneManager.getZoneByZoneID(loadID); - if (zone == null) - zone = ZoneManager.getZoneByUUID(loadID); - } else - zone = ZoneManager.findSmallestZone(pcSender.getLoc()); - - if (zone == null) { - if (loadID != 0) - throwbackError(pcSender, "Error: can't find the zone of ID " + loadID + '.'); - else - throwbackError(pcSender, "Error: can't find the zone you are in."); - return; - } - - //get all mobs for the zone - - throwbackInfo(pcSender, zone.getName() + " (" + zone.getLoadNum() + ") " + zone.getObjectUUID()); - - for (Mob m : zone.zoneMobSet) { - - if (m != null) { - String out = m.getName() + '(' + m.getDBID() + "): "; - if (m.isAlive()) - out += m.getLoc().x + "x" + m.getLoc().z + "; isAlive: " + m.isAlive(); - else - out += " isAlive: " + m.isAlive(); - throwbackInfo(pcSender, out); - } else - throwbackInfo(pcSender, "Unknown (" + m.getDBID() + "): not loaded"); - } - } - - @Override - protected String _getUsageString() { - return "' /getzonemobs [zoneID]'"; - } - - @Override - protected String _getHelpString() { - return "lists all mobs for a zone"; - } - -} diff --git a/src/engine/devcmd/cmds/ZoneSetCmd.java b/src/engine/devcmd/cmds/ZoneSetCmd.java new file mode 100644 index 00000000..679a4c5f --- /dev/null +++ b/src/engine/devcmd/cmds/ZoneSetCmd.java @@ -0,0 +1,87 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.devcmd.cmds; + +import engine.devcmd.AbstractDevCmd; +import engine.gameManager.ZoneManager; +import engine.objects.*; + +public class ZoneSetCmd extends AbstractDevCmd { + + public ZoneSetCmd() { + super("zoneset"); + } + + @Override + protected void _doCmd(PlayerCharacter playerCharacter, String[] words, + AbstractGameObject target) { + Zone zone; + + if (playerCharacter == null) + return; + + if (words.length == 0) { + throwbackError(playerCharacter, "Usage: zoneset npc/mob"); + return; + } + + if (!words[0].equalsIgnoreCase("npc") && + !words[0].equalsIgnoreCase("mob")) { + throwbackError(playerCharacter, "Usage: zoneset npc/mob"); + return; + } + + zone = ZoneManager.findSmallestZone(playerCharacter.getLoc()); + + if (zone == null) { + throwbackError(playerCharacter, "Error: can't find the zone you are in."); + return; + } + + //get all mobs for the zone + + throwbackInfo(playerCharacter, zone.getName() + " (" + zone.getLoadNum() + ") " + zone.getObjectUUID()); + + if (words[0].equalsIgnoreCase("mob")) { + + for (Mob mob : zone.zoneMobSet) { + + String out = mob.getName() + '(' + mob.getDBID() + "): "; + + if (mob.isAlive()) + out += mob.getLoc().x + "x" + mob.getLoc().z + "; isAlive: " + mob.isAlive(); + else + out += " isAlive: " + mob.isAlive(); + + throwbackInfo(playerCharacter, out); + return; + } + } + + // NPC + + for (NPC npc : zone.zoneNPCSet) { + String out = npc.getName() + '(' + npc.getDBID() + "): "; + throwbackInfo(playerCharacter, out); + } + + } + + @Override + protected String _getUsageString() { + return "' /zoneset npc|mob'"; + } + + @Override + protected String _getHelpString() { + return "lists entries in zone npc set"; + } + +} diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 8549214e..33ba103d 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -42,10 +42,9 @@ public enum DevCmdManager { // Player DevCmdManager.registerDevCmd(new DistanceCmd()); - ; DevCmdManager.registerDevCmd(new HelpCmd()); DevCmdManager.registerDevCmd(new GetZoneCmd()); - DevCmdManager.registerDevCmd(new GetZoneMobsCmd()); + DevCmdManager.registerDevCmd(new ZoneSetCmd()); DevCmdManager.registerDevCmd(new PrintBankCmd()); DevCmdManager.registerDevCmd(new PrintEquipCmd()); DevCmdManager.registerDevCmd(new PrintInventoryCmd());