Browse Source

bane commander NPC

lakebane2
FatBoy-DOTC 3 weeks ago
parent
commit
9f0c7f6a76
  1. 14
      src/engine/db/handlers/dbNPCHandler.java
  2. 10
      src/engine/gameManager/BuildingManager.java
  3. 10
      src/engine/objects/Bane.java

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

@ -131,11 +131,11 @@ public class dbNPCHandler extends dbHandlerBase {
return npc; return npc;
} }
public boolean BANE_COMMANDER_EXISTS(final int objectUUID) { public int BANE_COMMANDER_EXISTS(final int objectUUID) {
boolean exists = false; int uid = 0;
String query = "SELECT 1 FROM `obj_npc` WHERE `npc_buildingID` = ? LIMIT 1;"; String query = "SELECT `UID` FROM `obj_npc` WHERE `npc_buildingID` = ? LIMIT 1;";
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(query)) { PreparedStatement preparedStatement = connection.prepareStatement(query)) {
@ -143,15 +143,17 @@ public class dbNPCHandler extends dbHandlerBase {
preparedStatement.setInt(1, objectUUID); preparedStatement.setInt(1, objectUUID);
try (ResultSet rs = preparedStatement.executeQuery()) { try (ResultSet rs = preparedStatement.executeQuery()) {
// If there's a result, it means the entry exists if (rs.next()) {
exists = rs.next(); // Retrieve the UID column value
uid = rs.getInt("UID");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
Logger.error(e); Logger.error(e);
} }
return exists; return uid;
} }

10
src/engine/gameManager/BuildingManager.java

@ -438,6 +438,16 @@ public enum BuildingManager {
public static boolean IsPlayerHostile(Building building, PlayerCharacter player) { public static boolean IsPlayerHostile(Building building, PlayerCharacter player) {
if(building.getBlueprint().getBuildingGroup().equals(BuildingGroup.BANESTONE))
{
Guild playerNation = player.guild.getNation();
City banedCity = ZoneManager.getCityAtLocation(building.loc);
if(banedCity != null){
if(banedCity.getGuild().getNation().equals(playerNation)){
return false;
}
}
}
//Nation Members and Guild members are not hostile. //Nation Members and Guild members are not hostile.
// if (building.getGuild() != null){ // if (building.getGuild() != null){
// if (pc.getGuild() != null) // if (pc.getGuild() != null)

10
src/engine/objects/Bane.java

@ -273,16 +273,18 @@ 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;
boolean npcPresent = DbManager.NPCQueries.BANE_COMMANDER_EXISTS(bane.getStone().getObjectUUID()); int commanderuuid = DbManager.NPCQueries.BANE_COMMANDER_EXISTS(bane.getStone().getObjectUUID());
if(!npcPresent) { if(commanderuuid != 0) {
//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{ }
baneCommander = (NPC)bane.getStone().getHirelings().keySet().iterator().next(); else
{
baneCommander = NPC.getNPC(commanderuuid);
baneCommander.setLoc(spawnLoc); baneCommander.setLoc(spawnLoc);
baneCommander.setGuild(bane.getCity().getGuild()); baneCommander.setGuild(bane.getCity().getGuild());
} }

Loading…
Cancel
Save