Browse Source

Name/level saved to disk when slotting mobiles.

master
MagicBot 2 years ago
parent
commit
edd1c0e9a6
  1. 6
      src/engine/db/handlers/dbMobHandler.java
  2. 2
      src/engine/gameManager/BuildingManager.java
  3. 51
      src/engine/objects/Mob.java

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

@ -9,7 +9,6 @@
package engine.db.handlers; package engine.db.handlers;
import engine.gameManager.NPCManager;
import engine.objects.Mob; import engine.objects.Mob;
import engine.objects.Zone; import engine.objects.Zone;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
@ -27,9 +26,9 @@ public class dbMobHandler extends dbHandlerBase {
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
} }
public Mob ADD_MOB(Mob toAdd, boolean isMob) public Mob ADD_MOB(Mob toAdd)
{ {
prepareCallable("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); prepareCallable("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
setLong(1, toAdd.getParentZoneID()); setLong(1, toAdd.getParentZoneID());
setInt(2, toAdd.getMobBaseID()); setInt(2, toAdd.getMobBaseID());
setInt(3, toAdd.getGuildUUID()); setInt(3, toAdd.getGuildUUID());
@ -45,6 +44,7 @@ public class dbMobHandler extends dbHandlerBase {
setInt(10, 0); setInt(10, 0);
setInt(11, toAdd.getBuildingID()); setInt(11, toAdd.getBuildingID());
setInt(12, toAdd.getLevel()); setInt(12, toAdd.getLevel());
setString(13, toAdd.getFirstName());
int objectUUID = (int) getUUID(); int objectUUID = (int) getUUID();
if (objectUUID > 0) if (objectUUID > 0)
return GET_MOB(objectUUID); return GET_MOB(objectUUID);

2
src/engine/gameManager/BuildingManager.java

@ -470,7 +470,7 @@ public enum BuildingManager {
NPC npc = null; NPC npc = null;
if (NPC.ISWallArcher(contractID.getContractID())) { if (NPC.ISWallArcher(contractID.getContractID())) {
mob = Mob.createMob( contractID.getMobbaseID(), NpcLoc, contractOwner.getGuild(), true, zone, building, contractID.getContractID(), pirateName, 1); mob = Mob.createMob( contractID.getMobbaseID(), NpcLoc, contractOwner.getGuild(), true, zone, building, contractID.getContractID(), pirateName, rank);
if (mob == null) if (mob == null)
return false; return false;

51
src/engine/objects/Mob.java

@ -126,10 +126,10 @@ public class Mob extends AbstractIntelligenceAgent {
if (building != null) this.buildingID = building.getObjectUUID(); if (building != null) this.buildingID = building.getObjectUUID();
else this.buildingID = 0; else this.buildingID = 0;
if (contractID == 0) this.contract = null; if (contractID == 0)
else this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); this.contract = null;
else
if (this.contract != null) this.level = 10; this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID);
clearStatic(); clearStatic();
} }
@ -223,8 +223,10 @@ public class Mob extends AbstractIntelligenceAgent {
int contractID = rs.getInt("mob_contractID"); int contractID = rs.getInt("mob_contractID");
if (contractID == 0) this.contract = null; if (contractID == 0)
else this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); this.contract = null;
else
this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID);
if (this.contract != null) if (NPC.ISGuardCaptain(contract.getContractID())) { if (this.contract != null) if (NPC.ISGuardCaptain(contract.getContractID())) {
this.spawnTime = 60 * 15; this.spawnTime = 60 * 15;
@ -235,15 +237,18 @@ public class Mob extends AbstractIntelligenceAgent {
int guildID = rs.getInt("mob_guildUID"); int guildID = rs.getInt("mob_guildUID");
if (this.building != null) this.guild = this.building.getGuild(); if (this.building != null)
else this.guild = Guild.getGuild(guildID); this.guild = this.building.getGuild();
else
this.guild = Guild.getGuild(guildID);
if (this.guild == null) this.guild = Guild.getErrantGuild(); if (this.guild == null) this.guild = Guild.getErrantGuild();
java.util.Date sqlDateTime; java.util.Date sqlDateTime;
sqlDateTime = rs.getTimestamp("upgradeDate"); sqlDateTime = rs.getTimestamp("upgradeDate");
if (sqlDateTime != null) upgradeDateTime = new DateTime(sqlDateTime); if (sqlDateTime != null)
upgradeDateTime = new DateTime(sqlDateTime);
else upgradeDateTime = null; else upgradeDateTime = null;
// Submit upgrade job if NPC is currently set to rank. // Submit upgrade job if NPC is currently set to rank.
@ -254,23 +259,30 @@ public class Mob extends AbstractIntelligenceAgent {
this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks()); this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks());
if (this.mobBase != null && this.spawnTime == 0) this.spawnTime = this.mobBase.getSpawnTime(); if (this.mobBase != null && this.spawnTime == 0)
this.spawnTime = this.mobBase.getSpawnTime();
this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon);
this.setParentZone(ZoneManager.getZoneByUUID(this.parentZoneID)); this.setParentZone(ZoneManager.getZoneByUUID(this.parentZoneID));
this.equipmentSetID = rs.getInt("equipmentSet");
this.runeSet = rs.getInt("runeSet"); this.runeSet = rs.getInt("runeSet");
this.bootySet = rs.getInt("bootySet"); this.bootySet = rs.getInt("bootySet");
this.notEnemy = EnumBitSet.asEnumBitSet(rs.getLong("notEnemy"), Enum.MonsterType.class); this.notEnemy = EnumBitSet.asEnumBitSet(rs.getLong("notEnemy"), Enum.MonsterType.class);
this.enemy = EnumBitSet.asEnumBitSet(rs.getLong("enemy"), Enum.MonsterType.class); this.enemy = EnumBitSet.asEnumBitSet(rs.getLong("enemy"), Enum.MonsterType.class);
if (this.contract != null) this.equipmentSetID = this.contract.getEquipmentSet(); if (this.contract != null) {
this.equipmentSetID = this.contract.getEquipmentSet();
this.nameOverride = rs.getString("npc_name") + " the " + this.getContract().getName();
} else {
this.equipmentSetID = rs.getInt("equipmentSet");
this.nameOverride = rs.getString("mob_name");
}
if (rs.getString("fsm").length() > 1)
this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm"));
this.nameOverride = rs.getString("mob_name");
if (rs.getString("fsm").length() > 1) this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm"));
} catch (Exception e) { } catch (Exception e) {
Logger.error(currentID + ""); Logger.error(currentID + "");
} }
@ -503,16 +515,20 @@ public class Mob extends AbstractIntelligenceAgent {
public static Mob createMob(int loadID, Vector3fImmutable spawn, Guild guild, boolean isMob, Zone parent, Building building, int contractID, String pirateName, int rank) { public static Mob createMob(int loadID, Vector3fImmutable spawn, Guild guild, boolean isMob, Zone parent, Building building, int contractID, String pirateName, int rank) {
Mob mobWithoutID = new Mob("", "", (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); 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 (parent != null) if (parent != null)
mobWithoutID.setRelPos(parent, spawn.x - parent.absX, spawn.y - parent.absY, spawn.z - parent.absZ); mobWithoutID.setRelPos(parent, spawn.x - parent.absX, spawn.y - parent.absY, spawn.z - parent.absZ);
if (mobWithoutID.mobBase == null)
return null;
mobWithoutID.level = (short) (rank * 10);
if (mobWithoutID.mobBase == null) return null;
Mob mob; Mob mob;
try { try {
mob = DbManager.MobQueries.ADD_MOB(mobWithoutID, isMob); mob = DbManager.MobQueries.ADD_MOB(mobWithoutID);
mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks());
mob.setMob(); mob.setMob();
mob.setParentZone(parent); mob.setParentZone(parent);
@ -522,7 +538,6 @@ public class Mob extends AbstractIntelligenceAgent {
mob.setLoc(buildingWorldLoc); mob.setLoc(buildingWorldLoc);
mob.region = AbstractWorldObject.GetRegionByWorldObject(mob); mob.region = AbstractWorldObject.GetRegionByWorldObject(mob);
MovementManager.translocate(mob, buildingWorldLoc, mob.region); MovementManager.translocate(mob, buildingWorldLoc, mob.region);
mob.nameOverride = NPC.getPirateName(mob.getMobBaseID()) + " the " + mob.getContract().getName();
mob.runAfterLoad(); mob.runAfterLoad();
} catch (Exception e) { } catch (Exception e) {
Logger.error("SQLException:" + e.getMessage()); Logger.error("SQLException:" + e.getMessage());

Loading…
Cancel
Save