Browse Source

Project cleanup pre merge.

master
MagicBot 2 years ago
parent
commit
9bbdef224d
  1. 15
      README.md
  2. 2
      src/discord/DiscordAccount.java
  3. 297
      src/discord/MagicBot.java
  4. 3
      src/discord/handlers/ChatChannelHandler.java
  5. 7
      src/discord/handlers/DevRequestHandler.java
  6. 320
      src/engine/InterestManagement/HeightMap.java
  7. 246
      src/engine/InterestManagement/InterestManager.java
  8. 2
      src/engine/InterestManagement/RealmMap.java
  9. 68
      src/engine/InterestManagement/WorldGrid.java
  10. 121
      src/engine/ai/MobileFSM.java
  11. 5
      src/engine/ai/MobileFSMManager.java
  12. 2
      src/engine/ai/utilities/CombatUtilities.java
  13. 49
      src/engine/core/ControlledRunnable.java
  14. 12
      src/engine/db/archive/BaneRecord.java
  15. 3
      src/engine/db/archive/CharacterRecord.java
  16. 3
      src/engine/db/archive/CityRecord.java
  17. 1
      src/engine/db/archive/DataRecord.java
  18. 44
      src/engine/db/archive/DataWarehouse.java
  19. 15
      src/engine/db/archive/GuildRecord.java
  20. 6
      src/engine/db/archive/MineRecord.java
  21. 3
      src/engine/db/archive/PvpRecord.java
  22. 3
      src/engine/db/archive/RealmRecord.java
  23. 120
      src/engine/devcmd/AbstractDevCmd.java
  24. 1
      src/engine/devcmd/cmds/AddGoldCmd.java
  25. 17
      src/engine/devcmd/cmds/AddMobCmd.java
  26. 5
      src/engine/devcmd/cmds/AddNPCCmd.java
  27. 36
      src/engine/devcmd/cmds/ApplyBonusCmd.java
  28. 47
      src/engine/devcmd/cmds/ApplyStatModCmd.java
  29. 35
      src/engine/devcmd/cmds/AuditFailedItemsCmd.java
  30. 7
      src/engine/devcmd/cmds/AuditHeightMapCmd.java
  31. 15
      src/engine/devcmd/cmds/AuditMobsCmd.java
  32. 14
      src/engine/devcmd/cmds/BoundsCmd.java
  33. 2
      src/engine/devcmd/cmds/ChangeNameCmd.java
  34. 5
      src/engine/devcmd/cmds/CombatMessageCmd.java
  35. 5
      src/engine/devcmd/cmds/CreateItemCmd.java
  36. 17
      src/engine/devcmd/cmds/DebugCmd.java
  37. 1
      src/engine/devcmd/cmds/DebugMeleeSyncCmd.java
  38. 4
      src/engine/devcmd/cmds/DecachePlayerCmd.java
  39. 13
      src/engine/devcmd/cmds/DespawnCmd.java
  40. 5
      src/engine/devcmd/cmds/DistanceCmd.java
  41. 2
      src/engine/devcmd/cmds/EffectCmd.java
  42. 13
      src/engine/devcmd/cmds/EnchantCmd.java
  43. 3
      src/engine/devcmd/cmds/FlashMsgCmd.java
  44. 5
      src/engine/devcmd/cmds/GateInfoCmd.java
  45. 8
      src/engine/devcmd/cmds/GetBankCmd.java
  46. 41
      src/engine/devcmd/cmds/GetHeightCmd.java
  47. 27
      src/engine/devcmd/cmds/GetMemoryCmd.java
  48. 7
      src/engine/devcmd/cmds/GetMobBaseLoot.java
  49. 3
      src/engine/devcmd/cmds/GetOffsetCmd.java
  50. 3
      src/engine/devcmd/cmds/GetRuneDropRateCmd.java
  51. 6
      src/engine/devcmd/cmds/GetVaultCmd.java
  52. 3
      src/engine/devcmd/cmds/GetZoneCmd.java
  53. 6
      src/engine/devcmd/cmds/GetZoneMobsCmd.java
  54. 17
      src/engine/devcmd/cmds/GotoBoundsCmd.java
  55. 39
      src/engine/devcmd/cmds/GotoCmd.java
  56. 1
      src/engine/devcmd/cmds/GotoObj.java
  57. 1
      src/engine/devcmd/cmds/HeartbeatCmd.java
  58. 2
      src/engine/devcmd/cmds/HotzoneCmd.java
  59. 87
      src/engine/devcmd/cmds/InfoCmd.java
  60. 2
      src/engine/devcmd/cmds/JumpCmd.java
  61. 18
      src/engine/devcmd/cmds/MBDropCmd.java
  62. 7
      src/engine/devcmd/cmds/MakeBaneCmd.java
  63. 12
      src/engine/devcmd/cmds/MakeItemCmd.java
  64. 44
      src/engine/devcmd/cmds/NetDebugCmd.java
  65. 2
      src/engine/devcmd/cmds/PrintBankCmd.java
  66. 7
      src/engine/devcmd/cmds/PrintBonusesCmd.java
  67. 16
      src/engine/devcmd/cmds/PrintEquipCmd.java
  68. 5
      src/engine/devcmd/cmds/PrintInventoryCmd.java
  69. 1
      src/engine/devcmd/cmds/PrintLocationCmd.java
  70. 22
      src/engine/devcmd/cmds/PrintStatsCmd.java
  71. 2
      src/engine/devcmd/cmds/PrintVaultCmd.java
  72. 76
      src/engine/devcmd/cmds/PullCmd.java
  73. 247
      src/engine/devcmd/cmds/PurgeObjectsCmd.java
  74. 1
      src/engine/devcmd/cmds/RealmInfoCmd.java
  75. 6
      src/engine/devcmd/cmds/RebootCmd.java
  76. 19
      src/engine/devcmd/cmds/RegionCmd.java
  77. 1
      src/engine/devcmd/cmds/RemoveBaneCmd.java
  78. 16
      src/engine/devcmd/cmds/RemoveObjectCmd.java
  79. 6
      src/engine/devcmd/cmds/RenameCmd.java
  80. 1
      src/engine/devcmd/cmds/ResetLevelCmd.java
  81. 44
      src/engine/devcmd/cmds/RotateCmd.java
  82. 16
      src/engine/devcmd/cmds/SetAICmd.java
  83. 4
      src/engine/devcmd/cmds/SetAdminRuneCmd.java
  84. 1
      src/engine/devcmd/cmds/SetBaneActiveCmd.java
  85. 7
      src/engine/devcmd/cmds/SetBuildingAltitudeCmd.java
  86. 1
      src/engine/devcmd/cmds/SetForceRenameCityCmd.java
  87. 12
      src/engine/devcmd/cmds/SetGuildCmd.java
  88. 1
      src/engine/devcmd/cmds/SetHealthCmd.java
  89. 5
      src/engine/devcmd/cmds/SetInvulCmd.java
  90. 3
      src/engine/devcmd/cmds/SetMaintCmd.java
  91. 38
      src/engine/devcmd/cmds/SetNpcEquipSetCmd.java
  92. 7
      src/engine/devcmd/cmds/SetNpcMobbaseCmd.java
  93. 6
      src/engine/devcmd/cmds/SetNpcNameCmd.java
  94. 19
      src/engine/devcmd/cmds/SetOwnerCmd.java
  95. 16
      src/engine/devcmd/cmds/SetRankCmd.java
  96. 2
      src/engine/devcmd/cmds/SetRuneCmd.java
  97. 1
      src/engine/devcmd/cmds/SetStaminaCmd.java
  98. 31
      src/engine/devcmd/cmds/SetSubRaceCmd.java
  99. 3
      src/engine/devcmd/cmds/ShowOffsetCmd.java
  100. 3
      src/engine/devcmd/cmds/SlotTestCmd.java
  101. Some files were not shown because too many files have changed in this diff Show More

15
README.md

@ -1,17 +1,23 @@
![Logo](https://magicbane.com/images/MBLogo.jpg) ![Logo](https://magicbane.com/images/MBLogo.jpg)
# Magicbane Open-Source MMO Project # Magicbane Open-Source MMO Project
### *The Community written Shadowbane emulator* ### *The Community written Shadowbane emulator*
[Magicbane](http://www.magicbane.com) [Magicbane](http://www.magicbane.com)
</BR> </BR>
[Public Repository](http://repo.magicbane.com) [Public Repository](http://repo.magicbane.com)
<BR> <BR>
<magicbot@magicbane.com> <magicbot@magicbane.com>
> Magicbane is an emulator for the long dead but much beloved Ubisoft MMO, [Shadowbane](https://en.wikipedia.org/wiki/Shadowbane). > Magicbane is an emulator for the long dead but much beloved Ubisoft
The project was founded in 2013 with the concept of free availability of gameplay; players unencumbered by any factor other than a desire to again play a game they once loved. A game where the developers do not play is guaranteed to be the fairest game. > MMO, [Shadowbane](https://en.wikipedia.org/wiki/Shadowbane).
> The project was founded in 2013 with the concept of free availability of gameplay; players unencumbered by any factor
> other than a desire to again play a game they once loved. A game where the developers do not play is guaranteed to be
> the fairest game.
The Magicbane Team has wanted to open source Shadowbane for half a decade. We are excited to now finally have the opportunity, along with some new technology, to truly democratize Shadowbane. The Magicbane Team has wanted to open source Shadowbane for half a decade. We are excited to now finally have the
opportunity, along with some new technology, to truly democratize Shadowbane.
- Written in some 80k lines of Java 8 and bash. - Written in some 80k lines of Java 8 and bash.
- Project with real infrastructure; Production and development servers supporting multiple containerized apps. - Project with real infrastructure; Production and development servers supporting multiple containerized apps.
@ -27,4 +33,5 @@ The Magicbane Team has wanted to open source Shadowbane for half a decade. We a
## Support ## Support
Documentation is available through the Magicbane [Wiki](http://repo.magicbane.com/MagicBane/Server/wiki) and [Discord server](www.magicbane.com). Documentation is available through the Magicbane [Wiki](http://repo.magicbane.com/MagicBane/Server/wiki)
and [Discord server](www.magicbane.com).

2
src/discord/DiscordAccount.java

@ -7,6 +7,7 @@
// www.magicbane.com // www.magicbane.com
package discord; package discord;
import engine.Enum; import engine.Enum;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -18,6 +19,7 @@ public class DiscordAccount {
public LocalDateTime registrationDate; public LocalDateTime registrationDate;
public LocalDateTime lastUpdateRequest; public LocalDateTime lastUpdateRequest;
public byte isDiscordAdmin; public byte isDiscordAdmin;
public DiscordAccount() { public DiscordAccount() {
} }

297
src/discord/MagicBot.java

@ -37,32 +37,32 @@ import java.util.regex.Pattern;
import static discord.ChatChannel.ADMINLOG; import static discord.ChatChannel.ADMINLOG;
/* /*
* MagicBot is many things to Magicbane... * MagicBot is many things to Magicbane...
* *
* -Project Mascot * -Project Mascot
* -Customer service and administration bot * -Customer service and administration bot
* -Benevolent dictator * -Benevolent dictator
* -Investment manager. * -Investment manager.
* *
* MagicBot will never beg you for money. He is a very * MagicBot will never beg you for money. He is a very
* responsible robot. He was varnished but never garnished. * responsible robot. He was varnished but never garnished.
* MagicBot does not for to overclock himself. His chips * MagicBot does not for to overclock himself. His chips
* will therefore never overcook. * will therefore never overcook.
* MagicBot will never be a pitiful robot trying for to use * MagicBot will never be a pitiful robot trying for to use
* you as emotional support human. * you as emotional support human.
* *
* MagicBot is just not that sort of robot and Magicbane * MagicBot is just not that sort of robot and Magicbane
* just isn't that sort of project. * just isn't that sort of project.
* *
* MagicBot runs a Shaodowbane emulator not a Second Life emulator. * MagicBot runs a Shaodowbane emulator not a Second Life emulator.
* *
*/ */
public class MagicBot extends ListenerAdapter { public class MagicBot extends ListenerAdapter {
public static JDA jda;
public static Database database;
public static final Pattern accountNameRegex = Pattern.compile("^[\\p{Alnum}]{6,20}$"); public static final Pattern accountNameRegex = Pattern.compile("^[\\p{Alnum}]{6,20}$");
public static final Pattern passwordRegex = Pattern.compile("^[\\p{Alnum}]{6,20}$"); public static final Pattern passwordRegex = Pattern.compile("^[\\p{Alnum}]{6,20}$");
public static JDA jda;
public static Database database;
public static long discordServerID; public static long discordServerID;
public static long discordRoleID; public static long discordRoleID;
@ -126,12 +126,136 @@ public class MagicBot extends ListenerAdapter {
Runnable adminLogRunnable = () -> SendAdminLogUpdates(); Runnable adminLogRunnable = () -> SendAdminLogUpdates();
ScheduledExecutorService exec = Executors.newScheduledThreadPool(1); ScheduledExecutorService exec = Executors.newScheduledThreadPool(1);
exec.scheduleAtFixedRate(adminLogRunnable , 0, 1, TimeUnit.MINUTES); exec.scheduleAtFixedRate(adminLogRunnable, 0, 1, TimeUnit.MINUTES);
Logger.info("***MAGICBOT IS RUNNING***"); Logger.info("***MAGICBOT IS RUNNING***");
} }
public static void sendResponse(MessageReceivedEvent event, String responseContent) {
// Send a formatted MagicBot response to a Discord user
String discordUserName;
MessageChannel channel;
// Exit if discord is offline
if (jda.getStatus().equals(JDA.Status.CONNECTED) == false)
return;
discordUserName = event.getAuthor().getName();
channel = event.getMessage().getChannel();
channel.sendMessage(
"```\n" + "Hello Player " + discordUserName + "\n\n" +
responseContent + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```").queue();
}
public static boolean isAdminEvent(MessageReceivedEvent event) {
String discordAccountID = event.getAuthor().getId();
List<DiscordAccount> discordAccounts;
DiscordAccount discordAccount;
// Note that database errors will cause this to return false.
// After the database is offline Avail status must be set
// to true before any subsequent admin commands will function.
if (Database.online == false)
return false;
discordAccounts = database.getDiscordAccounts(discordAccountID);
if (discordAccounts.isEmpty())
return false;
discordAccount = discordAccounts.get(0);
return (discordAccount.isDiscordAdmin == 1);
}
public static String generatePassword(int length) {
String ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
StringBuilder passwordBuilder = new StringBuilder(length);
Random random = new Random();
// Generate alphanumeric password of a given length.
// Could not find a good method of generating a password
// based upon a given regex.
for (int i = 0; i < length; i++)
passwordBuilder.append(ALPHABET.charAt(random.nextInt(ALPHABET.length())));
return new String(passwordBuilder);
}
public static String readLogFile(String filePath, int lineCount) {
ProcessBuilder builder = new ProcessBuilder("/bin/bash", "-c", "tail -n " + lineCount + " " + filePath);
builder.redirectErrorStream(true);
Process process = null;
String line = null;
String logOutput = "";
try {
process = builder.start();
InputStream is = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
while ((line = reader.readLine()) != null) {
logOutput += line + "\n";
}
} catch (IOException e) {
Logger.error(e.toString());
return "Error while reading logfile";
}
return logOutput;
}
private static void junkbot(String command, String[] inString) {
String outString;
Writer fileWriter;
if (inString == null)
return;
;
outString = command + String.join(" ", inString);
outString += "\n";
try {
fileWriter = new BufferedWriter(new FileWriter("junkbot.txt", true));
fileWriter.append(outString);
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void SendAdminLogUpdates() {
HashMap<Integer, String> adminEvents = database.getAdminEvents();
for (int adminEvent : adminEvents.keySet()) {
// Set event as read
database.setAdminEventAsRead(adminEvent);
String outString =
"```\n" + "Hello Players \n\n" +
adminEvents.get(adminEvent) + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```";
if (ADMINLOG.textChannel.canTalk())
ADMINLOG.textChannel.sendMessage(outString).queue();
}
}
@Override @Override
public void onMessageReceived(MessageReceivedEvent event) { public void onMessageReceived(MessageReceivedEvent event) {
@ -142,7 +266,8 @@ public class MagicBot extends ListenerAdapter {
// Early exit if message sent to us by another bot or ourselves. // Early exit if message sent to us by another bot or ourselves.
if (event.getAuthor().isBot()) return; if (event.getAuthor().isBot())
return;
// Extract message and origin channel from event // Extract message and origin channel from event
@ -247,49 +372,6 @@ public class MagicBot extends ListenerAdapter {
} }
} }
public static void sendResponse(MessageReceivedEvent event, String responseContent) {
// Send a formatted MagicBot response to a Discord user
String discordUserName;
MessageChannel channel;
// Exit if discord is offline
if (jda.getStatus().equals(JDA.Status.CONNECTED) == false)
return;
discordUserName = event.getAuthor().getName();
channel = event.getMessage().getChannel();
channel.sendMessage(
"```\n" + "Hello Player " + discordUserName + "\n\n" +
responseContent + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```").queue();
}
public static boolean isAdminEvent(MessageReceivedEvent event) {
String discordAccountID = event.getAuthor().getId();
List<DiscordAccount> discordAccounts;
DiscordAccount discordAccount;
// Note that database errors will cause this to return false.
// After the database is offline Avail status must be set
// to true before any subsequent admin commands will function.
if (Database.online == false)
return false;
discordAccounts = database.getDiscordAccounts(discordAccountID);
if (discordAccounts.isEmpty())
return false;
discordAccount = discordAccounts.get(0);
return (discordAccount.isDiscordAdmin == 1);
}
public void handleHelpRequest(MessageReceivedEvent event) { public void handleHelpRequest(MessageReceivedEvent event) {
// Help is kept here in the main class instead of a handler as a // Help is kept here in the main class instead of a handler as a
@ -322,85 +404,4 @@ public class MagicBot extends ListenerAdapter {
"#trash <blank>/detail/flush"; "#trash <blank>/detail/flush";
sendResponse(event, helpString); sendResponse(event, helpString);
} }
public static String generatePassword(int length) {
String ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
StringBuilder passwordBuilder = new StringBuilder(length);
Random random = new Random();
// Generate alphanumeric password of a given length.
// Could not find a good method of generating a password
// based upon a given regex.
for (int i = 0; i < length; i++)
passwordBuilder.append(ALPHABET.charAt(random.nextInt(ALPHABET.length())));
return new String(passwordBuilder);
}
public static String readLogFile(String filePath, int lineCount) {
ProcessBuilder builder = new ProcessBuilder("/bin/bash", "-c", "tail -n " + lineCount + " " + filePath);
builder.redirectErrorStream(true);
Process process = null;
String line = null;
String logOutput = "";
try {
process = builder.start();
InputStream is = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
while ((line = reader.readLine()) != null) {
logOutput += line + "\n";
}
} catch (IOException e) {
Logger.error(e.toString());
return "Error while reading logfile";
}
return logOutput;
}
private static void junkbot(String command, String[] inString) {
String outString;
Writer fileWriter;
if (inString == null)
return;
;
outString = command + String.join(" ", inString);
outString += "\n";
try {
fileWriter = new BufferedWriter(new FileWriter("junkbot.txt", true));
fileWriter.append(outString);
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void SendAdminLogUpdates() {
HashMap<Integer, String> adminEvents = database.getAdminEvents();
for (int adminEvent : adminEvents.keySet()) {
// Set event as read
database.setAdminEventAsRead(adminEvent);
String outString =
"```\n" + "Hello Players \n\n" +
adminEvents.get(adminEvent) + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```";
if (ADMINLOG.textChannel.canTalk())
ADMINLOG.textChannel.sendMessage(outString).queue();
}
}
} }

3
src/discord/handlers/ChatChannelHandler.java

@ -42,7 +42,8 @@ public class ChatChannelHandler {
"```\n" + "Hello Players \n\n" + "```\n" + "Hello Players \n\n" +
chatText.substring(3) + "\n\n" + chatText.substring(3) + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```"; RobotSpeak.getRobotSpeak() + "\n```";
else outString = chatText; else
outString = chatText;
// Write string to changelog channel // Write string to changelog channel

7
src/discord/handlers/DevRequestHandler.java

@ -40,7 +40,7 @@ public class DevRequestHandler {
switch (serverCommand) { switch (serverCommand) {
case "build" : case "build":
commandString = "./mbdevbuild.sh"; commandString = "./mbdevbuild.sh";
break; break;
case "restart": case "restart":
@ -62,7 +62,7 @@ public class DevRequestHandler {
MagicBot.sendResponse(event, MagicBot.sendResponse(event,
"#dev build <target> (blank==master) \n" + "#dev build <target> (blank==master) \n" +
"#dev shutdown (Shutdown dev server)\n" + "#dev shutdown (Shutdown dev server)\n" +
"#dev restart (Restarts the server)\n"+ "#dev restart (Restarts the server)\n" +
"#dev debug (Restarts server in debug mode)\n" + "#dev debug (Restarts server in debug mode)\n" +
"#dev console # (Displays # lines from console)\n" + "#dev console # (Displays # lines from console)\n" +
"#dev lastout (Displays output from last command) \n"); "#dev lastout (Displays output from last command) \n");
@ -77,7 +77,7 @@ public class DevRequestHandler {
} }
processBuilder = new ProcessBuilder("/bin/sh", "-c", commandString + " " + commandArgument + " > devLastOut"); processBuilder = new ProcessBuilder("/bin/sh", "-c", commandString + " " + commandArgument + " > devLastOut");
logString = String.join(" ",processBuilder.command().toArray(new String[0])); logString = String.join(" ", processBuilder.command().toArray(new String[0]));
try { try {
processBuilder.start(); processBuilder.start();
@ -89,6 +89,7 @@ public class DevRequestHandler {
"Use #dev lastout to view results"); "Use #dev lastout to view results");
} }
private static String getLastOutput() { private static String getLastOutput() {
String outString = null; String outString = null;

320
src/engine/InterestManagement/HeightMap.java

@ -142,7 +142,7 @@ public class HeightMap {
this.bucketWidthX = 1; this.bucketWidthX = 1;
this.bucketWidthY = 1; this.bucketWidthY = 1;
this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY+1]; this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY + 1];
for (int y = 0; y <= this.fullExtentsY; y++) { for (int y = 0; y <= this.fullExtentsY; y++) {
for (int x = 0; x <= this.fullExtentsX; x++) { for (int x = 0; x <= this.fullExtentsX; x++) {
@ -180,7 +180,7 @@ public class HeightMap {
this.bucketWidthX = 1; this.bucketWidthX = 1;
this.bucketWidthY = 1; this.bucketWidthY = 1;
this.pixelColorValues = new int[this.fullExtentsX+1][this.fullExtentsY+1]; this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY + 1];
for (int y = 0; y <= this.fullExtentsY; y++) { for (int y = 0; y <= this.fullExtentsY; y++) {
for (int x = 0; x <= this.fullExtentsX; x++) { for (int x = 0; x <= this.fullExtentsX; x++) {
@ -206,88 +206,6 @@ public class HeightMap {
} }
public Vector2f getGridSquare(Vector2f zoneLoc) {
if (zoneLoc.x < 0)
zoneLoc.setX(0);
if (zoneLoc.x > this.fullExtentsX - 1)
zoneLoc.setX((this.fullExtentsX - 1) + .9999999f);
if (zoneLoc.y < 0)
zoneLoc.setY(0);
if (zoneLoc.y > this.fullExtentsY - 1)
zoneLoc.setY((this.fullExtentsY - 1) + .9999999f);
float xBucket = (zoneLoc.x / this.bucketWidthX);
float yBucket = (zoneLoc.y / this.bucketWidthY);
return new Vector2f(xBucket, yBucket);
}
public float getInterpolatedTerrainHeight(Vector2f zoneLoc) {
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
int maxX = (int) (this.fullExtentsX / this.bucketWidthX);
int maxY = (int) (this.fullExtentsY / this.bucketWidthY);
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
if (gridX > maxX)
gridX = maxX;
if (gridY > maxY)
gridY = maxY;
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = 0;
float topRightHeight = 0;
float bottomLeftHeight = 0;
float bottomRightHeight = 0;
int nextY = gridY +1;
int nextX = gridX + 1;
if (nextY > maxY)
nextY = gridY;
if (nextX > maxX)
nextX = gridX;
topLeftHeight = pixelColorValues[gridX][gridY];
topRightHeight = pixelColorValues[nextX][gridY];
bottomLeftHeight = pixelColorValues[gridX][nextY];
bottomRightHeight = pixelColorValues[nextX][nextY];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
public static Zone getNextZoneWithTerrain(Zone zone) { public static Zone getNextZoneWithTerrain(Zone zone) {
Zone nextZone = zone; Zone nextZone = zone;
@ -505,48 +423,6 @@ public class HeightMap {
return realWorldAltitude; return realWorldAltitude;
} }
public float getInterpolatedTerrainHeight(Vector3fImmutable zoneLoc3f) {
Vector2f zoneLoc = new Vector2f(zoneLoc3f.x, zoneLoc3f.z);
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = pixelColorValues[gridX][gridY];
float topRightHeight = pixelColorValues[gridX + 1][gridY];
float bottomLeftHeight = pixelColorValues[gridX][gridY + 1];
float bottomRightHeight = pixelColorValues[gridX + 1][gridY + 1];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
public static float getOutsetHeight(float interpolatedAltitude, Zone zone, Vector3fImmutable worldLocation) { public static float getOutsetHeight(float interpolatedAltitude, Zone zone, Vector3fImmutable worldLocation) {
Vector2f parentLoc; Vector2f parentLoc;
@ -620,24 +496,6 @@ public class HeightMap {
return outsetALt; return outsetALt;
} }
private void generatePixelData() {
Color color;
// Generate altitude lookup table for this heightmap
this.pixelColorValues = new int[this.heightmapImage.getWidth()][this.heightmapImage.getHeight()];
for (int y = 0; y < this.heightmapImage.getHeight(); y++) {
for (int x = 0; x < this.heightmapImage.getWidth(); x++) {
color = new Color(this.heightmapImage.getRGB(x, y));
pixelColorValues[x][y] = color.getRed();
}
}
}
public static Vector2f getGridOffset(Vector2f gridSquare) { public static Vector2f getGridOffset(Vector2f gridSquare) {
int floorX = (int) gridSquare.x; int floorX = (int) gridSquare.x;
@ -647,11 +505,6 @@ public class HeightMap {
} }
public float getScaledHeightForColor(float color) {
return (color / 256) * this.maxHeight;
}
public static void loadAlHeightMaps() { public static void loadAlHeightMaps() {
// Load the heightmaps into staging hashmap keyed by HashMapID // Load the heightmaps into staging hashmap keyed by HashMapID
@ -672,6 +525,164 @@ public class HeightMap {
Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached."); Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached.");
} }
public static boolean isLocUnderwater(Vector3fImmutable currentLoc) {
float localAltitude = HeightMap.getWorldHeight(currentLoc);
Zone zone = ZoneManager.findSmallestZone(currentLoc);
if (localAltitude < zone.getSeaLevel())
return true;
return false;
}
public Vector2f getGridSquare(Vector2f zoneLoc) {
if (zoneLoc.x < 0)
zoneLoc.setX(0);
if (zoneLoc.x > this.fullExtentsX - 1)
zoneLoc.setX((this.fullExtentsX - 1) + .9999999f);
if (zoneLoc.y < 0)
zoneLoc.setY(0);
if (zoneLoc.y > this.fullExtentsY - 1)
zoneLoc.setY((this.fullExtentsY - 1) + .9999999f);
float xBucket = (zoneLoc.x / this.bucketWidthX);
float yBucket = (zoneLoc.y / this.bucketWidthY);
return new Vector2f(xBucket, yBucket);
}
public float getInterpolatedTerrainHeight(Vector2f zoneLoc) {
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
int maxX = (int) (this.fullExtentsX / this.bucketWidthX);
int maxY = (int) (this.fullExtentsY / this.bucketWidthY);
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
if (gridX > maxX)
gridX = maxX;
if (gridY > maxY)
gridY = maxY;
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = 0;
float topRightHeight = 0;
float bottomLeftHeight = 0;
float bottomRightHeight = 0;
int nextY = gridY + 1;
int nextX = gridX + 1;
if (nextY > maxY)
nextY = gridY;
if (nextX > maxX)
nextX = gridX;
topLeftHeight = pixelColorValues[gridX][gridY];
topRightHeight = pixelColorValues[nextX][gridY];
bottomLeftHeight = pixelColorValues[gridX][nextY];
bottomRightHeight = pixelColorValues[nextX][nextY];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
public float getInterpolatedTerrainHeight(Vector3fImmutable zoneLoc3f) {
Vector2f zoneLoc = new Vector2f(zoneLoc3f.x, zoneLoc3f.z);
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = pixelColorValues[gridX][gridY];
float topRightHeight = pixelColorValues[gridX + 1][gridY];
float bottomLeftHeight = pixelColorValues[gridX][gridY + 1];
float bottomRightHeight = pixelColorValues[gridX + 1][gridY + 1];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
private void generatePixelData() {
Color color;
// Generate altitude lookup table for this heightmap
this.pixelColorValues = new int[this.heightmapImage.getWidth()][this.heightmapImage.getHeight()];
for (int y = 0; y < this.heightmapImage.getHeight(); y++) {
for (int x = 0; x < this.heightmapImage.getWidth(); x++) {
color = new Color(this.heightmapImage.getRGB(x, y));
pixelColorValues[x][y] = color.getRed();
}
}
}
public float getScaledHeightForColor(float color) {
return (color / 256) * this.maxHeight;
}
public float getBucketWidthX() { public float getBucketWidthX() {
return bucketWidthX; return bucketWidthX;
} }
@ -692,15 +703,4 @@ public class HeightMap {
return seaLevel; return seaLevel;
} }
public static boolean isLocUnderwater(Vector3fImmutable currentLoc) {
float localAltitude = HeightMap.getWorldHeight(currentLoc);
Zone zone = ZoneManager.findSmallestZone(currentLoc);
if (localAltitude < zone.getSeaLevel())
return true;
return false;
}
} }

246
src/engine/InterestManagement/InterestManager.java

@ -38,14 +38,128 @@ public enum InterestManager implements Runnable {
private static long lastTime; private static long lastTime;
private static boolean keepGoing = true; private static boolean keepGoing = true;
public void shutdown() {
this.keepGoing = false;
}
InterestManager() { InterestManager() {
Logger.info(" Interest Management thread is running."); Logger.info(" Interest Management thread is running.");
} }
public static void forceLoad(AbstractWorldObject awo) {
AbstractNetMsg msg = null;
LoadStructureMsg lsm;
LoadCharacterMsg lcm;
NPC npc;
Corpse corpse;
HashSet<AbstractWorldObject> toUpdate;
switch (awo.getObjectType()) {
case Building:
lsm = new LoadStructureMsg();
lsm.addObject((Building) awo);
msg = lsm;
break;
case Corpse:
corpse = (Corpse) awo;
lcm = new LoadCharacterMsg(corpse, false);
msg = lcm;
break;
case NPC:
npc = (NPC) awo;
lcm = new LoadCharacterMsg(npc, false);
msg = lcm;
break;
default:
return;
}
toUpdate = WorldGrid.getObjectsInRangePartial(awo.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER);
boolean send;
for (AbstractWorldObject tar : toUpdate) {
PlayerCharacter player = (PlayerCharacter) tar;
HashSet<AbstractWorldObject> loadedStaticObjects = player.getLoadedStaticObjects();
send = false;
if (!loadedStaticObjects.contains(awo)) {
loadedStaticObjects.add(awo);
send = true;
}
if (send) {
Dispatch dispatch = Dispatch.borrow(player, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
}
}
}
public static void HandleSpecialUnload(Building building, ClientConnection origin) {
if (Regions.FurnitureRegionMap.get(building.getObjectUUID()) == null)
return;
Regions buildingRegion = Regions.FurnitureRegionMap.get(building.getObjectUUID());
if (!buildingRegion.isOutside())
return;
MoveToPointMsg moveMsg = new MoveToPointMsg(building);
if (origin != null)
origin.sendMsg(moveMsg);
}
public static void reloadCharacter(AbstractCharacter absChar) {
UnloadObjectsMsg uom = new UnloadObjectsMsg();
uom.addObject(absChar);
LoadCharacterMsg lcm = new LoadCharacterMsg(absChar, false);
HashSet<AbstractWorldObject> toSend = WorldGrid.getObjectsInRangePartial(absChar.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE,
MBServerStatics.MASK_PLAYER);
PlayerCharacter pc = null;
if (absChar.getObjectType().equals(GameObjectType.PlayerCharacter))
pc = (PlayerCharacter) absChar;
for (AbstractWorldObject awo : toSend) {
PlayerCharacter pcc = (PlayerCharacter) awo;
if (pcc == null)
continue;
ClientConnection cc = SessionManager.getClientConnection(pcc);
if (cc == null)
continue;
if (pcc.getObjectUUID() == absChar.getObjectUUID())
continue;
else {
if (pc != null)
if (pcc.getSeeInvis() < pc.getHidden())
continue;
if (!cc.sendMsg(uom)) {
String classType = uom.getClass().getSimpleName();
Logger.error("Failed to send message ");
}
if (!cc.sendMsg(lcm)) {
String classType = lcm.getClass().getSimpleName();
Logger.error("Failed to send message");
}
}
}
}
public void shutdown() {
this.keepGoing = false;
}
@Override @Override
public void run() { public void run() {
beginLoadJob(); beginLoadJob();
@ -84,6 +198,9 @@ public enum InterestManager implements Runnable {
return dur; return dur;
} }
// Forces the loading of static objects (corpses and buildings).
// Needed to override threshold limits on loading statics
private void updateAllPlayers() { private void updateAllPlayers() {
// get all players // get all players
@ -341,7 +458,7 @@ public enum InterestManager implements Runnable {
awonpc.playerAgroMap.put(player.getObjectUUID(), false); awonpc.playerAgroMap.put(player.getObjectUUID(), false);
//MobileFSM.setAwake(awonpc, false); //MobileFSM.setAwake(awonpc, false);
((Mob)awonpc).setCombatTarget(null); ((Mob) awonpc).setCombatTarget(null);
// IVarController.setVariable(awonpc, "IntelligenceDisableDelay", (double) (System.currentTimeMillis() + 5000)); // IVarController.setVariable(awonpc, "IntelligenceDisableDelay", (double) (System.currentTimeMillis() + 5000));
// awonpc.enableIntelligence(); // awonpc.enableIntelligence();
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii()); lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
@ -358,7 +475,7 @@ public enum InterestManager implements Runnable {
if (awonpc.isMob()) if (awonpc.isMob())
//MobileFSM.setAwake(awonpc, false); //MobileFSM.setAwake(awonpc, false);
((Mob)awonpc).setCombatTarget(null); ((Mob) awonpc).setCombatTarget(null);
// IVarController.setVariable(awonpc, "IntelligenceDisableDelay", (double) (System.currentTimeMillis() + 5000)); // IVarController.setVariable(awonpc, "IntelligenceDisableDelay", (double) (System.currentTimeMillis() + 5000));
// awonpc.enableIntelligence(); // awonpc.enableIntelligence();
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii()); lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
@ -385,76 +502,6 @@ public enum InterestManager implements Runnable {
//JobScheduler.getInstance().scheduleJob(new LoadEffectsJob(players, origin), MBServerStatics.LOAD_OBJECT_DELAY); //JobScheduler.getInstance().scheduleJob(new LoadEffectsJob(players, origin), MBServerStatics.LOAD_OBJECT_DELAY);
} }
// Forces the loading of static objects (corpses and buildings).
// Needed to override threshold limits on loading statics
public static void forceLoad(AbstractWorldObject awo) {
AbstractNetMsg msg = null;
LoadStructureMsg lsm;
LoadCharacterMsg lcm;
NPC npc;
Corpse corpse;
HashSet<AbstractWorldObject> toUpdate;
switch (awo.getObjectType()) {
case Building:
lsm = new LoadStructureMsg();
lsm.addObject((Building) awo);
msg = lsm;
break;
case Corpse:
corpse = (Corpse) awo;
lcm = new LoadCharacterMsg(corpse, false);
msg = lcm;
break;
case NPC:
npc = (NPC) awo;
lcm = new LoadCharacterMsg(npc, false);
msg = lcm;
break;
default:
return;
}
toUpdate = WorldGrid.getObjectsInRangePartial(awo.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER);
boolean send;
for (AbstractWorldObject tar : toUpdate) {
PlayerCharacter player = (PlayerCharacter) tar;
HashSet<AbstractWorldObject> loadedStaticObjects = player.getLoadedStaticObjects();
send = false;
if (!loadedStaticObjects.contains(awo)) {
loadedStaticObjects.add(awo);
send = true;
}
if (send) {
Dispatch dispatch = Dispatch.borrow(player, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
}
}
}
public static void HandleSpecialUnload(Building building, ClientConnection origin) {
if (Regions.FurnitureRegionMap.get(building.getObjectUUID()) == null)
return;
Regions buildingRegion = Regions.FurnitureRegionMap.get(building.getObjectUUID());
if (!buildingRegion.isOutside())
return;
MoveToPointMsg moveMsg = new MoveToPointMsg(building);
if (origin != null)
origin.sendMsg(moveMsg);
}
public synchronized void HandleLoadForEnterWorld(PlayerCharacter player) { public synchronized void HandleLoadForEnterWorld(PlayerCharacter player) {
if (player == null) if (player == null)
@ -504,51 +551,4 @@ public enum InterestManager implements Runnable {
Logger.error("InterestManager.updateAllMobilePlayers: " + player.getObjectUUID(), e); Logger.error("InterestManager.updateAllMobilePlayers: " + player.getObjectUUID(), e);
} }
} }
public static void reloadCharacter(AbstractCharacter absChar) {
UnloadObjectsMsg uom = new UnloadObjectsMsg();
uom.addObject(absChar);
LoadCharacterMsg lcm = new LoadCharacterMsg(absChar, false);
HashSet<AbstractWorldObject> toSend = WorldGrid.getObjectsInRangePartial(absChar.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE,
MBServerStatics.MASK_PLAYER);
PlayerCharacter pc = null;
if (absChar.getObjectType().equals(GameObjectType.PlayerCharacter))
pc = (PlayerCharacter) absChar;
for (AbstractWorldObject awo : toSend) {
PlayerCharacter pcc = (PlayerCharacter) awo;
if (pcc == null)
continue;
ClientConnection cc = SessionManager.getClientConnection(pcc);
if (cc == null)
continue;
if (pcc.getObjectUUID() == absChar.getObjectUUID())
continue;
else {
if (pc != null)
if (pcc.getSeeInvis() < pc.getHidden())
continue;
if (!cc.sendMsg(uom)) {
String classType = uom.getClass().getSimpleName();
Logger.error("Failed to send message ");
}
if (!cc.sendMsg(lcm)) {
String classType = lcm.getClass().getSimpleName();
Logger.error("Failed to send message");
}
}
}
}
} }

2
src/engine/InterestManagement/RealmMap.java

@ -36,8 +36,8 @@ public enum RealmMap {
// Spatial hashmap. Used for determining which Realm // Spatial hashmap. Used for determining which Realm
// a player is currently located within. // a player is currently located within.
public static int[][] _realmImageMap;
private static final HashMap<Color, Integer> _rgbToIDMap = new HashMap<>(); private static final HashMap<Color, Integer> _rgbToIDMap = new HashMap<>();
public static int[][] _realmImageMap;
public static int getRealmIDByColor(Color color) { public static int getRealmIDByColor(Color color) {

68
src/engine/InterestManagement/WorldGrid.java

@ -26,10 +26,11 @@ import java.util.concurrent.ConcurrentHashMap;
public class WorldGrid { public class WorldGrid {
public static ConcurrentHashMap<Integer,AbstractWorldObject>[][] DynamicGridMap; public static ConcurrentHashMap<Integer, AbstractWorldObject>[][] DynamicGridMap;
public static ConcurrentHashMap<Integer,AbstractWorldObject>[][] StaticGridMap; public static ConcurrentHashMap<Integer, AbstractWorldObject>[][] StaticGridMap;
private static float dynamicBucketScale = 0.00390625f; // 256 bucket size, 1/256 private static float dynamicBucketScale = 0.00390625f; // 256 bucket size, 1/256
private static float staticBucketScale = 0.00390625f; private static float staticBucketScale = 0.00390625f;
public static void startLoadJob() { public static void startLoadJob() {
Thread loadJobThread; Thread loadJobThread;
@ -59,16 +60,15 @@ public class WorldGrid {
else else
scale = WorldGrid.dynamicBucketScale; scale = WorldGrid.dynamicBucketScale;
int gridX = (int) Math.abs(loc.x * scale); int gridX = (int) Math.abs(loc.x * scale);
int gridZ = (int)Math.abs(loc.z * scale); int gridZ = (int) Math.abs(loc.z * scale);
int bucketSize = (int) (r *scale) + 1; int bucketSize = (int) (r * scale) + 1;
//start at top left most corner to scan. //start at top left most corner to scan.
int startingX = gridX - bucketSize; int startingX = gridX - bucketSize;
int startingZ = gridZ + bucketSize; int startingZ = gridZ + bucketSize;
int limitX = Math.abs((int) (MBServerStatics.MAX_WORLD_WIDTH * scale));
int limitX = Math.abs((int) (MBServerStatics.MAX_WORLD_WIDTH *scale)); int limitZ = Math.abs((int) (MBServerStatics.MAX_WORLD_HEIGHT * scale)); //LimitZ is negative, remember to flip sign.
int limitZ = Math.abs((int) (MBServerStatics.MAX_WORLD_HEIGHT *scale)); //LimitZ is negative, remember to flip sign.
if (startingX < 0) if (startingX < 0)
startingX = 0; startingX = 0;
@ -98,16 +98,16 @@ public class WorldGrid {
endZ = limitZ; endZ = limitZ;
int auditMob = 0; int auditMob = 0;
for (int x = startingX;x<=endX;x++){ for (int x = startingX; x <= endX; x++) {
for (int z = startingZ;z >= endZ;z--){ for (int z = startingZ; z >= endZ; z--) {
ConcurrentHashMap<Integer,AbstractWorldObject> gridMap; ConcurrentHashMap<Integer, AbstractWorldObject> gridMap;
if ((MBServerStatics.MASK_STATIC & mask) != 0) if ((MBServerStatics.MASK_STATIC & mask) != 0)
gridMap = WorldGrid.StaticGridMap[x][z]; gridMap = WorldGrid.StaticGridMap[x][z];
else else
gridMap = WorldGrid.DynamicGridMap[x][z]; gridMap = WorldGrid.DynamicGridMap[x][z];
for (AbstractWorldObject gridObject: gridMap.values()){ for (AbstractWorldObject gridObject : gridMap.values()) {
if ((gridObject.getObjectTypeMask() & mask) == 0) if ((gridObject.getObjectTypeMask() & mask) == 0)
continue; continue;
if (gridObject.getLoc().distanceSquared2D(loc) <= FastMath.sqr(r)) if (gridObject.getLoc().distanceSquared2D(loc) <= FastMath.sqr(r))
@ -124,7 +124,7 @@ public class WorldGrid {
} }
public static HashSet<AbstractWorldObject> getObjectsInRangeContains(Vector3fImmutable loc, double r, int mask) { public static HashSet<AbstractWorldObject> getObjectsInRangeContains(Vector3fImmutable loc, double r, int mask) {
HashSet<AbstractWorldObject> outbound = getObjectsInRangePartial(loc,r,mask); HashSet<AbstractWorldObject> outbound = getObjectsInRangePartial(loc, r, mask);
return outbound; return outbound;
} }
@ -133,36 +133,36 @@ public class WorldGrid {
} }
public static void InitializeGridObjects(){ public static void InitializeGridObjects() {
int dynamicWidth = (int) Math.abs(MBServerStatics.MAX_WORLD_WIDTH *WorldGrid.dynamicBucketScale); int dynamicWidth = (int) Math.abs(MBServerStatics.MAX_WORLD_WIDTH * WorldGrid.dynamicBucketScale);
int dynamicHeight = (int) Math.abs(MBServerStatics.MAX_WORLD_HEIGHT*WorldGrid.dynamicBucketScale); int dynamicHeight = (int) Math.abs(MBServerStatics.MAX_WORLD_HEIGHT * WorldGrid.dynamicBucketScale);
int staticWidth = (int) Math.abs(MBServerStatics.MAX_WORLD_WIDTH *WorldGrid.staticBucketScale); int staticWidth = (int) Math.abs(MBServerStatics.MAX_WORLD_WIDTH * WorldGrid.staticBucketScale);
int staticHeight = (int) Math.abs(MBServerStatics.MAX_WORLD_HEIGHT*WorldGrid.staticBucketScale); int staticHeight = (int) Math.abs(MBServerStatics.MAX_WORLD_HEIGHT * WorldGrid.staticBucketScale);
WorldGrid.DynamicGridMap = new ConcurrentHashMap[dynamicWidth+ 1][dynamicHeight + 1]; WorldGrid.DynamicGridMap = new ConcurrentHashMap[dynamicWidth + 1][dynamicHeight + 1];
WorldGrid.StaticGridMap = new ConcurrentHashMap[staticWidth + 1][staticHeight + 1]; WorldGrid.StaticGridMap = new ConcurrentHashMap[staticWidth + 1][staticHeight + 1];
//create new hash maps for each bucket //create new hash maps for each bucket
for (int x = 0; x<= staticWidth; x++) for (int x = 0; x <= staticWidth; x++)
for (int y = 0; y<= staticHeight; y++){ for (int y = 0; y <= staticHeight; y++) {
WorldGrid.StaticGridMap[x][y] = new ConcurrentHashMap<Integer,AbstractWorldObject>(); WorldGrid.StaticGridMap[x][y] = new ConcurrentHashMap<Integer, AbstractWorldObject>();
} }
for (int x = 0; x<= dynamicWidth; x++) for (int x = 0; x <= dynamicWidth; x++)
for (int y = 0; y<= dynamicHeight; y++){ for (int y = 0; y <= dynamicHeight; y++) {
WorldGrid.DynamicGridMap[x][y] = new ConcurrentHashMap<Integer,AbstractWorldObject>(); WorldGrid.DynamicGridMap[x][y] = new ConcurrentHashMap<Integer, AbstractWorldObject>();
} }
} }
public static void RemoveWorldObject(AbstractWorldObject gridObject){ public static void RemoveWorldObject(AbstractWorldObject gridObject) {
if (gridObject == null) if (gridObject == null)
return; return;
AbstractWorldObject.RemoveFromWorldGrid(gridObject); AbstractWorldObject.RemoveFromWorldGrid(gridObject);
} }
public static boolean addObject(AbstractWorldObject gridObject, float x, float z){ public static boolean addObject(AbstractWorldObject gridObject, float x, float z) {
if (gridObject == null) if (gridObject == null)
return false; return false;
@ -181,12 +181,12 @@ public class WorldGrid {
int gridX; int gridX;
int gridZ; int gridZ;
if (gridObject.getGridObjectType().equals(GridObjectType.STATIC)){ if (gridObject.getGridObjectType().equals(GridObjectType.STATIC)) {
gridX = Math.abs((int) (x *WorldGrid.staticBucketScale)); gridX = Math.abs((int) (x * WorldGrid.staticBucketScale));
gridZ = Math.abs((int) (z*WorldGrid.staticBucketScale)); gridZ = Math.abs((int) (z * WorldGrid.staticBucketScale));
}else{ } else {
gridX = Math.abs((int) (x *WorldGrid.dynamicBucketScale)); gridX = Math.abs((int) (x * WorldGrid.dynamicBucketScale));
gridZ = Math.abs((int) (z*WorldGrid.dynamicBucketScale)); gridZ = Math.abs((int) (z * WorldGrid.dynamicBucketScale));
} }
@ -212,7 +212,7 @@ public class WorldGrid {
switch (awo.getObjectType()) { switch (awo.getObjectType()) {
case Building: case Building:
lsm = new LoadStructureMsg(); lsm = new LoadStructureMsg();
lsm.addObject((Building)awo); lsm.addObject((Building) awo);
DispatchMessage.sendToAllInRange(awo, lsm); DispatchMessage.sendToAllInRange(awo, lsm);
break; break;
case NPC: case NPC:
@ -238,7 +238,7 @@ public class WorldGrid {
case Building: case Building:
lsm = new LoadStructureMsg(); lsm = new LoadStructureMsg();
lsm.addObject((Building)awo); lsm.addObject((Building) awo);
DispatchMessage.sendToAllInRange(awo, lsm); DispatchMessage.sendToAllInRange(awo, lsm);
break; break;
case NPC: case NPC:

121
src/engine/ai/MobileFSM.java

@ -6,6 +6,7 @@
// Magicbane Emulator Project © 2013 - 2022 // Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com // www.magicbane.com
package engine.ai; package engine.ai;
import engine.Enum; import engine.Enum;
import engine.Enum.DispatchChannel; import engine.Enum.DispatchChannel;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
@ -22,12 +23,15 @@ import engine.objects.*;
import engine.powers.ActionsBase; import engine.powers.ActionsBase;
import engine.powers.PowersBase; import engine.powers.PowersBase;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import static engine.math.FastMath.sqr; import static engine.math.FastMath.sqr;
public class MobileFSM { public class MobileFSM {
private static void AttackTarget(Mob mob, AbstractWorldObject target) { private static void AttackTarget(Mob mob, AbstractWorldObject target) {
if (mob == null) if (mob == null)
@ -36,8 +40,8 @@ public class MobileFSM {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
} }
if(target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)){ if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) {
if(MobCast(mob)){ if (MobCast(mob)) {
return; return;
} }
} }
@ -58,8 +62,9 @@ public class MobileFSM {
break; break;
} }
} }
public static void AttackPlayer(Mob mob, PlayerCharacter target) { public static void AttackPlayer(Mob mob, PlayerCharacter target) {
if(!mob.canSee(target)){ if (!mob.canSee(target)) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
} }
@ -100,6 +105,7 @@ public class MobileFSM {
} }
} }
} }
public static void AttackBuilding(Mob mob, Building target) { public static void AttackBuilding(Mob mob, Building target) {
if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
@ -140,6 +146,7 @@ public class MobileFSM {
DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
} }
} }
public static void AttackMob(Mob mob, Mob target) { public static void AttackMob(Mob mob, Mob target) {
if (mob.getRange() >= 30 && mob.isMoving()) if (mob.getRange() >= 30 && mob.isMoving())
return; return;
@ -166,6 +173,7 @@ public class MobileFSM {
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
} }
} }
private static void Patrol(Mob mob) { private static void Patrol(Mob mob) {
//make sure mob is out of combat stance //make sure mob is out of combat stance
if (mob.isCombat() && mob.getCombatTarget() == null) { if (mob.isCombat() && mob.getCombatTarget() == null) {
@ -174,7 +182,7 @@ public class MobileFSM {
rwss.setPlayer(mob); rwss.setPlayer(mob);
DispatchMessage.sendToAllInRange(mob, rwss); DispatchMessage.sendToAllInRange(mob, rwss);
} }
int patrolDelay = ThreadLocalRandom.current().nextInt((int)(MobileFSMManager.AI_PATROL_DIVISOR * 0.5f), MobileFSMManager.AI_PATROL_DIVISOR) + MobileFSMManager.AI_PATROL_DIVISOR; int patrolDelay = ThreadLocalRandom.current().nextInt((int) (MobileFSMManager.AI_PATROL_DIVISOR * 0.5f), MobileFSMManager.AI_PATROL_DIVISOR) + MobileFSMManager.AI_PATROL_DIVISOR;
if (mob.stopPatrolTime + (patrolDelay * 1000) > System.currentTimeMillis()) if (mob.stopPatrolTime + (patrolDelay * 1000) > System.currentTimeMillis())
//early exit while waiting to patrol again //early exit while waiting to patrol again
return; return;
@ -183,7 +191,7 @@ public class MobileFSM {
Building barracks = mob.building; Building barracks = mob.building;
if (barracks != null && barracks.patrolPoints != null && !barracks.getPatrolPoints().isEmpty()) { if (barracks != null && barracks.patrolPoints != null && !barracks.getPatrolPoints().isEmpty()) {
mob.patrolPoints = barracks.patrolPoints; mob.patrolPoints = barracks.patrolPoints;
} else{ } else {
randomGuardPatrolPoint(mob); randomGuardPatrolPoint(mob);
return; return;
} }
@ -194,7 +202,7 @@ public class MobileFSM {
mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex); mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex);
mob.lastPatrolPointIndex += 1; mob.lastPatrolPointIndex += 1;
MovementUtilities.aiMove(mob, mob.destination, true); MovementUtilities.aiMove(mob, mob.destination, true);
if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()){ if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) { for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
//make sure mob is out of combat stance //make sure mob is out of combat stance
if (minion.getKey().despawned == false) { if (minion.getKey().despawned == false) {
@ -214,6 +222,7 @@ public class MobileFSM {
} }
} }
} }
public static boolean canCast(Mob mob) { public static boolean canCast(Mob mob) {
// Performs validation to determine if a // Performs validation to determine if a
// mobile in the proper state to cast. // mobile in the proper state to cast.
@ -221,7 +230,7 @@ public class MobileFSM {
return false; return false;
if (mob.mobPowers.isEmpty()) if (mob.mobPowers.isEmpty())
return false; return false;
if(!mob.canSee((PlayerCharacter) mob.getCombatTarget())){ if (!mob.canSee((PlayerCharacter) mob.getCombatTarget())) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return false; return false;
} }
@ -229,6 +238,7 @@ public class MobileFSM {
mob.nextCastTime = System.currentTimeMillis(); mob.nextCastTime = System.currentTimeMillis();
return mob.nextCastTime <= System.currentTimeMillis(); return mob.nextCastTime <= System.currentTimeMillis();
} }
public static boolean MobCast(Mob mob) { public static boolean MobCast(Mob mob) {
// Method picks a random spell from a mobile's list of powers // Method picks a random spell from a mobile's list of powers
// and casts it on the current target (or itself). Validation // and casts it on the current target (or itself). Validation
@ -261,7 +271,7 @@ public class MobileFSM {
int powerRank = mob.mobPowers.get(powerToken); int powerRank = mob.mobPowers.get(powerToken);
PowersBase mobPower = PowersManager.getPowerByToken(powerToken); PowersBase mobPower = PowersManager.getPowerByToken(powerToken);
//check for hit-roll //check for hit-roll
if(mobPower.requiresHitRoll) { if (mobPower.requiresHitRoll) {
if (CombatUtilities.triggerDefense(mob, mob.getCombatTarget())) { if (CombatUtilities.triggerDefense(mob, mob.getCombatTarget())) {
return false; return false;
} }
@ -291,6 +301,7 @@ public class MobileFSM {
} }
return false; return false;
} }
public static void MobCallForHelp(Mob mob) { public static void MobCallForHelp(Mob mob) {
boolean callGotResponse = false; boolean callGotResponse = false;
if (mob.nextCallForHelp == 0) { if (mob.nextCallForHelp == 0) {
@ -311,6 +322,7 @@ public class MobileFSM {
//wait 60 seconds to call for help again //wait 60 seconds to call for help again
mob.nextCallForHelp = System.currentTimeMillis() + 60000; mob.nextCallForHelp = System.currentTimeMillis() + 60000;
} }
public static void DetermineAction(Mob mob) { public static void DetermineAction(Mob mob) {
if (mob == null) if (mob == null)
return; return;
@ -321,10 +333,10 @@ public class MobileFSM {
} }
if (mob.despawned && mob.isPlayerGuard) { if (mob.despawned && mob.isPlayerGuard) {
//override for guards //override for guards
if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()){ if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if(mob.npcOwner.isAlive() == false || ((Mob)mob.npcOwner).despawned == true){ if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) {
//minions don't respawn while guard captain is dead //minions don't respawn while guard captain is dead
if(mob.isAlive() == false) { if (mob.isAlive() == false) {
mob.deathTime = System.currentTimeMillis(); mob.deathTime = System.currentTimeMillis();
return; return;
} }
@ -351,7 +363,7 @@ public class MobileFSM {
} }
mob.updateLocation(); mob.updateLocation();
CheckToSendMobHome(mob); CheckToSendMobHome(mob);
if(mob.combatTarget != null && mob.combatTarget.isAlive() == false){ if (mob.combatTarget != null && mob.combatTarget.isAlive() == false) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
} }
switch (mob.BehaviourType) { switch (mob.BehaviourType) {
@ -375,6 +387,7 @@ public class MobileFSM {
break; break;
} }
} }
private static void CheckForAggro(Mob aiAgent) { private static void CheckForAggro(Mob aiAgent) {
//looks for and sets mobs combatTarget //looks for and sets mobs combatTarget
if (!aiAgent.isAlive()) if (!aiAgent.isAlive())
@ -405,10 +418,11 @@ public class MobileFSM {
} }
} }
} }
private static void CheckMobMovement(Mob mob) { private static void CheckMobMovement(Mob mob) {
if (!MovementUtilities.canMove(mob)) if (!MovementUtilities.canMove(mob))
return; return;
switch(mob.BehaviourType){ switch (mob.BehaviourType) {
case Pet1: case Pet1:
if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) { if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) {
//mob no longer has its owner loaded, translocate pet to owner //mob no longer has its owner loaded, translocate pet to owner
@ -425,27 +439,28 @@ public class MobileFSM {
chaseTarget(mob); chaseTarget(mob);
break; break;
case GuardMinion: case GuardMinion:
if (!mob.npcOwner.isAlive() || ((Mob)mob.npcOwner).despawned) if (!mob.npcOwner.isAlive() || ((Mob) mob.npcOwner).despawned)
randomGuardPatrolPoint(mob); randomGuardPatrolPoint(mob);
else{ else {
if(mob.getCombatTarget() != null){ if (mob.getCombatTarget() != null) {
chaseTarget(mob); chaseTarget(mob);
} }
} }
break; break;
default: default:
if (mob.getCombatTarget() == null) { if (mob.getCombatTarget() == null) {
if(!mob.isMoving()) { if (!mob.isMoving()) {
Patrol(mob); Patrol(mob);
} else{ } else {
mob.stopPatrolTime = System.currentTimeMillis(); mob.stopPatrolTime = System.currentTimeMillis();
} }
}else { } else {
chaseTarget(mob); chaseTarget(mob);
} }
break; break;
} }
} }
private static void CheckForRespawn(Mob aiAgent) { private static void CheckForRespawn(Mob aiAgent) {
if (aiAgent.deathTime == 0) { if (aiAgent.deathTime == 0) {
aiAgent.setDeathTime(System.currentTimeMillis()); aiAgent.setDeathTime(System.currentTimeMillis());
@ -479,14 +494,15 @@ public class MobileFSM {
aiAgent.respawn(); aiAgent.respawn();
} }
} }
public static void CheckForAttack(Mob mob) { public static void CheckForAttack(Mob mob) {
//checks if mob can attack based on attack timer and range //checks if mob can attack based on attack timer and range
if (mob.isAlive() == false) if (mob.isAlive() == false)
return; return;
if(mob.getCombatTarget() == null){ if (mob.getCombatTarget() == null) {
return; return;
} }
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter)mob.getCombatTarget()) == false) { if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
if (mob.isCombat()) { if (mob.isCombat()) {
mob.setCombat(false); mob.setCombat(false);
@ -505,18 +521,18 @@ public class MobileFSM {
if (System.currentTimeMillis() > mob.getLastAttackTime()) if (System.currentTimeMillis() > mob.getLastAttackTime())
AttackTarget(mob, mob.getCombatTarget()); AttackTarget(mob, mob.getCombatTarget());
} }
private static void CheckToSendMobHome(Mob mob) { private static void CheckToSendMobHome(Mob mob) {
if(mob.BehaviourType.isAgressive) { if (mob.BehaviourType.isAgressive) {
if(mob.isPlayerGuard()) if (mob.isPlayerGuard()) {
{ if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()){
CheckForPlayerGuardAggro(mob); CheckForPlayerGuardAggro(mob);
} }
} else { } else {
CheckForAggro(mob); CheckForAggro(mob);
} }
} }
if(mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob,mob.getCombatTarget(), MobileFSMManager.AI_BASE_AGGRO_RANGE * 0.5f)){ if (mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob, mob.getCombatTarget(), MobileFSMManager.AI_BASE_AGGRO_RANGE * 0.5f)) {
return; return;
} }
if (mob.isPlayerGuard() && !mob.despawned) { if (mob.isPlayerGuard() && !mob.despawned) {
@ -525,7 +541,7 @@ public class MobileFSM {
PowersBase recall = PowersManager.getPowerByToken(-1994153779); PowersBase recall = PowersManager.getPowerByToken(-1994153779);
PowersManager.useMobPower(mob, mob, recall, 40); PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null); mob.setCombatTarget(null);
if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()){ if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) {
//guard captain pulls his minions home with him //guard captain pulls his minions home with him
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) { for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
PowersManager.useMobPower(minion.getKey(), minion.getKey(), recall, 40); PowersManager.useMobPower(minion.getKey(), minion.getKey(), recall, 40);
@ -533,20 +549,20 @@ public class MobileFSM {
} }
} }
} }
} } else if (MovementUtilities.inRangeOfBindLocation(mob) == false) {
else if(MovementUtilities.inRangeOfBindLocation(mob) == false) {
PowersBase recall = PowersManager.getPowerByToken(-1994153779); PowersBase recall = PowersManager.getPowerByToken(-1994153779);
PowersManager.useMobPower(mob, mob, recall, 40); PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null); mob.setCombatTarget(null);
for (Entry playerEntry : mob.playerAgroMap.entrySet()) { for (Entry playerEntry : mob.playerAgroMap.entrySet()) {
PlayerCharacter.getFromCache((int)playerEntry.getKey()).setHateValue(0); PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0);
} }
} }
} }
private static void chaseTarget(Mob mob) { private static void chaseTarget(Mob mob) {
mob.updateMovementState(); mob.updateMovementState();
if(mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false){ if (mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
} }
@ -560,6 +576,7 @@ public class MobileFSM {
} }
} }
} }
private static void SafeGuardAggro(Mob mob) { private static void SafeGuardAggro(Mob mob) {
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB); HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB);
for (AbstractWorldObject awoMob : awoList) { for (AbstractWorldObject awoMob : awoList) {
@ -575,29 +592,33 @@ public class MobileFSM {
mob.setCombatTarget(aggroMob); mob.setCombatTarget(aggroMob);
} }
} }
public static void GuardCaptainLogic(Mob mob) { public static void GuardCaptainLogic(Mob mob) {
if (mob.getCombatTarget() == null) if (mob.getCombatTarget() == null)
CheckForPlayerGuardAggro(mob); CheckForPlayerGuardAggro(mob);
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
} }
public static void GuardMinionLogic(Mob mob) { public static void GuardMinionLogic(Mob mob) {
if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) { if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) {
CheckForPlayerGuardAggro(mob); CheckForPlayerGuardAggro(mob);
} }
if(mob.npcOwner.getCombatTarget() != null) if (mob.npcOwner.getCombatTarget() != null)
mob.setCombatTarget(mob.npcOwner.getCombatTarget()); mob.setCombatTarget(mob.npcOwner.getCombatTarget());
else else
mob.setCombatTarget(null); mob.setCombatTarget(null);
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
} }
public static void GuardWallArcherLogic(Mob mob) { public static void GuardWallArcherLogic(Mob mob) {
if (mob.getCombatTarget() == null) if (mob.getCombatTarget() == null)
CheckForPlayerGuardAggro(mob); CheckForPlayerGuardAggro(mob);
else else
CheckForAttack(mob); CheckForAttack(mob);
} }
private static void PetLogic(Mob mob) { private static void PetLogic(Mob mob) {
if (mob.getCombatTarget() != null && !mob.getCombatTarget().isAlive()) if (mob.getCombatTarget() != null && !mob.getCombatTarget().isAlive())
mob.setCombatTarget(null); mob.setCombatTarget(null);
@ -605,19 +626,21 @@ public class MobileFSM {
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
} }
private static void HamletGuardLogic(Mob mob) { private static void HamletGuardLogic(Mob mob) {
if (mob.getCombatTarget() == null) { if (mob.getCombatTarget() == null) {
//safehold guard //safehold guard
SafeGuardAggro(mob); SafeGuardAggro(mob);
} else{ } else {
if(mob.combatTarget.isAlive() == false){ if (mob.combatTarget.isAlive() == false) {
SafeGuardAggro(mob); SafeGuardAggro(mob);
} }
} }
CheckForAttack(mob); CheckForAttack(mob);
} }
private static void DefaultLogic(Mob mob) { private static void DefaultLogic(Mob mob) {
if(mob.getObjectUUID() == 40548){ if (mob.getObjectUUID() == 40548) {
int thing = 0; int thing = 0;
} }
//check for players that can be aggroed if mob is agressive and has no target //check for players that can be aggroed if mob is agressive and has no target
@ -643,6 +666,7 @@ public class MobileFSM {
if (!mob.BehaviourType.isWimpy && !mob.isMoving() && mob.combatTarget != null) if (!mob.BehaviourType.isWimpy && !mob.isMoving() && mob.combatTarget != null)
CheckForAttack(mob); CheckForAttack(mob);
} }
public static void CheckForPlayerGuardAggro(Mob mob) { public static void CheckForPlayerGuardAggro(Mob mob) {
//looks for and sets mobs combatTarget //looks for and sets mobs combatTarget
if (!mob.isAlive()) if (!mob.isAlive())
@ -673,14 +697,15 @@ public class MobileFSM {
} }
} }
} }
public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) { public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) {
if (mob.getGuild().getNation().equals(target.getGuild().getNation())) if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
return false; return false;
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if(((Mob)mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true){ if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
return true; return true;
} }
} else if(mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true){ } else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
return true; return true;
} }
//first check condemn list for aggro allowed (allies button is checked) //first check condemn list for aggro allowed (allies button is checked)
@ -697,7 +722,7 @@ public class MobileFSM {
return false; return false;
} }
return true; return true;
} else{ } else {
//allies button is not checked //allies button is not checked
for (Entry<Integer, Condemned> entry : ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().getCondemned().entrySet()) { for (Entry<Integer, Condemned> entry : ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().getCondemned().entrySet()) {
if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive()) if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive())
@ -713,7 +738,8 @@ public class MobileFSM {
} }
return false; return false;
} }
public static void randomGuardPatrolPoint(Mob mob){
public static void randomGuardPatrolPoint(Mob mob) {
if (mob.isMoving() == true) { if (mob.isMoving() == true) {
//early exit for a mob who is already moving to a patrol point //early exit for a mob who is already moving to a patrol point
//while mob moving, update lastPatrolTime so that when they stop moving the 10 second timer can begin //while mob moving, update lastPatrolTime so that when they stop moving the 10 second timer can begin
@ -728,9 +754,9 @@ public class MobileFSM {
float xPoint = ThreadLocalRandom.current().nextInt(400) - 200; float xPoint = ThreadLocalRandom.current().nextInt(400) - 200;
float zPoint = ThreadLocalRandom.current().nextInt(400) - 200; float zPoint = ThreadLocalRandom.current().nextInt(400) - 200;
Vector3fImmutable TreePos = mob.getGuild().getOwnedCity().getLoc(); Vector3fImmutable TreePos = mob.getGuild().getOwnedCity().getLoc();
mob.destination = new Vector3fImmutable(TreePos.x + xPoint,TreePos.y,TreePos.z + zPoint); mob.destination = new Vector3fImmutable(TreePos.x + xPoint, TreePos.y, TreePos.z + zPoint);
MovementUtilities.aiMove(mob, mob.destination, true); MovementUtilities.aiMove(mob, mob.destination, true);
if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()){ if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) { for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
//make sure mob is out of combat stance //make sure mob is out of combat stance
if (minion.getKey().despawned == false) { if (minion.getKey().despawned == false) {
@ -750,18 +776,19 @@ public class MobileFSM {
} }
} }
} }
public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob){
public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) {
float CurrentHateValue = 0; float CurrentHateValue = 0;
if(mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
CurrentHateValue = ((PlayerCharacter)mob.getCombatTarget()).getHateValue(); CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue();
} }
AbstractWorldObject mostHatedTarget = null; AbstractWorldObject mostHatedTarget = null;
for (Entry playerEntry : mob.playerAgroMap.entrySet()) { for (Entry playerEntry : mob.playerAgroMap.entrySet()) {
PlayerCharacter potentialTarget = PlayerCharacter.getFromCache((int)playerEntry.getKey()); PlayerCharacter potentialTarget = PlayerCharacter.getFromCache((int) playerEntry.getKey());
if(potentialTarget.equals(mob.getCombatTarget())){ if (potentialTarget.equals(mob.getCombatTarget())) {
continue; continue;
} }
if(potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)){ if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = potentialTarget.getHateValue(); CurrentHateValue = potentialTarget.getHateValue();
mostHatedTarget = potentialTarget; mostHatedTarget = potentialTarget;
} }

5
src/engine/ai/MobileFSMManager.java

@ -25,9 +25,6 @@ public class MobileFSMManager {
private static final MobileFSMManager INSTANCE = new MobileFSMManager(); private static final MobileFSMManager INSTANCE = new MobileFSMManager();
public static Duration executionTime = Duration.ofNanos(1); public static Duration executionTime = Duration.ofNanos(1);
public static Duration executionMax = Duration.ofNanos(1); public static Duration executionMax = Duration.ofNanos(1);
private volatile boolean alive;
private long timeOfKill = -1;
//AI variables moved form mb_server_statics //AI variables moved form mb_server_statics
public static int AI_BASE_AGGRO_RANGE = 60; public static int AI_BASE_AGGRO_RANGE = 60;
public static int AI_DROP_AGGRO_RANGE = 60; public static int AI_DROP_AGGRO_RANGE = 60;
@ -37,6 +34,8 @@ public class MobileFSMManager {
public static int AI_PATROL_DIVISOR = 15; public static int AI_PATROL_DIVISOR = 15;
public static int AI_POWER_DIVISOR = 20; public static int AI_POWER_DIVISOR = 20;
public static float AI_MAX_ANGLE = 10f; public static float AI_MAX_ANGLE = 10f;
private volatile boolean alive;
private long timeOfKill = -1;
private MobileFSMManager() { private MobileFSMManager() {

2
src/engine/ai/utilities/CombatUtilities.java

@ -405,7 +405,7 @@ public class CombatUtilities {
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None); float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
double min = agent.getMinDamageHandOne(); double min = agent.getMinDamageHandOne();
double max = agent.getMaxDamageHandOne(); double max = agent.getMaxDamageHandOne();
if(agent.getEquip().get(1) != null) { if (agent.getEquip().get(1) != null) {
if (agent.getEquip().get(1).getItemBase() != null) { if (agent.getEquip().get(1).getItemBase() != null) {
dt = agent.getEquip().get(1).getItemBase().getDamageType(); dt = agent.getEquip().get(1).getItemBase().getDamageType();
min = agent.getMinDamageHandOne(); min = agent.getMinDamageHandOne();

49
src/engine/core/ControlledRunnable.java

@ -17,10 +17,16 @@ import java.util.ArrayList;
* *
*/ */
public abstract class ControlledRunnable implements Runnable { public abstract class ControlledRunnable implements Runnable {
// Runnable tracking
private static final ArrayList<ControlledRunnable> runnables = new ArrayList<>();
private final String threadName;
protected boolean runCmd = false; protected boolean runCmd = false;
protected boolean runStatus = false; protected boolean runStatus = false;
private Thread thisThread; private Thread thisThread;
private final String threadName;
/*
* Main loop
*/
public ControlledRunnable(String threadName) { public ControlledRunnable(String threadName) {
super(); super();
@ -28,9 +34,14 @@ public abstract class ControlledRunnable implements Runnable {
ControlledRunnable.runnables.add(this); ControlledRunnable.runnables.add(this);
} }
/* public static void shutdownAllRunnables() {
* Main loop for (ControlledRunnable cr : ControlledRunnable.runnables) {
*/ //Use Direct logging since JobManager is a runnable.
Logger.info("ControlledRunnable",
"Sending Shutdown cmd to: " + cr.threadName);
cr.shutdown();
}
}
/** /**
* This is the method called when ControlledRunnable.thisThread.start() is * This is the method called when ControlledRunnable.thisThread.start() is
@ -62,6 +73,10 @@ public abstract class ControlledRunnable implements Runnable {
*/ */
protected abstract boolean _preRun(); protected abstract boolean _preRun();
/*
* Control
*/
/** /**
* _Run() is called after _startup() and contains should contain the main * _Run() is called after _startup() and contains should contain the main
* loop. * loop.
@ -78,10 +93,6 @@ public abstract class ControlledRunnable implements Runnable {
*/ */
protected abstract boolean _postRun(); protected abstract boolean _postRun();
/*
* Control
*/
/** /**
* startup() initializes the internal thread, sets the runCMD to true, and * startup() initializes the internal thread, sets the runCMD to true, and
* calls _startup() prior to starting of the internal Thread. * calls _startup() prior to starting of the internal Thread.
@ -134,13 +145,17 @@ public abstract class ControlledRunnable implements Runnable {
System.out.println("BLOCKING"); System.out.println("BLOCKING");
Thread.sleep(25L); Thread.sleep(25L);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Logger.debug( e.getMessage()); Logger.debug(e.getMessage());
break; break;
} }
} }
} }
/*
* Instance monitoring and tools
*/
/** /**
* @return the thisThread * @return the thisThread
*/ */
@ -155,20 +170,4 @@ public abstract class ControlledRunnable implements Runnable {
return threadName; return threadName;
} }
/*
* Instance monitoring and tools
*/
// Runnable tracking
private static final ArrayList<ControlledRunnable> runnables = new ArrayList<>();
public static void shutdownAllRunnables() {
for (ControlledRunnable cr : ControlledRunnable.runnables) {
//Use Direct logging since JobManager is a runnable.
Logger.info("ControlledRunnable",
"Sending Shutdown cmd to: " + cr.threadName);
cr.shutdown();
}
}
} }

12
src/engine/db/archive/BaneRecord.java

@ -50,8 +50,7 @@ public class BaneRecord extends DataRecord {
if (baneRecord == null) { if (baneRecord == null) {
baneRecord = new BaneRecord(bane); baneRecord = new BaneRecord(bane);
baneRecord.eventType = eventType; baneRecord.eventType = eventType;
} } else {
else {
baneRecord.recordType = Enum.DataRecordType.BANE; baneRecord.recordType = Enum.DataRecordType.BANE;
baneRecord.eventType = eventType; baneRecord.eventType = eventType;
@ -67,8 +66,7 @@ public class BaneRecord extends DataRecord {
baneRecord.baneDropperHash = "ERRANT"; baneRecord.baneDropperHash = "ERRANT";
baneRecord.baneGuildHash = "ERRANT"; baneRecord.baneGuildHash = "ERRANT";
baneRecord.baneNationHash = "ERRANT"; baneRecord.baneNationHash = "ERRANT";
} } else {
else {
baneRecord.baneDropperHash = DataWarehouse.hasher.encrypt(bane.getOwner().getObjectUUID()); // getPlayerCharacter didn't check hash first? OMFG baneRecord.baneDropperHash = DataWarehouse.hasher.encrypt(bane.getOwner().getObjectUUID()); // getPlayerCharacter didn't check hash first? OMFG
@ -153,7 +151,7 @@ public class BaneRecord extends DataRecord {
} }
private static PreparedStatement buildDateTimeQueryStatement (Connection connection, City city) throws SQLException { private static PreparedStatement buildDateTimeQueryStatement(Connection connection, City city) throws SQLException {
PreparedStatement outStatement; PreparedStatement outStatement;
String queryString = "SELECT `endDatetime` FROM `warehouse_banehistory` WHERE `city_id` = ? ORDER BY `endDatetime` DESC LIMIT 1"; String queryString = "SELECT `endDatetime` FROM `warehouse_banehistory` WHERE `city_id` = ? ORDER BY `endDatetime` DESC LIMIT 1";
outStatement = connection.prepareStatement(queryString); outStatement = connection.prepareStatement(queryString);
@ -275,7 +273,7 @@ public class BaneRecord extends DataRecord {
} }
} catch (SQLException e) { } catch (SQLException e) {
Logger.error( e.toString()); Logger.error(e.toString());
} }
} }
@ -287,7 +285,7 @@ public class BaneRecord extends DataRecord {
statement.execute(); statement.execute();
return true; return true;
} catch (SQLException e) { } catch (SQLException e) {
Logger.error( e.toString()); Logger.error(e.toString());
return false; return false;
} }
} }

3
src/engine/db/archive/CharacterRecord.java

@ -44,8 +44,7 @@ public class CharacterRecord extends DataRecord {
if (characterRecord == null) { if (characterRecord == null) {
characterRecord = new CharacterRecord(player); characterRecord = new CharacterRecord(player);
} } else {
else {
characterRecord.recordType = Enum.DataRecordType.CHARACTER; characterRecord.recordType = Enum.DataRecordType.CHARACTER;
characterRecord.player = player; characterRecord.player = player;

3
src/engine/db/archive/CityRecord.java

@ -46,8 +46,7 @@ public class CityRecord extends DataRecord {
if (cityRecord == null) { if (cityRecord == null) {
cityRecord = new CityRecord(city); cityRecord = new CityRecord(city);
cityRecord.eventType = eventType; cityRecord.eventType = eventType;
} } else {
else {
cityRecord.recordType = Enum.DataRecordType.CITY; cityRecord.recordType = Enum.DataRecordType.CITY;
cityRecord.eventType = eventType; cityRecord.eventType = eventType;
cityRecord.city = city; cityRecord.city = city;

1
src/engine/db/archive/DataRecord.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.db.archive; package engine.db.archive;
import engine.Enum; import engine.Enum;

44
src/engine/db/archive/DataWarehouse.java

@ -35,12 +35,12 @@ public class DataWarehouse implements Runnable {
// If WarehousePush is disabled // If WarehousePush is disabled
// then early exit // then early exit
if ( ConfigManager.MB_WORLD_WAREHOUSE_PUSH.getValue().equalsIgnoreCase("false")) { if (ConfigManager.MB_WORLD_WAREHOUSE_PUSH.getValue().equalsIgnoreCase("false")) {
Logger.info("Warehouse Remote Connection disabled along with push"); Logger.info("Warehouse Remote Connection disabled along with push");
return; return;
} }
Logger.info( "Configuring remote Database Connection Pool..."); Logger.info("Configuring remote Database Connection Pool...");
configureRemoteConnectionPool(); configureRemoteConnectionPool();
} }
@ -188,6 +188,24 @@ public class DataWarehouse implements Runnable {
return false; return false;
} }
private static void configureRemoteConnectionPool() {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(1); // Only the server talks to remote, so yeah.
config.setJdbcUrl(ConfigManager.MB_WAREHOUSE_ADDR.getValue());
config.setUsername(ConfigManager.MB_WAREHOUSE_USER.getValue());
config.setPassword(ConfigManager.MB_WAREHOUSE_PASS.getValue());
config.addDataSourceProperty("characterEncoding", "utf8");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
remoteConnectionPool = new HikariDataSource(config); // setup the connection pool
Logger.info("remote warehouse connection configured");
}
public void run() { public void run() {
// Working variable set // Working variable set
@ -201,7 +219,7 @@ public class DataWarehouse implements Runnable {
RealmRecord realmRecord; RealmRecord realmRecord;
MineRecord mineRecord; MineRecord mineRecord;
Logger.info( "DataWarehouse is running."); Logger.info("DataWarehouse is running.");
while (true) { while (true) {
@ -261,7 +279,7 @@ public class DataWarehouse implements Runnable {
mineRecord.release(); mineRecord.release();
break; break;
default: default:
Logger.error( "Unhandled record type"); Logger.error("Unhandled record type");
break; break;
} // end switch } // end switch
@ -269,22 +287,4 @@ public class DataWarehouse implements Runnable {
} }
} }
private static void configureRemoteConnectionPool() {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(1); // Only the server talks to remote, so yeah.
config.setJdbcUrl(ConfigManager.MB_WAREHOUSE_ADDR.getValue());
config.setUsername(ConfigManager.MB_WAREHOUSE_USER.getValue());
config.setPassword(ConfigManager.MB_WAREHOUSE_PASS.getValue());
config.addDataSourceProperty("characterEncoding", "utf8");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
remoteConnectionPool = new HikariDataSource(config); // setup the connection pool
Logger.info("remote warehouse connection configured");
}
} }

15
src/engine/db/archive/GuildRecord.java

@ -27,9 +27,11 @@ import java.util.concurrent.LinkedBlockingQueue;
public class GuildRecord extends DataRecord { public class GuildRecord extends DataRecord {
private static final LinkedBlockingQueue<GuildRecord> recordPool = new LinkedBlockingQueue<>(); private static final LinkedBlockingQueue<GuildRecord> recordPool = new LinkedBlockingQueue<>();
public static HashMap<Integer, GuildRecord> GuildRecordCache = null;
public String guildHash;
public int guildID;
private Enum.RecordEventType eventType; private Enum.RecordEventType eventType;
private Guild guild; private Guild guild;
public String guildHash;
private String guildName; private String guildName;
private String charterName; private String charterName;
private String GLHash; private String GLHash;
@ -39,12 +41,8 @@ public class GuildRecord extends DataRecord {
private int bgColour2; private int bgColour2;
private int fgIcon; private int fgIcon;
private int fgColour; private int fgColour;
public int guildID;
private java.time.LocalDateTime eventDatetime; private java.time.LocalDateTime eventDatetime;
public static HashMap<Integer, GuildRecord> GuildRecordCache = null;
private GuildRecord(Guild guild) { private GuildRecord(Guild guild) {
this.recordType = Enum.DataRecordType.GUILD; this.recordType = Enum.DataRecordType.GUILD;
this.guild = guild; this.guild = guild;
@ -52,7 +50,6 @@ public class GuildRecord extends DataRecord {
} }
public GuildRecord(ResultSet rs) throws SQLException { public GuildRecord(ResultSet rs) throws SQLException {
super(); super();
this.eventType = RecordEventType.valueOf(rs.getString("eventType")); this.eventType = RecordEventType.valueOf(rs.getString("eventType"));
@ -74,7 +71,6 @@ public class GuildRecord extends DataRecord {
} }
public static GuildRecord borrow(Guild guild, Enum.RecordEventType eventType) { public static GuildRecord borrow(Guild guild, Enum.RecordEventType eventType) {
GuildRecord guildRecord; GuildRecord guildRecord;
//add //add
@ -83,8 +79,7 @@ public class GuildRecord extends DataRecord {
if (guildRecord == null) { if (guildRecord == null) {
guildRecord = new GuildRecord(guild); guildRecord = new GuildRecord(guild);
guildRecord.eventType = eventType; guildRecord.eventType = eventType;
} } else {
else {
guildRecord.guild = guild; guildRecord.guild = guild;
guildRecord.recordType = Enum.DataRecordType.GUILD; guildRecord.recordType = Enum.DataRecordType.GUILD;
guildRecord.eventType = eventType; guildRecord.eventType = eventType;
@ -197,7 +192,7 @@ public class GuildRecord extends DataRecord {
outStatement.setInt(9, this.fgIcon); outStatement.setInt(9, this.fgIcon);
outStatement.setInt(10, this.fgColour); outStatement.setInt(10, this.fgColour);
outStatement.setString(11, this.eventType.name()); outStatement.setString(11, this.eventType.name());
outStatement.setTimestamp(12, new java.sql.Timestamp( this.eventDatetime.atZone(ZoneId.systemDefault()) outStatement.setTimestamp(12, new java.sql.Timestamp(this.eventDatetime.atZone(ZoneId.systemDefault())
.toInstant().toEpochMilli())); .toInstant().toEpochMilli()));
return outStatement; return outStatement;

6
src/engine/db/archive/MineRecord.java

@ -47,8 +47,7 @@ public class MineRecord extends DataRecord {
if (mineRecord == null) { if (mineRecord == null) {
mineRecord = new MineRecord(); mineRecord = new MineRecord();
mineRecord.eventType = eventType; mineRecord.eventType = eventType;
} } else {
else {
mineRecord.recordType = Enum.DataRecordType.MINE; mineRecord.recordType = Enum.DataRecordType.MINE;
mineRecord.eventType = eventType; mineRecord.eventType = eventType;
} }
@ -58,8 +57,7 @@ public class MineRecord extends DataRecord {
if (character.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { if (character.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
player = (PlayerCharacter) character; player = (PlayerCharacter) character;
mineRecord.charHash = player.getHash(); mineRecord.charHash = player.getHash();
} } else
else
mineRecord.charHash = character.getName(); mineRecord.charHash = character.getName();
DataWarehouse.hasher.encrypt(0); DataWarehouse.hasher.encrypt(0);

3
src/engine/db/archive/PvpRecord.java

@ -51,8 +51,7 @@ public class PvpRecord extends DataRecord {
if (pvpRecord == null) { if (pvpRecord == null) {
pvpRecord = new PvpRecord(player, victim, location, pvpExp); pvpRecord = new PvpRecord(player, victim, location, pvpExp);
} } else {
else {
pvpRecord.recordType = DataRecordType.PVP; pvpRecord.recordType = DataRecordType.PVP;
pvpRecord.player = player; pvpRecord.player = player;
pvpRecord.victim = victim; pvpRecord.victim = victim;

3
src/engine/db/archive/RealmRecord.java

@ -44,8 +44,7 @@ public class RealmRecord extends DataRecord {
if (realmRecord == null) { if (realmRecord == null) {
realmRecord = new RealmRecord(realm); realmRecord = new RealmRecord(realm);
realmRecord.eventType = eventType; realmRecord.eventType = eventType;
} } else {
else {
realmRecord.recordType = Enum.DataRecordType.REALM; realmRecord.recordType = Enum.DataRecordType.REALM;
realmRecord.eventType = eventType; realmRecord.eventType = eventType;
realmRecord.realm = realm; realmRecord.realm = realm;

120
src/engine/devcmd/AbstractDevCmd.java

@ -29,6 +29,60 @@ public abstract class AbstractDevCmd {
this.rsult = ""; this.rsult = "";
} }
/*
* Misc tools/helpers
*/
protected static Building getTargetAsBuilding(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Building.ordinal()) {
Building b = (Building) DbManager
.getFromCache(GameObjectType.Building, targetID);
if (b == null) {
ChatManager.chatSystemError(
pc,
"Command Failed. Could not find building of ID "
+ targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static Mob getTargetAsMob(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Mob.ordinal()) {
Mob b = Mob.getMob(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find Mob of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static NPC getTargetAsNPC(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.NPC.ordinal()) {
NPC b = NPC.getFromCache(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find NPC of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
/** /**
* This function is called by the DevCmdManager. Method splits argString * This function is called by the DevCmdManager. Method splits argString
* into a String array and then calls the subclass specific _doCmd method. * into a String array and then calls the subclass specific _doCmd method.
@ -89,22 +143,22 @@ public abstract class AbstractDevCmd {
this.cmdStrings.add(lowercase); this.cmdStrings.add(lowercase);
} }
public void setTarget(AbstractGameObject ago) {
this.tr = ago;
}
public AbstractGameObject getTarget() { public AbstractGameObject getTarget() {
return this.tr; return this.tr;
} }
public void setResult(String result) { public void setTarget(AbstractGameObject ago) {
this.rsult = result; this.tr = ago;
} }
public String getResult() { public String getResult() {
return this.rsult; return this.rsult;
} }
public void setResult(String result) {
this.rsult = result;
}
/* /*
* Helper functions * Helper functions
*/ */
@ -124,58 +178,4 @@ public abstract class AbstractDevCmd {
ChatManager.chatSystemInfo(pc, msgText); ChatManager.chatSystemInfo(pc, msgText);
} }
/*
* Misc tools/helpers
*/
protected static Building getTargetAsBuilding(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Building.ordinal()) {
Building b = (Building) DbManager
.getFromCache(GameObjectType.Building, targetID);
if (b == null) {
ChatManager.chatSystemError(
pc,
"Command Failed. Could not find building of ID "
+ targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static Mob getTargetAsMob(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Mob.ordinal()) {
Mob b = Mob.getMob(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find Mob of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static NPC getTargetAsNPC(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.NPC.ordinal()) {
NPC b = NPC.getFromCache(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find NPC of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
} }

1
src/engine/devcmd/cmds/AddGoldCmd.java

@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter;
/** /**
* @author Eighty * @author Eighty
*
*/ */
public class AddGoldCmd extends AbstractDevCmd { public class AddGoldCmd extends AbstractDevCmd {

17
src/engine/devcmd/cmds/AddMobCmd.java

@ -20,7 +20,6 @@ import org.pmw.tinylog.Logger;
/** /**
* @author Eighty * @author Eighty
*
*/ */
public class AddMobCmd extends AbstractDevCmd { public class AddMobCmd extends AbstractDevCmd {
@ -38,19 +37,19 @@ public class AddMobCmd extends AbstractDevCmd {
Zone zone = ZoneManager.findSmallestZone(pc.getLoc()); Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
if (words[0].equals("all")){ if (words[0].equals("all")) {
for (AbstractGameObject mobbaseAGO: DbManager.getList(GameObjectType.MobBase)){ for (AbstractGameObject mobbaseAGO : DbManager.getList(GameObjectType.MobBase)) {
MobBase mb = (MobBase)mobbaseAGO; MobBase mb = (MobBase) mobbaseAGO;
int loadID = mb.getObjectUUID(); int loadID = mb.getObjectUUID();
Mob mob = Mob.createMob( loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100), Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
null, true, zone, null,0, "", 1); null, true, zone, null, 0, "", 1);
if (mob != null) { if (mob != null) {
mob.updateDatabase(); mob.updateDatabase();
this.setResult(String.valueOf(mob.getDBID())); this.setResult(String.valueOf(mob.getDBID()));
} else { } else {
throwbackError(pc, "Failed to create mob of type " + loadID); throwbackError(pc, "Failed to create mob of type " + loadID);
Logger.error( "Failed to create mob of type " Logger.error("Failed to create mob of type "
+ loadID); + loadID);
} }
} }
@ -84,8 +83,8 @@ public class AddMobCmd extends AbstractDevCmd {
} }
Mob mob = Mob.createMob( loadID, pc.getLoc(), Mob mob = Mob.createMob(loadID, pc.getLoc(),
null, true, zone, null,0, "", 1); null, true, zone, null, 0, "", 1);
if (mob != null) { if (mob != null) {
mob.updateDatabase(); mob.updateDatabase();
ChatManager.chatSayInfo(pc, ChatManager.chatSayInfo(pc,

5
src/engine/devcmd/cmds/AddNPCCmd.java

@ -18,7 +18,6 @@ import org.pmw.tinylog.Logger;
/** /**
* @author Eighty * @author Eighty
*
*/ */
public class AddNPCCmd extends AbstractDevCmd { public class AddNPCCmd extends AbstractDevCmd {
@ -73,8 +72,8 @@ public class AddNPCCmd extends AbstractDevCmd {
} }
if (target != null) if (target != null)
if (target.getObjectType() == GameObjectType.Building){ if (target.getObjectType() == GameObjectType.Building) {
Building parentBuilding = (Building)target; Building parentBuilding = (Building) target;
BuildingManager.addHirelingForWorld(parentBuilding, pc, parentBuilding.getLoc(), parentBuilding.getParentZone(), contract, level); BuildingManager.addHirelingForWorld(parentBuilding, pc, parentBuilding.getLoc(), parentBuilding.getParentZone(), contract, level);
return; return;
} }

36
src/engine/devcmd/cmds/ApplyBonusCmd.java

@ -38,36 +38,36 @@ public class ApplyBonusCmd extends AbstractDevCmd {
PowerActionType actionType = null; PowerActionType actionType = null;
HashMap<String,HashSet<String>> appliedMods = new HashMap<>(); HashMap<String, HashSet<String>> appliedMods = new HashMap<>();
try{ try {
if (action.equals("all") == false) if (action.equals("all") == false)
for (PowerActionType powerActionType : PowerActionType.values()){ for (PowerActionType powerActionType : PowerActionType.values()) {
if (powerActionType.name().equalsIgnoreCase(action) == false) if (powerActionType.name().equalsIgnoreCase(action) == false)
continue; continue;
actionType = powerActionType; actionType = powerActionType;
break; break;
} }
}catch(Exception e){ } catch (Exception e) {
this.throwbackError(pcSender, "Invalid power Action type for " + action); this.throwbackError(pcSender, "Invalid power Action type for " + action);
this.throwbackInfo(pcSender, "Valid Types : " + this.getActionTypes()); this.throwbackInfo(pcSender, "Valid Types : " + this.getActionTypes());
return; return;
} }
if (action.equals("all") == false) if (action.equals("all") == false)
if (actionType == null){ if (actionType == null) {
this.throwbackError(pcSender, "Invalid power Action type for " + action); this.throwbackError(pcSender, "Invalid power Action type for " + action);
this.throwbackInfo(pcSender, "Valid Types : " + this.getActionTypes()); this.throwbackInfo(pcSender, "Valid Types : " + this.getActionTypes());
return; return;
} }
for (PowersBase pb : PowersManager.powersBaseByIDString.values()){ for (PowersBase pb : PowersManager.powersBaseByIDString.values()) {
if (pb.getActions() == null || pb.getActions().isEmpty()) if (pb.getActions() == null || pb.getActions().isEmpty())
continue; continue;
for (ActionsBase ab: pb.getActions()){ for (ActionsBase ab : pb.getActions()) {
if (ab.getPowerAction() == null) if (ab.getPowerAction() == null)
continue; continue;
if (action.equals("all") == false) if (action.equals("all") == false)
@ -75,8 +75,8 @@ public class ApplyBonusCmd extends AbstractDevCmd {
continue; continue;
String effect1 = ""; String effect1 = "";
String effect2 = ""; String effect2 = "";
ChatManager.chatSystemInfo(pcSender,"Applying Power " + pb.getName() + " : " +pb.getDescription()); ChatManager.chatSystemInfo(pcSender, "Applying Power " + pb.getName() + " : " + pb.getDescription());
if (ab.getPowerAction().getEffectsBase() == null){ if (ab.getPowerAction().getEffectsBase() == null) {
try { try {
PowersManager.runPowerAction(pcSender, pcSender, pcSender.getLoc(), ab, 1, pb); PowersManager.runPowerAction(pcSender, pcSender, pcSender.getLoc(), ab, 1, pb);
@ -89,7 +89,7 @@ public class ApplyBonusCmd extends AbstractDevCmd {
} }
if (ab.getPowerAction().getEffectsBase().getModifiers() == null || ab.getPowerAction().getEffectsBase().getModifiers().isEmpty()){ if (ab.getPowerAction().getEffectsBase().getModifiers() == null || ab.getPowerAction().getEffectsBase().getModifiers().isEmpty()) {
try { try {
PowersManager.runPowerAction(pcSender, pcSender, pcSender.getLoc(), ab, 1, pb); PowersManager.runPowerAction(pcSender, pcSender, pcSender.getLoc(), ab, 1, pb);
} catch (Exception e) { } catch (Exception e) {
@ -100,8 +100,8 @@ public class ApplyBonusCmd extends AbstractDevCmd {
} }
boolean run = true; boolean run = true;
for (AbstractEffectModifier mod : ab.getPowerAction().getEffectsBase().getModifiers()){ for (AbstractEffectModifier mod : ab.getPowerAction().getEffectsBase().getModifiers()) {
if (appliedMods.containsKey(mod.modType.name()) == false){ if (appliedMods.containsKey(mod.modType.name()) == false) {
appliedMods.put(mod.modType.name(), new HashSet<>()); appliedMods.put(mod.modType.name(), new HashSet<>());
} }
@ -110,7 +110,7 @@ public class ApplyBonusCmd extends AbstractDevCmd {
// } // }
appliedMods.get(mod.modType.name()).add(mod.sourceType.name()); appliedMods.get(mod.modType.name()).add(mod.sourceType.name());
try{ try {
try { try {
PowersManager.runPowerAction(pcSender, pcSender, pcSender.getLoc(), ab, 1, pb); PowersManager.runPowerAction(pcSender, pcSender, pcSender.getLoc(), ab, 1, pb);
} catch (Exception e) { } catch (Exception e) {
@ -118,14 +118,12 @@ public class ApplyBonusCmd extends AbstractDevCmd {
e.printStackTrace(); e.printStackTrace();
} }
}catch(Exception e){ } catch (Exception e) {
Logger.error(e); Logger.error(e);
} }
break; break;
} }
} }
@ -144,15 +142,15 @@ public class ApplyBonusCmd extends AbstractDevCmd {
} }
private String getActionTypes(){ private String getActionTypes() {
String output = ""; String output = "";
for (PowerActionType actionType : PowerActionType.values()){ for (PowerActionType actionType : PowerActionType.values()) {
output += actionType.name() + " | "; output += actionType.name() + " | ";
} }
return output.substring(0, output.length() -3); return output.substring(0, output.length() - 3);
} }
} }

47
src/engine/devcmd/cmds/ApplyStatModCmd.java

@ -21,28 +21,26 @@ import engine.powers.PowersBase;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
*
* @author Eighty * @author Eighty
*
*/ */
public class ApplyStatModCmd extends AbstractDevCmd { public class ApplyStatModCmd extends AbstractDevCmd {
private static int cnt = 0;
public ApplyStatModCmd() { public ApplyStatModCmd() {
super("applystatmod"); super("applystatmod");
} }
private static int cnt = 0;
@Override @Override
protected void _doCmd(PlayerCharacter pcSender, String[] args, protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) { AbstractGameObject target) {
if(args.length < 1) { if (args.length < 1) {
// if(args.length < 2) { // if(args.length < 2) {
this.sendUsage(pcSender); this.sendUsage(pcSender);
return; return;
} }
if(!(target instanceof AbstractCharacter)) { if (!(target instanceof AbstractCharacter)) {
this.sendHelp(pcSender); this.sendHelp(pcSender);
return; return;
} }
@ -51,7 +49,7 @@ public class ApplyStatModCmd extends AbstractDevCmd {
int spellID; int spellID;
int powerAction = 0; int powerAction = 0;
if (args[0].toLowerCase().contains("all")){ if (args[0].toLowerCase().contains("all")) {
int amount = 0; int amount = 0;
if (args.length == 1) { if (args.length == 1) {
@ -59,7 +57,7 @@ public class ApplyStatModCmd extends AbstractDevCmd {
ApplyStatModCmd.cnt++; ApplyStatModCmd.cnt++;
} else { } else {
amount = Integer.valueOf(args[1]); amount = Integer.valueOf(args[1]);
ApplyStatModCmd.cnt = amount+1; ApplyStatModCmd.cnt = amount + 1;
} }
@ -72,43 +70,40 @@ public class ApplyStatModCmd extends AbstractDevCmd {
pbList.add(PowersManager.getPowerByToken(431081336)); pbList.add(PowersManager.getPowerByToken(431081336));
for (PowersBase pb : pbList) {
if (amount <= 0) {
if (pb.getToken() == 428677994)
for (PowersBase pb:pbList){
if(amount <= 0) {
if (pb.getToken() ==428677994)
powerAction = 1; powerAction = 1;
PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false); PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false);
continue; continue;
} else if(amount > 9999 || amount < 21) { } else if (amount > 9999 || amount < 21) {
ChatManager.chatSystemInfo(pcSender, "Amount must be between 21 and 9999 inclusive."); ChatManager.chatSystemInfo(pcSender, "Amount must be between 21 and 9999 inclusive.");
return; return;
} }
if (pb.getToken() ==428677994){ if (pb.getToken() == 428677994) {
PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false); PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false);
PowersManager.runPowerAction(pcSender, pcSender, Vector3fImmutable.ZERO, pb.getActions().get(powerAction), amount - 20, pb); PowersManager.runPowerAction(pcSender, pcSender, Vector3fImmutable.ZERO, pb.getActions().get(powerAction), amount - 20, pb);
} }
if (pb.getToken() ==428677994) if (pb.getToken() == 428677994)
powerAction = 1; powerAction = 1;
PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false); PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false);
PowersManager.runPowerAction(pcSender, pcSender, Vector3fImmutable.ZERO, pb.getActions().get(powerAction), amount - 20, pb); PowersManager.runPowerAction(pcSender, pcSender, Vector3fImmutable.ZERO, pb.getActions().get(powerAction), amount - 20, pb);
} }
return; return;
} }
if(args[0].toLowerCase().contains("con")) { if (args[0].toLowerCase().contains("con")) {
spellID = 429047968; //Blessing of Health spellID = 429047968; //Blessing of Health
} else if(args[0].toLowerCase().contains("str")) { } else if (args[0].toLowerCase().contains("str")) {
spellID = 429768864; //Blessing of Might spellID = 429768864; //Blessing of Might
} else if(args[0].toLowerCase().contains("dex")) { } else if (args[0].toLowerCase().contains("dex")) {
spellID = 428458144; //Blessing of Dexterity spellID = 428458144; //Blessing of Dexterity
} else if(args[0].toLowerCase().contains("int")) { } else if (args[0].toLowerCase().contains("int")) {
spellID = 428677994; //Bard Spi - TODO spellID = 428677994; //Bard Spi - TODO
powerAction = 1; powerAction = 1;
} else if(args[0].toLowerCase().contains("spi")) { } else if (args[0].toLowerCase().contains("spi")) {
spellID = 428677994; //Bard Spi spellID = 428677994; //Bard Spi
} else{ } else {
ChatManager.chatSystemInfo(pcSender, "No valid stat found."); ChatManager.chatSystemInfo(pcSender, "No valid stat found.");
return; return;
} }
@ -121,13 +116,13 @@ public class ApplyStatModCmd extends AbstractDevCmd {
ApplyStatModCmd.cnt++; ApplyStatModCmd.cnt++;
} else { } else {
amount = Integer.valueOf(args[1]); amount = Integer.valueOf(args[1]);
ApplyStatModCmd.cnt = amount+1; ApplyStatModCmd.cnt = amount + 1;
} }
// int amount = Integer.valueOf(args[1]); // int amount = Integer.valueOf(args[1]);
if(amount <= 0) { if (amount <= 0) {
PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false); PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false);
return; return;
} else if(amount > 9999 || amount < 21) { } else if (amount > 9999 || amount < 21) {
ChatManager.chatSystemInfo(pcSender, "Amount must be between 21 and 9999 inclusive."); ChatManager.chatSystemInfo(pcSender, "Amount must be between 21 and 9999 inclusive.");
return; return;
} }

35
src/engine/devcmd/cmds/AuditFailedItemsCmd.java

@ -29,7 +29,6 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
AbstractGameObject target) { AbstractGameObject target) {
if (ItemProductionManager.FailedItems.isEmpty()) if (ItemProductionManager.FailedItems.isEmpty())
return; return;
@ -38,10 +37,10 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
String newLine = "\r\n"; String newLine = "\r\n";
String auditFailedItem = "Failed Item Name | Prefix | Suffix | NPC | Contract | Player | "; String auditFailedItem = "Failed Item Name | Prefix | Suffix | NPC | Contract | Player | ";
for (ProducedItem failedItem: ItemProductionManager.FailedItems){ for (ProducedItem failedItem : ItemProductionManager.FailedItems) {
String npcName = ""; String npcName = "";
String playerName =""; String playerName = "";
String contractName = ""; String contractName = "";
String prefix = ""; String prefix = "";
@ -49,10 +48,10 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
String itemName = ""; String itemName = "";
NPC npc = NPC.getFromCache(failedItem.getNpcUID()); NPC npc = NPC.getFromCache(failedItem.getNpcUID());
if (npc == null){ if (npc == null) {
npcName = "null"; npcName = "null";
contractName = "null"; contractName = "null";
}else{ } else {
npcName = npc.getName(); npcName = npc.getName();
if (npc.getContract() != null) if (npc.getContract() != null)
contractName = npc.getContract().getName(); contractName = npc.getContract().getName();
@ -67,16 +66,16 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
ItemBase ib = ItemBase.getItemBase(failedItem.getItemBaseID()); ItemBase ib = ItemBase.getItemBase(failedItem.getItemBaseID());
if (ib != null){ if (ib != null) {
itemName = ib.getName(); itemName = ib.getName();
} }
if (failedItem.isRandom() == false){ if (failedItem.isRandom() == false) {
if (failedItem.getPrefix().isEmpty() == false){ if (failedItem.getPrefix().isEmpty() == false) {
AbstractPowerAction pa = PowersManager.getPowerActionByIDString(failedItem.getPrefix()); AbstractPowerAction pa = PowersManager.getPowerActionByIDString(failedItem.getPrefix());
if (pa != null){ if (pa != null) {
for (AbstractEffectModifier aem : pa.getEffectsBase().getModifiers()){ for (AbstractEffectModifier aem : pa.getEffectsBase().getModifiers()) {
if (aem.modType.equals(ModType.ItemName)){ if (aem.modType.equals(ModType.ItemName)) {
prefix = aem.getString1(); prefix = aem.getString1();
break; break;
} }
@ -85,11 +84,11 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
} }
if (failedItem.getSuffix().isEmpty() == false){ if (failedItem.getSuffix().isEmpty() == false) {
AbstractPowerAction pa = PowersManager.getPowerActionByIDString(failedItem.getSuffix()); AbstractPowerAction pa = PowersManager.getPowerActionByIDString(failedItem.getSuffix());
if (pa != null){ if (pa != null) {
for (AbstractEffectModifier aem : pa.getEffectsBase().getModifiers()){ for (AbstractEffectModifier aem : pa.getEffectsBase().getModifiers()) {
if (aem.modType.equals(ModType.ItemName)){ if (aem.modType.equals(ModType.ItemName)) {
suffix = aem.getString1(); suffix = aem.getString1();
break; break;
} }
@ -98,15 +97,13 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
} }
}else{ } else {
prefix = "random"; prefix = "random";
} }
auditFailedItem += newLine; auditFailedItem += newLine;
auditFailedItem += itemName + " | "+prefix + " | "+suffix + " | "+ failedItem.getNpcUID() + ":" +npcName + " | "+contractName + " | "+failedItem.getPlayerID() + ":" +playerName; auditFailedItem += itemName + " | " + prefix + " | " + suffix + " | " + failedItem.getNpcUID() + ":" + npcName + " | " + contractName + " | " + failedItem.getPlayerID() + ":" + playerName;
} }
Logger.info(auditFailedItem); Logger.info(auditFailedItem);

7
src/engine/devcmd/cmds/AuditHeightMapCmd.java

@ -30,18 +30,17 @@ public class AuditHeightMapCmd extends AbstractDevCmd {
int count = Integer.parseInt(words[0]); int count = Integer.parseInt(words[0]);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
for (int i = 0; i<count;i++){ for (int i = 0; i < count; i++) {
Zone currentZone = ZoneManager.findSmallestZone(pcSender.getLoc()); Zone currentZone = ZoneManager.findSmallestZone(pcSender.getLoc());
Vector3fImmutable currentLoc = Vector3fImmutable.getRandomPointInCircle(currentZone.getLoc(), currentZone.getBounds().getHalfExtents().x < currentZone.getBounds().getHalfExtents().y ? currentZone.getBounds().getHalfExtents().x : currentZone.getBounds().getHalfExtents().y);
Vector3fImmutable currentLoc = Vector3fImmutable.getRandomPointInCircle(currentZone.getLoc(), currentZone.getBounds().getHalfExtents().x < currentZone.getBounds().getHalfExtents().y ? currentZone.getBounds().getHalfExtents().x : currentZone.getBounds().getHalfExtents().y );
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentLoc, currentZone); Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentLoc, currentZone);
if (currentZone != null && currentZone.getHeightMap() != null){ if (currentZone != null && currentZone.getHeightMap() != null) {
float altitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); float altitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
float outsetAltitude = HeightMap.getOutsetHeight(altitude, currentZone, pcSender.getLoc()); float outsetAltitude = HeightMap.getOutsetHeight(altitude, currentZone, pcSender.getLoc());
} }

15
src/engine/devcmd/cmds/AuditMobsCmd.java

@ -24,20 +24,21 @@ public class AuditMobsCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pcSender, String[] words, protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (pcSender == null) return; if (pcSender == null)
return;
//get Zone to check mobs against //get Zone to check mobs against
Zone zone; Zone zone;
if (words.length == 2){ if (words.length == 2) {
if (words[0].equals("all")){ if (words[0].equals("all")) {
int plusplus = 0; int plusplus = 0;
int count = Integer.parseInt(words[1]); int count = Integer.parseInt(words[1]);
for (Zone zoneMicro: ZoneManager.getAllZones()){ for (Zone zoneMicro : ZoneManager.getAllZones()) {
int size = zoneMicro.zoneMobSet.size(); int size = zoneMicro.zoneMobSet.size();
if (size >= count){ if (size >= count) {
plusplus++; plusplus++;
throwbackInfo(pcSender, zoneMicro.getName() + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. "); throwbackInfo(pcSender, zoneMicro.getName() + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. ");
System.out.println(zoneMicro.getName() + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. "); System.out.println(zoneMicro.getName() + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. ");
@ -45,7 +46,7 @@ public class AuditMobsCmd extends AbstractDevCmd {
} }
throwbackInfo(pcSender," there are " +plusplus + " zones with at least " + count + " mobs in each."); throwbackInfo(pcSender, " there are " + plusplus + " zones with at least " + count + " mobs in each.");
} }
return; return;
} }
@ -83,12 +84,10 @@ public class AuditMobsCmd extends AbstractDevCmd {
throwbackInfo(pcSender, "UUID, dbID, inRespawnMap, isAlive, activeAI, Loc"); throwbackInfo(pcSender, "UUID, dbID, inRespawnMap, isAlive, activeAI, Loc");
//mob not found in spawn map, check respawn //mob not found in spawn map, check respawn
boolean inRespawn = false; boolean inRespawn = false;
} }

14
src/engine/devcmd/cmds/BoundsCmd.java

@ -24,14 +24,14 @@ public class BoundsCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pcSender, String[] words, protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (target == null || !target.getObjectType().equals(GameObjectType.Building)){ if (target == null || !target.getObjectType().equals(GameObjectType.Building)) {
this.throwbackError(pcSender, "No Building Selected"); this.throwbackError(pcSender, "No Building Selected");
return; return;
} }
Building building = (Building)target; Building building = (Building) target;
if (building.getBounds() == null){ if (building.getBounds() == null) {
this.throwbackInfo(pcSender, "No valid Bounds for building UUID " + building.getObjectUUID()); this.throwbackInfo(pcSender, "No valid Bounds for building UUID " + building.getObjectUUID());
return; return;
} }
@ -52,10 +52,10 @@ public class BoundsCmd extends AbstractDevCmd {
String output = "Bounds Information for Building UUID " + building.getObjectUUID(); String output = "Bounds Information for Building UUID " + building.getObjectUUID();
output += newLine; output += newLine;
output+= "Top Left : " + topLeftX + " , " + topLeftY + newLine; output += "Top Left : " + topLeftX + " , " + topLeftY + newLine;
output+= "Top Right : " + topRightX + " , " + topRightY + newLine; output += "Top Right : " + topRightX + " , " + topRightY + newLine;
output+= "Bottom Left : " + bottomLeftX + " , " + bottomLeftY + newLine; output += "Bottom Left : " + bottomLeftX + " , " + bottomLeftY + newLine;
output+= "Bottom Right : " + bottomRightX + " , " + bottomRightY + newLine; output += "Bottom Right : " + bottomRightX + " , " + bottomRightY + newLine;
this.throwbackInfo(pcSender, output); this.throwbackInfo(pcSender, output);

2
src/engine/devcmd/cmds/ChangeNameCmd.java

@ -39,7 +39,7 @@ public class ChangeNameCmd extends AbstractDevCmd {
String newLast = ""; String newLast = "";
if (words.length > 2) { if (words.length > 2) {
newLast = words[2]; newLast = words[2];
for (int i=3; i<words.length; i++) for (int i = 3; i < words.length; i++)
newLast += ' ' + words[i]; newLast += ' ' + words[i];
} }

5
src/engine/devcmd/cmds/CombatMessageCmd.java

@ -7,9 +7,6 @@
// www.magicbane.com // www.magicbane.com
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . // • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
@ -27,9 +24,7 @@ import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
/** /**
*
* @author Eighty * @author Eighty
*
*/ */
public class CombatMessageCmd extends AbstractDevCmd { public class CombatMessageCmd extends AbstractDevCmd {

5
src/engine/devcmd/cmds/CreateItemCmd.java

@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter;
/** /**
* @author Eighty * @author Eighty
*
*/ */
public class CreateItemCmd extends AbstractDevCmd { public class CreateItemCmd extends AbstractDevCmd {
@ -37,14 +36,14 @@ public class CreateItemCmd extends AbstractDevCmd {
if (id == 0) if (id == 0)
id = Integer.parseInt(words[0]); id = Integer.parseInt(words[0]);
if (id == 7){ if (id == 7) {
this.throwbackInfo(pc, "use /addgold to add gold....."); this.throwbackInfo(pc, "use /addgold to add gold.....");
return; return;
} }
int size = 1; int size = 1;
if(words.length < 3) { if (words.length < 3) {
size = Integer.parseInt(words[1]); size = Integer.parseInt(words[1]);
} }

17
src/engine/devcmd/cmds/DebugCmd.java

@ -17,12 +17,19 @@ import engine.objects.PlayerCharacter;
public class DebugCmd extends AbstractDevCmd { public class DebugCmd extends AbstractDevCmd {
public DebugCmd() { public DebugCmd() {
super("debug"); super("debug");
// super("debug", MBServerStatics.ACCESS_GROUP_ALL_TEAM, 0, false, false); // super("debug", MBServerStatics.ACCESS_GROUP_ALL_TEAM, 0, false, false);
} }
private static void toggleDebugTimer(PlayerCharacter pc, String name, int num, int duration, boolean toggle) {
if (toggle) {
DebugTimerJob dtj = new DebugTimerJob(pc, name, num, duration);
pc.renewTimer(name, dtj, duration);
} else
pc.cancelTimer(name);
}
@Override @Override
protected void _doCmd(PlayerCharacter pc, String[] words, protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
@ -112,12 +119,4 @@ public class DebugCmd extends AbstractDevCmd {
protected String _getUsageString() { protected String _getUsageString() {
return "'./Debug command on/off'"; return "'./Debug command on/off'";
} }
private static void toggleDebugTimer(PlayerCharacter pc, String name, int num, int duration, boolean toggle) {
if (toggle) {
DebugTimerJob dtj = new DebugTimerJob(pc, name, num, duration);
pc.renewTimer(name, dtj, duration);
} else
pc.cancelTimer(name);
}
} }

1
src/engine/devcmd/cmds/DebugMeleeSyncCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;

4
src/engine/devcmd/cmds/DecachePlayerCmd.java

@ -27,13 +27,13 @@ public class DecachePlayerCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pc, String[] words, protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if(words.length < 1) { if (words.length < 1) {
this.sendUsage(pc); this.sendUsage(pc);
} }
int objectUUID = Integer.parseInt(words[0]); int objectUUID = Integer.parseInt(words[0]);
if(DbManager.inCache(Enum.GameObjectType.PlayerCharacter, objectUUID)) { if (DbManager.inCache(Enum.GameObjectType.PlayerCharacter, objectUUID)) {
this.setTarget(PlayerCharacter.getFromCache(objectUUID)); //for logging this.setTarget(PlayerCharacter.getFromCache(objectUUID)); //for logging
PlayerCharacter.getFromCache(objectUUID).removeFromCache(); PlayerCharacter.getFromCache(objectUUID).removeFromCache();
} else { } else {

13
src/engine/devcmd/cmds/DespawnCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
@ -27,21 +26,15 @@ public class DespawnCmd extends AbstractDevCmd {
AbstractGameObject target) { AbstractGameObject target) {
if (pc == null) { if (pc == null) {
return; return;
} }
Mob mob = null; Mob mob = null;
if (target != null && target.getObjectType().equals(GameObjectType.Mob)) if (target != null && target.getObjectType().equals(GameObjectType.Mob))
mob = (Mob)target; mob = (Mob) target;
if (mob == null) if (mob == null)
mob = Mob.getFromCache(Integer.parseInt(words[1])); mob = Mob.getFromCache(Integer.parseInt(words[1]));
@ -49,10 +42,10 @@ public class DespawnCmd extends AbstractDevCmd {
if (mob == null) if (mob == null)
return; return;
if (words[0].equalsIgnoreCase("respawn")){ if (words[0].equalsIgnoreCase("respawn")) {
mob.respawn(); mob.respawn();
this.throwbackInfo(pc, "Mob with ID " + mob.getObjectUUID() + " Respawned"); this.throwbackInfo(pc, "Mob with ID " + mob.getObjectUUID() + " Respawned");
}else if (words[0].equalsIgnoreCase("despawn")){ } else if (words[0].equalsIgnoreCase("despawn")) {
mob.despawn(); mob.despawn();
this.throwbackInfo(pc, "Mob with ID " + mob.getObjectUUID() + " Despawned"); this.throwbackInfo(pc, "Mob with ID " + mob.getObjectUUID() + " Despawned");
} }

5
src/engine/devcmd/cmds/DistanceCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
@ -27,8 +26,6 @@ public class DistanceCmd extends AbstractDevCmd {
AbstractGameObject target) { AbstractGameObject target) {
// Arg Count Check // Arg Count Check
if (words.length != 1) { if (words.length != 1) {
this.sendUsage(pc); this.sendUsage(pc);
@ -43,7 +40,7 @@ public class DistanceCmd extends AbstractDevCmd {
return; return;
} }
AbstractWorldObject awoTarget = (AbstractWorldObject)target; AbstractWorldObject awoTarget = (AbstractWorldObject) target;
Vector3fImmutable pcLoc = pc.getLoc(); Vector3fImmutable pcLoc = pc.getLoc();
Vector3fImmutable tarLoc = awoTarget.getLoc(); Vector3fImmutable tarLoc = awoTarget.getLoc();

2
src/engine/devcmd/cmds/EffectCmd.java

@ -17,9 +17,7 @@ import engine.objects.PlayerCharacter;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
/** /**
*
* @author Eighty * @author Eighty
*
*/ */
public class EffectCmd extends AbstractDevCmd { public class EffectCmd extends AbstractDevCmd {

13
src/engine/devcmd/cmds/EnchantCmd.java

@ -28,14 +28,13 @@ public class EnchantCmd extends AbstractDevCmd {
} }
try{ try {
rank = Integer.parseInt(words[0]); rank = Integer.parseInt(words[0]);
}catch(Exception e){ } catch (Exception e) {
} }
Item item; Item item;
if (target == null || target instanceof Item) if (target == null || target instanceof Item)
item = (Item) target; item = (Item) target;
@ -56,12 +55,12 @@ public class EnchantCmd extends AbstractDevCmd {
this.setResult(String.valueOf(item.getObjectUUID())); this.setResult(String.valueOf(item.getObjectUUID()));
} else { } else {
int cnt = words.length; int cnt = words.length;
for (int i=1;i<cnt;i++) { for (int i = 1; i < cnt; i++) {
String enchant = words[i]; String enchant = words[i];
boolean valid = true; boolean valid = true;
for (Effect eff: item.getEffects().values()){ for (Effect eff : item.getEffects().values()) {
if (eff.getEffectsBase().getIDString().equals(enchant)){ if (eff.getEffectsBase().getIDString().equals(enchant)) {
throwbackError(pc,"This item already has that enchantment"); throwbackError(pc, "This item already has that enchantment");
return; return;
} }
} }

3
src/engine/devcmd/cmds/FlashMsgCmd.java

@ -15,9 +15,7 @@ import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
/** /**
*
* @author Eighty * @author Eighty
*
*/ */
public class FlashMsgCmd extends AbstractDevCmd { public class FlashMsgCmd extends AbstractDevCmd {
@ -39,7 +37,6 @@ public class FlashMsgCmd extends AbstractDevCmd {
* This function is called by the DevCmdManager. Override to avoid splitting * This function is called by the DevCmdManager. Override to avoid splitting
* argString into String array, since flash displays full String as message, * argString into String array, since flash displays full String as message,
* then calls the subclass specific _doCmd method. * then calls the subclass specific _doCmd method.
*
*/ */
@Override @Override

5
src/engine/devcmd/cmds/GateInfoCmd.java

@ -23,7 +23,7 @@ public class GateInfoCmd extends AbstractDevCmd {
Runegate runeGate; Runegate runeGate;
Blueprint blueprint; Blueprint blueprint;
String newline = "\r\n "; String newline = "\r\n ";
targetBuilding = (Building)target; targetBuilding = (Building) target;
if (targetBuilding.getObjectType() != GameObjectType.Building) { if (targetBuilding.getObjectType() != GameObjectType.Building) {
throwbackInfo(player, "GateInfo: target must be a Building"); throwbackInfo(player, "GateInfo: target must be a Building");
@ -34,7 +34,7 @@ public class GateInfoCmd extends AbstractDevCmd {
blueprint = Blueprint._meshLookup.get(targetBuilding.getMeshUUID()); blueprint = Blueprint._meshLookup.get(targetBuilding.getMeshUUID());
if (blueprint == null || if (blueprint == null ||
(blueprint.getBuildingGroup() != BuildingGroup.RUNEGATE)){ (blueprint.getBuildingGroup() != BuildingGroup.RUNEGATE)) {
throwbackInfo(player, "showgate: target must be a Runegate"); throwbackInfo(player, "showgate: target must be a Runegate");
return; return;
} }
@ -81,5 +81,4 @@ public class GateInfoCmd extends AbstractDevCmd {
} }
} }

8
src/engine/devcmd/cmds/GetBankCmd.java

@ -17,9 +17,7 @@ import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
/** /**
*
* @author Eighty * @author Eighty
*
*/ */
public class GetBankCmd extends AbstractDevCmd { public class GetBankCmd extends AbstractDevCmd {
@ -30,10 +28,12 @@ public class GetBankCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pcSender, String[] args, protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) { AbstractGameObject target) {
if (pcSender == null) return; if (pcSender == null)
return;
ClientConnection cc = SessionManager.getClientConnection(pcSender); ClientConnection cc = SessionManager.getClientConnection(pcSender);
if (cc == null) return; if (cc == null)
return;
VendorDialogMsg.getBank(pcSender, null, cc); VendorDialogMsg.getBank(pcSender, null, cc);
this.setTarget(pcSender); //for logging this.setTarget(pcSender); //for logging

41
src/engine/devcmd/cmds/GetHeightCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.InterestManagement.HeightMap; import engine.InterestManagement.HeightMap;
@ -41,7 +40,7 @@ public class GetHeightCmd extends AbstractDevCmd {
Zone zone = ZoneManager.findSmallestZone(pc.getLoc()); Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
this.throwbackInfo(pc, "Water Level : " + zone.getSeaLevel()); this.throwbackInfo(pc, "Water Level : " + zone.getSeaLevel());
this.throwbackInfo(pc, "Character Water Level Above : " + (pc.getCharacterHeight() + height - zone.getSeaLevel()) ); this.throwbackInfo(pc, "Character Water Level Above : " + (pc.getCharacterHeight() + height - zone.getSeaLevel()));
if (end) if (end)
return; return;
@ -62,9 +61,9 @@ public class GetHeightCmd extends AbstractDevCmd {
//find the next parents heightmap if the currentzone heightmap is null. //find the next parents heightmap if the currentzone heightmap is null.
while (heightMap == null){ while (heightMap == null) {
if (currentZone == ZoneManager.getSeaFloor()){ if (currentZone == ZoneManager.getSeaFloor()) {
this.throwbackInfo(pc, "Could not find a heightmap to get height."); this.throwbackInfo(pc, "Could not find a heightmap to get height.");
break; break;
} }
@ -76,9 +75,9 @@ public class GetHeightCmd extends AbstractDevCmd {
} }
if ( (heightMap == null) || (currentZone == ZoneManager.getSeaFloor()) ) { if ((heightMap == null) || (currentZone == ZoneManager.getSeaFloor())) {
this.throwbackInfo(pc, currentZone.getName() + " has no heightmap " ); this.throwbackInfo(pc, currentZone.getName() + " has no heightmap ");
this.throwbackInfo(pc, "Current altitude: " + currentZone.absY ); this.throwbackInfo(pc, "Current altitude: " + currentZone.absY);
return; return;
} }
@ -88,8 +87,6 @@ public class GetHeightCmd extends AbstractDevCmd {
this.throwbackInfo(pc, "SeaFloor Local : " + seaFloorLocalLoc.x + " , " + seaFloorLocalLoc.y); this.throwbackInfo(pc, "SeaFloor Local : " + seaFloorLocalLoc.x + " , " + seaFloorLocalLoc.y);
this.throwbackInfo(pc, "Local Zone Location : " + zoneLoc.x + " , " + zoneLoc.y); this.throwbackInfo(pc, "Local Zone Location : " + zoneLoc.x + " , " + zoneLoc.y);
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone); Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone);
Vector3fImmutable parentLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone.getParent()); Vector3fImmutable parentLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone.getParent());
@ -99,10 +96,11 @@ public class GetHeightCmd extends AbstractDevCmd {
Vector2f parentZoneLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), currentZone.getParent()); Vector2f parentZoneLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), currentZone.getParent());
this.throwbackInfo(pc, "Parent Zone Location from Bottom Left : " + parentZoneLoc); this.throwbackInfo(pc, "Parent Zone Location from Bottom Left : " + parentZoneLoc);
if ((parentZone != null ) && (parentZone.getHeightMap() != null)) { if ((parentZone != null) && (parentZone.getHeightMap() != null)) {
parentLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), parentZone); parentLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), parentZone);
parentGrid = parentZone.getHeightMap().getGridSquare( parentLoc); parentGrid = parentZone.getHeightMap().getGridSquare(parentLoc);
} else parentGrid = new Vector2f(-1,-1); } else
parentGrid = new Vector2f(-1, -1);
gridSquare = heightMap.getGridSquare(zoneLoc); gridSquare = heightMap.getGridSquare(zoneLoc);
gridOffset = HeightMap.getGridOffset(gridSquare); gridOffset = HeightMap.getGridOffset(gridSquare);
@ -110,7 +108,7 @@ public class GetHeightCmd extends AbstractDevCmd {
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
this.throwbackInfo(pc, currentZone.getName()); this.throwbackInfo(pc, currentZone.getName());
this.throwbackInfo(pc, "Current Grid Square: " + gridSquare.x + " , " + gridSquare.y ); this.throwbackInfo(pc, "Current Grid Square: " + gridSquare.x + " , " + gridSquare.y);
this.throwbackInfo(pc, "Grid Offset: " + gridOffset.x + " , " + gridOffset.y); this.throwbackInfo(pc, "Grid Offset: " + gridOffset.x + " , " + gridOffset.y);
this.throwbackInfo(pc, "Parent Grid: " + parentGrid.x + " , " + parentGrid.y); this.throwbackInfo(pc, "Parent Grid: " + parentGrid.x + " , " + parentGrid.y);
@ -126,15 +124,15 @@ public class GetHeightCmd extends AbstractDevCmd {
float realWorldAltitude = interaltitude + currentZone.getWorldAltitude(); float realWorldAltitude = interaltitude + currentZone.getWorldAltitude();
//OUTSET //OUTSET
if (parentZone != null){ if (parentZone != null) {
float parentXRadius = currentZone.getBounds().getHalfExtents().x; float parentXRadius = currentZone.getBounds().getHalfExtents().x;
float parentZRadius = currentZone.getBounds().getHalfExtents().y; float parentZRadius = currentZone.getBounds().getHalfExtents().y;
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius)); float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius)); float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
float bucketScaleX = 100/parentXRadius; float bucketScaleX = 100 / parentXRadius;
float bucketScaleZ = 200/parentZRadius; float bucketScaleZ = 200 / parentZRadius;
float outsideGridSizeX = 1 - bucketScaleX; //32/256 float outsideGridSizeX = 1 - bucketScaleX; //32/256
float outsideGridSizeZ = 1 - bucketScaleZ; float outsideGridSizeZ = 1 - bucketScaleZ;
@ -143,7 +141,7 @@ public class GetHeightCmd extends AbstractDevCmd {
double scale; double scale;
if (offsetX > outsideGridSizeX && offsetX > offsetZ){ if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
weight = (offsetX - outsideGridSizeX) / bucketScaleX; weight = (offsetX - outsideGridSizeX) / bucketScaleX;
scale = Math.atan2((.5 - weight) * 3.1415927, 1); scale = Math.atan2((.5 - weight) * 3.1415927, 1);
@ -164,7 +162,7 @@ public class GetHeightCmd extends AbstractDevCmd {
outsetALt += currentZone.getParent().getAbsY(); outsetALt += currentZone.getParent().getAbsY();
realWorldAltitude = outsetALt; realWorldAltitude = outsetALt;
}else if (offsetZ > outsideGridSizeZ){ } else if (offsetZ > outsideGridSizeZ) {
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ; weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
scale = Math.atan2((.5 - weight) * 3.1415927, 1); scale = Math.atan2((.5 - weight) * 3.1415927, 1);
@ -184,8 +182,6 @@ public class GetHeightCmd extends AbstractDevCmd {
realWorldAltitude = outsetALt; realWorldAltitude = outsetALt;
} }
} }
@ -196,7 +192,7 @@ public class GetHeightCmd extends AbstractDevCmd {
strMod += 1f; strMod += 1f;
float radius = 0; float radius = 0;
switch (pc.getRaceID()){ switch (pc.getRaceID()) {
case 2017: case 2017:
radius = 3.1415927f; radius = 3.1415927f;
case 2000: case 2000:
@ -210,14 +206,11 @@ public class GetHeightCmd extends AbstractDevCmd {
strMod -= .5f; strMod -= .5f;
realWorldAltitude += strMod; realWorldAltitude += strMod;
this.throwbackInfo(pc, "interpolated height with World: " + realWorldAltitude); this.throwbackInfo(pc, "interpolated height with World: " + realWorldAltitude);
} }
@Override @Override

27
src/engine/devcmd/cmds/GetMemoryCmd.java

@ -19,19 +19,6 @@ public class GetMemoryCmd extends AbstractDevCmd {
super("getmemory"); super("getmemory");
} }
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
String hSize = getMemoryOutput(Runtime.getRuntime().totalMemory());
String mhSize = getMemoryOutput(Runtime.getRuntime().maxMemory());
String fhSize = getMemoryOutput(Runtime.getRuntime().freeMemory());
String out = "Heap Size: " + hSize + ", Max Heap Size: " + mhSize + ", Free Heap Size: " + fhSize;
throwbackInfo(pcSender, out);
}
public static String getMemoryOutput(long memory) { public static String getMemoryOutput(long memory) {
String out = ""; String out = "";
if (memory > 1073741824) if (memory > 1073741824)
@ -44,6 +31,20 @@ public class GetMemoryCmd extends AbstractDevCmd {
return memory + "B"; return memory + "B";
} }
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null)
return;
String hSize = getMemoryOutput(Runtime.getRuntime().totalMemory());
String mhSize = getMemoryOutput(Runtime.getRuntime().maxMemory());
String fhSize = getMemoryOutput(Runtime.getRuntime().freeMemory());
String out = "Heap Size: " + hSize + ", Max Heap Size: " + mhSize + ", Free Heap Size: " + fhSize;
throwbackInfo(pcSender, out);
}
@Override @Override
protected String _getUsageString() { protected String _getUsageString() {
return "' /getmemory'"; return "' /getmemory'";

7
src/engine/devcmd/cmds/GetMobBaseLoot.java

@ -18,7 +18,6 @@ import engine.objects.PlayerCharacter;
/** /**
* @author Eighty * @author Eighty
*
*/ */
public class GetMobBaseLoot extends AbstractDevCmd { public class GetMobBaseLoot extends AbstractDevCmd {
@ -29,14 +28,14 @@ public class GetMobBaseLoot extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pc, String[] words, protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (target.getObjectType() != GameObjectType.Mob){ if (target.getObjectType() != GameObjectType.Mob) {
this.throwbackError(pc, "Must be targeting a Valid Mob For this Command."); this.throwbackError(pc, "Must be targeting a Valid Mob For this Command.");
return; return;
} }
Mob mob = (Mob)target; Mob mob = (Mob) target;
for (MobLootBase mlb : MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())){ for (MobLootBase mlb : MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())) {
this.throwbackInfo(pc, "LootTable11 = " + mlb.getLootTableID() + "\rn "); this.throwbackInfo(pc, "LootTable11 = " + mlb.getLootTableID() + "\rn ");
this.throwbackInfo(pc, "Chance = " + mlb.getChance() + "\rn "); this.throwbackInfo(pc, "Chance = " + mlb.getChance() + "\rn ");

3
src/engine/devcmd/cmds/GetOffsetCmd.java

@ -24,7 +24,8 @@ public class GetOffsetCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pcSender, String[] words, protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (pcSender == null) return; if (pcSender == null)
return;
Zone zone = null; Zone zone = null;
try { try {

3
src/engine/devcmd/cmds/GetRuneDropRateCmd.java

@ -23,7 +23,8 @@ public class GetRuneDropRateCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pcSender, String[] words, protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (pcSender == null) return; if (pcSender == null)
return;
String out = "Depracated"; String out = "Depracated";
throwbackInfo(pcSender, out); throwbackInfo(pcSender, out);

6
src/engine/devcmd/cmds/GetVaultCmd.java

@ -25,10 +25,12 @@ public class GetVaultCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pcSender, String[] args, protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) { AbstractGameObject target) {
if (pcSender == null) return; if (pcSender == null)
return;
ClientConnection cc = SessionManager.getClientConnection(pcSender); ClientConnection cc = SessionManager.getClientConnection(pcSender);
if (cc == null) return; if (cc == null)
return;
VendorDialogMsg.getVault(pcSender, null, cc); VendorDialogMsg.getVault(pcSender, null, cc);
this.setTarget(pcSender); //for logging this.setTarget(pcSender); //for logging

3
src/engine/devcmd/cmds/GetZoneCmd.java

@ -26,7 +26,8 @@ public class GetZoneCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pcSender, String[] words, protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (pcSender == null) return; if (pcSender == null)
return;
if (words.length != 1) { if (words.length != 1) {
this.sendUsage(pcSender); this.sendUsage(pcSender);

6
src/engine/devcmd/cmds/GetZoneMobsCmd.java

@ -25,13 +25,15 @@ public class GetZoneMobsCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pcSender, String[] words, protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (pcSender == null) return; if (pcSender == null)
return;
int loadID = 0; int loadID = 0;
if (words.length == 1) { if (words.length == 1) {
try { try {
loadID = Integer.parseInt(words[0]); loadID = Integer.parseInt(words[0]);
} catch (Exception e) {} } catch (Exception e) {
}
} }
//find the zone //find the zone

17
src/engine/devcmd/cmds/GotoBoundsCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
@ -30,27 +29,27 @@ public class GotoBoundsCmd extends AbstractDevCmd {
String corner = words[0]; String corner = words[0];
Vector3fImmutable targetLoc = Vector3fImmutable.ZERO; Vector3fImmutable targetLoc = Vector3fImmutable.ZERO;
if (target == null || !target.getObjectType().equals(GameObjectType.Building)){ if (target == null || !target.getObjectType().equals(GameObjectType.Building)) {
this.throwbackError(player, "No Building Selected"); this.throwbackError(player, "No Building Selected");
return; return;
} }
Building building = (Building)target; Building building = (Building) target;
if (building.getBounds() == null){ if (building.getBounds() == null) {
this.throwbackInfo(player, "No valid Bounds for building UUID " + building.getObjectUUID()); this.throwbackInfo(player, "No valid Bounds for building UUID " + building.getObjectUUID());
return; return;
} }
float x = building.getBounds().getHalfExtents().x; float x = building.getBounds().getHalfExtents().x;
float z = building.getBounds().getHalfExtents().y; float z = building.getBounds().getHalfExtents().y;
if (building.getBlueprint() != null){ if (building.getBlueprint() != null) {
x = building.getBlueprint().getExtents().x; x = building.getBlueprint().getExtents().x;
z = building.getBlueprint().getExtents().y; z = building.getBlueprint().getExtents().y;
} }
float topLeftX = building.getLoc().x - x; float topLeftX = building.getLoc().x - x;
float topLeftY = building.getLoc().z -z; float topLeftY = building.getLoc().z - z;
float topRightX = building.getLoc().x + x; float topRightX = building.getLoc().x + x;
float topRightY = building.getLoc().z - z; float topRightY = building.getLoc().z - z;
@ -58,11 +57,11 @@ public class GotoBoundsCmd extends AbstractDevCmd {
float bottomLeftX = building.getLoc().x - x; float bottomLeftX = building.getLoc().x - x;
float bottomLeftY = building.getLoc().z + z; float bottomLeftY = building.getLoc().z + z;
float bottomRightX = building.getLoc().x +x; float bottomRightX = building.getLoc().x + x;
float bottomRightY = building.getLoc().z + z; float bottomRightY = building.getLoc().z + z;
switch (corner){ switch (corner) {
case "topleft": case "topleft":
targetLoc = new Vector3fImmutable(topLeftX, 0, topLeftY); targetLoc = new Vector3fImmutable(topLeftX, 0, topLeftY);
break; break;
@ -81,7 +80,7 @@ public class GotoBoundsCmd extends AbstractDevCmd {
} }
targetLoc = Vector3fImmutable.transform(building.getLoc(),targetLoc , building.getBounds().getRotationDegrees()); targetLoc = Vector3fImmutable.transform(building.getLoc(), targetLoc, building.getBounds().getRotationDegrees());
// Teleport player // Teleport player

39
src/engine/devcmd/cmds/GotoCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
@ -34,20 +33,20 @@ public class GotoCmd extends AbstractDevCmd {
// Arg Count Check // Arg Count Check
if (target != null && words[0].isEmpty()){ if (target != null && words[0].isEmpty()) {
AbstractWorldObject targetAgo = (AbstractWorldObject)target; AbstractWorldObject targetAgo = (AbstractWorldObject) target;
pc.teleport(targetAgo.getLoc()); pc.teleport(targetAgo.getLoc());
return; return;
} }
if (words[0].isEmpty()){ if (words[0].isEmpty()) {
this.sendUsage(pc); this.sendUsage(pc);
return; return;
} }
if (words[0].equalsIgnoreCase("playground")){ if (words[0].equalsIgnoreCase("playground")) {
if (target instanceof AbstractCharacter){ if (target instanceof AbstractCharacter) {
loc = new Vector3fImmutable(63276,0,-54718); loc = new Vector3fImmutable(63276, 0, -54718);
} }
if (loc != null) if (loc != null)
@ -56,9 +55,9 @@ public class GotoCmd extends AbstractDevCmd {
return; return;
} }
if (words[0].equalsIgnoreCase("coc")){ if (words[0].equalsIgnoreCase("coc")) {
if (target instanceof AbstractCharacter){ if (target instanceof AbstractCharacter) {
loc = new Vector3fImmutable(98561.656f,0,-13353.778f); loc = new Vector3fImmutable(98561.656f, 0, -13353.778f);
} }
if (loc != null) if (loc != null)
@ -68,20 +67,20 @@ public class GotoCmd extends AbstractDevCmd {
} }
String cityName = ""; String cityName = "";
for (String partial: words){ for (String partial : words) {
cityName += partial + ' '; cityName += partial + ' ';
} }
cityName = cityName.substring(0, cityName.length() - 1); cityName = cityName.substring(0, cityName.length() - 1);
for (AbstractGameObject cityAgo: DbManager.getList(GameObjectType.City)){ for (AbstractGameObject cityAgo : DbManager.getList(GameObjectType.City)) {
City city = (City)cityAgo; City city = (City) cityAgo;
if (city == null) if (city == null)
continue; continue;
if (!city.getCityName().equalsIgnoreCase(cityName)) if (!city.getCityName().equalsIgnoreCase(cityName))
continue; continue;
Zone zone = city.getParent(); Zone zone = city.getParent();
if (zone != null){ if (zone != null) {
if (zone.isNPCCity() || zone.isPlayerCity()) if (zone.isNPCCity() || zone.isPlayerCity())
loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS); loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS);
else else
@ -93,14 +92,14 @@ public class GotoCmd extends AbstractDevCmd {
} }
} }
if (loc == null){ if (loc == null) {
for (AbstractGameObject zoneAgo: DbManager.getList(GameObjectType.Zone)){ for (AbstractGameObject zoneAgo : DbManager.getList(GameObjectType.Zone)) {
Zone zone = (Zone)zoneAgo; Zone zone = (Zone) zoneAgo;
if (zone == null) if (zone == null)
continue; continue;
if (!zone.getName().equalsIgnoreCase(cityName)) if (!zone.getName().equalsIgnoreCase(cityName))
continue; continue;
if (zone != null){ if (zone != null) {
if (zone.isNPCCity() || zone.isPlayerCity()) if (zone.isNPCCity() || zone.isPlayerCity())
loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS); loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS);
else else
@ -112,12 +111,12 @@ public class GotoCmd extends AbstractDevCmd {
} }
} }
} }
if (loc == null && words.length == 1){ if (loc == null && words.length == 1) {
try { try {
PlayerCharacter pcDest = SessionManager PlayerCharacter pcDest = SessionManager
.getPlayerCharacterByLowerCaseName(words[0]); .getPlayerCharacterByLowerCaseName(words[0]);
if (pcDest == null){ if (pcDest == null) {
this.throwbackError(pc, "Player or Zone not found by name: " this.throwbackError(pc, "Player or Zone not found by name: "
+ words[0]); + words[0]);
this.throwbackInfo(pc, "If you have spaces in the zone name, replace them with '_'"); this.throwbackInfo(pc, "If you have spaces in the zone name, replace them with '_'");

1
src/engine/devcmd/cmds/GotoObj.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum; import engine.Enum;

1
src/engine/devcmd/cmds/HeartbeatCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.ai.MobileFSMManager; import engine.ai.MobileFSMManager;

2
src/engine/devcmd/cmds/HotzoneCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
@ -63,6 +62,7 @@ public class HotzoneCmd extends AbstractDevCmd {
return; return;
} }
@Override @Override
protected String _getHelpString() { protected String _getHelpString() {
return "Use no arguments to see the current hotzone or \"random\" to change it randomly."; return "Use no arguments to see the current hotzone or \"random\" to change it randomly.";

87
src/engine/devcmd/cmds/InfoCmd.java

@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentHashMap;
/** /**
* @author * @author
*
*/ */
public class InfoCmd extends AbstractDevCmd { public class InfoCmd extends AbstractDevCmd {
@ -118,7 +117,7 @@ public class InfoCmd extends AbstractDevCmd {
output += ' ' + targetBuilding.getBlueprint().getName(); output += ' ' + targetBuilding.getBlueprint().getName();
output += newline; output += newline;
output += targetBuilding.getBlueprint() != null ? targetBuilding.getBlueprint().getBuildingGroup().name(): " no building group"; output += targetBuilding.getBlueprint() != null ? targetBuilding.getBlueprint().getBuildingGroup().name() : " no building group";
output += newline; output += newline;
output += "EffectFlags: " + targetBuilding.getEffectFlags(); output += "EffectFlags: " + targetBuilding.getEffectFlags();
@ -183,40 +182,40 @@ public class InfoCmd extends AbstractDevCmd {
output += "Nation crest: " + nTag; output += "Nation crest: " + nTag;
} }
output+= newline; output += newline;
if (targetBuilding.getBlueprint() != null){ if (targetBuilding.getBlueprint() != null) {
if(targetBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.MINE){ if (targetBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.MINE) {
Mine mine = Mine.getMineFromTower(targetBuilding.getObjectUUID()); Mine mine = Mine.getMineFromTower(targetBuilding.getObjectUUID());
if (mine != null){ if (mine != null) {
output+= newline; output += newline;
output+= "Mine active: " + mine.getIsActive(); output += "Mine active: " + mine.getIsActive();
output+= newline; output += newline;
output+= "Was claimed: " + mine.wasClaimed; output += "Was claimed: " + mine.wasClaimed;
output+= newline; output += newline;
output+= "Mine Type: "+mine.getMineType().name; output += "Mine Type: " + mine.getMineType().name;
output+= newline; output += newline;
output+= "Expansion : " + mine.isExpansion(); output += "Expansion : " + mine.isExpansion();
output+= newline; output += newline;
output+= "Production type: " +mine.getProduction().name(); output += "Production type: " + mine.getProduction().name();
} }
} }
output += newline; output += newline;
if (targetBuilding.maintDateTime != null){ if (targetBuilding.maintDateTime != null) {
output += targetBuilding.maintDateTime.toString(); output += targetBuilding.maintDateTime.toString();
output+= newline; output += newline;
} }
} }
output += "Reserve : " + targetBuilding.reserve; output += "Reserve : " + targetBuilding.reserve;
output+= newline; output += newline;
output += "Strongbox : " + targetBuilding.getStrongboxValue(); output += "Strongbox : " + targetBuilding.getStrongboxValue();
output+= newline; output += newline;
// List hirelings // List hirelings
@ -235,13 +234,13 @@ public class InfoCmd extends AbstractDevCmd {
} }
ArrayList<BuildingRegions> tempList = BuildingRegions._staticRegions.get(targetBuilding.getMeshUUID()); ArrayList<BuildingRegions> tempList = BuildingRegions._staticRegions.get(targetBuilding.getMeshUUID());
output+= newline; output += newline;
output+= "Building Regions: Size - " + tempList.size(); output += "Building Regions: Size - " + tempList.size();
output+= newline; output += newline;
output+= "Building Regions from Bounds: Size - " + targetBuilding.getBounds().getRegions().size(); output += "Building Regions from Bounds: Size - " + targetBuilding.getBounds().getRegions().size();
output+= newline; output += newline;
for (Regions regions: targetBuilding.getBounds().getRegions()){ for (Regions regions : targetBuilding.getBounds().getRegions()) {
//TODO ADD REGION INFO //TODO ADD REGION INFO
} }
@ -258,8 +257,8 @@ public class InfoCmd extends AbstractDevCmd {
output += "Race: " + targetPC.getRace().getName(); output += "Race: " + targetPC.getRace().getName();
output += newline; output += newline;
output += "Safe:" + targetPC.inSafeZone(); output += "Safe:" + targetPC.inSafeZone();
output+= newline; output += newline;
output+= "Experience : " + targetPC.getExp(); output += "Experience : " + targetPC.getExp();
output += newline; output += newline;
output += "OverFlowExperience : " + targetPC.getOverFlowEXP(); output += "OverFlowExperience : " + targetPC.getOverFlowEXP();
output += newline; output += newline;
@ -282,13 +281,13 @@ public class InfoCmd extends AbstractDevCmd {
output += newline; output += newline;
output += "Max Inventory Weight:" + ((int) targetPC.statStrBase * 3); output += "Max Inventory Weight:" + ((int) targetPC.statStrBase * 3);
output += newline; output += newline;
output += "ALTITUDE :"+ targetPC.getAltitude(); output += "ALTITUDE :" + targetPC.getAltitude();
output += newline; output += newline;
output += "BuildingID :"+ targetPC.getInBuildingID(); output += "BuildingID :" + targetPC.getInBuildingID();
output += newline; output += newline;
output += "inBuilding :"+ targetPC.getInBuilding(); output += "inBuilding :" + targetPC.getInBuilding();
output += newline; output += newline;
output += "inFloor :"+ targetPC.getInFloorID(); output += "inFloor :" + targetPC.getInFloorID();
output += newline; output += newline;
BaseClass baseClass = targetPC.getBaseClass(); BaseClass baseClass = targetPC.getBaseClass();
@ -309,12 +308,12 @@ public class InfoCmd extends AbstractDevCmd {
output += "====Guild Info===="; output += "====Guild Info====";
output += newline; output += newline;
if (targetPC.getGuild() != null){ if (targetPC.getGuild() != null) {
output += "Name: " + targetPC.getGuild().getName(); output += "Name: " + targetPC.getGuild().getName();
output += newline; output += newline;
output += "State: " + targetPC.getGuild().getGuildState(); output += "State: " + targetPC.getGuild().getGuildState();
output += newline; output += newline;
output += "Realms Owned:" +targetPC.getGuild().getRealmsOwned(); output += "Realms Owned:" + targetPC.getGuild().getRealmsOwned();
output += newline; output += newline;
output += "====Nation===="; output += "====Nation====";
output += newline; output += newline;
@ -322,9 +321,9 @@ public class InfoCmd extends AbstractDevCmd {
output += newline; output += newline;
output += "Nation State: " + targetPC.getGuild().getNation().getGuildState(); output += "Nation State: " + targetPC.getGuild().getNation().getGuildState();
output += newline; output += newline;
output += "Realms Owned:" +targetPC.getGuild().getNation().getRealmsOwned(); output += "Realms Owned:" + targetPC.getGuild().getNation().getRealmsOwned();
output += newline; output += newline;
output += "Guild Rank:" +(GuildStatusController.getRank(targetPC.getGuildStatus()) + targetPC.getGuild().getRealmsOwnedFlag()); output += "Guild Rank:" + (GuildStatusController.getRank(targetPC.getGuildStatus()) + targetPC.getGuild().getRealmsOwnedFlag());
} }
output += newline; output += newline;
@ -426,8 +425,7 @@ public class InfoCmd extends AbstractDevCmd {
output += newline; output += newline;
output += "enemy: " + targetMob.enemy.toString(); output += "enemy: " + targetMob.enemy.toString();
output += newline; output += newline;
} } catch (Exception ex) {
catch(Exception ex){
//who cares its info //who cares its info
} }
output += "Spawn: (" + targetMob.getBindLoc().getX(); output += "Spawn: (" + targetMob.getBindLoc().getX();
@ -436,10 +434,11 @@ public class InfoCmd extends AbstractDevCmd {
output += newline; output += newline;
if (targetMob.isPet()) { if (targetMob.isPet()) {
output += "isPet: true"; output += "isPet: true";
output+= newline; output += newline;
if (targetMob.isSummonedPet()) if (targetMob.isSummonedPet())
output += "isSummonedPet: true"; output += "isSummonedPet: true";
else output += "isSummonedPet: false"; else
output += "isSummonedPet: false";
PlayerCharacter owner = targetMob.getOwner(); PlayerCharacter owner = targetMob.getOwner();
if (owner != null) if (owner != null)
output += " owner: " + owner.getObjectUUID(); output += " owner: " + owner.getObjectUUID();
@ -472,7 +471,7 @@ public class InfoCmd extends AbstractDevCmd {
output += newline; output += newline;
try { try {
output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum(); output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum();
} catch(Exception ex){ } catch (Exception ex) {
//who cares //who cares
} }
output += newline; output += newline;
@ -488,7 +487,7 @@ public class InfoCmd extends AbstractDevCmd {
output += "BuildingID : " + targetMob.building + newline; output += "BuildingID : " + targetMob.building + newline;
output += "Bind Loc : " + targetMob.getBindLoc() + newline; output += "Bind Loc : " + targetMob.getBindLoc() + newline;
output += "Curr Loc : " + targetMob.getLoc() + newline; output += "Curr Loc : " + targetMob.getLoc() + newline;
}else{ } else {
output += newline; output += newline;
output += "No building found."; output += "No building found.";
} }
@ -516,8 +515,8 @@ public class InfoCmd extends AbstractDevCmd {
ConcurrentHashMap<String, Effect> effects = item.getEffects(); ConcurrentHashMap<String, Effect> effects = item.getEffects();
for (String name : effects.keySet()) { for (String name : effects.keySet()) {
Effect eff = effects.get(name); Effect eff = effects.get(name);
output+= eff.getEffectsBase().getIDString(); output += eff.getEffectsBase().getIDString();
output+= newline; output += newline;
// output += eff.getEffectToken() + (eff.bakedInStat() ? " (baked in)" : "") + newline; // output += eff.getEffectToken() + (eff.bakedInStat() ? " (baked in)" : "") + newline;
} }

2
src/engine/devcmd/cmds/JumpCmd.java

@ -31,7 +31,7 @@ public class JumpCmd extends AbstractDevCmd {
//test //test
if (words[0].equalsIgnoreCase("face")){ if (words[0].equalsIgnoreCase("face")) {
try { try {
float range = Float.parseFloat(words[1]); float range = Float.parseFloat(words[1]);

18
src/engine/devcmd/cmds/MBDropCmd.java

@ -16,9 +16,7 @@ import engine.objects.LootTable;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
/** /**
*
* @author Eighty * @author Eighty
*
*/ */
public class MBDropCmd extends AbstractDevCmd { public class MBDropCmd extends AbstractDevCmd {
@ -30,14 +28,14 @@ public class MBDropCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pcSender, String[] args, protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) { AbstractGameObject target) {
String newline = "\r\n "; String newline = "\r\n ";
if (args.length != 1){ if (args.length != 1) {
this.sendUsage(pcSender); this.sendUsage(pcSender);
this.sendHelp(pcSender); this.sendHelp(pcSender);
return; return;
} }
String output = ""; String output = "";
switch (args[0].toLowerCase()){ switch (args[0].toLowerCase()) {
case "clear": case "clear":
LootTable.contractCount = 0; LootTable.contractCount = 0;
@ -55,7 +53,7 @@ public class MBDropCmd extends AbstractDevCmd {
break; break;
case "all": case "all":
output = LootTable.dropCount + " items - ITEM NAME : DROP COUNT" + newline; output = LootTable.dropCount + " items - ITEM NAME : DROP COUNT" + newline;
for (ItemBase ib: LootTable.itemsDroppedMap.keySet()){ for (ItemBase ib : LootTable.itemsDroppedMap.keySet()) {
int dropCount = LootTable.itemsDroppedMap.get(ib); int dropCount = LootTable.itemsDroppedMap.get(ib);
output += ib.getName() + " : " + dropCount + newline; output += ib.getName() + " : " + dropCount + newline;
@ -64,7 +62,7 @@ public class MBDropCmd extends AbstractDevCmd {
break; break;
case "resource": case "resource":
output = LootTable.resourceCount + " Resources - ITEM NAME : DROP COUNT" + newline; output = LootTable.resourceCount + " Resources - ITEM NAME : DROP COUNT" + newline;
for (ItemBase ib: LootTable.resourceDroppedMap.keySet()){ for (ItemBase ib : LootTable.resourceDroppedMap.keySet()) {
int dropCount = LootTable.resourceDroppedMap.get(ib); int dropCount = LootTable.resourceDroppedMap.get(ib);
output += ib.getName() + " : " + dropCount + newline; output += ib.getName() + " : " + dropCount + newline;
@ -75,7 +73,7 @@ public class MBDropCmd extends AbstractDevCmd {
case "rune": case "rune":
output = LootTable.runeCount + " Runes - ITEM NAME : DROP COUNT" + newline; output = LootTable.runeCount + " Runes - ITEM NAME : DROP COUNT" + newline;
for (ItemBase ib: LootTable.runeDroppedMap.keySet()){ for (ItemBase ib : LootTable.runeDroppedMap.keySet()) {
int dropCount = LootTable.runeDroppedMap.get(ib); int dropCount = LootTable.runeDroppedMap.get(ib);
output += ib.getName() + " : " + dropCount + newline; output += ib.getName() + " : " + dropCount + newline;
@ -85,7 +83,7 @@ public class MBDropCmd extends AbstractDevCmd {
case "contract": case "contract":
output = LootTable.contractCount + " Contracts - ITEM NAME : DROP COUNT" + newline; output = LootTable.contractCount + " Contracts - ITEM NAME : DROP COUNT" + newline;
for (ItemBase ib: LootTable.contractDroppedMap.keySet()){ for (ItemBase ib : LootTable.contractDroppedMap.keySet()) {
int dropCount = LootTable.contractDroppedMap.get(ib); int dropCount = LootTable.contractDroppedMap.get(ib);
output += ib.getName() + " : " + dropCount + newline; output += ib.getName() + " : " + dropCount + newline;
@ -97,7 +95,7 @@ public class MBDropCmd extends AbstractDevCmd {
case "glass": case "glass":
output = LootTable.glassCount + " Glass - ITEM NAME : DROP COUNT" + newline; output = LootTable.glassCount + " Glass - ITEM NAME : DROP COUNT" + newline;
for (ItemBase ib: LootTable.glassDroppedMap.keySet()){ for (ItemBase ib : LootTable.glassDroppedMap.keySet()) {
int dropCount = LootTable.glassDroppedMap.get(ib); int dropCount = LootTable.glassDroppedMap.get(ib);
output += ib.getName() + " : " + dropCount + newline; output += ib.getName() + " : " + dropCount + newline;
@ -105,7 +103,7 @@ public class MBDropCmd extends AbstractDevCmd {
break; break;
case "chance": case "chance":
float chance = (float)LootTable.dropCount/(float)LootTable.rollCount * 100; float chance = (float) LootTable.dropCount / (float) LootTable.rollCount * 100;
output = LootTable.dropCount + " out of " + LootTable.rollCount + " items Dropped. chance = " + chance + '%'; output = LootTable.dropCount + " out of " + LootTable.rollCount + " items Dropped. chance = " + chance + '%';
break; break;

7
src/engine/devcmd/cmds/MakeBaneCmd.java

@ -23,7 +23,6 @@ import org.pmw.tinylog.Logger;
/** /**
* @author Eighty * @author Eighty
*
*/ */
public class MakeBaneCmd extends AbstractDevCmd { public class MakeBaneCmd extends AbstractDevCmd {
@ -78,8 +77,6 @@ public class MakeBaneCmd extends AbstractDevCmd {
PlayerCharacter player = PlayerCharacter.getPlayerCharacter(attackerID); PlayerCharacter player = PlayerCharacter.getPlayerCharacter(attackerID);
if (player.getGuild().isEmptyGuild()) { if (player.getGuild().isEmptyGuild()) {
throwbackError(pc, "Errant's can not place banes"); throwbackError(pc, "Errant's can not place banes");
return; return;
@ -154,7 +151,7 @@ public class MakeBaneCmd extends AbstractDevCmd {
//Let's drop a banestone! //Let's drop a banestone!
Vector3fImmutable localLocation = ZoneManager.worldToLocal(pc.getLoc(), zone); Vector3fImmutable localLocation = ZoneManager.worldToLocal(pc.getLoc(), zone);
if (localLocation == null){ if (localLocation == null) {
ChatManager.chatSystemError(pc, "Failed to convert world location to zone location. Contact a CCR."); ChatManager.chatSystemError(pc, "Failed to convert world location to zone location. Contact a CCR.");
Logger.info("Failed to Convert World coordinates to local zone coordinates"); Logger.info("Failed to Convert World coordinates to local zone coordinates");
return; return;
@ -171,7 +168,7 @@ public class MakeBaneCmd extends AbstractDevCmd {
} }
stone.addEffectBit((1 << 19)); stone.addEffectBit((1 << 19));
stone.setRank((byte) rank); stone.setRank((byte) rank);
stone.setMaxHitPoints( blueprint.getMaxHealth(stone.getRank())); stone.setMaxHitPoints(blueprint.getMaxHealth(stone.getRank()));
stone.setCurrentHitPoints(stone.getMaxHitPoints()); stone.setCurrentHitPoints(stone.getMaxHitPoints());
BuildingManager.setUpgradeDateTime(stone, null, 0); BuildingManager.setUpgradeDateTime(stone, null, 0);

12
src/engine/devcmd/cmds/MakeItemCmd.java

@ -21,7 +21,6 @@ import java.util.ArrayList;
/** /**
* @author Eighty * @author Eighty
*
*/ */
public class MakeItemCmd extends AbstractDevCmd { public class MakeItemCmd extends AbstractDevCmd {
@ -33,8 +32,8 @@ public class MakeItemCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pc, String[] words, protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (words[0].equals("resources")){ if (words[0].equals("resources")) {
for (int ibID : Warehouse.getMaxResources().keySet()){ for (int ibID : Warehouse.getMaxResources().keySet()) {
if (ibID == 7) if (ibID == 7)
continue; continue;
@ -50,9 +49,9 @@ public class MakeItemCmd extends AbstractDevCmd {
boolean worked = false; boolean worked = false;
Item item = new Item(ib, pc.getObjectUUID(), Item item = new Item(ib, pc.getObjectUUID(),
OwnerType.PlayerCharacter, (byte)0, (byte)0, (short)ib.getDurability(), (short)ib.getDurability(), OwnerType.PlayerCharacter, (byte) 0, (byte) 0, (short) ib.getDurability(), (short) ib.getDurability(),
true, false, ItemContainerType.INVENTORY, (byte) 0, true, false, ItemContainerType.INVENTORY, (byte) 0,
new ArrayList<>(),""); new ArrayList<>(), "");
item.setNumOfItems(Warehouse.getMaxResources().get(ibID)); item.setNumOfItems(Warehouse.getMaxResources().get(ibID));
@ -70,7 +69,6 @@ public class MakeItemCmd extends AbstractDevCmd {
} }
//add item to inventory //add item to inventory
pc.getCharItemManager().addItemToInventory(item); pc.getCharItemManager().addItemToInventory(item);
} }
@ -210,7 +208,7 @@ public class MakeItemCmd extends AbstractDevCmd {
Item item = new Item(ib, pc.getObjectUUID(), Item item = new Item(ib, pc.getObjectUUID(),
OwnerType.PlayerCharacter, charges, charges, dur, dur, OwnerType.PlayerCharacter, charges, charges, dur, dur,
true, false, ItemContainerType.INVENTORY, (byte) 0, true, false, ItemContainerType.INVENTORY, (byte) 0,
new ArrayList<>(),""); new ArrayList<>(), "");
if (numItems > 1) if (numItems > 1)
item.setNumOfItems(numItems); item.setNumOfItems(numItems);

44
src/engine/devcmd/cmds/NetDebugCmd.java

@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
/** /**
* @author * @author Summary: Devcmd to toggle logging of application protocol messages
* Summary: Devcmd to toggle logging of application protocol messages
*
*/ */
public class NetDebugCmd extends AbstractDevCmd { public class NetDebugCmd extends AbstractDevCmd {
@ -23,13 +21,30 @@ public class NetDebugCmd extends AbstractDevCmd {
// AbstractDevCmd Overridden methods // AbstractDevCmd Overridden methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "onoff";
// incorrect number of arguments test
if (userInput.length != 1)
return false;
// Validate arguments
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
return stringIndex != -1;
}
@Override @Override
protected void _doCmd(PlayerCharacter pc, String[] args, protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) { AbstractGameObject target) {
Boolean debugState = false; Boolean debugState = false;
if(validateUserInput(args) == false) { if (validateUserInput(args) == false) {
this.sendUsage(pc); this.sendUsage(pc);
return; return;
} }
@ -58,29 +73,12 @@ public class NetDebugCmd extends AbstractDevCmd {
return "Toggles sending network messages to log"; return "Toggles sending network messages to log";
} }
// Class methods
@Override @Override
protected String _getUsageString() { protected String _getUsageString() {
return "/netdebug on|off"; return "/netdebug on|off";
} }
// Class methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "onoff";
// incorrect number of arguments test
if (userInput.length != 1)
return false;
// Validate arguments
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
return stringIndex != -1;
}
} }

2
src/engine/devcmd/cmds/PrintBankCmd.java

@ -47,7 +47,7 @@ public class PrintBankCmd extends AbstractDevCmd {
} }
CharacterItemManager cim = ((AbstractCharacter)tar).getCharItemManager(); CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager();
ArrayList<Item> list = cim.getBank(); ArrayList<Item> list = cim.getBank();
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Item item : list) { for (Item item : list) {

7
src/engine/devcmd/cmds/PrintBonusesCmd.java

@ -71,10 +71,9 @@ public class PrintBonusesCmd extends AbstractDevCmd {
for (AbstractEffectModifier targetName : targetItem.getBonuses().keySet()) { for (AbstractEffectModifier targetName : targetItem.getBonuses().keySet()) {
ChatManager.chatSystemInfo(pc, " " + targetName.modType.name() + "-" + targetName.sourceType.name() + ": " + targetItem.getBonuses().get(name)); ChatManager.chatSystemInfo(pc, " " + targetName.modType.name() + "-" + targetName.sourceType.name() + ": " + targetItem.getBonuses().get(name));
} }
} else if (((AbstractCharacter)tar).getBonuses() != null) { } else if (((AbstractCharacter) tar).getBonuses() != null) {
((AbstractCharacter)tar).getBonuses().printBonusesToClient(pc); ((AbstractCharacter) tar).getBonuses().printBonusesToClient(pc);
} } else
else
throwbackInfo(pc, "Bonuses for " + type + ' ' + name + " not found"); throwbackInfo(pc, "Bonuses for " + type + ' ' + name + " not found");
} }

16
src/engine/devcmd/cmds/PrintEquipCmd.java

@ -60,27 +60,27 @@ public class PrintEquipCmd extends AbstractDevCmd {
type = "NPC"; type = "NPC";
} }
if (tar.getObjectType() == GameObjectType.Mob){ if (tar.getObjectType() == GameObjectType.Mob) {
Mob tarMob = (Mob)tar; Mob tarMob = (Mob) tar;
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (int slot:tarMob.getEquip().keySet()){ for (int slot : tarMob.getEquip().keySet()) {
MobEquipment equip = tarMob.getEquip().get(slot); MobEquipment equip = tarMob.getEquip().get(slot);
throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + equip.getItemBase().getName() + ", slot: " + slot); throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + equip.getItemBase().getName() + ", slot: " + slot);
} }
return; return;
} }
if (tar.getObjectType() == GameObjectType.NPC){ if (tar.getObjectType() == GameObjectType.NPC) {
NPC tarMob = (NPC)tar; NPC tarMob = (NPC) tar;
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (int slot:tarMob.getEquip().keySet()){ for (int slot : tarMob.getEquip().keySet()) {
MobEquipment equip = tarMob.getEquip().get(slot); MobEquipment equip = tarMob.getEquip().get(slot);
throwbackInfo(pc,equip.getItemBase().getUUID() + " : " + equip.getItemBase().getName() + ", slot: " + slot); throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + equip.getItemBase().getName() + ", slot: " + slot);
} }
return; return;
} }
CharacterItemManager cim = ((AbstractCharacter)tar).getCharItemManager(); CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager();
ConcurrentHashMap<Integer, Item> list = cim.getEquipped(); ConcurrentHashMap<Integer, Item> list = cim.getEquipped();
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Integer slot : list.keySet()) { for (Integer slot : list.keySet()) {

5
src/engine/devcmd/cmds/PrintInventoryCmd.java

@ -38,7 +38,7 @@ public class PrintInventoryCmd extends AbstractDevCmd {
DecimalFormat df = new DecimalFormat("###,###,###,##0"); DecimalFormat df = new DecimalFormat("###,###,###,##0");
if (target instanceof AbstractCharacter) { if (target instanceof AbstractCharacter) {
AbstractCharacter tar = (AbstractCharacter)target; AbstractCharacter tar = (AbstractCharacter) target;
name = tar.getFirstName(); name = tar.getFirstName();
@ -83,7 +83,8 @@ public class PrintInventoryCmd extends AbstractDevCmd {
chargeInfo = " charges: " + charges + '/' + chargeMax; chargeInfo = " charges: " + charges + '/' + chargeMax;
} }
throwbackInfo(pc, " " + item.getItemBase().getName() + ", count: " + item.getNumOfItems() + chargeInfo); throwbackInfo(pc, " " + item.getItemBase().getName() + ", count: " + item.getNumOfItems() + chargeInfo);
} else goldCount += item.getNumOfItems(); } else
goldCount += item.getNumOfItems();
} }
if (gold != null) { if (gold != null) {
goldCount += gold.getNumOfItems(); goldCount += gold.getNumOfItems();

1
src/engine/devcmd/cmds/PrintLocationCmd.java

@ -16,7 +16,6 @@ import engine.objects.Regions;
/** /**
* @author Eighty * @author Eighty
*
*/ */
public class PrintLocationCmd extends AbstractDevCmd { public class PrintLocationCmd extends AbstractDevCmd {

22
src/engine/devcmd/cmds/PrintStatsCmd.java

@ -25,6 +25,16 @@ public class PrintStatsCmd extends AbstractDevCmd {
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN); // super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
} }
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
if (equip.containsKey(slot)) {
MobEquipment item = equip.get(slot);
if (item != null && item.getItemBase() != null) {
return item.getItemBase();
}
}
return null;
}
@Override @Override
protected void _doCmd(PlayerCharacter pc, String[] words, protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
@ -71,7 +81,6 @@ public class PrintStatsCmd extends AbstractDevCmd {
return; return;
String newline = "\r\n "; String newline = "\r\n ";
String out = "Server stats for Mob " + mb.getFirstName() + newline; String out = "Server stats for Mob " + mb.getFirstName() + newline;
out += "Stats Base (Modified)" + newline; out += "Stats Base (Modified)" + newline;
@ -130,17 +139,6 @@ public class PrintStatsCmd extends AbstractDevCmd {
throwbackInfo(pc, out); throwbackInfo(pc, out);
} }
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
if (equip.containsKey(slot)) {
MobEquipment item = equip.get(slot);
if (item != null && item.getItemBase() != null) {
return item.getItemBase();
}
}
return null;
}
@Override @Override
protected String _getHelpString() { protected String _getHelpString() {
return "Returns the player's current stats"; return "Returns the player's current stats";

2
src/engine/devcmd/cmds/PrintVaultCmd.java

@ -46,7 +46,7 @@ public class PrintVaultCmd extends AbstractDevCmd {
} }
CharacterItemManager cim = ((AbstractCharacter)tar).getCharItemManager(); CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager();
ArrayList<Item> list = cim.getVault(); ArrayList<Item> list = cim.getVault();
throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Item item : list) { for (Item item : list) {

76
src/engine/devcmd/cmds/PullCmd.java

@ -8,9 +8,7 @@ import engine.math.Vector3fImmutable;
import engine.objects.*; import engine.objects.*;
/** /**
* * @author Dev command to move mobile and it's spawn location
* @author
* Dev command to move mobile and it's spawn location
* to the player's current location * to the player's current location
*/ */
public class PullCmd extends AbstractDevCmd { public class PullCmd extends AbstractDevCmd {
@ -19,6 +17,42 @@ public class PullCmd extends AbstractDevCmd {
super("pull"); super("pull");
} }
private static void MoveMobile(Mob targetMobile, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.MobQueries.MOVE_MOB(targetMobile.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetMobile.setBindLoc(newLoc);
targetMobile.setLoc(newLoc);
targetMobile.refresh();
}
private static void MoveBuilding(Building targetBuilding, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.BuildingQueries.MOVE_BUILDING(targetBuilding.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetBuilding.setLoc(newLoc);
targetBuilding.getBounds().setBounds(targetBuilding);
targetBuilding.refresh(true);
}
private static void MoveNPC(NPC targetNPC, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.NPCQueries.MOVE_NPC(targetNPC.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetNPC.setBindLoc(newLoc);
targetNPC.setLoc(newLoc);
WorldGrid.updateObject(targetNPC, pcSender);
}
@Override @Override
protected void _doCmd(PlayerCharacter pcSender, String[] args, protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) { AbstractGameObject target) {
@ -65,40 +99,4 @@ public class PullCmd extends AbstractDevCmd {
} }
return true; return true;
} }
private static void MoveMobile(Mob targetMobile, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.MobQueries.MOVE_MOB(targetMobile.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetMobile.setBindLoc(newLoc);
targetMobile.setLoc(newLoc);
targetMobile.refresh();
}
private static void MoveBuilding(Building targetBuilding, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.BuildingQueries.MOVE_BUILDING(targetBuilding.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetBuilding.setLoc(newLoc);
targetBuilding.getBounds().setBounds(targetBuilding);
targetBuilding.refresh(true);
}
private static void MoveNPC(NPC targetNPC, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.NPCQueries.MOVE_NPC(targetNPC.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetNPC.setBindLoc(newLoc);
targetNPC.setLoc(newLoc);
WorldGrid.updateObject(targetNPC, pcSender);
}
} }

247
src/engine/devcmd/cmds/PurgeObjectsCmd.java

@ -18,9 +18,8 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
/** /**
* @author * @author Summary: Game designer utility command to purge all
* Summary: Game designer utility command to purge all * objects of a given type within a supplied range
objects of a given type within a supplied range
*/ */
public class PurgeObjectsCmd extends AbstractDevCmd { public class PurgeObjectsCmd extends AbstractDevCmd {
@ -41,27 +40,26 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
super("purge"); super("purge");
} }
private static void PurgeWalls(Zone zone, PlayerCharacter pc){ private static void PurgeWalls(Zone zone, PlayerCharacter pc) {
if (!zone.isPlayerCity()) if (!zone.isPlayerCity())
return; return;
for (Building building: zone.zoneBuildingSet){ for (Building building : zone.zoneBuildingSet) {
if (!BuildingManager.IsWallPiece(building)) if (!BuildingManager.IsWallPiece(building))
continue; continue;
for (AbstractCharacter ac: building.getHirelings().keySet()){ for (AbstractCharacter ac : building.getHirelings().keySet()) {
NPC npc = null; NPC npc = null;
Mob mobA = null; Mob mobA = null;
if (ac.getObjectType() == GameObjectType.NPC) if (ac.getObjectType() == GameObjectType.NPC)
npc = (NPC)ac; npc = (NPC) ac;
else if (ac.getObjectType() == GameObjectType.Mob) else if (ac.getObjectType() == GameObjectType.Mob)
mobA = (Mob)ac; mobA = (Mob) ac;
if (npc != null) {
if (npc != null){ for (Mob mob : npc.getSiegeMinionMap().keySet()) {
for (Mob mob: npc.getSiegeMinionMap().keySet()){
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob); //Mob.getRespawnMap().remove(mob);
@ -72,8 +70,8 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
DbManager.removeFromCache(GameObjectType.NPC, DbManager.removeFromCache(GameObjectType.NPC,
npc.getObjectUUID()); npc.getObjectUUID());
WorldGrid.RemoveWorldObject(npc); WorldGrid.RemoveWorldObject(npc);
}else if (mobA != null){ } else if (mobA != null) {
for (Mob mob: mobA.getSiegeMinionMap().keySet()){ for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob); //Mob.getRespawnMap().remove(mob);
@ -100,6 +98,113 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
// AbstractDevCmd Overridden methods // AbstractDevCmd Overridden methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "npcmobmeshall";
// incorrect number of arguments test
if (userInput.length != 2)
return false;
// Test of game object type argument
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
if (stringIndex == -1)
return false;
// Test if range argument can convert to a float
try {
Float.parseFloat(userInput[1]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
// User input passes validation
return true;
}
private static void removeBuilding(PlayerCharacter pc, Building building) {
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL))
return;
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
Shrine.RemoveShrineFromCacheByBuilding(building);
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE))
building.disableSpire(false);
for (AbstractCharacter ac : building.getHirelings().keySet()) {
NPC npc = null;
Mob mobA = null;
if (ac.getObjectType() == GameObjectType.NPC)
npc = (NPC) ac;
else if (ac.getObjectType() == GameObjectType.Mob)
mobA = (Mob) ac;
if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(Enum.GameObjectType.NPC,
npc.getObjectUUID());
WorldGrid.RemoveWorldObject(npc);
} else if (mobA != null) {
for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.MobQueries.DELETE_MOB(mobA);
DbManager.removeFromCache(Enum.GameObjectType.Mob,
mobA.getObjectUUID());
WorldGrid.RemoveWorldObject(mobA);
}
}
DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
DbManager.removeFromCache(building);
WorldGrid.RemoveWorldObject(building);
WorldGrid.removeObject(building, pc);
}
private static void removeNPC(PlayerCharacter pc, NPC npc) {
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(npc);
WorldGrid.RemoveWorldObject(npc);
WorldGrid.removeObject(npc, pc);
}
// Class methods
private static void removeMob(PlayerCharacter pc, Mob mob) {
mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane..
mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc..
//mob.setHealth(-1, pc); //Kill it!
DbManager.MobQueries.DELETE_MOB(mob);
DbManager.removeFromCache(mob);
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
}
@Override @Override
protected void _doCmd(PlayerCharacter pc, String[] args, protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) { AbstractGameObject target) {
@ -110,14 +215,14 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
try { try {
if (args[0].toLowerCase().equals("walls")){ if (args[0].toLowerCase().equals("walls")) {
Zone zone = ZoneManager.findSmallestZone(pc.getLoc()); Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
PurgeWalls(zone, pc); PurgeWalls(zone, pc);
return; return;
} }
if(validateUserInput(args) == false) { if (validateUserInput(args) == false) {
this.sendUsage(pc); this.sendUsage(pc);
return; return;
} }
@ -136,7 +241,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
for (AbstractWorldObject awo : objectList) { for (AbstractWorldObject awo : objectList) {
switch(awo.getObjectType()) { switch (awo.getObjectType()) {
case Building: case Building:
removeBuilding(pc, (Building) awo); removeBuilding(pc, (Building) awo);
break; break;
@ -153,7 +258,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
// Send results to user // Send results to user
throwbackInfo(pc, "Purge: " + objectList.size() + " objects were removed in range " + _targetRange); throwbackInfo(pc, "Purge: " + objectList.size() + " objects were removed in range " + _targetRange);
}catch(Exception e){ } catch (Exception e) {
Logger.error(e); Logger.error(e);
} }
@ -174,38 +279,6 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
return "/purge [npc|mob|mesh|all] [range <= 200]"; return "/purge [npc|mob|mesh|all] [range <= 200]";
} }
// Class methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "npcmobmeshall";
// incorrect number of arguments test
if (userInput.length != 2)
return false;
// Test of game object type argument
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
if (stringIndex == -1)
return false;
// Test if range argument can convert to a float
try {
Float.parseFloat(userInput[1]); }
catch (NumberFormatException | NullPointerException e) {
return false;
}
// User input passes validation
return true;
}
private void parseUserInput(String[] userInput) { private void parseUserInput(String[] userInput) {
_targetMask = 0; _targetMask = 0;
@ -236,80 +309,4 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
_targetRange = Math.min(_targetRange, 200f); _targetRange = Math.min(_targetRange, 200f);
} }
private static void removeBuilding(PlayerCharacter pc, Building building) {
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL))
return;
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
Shrine.RemoveShrineFromCacheByBuilding(building);
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE))
building.disableSpire(false);
for (AbstractCharacter ac: building.getHirelings().keySet()){
NPC npc = null;
Mob mobA = null;
if (ac.getObjectType() == GameObjectType.NPC)
npc = (NPC)ac;
else if (ac.getObjectType() == GameObjectType.Mob)
mobA = (Mob)ac;
if (npc != null){
for (Mob mob: npc.getSiegeMinionMap().keySet()){
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(Enum.GameObjectType.NPC,
npc.getObjectUUID());
WorldGrid.RemoveWorldObject(npc);
}else if (mobA != null){
for (Mob mob: mobA.getSiegeMinionMap().keySet()){
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.MobQueries.DELETE_MOB(mobA);
DbManager.removeFromCache(Enum.GameObjectType.Mob,
mobA.getObjectUUID());
WorldGrid.RemoveWorldObject(mobA);
}
}
DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
DbManager.removeFromCache(building);
WorldGrid.RemoveWorldObject(building);
WorldGrid.removeObject(building, pc);
}
private static void removeNPC(PlayerCharacter pc, NPC npc) {
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(npc);
WorldGrid.RemoveWorldObject(npc);
WorldGrid.removeObject(npc, pc);
}
private static void removeMob(PlayerCharacter pc, Mob mob) {
mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane..
mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc..
//mob.setHealth(-1, pc); //Kill it!
DbManager.MobQueries.DELETE_MOB(mob);
DbManager.removeFromCache(mob);
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
}
} }

1
src/engine/devcmd/cmds/RealmInfoCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;

6
src/engine/devcmd/cmds/RebootCmd.java

@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
/** /**
* @author * @author Summary: Devcmd to reboot server
* Summary: Devcmd to reboot server
*
*/ */
public class RebootCmd extends AbstractDevCmd { public class RebootCmd extends AbstractDevCmd {
@ -30,7 +28,7 @@ public class RebootCmd extends AbstractDevCmd {
Runtime rt = Runtime.getRuntime(); Runtime rt = Runtime.getRuntime();
rt.exec("./mbrestart.sh"); rt.exec("./mbrestart.sh");
} catch (java.io.IOException err) { } catch (java.io.IOException err) {
Logger.info( err.getMessage()); Logger.info(err.getMessage());
} }
} }

19
src/engine/devcmd/cmds/RegionCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
@ -37,28 +36,28 @@ public class RegionCmd extends AbstractDevCmd {
String result = ""; String result = "";
result += (pc.region.getClass().getSimpleName()); result += (pc.region.getClass().getSimpleName());
result += (" {"); result += (" {");
result+=(newLine); result += (newLine);
Field[] fields = pc.region.getClass().getDeclaredFields(); Field[] fields = pc.region.getClass().getDeclaredFields();
//print field names paired with their values //print field names paired with their values
for ( Field field : fields ) { for (Field field : fields) {
field.setAccessible(true); field.setAccessible(true);
result+=(" "); result += (" ");
try { try {
if(field.getName().contains("Furniture")) if (field.getName().contains("Furniture"))
continue; continue;
result+=( field.getName()); result += (field.getName());
result+=(": "); result += (": ");
//requires access to private field: //requires access to private field:
result += (field.get(pc.region).toString()); result += (field.get(pc.region).toString());
} catch ( IllegalAccessException ex ) { } catch (IllegalAccessException ex) {
System.out.println(ex); System.out.println(ex);
} }
result.trim(); result.trim();
result+=(newLine); result += (newLine);
} }
result+=("}"); result += ("}");
this.throwbackInfo(pc, result.toString()); this.throwbackInfo(pc, result.toString());

1
src/engine/devcmd/cmds/RemoveBaneCmd.java

@ -16,7 +16,6 @@ import engine.objects.*;
/** /**
* @author Eighty * @author Eighty
*
*/ */
public class RemoveBaneCmd extends AbstractDevCmd { public class RemoveBaneCmd extends AbstractDevCmd {

16
src/engine/devcmd/cmds/RemoveObjectCmd.java

@ -130,9 +130,9 @@ public class RemoveObjectCmd extends AbstractDevCmd {
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)) if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE))
building.disableSpire(false); building.disableSpire(false);
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.WAREHOUSE)){ if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.WAREHOUSE)) {
City city =City.getCity(building.getParentZone().getPlayerCityUUID()); City city = City.getCity(building.getParentZone().getPlayerCityUUID());
if (city != null){ if (city != null) {
city.setWarehouseBuildingID(0); city.setWarehouseBuildingID(0);
} }
Warehouse.warehouseByBuildingUUID.remove(building.getObjectUUID()); Warehouse.warehouseByBuildingUUID.remove(building.getObjectUUID());
@ -149,11 +149,11 @@ public class RemoveObjectCmd extends AbstractDevCmd {
Mob mobA = null; Mob mobA = null;
if (ac.getObjectType() == GameObjectType.NPC) if (ac.getObjectType() == GameObjectType.NPC)
npc = (NPC)ac; npc = (NPC) ac;
else if (ac.getObjectType() == GameObjectType.Mob) else if (ac.getObjectType() == GameObjectType.Mob)
mobA = (Mob)ac; mobA = (Mob) ac;
if (npc != null){ if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) { for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
@ -165,7 +165,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
DbManager.removeFromCache(npc); DbManager.removeFromCache(npc);
WorldGrid.RemoveWorldObject(npc); WorldGrid.RemoveWorldObject(npc);
WorldGrid.removeObject(npc, pc); WorldGrid.removeObject(npc, pc);
}else if (mobA != null){ } else if (mobA != null) {
for (Mob mob : mobA.getSiegeMinionMap().keySet()) { for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
@ -185,7 +185,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
DbManager.BuildingQueries.DELETE_FROM_DATABASE(building); DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
DbManager.removeFromCache(building); DbManager.removeFromCache(building);
zone.zoneBuildingSet.remove(building); zone.zoneBuildingSet.remove(building);
if(building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.BARRACK)){ if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.BARRACK)) {
building.RemoveFromBarracksList(); building.RemoveFromBarracksList();
} }
WorldGrid.RemoveWorldObject(building); WorldGrid.RemoveWorldObject(building);

6
src/engine/devcmd/cmds/RenameCmd.java

@ -18,9 +18,7 @@ import engine.objects.NPC;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
/** /**
*
* @author Eighty * @author Eighty
*
*/ */
public class RenameCmd extends AbstractDevCmd { public class RenameCmd extends AbstractDevCmd {
@ -46,7 +44,7 @@ public class RenameCmd extends AbstractDevCmd {
if (target instanceof NPC) if (target instanceof NPC)
npc = (NPC) target; npc = (NPC) target;
else if (target instanceof Building) else if (target instanceof Building)
building = (Building)target; building = (Building) target;
} else } else
npc = getTargetAsNPC(pcSender); npc = getTargetAsNPC(pcSender);
if (npc != null) { if (npc != null) {
@ -60,7 +58,7 @@ public class RenameCmd extends AbstractDevCmd {
// npc.updateDatabase(); // npc.updateDatabase();
WorldGrid.updateObject(npc, pcSender); WorldGrid.updateObject(npc, pcSender);
} else if (building != null){ } else if (building != null) {
String name = args[0]; String name = args[0];
name = name.replaceAll("_", " "); name = name.replaceAll("_", " ");
building.setName(name); building.setName(name);

1
src/engine/devcmd/cmds/ResetLevelCmd.java

@ -32,5 +32,4 @@ public class ResetLevelCmd extends AbstractDevCmd {
} }
} }

44
src/engine/devcmd/cmds/RotateCmd.java

@ -28,16 +28,16 @@ public class RotateCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pc, String[] words, protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (target == null && (words.length != 2) ) { if (target == null && (words.length != 2)) {
this.sendUsage(pc); this.sendUsage(pc);
return; return;
} }
if (words.length == 3){ if (words.length == 3) {
try{ try {
}catch(Exception e){ } catch (Exception e) {
} }
} }
@ -47,7 +47,7 @@ public class RotateCmd extends AbstractDevCmd {
if (target != null && words.length == 1) { if (target != null && words.length == 1) {
try { try {
if (words[0].equalsIgnoreCase("face")){ if (words[0].equalsIgnoreCase("face")) {
this.rotateFace(pc, target); this.rotateFace(pc, target);
return; return;
} }
@ -66,11 +66,11 @@ public class RotateCmd extends AbstractDevCmd {
Vector3f rotation = new Vector3f(0f, rot, 0f); Vector3f rotation = new Vector3f(0f, rot, 0f);
if (target instanceof Building) if (target instanceof Building)
rotateBuilding(pc, (Building) target, rotation, rot,false); rotateBuilding(pc, (Building) target, rotation, rot, false);
else if (target instanceof NPC) else if (target instanceof NPC)
rotateNPC(pc, (NPC) target, rotation,false); rotateNPC(pc, (NPC) target, rotation, false);
else if (target instanceof Mob) else if (target instanceof Mob)
rotateMob(pc, (Mob) target, rotation,false); rotateMob(pc, (Mob) target, rotation, false);
else else
throwbackError(pc, "Target " + target.getObjectType() throwbackError(pc, "Target " + target.getObjectType()
+ " is not a valid object type"); + " is not a valid object type");
@ -81,7 +81,7 @@ public class RotateCmd extends AbstractDevCmd {
try { try {
id = Integer.parseInt(words[0]); id = Integer.parseInt(words[0]);
if (words[1].equalsIgnoreCase("face")){ if (words[1].equalsIgnoreCase("face")) {
Building b; Building b;
if (id != 0) if (id != 0)
@ -149,7 +149,7 @@ public class RotateCmd extends AbstractDevCmd {
else else
b = getTargetAsBuilding(pc); b = getTargetAsBuilding(pc);
if (b != null) { if (b != null) {
rotateBuilding(pc, b, rotation, rot,false); rotateBuilding(pc, b, rotation, rot, false);
return; return;
} }
@ -160,7 +160,7 @@ public class RotateCmd extends AbstractDevCmd {
else else
npc = getTargetAsNPC(pc); npc = getTargetAsNPC(pc);
if (npc != null) { if (npc != null) {
rotateNPC(pc, npc, rotation,false); rotateNPC(pc, npc, rotation, false);
return; return;
} }
@ -171,7 +171,7 @@ public class RotateCmd extends AbstractDevCmd {
else else
mob = getTargetAsMob(pc); mob = getTargetAsMob(pc);
if (mob != null) { if (mob != null) {
rotateMob(pc, mob, rotation,false); rotateMob(pc, mob, rotation, false);
return; return;
} }
throwbackError(pc, "Nothing found to rotate."); throwbackError(pc, "Nothing found to rotate.");
@ -190,9 +190,9 @@ public class RotateCmd extends AbstractDevCmd {
private void rotateBuilding(PlayerCharacter pc, Building building, Vector3f rot, float orig, boolean faceDirection) { private void rotateBuilding(PlayerCharacter pc, Building building, Vector3f rot, float orig, boolean faceDirection) {
if (!faceDirection) if (!faceDirection)
rot.set(0.0f, (float)Math.sin(Math.toRadians(orig)/2), 0.0f); rot.set(0.0f, (float) Math.sin(Math.toRadians(orig) / 2), 0.0f);
building.setRot(rot); building.setRot(rot);
building.setw( (float) Math.abs(Math.cos(Math.toRadians(orig)/2)) ); building.setw((float) Math.abs(Math.cos(Math.toRadians(orig) / 2)));
building.getBounds().setBounds(building); building.getBounds().setBounds(building);
WorldGrid.updateObject(building, pc); WorldGrid.updateObject(building, pc);
DbManager.BuildingQueries.SET_PROPERTY(building, "rotY", building.getRot().getY()); DbManager.BuildingQueries.SET_PROPERTY(building, "rotY", building.getRot().getY());
@ -201,7 +201,7 @@ public class RotateCmd extends AbstractDevCmd {
"Building with ID " + building.getObjectUUID() + " rotated"); "Building with ID " + building.getObjectUUID() + " rotated");
} }
private void rotateNPC(PlayerCharacter pc, NPC npc, Vector3f rot,boolean faceDirection) { private void rotateNPC(PlayerCharacter pc, NPC npc, Vector3f rot, boolean faceDirection) {
npc.setRot(rot); npc.setRot(rot);
DbManager.NPCQueries.SET_PROPERTY(npc, "npc_rotation", rot.y); DbManager.NPCQueries.SET_PROPERTY(npc, "npc_rotation", rot.y);
WorldGrid.updateObject(npc, pc); WorldGrid.updateObject(npc, pc);
@ -210,7 +210,7 @@ public class RotateCmd extends AbstractDevCmd {
"NPC with ID " + npc.getObjectUUID() + " rotated"); "NPC with ID " + npc.getObjectUUID() + " rotated");
} }
private void rotateMob(PlayerCharacter pc, Mob mob, Vector3f rot,boolean faceDirection) { private void rotateMob(PlayerCharacter pc, Mob mob, Vector3f rot, boolean faceDirection) {
mob.setRot(rot); mob.setRot(rot);
DbManager.MobQueries.SET_PROPERTY(mob, "mob_rotation", rot.y); DbManager.MobQueries.SET_PROPERTY(mob, "mob_rotation", rot.y);
WorldGrid.updateObject(mob, pc); WorldGrid.updateObject(mob, pc);
@ -219,8 +219,8 @@ public class RotateCmd extends AbstractDevCmd {
"Mob with ID " + mob.getObjectUUID() + " rotated"); "Mob with ID " + mob.getObjectUUID() + " rotated");
} }
private void rotateFace(PlayerCharacter pc, AbstractGameObject target){ private void rotateFace(PlayerCharacter pc, AbstractGameObject target) {
AbstractWorldObject awo = (AbstractWorldObject)target; AbstractWorldObject awo = (AbstractWorldObject) target;
if (awo == null) if (awo == null)
return; return;
Vector3fImmutable buildingLoc = awo.getLoc(); Vector3fImmutable buildingLoc = awo.getLoc();
@ -233,16 +233,16 @@ public class RotateCmd extends AbstractDevCmd {
float rot = (float) Math.toDegrees(rotangle); float rot = (float) Math.toDegrees(rotangle);
if (rot > 180) if (rot > 180)
rot*=-1; rot *= -1;
Vector3f buildingrotation = new Vector3f(0f, rot, 0f); Vector3f buildingrotation = new Vector3f(0f, rot, 0f);
Vector3f rotation = new Vector3f(0f, rotangle, 0f); Vector3f rotation = new Vector3f(0f, rotangle, 0f);
if (target instanceof Building) if (target instanceof Building)
rotateBuilding(pc, (Building) target, buildingrotation, rot,false); rotateBuilding(pc, (Building) target, buildingrotation, rot, false);
else if (target instanceof NPC) else if (target instanceof NPC)
rotateNPC(pc, (NPC) target, rotation,true); rotateNPC(pc, (NPC) target, rotation, true);
else if (target instanceof Mob) else if (target instanceof Mob)
rotateMob(pc, (Mob) target, rotation,true); rotateMob(pc, (Mob) target, rotation, true);
else else
throwbackError(pc, "Target " + target.getObjectType() throwbackError(pc, "Target " + target.getObjectType()
+ " is not a valid object type"); + " is not a valid object type");

16
src/engine/devcmd/cmds/SetAICmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.ai.MobileFSMManager; import engine.ai.MobileFSMManager;
@ -19,7 +18,6 @@ import engine.server.MBServerStatics;
/** /**
* @author Steve * @author Steve
*
*/ */
public class SetAICmd extends AbstractDevCmd { public class SetAICmd extends AbstractDevCmd {
@ -31,22 +29,22 @@ public class SetAICmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pc, String[] words, protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (words.length < 2){ if (words.length < 2) {
this.sendUsage(pc); this.sendUsage(pc);
return; return;
} }
int amount; int amount;
try{ try {
amount = Integer.valueOf(words[1]); amount = Integer.valueOf(words[1]);
}catch (NumberFormatException e) { } catch (NumberFormatException e) {
this.throwbackError(pc, "Failed to parse amount"); this.throwbackError(pc, "Failed to parse amount");
return; return;
} }
switch(words[0]){ switch (words[0]) {
case "angle" : case "angle":
float angle = Float.parseFloat(words[1]); float angle = Float.parseFloat(words[1]);
MobileFSMManager.AI_MAX_ANGLE = angle; MobileFSMManager.AI_MAX_ANGLE = angle;
@ -67,7 +65,7 @@ public class SetAICmd extends AbstractDevCmd {
this.throwbackInfo(pc, "Patrol Chance is now set to " + amount); this.throwbackInfo(pc, "Patrol Chance is now set to " + amount);
break; break;
case "pulse": case "pulse":
if (amount < 500){ if (amount < 500) {
this.throwbackError(pc, "pulse amount must be greather than 500 to execute."); this.throwbackError(pc, "pulse amount must be greather than 500 to execute.");
return; return;
} }
@ -75,7 +73,7 @@ public class SetAICmd extends AbstractDevCmd {
this.throwbackInfo(pc, "Pulse is now set to " + amount); this.throwbackInfo(pc, "Pulse is now set to " + amount);
break; break;
case "sleepthread": case "sleepthread":
if (amount < 500){ if (amount < 500) {
this.throwbackError(pc, "sleep amount must be greather than 500 to execute."); this.throwbackError(pc, "sleep amount must be greather than 500 to execute.");
return; return;
} }

4
src/engine/devcmd/cmds/SetAdminRuneCmd.java

@ -17,9 +17,7 @@ import engine.objects.CharacterRune;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
/** /**
*
* @author Eighty * @author Eighty
*
*/ */
public class SetAdminRuneCmd extends AbstractDevCmd { public class SetAdminRuneCmd extends AbstractDevCmd {
@ -46,7 +44,7 @@ public class SetAdminRuneCmd extends AbstractDevCmd {
return; return;
} }
if(!(target instanceof PlayerCharacter)) { if (!(target instanceof PlayerCharacter)) {
target = pcSender; target = pcSender;
} }

1
src/engine/devcmd/cmds/SetBaneActiveCmd.java

@ -15,7 +15,6 @@ import engine.objects.*;
/** /**
* @author Eighty * @author Eighty
*
*/ */
public class SetBaneActiveCmd extends AbstractDevCmd { public class SetBaneActiveCmd extends AbstractDevCmd {

7
src/engine/devcmd/cmds/SetBuildingAltitudeCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
@ -60,19 +59,19 @@ public class SetBuildingAltitudeCmd extends AbstractDevCmd {
return; return;
} }
if (target.getObjectType() != GameObjectType.Building){ if (target.getObjectType() != GameObjectType.Building) {
this.sendUsage(pc); this.sendUsage(pc);
return; return;
} }
Building targetBuilding = (Building)target; Building targetBuilding = (Building) target;
float altitude = 0; float altitude = 0;
try { try {
altitude = Float.parseFloat(words[0]); altitude = Float.parseFloat(words[0]);
if (!UpdateBuildingAltitude(targetBuilding, targetBuilding.getStatAlt() + altitude)){ if (!UpdateBuildingAltitude(targetBuilding, targetBuilding.getStatAlt() + altitude)) {
this.throwbackError(pc, "Failed to update building altitude"); this.throwbackError(pc, "Failed to update building altitude");
return; return;
} }

1
src/engine/devcmd/cmds/SetForceRenameCityCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;

12
src/engine/devcmd/cmds/SetGuildCmd.java

@ -10,9 +10,7 @@ import engine.objects.NPC;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
/** /**
* * @author Dev command to set the guild of targeted npc.
* @author
* Dev command to set the guild of targeted npc.
* Argument is a valid guild UID * Argument is a valid guild UID
*/ */
public class SetGuildCmd extends AbstractDevCmd { public class SetGuildCmd extends AbstractDevCmd {
@ -29,7 +27,7 @@ public class SetGuildCmd extends AbstractDevCmd {
NPC targetNPC; NPC targetNPC;
Guild targetGuild; Guild targetGuild;
if(validateUserInput(pcSender, target, args) == false) { if (validateUserInput(pcSender, target, args) == false) {
this.sendUsage(pcSender); this.sendUsage(pcSender);
return; return;
} }
@ -84,8 +82,8 @@ public class SetGuildCmd extends AbstractDevCmd {
// Argument must parse as a int. // Argument must parse as a int.
try { try {
Integer.parseInt(userInput[0]); } Integer.parseInt(userInput[0]);
catch (NumberFormatException | NullPointerException e) { } catch (NumberFormatException | NullPointerException e) {
return false; return false;
} }
@ -100,6 +98,6 @@ public class SetGuildCmd extends AbstractDevCmd {
return true; return true;
} }
} }

1
src/engine/devcmd/cmds/SetHealthCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum.DispatchChannel; import engine.Enum.DispatchChannel;

5
src/engine/devcmd/cmds/SetInvulCmd.java

@ -27,7 +27,8 @@ public class SetInvulCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pcSender, String[] words, protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (pcSender == null) return; if (pcSender == null)
return;
if (words.length != 1) { if (words.length != 1) {
this.sendUsage(pcSender); this.sendUsage(pcSender);
@ -57,7 +58,7 @@ public class SetInvulCmd extends AbstractDevCmd {
// if strucutre is a TOL then we're modifying the protection // if strucutre is a TOL then we're modifying the protection
// status of the entire city // status of the entire city
if ( (b.getBlueprint() != null) && if ((b.getBlueprint() != null) &&
(b.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL))) { (b.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL))) {
City city; City city;

3
src/engine/devcmd/cmds/SetMaintCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum; import engine.Enum;
@ -36,7 +35,7 @@ public class SetMaintCmd extends AbstractDevCmd {
return; return;
} }
Building targetBuilding = (Building)target; Building targetBuilding = (Building) target;
if (targetBuilding.getProtectionState().equals(Enum.ProtectionState.NPC)) { if (targetBuilding.getProtectionState().equals(Enum.ProtectionState.NPC)) {
ChatManager.chatSayInfo(player, "Target is not a valid building"); ChatManager.chatSayInfo(player, "Target is not a valid building");

38
src/engine/devcmd/cmds/SetNpcEquipSetCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
@ -21,6 +20,7 @@ import engine.objects.PlayerCharacter;
public class SetNpcEquipSetCmd extends AbstractDevCmd { public class SetNpcEquipSetCmd extends AbstractDevCmd {
public static int lastEquipSetID = 0; public static int lastEquipSetID = 0;
public SetNpcEquipSetCmd() { public SetNpcEquipSetCmd() {
super("setEquipSet"); super("setEquipSet");
this.addCmdString("equipset"); this.addCmdString("equipset");
@ -35,14 +35,14 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
return; return;
} }
if (target.getObjectType() != GameObjectType.NPC){ if (target.getObjectType() != GameObjectType.NPC) {
this.sendUsage(pc); this.sendUsage(pc);
return; return;
} }
NPC npc = (NPC)target; NPC npc = (NPC) target;
if (words[0].equalsIgnoreCase("next")){ if (words[0].equalsIgnoreCase("next")) {
if (SetNpcEquipSetCmd.lastEquipSetID >= 1222) if (SetNpcEquipSetCmd.lastEquipSetID >= 1222)
SetNpcEquipSetCmd.lastEquipSetID = 1; SetNpcEquipSetCmd.lastEquipSetID = 1;
@ -51,28 +51,27 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
boolean complete = false; boolean complete = false;
while (complete == false){ while (complete == false) {
complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID); complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
if (!complete){ if (!complete) {
SetNpcEquipSetCmd.lastEquipSetID++; SetNpcEquipSetCmd.lastEquipSetID++;
if (SetNpcEquipSetCmd.lastEquipSetID >= 1222) if (SetNpcEquipSetCmd.lastEquipSetID >= 1222)
SetNpcEquipSetCmd.lastEquipSetID = 1; SetNpcEquipSetCmd.lastEquipSetID = 1;
} }
} }
if (complete){ if (complete) {
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID()); npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
WorldGrid.updateObject(npc); WorldGrid.updateObject(npc);
this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID ); this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID);
} }
return; return;
} }
if (words[0].equalsIgnoreCase("last")){ if (words[0].equalsIgnoreCase("last")) {
if (SetNpcEquipSetCmd.lastEquipSetID <= 1) if (SetNpcEquipSetCmd.lastEquipSetID <= 1)
SetNpcEquipSetCmd.lastEquipSetID = 1222; SetNpcEquipSetCmd.lastEquipSetID = 1222;
@ -81,10 +80,10 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
boolean complete = false; boolean complete = false;
while (complete == false){ while (complete == false) {
complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID); complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
if (!complete){ if (!complete) {
SetNpcEquipSetCmd.lastEquipSetID--; SetNpcEquipSetCmd.lastEquipSetID--;
if (SetNpcEquipSetCmd.lastEquipSetID <= 1) if (SetNpcEquipSetCmd.lastEquipSetID <= 1)
SetNpcEquipSetCmd.lastEquipSetID = 1222; SetNpcEquipSetCmd.lastEquipSetID = 1222;
@ -92,27 +91,26 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
} }
if (complete){ if (complete) {
this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID ); this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID);
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID()); npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
WorldGrid.updateObject(npc); WorldGrid.updateObject(npc);
} }
return; return;
} }
int equipSetID = 0; int equipSetID = 0;
try{ try {
equipSetID = Integer.parseInt(words[0]); equipSetID = Integer.parseInt(words[0]);
}catch(Exception e){ } catch (Exception e) {
this.throwbackError(pc, e.getMessage()); this.throwbackError(pc, e.getMessage());
} }
if (!NPC.UpdateEquipSetID(npc, equipSetID)){ if (!NPC.UpdateEquipSetID(npc, equipSetID)) {
this.throwbackError(pc, "Unable to find Equipset for ID " + equipSetID ); this.throwbackError(pc, "Unable to find Equipset for ID " + equipSetID);
return; return;
} }
@ -120,7 +118,7 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID()); npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
WorldGrid.updateObject(npc); WorldGrid.updateObject(npc);
this.throwbackInfo(pc, "Equipment Set Changed to " + equipSetID ); this.throwbackInfo(pc, "Equipment Set Changed to " + equipSetID);
} }

7
src/engine/devcmd/cmds/SetNpcMobbaseCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
@ -35,16 +34,16 @@ public class SetNpcMobbaseCmd extends AbstractDevCmd {
return; return;
} }
if (target.getObjectType() != GameObjectType.NPC){ if (target.getObjectType() != GameObjectType.NPC) {
this.sendUsage(player); this.sendUsage(player);
return; return;
} }
NPC npc = (NPC)target; NPC npc = (NPC) target;
int mobBaseID = Integer.parseInt(words[0]); int mobBaseID = Integer.parseInt(words[0]);
if (MobBase.getMobBase(mobBaseID) == null){ if (MobBase.getMobBase(mobBaseID) == null) {
this.throwbackError(player, "Cannot find Mobbase for ID " + mobBaseID); this.throwbackError(player, "Cannot find Mobbase for ID " + mobBaseID);
return; return;
} }

6
src/engine/devcmd/cmds/SetNpcNameCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
@ -20,6 +19,7 @@ import engine.objects.PlayerCharacter;
public class SetNpcNameCmd extends AbstractDevCmd { public class SetNpcNameCmd extends AbstractDevCmd {
public static int lastEquipSetID = 0; public static int lastEquipSetID = 0;
public SetNpcNameCmd() { public SetNpcNameCmd() {
super("setNPCName"); super("setNPCName");
this.addCmdString("npcname"); this.addCmdString("npcname");
@ -34,12 +34,12 @@ public class SetNpcNameCmd extends AbstractDevCmd {
return; return;
} }
if (target.getObjectType() != GameObjectType.NPC){ if (target.getObjectType() != GameObjectType.NPC) {
this.sendUsage(pc); this.sendUsage(pc);
return; return;
} }
NPC npc = (NPC)target; NPC npc = (NPC) target;
String name = words[0]; String name = words[0];

19
src/engine/devcmd/cmds/SetOwnerCmd.java

@ -8,9 +8,7 @@ import engine.objects.*;
/** /**
* * @author Dev command to set the owner of targeted building.
* @author
* Dev command to set the owner of targeted building.
* Argument is a valid guild UID * Argument is a valid guild UID
*/ */
public class SetOwnerCmd extends AbstractDevCmd { public class SetOwnerCmd extends AbstractDevCmd {
@ -27,7 +25,7 @@ public class SetOwnerCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pcSender, String[] args, protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) { AbstractGameObject target) {
if(validateUserInput(pcSender, target, args) == false) { if (validateUserInput(pcSender, target, args) == false) {
this.sendUsage(pcSender); this.sendUsage(pcSender);
return; return;
} }
@ -45,7 +43,8 @@ public class SetOwnerCmd extends AbstractDevCmd {
if (city != null) { if (city != null) {
city.claim(outOwner); city.claim(outOwner);
return; } return;
}
} }
_targetBuilding.setOwner(outOwner); _targetBuilding.setOwner(outOwner);
@ -89,8 +88,8 @@ public class SetOwnerCmd extends AbstractDevCmd {
// Argument must parse to a long. // Argument must parse to a long.
try { try {
Long.parseLong(userInput[0]); } Long.parseLong(userInput[0]);
catch (NumberFormatException | NullPointerException e) { } catch (NumberFormatException | NullPointerException e) {
return false; return false;
} }
@ -100,10 +99,10 @@ public class SetOwnerCmd extends AbstractDevCmd {
switch (_newOwnerType) { switch (_newOwnerType) {
case NPC: case NPC:
outOwner = (AbstractCharacter)DbManager.getObject(GameObjectType.NPC, Integer.parseInt(userInput[0])); outOwner = (AbstractCharacter) DbManager.getObject(GameObjectType.NPC, Integer.parseInt(userInput[0]));
break; break;
case CHARACTER: case CHARACTER:
outOwner = (AbstractCharacter)DbManager.getObject(GameObjectType.PlayerCharacter, Integer.parseInt(userInput[0])); outOwner = (AbstractCharacter) DbManager.getObject(GameObjectType.PlayerCharacter, Integer.parseInt(userInput[0]));
break; break;
} }
@ -113,6 +112,6 @@ public class SetOwnerCmd extends AbstractDevCmd {
} }
return true; return true;
} }
} }

16
src/engine/devcmd/cmds/SetRankCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
@ -51,10 +50,10 @@ public class SetRankCmd extends AbstractDevCmd {
return; return;
} }
if (target != null){ if (target != null) {
switch(target.getObjectType()){ switch (target.getObjectType()) {
case Building: case Building:
Building targetBuilding = (Building)target; Building targetBuilding = (Building) target;
Blueprint blueprint = targetBuilding.getBlueprint(); Blueprint blueprint = targetBuilding.getBlueprint();
if (blueprint == null) { if (blueprint == null) {
@ -75,14 +74,14 @@ public class SetRankCmd extends AbstractDevCmd {
ChatManager.chatSayInfo(player, "Rank set for building with ID " + targetBuilding.getObjectUUID() + " to rank " + targetRank); ChatManager.chatSayInfo(player, "Rank set for building with ID " + targetBuilding.getObjectUUID() + " to rank " + targetRank);
break; break;
case NPC: case NPC:
NPC toRank = (NPC)target; NPC toRank = (NPC) target;
toRank.setRank(targetRank * 10); toRank.setRank(targetRank * 10);
toRank.setUpgradeDateTime(null); toRank.setUpgradeDateTime(null);
WorldGrid.updateObject(toRank); WorldGrid.updateObject(toRank);
break; break;
case Mob: case Mob:
Mob toRankCaptain = (Mob)target; Mob toRankCaptain = (Mob) target;
if (toRankCaptain.getContract() != null){ if (toRankCaptain.getContract() != null) {
toRankCaptain.setRank(targetRank * 10); toRankCaptain.setRank(targetRank * 10);
Mob.setUpgradeDateTime(toRankCaptain, null); Mob.setUpgradeDateTime(toRankCaptain, null);
WorldGrid.updateObject(toRankCaptain); WorldGrid.updateObject(toRankCaptain);
@ -91,7 +90,7 @@ public class SetRankCmd extends AbstractDevCmd {
break; break;
} }
}else{ } else {
Building targetBuilding = null; Building targetBuilding = null;
if (uuid != 0) if (uuid != 0)
targetBuilding = BuildingManager.getBuilding(uuid); targetBuilding = BuildingManager.getBuilding(uuid);
@ -126,7 +125,6 @@ public class SetRankCmd extends AbstractDevCmd {
} }
} }
@Override @Override

2
src/engine/devcmd/cmds/SetRuneCmd.java

@ -17,9 +17,7 @@ import engine.objects.CharacterRune;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
/** /**
*
* @author Eighty * @author Eighty
*
*/ */
public class SetRuneCmd extends AbstractDevCmd { public class SetRuneCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/SetStaminaCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum.DispatchChannel; import engine.Enum.DispatchChannel;

31
src/engine/devcmd/cmds/SetSubRaceCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
@ -29,22 +28,22 @@ public class SetSubRaceCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pc, String[] words, protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (target instanceof AbstractCharacter){ if (target instanceof AbstractCharacter) {
if (words[0].equals("race")){ if (words[0].equals("race")) {
if (target.getObjectType() != GameObjectType.PlayerCharacter) if (target.getObjectType() != GameObjectType.PlayerCharacter)
return; return;
PlayerCharacter player = (PlayerCharacter)target; PlayerCharacter player = (PlayerCharacter) target;
int raceID = Integer.parseInt(words[1]); int raceID = Integer.parseInt(words[1]);
player.setSubRaceID(raceID); player.setSubRaceID(raceID);
if (raceID == 0) if (raceID == 0)
raceID = player.getRaceID(); raceID = player.getRaceID();
UpdateCharOrMobMessage ucm = new UpdateCharOrMobMessage(player, 1,raceID); UpdateCharOrMobMessage ucm = new UpdateCharOrMobMessage(player, 1, raceID);
DispatchMessage.sendToAllInRange(player, ucm); DispatchMessage.sendToAllInRange(player, ucm);
return; return;
} }
if (words[0].equals("all")){ if (words[0].equals("all")) {
for (int i = 15999; i< 16337;i++){ for (int i = 15999; i < 16337; i++) {
ApplyBuildingEffectMsg applyBuildingEffectMsg = new ApplyBuildingEffectMsg(4, 0, target.getObjectType().ordinal(), target.getObjectUUID(), i); ApplyBuildingEffectMsg applyBuildingEffectMsg = new ApplyBuildingEffectMsg(4, 0, target.getObjectType().ordinal(), target.getObjectUUID(), i);
DispatchMessage.sendToAllInRange((AbstractWorldObject) target, applyBuildingEffectMsg); DispatchMessage.sendToAllInRange((AbstractWorldObject) target, applyBuildingEffectMsg);
try { try {
@ -55,7 +54,7 @@ public class SetSubRaceCmd extends AbstractDevCmd {
} }
} }
}else{ } else {
ApplyBuildingEffectMsg applyBuildingEffectMsg = new ApplyBuildingEffectMsg(4, 0, target.getObjectType().ordinal(), target.getObjectUUID(), Integer.parseInt(words[0])); ApplyBuildingEffectMsg applyBuildingEffectMsg = new ApplyBuildingEffectMsg(4, 0, target.getObjectType().ordinal(), target.getObjectUUID(), Integer.parseInt(words[0]));
DispatchMessage.sendToAllInRange((AbstractWorldObject) target, applyBuildingEffectMsg); DispatchMessage.sendToAllInRange((AbstractWorldObject) target, applyBuildingEffectMsg);
} }
@ -63,10 +62,10 @@ public class SetSubRaceCmd extends AbstractDevCmd {
return; return;
} }
Building building = (Building)target; Building building = (Building) target;
building.removeAllVisualEffects(); building.removeAllVisualEffects();
building.addEffectBit(1<<Integer.parseInt(words[0])); building.addEffectBit(1 << Integer.parseInt(words[0]));
building.updateEffects(); building.updateEffects();
//63535 38751 //63535 38751
// Zone zone = ZoneManager.findSmallestZone(pc.getLoc()); // Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
@ -79,7 +78,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
//pc.getCharItemManager().updateInventory(); //pc.getCharItemManager().updateInventory();
// Mob mob = (Mob)target; // Mob mob = (Mob)target;
// //
// if (mob == null) // if (mob == null)
@ -90,8 +88,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
// mob.getCharItemManager().addItemToInventory(mobLoot); // mob.getCharItemManager().addItemToInventory(mobLoot);
// if (target.getObjectType() != GameObjectType.Building) // if (target.getObjectType() != GameObjectType.Building)
// return; // return;
// //
@ -155,13 +151,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
// } // }
// for (EffectsBase eb : EffectsBase.getAllEffectsBase()){ // for (EffectsBase eb : EffectsBase.getAllEffectsBase()){
// if (eb.getToken() == 0) // if (eb.getToken() == 0)
// continue; // continue;
@ -192,8 +181,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
// } // }
} }
@Override @Override

3
src/engine/devcmd/cmds/ShowOffsetCmd.java

@ -25,7 +25,7 @@ public class ShowOffsetCmd extends AbstractDevCmd {
Vector3fImmutable offset; Vector3fImmutable offset;
String newline = "\r\n "; String newline = "\r\n ";
targetBuilding = (Building)target; targetBuilding = (Building) target;
if (targetBuilding.getObjectType() != GameObjectType.Building) { if (targetBuilding.getObjectType() != GameObjectType.Building) {
throwbackInfo(pc, "showgate: target must be an Building"); throwbackInfo(pc, "showgate: target must be an Building");
@ -53,5 +53,4 @@ public class ShowOffsetCmd extends AbstractDevCmd {
} }
} }

3
src/engine/devcmd/cmds/SlotTestCmd.java

@ -7,7 +7,6 @@
// www.magicbane.com // www.magicbane.com
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
@ -77,7 +76,7 @@ public class SlotTestCmd extends AbstractDevCmd {
} }
ChatManager.chatSystemInfo(playerCharacter,outString); ChatManager.chatSystemInfo(playerCharacter, outString);
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save