Browse Source

Refactor towards new constructor.

combat-2
MagicBot 1 year ago
parent
commit
24639b62c0
  1. 24
      src/engine/db/handlers/dbMobHandler.java
  2. 4
      src/engine/objects/AbstractCharacter.java
  3. 32
      src/engine/objects/Mob.java

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

@ -35,24 +35,24 @@ public class dbMobHandler extends dbHandlerBase {
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) { PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
preparedStatement.setLong(1, toAdd.getParentZoneUUID()); preparedStatement.setLong(1, toAdd.parentZoneUUID);
preparedStatement.setInt(2, toAdd.getMobBaseID()); preparedStatement.setInt(2, toAdd.loadID);
preparedStatement.setInt(3, toAdd.getGuildUUID()); preparedStatement.setInt(3, toAdd.guildUUID);
preparedStatement.setFloat(4, toAdd.getSpawnX()); preparedStatement.setFloat(4, toAdd.bindLoc.x);
preparedStatement.setFloat(5, toAdd.getSpawnY()); preparedStatement.setFloat(5, toAdd.bindLoc.y);
preparedStatement.setFloat(6, toAdd.getSpawnZ()); preparedStatement.setFloat(6, toAdd.bindLoc.z);
preparedStatement.setInt(7, 0); preparedStatement.setInt(7, 0);
preparedStatement.setFloat(8, toAdd.getSpawnRadius()); preparedStatement.setFloat(8, toAdd.spawnRadius);
preparedStatement.setInt(9, toAdd.getTrueSpawnTime()); preparedStatement.setInt(9, toAdd.spawnTime);
if (toAdd.getContract() != null) if (toAdd.getContract() != null)
preparedStatement.setInt(10, toAdd.getContract().getContractID()); preparedStatement.setInt(10, toAdd.contractUUID);
else else
preparedStatement.setInt(10, 0); preparedStatement.setInt(10, 0);
preparedStatement.setInt(11, toAdd.getBuildingID()); preparedStatement.setInt(11, toAdd.buildingUUID);
preparedStatement.setInt(12, toAdd.getLevel()); preparedStatement.setInt(12, toAdd.level);
preparedStatement.setString(13, toAdd.getFirstName()); preparedStatement.setString(13, toAdd.firstName);
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();

4
src/engine/objects/AbstractCharacter.java

@ -52,8 +52,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
public int contractUUID; public int contractUUID;
public Contract contract; public Contract contract;
protected String firstName; public String firstName;
protected String lastName; public String lastName;
protected short statStrCurrent; protected short statStrCurrent;
protected short statDexCurrent; protected short statDexCurrent;
protected short statConCurrent; protected short statConCurrent;

32
src/engine/objects/Mob.java

@ -78,10 +78,10 @@ public class Mob extends AbstractIntelligenceAgent {
public long stopPatrolTime = 0; public long stopPatrolTime = 0;
public City guardedCity; public City guardedCity;
protected int dbID; //the database ID protected int dbID; //the database ID
protected int loadID; public int loadID;
protected float spawnRadius; public float spawnRadius;
//used by static mobs //used by static mobs
protected int parentZoneUUID; public int parentZoneUUID;
protected float statLat; protected float statLat;
protected float statLon; protected float statLon;
protected float statAlt; protected float statAlt;
@ -472,6 +472,7 @@ public class Mob extends AbstractIntelligenceAgent {
Mob mobile = new Mob(); Mob mobile = new Mob();
mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
mobile.loadID = loadID; mobile.loadID = loadID;
mobile.level = (short) level;
if (guild.isEmptyGuild()) if (guild.isEmptyGuild())
mobile.guildUUID = 0; mobile.guildUUID = 0;
@ -480,32 +481,21 @@ public class Mob extends AbstractIntelligenceAgent {
mobile.parentZoneUUID = parent.getObjectUUID(); mobile.parentZoneUUID = parent.getObjectUUID();
mobile.buildingUUID = building.getObjectUUID(); mobile.buildingUUID = building.getObjectUUID();
mobile.firstName = pirateName;
mobile.bindLoc = spawn;
Mob mobWithoutID = new Mob(pirateName, "", (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 1, 0, false, false, false, spawn, spawn, Vector3fImmutable.ZERO, (short) 1, (short) 1, (short) 1, guild, (byte) 0, loadID, isMob, parent, building, contractID);
if (mobWithoutID.mobBase == null)
return null;
mobWithoutID.level = (short) level;
// Parent zone is required by dbhandler. Can likely if (mobile.buildingUUID != 0)
// refactor that out and just use the id. mobile.bindLoc = Vector3fImmutable.ZERO;
else
mobile.bindLoc = spawn;
mobWithoutID.parentZone = parent; mobile.firstName = pirateName;
mobWithoutID.parentZoneUUID = parent.getObjectUUID();
// NPC in a Building derives position from slot mobile.contractUUID = contractID;
if (mobWithoutID.building != null)
mobWithoutID.bindLoc = Vector3fImmutable.ZERO;
Mob mob; Mob mob;
try { try {
mob = DbManager.MobQueries.ADD_MOB(mobWithoutID); mob = DbManager.MobQueries.ADD_MOB(mobile);
mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks());
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save