Browse Source

bane commander NPC

lakebane2
FatBoy-DOTC 3 weeks ago
parent
commit
022c06c803
  1. 24
      src/engine/db/handlers/dbNPCHandler.java
  2. 13
      src/engine/objects/Bane.java

24
src/engine/db/handlers/dbNPCHandler.java

@ -131,6 +131,30 @@ public class dbNPCHandler extends dbHandlerBase {
return npc; return npc;
} }
public boolean BANE_COMMANDER_EXISTS(final int objectUUID) {
boolean exists = false;
String query = "SELECT 1 FROM `obj_npc` WHERE `npc_buildingID` = ? LIMIT 1;";
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(query)) {
preparedStatement.setInt(1, objectUUID);
try (ResultSet rs = preparedStatement.executeQuery()) {
// If there's a result, it means the entry exists
exists = rs.next();
}
} catch (SQLException e) {
Logger.error(e);
}
return exists;
}
public int MOVE_NPC(long npcID, long parentID, float locX, float locY, float locZ) { public int MOVE_NPC(long npcID, long parentID, float locX, float locY, float locZ) {
int rowCount; int rowCount;

13
src/engine/objects/Bane.java

@ -14,13 +14,11 @@ import engine.Enum.ProtectionState;
import engine.Enum.SiegePhase; import engine.Enum.SiegePhase;
import engine.Enum.SiegeResult; import engine.Enum.SiegeResult;
import engine.InterestManagement.HeightMap; import engine.InterestManagement.HeightMap;
import engine.InterestManagement.InterestManager;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.db.archive.BaneRecord; import engine.db.archive.BaneRecord;
import engine.db.archive.DataWarehouse; import engine.db.archive.DataWarehouse;
import engine.gameManager.BuildingManager; import engine.gameManager.*;
import engine.gameManager.ChatManager;
import engine.gameManager.DbManager;
import engine.gameManager.ZoneManager;
import engine.job.JobScheduler; import engine.job.JobScheduler;
import engine.jobs.ActivateBaneJob; import engine.jobs.ActivateBaneJob;
import engine.jobs.BaneDefaultTimeJob; import engine.jobs.BaneDefaultTimeJob;
@ -275,17 +273,20 @@ public final class Bane {
public static void summonBaneCommander(Bane bane){ public static void summonBaneCommander(Bane bane){
Vector3fImmutable spawnLoc = Vector3fImmutable.getRandomPointOnCircle(bane.getStone().loc,15); Vector3fImmutable spawnLoc = Vector3fImmutable.getRandomPointOnCircle(bane.getStone().loc,15);
NPC baneCommander; NPC baneCommander;
if(bane.getStone().getHirelings().isEmpty()) { boolean npcPresent = DbManager.NPCQueries.BANE_COMMANDER_EXISTS(bane.getStone().getObjectUUID());
if(!npcPresent) {
//add bane commander NPC //add bane commander NPC
int contractID = 1502042; int contractID = 1502042;
baneCommander = NPC.createNPC("Bane Commander", contractID, spawnLoc, bane.getCity().getGuild(), ZoneManager.findSmallestZone(bane.getStone().loc), (short) 70, bane.getStone()); baneCommander = NPC.createNPC("Bane Commander", contractID, spawnLoc, bane.getCity().getGuild(), ZoneManager.findSmallestZone(bane.getStone().loc), (short) 70, bane.getStone());
baneCommander.setLoc(spawnLoc); baneCommander.setLoc(spawnLoc);
baneCommander.setGuild(bane.getCity().getGuild()); baneCommander.setGuild(bane.getCity().getGuild());
}else{ }else{
baneCommander = (NPC)bane.getStone().getHirelings().keySet().iterator().next(); baneCommander = (NPC)bane.getStone().getHirelings().keySet().iterator().next();
baneCommander.setLoc(spawnLoc); baneCommander.setLoc(spawnLoc);
baneCommander.setGuild(bane.getCity().getGuild()); baneCommander.setGuild(bane.getCity().getGuild());
} }
InterestManager.setObjectDirty(baneCommander);
} }
public static Bane getBane(int cityUUID) { public static Bane getBane(int cityUUID) {

Loading…
Cancel
Save