Compare commits
225
Commits
No files matched your search
@@ -468,7 +468,12 @@ public enum InterestManager implements Runnable {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
|
awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
|
||||||
((Mob) awonpc).setCombatTarget(null);
|
|
||||||
|
// siege engines keep firing at their target when a new player loads them
|
||||||
|
|
||||||
|
if (!awonpc.isSiege())
|
||||||
|
((Mob) awonpc).setCombatTarget(null);
|
||||||
|
|
||||||
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
|
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
|
||||||
|
|
||||||
} else if ((awo.getObjectTypeMask() & MBServerStatics.MASK_NPC) != 0) {
|
} else if ((awo.getObjectTypeMask() & MBServerStatics.MASK_NPC) != 0) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package engine.InterestManagement;
|
|||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Vector2f;
|
import engine.math.Vector2f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
|
import engine.mbEnums;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ public class Terrain {
|
|||||||
// Configure PLANAR zones to use the same 16x16 pixel image
|
// Configure PLANAR zones to use the same 16x16 pixel image
|
||||||
// that all similar terrains share. (See JSON)
|
// that all similar terrains share. (See JSON)
|
||||||
|
|
||||||
if (this.zone.template.terrain_type.equals("PLANAR"))
|
if (this.zone.template.terrain_type == mbEnums.TerrainGenType.PLANAR)
|
||||||
this.heightmap = 1006300; // all 0
|
this.heightmap = 1006300; // all 0
|
||||||
|
|
||||||
// Load pixel data for this terrain from cache
|
// Load pixel data for this terrain from cache
|
||||||
@@ -71,8 +72,8 @@ public class Terrain {
|
|||||||
// the blending area between child and parent terrains when
|
// the blending area between child and parent terrains when
|
||||||
// they are stitched together.
|
// they are stitched together.
|
||||||
|
|
||||||
this.blend_values.x = this.zone.template.max_blend;
|
this.blend_values.x = this.zone.template.zone_max_blend;
|
||||||
this.blend_values.y = this.zone.template.min_blend;
|
this.blend_values.y = this.zone.template.zone_min_blend;
|
||||||
|
|
||||||
Vector2f major_blend = new Vector2f(this.blend_values.x / this.zone.major_radius,
|
Vector2f major_blend = new Vector2f(this.blend_values.x / this.zone.major_radius,
|
||||||
this.blend_values.y / this.zone.major_radius);
|
this.blend_values.y / this.zone.major_radius);
|
||||||
@@ -217,8 +218,8 @@ public class Terrain {
|
|||||||
|
|
||||||
// Normalize terrain offset
|
// Normalize terrain offset
|
||||||
|
|
||||||
Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.zone.template.major_radius,
|
Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.zone.template.zone_major_radius,
|
||||||
Math.abs(zone_offset.y) / this.zone.template.minor_radius);
|
Math.abs(zone_offset.y) / this.zone.template.zone_minor_radius);
|
||||||
|
|
||||||
float blendCoefficient;
|
float blendCoefficient;
|
||||||
|
|
||||||
|
|||||||
@@ -118,11 +118,6 @@ public class WorldGrid {
|
|||||||
return outbound;
|
return outbound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashSet<AbstractWorldObject> getObjectsInRangePartialNecroPets(Vector3fImmutable loc, double r) {
|
|
||||||
HashSet<AbstractWorldObject> outbound = new HashSet<>();
|
|
||||||
return outbound;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import engine.mbEnums;
|
|||||||
import engine.objects.Bane;
|
import engine.objects.Bane;
|
||||||
import engine.objects.City;
|
import engine.objects.City;
|
||||||
import engine.workthreads.WarehousePushThread;
|
import engine.workthreads.WarehousePushThread;
|
||||||
|
import org.joda.time.DateTime;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
@@ -33,8 +34,8 @@ public class BaneRecord extends DataRecord {
|
|||||||
private String baneDropperHash;
|
private String baneDropperHash;
|
||||||
private String baneGuildHash;
|
private String baneGuildHash;
|
||||||
private String baneNationHash;
|
private String baneNationHash;
|
||||||
private LocalDateTime baneLiveTime;
|
private DateTime baneLiveTime;
|
||||||
private LocalDateTime baneDropTime;
|
private DateTime baneDropTime;
|
||||||
|
|
||||||
private BaneRecord(Bane bane) {
|
private BaneRecord(Bane bane) {
|
||||||
this.recordType = mbEnums.DataRecordType.BANE;
|
this.recordType = mbEnums.DataRecordType.BANE;
|
||||||
@@ -128,9 +129,9 @@ public class BaneRecord extends DataRecord {
|
|||||||
return outStatement;
|
return outStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LocalDateTime getLastBaneDateTime(City city) {
|
public static DateTime getLastBaneDateTime(City city) {
|
||||||
|
|
||||||
LocalDateTime outDateTime = null;
|
DateTime outDateTime = null;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement statement = buildDateTimeQueryStatement(connection, city);
|
PreparedStatement statement = buildDateTimeQueryStatement(connection, city);
|
||||||
@@ -138,7 +139,7 @@ public class BaneRecord extends DataRecord {
|
|||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
outDateTime = rs.getTimestamp("endDatetime").toLocalDateTime();
|
outDateTime = new DateTime(rs.getTimestamp("endDatetime"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +160,7 @@ public class BaneRecord extends DataRecord {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateLiveDate(Bane bane, LocalDateTime dateTime) {
|
public static void updateLiveDate(Bane bane, DateTime dateTime) {
|
||||||
|
|
||||||
if (bane == null)
|
if (bane == null)
|
||||||
return;
|
return;
|
||||||
@@ -174,13 +175,13 @@ public class BaneRecord extends DataRecord {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PreparedStatement buildUpdateLiveDateStatement(Connection connection, Bane bane, LocalDateTime dateTime) throws SQLException {
|
private static PreparedStatement buildUpdateLiveDateStatement(Connection connection, Bane bane, DateTime dateTime) throws SQLException {
|
||||||
|
|
||||||
PreparedStatement outStatement = null;
|
PreparedStatement outStatement = null;
|
||||||
String queryString = "UPDATE `warehouse_banehistory` SET `liveDatetime` = ?, `dirty` = 1 WHERE `city_id` = ? AND `resolution` = 'PENDING'";
|
String queryString = "UPDATE `warehouse_banehistory` SET `liveDatetime` = ?, `dirty` = 1 WHERE `city_id` = ? AND `resolution` = 'PENDING'";
|
||||||
|
|
||||||
outStatement = connection.prepareStatement(queryString);
|
outStatement = connection.prepareStatement(queryString);
|
||||||
outStatement.setTimestamp(1, Timestamp.valueOf(dateTime));
|
outStatement.setTimestamp(1, new java.sql.Timestamp(dateTime.getMillis()));
|
||||||
outStatement.setString(2, bane.getCity().getHash());
|
outStatement.setString(2, bane.getCity().getHash());
|
||||||
|
|
||||||
return outStatement;
|
return outStatement;
|
||||||
@@ -365,12 +366,12 @@ public class BaneRecord extends DataRecord {
|
|||||||
if (this.baneDropTime == null)
|
if (this.baneDropTime == null)
|
||||||
outStatement.setNull(8, java.sql.Types.DATE);
|
outStatement.setNull(8, java.sql.Types.DATE);
|
||||||
else
|
else
|
||||||
outStatement.setTimestamp(8, Timestamp.valueOf(this.baneDropTime));
|
outStatement.setTimestamp(8, new java.sql.Timestamp(this.baneDropTime.getMillis()));
|
||||||
|
|
||||||
if (this.baneLiveTime == null)
|
if (this.baneLiveTime == null)
|
||||||
outStatement.setNull(9, java.sql.Types.DATE);
|
outStatement.setNull(9, java.sql.Types.DATE);
|
||||||
else
|
else
|
||||||
outStatement.setTimestamp(9, Timestamp.valueOf(this.baneLiveTime));
|
outStatement.setTimestamp(9, new java.sql.Timestamp(this.baneLiveTime.getMillis()));
|
||||||
|
|
||||||
outStatement.setString(10, this.eventType.name());
|
outStatement.setString(10, this.eventType.name());
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import engine.objects.Bane;
|
|||||||
import engine.objects.Building;
|
import engine.objects.Building;
|
||||||
import engine.objects.City;
|
import engine.objects.City;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
import java.time.LocalDateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -71,12 +71,12 @@ public class dbBaneHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean SET_BANE_TIME(LocalDateTime toSet, int cityUUID) {
|
public boolean SET_BANE_TIME(DateTime toSet, int cityUUID) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=? WHERE `cityUUID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=? WHERE `cityUUID`=?")) {
|
||||||
|
|
||||||
preparedStatement.setTimestamp(1, java.sql.Timestamp.valueOf(toSet));
|
preparedStatement.setTimestamp(1, new java.sql.Timestamp(toSet.getMillis()));
|
||||||
preparedStatement.setLong(2, cityUUID);
|
preparedStatement.setLong(2, cityUUID);
|
||||||
|
|
||||||
preparedStatement.execute();
|
preparedStatement.execute();
|
||||||
|
|||||||
@@ -13,13 +13,7 @@ import engine.gameManager.DbManager;
|
|||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.mbEnums.GameObjectType;
|
import engine.mbEnums.GameObjectType;
|
||||||
import engine.objects.BaseClass;
|
import engine.objects.BaseClass;
|
||||||
import org.pmw.tinylog.Logger;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class dbBaseClassHandler extends dbHandlerBase {
|
public class dbBaseClassHandler extends dbHandlerBase {
|
||||||
|
|
||||||
@@ -33,59 +27,6 @@ public class dbBaseClassHandler extends dbHandlerBase {
|
|||||||
if (id == 0)
|
if (id == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
BaseClass baseClass = (BaseClass) DbManager.getFromCache(GameObjectType.BaseClass, id);
|
return (BaseClass) DbManager.getFromCache(GameObjectType.BaseClass, id);
|
||||||
|
|
||||||
if (baseClass != null)
|
|
||||||
return baseClass;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `obj_account` WHERE `UID`=?")) {
|
|
||||||
|
|
||||||
preparedStatement.setLong(1, id);
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
baseClass = (BaseClass) getObjectFromRs(rs);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<BaseClass> GET_BASECLASS_FOR_RACE(final int id) {
|
|
||||||
|
|
||||||
ArrayList<BaseClass> baseClasses = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT b.* FROM `static_rune_baseclass` b, `static_rune_racebaseclass` r WHERE b.`ID` = r.`BaseClassID` && r.`RaceID` = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, id);
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
baseClasses = getObjectsFromRs(rs, 20);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseClasses;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<BaseClass> GET_ALL_BASE_CLASSES() {
|
|
||||||
|
|
||||||
ArrayList<BaseClass> baseClasses = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_baseclass`;")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
baseClasses = getObjectsFromRs(rs, 20);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseClasses;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,9 +17,7 @@ import engine.mbEnums.DbObjectType;
|
|||||||
import engine.mbEnums.ProtectionState;
|
import engine.mbEnums.ProtectionState;
|
||||||
import engine.mbEnums.TaxType;
|
import engine.mbEnums.TaxType;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import java.time.Instant;
|
import org.joda.time.DateTime;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -30,6 +28,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class dbBuildingHandler extends dbHandlerBase {
|
public class dbBuildingHandler extends dbHandlerBase {
|
||||||
@@ -39,56 +38,55 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Building CREATE_BUILDING(int parentZoneID, int OwnerUUID, String name, int meshUUID,
|
public int PERSIST(Building building) {
|
||||||
Vector3fImmutable location, float meshScale, int currentHP,
|
|
||||||
ProtectionState protectionState, int currentGold, int rank,
|
|
||||||
Instant upgradeDate, int blueprintUUID, float w, float rotY) {
|
|
||||||
|
|
||||||
Building building = null;
|
int objectUUID = 0;
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(building))
|
||||||
|
return 0;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `building_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,? ,? ,?, ?);")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("CALL `building_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,? ,? ,?, ?);")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, parentZoneID);
|
preparedStatement.setInt(1, building.parentZoneUUID);
|
||||||
preparedStatement.setInt(2, OwnerUUID);
|
preparedStatement.setInt(2, building.getOwnerUUID());
|
||||||
preparedStatement.setString(3, name);
|
preparedStatement.setString(3, building.getName());
|
||||||
preparedStatement.setInt(4, meshUUID);
|
preparedStatement.setInt(4, building.meshUUID);
|
||||||
preparedStatement.setFloat(5, location.x);
|
preparedStatement.setFloat(5, building.statLat);
|
||||||
preparedStatement.setFloat(6, location.y);
|
preparedStatement.setFloat(6, building.statAlt);
|
||||||
preparedStatement.setFloat(7, location.z);
|
preparedStatement.setFloat(7, building.statLon);
|
||||||
preparedStatement.setFloat(8, meshScale);
|
preparedStatement.setFloat(8, building.getMeshScale().x);
|
||||||
preparedStatement.setInt(9, currentHP);
|
preparedStatement.setInt(9, (int) building.getHealth());
|
||||||
preparedStatement.setString(10, protectionState.name());
|
preparedStatement.setString(10, building.getProtectionState().name());
|
||||||
preparedStatement.setInt(11, currentGold);
|
preparedStatement.setInt(11, building.getStrongboxValue());
|
||||||
preparedStatement.setInt(12, rank);
|
preparedStatement.setInt(12, building.getRank());
|
||||||
|
|
||||||
if (upgradeDate != null)
|
if (building.upgradeDateTime != null)
|
||||||
preparedStatement.setTimestamp(13, new java.sql.Timestamp(upgradeDate.toEpochMilli()));
|
preparedStatement.setTimestamp(13, java.sql.Timestamp.valueOf(building.upgradeDateTime));
|
||||||
else
|
else
|
||||||
preparedStatement.setNull(13, java.sql.Types.DATE);
|
preparedStatement.setNull(13, java.sql.Types.DATE);
|
||||||
|
|
||||||
preparedStatement.setInt(14, blueprintUUID);
|
preparedStatement.setInt(14, building.getBlueprintUUID());
|
||||||
preparedStatement.setFloat(15, w);
|
preparedStatement.setFloat(15, building.getRotation().w);
|
||||||
preparedStatement.setFloat(16, rotY);
|
preparedStatement.setFloat(16, building.getRotation().y);
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
if (rs.next()) {
|
if (rs.next())
|
||||||
int objectUUID = (int) rs.getLong("UID");
|
objectUUID = (int) rs.getLong("UID");
|
||||||
|
|
||||||
if (objectUUID > 0)
|
|
||||||
building = GET_BUILDINGBYUUID(objectUUID);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return building;
|
return objectUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean DELETE_FROM_DATABASE(final Building b) {
|
public boolean DELETE_FROM_DATABASE(final Building b) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(b))
|
||||||
|
return false;
|
||||||
|
|
||||||
return removeFromBuildings(b);
|
return removeFromBuildings(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +107,26 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
return buildings;
|
return buildings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashSet<Integer> GET_NPC_BUILDING_OWNERS() {
|
||||||
|
|
||||||
|
HashSet<Integer> npcOwners = new HashSet<>();
|
||||||
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT DISTINCT `obj_building`.`ownerUUID` FROM `obj_building` INNER JOIN `object` ON `object`.`UID` = `obj_building`.`ownerUUID` WHERE `object`.`type` = 'npc';")) {
|
||||||
|
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next())
|
||||||
|
npcOwners.add(rs.getInt("ownerUUID"));
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.info("read: " + npcOwners.size() + " NPC building owners");
|
||||||
|
return npcOwners;
|
||||||
|
}
|
||||||
|
|
||||||
public Building GET_BUILDINGBYUUID(int uuid) {
|
public Building GET_BUILDINGBYUUID(int uuid) {
|
||||||
|
|
||||||
if (uuid == 0)
|
if (uuid == 0)
|
||||||
@@ -159,6 +177,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
String result = "";
|
String result = "";
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(b))
|
||||||
|
return result;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL building_SETPROP(?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("CALL building_SETPROP(?,?,?)")) {
|
||||||
|
|
||||||
@@ -182,6 +203,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
int rowCount;
|
int rowCount;
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingID))
|
||||||
|
return 0;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `object` INNER JOIN `obj_building` On `object`.`UID` = `obj_building`.`UID` SET `object`.`parent`=?, `obj_building`.`locationX`=?, `obj_building`.`locationY`=?, `obj_building`.`locationZ`=? WHERE `obj_building`.`UID`=?;")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `object` INNER JOIN `obj_building` On `object`.`UID` = `obj_building`.`UID` SET `object`.`parent`=?, `obj_building`.`locationX`=?, `obj_building`.`locationY`=?, `obj_building`.`locationZ`=? WHERE `obj_building`.`UID`=?;")) {
|
||||||
|
|
||||||
@@ -219,6 +243,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean CHANGE_NAME(Building b, String newName) {
|
public boolean CHANGE_NAME(Building b, String newName) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(b))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `name`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `name`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -235,6 +262,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean SET_RESERVE(Building b, int reserveAmount) {
|
public boolean SET_RESERVE(Building b, int reserveAmount) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(b))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `reserve`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `reserve`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -253,6 +283,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
//CAS update to rank
|
//CAS update to rank
|
||||||
public boolean CHANGE_RANK(final long buildingID, int newRank) {
|
public boolean CHANGE_RANK(final long buildingID, int newRank) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `rank`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `rank`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -269,6 +302,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_BUILDING_HEALTH(final long buildingID, int NewHealth) {
|
public boolean UPDATE_BUILDING_HEALTH(final long buildingID, int NewHealth) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `currentHP`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `currentHP`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -285,6 +321,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_BUILDING_ALTITUDE(final long buildingID, float newAltitude) {
|
public boolean UPDATE_BUILDING_ALTITUDE(final long buildingID, float newAltitude) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `locationY`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `locationY`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -301,6 +340,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_PROTECTIONSTATE(final long buildingUUID, ProtectionState protectionState) {
|
public boolean UPDATE_PROTECTIONSTATE(final long buildingUUID, ProtectionState protectionState) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingUUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `protectionState`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `protectionState`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -317,6 +359,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_DOOR_LOCK(final int buildingUUID, int doorFlags) {
|
public boolean UPDATE_DOOR_LOCK(final int buildingUUID, int doorFlags) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingUUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET doorState = ? WHERE UID = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET doorState = ? WHERE UID = ?")) {
|
||||||
|
|
||||||
@@ -333,6 +378,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean ADD_TO_FRIENDS_LIST(final long buildingID, final long friendID, final long guildID, final int friendType) {
|
public boolean ADD_TO_FRIENDS_LIST(final long buildingID, final long friendID, final long guildID, final int friendType) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_building_friends` (`buildingUID`, `playerUID`,`guildUID`, `friendType`) VALUES (?,?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_building_friends` (`buildingUID`, `playerUID`,`guildUID`, `friendType`) VALUES (?,?,?,?)")) {
|
||||||
|
|
||||||
@@ -351,6 +399,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean REMOVE_FROM_FRIENDS_LIST(final long buildingID, long friendID, long guildID, int friendType) {
|
public boolean REMOVE_FROM_FRIENDS_LIST(final long buildingID, long friendID, long guildID, int friendType) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_building_friends` WHERE `buildingUID`=? AND `playerUID`=? AND `guildUID` =? AND `friendType` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_building_friends` WHERE `buildingUID`=? AND `playerUID`=? AND `guildUID` =? AND `friendType` = ?")) {
|
||||||
|
|
||||||
@@ -369,6 +420,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean REMOVE_FROM_CONDEMNED_LIST(final long buildingID, long friendID, long guildID, int friendType) {
|
public boolean REMOVE_FROM_CONDEMNED_LIST(final long buildingID, long friendID, long guildID, int friendType) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_building_condemned` WHERE `buildingUID`=? AND `playerUID`=? AND `guildUID` =? AND `friendType` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_building_condemned` WHERE `buildingUID`=? AND `playerUID`=? AND `guildUID` =? AND `friendType` = ?")) {
|
||||||
|
|
||||||
@@ -387,6 +441,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public void CLEAR_FRIENDS_LIST(final long buildingID) {
|
public void CLEAR_FRIENDS_LIST(final long buildingID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingID))
|
||||||
|
return;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_building_friends` WHERE `buildingUID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_building_friends` WHERE `buildingUID`=?")) {
|
||||||
|
|
||||||
@@ -401,6 +458,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public void CLEAR_CONDEMNED_LIST(final long buildingID) {
|
public void CLEAR_CONDEMNED_LIST(final long buildingID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingID))
|
||||||
|
return;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_building_condemned` WHERE `buildingUID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_building_condemned` WHERE `buildingUID`=?")) {
|
||||||
|
|
||||||
@@ -415,6 +475,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean CLEAR_PATROL(final long buildingID) {
|
public boolean CLEAR_PATROL(final long buildingID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, buildingID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_building_patrol_points` WHERE `buildingUID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_building_patrol_points` WHERE `buildingUID`=?")) {
|
||||||
|
|
||||||
@@ -516,6 +579,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean ADD_TO_CONDEMNLIST(final long parentUID, final long playerUID, final long guildID, final int friendType) {
|
public boolean ADD_TO_CONDEMNLIST(final long parentUID, final long playerUID, final long guildID, final int friendType) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, parentUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_building_condemned` (`buildingUID`, `playerUID`,`guildUID`, `friendType`) VALUES (?,?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_building_condemned` (`buildingUID`, `playerUID`,`guildUID`, `friendType`) VALUES (?,?,?,?)")) {
|
||||||
|
|
||||||
@@ -534,6 +600,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean ADD_TO_PATROL(final long parentUID, final Vector3fImmutable patrolPoint) {
|
public boolean ADD_TO_PATROL(final long parentUID, final Vector3fImmutable patrolPoint) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, parentUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_building_patrol_points` (`buildingUID`, `patrolX`,`patrolY`, `patrolZ`) VALUES (?,?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_building_patrol_points` (`buildingUID`, `patrolX`,`patrolY`, `patrolZ`) VALUES (?,?,?,?)")) {
|
||||||
|
|
||||||
@@ -679,6 +748,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean updateBuildingRank(final Building b, int Rank) {
|
public boolean updateBuildingRank(final Building b, int Rank) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(b))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `rank`=?,"
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `rank`=?,"
|
||||||
+ "`upgradeDate`=?, `meshUUID`=?, `currentHP`=? "
|
+ "`upgradeDate`=?, `meshUUID`=?, `currentHP`=? "
|
||||||
@@ -700,6 +772,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean updateReverseKOS(final Building b, boolean reverse) {
|
public boolean updateReverseKOS(final Building b, boolean reverse) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(b))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `reverseKOS`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `reverseKOS`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
@@ -716,6 +791,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean updateActiveCondemn(final Condemned condemn, boolean active) {
|
public boolean updateActiveCondemn(final Condemned condemn, boolean active) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Building, condemn.buildingUUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_building_condemned` SET `active`=? "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_building_condemned` SET `active`=? "
|
||||||
+ "WHERE`buildingUID` = ? AND `playerUID` = ? AND `guildUID` = ? AND `friendType` = ?")) {
|
+ "WHERE`buildingUID` = ? AND `playerUID` = ? AND `guildUID` = ? AND `friendType` = ?")) {
|
||||||
@@ -736,6 +814,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean updateBuildingOwner(final Building building, int ownerUUID) {
|
public boolean updateBuildingOwner(final Building building, int ownerUUID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(building))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `ownerUUID`=? "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `ownerUUID`=? "
|
||||||
+ " WHERE `UID` = ?")) {
|
+ " WHERE `UID` = ?")) {
|
||||||
@@ -751,7 +832,10 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateBuildingUpgradeTime(Instant upgradeDateTime, Building toUpgrade, int costToUpgrade) {
|
public boolean updateBuildingUpgradeTime(LocalDateTime upgradeDateTime, Building toUpgrade, int costToUpgrade) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(toUpgrade))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET upgradeDate=?, currentGold=? "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET upgradeDate=?, currentGold=? "
|
||||||
@@ -760,7 +844,8 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
if (upgradeDateTime == null)
|
if (upgradeDateTime == null)
|
||||||
preparedStatement.setNull(1, java.sql.Types.DATE);
|
preparedStatement.setNull(1, java.sql.Types.DATE);
|
||||||
else
|
else
|
||||||
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.toEpochMilli()));
|
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.atZone(ZoneId.systemDefault())
|
||||||
|
.toInstant().toEpochMilli()));
|
||||||
|
|
||||||
preparedStatement.setInt(2, toUpgrade.getStrongboxValue() - costToUpgrade);
|
preparedStatement.setInt(2, toUpgrade.getStrongboxValue() - costToUpgrade);
|
||||||
preparedStatement.setInt(3, toUpgrade.getObjectUUID());
|
preparedStatement.setInt(3, toUpgrade.getObjectUUID());
|
||||||
@@ -775,6 +860,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean updateMaintDate(Building building) {
|
public boolean updateMaintDate(Building building) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(building))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET maintDate=? "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET maintDate=? "
|
||||||
+ "WHERE UID = ?")) {
|
+ "WHERE UID = ?")) {
|
||||||
@@ -796,6 +884,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean addTaxes(Building building, TaxType taxType, int amount, boolean enforceKOS) {
|
public boolean addTaxes(Building building, TaxType taxType, int amount, boolean enforceKOS) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(building))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET taxType=?, taxAmount = ?, enforceKOS = ? "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET taxType=?, taxAmount = ?, enforceKOS = ? "
|
||||||
+ "WHERE UID = ?")) {
|
+ "WHERE UID = ?")) {
|
||||||
@@ -815,6 +906,9 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean removeTaxes(Building building) {
|
public boolean removeTaxes(Building building) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(building))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET taxType=?, taxAmount = ?, enforceKOS = ?, taxDate = ? "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET taxType=?, taxAmount = ?, enforceKOS = ?, taxDate = ? "
|
||||||
+ "WHERE UID = ?")) {
|
+ "WHERE UID = ?")) {
|
||||||
@@ -835,11 +929,14 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean acceptTaxes(Building building) {
|
public boolean acceptTaxes(Building building) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(building))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET taxDate=? "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET taxDate=? "
|
||||||
+ "WHERE UID = ?")) {
|
+ "WHERE UID = ?")) {
|
||||||
|
|
||||||
preparedStatement.setTimestamp(1, new java.sql.Timestamp(Instant.now().plus(7, java.time.temporal.ChronoUnit.DAYS).toEpochMilli()));
|
preparedStatement.setTimestamp(1, new java.sql.Timestamp(DateTime.now().plusDays(7).getMillis()));
|
||||||
preparedStatement.setInt(2, building.getObjectUUID());
|
preparedStatement.setInt(2, building.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|||||||
@@ -139,6 +139,9 @@ public class dbCityHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean updateforceRename(City city, boolean value) {
|
public boolean updateforceRename(City city, boolean value) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(city))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `forceRename`=?"
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `forceRename`=?"
|
||||||
+ " WHERE `UID` = ?")) {
|
+ " WHERE `UID` = ?")) {
|
||||||
@@ -156,6 +159,9 @@ public class dbCityHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean updateOpenCity(City city, boolean value) {
|
public boolean updateOpenCity(City city, boolean value) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(city))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `open`=?"
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `open`=?"
|
||||||
+ " WHERE `UID` = ?")) {
|
+ " WHERE `UID` = ?")) {
|
||||||
@@ -173,6 +179,9 @@ public class dbCityHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean updateTOL(City city, int tolID) {
|
public boolean updateTOL(City city, int tolID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(city))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `treeOfLifeUUID`=?"
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `treeOfLifeUUID`=?"
|
||||||
+ " WHERE `UID` = ?")) {
|
+ " WHERE `UID` = ?")) {
|
||||||
@@ -191,6 +200,9 @@ public class dbCityHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean renameCity(City city, String name) {
|
public boolean renameCity(City city, String name) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(city))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `name`=?"
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `name`=?"
|
||||||
+ " WHERE `UID` = ?")) {
|
+ " WHERE `UID` = ?")) {
|
||||||
@@ -209,6 +221,9 @@ public class dbCityHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean updateSiegesWithstood(City city, int value) {
|
public boolean updateSiegesWithstood(City city, int value) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(city))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `name`=?"
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `name`=?"
|
||||||
+ " WHERE `UID` = ?")) {
|
+ " WHERE `UID` = ?")) {
|
||||||
@@ -227,6 +242,9 @@ public class dbCityHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean updateRealmTaxDate(City city, LocalDateTime localDateTime) {
|
public boolean updateRealmTaxDate(City city, LocalDateTime localDateTime) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(city))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `realmTaxDate` =?"
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_city` SET `realmTaxDate` =?"
|
||||||
+ " WHERE `UID` = ?")) {
|
+ " WHERE `UID` = ?")) {
|
||||||
|
|||||||
@@ -1,303 +0,0 @@
|
|||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
||||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
||||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
||||||
// Magicbane Emulator Project © 2013 - 2026
|
|
||||||
// https://www.magicbane.com
|
|
||||||
|
|
||||||
|
|
||||||
package engine.db.handlers;
|
|
||||||
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.gameManager.PowersManager;
|
|
||||||
import engine.mbEnums;
|
|
||||||
import engine.powers.EffectsBase;
|
|
||||||
import engine.powers.effectmodifiers.*;
|
|
||||||
import org.pmw.tinylog.Logger;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class dbEffectsBaseHandler extends dbHandlerBase {
|
|
||||||
|
|
||||||
public dbEffectsBaseHandler() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<EffectsBase> getAllEffectsBase() {
|
|
||||||
|
|
||||||
ArrayList<EffectsBase> effectList = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement prepareStatement = connection.prepareStatement("SELECT * FROM static_power_effectbase ORDER BY `IDString` DESC")) {
|
|
||||||
|
|
||||||
ResultSet rs = prepareStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
EffectsBase effectBase = new EffectsBase(rs);
|
|
||||||
effectList.add(effectBase);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return effectList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void cacheAllEffectModifiers() {
|
|
||||||
|
|
||||||
String IDString;
|
|
||||||
AbstractEffectModifier abstractEffectModifier = null;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement prepareStatement = connection.prepareStatement("SELECT * FROM static_power_effectmod")) {
|
|
||||||
|
|
||||||
ResultSet rs = prepareStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
|
|
||||||
IDString = rs.getString("IDString");
|
|
||||||
EffectsBase effectBase = PowersManager.getEffectByIDString(IDString);
|
|
||||||
mbEnums.ModType modifier = mbEnums.ModType.GetModType(rs.getString("modType"));
|
|
||||||
|
|
||||||
//combine item prefix and suffix effect modifiers
|
|
||||||
|
|
||||||
abstractEffectModifier = getCombinedModifiers(abstractEffectModifier, rs, effectBase, modifier);
|
|
||||||
|
|
||||||
if (abstractEffectModifier != null) {
|
|
||||||
|
|
||||||
if (EffectsBase.modifiersMap.containsKey(effectBase.getIDString()) == false)
|
|
||||||
EffectsBase.modifiersMap.put(effectBase.getIDString(), new HashSet<>());
|
|
||||||
|
|
||||||
EffectsBase.modifiersMap.get(effectBase.getIDString()).add(abstractEffectModifier);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AbstractEffectModifier getCombinedModifiers(AbstractEffectModifier abstractEffectModifier, ResultSet rs, EffectsBase effectBase, mbEnums.ModType modifier) throws SQLException {
|
|
||||||
switch (modifier) {
|
|
||||||
case AdjustAboveDmgCap:
|
|
||||||
abstractEffectModifier = new AdjustAboveDmgCapEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Ambidexterity:
|
|
||||||
abstractEffectModifier = new AmbidexterityEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case AnimOverride:
|
|
||||||
break;
|
|
||||||
case ArmorPiercing:
|
|
||||||
abstractEffectModifier = new ArmorPiercingEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case AttackDelay:
|
|
||||||
abstractEffectModifier = new AttackDelayEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Attr:
|
|
||||||
abstractEffectModifier = new AttributeEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case BlackMantle:
|
|
||||||
abstractEffectModifier = new BlackMantleEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case BladeTrails:
|
|
||||||
abstractEffectModifier = new BladeTrailsEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Block:
|
|
||||||
abstractEffectModifier = new BlockEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case BlockedPowerType:
|
|
||||||
abstractEffectModifier = new BlockedPowerTypeEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case CannotAttack:
|
|
||||||
abstractEffectModifier = new CannotAttackEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case CannotCast:
|
|
||||||
abstractEffectModifier = new CannotCastEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case CannotMove:
|
|
||||||
abstractEffectModifier = new CannotMoveEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case CannotTrack:
|
|
||||||
abstractEffectModifier = new CannotTrackEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Charmed:
|
|
||||||
abstractEffectModifier = new CharmedEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ConstrainedAmbidexterity:
|
|
||||||
abstractEffectModifier = new ConstrainedAmbidexterityEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case DamageCap:
|
|
||||||
abstractEffectModifier = new DamageCapEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case DamageShield:
|
|
||||||
abstractEffectModifier = new DamageShieldEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case DCV:
|
|
||||||
abstractEffectModifier = new DCVEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Dodge:
|
|
||||||
abstractEffectModifier = new DodgeEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case DR:
|
|
||||||
abstractEffectModifier = new DREffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Durability:
|
|
||||||
abstractEffectModifier = new DurabilityEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ExclusiveDamageCap:
|
|
||||||
abstractEffectModifier = new ExclusiveDamageCapEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Fade:
|
|
||||||
abstractEffectModifier = new FadeEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Fly:
|
|
||||||
abstractEffectModifier = new FlyEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Health:
|
|
||||||
abstractEffectModifier = new HealthEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case HealthFull:
|
|
||||||
abstractEffectModifier = new HealthFullEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case HealthRecoverRate:
|
|
||||||
abstractEffectModifier = new HealthRecoverRateEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case IgnoreDamageCap:
|
|
||||||
abstractEffectModifier = new IgnoreDamageCapEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case IgnorePassiveDefense:
|
|
||||||
abstractEffectModifier = new IgnorePassiveDefenseEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ImmuneTo:
|
|
||||||
abstractEffectModifier = new ImmuneToEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ImmuneToAttack:
|
|
||||||
abstractEffectModifier = new ImmuneToAttackEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ImmuneToPowers:
|
|
||||||
abstractEffectModifier = new ImmuneToPowersEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Invisible:
|
|
||||||
abstractEffectModifier = new InvisibleEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ItemName:
|
|
||||||
abstractEffectModifier = new ItemNameEffectModifier(rs);
|
|
||||||
if (((ItemNameEffectModifier) abstractEffectModifier).name.isEmpty())
|
|
||||||
break;
|
|
||||||
if (effectBase != null)
|
|
||||||
effectBase.setName((((ItemNameEffectModifier) abstractEffectModifier).name));
|
|
||||||
break;
|
|
||||||
case Mana:
|
|
||||||
abstractEffectModifier = new ManaEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ManaFull:
|
|
||||||
abstractEffectModifier = new ManaFullEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ManaRecoverRate:
|
|
||||||
abstractEffectModifier = new ManaRecoverRateEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case MaxDamage:
|
|
||||||
abstractEffectModifier = new MaxDamageEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case MeleeDamageModifier:
|
|
||||||
abstractEffectModifier = new MeleeDamageEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case MinDamage:
|
|
||||||
abstractEffectModifier = new MinDamageEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case NoMod:
|
|
||||||
abstractEffectModifier = new NoModEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case OCV:
|
|
||||||
abstractEffectModifier = new OCVEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Parry:
|
|
||||||
abstractEffectModifier = new ParryEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case PassiveDefense:
|
|
||||||
abstractEffectModifier = new PassiveDefenseEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case PowerCost:
|
|
||||||
abstractEffectModifier = new PowerCostEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case PowerCostHealth:
|
|
||||||
abstractEffectModifier = new PowerCostHealthEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case PowerDamageModifier:
|
|
||||||
abstractEffectModifier = new PowerDamageEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ProtectionFrom:
|
|
||||||
abstractEffectModifier = new ProtectionFromEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Resistance:
|
|
||||||
abstractEffectModifier = new ResistanceEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ScaleHeight:
|
|
||||||
abstractEffectModifier = new ScaleHeightEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ScaleWidth:
|
|
||||||
abstractEffectModifier = new ScaleWidthEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case ScanRange:
|
|
||||||
abstractEffectModifier = new ScanRangeEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case SeeInvisible:
|
|
||||||
abstractEffectModifier = new SeeInvisibleEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Silenced:
|
|
||||||
abstractEffectModifier = new SilencedEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Skill:
|
|
||||||
abstractEffectModifier = new SkillEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Slay:
|
|
||||||
abstractEffectModifier = new SlayEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Speed:
|
|
||||||
abstractEffectModifier = new SpeedEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case SpireBlock:
|
|
||||||
abstractEffectModifier = new SpireBlockEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Stamina:
|
|
||||||
abstractEffectModifier = new StaminaEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case StaminaFull:
|
|
||||||
abstractEffectModifier = new StaminaFullEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case StaminaRecoverRate:
|
|
||||||
abstractEffectModifier = new StaminaRecoverRateEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Stunned:
|
|
||||||
abstractEffectModifier = new StunnedEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case Value:
|
|
||||||
abstractEffectModifier = new ValueEffectModifier(rs);
|
|
||||||
if (effectBase != null) {
|
|
||||||
ValueEffectModifier valueEffect = (ValueEffectModifier) abstractEffectModifier;
|
|
||||||
effectBase.setValue(valueEffect.minMod);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WeaponProc:
|
|
||||||
abstractEffectModifier = new WeaponProcEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case WeaponRange:
|
|
||||||
abstractEffectModifier = new WeaponRangeEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
case WeaponSpeed:
|
|
||||||
abstractEffectModifier = new WeaponSpeedEffectModifier(rs);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
return abstractEffectModifier;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
||||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
||||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
||||||
// Magicbane Emulator Project © 2013 - 2026
|
|
||||||
// https://www.magicbane.com
|
|
||||||
|
|
||||||
|
|
||||||
package engine.db.handlers;
|
|
||||||
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.gameManager.PowersManager;
|
|
||||||
import engine.mbEnums;
|
|
||||||
import engine.objects.EffectsResourceCosts;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.pmw.tinylog.Logger;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class dbEffectsResourceCostHandler extends dbHandlerBase {
|
|
||||||
|
|
||||||
public dbEffectsResourceCostHandler() {
|
|
||||||
this.localClass = EffectsResourceCosts.class;
|
|
||||||
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LOAD_ALL_COSTMAPS() {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_effect_costmaps`")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
String effectID = rs.getString("effectID");
|
|
||||||
String costString = rs.getString("costmap");
|
|
||||||
JSONObject costJSON = new JSONObject(costString);
|
|
||||||
HashMap<mbEnums.ResourceType, Integer> costmap = new HashMap<>();
|
|
||||||
|
|
||||||
for (String key : costJSON.keySet()) {
|
|
||||||
int value = costJSON.getInt(key);
|
|
||||||
costmap.put(mbEnums.ResourceType.valueOf(key), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
PowersManager._effect_costMaps.put(effectID, costmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,7 @@ import engine.mbEnums;
|
|||||||
import engine.mbEnums.GuildHistoryType;
|
import engine.mbEnums.GuildHistoryType;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import engine.server.world.WorldServer;
|
import engine.server.world.WorldServer;
|
||||||
import java.time.Instant;
|
import org.joda.time.DateTime;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
@@ -95,6 +95,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean ADD_TO_BANISHED_FROM_GUILDLIST(int target, long characterID) {
|
public boolean ADD_TO_BANISHED_FROM_GUILDLIST(int target, long characterID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Guild, target))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guild_banishlist` (`GuildID`, `CharacterID`) VALUES (?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guild_banishlist` (`GuildID`, `CharacterID`) VALUES (?,?)")) {
|
||||||
|
|
||||||
@@ -111,6 +114,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean REMOVE_FROM_BANISH_LIST(int target, long characterID) {
|
public boolean REMOVE_FROM_BANISH_LIST(int target, long characterID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Guild, target))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guild_banishlist` (`GuildID`, `CharacterID`) VALUES (?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guild_banishlist` (`GuildID`, `CharacterID`) VALUES (?,?)")) {
|
||||||
|
|
||||||
@@ -125,7 +131,7 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ADD_TO_GUILDHISTORY(int target, PlayerCharacter playerCharacter, Instant historyDate, GuildHistoryType historyType) {
|
public boolean ADD_TO_GUILDHISTORY(int target, PlayerCharacter playerCharacter, DateTime historyDate, GuildHistoryType historyType) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_guildhistory` (`GuildID`, `CharacterID`, `historyDate`, `historyType`) VALUES (?,?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_guildhistory` (`GuildID`, `CharacterID`, `historyDate`, `historyType`) VALUES (?,?,?,?)")) {
|
||||||
@@ -136,7 +142,7 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
if (historyDate == null)
|
if (historyDate == null)
|
||||||
preparedStatement.setNull(3, java.sql.Types.DATE);
|
preparedStatement.setNull(3, java.sql.Types.DATE);
|
||||||
else
|
else
|
||||||
preparedStatement.setTimestamp(3, java.sql.Timestamp.from(historyDate));
|
preparedStatement.setTimestamp(3, new Timestamp(historyDate.getMillis()));
|
||||||
|
|
||||||
preparedStatement.setString(4, historyType.name());
|
preparedStatement.setString(4, historyType.name());
|
||||||
|
|
||||||
@@ -358,6 +364,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean SET_GUILD_OWNED_CITY(int guildID, int cityID) {
|
public boolean SET_GUILD_OWNED_CITY(int guildID, int cityID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Guild, guildID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_guild` SET `ownedCity`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_guild` SET `ownedCity`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -374,6 +383,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean SET_GUILD_LEADER(int objectUUID, int guildID) {
|
public boolean SET_GUILD_LEADER(int objectUUID, int guildID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Guild, guildID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_guild` SET `leaderUID`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_guild` SET `leaderUID`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -413,6 +425,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
Guild guild = null;
|
Guild guild = null;
|
||||||
GuildTag guildTag = g.getGuildTag();
|
GuildTag guildTag = g.getGuildTag();
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(g))
|
||||||
|
return null;
|
||||||
|
|
||||||
if (guildTag == null)
|
if (guildTag == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -465,6 +480,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_PARENT(int guildUID, int parentUID) {
|
public boolean UPDATE_PARENT(int guildUID, int parentUID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Guild, guildUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `object` SET `parent`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `object` SET `parent`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -483,6 +501,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
int row_count = 0;
|
int row_count = 0;
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(guild))
|
||||||
|
return 0;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `object` WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `object` WHERE `UID` = ?")) {
|
||||||
|
|
||||||
@@ -497,6 +518,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_MINETIME(int guildUID, int mineTime) {
|
public boolean UPDATE_MINETIME(int guildUID, int mineTime) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Guild, guildUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_guild` SET `mineTime`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_guild` SET `mineTime`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -564,6 +588,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean updateDatabase(final Guild g) {
|
public boolean updateDatabase(final Guild g) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(g))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_guild` SET `name`=?, `backgroundColor01`=?, `backgroundColor02`=?, `symbolColor`=?, `backgroundDesign`=?, `symbol`=?, `charter`=?, `motd`=?, `icMotd`=?, `nationMotd`=?, `leaderUID`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_guild` SET `name`=?, `backgroundColor01`=?, `backgroundColor02`=?, `symbolColor`=?, `backgroundDesign`=?, `symbol`=?, `charter`=?, `motd`=?, `icMotd`=?, `nationMotd`=?, `leaderUID`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -590,6 +617,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean ADD_TO_ALLIANCE_LIST(final long sourceGuildID, final long targetGuildID, boolean isRecommended, boolean isAlly, String recommender) {
|
public boolean ADD_TO_ALLIANCE_LIST(final long sourceGuildID, final long targetGuildID, boolean isRecommended, boolean isAlly, String recommender) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Guild, sourceGuildID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guild_allianceenemylist` (`GuildID`, `OtherGuildID`,`isRecommended`, `isAlliance`, `recommender`) VALUES (?,?,?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guild_allianceenemylist` (`GuildID`, `OtherGuildID`,`isRecommended`, `isAlliance`, `recommender`) VALUES (?,?,?,?,?)")) {
|
||||||
|
|
||||||
@@ -609,6 +639,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean REMOVE_FROM_ALLIANCE_LIST(final long sourceGuildID, long targetGuildID) {
|
public boolean REMOVE_FROM_ALLIANCE_LIST(final long sourceGuildID, long targetGuildID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Guild, sourceGuildID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guild_allianceenemylist` WHERE `GuildID`=? AND `OtherGuildID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guild_allianceenemylist` WHERE `GuildID`=? AND `OtherGuildID`=?")) {
|
||||||
|
|
||||||
@@ -625,6 +658,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_RECOMMENDED(final long sourceGuildID, long targetGuildID) {
|
public boolean UPDATE_RECOMMENDED(final long sourceGuildID, long targetGuildID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Guild, sourceGuildID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isRecommended` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isRecommended` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")) {
|
||||||
|
|
||||||
@@ -641,6 +677,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_ALLIANCE(final long sourceGuildID, long targetGuildID, boolean isAlly) {
|
public boolean UPDATE_ALLIANCE(final long sourceGuildID, long targetGuildID, boolean isAlly) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Guild, sourceGuildID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isAlliance` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isAlliance` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")) {
|
||||||
|
|
||||||
@@ -657,6 +696,9 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_ALLIANCE_AND_RECOMMENDED(final long sourceGuildID, long targetGuildID, boolean isAlly) {
|
public boolean UPDATE_ALLIANCE_AND_RECOMMENDED(final long sourceGuildID, long targetGuildID, boolean isAlly) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Guild, sourceGuildID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isRecommended` = ?, `isAlliance` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isRecommended` = ?, `isAlliance` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")) {
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ import engine.mbEnums.ItemType;
|
|||||||
import engine.objects.AbstractCharacter;
|
import engine.objects.AbstractCharacter;
|
||||||
import engine.objects.CharacterItemManager;
|
import engine.objects.CharacterItemManager;
|
||||||
import engine.objects.Item;
|
import engine.objects.Item;
|
||||||
import engine.objects.ItemTemplate;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -177,47 +175,23 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
return itemList;
|
return itemList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LOAD_ITEM_TEMPLATES() {
|
public HashMap<Integer, Integer> LOAD_TEMPLATE_MODTABLES() {
|
||||||
|
|
||||||
HashMap<ItemType, Integer> templateTCountMap = new HashMap<>();
|
HashMap<Integer, Integer> modTables = new HashMap<>();
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_templates`;");
|
|
||||||
ResultSet rs = preparedStatement.executeQuery()) {
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
int templateID = rs.getInt("id");
|
|
||||||
JSONObject jsonObject = new JSONObject(rs.getString("template"));
|
|
||||||
ItemTemplate itemTemplate = new ItemTemplate(jsonObject);
|
|
||||||
itemTemplate.template_id = templateID;
|
|
||||||
ItemTemplate.templates.put(templateID, itemTemplate);
|
|
||||||
|
|
||||||
templateTCountMap.merge(itemTemplate.item_type, 1, Integer::sum);
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.info(templateTCountMap.toString());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LOAD_TEMPLATE_MODTABLES() {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_vendor_items`;");
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_vendor_items`;");
|
||||||
ResultSet rs = preparedStatement.executeQuery()) {
|
ResultSet rs = preparedStatement.executeQuery()) {
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next())
|
||||||
int templateID = rs.getInt("templateID");
|
modTables.put(rs.getInt("templateID"), rs.getInt("modTable"));
|
||||||
int modTable = rs.getInt("modTable");
|
|
||||||
ItemTemplate template = ItemTemplate.templates.get(templateID);
|
|
||||||
template.modTable = modTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.info("read: " + modTables.size());
|
||||||
|
return modTables;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item GET_ITEM(final int itemUUID) {
|
public Item GET_ITEM(final int itemUUID) {
|
||||||
@@ -325,7 +299,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
for (Item item : inventory) {
|
for (Item item : inventory) {
|
||||||
|
|
||||||
if (item.template.item_type.equals(ItemType.GOLD))
|
if (item.template.getItemType().equals(ItemType.GOLD))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
@@ -474,7 +448,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
*/
|
*/
|
||||||
public boolean UPDATE_GOLD(final Item item, int newValue, int oldValue) {
|
public boolean UPDATE_GOLD(final Item item, int newValue, int oldValue) {
|
||||||
|
|
||||||
if (!item.template.item_type.equals(ItemType.GOLD))
|
if (!item.template.getItemType().equals(ItemType.GOLD))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
@@ -554,7 +528,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
// Write 0 if we will not modify the value from template
|
// Write 0 if we will not modify the value from template
|
||||||
|
|
||||||
if (value == item.template.item_value)
|
if (value == item.template.getItemValue())
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
||||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
||||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
||||||
// Magicbane Emulator Project © 2013 - 2026
|
|
||||||
// https://www.magicbane.com
|
|
||||||
|
|
||||||
|
|
||||||
package engine.db.handlers;
|
|
||||||
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.mbEnums;
|
|
||||||
import engine.objects.Kit;
|
|
||||||
import org.pmw.tinylog.Logger;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class dbKitHandler extends dbHandlerBase {
|
|
||||||
|
|
||||||
public dbKitHandler() {
|
|
||||||
this.localClass = Kit.class;
|
|
||||||
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Kit> GET_ALL_KITS() {
|
|
||||||
|
|
||||||
ArrayList<Kit> kitList = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_validkit`")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
kitList = getObjectsFromRs(rs, 20);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return kitList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,6 @@ package engine.db.handlers;
|
|||||||
|
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.loot.*;
|
import engine.loot.*;
|
||||||
import engine.objects.Item;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -221,20 +220,4 @@ public class dbLootHandler extends dbHandlerBase {
|
|||||||
return bootySets;
|
return bootySets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LOAD_ENCHANT_VALUES() {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `IDString`, `minMod` FROM `static_power_effectmod` WHERE `modType` = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setString(1, "Value");
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next())
|
|
||||||
Item.addEnchantValue(rs.getString("IDString"), rs.getInt("minMod"));
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,8 +13,6 @@ import engine.gameManager.DbManager;
|
|||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.mbEnums.GameObjectType;
|
import engine.mbEnums.GameObjectType;
|
||||||
import engine.objects.MobBase;
|
import engine.objects.MobBase;
|
||||||
import engine.objects.MobBaseEffects;
|
|
||||||
import engine.objects.MobBaseStats;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -69,71 +67,10 @@ public class dbMobBaseHandler extends dbHandlerBase {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.info("Loaded " + mobbaseList.size() + " mobbases");
|
||||||
|
|
||||||
return mobbaseList;
|
return mobbaseList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<MobBaseEffects> GET_RUNEBASE_EFFECTS(int runeID) {
|
|
||||||
|
|
||||||
ArrayList<MobBaseEffects> effectsList = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase_effects` WHERE `mobbaseUUID` = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, runeID);
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
MobBaseEffects mbs = new MobBaseEffects(rs);
|
|
||||||
effectsList.add(mbs);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return effectsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobBaseStats LOAD_STATS(int mobBaseUUID) {
|
|
||||||
|
|
||||||
MobBaseStats mobBaseStats = MobBaseStats.GetGenericStats();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase_stats` WHERE `mobbaseUUID` = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, mobBaseUUID);
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next())
|
|
||||||
mobBaseStats = new MobBaseStats(rs);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
return mobBaseStats;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LOAD_ALL_MOBBASE_SPEEDS(MobBase mobBase) {
|
|
||||||
|
|
||||||
if (mobBase.getLoadID() == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase_race` WHERE `mobbaseID` = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, mobBase.getLoadID());
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
float walk = rs.getFloat("walkStandard");
|
|
||||||
float walkCombat = rs.getFloat("walkCombat");
|
|
||||||
float run = rs.getFloat("runStandard");
|
|
||||||
float runCombat = rs.getFloat("runCombat");
|
|
||||||
mobBase.updateSpeeds(walk, walkCombat, run, runCombat);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -12,8 +12,7 @@ package engine.db.handlers;
|
|||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.objects.Mob;
|
import engine.objects.Mob;
|
||||||
import java.time.LocalDateTime;
|
import org.joda.time.DateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -33,6 +32,9 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
Mob mobile = null;
|
Mob mobile = null;
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(toAdd))
|
||||||
|
return null;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
|
||||||
|
|
||||||
@@ -83,7 +85,10 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
return mobileList;
|
return mobileList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateUpgradeTime(Mob mob, LocalDateTime upgradeDateTime) {
|
public boolean updateUpgradeTime(Mob mob, DateTime upgradeDateTime) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mob))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_mob SET upgradeDate=? "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_mob SET upgradeDate=? "
|
||||||
@@ -92,7 +97,7 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
if (upgradeDateTime == null)
|
if (upgradeDateTime == null)
|
||||||
preparedStatement.setNull(1, java.sql.Types.DATE);
|
preparedStatement.setNull(1, java.sql.Types.DATE);
|
||||||
else
|
else
|
||||||
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
|
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.getMillis()));
|
||||||
|
|
||||||
preparedStatement.setInt(2, mob.getObjectUUID());
|
preparedStatement.setInt(2, mob.getObjectUUID());
|
||||||
|
|
||||||
@@ -107,6 +112,10 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
public int DELETE_MOB(final Mob mob) {
|
public int DELETE_MOB(final Mob mob) {
|
||||||
|
|
||||||
int row_count = 0;
|
int row_count = 0;
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mob))
|
||||||
|
return 0;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `object` WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `object` WHERE `UID` = ?")) {
|
||||||
|
|
||||||
@@ -147,6 +156,9 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean ADD_GUARD_MINION(final long captainUID, final String minionName) {
|
public boolean ADD_GUARD_MINION(final long captainUID, final String minionName) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Mob, captainUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guards` (`captainUID`, `minionName`) VALUES (?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guards` (`captainUID`, `minionName`) VALUES (?,?)")) {
|
||||||
|
|
||||||
@@ -163,6 +175,9 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean REMOVE_GUARD_MINION(final long captainUID, final String minionName) {
|
public boolean REMOVE_GUARD_MINION(final long captainUID, final String minionName) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Mob, captainUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=? AND `minionName`=? LIMIT 1;")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=? AND `minionName`=? LIMIT 1;")) {
|
||||||
|
|
||||||
@@ -179,6 +194,9 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean REMOVE_ALL_MINIONS(final long captainUID) {
|
public boolean REMOVE_ALL_MINIONS(final long captainUID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Mob, captainUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=?;")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=?;")) {
|
||||||
|
|
||||||
@@ -213,6 +231,9 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
int row_count = 0;
|
int row_count = 0;
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Mob, mobID))
|
||||||
|
return 0;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `object` INNER JOIN `obj_mob` On `object`.`UID` = `obj_mob`.`UID` SET `object`.`parent`=?, `obj_mob`.`mob_spawnX`=?, `obj_mob`.`mob_spawnY`=?, `obj_mob`.`mob_spawnZ`=? WHERE `obj_mob`.`UID`=?;")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `object` INNER JOIN `obj_mob` On `object`.`UID` = `obj_mob`.`UID` SET `object`.`parent`=?, `obj_mob`.`mob_spawnX`=?, `obj_mob`.`mob_spawnY`=?, `obj_mob`.`mob_spawnZ`=? WHERE `obj_mob`.`UID`=?;")) {
|
||||||
|
|
||||||
@@ -235,6 +256,9 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
String result = "";
|
String result = "";
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(m))
|
||||||
|
return result;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL mob_SETPROP(?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("CALL mob_SETPROP(?,?,?)")) {
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ import engine.mbEnums;
|
|||||||
import engine.mbEnums.ProfitType;
|
import engine.mbEnums.ProfitType;
|
||||||
import engine.objects.NPC;
|
import engine.objects.NPC;
|
||||||
import engine.objects.NPCProfits;
|
import engine.objects.NPCProfits;
|
||||||
import java.time.LocalDateTime;
|
import org.joda.time.DateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -58,7 +57,7 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
runeSets.put(runeSetID, runeList);
|
runeSets.put(runeSetID, runeList);
|
||||||
} else {
|
} else {
|
||||||
ArrayList<Integer> runeList = runeSets.get(runeSetID);
|
ArrayList<Integer> runeList = runeSets.get(runeSetID);
|
||||||
runeList.add(runeSetID);
|
runeList.add(runeBaseID);
|
||||||
runeSets.put(runeSetID, runeList);
|
runeSets.put(runeSetID, runeList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,6 +75,9 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
NPC npc = null;
|
NPC npc = null;
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(toAdd))
|
||||||
|
return null;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `npc_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("CALL `npc_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
|
||||||
|
|
||||||
@@ -121,6 +123,9 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
npc.removeFromZone();
|
npc.removeFromZone();
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(npc))
|
||||||
|
return 0;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `object` WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `object` WHERE `UID` = ?")) {
|
||||||
|
|
||||||
@@ -173,6 +178,9 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
int rowCount;
|
int rowCount;
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.NPC, npcID))
|
||||||
|
return 0;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `object` INNER JOIN `obj_npc` On `object`.`UID` = `obj_npc`.`UID` SET `object`.`parent`=?, `obj_npc`.`npc_spawnX`=?, `obj_npc`.`npc_spawnY`=?, `obj_npc`.`npc_spawnZ`=? WHERE `obj_npc`.`UID`=?;")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `object` INNER JOIN `obj_npc` On `object`.`UID` = `obj_npc`.`UID` SET `object`.`parent`=?, `obj_npc`.`npc_spawnX`=?, `obj_npc`.`npc_spawnY`=?, `obj_npc`.`npc_spawnZ`=? WHERE `obj_npc`.`UID`=?;")) {
|
||||||
|
|
||||||
@@ -196,6 +204,9 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
String result = "";
|
String result = "";
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(n))
|
||||||
|
return result;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL npc_SETPROP(?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("CALL npc_SETPROP(?,?,?)")) {
|
||||||
|
|
||||||
@@ -216,6 +227,9 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public void updateDatabase(final NPC npc) {
|
public void updateDatabase(final NPC npc) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(npc))
|
||||||
|
return;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET npc_name=?, npc_contractID=?, npc_typeID=?, npc_guildID=?,"
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET npc_name=?, npc_contractID=?, npc_typeID=?, npc_guildID=?,"
|
||||||
+ " npc_spawnX=?, npc_spawnY=?, npc_spawnZ=?, npc_level=? ,"
|
+ " npc_spawnX=?, npc_spawnY=?, npc_spawnZ=?, npc_level=? ,"
|
||||||
@@ -241,7 +255,10 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateUpgradeTime(NPC npc, LocalDateTime upgradeDateTime) {
|
public boolean updateUpgradeTime(NPC npc, DateTime upgradeDateTime) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(npc))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET upgradeDate=? "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET upgradeDate=? "
|
||||||
@@ -250,7 +267,7 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
if (upgradeDateTime == null)
|
if (upgradeDateTime == null)
|
||||||
preparedStatement.setNull(1, java.sql.Types.DATE);
|
preparedStatement.setNull(1, java.sql.Types.DATE);
|
||||||
else
|
else
|
||||||
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
|
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.getMillis()));
|
||||||
|
|
||||||
preparedStatement.setInt(2, npc.getObjectUUID());
|
preparedStatement.setInt(2, npc.getObjectUUID());
|
||||||
|
|
||||||
@@ -265,6 +282,9 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_MOBBASE(NPC npc, int mobBaseID) {
|
public boolean UPDATE_MOBBASE(NPC npc, int mobBaseID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(npc))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `npc_raceID`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `npc_raceID`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -281,6 +301,9 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_EQUIPSET(NPC npc, int equipSetID) {
|
public boolean UPDATE_EQUIPSET(NPC npc, int equipSetID) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(npc))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipsetID`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipsetID`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -297,6 +320,9 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_NAME(NPC npc, String name) {
|
public boolean UPDATE_NAME(NPC npc, String name) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(npc))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `npc_name`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `npc_name`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -313,6 +339,9 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_RACE(NPC npc, int value) {
|
public boolean UPDATE_RACE(NPC npc, int value) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(npc))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `npc_raceID`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `npc_raceID`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
@@ -364,6 +393,9 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_PROFITS(NPC npc, ProfitType profitType, float value) {
|
public boolean UPDATE_PROFITS(NPC npc, ProfitType profitType, float value) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(npc))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_npc_profits` SET `" + profitType.dbField + "` = ? WHERE `npcUID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_npc_profits` SET `" + profitType.dbField + "` = ? WHERE `npcUID`=?")) {
|
||||||
|
|
||||||
@@ -399,6 +431,9 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean CREATE_PROFITS(NPC npc) {
|
public boolean CREATE_PROFITS(NPC npc) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(npc))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_npc_profits` (`npcUID`) VALUES (?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_npc_profits` (`npcUID`) VALUES (?)")) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
||||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
||||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
||||||
// Magicbane Emulator Project © 2013 - 2026
|
|
||||||
// https://www.magicbane.com
|
|
||||||
|
|
||||||
|
|
||||||
package engine.db.handlers;
|
|
||||||
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.gameManager.PowersManager;
|
|
||||||
import engine.mbEnums;
|
|
||||||
import engine.objects.Mob;
|
|
||||||
import engine.powers.EffectsBase;
|
|
||||||
import org.pmw.tinylog.Logger;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class dbPowerHandler extends dbHandlerBase {
|
|
||||||
|
|
||||||
public dbPowerHandler() {
|
|
||||||
this.localClass = Mob.class;
|
|
||||||
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addAllSourceTypes() {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_sourcetype")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
String IDString, source;
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
IDString = rs.getString("IDString");
|
|
||||||
int token = DbManager.hasher.SBStringHash(IDString);
|
|
||||||
|
|
||||||
source = rs.getString("source").replace("-", "").trim();
|
|
||||||
mbEnums.EffectSourceType effectSourceType = mbEnums.EffectSourceType.GetEffectSourceType(source);
|
|
||||||
|
|
||||||
if (EffectsBase.effectSourceTypeMap.containsKey(token) == false)
|
|
||||||
EffectsBase.effectSourceTypeMap.put(token, new HashSet<>());
|
|
||||||
|
|
||||||
EffectsBase.effectSourceTypeMap.get(token).add(effectSourceType);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addAllAnimationOverrides() {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_animation_override")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
String IDString;
|
|
||||||
int animation;
|
|
||||||
while (rs.next()) {
|
|
||||||
IDString = rs.getString("IDString");
|
|
||||||
|
|
||||||
EffectsBase eb = PowersManager.getEffectByIDString(IDString);
|
|
||||||
if (eb != null)
|
|
||||||
IDString = eb.getIDString();
|
|
||||||
|
|
||||||
animation = rs.getInt("animation");
|
|
||||||
PowersManager.AnimationOverrides.put(IDString, animation);
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -27,30 +27,17 @@ public class dbPromotionClassHandler extends dbHandlerBase {
|
|||||||
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Integer> GET_ALLOWED_RUNES(final PromotionClass pc) {
|
|
||||||
|
|
||||||
ArrayList<Integer> runeList = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_promotionrunereq` WHERE `promoID`=?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, pc.getObjectUUID());
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next())
|
|
||||||
runeList.add(rs.getInt("runereqID"));
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
|
|
||||||
}
|
|
||||||
return runeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PromotionClass GET_PROMOTION_CLASS(final int objectUUID) {
|
public PromotionClass GET_PROMOTION_CLASS(final int objectUUID) {
|
||||||
|
|
||||||
PromotionClass promotionClass = null;
|
PromotionClass promotionClass;
|
||||||
|
|
||||||
|
if (objectUUID == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
promotionClass = (PromotionClass) DbManager.getFromCache(mbEnums.GameObjectType.PromotionClass, objectUUID);
|
||||||
|
|
||||||
|
if (promotionClass != null)
|
||||||
|
return promotionClass;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_promotion` WHERE `ID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_promotion` WHERE `ID` = ?")) {
|
||||||
|
|||||||
@@ -10,15 +10,14 @@
|
|||||||
package engine.db.handlers;
|
package engine.db.handlers;
|
||||||
|
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.objects.Race;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
public class dbRaceHandler extends dbHandlerBase {
|
public class dbRaceHandler extends dbHandlerBase {
|
||||||
|
|
||||||
@@ -46,27 +45,6 @@ public class dbRaceHandler extends dbHandlerBase {
|
|||||||
return integerSet;
|
return integerSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<Integer> BEARD_STYLES_FOR_RACE(final int id) {
|
|
||||||
|
|
||||||
HashSet<Integer> integerSet = new HashSet<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `beardStyle` FROM `static_rune_racebeardstyle` WHERE `RaceID` = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, id);
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next())
|
|
||||||
integerSet.add(rs.getInt(1));
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return integerSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashSet<Integer> HAIR_COLORS_FOR_RACE(final int id) {
|
public HashSet<Integer> HAIR_COLORS_FOR_RACE(final int id) {
|
||||||
|
|
||||||
HashSet<Integer> integerSet = new HashSet<>();
|
HashSet<Integer> integerSet = new HashSet<>();
|
||||||
@@ -89,28 +67,6 @@ public class dbRaceHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<Integer> HAIR_STYLES_FOR_RACE(final int id) {
|
|
||||||
|
|
||||||
HashSet<Integer> integerSet = new HashSet<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `hairStyle` FROM `static_rune_racehairstyle` WHERE `RaceID` = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, id);
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next())
|
|
||||||
integerSet.add(rs.getInt(1));
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return integerSet;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashSet<Integer> SKIN_COLOR_FOR_RACE(final int id) {
|
public HashSet<Integer> SKIN_COLOR_FOR_RACE(final int id) {
|
||||||
|
|
||||||
HashSet<Integer> integerSet = new HashSet<>();
|
HashSet<Integer> integerSet = new HashSet<>();
|
||||||
@@ -132,32 +88,23 @@ public class dbRaceHandler extends dbHandlerBase {
|
|||||||
return integerSet;
|
return integerSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentHashMap<Integer, Race> LOAD_ALL_RACES() {
|
// Rune id -> {minHeight, strHeightMod}; the rows also decide which race runes are player races
|
||||||
|
public HashMap<Integer, float[]> LOAD_RACE_HEIGHTS() {
|
||||||
|
|
||||||
ConcurrentHashMap<Integer, Race> races;
|
HashMap<Integer, float[]> raceHeights = new HashMap<>();
|
||||||
Race thisRace;
|
|
||||||
|
|
||||||
races = new ConcurrentHashMap<>();
|
|
||||||
int recordsRead = 0;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_race")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_race")) {
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next())
|
||||||
|
raceHeights.put(rs.getInt("ID"), new float[]{rs.getFloat("minHeight"), rs.getFloat("strHeightMod")});
|
||||||
recordsRead++;
|
|
||||||
thisRace = new Race(rs);
|
|
||||||
|
|
||||||
races.put(thisRace.getRaceRuneID(), thisRace);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.info("read: " + recordsRead + " cached: " + races.size());
|
return raceHeights;
|
||||||
return races;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
||||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
||||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
||||||
// Magicbane Emulator Project © 2013 - 2026
|
|
||||||
// https://www.magicbane.com
|
|
||||||
|
|
||||||
|
|
||||||
package engine.db.handlers;
|
|
||||||
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.mbEnums;
|
|
||||||
import engine.objects.RuneBaseAttribute;
|
|
||||||
import org.pmw.tinylog.Logger;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class dbRuneBaseAttributeHandler extends dbHandlerBase {
|
|
||||||
|
|
||||||
public dbRuneBaseAttributeHandler() {
|
|
||||||
this.localClass = RuneBaseAttribute.class;
|
|
||||||
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<RuneBaseAttribute> GET_ATTRIBUTES_FOR_RUNEBASE() {
|
|
||||||
|
|
||||||
ArrayList<RuneBaseAttribute> runeBaseAttributesList = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_runebaseattribute`")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
runeBaseAttributesList = getObjectsFromRs(rs, 10);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return runeBaseAttributesList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
||||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
||||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
||||||
// Magicbane Emulator Project © 2013 - 2026
|
|
||||||
// https://www.magicbane.com
|
|
||||||
|
|
||||||
|
|
||||||
package engine.db.handlers;
|
|
||||||
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.mbEnums;
|
|
||||||
import engine.mbEnums.GameObjectType;
|
|
||||||
import engine.objects.AbstractGameObject;
|
|
||||||
import engine.objects.RuneBaseEffect;
|
|
||||||
import org.pmw.tinylog.Logger;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class dbRuneBaseEffectHandler extends dbHandlerBase {
|
|
||||||
|
|
||||||
public dbRuneBaseEffectHandler() {
|
|
||||||
this.localClass = RuneBaseEffect.class;
|
|
||||||
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<RuneBaseEffect> GET_EFFECTS_FOR_RUNEBASE(int id) {
|
|
||||||
|
|
||||||
ArrayList<RuneBaseEffect> runeBaseEffectsList = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_baseeffect` WHERE `runeID`=?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, id);
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
runeBaseEffectsList = getObjectsFromRs(rs, 250);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return runeBaseEffectsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<RuneBaseEffect> GET_ALL_RUNEBASE_EFFECTS() {
|
|
||||||
|
|
||||||
ArrayList<RuneBaseEffect> runeBaseEffectsList = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_baseeffect`;")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
runeBaseEffectsList = getObjectsFromRs(rs, 250);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return runeBaseEffectsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
//This calls from cache only. Call this AFTER caching all runebase effects;
|
|
||||||
|
|
||||||
public HashMap<Integer, ArrayList<RuneBaseEffect>> LOAD_BASEEFFECTS_FOR_RUNEBASE() {
|
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<RuneBaseEffect>> runeBaseEffectSet;
|
|
||||||
runeBaseEffectSet = new HashMap<>();
|
|
||||||
|
|
||||||
for (AbstractGameObject runeBaseEffect : DbManager.getList(GameObjectType.RuneBaseEffect)) {
|
|
||||||
|
|
||||||
int runeBaseID = ((RuneBaseEffect) runeBaseEffect).getRuneBaseID();
|
|
||||||
if (runeBaseEffectSet.get(runeBaseID) == null) {
|
|
||||||
ArrayList<RuneBaseEffect> runeBaseEffectList = new ArrayList<>();
|
|
||||||
runeBaseEffectList.add((RuneBaseEffect) runeBaseEffect);
|
|
||||||
runeBaseEffectSet.put(runeBaseID, runeBaseEffectList);
|
|
||||||
} else {
|
|
||||||
ArrayList<RuneBaseEffect> runeBaseEffectList = runeBaseEffectSet.get(runeBaseID);
|
|
||||||
runeBaseEffectList.add((RuneBaseEffect) runeBaseEffect);
|
|
||||||
runeBaseEffectSet.put(runeBaseID, runeBaseEffectList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return runeBaseEffectSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -11,17 +11,16 @@ package engine.db.handlers;
|
|||||||
|
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
|
import engine.objects.AbstractGameObject;
|
||||||
|
import engine.objects.BaseClass;
|
||||||
|
import engine.objects.PromotionClass;
|
||||||
|
import engine.objects.Race;
|
||||||
import engine.objects.RuneBase;
|
import engine.objects.RuneBase;
|
||||||
import engine.powers.RunePowerEntry;
|
|
||||||
import engine.powers.RuneSkillAdjustEntry;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class dbRuneBaseHandler extends dbHandlerBase {
|
public class dbRuneBaseHandler extends dbHandlerBase {
|
||||||
|
|
||||||
@@ -30,231 +29,57 @@ public class dbRuneBaseHandler extends dbHandlerBase {
|
|||||||
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<Integer, ArrayList<RunePowerEntry>> LOAD_RUNE_POWERS() {
|
// static_rune_lookup is generated for the DB views; a failed write must never stop the boot
|
||||||
|
public static void WRITE_RUNE_LOOKUP() {
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<RunePowerEntry>> mobPowers = new HashMap<>();
|
int rowsWritten = 0;
|
||||||
RunePowerEntry runePowerEntry;
|
|
||||||
|
|
||||||
int rune_id;
|
|
||||||
int recordsRead = 0;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_powers")) {
|
PreparedStatement deleteStatement = connection.prepareStatement("DELETE FROM `static_rune_lookup`");
|
||||||
|
PreparedStatement insertStatement = connection.prepareStatement("INSERT INTO `static_rune_lookup` (`ID`, `type`, `name`) VALUES (?, ?, ?)")) {
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
connection.setAutoCommit(false);
|
||||||
|
|
||||||
while (rs.next()) {
|
try {
|
||||||
|
deleteStatement.executeUpdate();
|
||||||
|
|
||||||
recordsRead++;
|
for (Race race : Race.getAllRaces()) {
|
||||||
|
addRuneLookupRow(insertStatement, race.getRaceRuneID(), "RACE", race.getName());
|
||||||
rune_id = rs.getInt("rune_id");
|
rowsWritten++;
|
||||||
runePowerEntry = new RunePowerEntry(rs);
|
|
||||||
|
|
||||||
if (mobPowers.get(rune_id) == null) {
|
|
||||||
ArrayList<RunePowerEntry> runePowerList = new ArrayList<>();
|
|
||||||
runePowerList.add(runePowerEntry);
|
|
||||||
mobPowers.put(rune_id, runePowerList);
|
|
||||||
} else {
|
|
||||||
ArrayList<RunePowerEntry> powerList = mobPowers.get(rune_id);
|
|
||||||
powerList.add(runePowerEntry);
|
|
||||||
mobPowers.put(rune_id, powerList);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
return mobPowers;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.info("read: " + recordsRead + " cached: " + mobPowers.size());
|
for (AbstractGameObject baseClass : DbManager.getMap(mbEnums.GameObjectType.BaseClass).values()) {
|
||||||
return mobPowers;
|
addRuneLookupRow(insertStatement, baseClass.getObjectUUID(), "BASECLASS", ((BaseClass) baseClass).getName());
|
||||||
}
|
rowsWritten++;
|
||||||
|
|
||||||
public static HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> LOAD_RUNE_SKILL_ADJUSTS() {
|
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> runeSkillAdjusts = new HashMap<>();
|
|
||||||
RuneSkillAdjustEntry runeSkillAdjustEntry;
|
|
||||||
|
|
||||||
int rune_id;
|
|
||||||
int recordsRead = 0;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_skill_adjusts")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
|
|
||||||
recordsRead++;
|
|
||||||
|
|
||||||
rune_id = rs.getInt("rune_id");
|
|
||||||
runeSkillAdjustEntry = new RuneSkillAdjustEntry(rs);
|
|
||||||
|
|
||||||
if (runeSkillAdjusts.get(rune_id) == null) {
|
|
||||||
ArrayList<RuneSkillAdjustEntry> skillAdjustList = new ArrayList<>();
|
|
||||||
skillAdjustList.add(runeSkillAdjustEntry);
|
|
||||||
runeSkillAdjusts.put(rune_id, skillAdjustList);
|
|
||||||
} else {
|
|
||||||
ArrayList<RuneSkillAdjustEntry> powerList = runeSkillAdjusts.get(rune_id);
|
|
||||||
powerList.add(runeSkillAdjustEntry);
|
|
||||||
runeSkillAdjusts.put(rune_id, powerList);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
return runeSkillAdjusts;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.info("read: " + recordsRead + " cached: " + runeSkillAdjusts.size());
|
for (AbstractGameObject promotionClass : DbManager.getMap(mbEnums.GameObjectType.PromotionClass).values()) {
|
||||||
return runeSkillAdjusts;
|
addRuneLookupRow(insertStatement, promotionClass.getObjectUUID(), "PROMOTION", ((PromotionClass) promotionClass).getName());
|
||||||
}
|
rowsWritten++;
|
||||||
|
|
||||||
public void GET_RUNE_REQS(final RuneBase rb) {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_runereq` WHERE `runeID` = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, rb.getObjectUUID());
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
int type = rs.getInt("type");
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case 1:
|
|
||||||
rb.getRace().put(rs.getInt("requiredRuneID"), rs.getBoolean("isAllowed"));
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
rb.getBaseClass().put(rs.getInt("requiredRuneID"), rs.getBoolean("isAllowed"));
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
rb.getPromotionClass().put(rs.getInt("requiredRuneID"), rs.getBoolean("isAllowed"));
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
rb.getDiscipline().put(rs.getInt("requiredRuneID"), rs.getBoolean("isAllowed"));
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
rb.getOverwrite().add(rs.getInt("requiredRuneID"));
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
rb.setLevelRequired(rs.getInt("requiredRuneID"));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
insertStatement.executeBatch();
|
||||||
|
connection.commit();
|
||||||
|
} catch (SQLException | RuntimeException e) {
|
||||||
|
// Roll back before setAutoCommit(true), which would otherwise commit the delete
|
||||||
|
connection.rollback();
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
connection.setAutoCommit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.warn("static_rune_lookup not written; DB views keep their old names: " + e.getMessage());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.info("static_rune_lookup: wrote " + rowsWritten + " rows");
|
||||||
}
|
}
|
||||||
|
|
||||||
public RuneBase GET_RUNEBASE(final int id) {
|
private static void addRuneLookupRow(PreparedStatement insertStatement, int runeID, String type, String name) throws SQLException {
|
||||||
|
insertStatement.setInt(1, runeID);
|
||||||
RuneBase runeBase = null;
|
insertStatement.setString(2, type);
|
||||||
|
insertStatement.setString(3, name);
|
||||||
try (Connection connection = DbManager.getConnection();
|
insertStatement.addBatch();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_runebase` WHERE `ID` = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, id);
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
runeBase = (RuneBase) getObjectFromRs(rs);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
return runeBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<RuneBase> LOAD_ALL_RUNEBASES() {
|
|
||||||
|
|
||||||
ArrayList<RuneBase> runeBasesList = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_runebase`;")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
runeBasesList = getObjectsFromRs(rs, 1000);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return runeBasesList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<Integer, ArrayList<Integer>> LOAD_ALLOWED_STARTING_RUNES_FOR_BASECLASS() {
|
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<Integer>> runeSets = new HashMap<>();
|
|
||||||
|
|
||||||
int recordsRead = 0;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_baseclassrune")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
|
|
||||||
recordsRead++;
|
|
||||||
|
|
||||||
int baseClassID = rs.getInt("BaseClassesID");
|
|
||||||
int runeBaseID = rs.getInt("RuneBaseID");
|
|
||||||
|
|
||||||
if (runeSets.get(baseClassID) == null) {
|
|
||||||
ArrayList<Integer> runeList = new ArrayList<>();
|
|
||||||
runeList.add(runeBaseID);
|
|
||||||
runeSets.put(baseClassID, runeList);
|
|
||||||
} else {
|
|
||||||
ArrayList<Integer> runeList = runeSets.get(baseClassID);
|
|
||||||
runeList.add(runeBaseID);
|
|
||||||
runeSets.put(baseClassID, runeList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.info("read: " + recordsRead + " cached: " + runeSets.size());
|
|
||||||
|
|
||||||
return runeSets;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<Integer, ArrayList<Integer>> LOAD_ALLOWED_STARTING_RUNES_FOR_RACE() {
|
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<Integer>> runeSets;
|
|
||||||
|
|
||||||
runeSets = new HashMap<>();
|
|
||||||
int recordsRead = 0;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_racerune")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
|
|
||||||
recordsRead++;
|
|
||||||
|
|
||||||
int raceID = rs.getInt("RaceID");
|
|
||||||
int runeBaseID = rs.getInt("RuneBaseID");
|
|
||||||
|
|
||||||
if (runeSets.get(raceID) == null) {
|
|
||||||
ArrayList<Integer> runeList = new ArrayList<>();
|
|
||||||
runeList.add(runeBaseID);
|
|
||||||
runeSets.put(raceID, runeList);
|
|
||||||
} else {
|
|
||||||
ArrayList<Integer> runeList = runeSets.get(raceID);
|
|
||||||
runeList.add(runeBaseID);
|
|
||||||
runeSets.put(raceID, runeList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.info("read: " + recordsRead + " cached: " + runeSets.size());
|
|
||||||
return runeSets;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ import engine.mbEnums.ProtectionState;
|
|||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.AbstractGameObject;
|
||||||
import engine.objects.Building;
|
import engine.objects.Building;
|
||||||
import engine.objects.Shrine;
|
import engine.objects.Shrine;
|
||||||
import java.time.Instant;
|
import org.joda.time.DateTime;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -53,7 +53,7 @@ public class dbShrineHandler extends dbHandlerBase {
|
|||||||
public ArrayList<AbstractGameObject> CREATE_SHRINE(int parentZoneID, int OwnerUUID, String name, int meshUUID,
|
public ArrayList<AbstractGameObject> CREATE_SHRINE(int parentZoneID, int OwnerUUID, String name, int meshUUID,
|
||||||
Vector3fImmutable location, float meshScale, int currentHP,
|
Vector3fImmutable location, float meshScale, int currentHP,
|
||||||
ProtectionState protectionState, int currentGold, int rank,
|
ProtectionState protectionState, int currentGold, int rank,
|
||||||
Instant upgradeDate, int blueprintUUID, float w, float rotY, String shrineType) {
|
DateTime upgradeDate, int blueprintUUID, float w, float rotY, String shrineType) {
|
||||||
|
|
||||||
ArrayList<AbstractGameObject> shrineList = new ArrayList<>();
|
ArrayList<AbstractGameObject> shrineList = new ArrayList<>();
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public class dbShrineHandler extends dbHandlerBase {
|
|||||||
preparedStatement.setInt(12, rank);
|
preparedStatement.setInt(12, rank);
|
||||||
|
|
||||||
if (upgradeDate != null)
|
if (upgradeDate != null)
|
||||||
preparedStatement.setTimestamp(13, java.sql.Timestamp.from(upgradeDate));
|
preparedStatement.setTimestamp(13, new java.sql.Timestamp(upgradeDate.getMillis()));
|
||||||
else
|
else
|
||||||
preparedStatement.setNull(13, java.sql.Types.DATE);
|
preparedStatement.setNull(13, java.sql.Types.DATE);
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ package engine.db.handlers;
|
|||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.mbEnums.GameObjectType;
|
import engine.mbEnums.GameObjectType;
|
||||||
import engine.objects.MaxSkills;
|
|
||||||
import engine.objects.SkillsBase;
|
import engine.objects.SkillsBase;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -20,7 +19,6 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class dbSkillBaseHandler extends dbHandlerBase {
|
public class dbSkillBaseHandler extends dbHandlerBase {
|
||||||
@@ -31,122 +29,33 @@ public class dbSkillBaseHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SkillsBase GET_BASE(final int objectUUID) {
|
public SkillsBase GET_BASE(final int objectUUID) {
|
||||||
|
return (SkillsBase) DbManager.getFromCache(GameObjectType.SkillsBase, objectUUID);
|
||||||
SkillsBase skillsBase = (SkillsBase) DbManager.getFromCache(GameObjectType.SkillsBase, objectUUID);
|
|
||||||
|
|
||||||
if (skillsBase != null)
|
|
||||||
return skillsBase;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_skill_skillsbase WHERE ID = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, objectUUID);
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
skillsBase = (SkillsBase) getObjectFromRs(rs);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
SkillsBase.putInCache(skillsBase);
|
|
||||||
return skillsBase;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkillsBase GET_BASE_BY_NAME(String name) {
|
public SkillsBase GET_BASE_BY_NAME(String name) {
|
||||||
|
return SkillsBase.getFromCache(name);
|
||||||
SkillsBase skillsBase = SkillsBase.getFromCache(name);
|
|
||||||
|
|
||||||
if (skillsBase != null)
|
|
||||||
return skillsBase;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_skill_skillsbase WHERE name = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setString(1, name);
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
skillsBase = (SkillsBase) getObjectFromRs(rs);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
SkillsBase.putInCache(skillsBase);
|
|
||||||
return skillsBase;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkillsBase GET_BASE_BY_TOKEN(final int token) {
|
public SkillsBase GET_BASE_BY_TOKEN(final int token) {
|
||||||
|
return SkillsBase.getFromCache(token);
|
||||||
|
}
|
||||||
|
|
||||||
SkillsBase skillsBase = SkillsBase.getFromCache(token);
|
public HashMap<Integer, String> GET_ALL_SKILL_NAMES() {
|
||||||
|
|
||||||
if (skillsBase != null)
|
HashMap<Integer, String> skillNames = new HashMap<>();
|
||||||
return skillsBase;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_skill_skillsbase WHERE token = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT ID, name FROM static_skill_skillsbase")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, token);
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
skillsBase = (SkillsBase) getObjectFromRs(rs);
|
while (rs.next())
|
||||||
|
skillNames.put(rs.getInt("ID"), rs.getString("name"));
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkillsBase.putInCache(skillsBase);
|
return skillNames;
|
||||||
return skillsBase;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LOAD_ALL_MAX_SKILLS_FOR_CONTRACT() {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_maxskills`")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
|
|
||||||
MaxSkills maxSKills = new MaxSkills(rs);
|
|
||||||
|
|
||||||
if (MaxSkills.MaxSkillsSet.get(maxSKills.getRuneID()) == null) {
|
|
||||||
ArrayList<MaxSkills> newMaxSkillsList = new ArrayList<>();
|
|
||||||
newMaxSkillsList.add(maxSKills);
|
|
||||||
MaxSkills.MaxSkillsSet.put(maxSKills.getRuneID(), newMaxSkillsList);
|
|
||||||
} else
|
|
||||||
MaxSkills.MaxSkillsSet.get(maxSKills.getRuneID()).add(maxSKills);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void LOAD_ALL_RUNE_SKILLS() {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_skill_skillsgranted`")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
|
|
||||||
int runeID = rs.getInt("runeID");
|
|
||||||
int token = rs.getInt("token");
|
|
||||||
int amount = rs.getInt("amount");
|
|
||||||
|
|
||||||
if (SkillsBase.runeSkillsCache.get(runeID) == null)
|
|
||||||
SkillsBase.runeSkillsCache.put(runeID, new HashMap<>());
|
|
||||||
|
|
||||||
SkillsBase.runeSkillsCache.get(runeID).put(token, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,18 +9,8 @@
|
|||||||
|
|
||||||
package engine.db.handlers;
|
package engine.db.handlers;
|
||||||
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.objects.SkillReq;
|
import engine.objects.SkillReq;
|
||||||
import engine.powers.PowersBase;
|
|
||||||
import org.pmw.tinylog.Logger;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class dbSkillReqHandler extends dbHandlerBase {
|
public class dbSkillReqHandler extends dbHandlerBase {
|
||||||
|
|
||||||
@@ -28,72 +18,4 @@ public class dbSkillReqHandler extends dbHandlerBase {
|
|||||||
this.localClass = SkillReq.class;
|
this.localClass = SkillReq.class;
|
||||||
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<PowersBase> getAllPowersBase() {
|
|
||||||
|
|
||||||
ArrayList<PowersBase> powerBaseList = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_powerbase")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
PowersBase toAdd = new PowersBase(rs);
|
|
||||||
powerBaseList.add(toAdd);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return powerBaseList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void getFailConditions(HashMap<String, PowersBase> powers) {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT IDString, type FROM static_power_failcondition where powerOrEffect = 'Power'")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
String type = rs.getString("type");
|
|
||||||
String IDString = rs.getString("IDString");
|
|
||||||
PowersBase pb = powers.get(IDString);
|
|
||||||
|
|
||||||
if (pb != null)
|
|
||||||
switch (type) {
|
|
||||||
case "CastSpell":
|
|
||||||
pb.cancelOnCastSpell = true;
|
|
||||||
break;
|
|
||||||
case "TakeDamage":
|
|
||||||
pb.cancelOnTakeDamage = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<SkillReq> GET_REQS_FOR_RUNE(final int objectUUID) {
|
|
||||||
|
|
||||||
ArrayList<SkillReq> skillReqsList = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_skill_skillreq` WHERE `runeID`=?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, objectUUID);
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
skillReqsList = getObjectsFromRs(rs, 5);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return skillReqsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+13
-13
@@ -6,42 +6,42 @@
|
|||||||
// Magicbane Emulator Project © 2013 - 2026
|
// Magicbane Emulator Project © 2013 - 2026
|
||||||
// https://www.magicbane.com
|
// https://www.magicbane.com
|
||||||
|
|
||||||
|
|
||||||
package engine.db.handlers;
|
package engine.db.handlers;
|
||||||
|
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.objects.Resists;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class dbResistHandler extends dbHandlerBase {
|
public class dbStaticWorldHandler extends dbHandlerBase {
|
||||||
|
|
||||||
public dbResistHandler() {
|
public dbStaticWorldHandler() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resists GET_RESISTS_FOR_MOB(int resistID) {
|
// Table and column come from StaticManifest's fixed list, never from input. -1 means "none" and is skipped.
|
||||||
|
public HashMap<Integer, Integer> GET_NEGATIVE_REFERENCES(String table, String column) {
|
||||||
|
|
||||||
Resists resists = null;
|
HashMap<Integer, Integer> rowsByValue = new HashMap<>();
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mob_resists` WHERE `ID` = ?;")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `" + column + "` AS `value`, COUNT(*) AS `rows` FROM `"
|
||||||
|
+ table + "` WHERE `" + column + "` < -1 GROUP BY `" + column + "`;")) {
|
||||||
preparedStatement.setInt(1, resistID);
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
if (rs.next())
|
while (rs.next())
|
||||||
resists = new Resists(rs);
|
rowsByValue.put(rs.getInt("value"), rs.getInt("rows"));
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error(e);
|
Logger.error(table + "." + column + ": " + e);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return resists;
|
return rowsByValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,8 +20,9 @@ import engine.objects.City;
|
|||||||
import engine.objects.Transaction;
|
import engine.objects.Transaction;
|
||||||
import engine.objects.Warehouse;
|
import engine.objects.Warehouse;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import java.time.Instant;
|
import org.joda.time.DateTime;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CREATE_TRANSACTION(int warehouseBuildingID, GameObjectType targetType, int targetUUID, TransactionType transactionType, mbEnums.ResourceType resource, int amount, Instant date) {
|
public boolean CREATE_TRANSACTION(int warehouseBuildingID, GameObjectType targetType, int targetUUID, TransactionType transactionType, mbEnums.ResourceType resource, int amount, DateTime date) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_warehouse_transactions` (`warehouseUID`, `targetType`,`targetUID`, `type`,`resource`,`amount`,`date` ) VALUES (?,?,?,?,?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_warehouse_transactions` (`warehouseUID`, `targetType`,`targetUID`, `type`,`resource`,`amount`,`date` ) VALUES (?,?,?,?,?,?,?)")) {
|
||||||
@@ -51,7 +52,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
preparedStatement.setString(4, transactionType.name());
|
preparedStatement.setString(4, transactionType.name());
|
||||||
preparedStatement.setString(5, resource.name());
|
preparedStatement.setString(5, resource.name());
|
||||||
preparedStatement.setInt(6, amount);
|
preparedStatement.setInt(6, amount);
|
||||||
preparedStatement.setTimestamp(7, new java.sql.Timestamp(date.toEpochMilli()));
|
preparedStatement.setTimestamp(7, new java.sql.Timestamp(date.getMillis()));
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -134,7 +135,6 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
int cityUID = rs.getInt("cityUUID");
|
int cityUID = rs.getInt("cityUUID");
|
||||||
JSONObject jsonObject = new JSONObject(rs.getString("warehouse"));
|
|
||||||
City city = City.getCity(cityUID);
|
City city = City.getCity(cityUID);
|
||||||
|
|
||||||
if (city == null) {
|
if (city == null) {
|
||||||
@@ -142,12 +142,18 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
city.warehouse = new Warehouse(jsonObject);
|
try {
|
||||||
|
city.warehouse = new Warehouse(new JSONObject(rs.getString("warehouse")));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
Logger.error("Warehouse for city " + cityUID + " failed to load: " + e.getMessage());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
city.warehouse.city = city;
|
city.warehouse.city = city;
|
||||||
|
|
||||||
// Locate warehouse building
|
// Locate warehouse building
|
||||||
for (Building building : city.parentZone.zoneBuildingSet) {
|
for (Building building : city.parentZone.zoneBuildingSet) {
|
||||||
if (building.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.WAREHOUSE)) {
|
if (building.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.WAREHOUSE) && building.getRank() != -1) {
|
||||||
city.warehouse.building = building;
|
city.warehouse.building = building;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -205,8 +211,16 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
ResultSet rs = preparedStatement.executeQuery()) {
|
ResultSet rs = preparedStatement.executeQuery()) {
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
JSONObject jsonObject = new JSONObject(rs.getString("workorder"));
|
int workOrderID = rs.getInt("workorderID");
|
||||||
WorkOrder workOrder = new WorkOrder(jsonObject);
|
WorkOrder workOrder;
|
||||||
|
|
||||||
|
try {
|
||||||
|
workOrder = new WorkOrder(new JSONObject(rs.getString("workorder")));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
Logger.error("WorkOrder " + workOrderID + " failed to load: " + e.getMessage());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
submitList.add(workOrder);
|
submitList.add(workOrder);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -10,10 +10,8 @@
|
|||||||
package engine.db.handlers;
|
package engine.db.handlers;
|
||||||
|
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.gameManager.ZoneManager;
|
|
||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import engine.objects.ZoneTemplate;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -46,6 +44,23 @@ public class dbZoneHandler extends dbHandlerBase {
|
|||||||
return zoneList;
|
return zoneList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<Zone> GET_PLAYER_CITY_ZONES() {
|
||||||
|
|
||||||
|
ArrayList<Zone> zoneList = new ArrayList<>();
|
||||||
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` WHERE `obj_zone`.`template` = 0 ORDER BY `object`.`UID` ASC;")) {
|
||||||
|
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
zoneList = getObjectsFromRs(rs, 200);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return zoneList;
|
||||||
|
}
|
||||||
|
|
||||||
public Zone GET_BY_UID(long ID) {
|
public Zone GET_BY_UID(long ID) {
|
||||||
|
|
||||||
Zone zone = (Zone) DbManager.getFromCache(mbEnums.GameObjectType.Zone, (int) ID);
|
Zone zone = (Zone) DbManager.getFromCache(mbEnums.GameObjectType.Zone, (int) ID);
|
||||||
@@ -68,42 +83,11 @@ public class dbZoneHandler extends dbHandlerBase {
|
|||||||
return zone;
|
return zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LOAD_ALL_ZONE_TEMPLATES() {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_zone_templates")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
ZoneTemplate zoneTemplate = new ZoneTemplate(rs);
|
|
||||||
ZoneManager._zone_templates.put(zoneTemplate.templateID, zoneTemplate);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add player city
|
|
||||||
|
|
||||||
ZoneTemplate zoneTemplate = new ZoneTemplate();
|
|
||||||
|
|
||||||
zoneTemplate.templateID = 0;
|
|
||||||
zoneTemplate.sea_level_type = "PARENT";
|
|
||||||
zoneTemplate.sea_level = 0;
|
|
||||||
zoneTemplate.max_blend = 128;
|
|
||||||
zoneTemplate.min_blend = 128;
|
|
||||||
zoneTemplate.terrain_max_y = 5;
|
|
||||||
zoneTemplate.major_radius = (int) mbEnums.CityBoundsType.ZONE.halfExtents;
|
|
||||||
zoneTemplate.minor_radius = (int) mbEnums.CityBoundsType.ZONE.halfExtents;
|
|
||||||
zoneTemplate.terrain_type = "PLANAR";
|
|
||||||
|
|
||||||
ZoneManager._zone_templates.put(zoneTemplate.templateID, zoneTemplate);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean DELETE_ZONE(final Zone zone) {
|
public boolean DELETE_ZONE(final Zone zone) {
|
||||||
|
|
||||||
|
if (DbManager.refuseStaticWrite(zone))
|
||||||
|
return false;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `object` WHERE `UID` = ? AND `type` = 'zone'")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `object` WHERE `UID` = ? AND `type` = 'zone'")) {
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import engine.gameManager.ChatManager;
|
|||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.mbEnums.GameObjectType;
|
import engine.mbEnums.GameObjectType;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -99,12 +100,18 @@ public abstract class AbstractDevCmd {
|
|||||||
if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
|
if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
|
||||||
this.sendHelp(pcSender);
|
this.sendHelp(pcSender);
|
||||||
this.sendUsage(pcSender);
|
this.sendUsage(pcSender);
|
||||||
|
} else if (this.addsWorldContent()) {
|
||||||
|
this.refuseWorldChange(pcSender, target);
|
||||||
} else {
|
} else {
|
||||||
this.tr = target;
|
this.tr = target;
|
||||||
this._doCmd(pcSender, args, target);
|
this._doCmd(pcSender, args, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean addsWorldContent() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void _doCmd(PlayerCharacter pcSender, String[] args,
|
protected abstract void _doCmd(PlayerCharacter pcSender, String[] args,
|
||||||
AbstractGameObject target);
|
AbstractGameObject target);
|
||||||
|
|
||||||
@@ -178,4 +185,22 @@ public abstract class AbstractDevCmd {
|
|||||||
ChatManager.chatSystemInfo(pc, msgText);
|
ChatManager.chatSystemInfo(pc, msgText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Static world objects are built from client data each boot, so they are changed with external tooling only.
|
||||||
|
protected boolean refuseStaticTarget(PlayerCharacter pc, AbstractGameObject target) {
|
||||||
|
|
||||||
|
if (!(target instanceof AbstractWorldObject) || !((AbstractWorldObject) target).isStaticWorldObject())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this.refuseWorldChange(pc, target);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void refuseWorldChange(PlayerCharacter pc, AbstractGameObject target) {
|
||||||
|
|
||||||
|
String targetText = (target == null) ? "no target" : target.getObjectType() + " " + target.getObjectUUID();
|
||||||
|
|
||||||
|
this.throwbackError(pc, "Must use external tooling to modify gameworld");
|
||||||
|
Logger.info("Refused dev command " + this.getMainCmdString() + " on " + targetText + " by " + pc.getFirstName());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@ import engine.devcmd.AbstractDevCmd;
|
|||||||
import engine.gameManager.ChatManager;
|
import engine.gameManager.ChatManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Quaternion;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.mbEnums.ProtectionState;
|
import engine.mbEnums.ProtectionState;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
@@ -54,8 +54,7 @@ public class AddBuildingCmd extends AbstractDevCmd {
|
|||||||
"Invalid addBuilding Command. Invalid Building ID.");
|
"Invalid addBuilding Command. Invalid Building ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Vector3f rot = new Vector3f(0.0f, 0.0f, 0.0f);
|
Quaternion rotation = new Quaternion();
|
||||||
float w = 1f;
|
|
||||||
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
|
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||||
|
|
||||||
if (zone == null) {
|
if (zone == null) {
|
||||||
@@ -73,8 +72,7 @@ public class AddBuildingCmd extends AbstractDevCmd {
|
|||||||
Building likeBuilding = DbManager.BuildingQueries.GET_BUILDING_BY_MESH(ID);
|
Building likeBuilding = DbManager.BuildingQueries.GET_BUILDING_BY_MESH(ID);
|
||||||
|
|
||||||
if (likeBuilding != null) {
|
if (likeBuilding != null) {
|
||||||
rot = likeBuilding.getRot();
|
rotation = likeBuilding.getRotation();
|
||||||
w = likeBuilding.getw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String buildingName = "";
|
String buildingName = "";
|
||||||
@@ -90,11 +88,10 @@ public class AddBuildingCmd extends AbstractDevCmd {
|
|||||||
blueprintUUID = blueprint.getBlueprintUUID();
|
blueprintUUID = blueprint.getBlueprintUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
Building building = DbManager.BuildingQueries.
|
Building building = Building.persistBuilding(Building.createBuilding(
|
||||||
CREATE_BUILDING(
|
zone, 0, buildingName, ID,
|
||||||
zone.getObjectUUID(), 0, buildingName, ID,
|
localLoc, 1.0f, 0, ProtectionState.PROTECTED, 0, rank,
|
||||||
localLoc, 1.0f, 0, ProtectionState.PROTECTED, 0, rank,
|
null, blueprintUUID, rotation.w, rotation.y));
|
||||||
null, blueprintUUID, w, rot.y);
|
|
||||||
|
|
||||||
|
|
||||||
if (building == null) {
|
if (building == null) {
|
||||||
@@ -102,9 +99,6 @@ public class AddBuildingCmd extends AbstractDevCmd {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
building.setRot(rot);
|
|
||||||
building.setw(w);
|
|
||||||
|
|
||||||
building.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
building.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
||||||
WorldGrid.addObject(building, pc);
|
WorldGrid.addObject(building, pc);
|
||||||
ChatManager.chatSayInfo(pc,
|
ChatManager.chatSayInfo(pc,
|
||||||
@@ -114,6 +108,11 @@ public class AddBuildingCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean addsWorldContent() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getHelpString() {
|
protected String _getHelpString() {
|
||||||
return "Creates a building of type 'buildingID' at the location your character is standing.";
|
return "Creates a building of type 'buildingID' at the location your character is standing.";
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ public class AddMobCmd extends AbstractDevCmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean addsWorldContent() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getHelpString() {
|
protected String _getHelpString() {
|
||||||
return "Creates a Mob of type 'mobID' at the location your character is standing";
|
return "Creates a Mob of type 'mobID' at the location your character is standing";
|
||||||
|
|||||||
@@ -94,6 +94,11 @@ public class AddNPCCmd extends AbstractDevCmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean addsWorldContent() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getHelpString() {
|
protected String _getHelpString() {
|
||||||
return "Creates an NPC of type 'npcID' at the location your character is standing";
|
return "Creates an NPC of type 'npcID' at the location your character is standing";
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import engine.gameManager.DbManager;
|
|||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.AbstractGameObject;
|
||||||
import engine.objects.Item;
|
import engine.objects.Item;
|
||||||
import engine.objects.ItemTemplate;
|
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,7 +38,7 @@ public class CreateItemCmd extends AbstractDevCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int templateID = Integer.parseInt(words[0]);
|
int templateID = Integer.parseInt(words[0]);
|
||||||
ItemTemplate template = ItemTemplate.templates.get(templateID);
|
CObjectTemplate template = CObjectTemplate.lookup(templateID);
|
||||||
|
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
ChatManager.chatSystemInfo(playerCharacter, "No such template found.");
|
ChatManager.chatSystemInfo(playerCharacter, "No such template found.");
|
||||||
@@ -51,7 +51,7 @@ public class CreateItemCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
|
|
||||||
if (!playerCharacter.charItemManager.hasRoomInventory(template.item_wt)) {
|
if (!playerCharacter.charItemManager.hasRoomInventory(template.getItemWt())) {
|
||||||
ChatManager.chatSystemInfo(playerCharacter, "You are encumbered!.");
|
ChatManager.chatSystemInfo(playerCharacter, "You are encumbered!.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2026
|
||||||
|
// https://www.magicbane.com
|
||||||
|
|
||||||
|
|
||||||
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
|
import engine.devcmd.AbstractDevCmd;
|
||||||
|
import engine.gameManager.ChatManager;
|
||||||
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.mbEnums;
|
||||||
|
import engine.objects.AbstractGameObject;
|
||||||
|
import engine.objects.Building;
|
||||||
|
import engine.objects.City;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.objects.Warehouse;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class FillCmd extends AbstractDevCmd {
|
||||||
|
|
||||||
|
public FillCmd() {
|
||||||
|
super("fill");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||||
|
AbstractGameObject target) {
|
||||||
|
|
||||||
|
Building building;
|
||||||
|
City city;
|
||||||
|
Warehouse warehouse;
|
||||||
|
int amount = Integer.MAX_VALUE;
|
||||||
|
HashMap<mbEnums.ResourceType, Integer> oldResources;
|
||||||
|
|
||||||
|
if (words.length > 1) {
|
||||||
|
this.sendUsage(pc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (words.length == 1 && !words[0].isEmpty()) {
|
||||||
|
try {
|
||||||
|
amount = Integer.parseInt(words[0]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throwbackError(pc, "Amount must be a number, " + words[0] + " is invalid");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amount < 0) {
|
||||||
|
throwbackError(pc, "Amount must be 0 or more");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target == null || target.getObjectType() != mbEnums.GameObjectType.Building) {
|
||||||
|
throwbackError(pc, "Select a warehouse");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
building = (Building) target;
|
||||||
|
|
||||||
|
if (building.getBlueprint() == null || building.getBlueprint().getBuildingGroup() != mbEnums.BuildingGroup.WAREHOUSE) {
|
||||||
|
throwbackError(pc, "Selected building is not a warehouse");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
city = building.getCity();
|
||||||
|
|
||||||
|
if (city == null || city.warehouse == null || city.warehouse.building == null
|
||||||
|
|| city.warehouse.building.getObjectUUID() != building.getObjectUUID()) {
|
||||||
|
throwbackError(pc, "Selected warehouse is not the active warehouse of a city");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
warehouse = city.warehouse;
|
||||||
|
|
||||||
|
oldResources = new HashMap<>(warehouse.resources);
|
||||||
|
|
||||||
|
for (mbEnums.ResourceType resourceType : mbEnums.ResourceType.values())
|
||||||
|
warehouse.resources.put(resourceType, Math.min(amount, resourceType.deposit_limit));
|
||||||
|
|
||||||
|
if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) {
|
||||||
|
warehouse.resources.putAll(oldResources);
|
||||||
|
throwbackError(pc, "Failed to update the warehouse in the database");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatManager.chatSayInfo(pc, "Filled the " + city.getCityName() + " warehouse"
|
||||||
|
+ (amount == Integer.MAX_VALUE ? " to each deposit limit" : " with " + amount + " of each resource (capped at the deposit limit)"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String _getHelpString() {
|
||||||
|
return "Sets every resource in the selected warehouse";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String _getUsageString() {
|
||||||
|
return "' ./fill [amount]' with a warehouse selected (no amount fills each resource to its deposit limit)";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -37,8 +37,8 @@ public class GetHeightCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
Vector2f childZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone);
|
Vector2f childZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone);
|
||||||
Vector2f childZoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone);
|
Vector2f childZoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone);
|
||||||
Vector2f normalizedOffset = new Vector2f(Math.abs(childZoneOffset.x) / heightmapZone.template.major_radius,
|
Vector2f normalizedOffset = new Vector2f(Math.abs(childZoneOffset.x) / heightmapZone.template.zone_major_radius,
|
||||||
Math.abs(childZoneOffset.y) / heightmapZone.template.minor_radius);
|
Math.abs(childZoneOffset.y) / heightmapZone.template.zone_minor_radius);
|
||||||
Vector2f parentZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), parentZone);
|
Vector2f parentZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), parentZone);
|
||||||
|
|
||||||
float childHeight = heightmapZone.terrain.getInterpolatedTerrainHeight(childZoneLoc);
|
float childHeight = heightmapZone.terrain.getInterpolatedTerrainHeight(childZoneLoc);
|
||||||
@@ -74,7 +74,7 @@ public class GetHeightCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
this.throwbackInfo(playerCharacter, "Child Zone Offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]");
|
this.throwbackInfo(playerCharacter, "Child Zone Offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]");
|
||||||
this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]");
|
this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]");
|
||||||
this.throwbackInfo(playerCharacter, "template blend Values: (max/min): " + heightmapZone.template.max_blend + " /" + heightmapZone.template.min_blend);
|
this.throwbackInfo(playerCharacter, "template blend Values: (max/min): " + heightmapZone.template.zone_max_blend + " /" + heightmapZone.template.zone_min_blend);
|
||||||
this.throwbackInfo(playerCharacter, "terrain values (max/min): " + heightmapZone.terrain.blend_values.x + " /" + heightmapZone.terrain.blend_values.y);
|
this.throwbackInfo(playerCharacter, "terrain values (max/min): " + heightmapZone.terrain.blend_values.x + " /" + heightmapZone.terrain.blend_values.y);
|
||||||
this.throwbackInfo(playerCharacter, "Blend coefficient: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset));
|
this.throwbackInfo(playerCharacter, "Blend coefficient: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset));
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import engine.mbEnums.BuildingGroup;
|
|||||||
import engine.mbEnums.GameObjectType;
|
import engine.mbEnums.GameObjectType;
|
||||||
import engine.mbEnums.TargetColor;
|
import engine.mbEnums.TargetColor;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
import engine.util.StringUtils;
|
import engine.util.StringUtils;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
@@ -87,7 +89,7 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
output += newline;
|
output += newline;
|
||||||
output += StringUtils.addWS("Alt: " + targetLoc.y, 20);
|
output += StringUtils.addWS("Alt: " + targetLoc.y, 20);
|
||||||
output += newline;
|
output += newline;
|
||||||
output += "Rot: " + targetAWO.getRot().y;
|
output += "Rot: " + targetAWO.getRotation().y;
|
||||||
output += newline;
|
output += newline;
|
||||||
double radian = 0;
|
double radian = 0;
|
||||||
|
|
||||||
@@ -105,7 +107,7 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
case Building:
|
case Building:
|
||||||
Building targetBuilding = (Building) target;
|
Building targetBuilding = (Building) target;
|
||||||
output += StringUtils.addWS("Lac: "
|
output += StringUtils.addWS("Lac: "
|
||||||
+ targetBuilding.getw(), 20);
|
+ targetBuilding.getRotation().w, 20);
|
||||||
output += "Blueprint : ";
|
output += "Blueprint : ";
|
||||||
output += targetBuilding.getBlueprintUUID();
|
output += targetBuilding.getBlueprintUUID();
|
||||||
output += newline;
|
output += newline;
|
||||||
@@ -342,7 +344,7 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
case NPC:
|
case NPC:
|
||||||
NPC targetNPC = (NPC) target;
|
NPC targetNPC = (NPC) target;
|
||||||
output += "databaseID: " + targetNPC.getDBID() + newline;
|
output += "databaseID: " + databaseIDText(targetNPC.getDBID()) + newline;
|
||||||
output += "Name: " + targetNPC.getName();
|
output += "Name: " + targetNPC.getName();
|
||||||
output += newline;
|
output += newline;
|
||||||
output += StringUtils.addWS("Level: " + targetNPC.getLevel(), 20);
|
output += StringUtils.addWS("Level: " + targetNPC.getLevel(), 20);
|
||||||
@@ -413,7 +415,7 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
break;
|
break;
|
||||||
case Mob:
|
case Mob:
|
||||||
Mob targetMob = (Mob) target;
|
Mob targetMob = (Mob) target;
|
||||||
output += "databaseID: " + targetMob.getDBID() + newline;
|
output += "databaseID: " + databaseIDText(targetMob.getDBID()) + newline;
|
||||||
output += "Name: " + targetMob.getName();
|
output += "Name: " + targetMob.getName();
|
||||||
output += newline;
|
output += newline;
|
||||||
output += StringUtils.addWS("Level: " + targetMob.getLevel(), 20);
|
output += StringUtils.addWS("Level: " + targetMob.getLevel(), 20);
|
||||||
@@ -507,17 +509,17 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
case Item: //intentional passthrough
|
case Item: //intentional passthrough
|
||||||
case MobLoot:
|
case MobLoot:
|
||||||
Item item = (Item) target;
|
Item item = (Item) target;
|
||||||
ItemTemplate template = ItemTemplate.templates.get(item.templateID);
|
CObjectTemplate template = CObjectTemplate.lookup(item.templateID);
|
||||||
output += StringUtils.addWS("Template: " + template.template_id, 20);
|
output += StringUtils.addWS("Template: " + template.getTemplateId(), 20);
|
||||||
output += "Weight: " + template.item_wt;
|
output += "Weight: " + template.getItemWt();
|
||||||
output += newline;
|
output += newline;
|
||||||
DecimalFormat df = new DecimalFormat("###,###,###,###,##0");
|
DecimalFormat df = new DecimalFormat("###,###,###,###,##0");
|
||||||
output += StringUtils.addWS("Qty: "
|
output += StringUtils.addWS("Qty: "
|
||||||
+ df.format(item.getNumOfItems()), 20);
|
+ df.format(item.getNumOfItems()), 20);
|
||||||
output += "Charges: " + (byte) item.chargesRemaining
|
output += "Charges: " + (byte) item.chargesRemaining
|
||||||
+ '/' + item.template.item_initial_charges;
|
+ '/' + item.template.getItemInitialCharges();
|
||||||
output += newline;
|
output += newline;
|
||||||
output += "Name: " + template.item_base_name;
|
output += "Name: " + template.getItemBaseName();
|
||||||
output += newline;
|
output += newline;
|
||||||
output += item.getContainerInfo();
|
output += item.getContainerInfo();
|
||||||
|
|
||||||
@@ -538,6 +540,14 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
throwbackInfo(pc, output);
|
throwbackInfo(pc, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String databaseIDText(int databaseID) {
|
||||||
|
|
||||||
|
if (databaseID == MBServerStatics.NO_DB_ROW_ASSIGNED_YET)
|
||||||
|
return "none";
|
||||||
|
|
||||||
|
return String.valueOf(databaseID);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getHelpString() {
|
protected String _getHelpString() {
|
||||||
return "Gets information on an Object.";
|
return "Gets information on an Object.";
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ package engine.devcmd.cmds;
|
|||||||
|
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.mbEnums.ItemContainerType;
|
||||||
import engine.mbEnums.ItemType;
|
import engine.mbEnums.ItemType;
|
||||||
import engine.mbEnums.OwnerType;
|
import engine.mbEnums.OwnerType;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
import engine.powers.EffectsBase;
|
import engine.powers.EffectsBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,18 +61,17 @@ public class MakeItemCmd extends AbstractDevCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int templateID;
|
int templateID;
|
||||||
ItemTemplate template;
|
CObjectTemplate template;
|
||||||
try {
|
try {
|
||||||
templateID = Integer.parseInt(words[0]);
|
templateID = Integer.parseInt(words[0]);
|
||||||
template = ItemTemplate.templates.get(words[0].toLowerCase());
|
template = CObjectTemplate.lookup(templateID);
|
||||||
|
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
throwbackError(pc, "Supplied type " + words[0]
|
throwbackError(pc, "No item template with id " + words[0]);
|
||||||
+ " failed to parse to an Integer");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template.item_type == ItemType.GOLD) {
|
if (template.getItemType() == ItemType.GOLD) {
|
||||||
this.throwbackInfo(pc, "use /addgold to add gold.");
|
this.throwbackInfo(pc, "use /addgold to add gold.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -132,7 +133,7 @@ public class MakeItemCmd extends AbstractDevCmd {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template = ItemTemplate.templates.get(templateID);
|
template = CObjectTemplate.lookup(templateID);
|
||||||
|
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
throwbackError(pc, "Unable to find template " + templateID);
|
throwbackError(pc, "Unable to find template " + templateID);
|
||||||
@@ -140,8 +141,8 @@ public class MakeItemCmd extends AbstractDevCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((numItems > 1)
|
if ((numItems > 1)
|
||||||
&& (template.item_type.equals(ItemType.RESOURCE) == false)
|
&& (template.getItemType().equals(ItemType.RESOURCE) == false)
|
||||||
&& (template.item_type.equals(ItemType.OFFERING)) == false)
|
&& (template.getItemType().equals(ItemType.OFFERING)) == false)
|
||||||
numItems = 1;
|
numItems = 1;
|
||||||
|
|
||||||
CharacterItemManager cim = pc.charItemManager;
|
CharacterItemManager cim = pc.charItemManager;
|
||||||
@@ -155,7 +156,7 @@ public class MakeItemCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
for (int i = 0; i < quantity; i++) {
|
for (int i = 0; i < quantity; i++) {
|
||||||
|
|
||||||
int weight = template.item_wt;
|
int weight = template.getItemWt();
|
||||||
|
|
||||||
if (!cim.hasRoomInventory(weight)) {
|
if (!cim.hasRoomInventory(weight)) {
|
||||||
throwbackError(pc, "Not enough room in inventory for any more of this item. " + i + " produced.");
|
throwbackError(pc, "Not enough room in inventory for any more of this item. " + i + " produced.");
|
||||||
@@ -169,6 +170,7 @@ public class MakeItemCmd extends AbstractDevCmd {
|
|||||||
Item item = new Item(templateID);
|
Item item = new Item(templateID);
|
||||||
item.ownerID = pc.getObjectUUID();
|
item.ownerID = pc.getObjectUUID();
|
||||||
item.ownerType = OwnerType.PlayerCharacter;
|
item.ownerType = OwnerType.PlayerCharacter;
|
||||||
|
item.containerType = ItemContainerType.INVENTORY;
|
||||||
|
|
||||||
if (numItems > 1)
|
if (numItems > 1)
|
||||||
item.setNumOfItems(numItems);
|
item.setNumOfItems(numItems);
|
||||||
@@ -180,6 +182,11 @@ public class MakeItemCmd extends AbstractDevCmd {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item == null) {
|
||||||
|
throwbackError(pc, "DB error 2: Unable to create item " + templateID + ".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//create prefix
|
//create prefix
|
||||||
if (!prefix.isEmpty())
|
if (!prefix.isEmpty())
|
||||||
item.addPermanentEnchantmentForDev(prefix, 0);
|
item.addPermanentEnchantmentForDev(prefix, 0);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package engine.devcmd.cmds;
|
|||||||
|
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -52,8 +53,8 @@ public class PrintBankCmd extends AbstractDevCmd {
|
|||||||
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||||
|
|
||||||
for (Item item : list) {
|
for (Item item : list) {
|
||||||
ItemTemplate template = ItemTemplate.templates.get(item.templateID);
|
CObjectTemplate template = CObjectTemplate.lookup(item.templateID);
|
||||||
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
|
throwbackInfo(pc, " " + template.getItemBaseName() + ", count: " + item.getNumOfItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
Item gold = cim.getGoldBank();
|
Item gold = cim.getGoldBank();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import engine.devcmd.AbstractDevCmd;
|
|||||||
import engine.gameManager.ChatManager;
|
import engine.gameManager.ChatManager;
|
||||||
import engine.mbEnums.GameObjectType;
|
import engine.mbEnums.GameObjectType;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
||||||
|
|
||||||
public class PrintBonusesCmd extends AbstractDevCmd {
|
public class PrintBonusesCmd extends AbstractDevCmd {
|
||||||
@@ -33,8 +34,8 @@ public class PrintBonusesCmd extends AbstractDevCmd {
|
|||||||
if (target instanceof Item) {
|
if (target instanceof Item) {
|
||||||
type = "Item";
|
type = "Item";
|
||||||
tar = (Item) target;
|
tar = (Item) target;
|
||||||
ItemTemplate template = ItemTemplate.templates.get(((Item) tar).templateID);
|
CObjectTemplate template = CObjectTemplate.lookup(((Item) tar).templateID);
|
||||||
name = template.item_base_name;
|
name = template.getItemBaseName();
|
||||||
} else if (target instanceof AbstractCharacter) {
|
} else if (target instanceof AbstractCharacter) {
|
||||||
tar = (AbstractCharacter) target;
|
tar = (AbstractCharacter) target;
|
||||||
name = ((AbstractCharacter) tar).getFirstName();
|
name = ((AbstractCharacter) tar).getFirstName();
|
||||||
|
|||||||
@@ -10,9 +10,15 @@
|
|||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
|
import engine.mbEnums.GameObjectType;
|
||||||
import engine.objects.AbstractCharacter;
|
import engine.objects.AbstractCharacter;
|
||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.AbstractGameObject;
|
||||||
|
import engine.objects.Effect;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.powers.EffectsBase;
|
||||||
|
import engine.powers.PowersBase;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -30,28 +36,60 @@ public class PrintEffectsCmd extends AbstractDevCmd {
|
|||||||
AbstractGameObject target) {
|
AbstractGameObject target) {
|
||||||
|
|
||||||
AbstractCharacter tar;
|
AbstractCharacter tar;
|
||||||
|
StringBuilder output;
|
||||||
|
String newline = "\r\n ";
|
||||||
|
Effect effect;
|
||||||
|
EffectsBase effectsBase;
|
||||||
|
PowersBase power;
|
||||||
|
|
||||||
if (target != null && target instanceof AbstractCharacter) {
|
if (target == null)
|
||||||
tar = (AbstractCharacter) target;
|
return;
|
||||||
|
|
||||||
String newline = "\r\n ";
|
if (target.getObjectType() != GameObjectType.PlayerCharacter && target.getObjectType() != GameObjectType.Mob
|
||||||
String output = "Effects For Character: " + tar.getName() + newline;
|
&& target.getObjectType() != GameObjectType.NPC)
|
||||||
|
return;
|
||||||
|
|
||||||
for (String effect : tar.effects.keySet()) {
|
tar = (AbstractCharacter) target;
|
||||||
output += effect + newline;
|
output = new StringBuilder("Effects for " + tar.getName() + " (" + tar.effects.size() + "):" + newline);
|
||||||
}
|
|
||||||
throwbackInfo(pc, output);
|
// Keys are the effect UUID for mobbase/rune effects, or the stack type (e.g. PetBuff) for power effects
|
||||||
|
for (Map.Entry<String, Effect> entry : tar.effects.entrySet()) {
|
||||||
|
|
||||||
|
effect = entry.getValue();
|
||||||
|
effectsBase = effect.getEffectsBase();
|
||||||
|
power = effect.getPower();
|
||||||
|
|
||||||
|
output.append(entry.getKey()).append(": ");
|
||||||
|
|
||||||
|
if (effectsBase != null)
|
||||||
|
output.append(effectsBase.getIDString()).append(" '").append(effectsBase.getName()).append("'");
|
||||||
|
else
|
||||||
|
output.append("no EffectsBase");
|
||||||
|
|
||||||
|
output.append(" rank ").append(effect.getTrains());
|
||||||
|
|
||||||
|
if (effect.isStatic())
|
||||||
|
output.append(", static");
|
||||||
|
else
|
||||||
|
output.append(", ").append((int) effect.getDuration()).append("s left");
|
||||||
|
|
||||||
|
if (power != null)
|
||||||
|
output.append(", from ").append(power.getIDString()).append(" '").append(power.getName()).append("'");
|
||||||
|
|
||||||
|
output.append(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throwbackInfo(pc, output.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getHelpString() {
|
protected String _getHelpString() {
|
||||||
return "Returns the player's current stats";
|
return "Lists the target's effects: key, effect id and name, rank, time left and source power";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getUsageString() {
|
protected String _getUsageString() {
|
||||||
return "' /printstats'";
|
return "' /printeffects'";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
|
|||||||
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||||
for (mbEnums.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) {
|
for (mbEnums.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) {
|
||||||
Item equip = tarMob.charItemManager.equipped.get(slot);
|
Item equip = tarMob.charItemManager.equipped.get(slot);
|
||||||
throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot);
|
throwbackInfo(pc, equip.templateID + " : " + equip.template.getItemBaseName() + ", slot: " + slot);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
|
|||||||
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||||
for (mbEnums.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) {
|
for (mbEnums.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) {
|
||||||
Item equip = tarMob.charItemManager.equipped.get(slot);
|
Item equip = tarMob.charItemManager.equipped.get(slot);
|
||||||
throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot);
|
throwbackInfo(pc, equip.templateID + " : " + equip.template.getItemBaseName() + ", slot: " + slot);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
for (mbEnums.EquipSlotType slot : list.keySet()) {
|
for (mbEnums.EquipSlotType slot : list.keySet()) {
|
||||||
Item item = list.get(slot);
|
Item item = list.get(slot);
|
||||||
throwbackInfo(pc, " " + item.template.item_base_name + ", slot: " + slot);
|
throwbackInfo(pc, " " + item.template.getItemBaseName() + ", slot: " + slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ package engine.devcmd.cmds;
|
|||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.mbEnums.ItemType;
|
import engine.mbEnums.ItemType;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -75,18 +76,18 @@ public class PrintInventoryCmd extends AbstractDevCmd {
|
|||||||
int goldCount = 0;
|
int goldCount = 0;
|
||||||
|
|
||||||
for (Item item : inventory) {
|
for (Item item : inventory) {
|
||||||
ItemTemplate template = ItemTemplate.templates.get(item.templateID);
|
CObjectTemplate template = CObjectTemplate.lookup(item.templateID);
|
||||||
|
|
||||||
if (item.template.item_type.equals(ItemType.GOLD) == false) {
|
if (item.template.getItemType().equals(ItemType.GOLD) == false) {
|
||||||
|
|
||||||
String chargeInfo = "";
|
String chargeInfo = "";
|
||||||
int chargeMax = template.item_initial_charges;
|
int chargeMax = template.getItemInitialCharges();
|
||||||
|
|
||||||
if (chargeMax > 0) {
|
if (chargeMax > 0) {
|
||||||
int charges = item.chargesRemaining;
|
int charges = item.chargesRemaining;
|
||||||
chargeInfo = " charges: " + charges + '/' + chargeMax;
|
chargeInfo = " charges: " + charges + '/' + chargeMax;
|
||||||
}
|
}
|
||||||
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems() + chargeInfo);
|
throwbackInfo(pc, " " + template.getItemBaseName() + ", count: " + item.getNumOfItems() + chargeInfo);
|
||||||
} else
|
} else
|
||||||
goldCount += item.getNumOfItems();
|
goldCount += item.getNumOfItems();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package engine.devcmd.cmds;
|
|||||||
|
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -50,8 +51,8 @@ public class PrintVaultCmd extends AbstractDevCmd {
|
|||||||
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) {
|
||||||
ItemTemplate template = ItemTemplate.templates.get(item.templateID);
|
CObjectTemplate template = CObjectTemplate.lookup(item.templateID);
|
||||||
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
|
throwbackInfo(pc, " " + template.getItemBaseName() + ", count: " + item.getNumOfItems());
|
||||||
}
|
}
|
||||||
Item gold = cim.getGoldVault();
|
Item gold = cim.getGoldVault();
|
||||||
if (gold != null)
|
if (gold != null)
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ public class PullCmd extends AbstractDevCmd {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.refuseStaticTarget(pcSender, target))
|
||||||
|
return;
|
||||||
|
|
||||||
targetLoc = pcSender.getLoc();
|
targetLoc = pcSender.getLoc();
|
||||||
serverZone = ZoneManager.findSmallestZone(targetLoc);
|
serverZone = ZoneManager.findSmallestZone(targetLoc);
|
||||||
switch (target.getObjectType()) {
|
switch (target.getObjectType()) {
|
||||||
|
|||||||
@@ -245,11 +245,17 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
HashSet<AbstractWorldObject> objectList =
|
HashSet<AbstractWorldObject> objectList =
|
||||||
WorldGrid.getObjectsInRangePartial(_currentLocation, _targetRange, _targetMask);
|
WorldGrid.getObjectsInRangePartial(_currentLocation, _targetRange, _targetMask);
|
||||||
|
int staticSkipped = 0;
|
||||||
|
|
||||||
// Iterate through array and remove objects from game world and database
|
// Iterate through array and remove objects from game world and database
|
||||||
|
|
||||||
for (AbstractWorldObject awo : objectList) {
|
for (AbstractWorldObject awo : objectList) {
|
||||||
|
|
||||||
|
if (awo.isStaticWorldObject()) {
|
||||||
|
staticSkipped++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (awo.getObjectType()) {
|
switch (awo.getObjectType()) {
|
||||||
case Building:
|
case Building:
|
||||||
removeBuilding(pc, (Building) awo);
|
removeBuilding(pc, (Building) awo);
|
||||||
@@ -266,7 +272,8 @@ 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() - staticSkipped) + " objects were removed in range " + _targetRange
|
||||||
|
+ ", " + staticSkipped + " static objects skipped");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ public class RemoveObjectCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
private void removeBuilding(PlayerCharacter pc, Building building) {
|
private void removeBuilding(PlayerCharacter pc, Building building) {
|
||||||
|
|
||||||
|
if (this.refuseStaticTarget(pc, building))
|
||||||
|
return;
|
||||||
|
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc());
|
Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||||
|
|
||||||
if (currentZone == null) {
|
if (currentZone == null) {
|
||||||
@@ -164,6 +167,9 @@ public class RemoveObjectCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
private void removeNPC(PlayerCharacter pc, NPC npc) {
|
private void removeNPC(PlayerCharacter pc, NPC npc) {
|
||||||
|
|
||||||
|
if (this.refuseStaticTarget(pc, npc))
|
||||||
|
return;
|
||||||
|
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc());
|
Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||||
if (currentZone == null) {
|
if (currentZone == null) {
|
||||||
this.throwbackError(pc, "Could not locate zone for player.");
|
this.throwbackError(pc, "Could not locate zone for player.");
|
||||||
@@ -196,6 +202,9 @@ public class RemoveObjectCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
private void removeMob(PlayerCharacter pc, Mob mob) {
|
private void removeMob(PlayerCharacter pc, Mob mob) {
|
||||||
|
|
||||||
|
if (this.refuseStaticTarget(pc, mob))
|
||||||
|
return;
|
||||||
|
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc());
|
Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||||
|
|
||||||
if (currentZone == null) {
|
if (currentZone == null) {
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ public class RenameCmd extends AbstractDevCmd {
|
|||||||
building = (Building) target;
|
building = (Building) target;
|
||||||
} else
|
} else
|
||||||
npc = getTargetAsNPC(pcSender);
|
npc = getTargetAsNPC(pcSender);
|
||||||
|
|
||||||
|
if (this.refuseStaticTarget(pcSender, npc) || this.refuseStaticTarget(pcSender, building))
|
||||||
|
return;
|
||||||
|
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
DbManager.NPCQueries.SET_PROPERTY(npc, "npc_name", args[0]);
|
DbManager.NPCQueries.SET_PROPERTY(npc, "npc_name", args[0]);
|
||||||
String name = args[0];
|
String name = args[0];
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ import engine.devcmd.AbstractDevCmd;
|
|||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
import engine.gameManager.ChatManager;
|
import engine.gameManager.ChatManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.math.Vector3f;
|
import engine.math.FastMath;
|
||||||
|
import engine.math.Quaternion;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
|
||||||
@@ -63,14 +64,12 @@ public class RotateCmd extends AbstractDevCmd {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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, (float) Math.toRadians(rot));
|
||||||
else if (target instanceof NPC)
|
else if (target instanceof NPC)
|
||||||
rotateNPC(pc, (NPC) target, rotation, false);
|
rotateNPC(pc, (NPC) target, (float) Math.toRadians(rot));
|
||||||
else if (target instanceof Mob)
|
else if (target instanceof Mob)
|
||||||
rotateMob(pc, (Mob) target, rotation, false);
|
rotateMob(pc, (Mob) target, (float) Math.toRadians(rot));
|
||||||
else
|
else
|
||||||
throwbackError(pc, "Target " + target.getObjectType()
|
throwbackError(pc, "Target " + target.getObjectType()
|
||||||
+ " is not a valid object type");
|
+ " is not a valid object type");
|
||||||
@@ -141,15 +140,13 @@ public class RotateCmd extends AbstractDevCmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f rotation = new Vector3f(0f, rot, 0f);
|
|
||||||
|
|
||||||
Building b;
|
Building b;
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
b = BuildingManager.getBuilding(id);
|
b = BuildingManager.getBuilding(id);
|
||||||
else
|
else
|
||||||
b = getTargetAsBuilding(pc);
|
b = getTargetAsBuilding(pc);
|
||||||
if (b != null) {
|
if (b != null) {
|
||||||
rotateBuilding(pc, b, rotation, rot, false);
|
rotateBuilding(pc, b, (float) Math.toRadians(rot));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +157,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, (float) Math.toRadians(rot));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +168,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, (float) Math.toRadians(rot));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throwbackError(pc, "Nothing found to rotate.");
|
throwbackError(pc, "Nothing found to rotate.");
|
||||||
@@ -185,40 +182,52 @@ public class RotateCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getUsageString() {
|
protected String _getUsageString() {
|
||||||
return "' /rotate [objectID] rotation' || ' /rot [objectID] rotation'";
|
return "' /rotate [objectID] degrees' || ' /rot [objectID] degrees' || ' /rotate face'";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rotateBuilding(PlayerCharacter pc, Building building, Vector3f rot, float orig, boolean faceDirection) {
|
private void rotateBuilding(PlayerCharacter pc, Building building, float yaw) {
|
||||||
if (!faceDirection)
|
|
||||||
rot.set(0.0f, (float) Math.sin(Math.toRadians(orig) / 2), 0.0f);
|
if (this.refuseStaticTarget(pc, building))
|
||||||
building.setRot(rot);
|
return;
|
||||||
building.setw((float) Math.abs(Math.cos(Math.toRadians(orig) / 2)));
|
|
||||||
|
building.setRotation(Quaternion.fromYaw(yaw));
|
||||||
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.getRotation().y);
|
||||||
DbManager.BuildingQueries.SET_PROPERTY(building, "w", building.getw());
|
DbManager.BuildingQueries.SET_PROPERTY(building, "w", building.getRotation().w);
|
||||||
ChatManager.chatSayInfo(pc,
|
ChatManager.chatSayInfo(pc,
|
||||||
"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, float yaw) {
|
||||||
npc.setRot(rot);
|
|
||||||
DbManager.NPCQueries.SET_PROPERTY(npc, "npc_rotation", rot.y);
|
if (this.refuseStaticTarget(pc, npc))
|
||||||
|
return;
|
||||||
|
|
||||||
|
npc.setRotation(characterRotation(yaw));
|
||||||
|
DbManager.NPCQueries.SET_PROPERTY(npc, "npc_rotation", npc.getRotation().w);
|
||||||
WorldGrid.updateObject(npc, pc);
|
WorldGrid.updateObject(npc, pc);
|
||||||
//no rotation for npc's in db currently
|
|
||||||
ChatManager.chatSayInfo(pc,
|
ChatManager.chatSayInfo(pc,
|
||||||
"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, float yaw) {
|
||||||
mob.setRot(rot);
|
|
||||||
DbManager.MobQueries.SET_PROPERTY(mob, "mob_rotation", rot.y);
|
if (this.refuseStaticTarget(pc, mob))
|
||||||
|
return;
|
||||||
|
|
||||||
|
mob.setRotation(characterRotation(yaw));
|
||||||
|
DbManager.MobQueries.SET_PROPERTY(mob, "mob_rotation", mob.getRotation().w);
|
||||||
WorldGrid.updateObject(mob, pc);
|
WorldGrid.updateObject(mob, pc);
|
||||||
//no rotation for mobs's in db currently
|
|
||||||
ChatManager.chatSayInfo(pc,
|
ChatManager.chatSayInfo(pc,
|
||||||
"Mob with ID " + mob.getObjectUUID() + " rotated");
|
"Mob with ID " + mob.getObjectUUID() + " rotated");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// npc_rotation and mob_rotation store w = cos θ/2, which reloads to the same yaw only for θ in [0, 2π).
|
||||||
|
private static Quaternion characterRotation(float yaw) {
|
||||||
|
return Quaternion.fromYaw((float) (yaw - FastMath.TWO_PI * Math.floor(yaw / FastMath.TWO_PI)));
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
@@ -230,19 +239,12 @@ public class RotateCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
float rotangle = faceDirection.getRotation();
|
float rotangle = faceDirection.getRotation();
|
||||||
|
|
||||||
float rot = (float) Math.toDegrees(rotangle);
|
|
||||||
|
|
||||||
if (rot > 180)
|
|
||||||
rot *= -1;
|
|
||||||
|
|
||||||
Vector3f buildingrotation = new Vector3f(0f, rot, 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, rotangle);
|
||||||
else if (target instanceof NPC)
|
else if (target instanceof NPC)
|
||||||
rotateNPC(pc, (NPC) target, rotation, true);
|
rotateNPC(pc, (NPC) target, rotangle);
|
||||||
else if (target instanceof Mob)
|
else if (target instanceof Mob)
|
||||||
rotateMob(pc, (Mob) target, rotation, true);
|
rotateMob(pc, (Mob) target, rotangle);
|
||||||
else
|
else
|
||||||
throwbackError(pc, "Target " + target.getObjectType()
|
throwbackError(pc, "Target " + target.getObjectType()
|
||||||
+ " is not a valid object type");
|
+ " is not a valid object type");
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ public class SetBuildingAltitudeCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
Building targetBuilding = (Building) target;
|
Building targetBuilding = (Building) target;
|
||||||
|
|
||||||
|
if (this.refuseStaticTarget(pc, targetBuilding))
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
float altitude = 0;
|
float altitude = 0;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ public class SetForceRenameCityCmd extends AbstractDevCmd {
|
|||||||
City city = City.getCity(zone.playerCityUUID);
|
City city = City.getCity(zone.playerCityUUID);
|
||||||
if (city == null)
|
if (city == null)
|
||||||
return;
|
return;
|
||||||
|
if (this.refuseStaticTarget(pc, city))
|
||||||
|
return;
|
||||||
city.setForceRename(rename);
|
city.setForceRename(rename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ public class SetGuildCmd extends AbstractDevCmd {
|
|||||||
targetNPC = getTargetAsNPC(pcSender);
|
targetNPC = getTargetAsNPC(pcSender);
|
||||||
targetGuild = Guild.getGuild(Integer.parseInt(args[0]));
|
targetGuild = Guild.getGuild(Integer.parseInt(args[0]));
|
||||||
|
|
||||||
|
if (this.refuseStaticTarget(pcSender, targetNPC))
|
||||||
|
return;
|
||||||
|
|
||||||
DbManager.NPCQueries.SET_PROPERTY(targetNPC, "npc_guildID", args[0]);
|
DbManager.NPCQueries.SET_PROPERTY(targetNPC, "npc_guildID", args[0]);
|
||||||
targetNPC.setGuild(targetGuild);
|
targetNPC.setGuild(targetGuild);
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ public class SetNpcNameCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
NPC npc = (NPC) target;
|
NPC npc = (NPC) target;
|
||||||
|
|
||||||
|
if (this.refuseStaticTarget(pc, npc))
|
||||||
|
return;
|
||||||
|
|
||||||
String name = words[0];
|
String name = words[0];
|
||||||
|
|
||||||
NPC.UpdateName(npc, name);
|
NPC.UpdateName(npc, name);
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ public class SetOwnerCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
_targetBuilding = getTargetAsBuilding(pcSender);
|
_targetBuilding = getTargetAsBuilding(pcSender);
|
||||||
|
|
||||||
|
if (this.refuseStaticTarget(pcSender, _targetBuilding))
|
||||||
|
return;
|
||||||
|
|
||||||
// if it's a tol change ownership of the city
|
// if it's a tol change ownership of the city
|
||||||
|
|
||||||
if (_targetBuilding.getBlueprint() != null &&
|
if (_targetBuilding.getBlueprint() != null &&
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ public class SetRankCmd extends AbstractDevCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
|
|
||||||
|
if (this.refuseStaticTarget(player, target))
|
||||||
|
return;
|
||||||
|
|
||||||
switch (target.getObjectType()) {
|
switch (target.getObjectType()) {
|
||||||
case Building:
|
case Building:
|
||||||
Building targetBuilding = (Building) target;
|
Building targetBuilding = (Building) target;
|
||||||
@@ -99,6 +103,9 @@ public class SetRankCmd extends AbstractDevCmd {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.refuseStaticTarget(player, targetBuilding))
|
||||||
|
return;
|
||||||
|
|
||||||
Blueprint blueprint = targetBuilding.getBlueprint();
|
Blueprint blueprint = targetBuilding.getBlueprint();
|
||||||
|
|
||||||
if (blueprint == null) {
|
if (blueprint == null) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import engine.gameManager.LootManager;
|
|||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.loot.BootySetEntry;
|
import engine.loot.BootySetEntry;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
@@ -34,10 +35,10 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
|||||||
if (mob.bootySet != 0) {
|
if (mob.bootySet != 0) {
|
||||||
for (BootySetEntry entry : LootManager._bootySetMap.get(mob.bootySet)) {
|
for (BootySetEntry entry : LootManager._bootySetMap.get(mob.bootySet)) {
|
||||||
|
|
||||||
ItemTemplate template = ItemTemplate.templates.get(entry.templateID);
|
CObjectTemplate template = CObjectTemplate.lookup(entry.templateID);
|
||||||
|
|
||||||
if (template != null)
|
if (template != null)
|
||||||
output += "[" + entry.bootyType + "] " + template.item_base_name + " [Chance] " + entry.dropChance + newline;
|
output += "[" + entry.bootyType + "] " + template.getItemBaseName() + " [Chance] " + entry.dropChance + newline;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
|||||||
try {
|
try {
|
||||||
mob.loadInventory();
|
mob.loadInventory();
|
||||||
for (Item lootItem : mob.charItemManager.getInventory()) {
|
for (Item lootItem : mob.charItemManager.getInventory()) {
|
||||||
switch (lootItem.template.item_type) {
|
switch (lootItem.template.getItemType()) {
|
||||||
case EMPLOYMENTCONTRACT: //CONTRACT
|
case EMPLOYMENTCONTRACT: //CONTRACT
|
||||||
Contracts.add(lootItem);
|
Contracts.add(lootItem);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -118,18 +118,17 @@ public class aiInfoCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
ArrayList<RunePowerEntry> powerEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.getMobBaseID()));
|
ArrayList<RunePowerEntry> powerEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.getMobBaseID()));
|
||||||
|
|
||||||
// Additional powers may come from the contract ID. This is to support
|
// Player guards also cast their captain contract's powers, irrespective of the mobbase used.
|
||||||
// powers for player guards irrespective of the mobbase used.
|
|
||||||
|
|
||||||
if (mob.isPlayerGuard()) {
|
if (mob.isPlayerGuard()) {
|
||||||
|
|
||||||
ArrayList<RunePowerEntry> contractEntries = new ArrayList<>();
|
ArrayList<RunePowerEntry> contractEntries = new ArrayList<>();
|
||||||
|
|
||||||
if (mob.contract != null)
|
if (mob.contract != null)
|
||||||
contractEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.contractUUID));
|
contractEntries = new ArrayList<>(mbEnums.MinionType.getCaptainPowers(mob.contractUUID));
|
||||||
|
|
||||||
if (mob.agentType.equals(mbEnums.AIAgentType.GUARDMINION))
|
if (mob.agentType.equals(mbEnums.AIAgentType.GUARDMINION))
|
||||||
contractEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.guardCaptain.contractUUID));
|
contractEntries = new ArrayList<>(mbEnums.MinionType.getCaptainPowers(mob.guardCaptain.contractUUID));
|
||||||
|
|
||||||
powerEntries.addAll(contractEntries);
|
powerEntries.addAll(contractEntries);
|
||||||
|
|
||||||
|
|||||||
@@ -22,15 +22,16 @@ import engine.mbEnums.BuildingGroup;
|
|||||||
import engine.mbEnums.GameObjectType;
|
import engine.mbEnums.GameObjectType;
|
||||||
import engine.net.client.msg.ErrorPopupMsg;
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ public enum BuildingManager {
|
|||||||
public static HashMap<Integer, ConcurrentHashMap<Integer, BuildingFriends>> _buildingFriends = new HashMap<>();
|
public static HashMap<Integer, ConcurrentHashMap<Integer, BuildingFriends>> _buildingFriends = new HashMap<>();
|
||||||
public static HashMap<Integer, ConcurrentHashMap<Integer, Condemned>> _buildingCondemned = new HashMap<>();
|
public static HashMap<Integer, ConcurrentHashMap<Integer, Condemned>> _buildingCondemned = new HashMap<>();
|
||||||
public static HashMap<Integer, ArrayList<Vector3fImmutable>> _buildingPatrolPoints = new HashMap<>();
|
public static HashMap<Integer, ArrayList<Vector3fImmutable>> _buildingPatrolPoints = new HashMap<>();
|
||||||
|
public static HashSet<Integer> _npcBuildingOwners = new HashSet<>();
|
||||||
|
|
||||||
public static int getAvailableSlot(Building building) {
|
public static int getAvailableSlot(Building building) {
|
||||||
|
|
||||||
@@ -200,31 +202,31 @@ public enum BuildingManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemTemplate template = ItemTemplate.templates.get(1705032); // Elan Stone
|
CObjectTemplate template = CObjectTemplate.lookup(1705032); // Elan Stone
|
||||||
|
|
||||||
if (!player.charItemManager.hasRoomInventory(template.item_wt))
|
if (!player.charItemManager.hasRoomInventory(template.getItemWt()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!ItemManager.MakeItemForPlayer(template.template_id, player, amount))
|
if (!ItemManager.MakeItemForPlayer(template.getTemplateId(), player, amount))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
shrine.setFavors(0);
|
shrine.setFavors(0);
|
||||||
break;
|
break;
|
||||||
case WAREHOUSE:
|
case WAREHOUSE:
|
||||||
|
|
||||||
City city = building.getCity();
|
Warehouse warehouse = Warehouse.destroyedWarehouses.get(building.getObjectUUID());
|
||||||
|
|
||||||
if (city == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
Warehouse warehouse = city.warehouse;
|
|
||||||
|
|
||||||
if (warehouse == null)
|
if (warehouse == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (mbEnums.ResourceType resourceType : EnumSet.allOf(mbEnums.ResourceType.class)) {
|
for (mbEnums.ResourceType resourceType : EnumSet.allOf(mbEnums.ResourceType.class)) {
|
||||||
|
|
||||||
if (!player.charItemManager.hasRoomInventory(resourceType.template.item_wt)) {
|
CObjectTemplate resourceTemplate = CObjectTemplate.lookup(resourceType.templateID);
|
||||||
|
|
||||||
|
if (resourceTemplate == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!player.charItemManager.hasRoomInventory(resourceTemplate.getItemWt())) {
|
||||||
ChatManager.chatSystemInfo(player, "You can not carry any more of that item.");
|
ChatManager.chatSystemInfo(player, "You can not carry any more of that item.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -242,6 +244,9 @@ public enum BuildingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Warehouse.isEmpty(warehouse))
|
||||||
|
Warehouse.destroyedWarehouses.remove(building.getObjectUUID());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -275,8 +280,7 @@ public enum BuildingManager {
|
|||||||
|
|
||||||
if (building == null)
|
if (building == null)
|
||||||
return;
|
return;
|
||||||
Instant instant = (upgradeDateTime == null) ? null : upgradeDateTime.atZone(ZoneId.systemDefault()).toInstant();
|
if (!DbManager.BuildingQueries.updateBuildingUpgradeTime(upgradeDateTime, building, rankCost)) {
|
||||||
if (!DbManager.BuildingQueries.updateBuildingUpgradeTime(instant, building, rankCost)) {
|
|
||||||
Logger.error("Failed to set upgradeTime for building " + building.getObjectUUID());
|
Logger.error("Failed to set upgradeTime for building " + building.getObjectUUID());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import engine.net.client.ClientConnection;
|
|||||||
import engine.net.client.handlers.ClientAdminCommandMsgHandler;
|
import engine.net.client.handlers.ClientAdminCommandMsgHandler;
|
||||||
import engine.net.client.msg.chat.*;
|
import engine.net.client.msg.chat.*;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import engine.server.world.WorldServer;
|
import engine.server.world.WorldServer;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
@@ -535,12 +536,12 @@ public enum ChatManager {
|
|||||||
if (item != null) //Steal
|
if (item != null) //Steal
|
||||||
if (success) {
|
if (success) {
|
||||||
String name = "";
|
String name = "";
|
||||||
if (item.template.item_type.equals(mbEnums.ItemType.GOLD))
|
if (item.template.getItemType().equals(mbEnums.ItemType.GOLD))
|
||||||
name = amount + " gold ";
|
name = amount + " gold ";
|
||||||
else {
|
else {
|
||||||
String vowels = "aeiou";
|
String vowels = "aeiou";
|
||||||
ItemTemplate template = ItemTemplate.templates.get(item.templateID);
|
CObjectTemplate template = CObjectTemplate.lookup(item.templateID);
|
||||||
String iName = template.item_base_name;
|
String iName = template.getItemBaseName();
|
||||||
if (iName.length() > 0)
|
if (iName.length() > 0)
|
||||||
if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0)
|
if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0)
|
||||||
name = "an " + iName + ' ';
|
name = "an " + iName + ' ';
|
||||||
|
|||||||
@@ -14,9 +14,12 @@ import engine.jobs.AttackJob;
|
|||||||
import engine.jobs.DeferredPowerJob;
|
import engine.jobs.DeferredPowerJob;
|
||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.PowerProjectileMsg;
|
||||||
import engine.net.client.msg.TargetedActionMsg;
|
import engine.net.client.msg.TargetedActionMsg;
|
||||||
import engine.net.client.msg.UpdateStateMsg;
|
import engine.net.client.msg.UpdateStateMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
|
import engine.parsers.objects.RuneTemplate;
|
||||||
import engine.powers.DamageShield;
|
import engine.powers.DamageShield;
|
||||||
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
||||||
import engine.powers.effectmodifiers.WeaponProcEffectModifier;
|
import engine.powers.effectmodifiers.WeaponProcEffectModifier;
|
||||||
@@ -25,6 +28,7 @@ import org.pmw.tinylog.Logger;
|
|||||||
|
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
@@ -91,25 +95,25 @@ public enum CombatManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mainWeapon == null && offWeapon != null && !offWeapon.template.item_skill_used.equals("Block")) {
|
if (mainWeapon == null && offWeapon != null && !offWeapon.template.getItemSkillUsed().equals("Block")) {
|
||||||
//swing left hand only
|
//swing left hand only
|
||||||
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD);
|
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_used.equals("Block")) {
|
if (mainWeapon == null && offWeapon != null && offWeapon.template.getItemSkillUsed().equals("Block")) {
|
||||||
//no weapon equipped with a shield, punch with one hand
|
//no weapon equipped with a shield, punch with one hand
|
||||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_used.equals("Block")) {
|
if (mainWeapon != null && offWeapon != null && offWeapon.template.getItemSkillUsed().equals("Block")) {
|
||||||
//one weapon equipped with a shield, swing with one hand
|
//one weapon equipped with a shield, swing with one hand
|
||||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mainWeapon != null && offWeapon != null && !offWeapon.template.item_skill_used.equals("Block")) {
|
if (mainWeapon != null && offWeapon != null && !offWeapon.template.getItemSkillUsed().equals("Block")) {
|
||||||
//two weapons equipped, swing both hands
|
//two weapons equipped, swing both hands
|
||||||
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
|
||||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter))
|
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter))
|
||||||
@@ -145,12 +149,20 @@ public enum CombatManager {
|
|||||||
if (bonus != null)
|
if (bonus != null)
|
||||||
rangeMod += bonus.getFloatPercentAll(mbEnums.ModType.WeaponRange, mbEnums.SourceType.None);
|
rangeMod += bonus.getFloatPercentAll(mbEnums.ModType.WeaponRange, mbEnums.SourceType.None);
|
||||||
|
|
||||||
attackRange += weapon.template.item_weapon_max_range * rangeMod;
|
attackRange += engine.parsers.objects.ItemTemplate.getWeapon(weapon.templateID).weapon_max_range * rangeMod;
|
||||||
|
} else if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) {
|
||||||
|
|
||||||
|
//unarmed mob, add the natural attack range from its rune (0 for most melee mobs)
|
||||||
|
|
||||||
|
if (bonus != null)
|
||||||
|
rangeMod += bonus.getFloatPercentAll(mbEnums.ModType.WeaponRange, mbEnums.SourceType.None);
|
||||||
|
|
||||||
|
attackRange += getNaturalAttackRange(attacker, slot) * rangeMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
||||||
if (((Mob) attacker).isSiege())
|
if (((Mob) attacker).isSiege())
|
||||||
attackRange = 300;
|
attackRange = getSiegeRange((Mob) attacker);
|
||||||
|
|
||||||
float distanceSquared = attacker.loc.distanceSquared(target.loc);
|
float distanceSquared = attacker.loc.distanceSquared(target.loc);
|
||||||
|
|
||||||
@@ -202,7 +214,7 @@ public enum CombatManager {
|
|||||||
|
|
||||||
if (weapon != null) {
|
if (weapon != null) {
|
||||||
|
|
||||||
float wepSpeed = (int) (weapon.template.item_weapon_wepspeed);
|
float wepSpeed = (int) (engine.parsers.objects.ItemTemplate.getWeapon(weapon.templateID).weapon_wepspeed);
|
||||||
|
|
||||||
if (weapon.getBonusPercent(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None) != 0f) //add weapon speed bonus
|
if (weapon.getBonusPercent(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None) != 0f) //add weapon speed bonus
|
||||||
wepSpeed *= (1 + weapon.getBonus(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None));
|
wepSpeed *= (1 + weapon.getBonus(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None));
|
||||||
@@ -214,6 +226,22 @@ public enum CombatManager {
|
|||||||
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
|
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
|
||||||
|
|
||||||
delay = (long)wepSpeed * 100L;
|
delay = (long)wepSpeed * 100L;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
//unarmed, use the natural attack speed from the mob or race rune
|
||||||
|
|
||||||
|
float naturalSpeed = getNaturalAttackSpeed(attacker, slot);
|
||||||
|
|
||||||
|
if (naturalSpeed > 0) {
|
||||||
|
|
||||||
|
if (attacker.getBonuses() != null && attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None) != 0f) //add effects speed bonus
|
||||||
|
naturalSpeed *= (1 + attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None));
|
||||||
|
|
||||||
|
if (naturalSpeed < 10)
|
||||||
|
naturalSpeed = 10;
|
||||||
|
|
||||||
|
delay = (long) naturalSpeed * 100L;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
|
||||||
@@ -232,7 +260,8 @@ public enum CombatManager {
|
|||||||
|
|
||||||
|
|
||||||
//handle retaliate
|
//handle retaliate
|
||||||
if (AbstractCharacter.IsAbstractCharacter(target)) {
|
//siege engines only retaliate on damage, see AbstractCharacter.modifyHealth
|
||||||
|
if (AbstractCharacter.IsAbstractCharacter(target) && !(target.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob) target).isSiege())) {
|
||||||
if (((AbstractCharacter) target).combatTarget == null || !((AbstractCharacter) target).combatTarget.isAlive()) {
|
if (((AbstractCharacter) target).combatTarget == null || !((AbstractCharacter) target).combatTarget.isAlive()) {
|
||||||
((AbstractCharacter) target).combatTarget = attacker;
|
((AbstractCharacter) target).combatTarget = attacker;
|
||||||
if (target.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && ((AbstractCharacter) target).isCombat())
|
if (target.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && ((AbstractCharacter) target).isCombat())
|
||||||
@@ -244,13 +273,13 @@ public enum CombatManager {
|
|||||||
if (weapon != null && !attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) {
|
if (weapon != null && !attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) {
|
||||||
//check if Out of Stamina
|
//check if Out of Stamina
|
||||||
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) {
|
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) {
|
||||||
if (attacker.getStamina() < (weapon.template.item_wt / 3f)) {
|
if (attacker.getStamina() < (weapon.template.getItemWt() / 3f)) {
|
||||||
//set auto attack job
|
//set auto attack job
|
||||||
setAutoAttackJob(attacker, slot, delay);
|
setAutoAttackJob(attacker, slot, delay);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float stam = weapon.template.item_wt / 3f;
|
float stam = weapon.template.getItemWt() / 3f;
|
||||||
stam = (stam < 1) ? 1 : stam;
|
stam = (stam < 1) ? 1 : stam;
|
||||||
attacker.modifyStamina(-(stam), attacker, true);
|
attacker.modifyStamina(-(stam), attacker, true);
|
||||||
} else
|
} else
|
||||||
@@ -319,7 +348,7 @@ public enum CombatManager {
|
|||||||
DispatchManager.sendToAllInRange(attacker, msg);
|
DispatchManager.sendToAllInRange(attacker, msg);
|
||||||
|
|
||||||
//we need to send the animation even if the attacker misses
|
//we need to send the animation even if the attacker misses
|
||||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
|
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon == null ? null : weapon.template, null, slot));
|
||||||
DispatchManager.sendToAllInRange(target, cmm);
|
DispatchManager.sendToAllInRange(target, cmm);
|
||||||
|
|
||||||
//set auto attack job
|
//set auto attack job
|
||||||
@@ -359,7 +388,7 @@ public enum CombatManager {
|
|||||||
DispatchManager.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
DispatchManager.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||||
|
|
||||||
//we need to send the animation even if the attacker misses
|
//we need to send the animation even if the attacker misses
|
||||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
|
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon == null ? null : weapon.template, null, slot));
|
||||||
DispatchManager.sendToAllInRange(target, cmm);
|
DispatchManager.sendToAllInRange(target, cmm);
|
||||||
//set auto attack job
|
//set auto attack job
|
||||||
setAutoAttackJob(attacker, slot, delay);
|
setAutoAttackJob(attacker, slot, delay);
|
||||||
@@ -390,7 +419,7 @@ public enum CombatManager {
|
|||||||
if (((Mob) attacker).isSiege())
|
if (((Mob) attacker).isSiege())
|
||||||
damageType = mbEnums.DamageType.SIEGE;
|
damageType = mbEnums.DamageType.SIEGE;
|
||||||
} else {
|
} else {
|
||||||
damageType = (mbEnums.DamageType) attacker.charItemManager.getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0];
|
damageType = engine.parsers.objects.ItemTemplate.getWeapon(attacker.charItemManager.getEquipped().get(slot).templateID).weapon_damage.get(0).damage_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get resists
|
//get resists
|
||||||
@@ -447,7 +476,7 @@ public enum CombatManager {
|
|||||||
if (resists.immuneTo(damageType)) {
|
if (resists.immuneTo(damageType)) {
|
||||||
//set auto attack job
|
//set auto attack job
|
||||||
//we need to send the animation even if the attacker misses
|
//we need to send the animation even if the attacker misses
|
||||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
|
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon == null ? null : weapon.template, null, slot));
|
||||||
DispatchManager.sendToAllInRange(target, cmm);
|
DispatchManager.sendToAllInRange(target, cmm);
|
||||||
setAutoAttackJob(attacker, slot, delay);
|
setAutoAttackJob(attacker, slot, delay);
|
||||||
return;
|
return;
|
||||||
@@ -479,6 +508,15 @@ public enum CombatManager {
|
|||||||
}
|
}
|
||||||
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim);
|
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim);
|
||||||
DispatchManager.sendToAllInRange(target, cmm);
|
DispatchManager.sendToAllInRange(target, cmm);
|
||||||
|
|
||||||
|
//siege projectile is sent once per hit, not per AI pulse
|
||||||
|
|
||||||
|
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob) attacker).isSiege()
|
||||||
|
&& target.getObjectType().equals(mbEnums.GameObjectType.Building)) {
|
||||||
|
PowerProjectileMsg ppm = new PowerProjectileMsg(attacker, target);
|
||||||
|
ppm.setRange(50);
|
||||||
|
DispatchManager.dispatchMsgToInterestArea(attacker, ppm, mbEnums.DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,13 +580,14 @@ public enum CombatManager {
|
|||||||
target.setCombatTarget(attacker);
|
target.setCombatTarget(attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getSwingAnimation(ItemTemplate wb, DeferredPowerJob dpj, mbEnums.EquipSlotType slot) {
|
public static int getSwingAnimation(CObjectTemplate wb, DeferredPowerJob dpj, mbEnums.EquipSlotType slot) {
|
||||||
|
|
||||||
//No weapon, return default animation
|
//No weapon, return default animation
|
||||||
if (wb == null)
|
if (wb == null)
|
||||||
return 75;
|
return 75;
|
||||||
|
|
||||||
int token;
|
int token;
|
||||||
|
engine.parsers.objects.ItemTemplate.Weapon weapon = engine.parsers.objects.ItemTemplate.getWeapon(wb.getTemplateId());
|
||||||
|
|
||||||
if (dpj != null) {
|
if (dpj != null) {
|
||||||
|
|
||||||
@@ -559,47 +598,30 @@ public enum CombatManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Item has no equipment slots and should not try to return an animation, return default instead
|
//Item has no equipment slots and should not try to return an animation, return default instead
|
||||||
if (wb.item_eq_slots_or == null || wb.item_eq_slots_or.isEmpty()) {
|
if (wb.getItemEqSlotsOr().isEmpty()) {
|
||||||
return 75;
|
return 75;
|
||||||
}
|
}
|
||||||
|
|
||||||
//declare variables
|
//declare variables
|
||||||
int anim;
|
mbEnums.EquipSlotType hand;
|
||||||
int random;
|
ArrayList<int[]> anims;
|
||||||
|
|
||||||
//Item can only be equipped in one slot, return animation for that slot
|
//Item can only be equipped in one slot, use the animations for that slot
|
||||||
if (wb.item_eq_slots_or.size() == 1) {
|
if (wb.getItemEqSlotsOr().size() == 1)
|
||||||
if (wb.item_eq_slots_or.iterator().next().equals(mbEnums.EquipSlotType.RHELD)) {
|
hand = wb.getItemEqSlotsOr().iterator().next();
|
||||||
anim = wb.weapon_attack_anim_right.get(0)[0];
|
else
|
||||||
if (dpj != null) {
|
hand = slot;
|
||||||
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size());
|
|
||||||
anim = wb.weapon_attack_anim_right.get(random)[0];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
anim = wb.weapon_attack_anim_left.get(0)[0];
|
|
||||||
if (dpj != null) {
|
|
||||||
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size());
|
|
||||||
anim = wb.weapon_attack_anim_left.get(random)[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return anim;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Item can be equipped in either hand, and should have animation sets for each hand
|
anims = hand.equals(mbEnums.EquipSlotType.RHELD) ? weapon.weapon_attack_anim_right : weapon.weapon_attack_anim_left;
|
||||||
if (slot.equals(mbEnums.EquipSlotType.RHELD)) {
|
|
||||||
anim = wb.weapon_attack_anim_right.get(0)[0];
|
// Many cache weapons have no swing anims; GUESS: the client falls back to the default too
|
||||||
if (dpj != null) {
|
if (anims.isEmpty())
|
||||||
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size());
|
return 75;
|
||||||
anim = wb.weapon_attack_anim_right.get(random)[0];
|
|
||||||
}
|
if (dpj != null)
|
||||||
} else {
|
return anims.get(ThreadLocalRandom.current().nextInt(anims.size()))[0];
|
||||||
anim = wb.weapon_attack_anim_left.get(0)[0];
|
|
||||||
if (dpj != null) {
|
return anims.get(0)[0];
|
||||||
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size());
|
|
||||||
anim = wb.weapon_attack_anim_left.get(random)[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return anim;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getPassiveAnimation(mbEnums.PassiveType passiveType) {
|
public static int getPassiveAnimation(mbEnums.PassiveType passiveType) {
|
||||||
@@ -636,6 +658,76 @@ public enum CombatManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float getNaturalAttackSpeed(AbstractCharacter attacker, mbEnums.EquipSlotType slot) {
|
||||||
|
|
||||||
|
// Returns the rune natural attack speed (x100 ms) for this hand, or 0 if the rune has none.
|
||||||
|
|
||||||
|
float[] attack = getNaturalAttack(attacker, slot);
|
||||||
|
|
||||||
|
if (attack == null || attack.length < 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return attack[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getNaturalAttackRange(AbstractCharacter attacker, mbEnums.EquipSlotType slot) {
|
||||||
|
|
||||||
|
// Returns the rune natural attack range for this hand, or 0 if the rune has none.
|
||||||
|
|
||||||
|
float[] attack = getNaturalAttack(attacker, slot);
|
||||||
|
|
||||||
|
if (attack == null || attack.length < 2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return attack[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getSiegeRange(Mob siegeEngine) {
|
||||||
|
|
||||||
|
// Siege engines use the range from their rune natural attack (350 for all three), 300 if the rune has none.
|
||||||
|
|
||||||
|
float range = getNaturalAttackRange(siegeEngine, mbEnums.EquipSlotType.RHELD);
|
||||||
|
|
||||||
|
if (range <= 0)
|
||||||
|
return 300;
|
||||||
|
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float[] getNaturalAttack(AbstractCharacter attacker, mbEnums.EquipSlotType slot) {
|
||||||
|
|
||||||
|
// Returns the rune natural attack entry for this hand, or null if the rune has none.
|
||||||
|
// Mobs use their mobbase rune, players use their race rune.
|
||||||
|
|
||||||
|
int runeID;
|
||||||
|
RuneTemplate rune;
|
||||||
|
int hand = slot.equals(mbEnums.EquipSlotType.LHELD) ? 2 : 1;
|
||||||
|
|
||||||
|
switch (attacker.getObjectType()) {
|
||||||
|
case Mob:
|
||||||
|
runeID = ((Mob) attacker).loadID;
|
||||||
|
break;
|
||||||
|
case PlayerCharacter:
|
||||||
|
runeID = ((PlayerCharacter) attacker).getRaceID();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
rune = RuneTemplate._runes.get(runeID);
|
||||||
|
|
||||||
|
if (rune == null || rune.rune_naturalattacks.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
for (float[] attack : rune.rune_naturalattacks)
|
||||||
|
if (attack.length > 3 && (int) attack[3] == hand)
|
||||||
|
return attack;
|
||||||
|
|
||||||
|
// No entry for this hand, fall back to the first natural attack
|
||||||
|
|
||||||
|
return rune.rune_naturalattacks.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
public static int calculatePetDamage(AbstractCharacter agent) {
|
public static int calculatePetDamage(AbstractCharacter agent) {
|
||||||
//damage calc for pet
|
//damage calc for pet
|
||||||
float range;
|
float range;
|
||||||
|
|||||||
@@ -71,10 +71,12 @@ public enum ConfigManager {
|
|||||||
MB_WORLD_KEYCLONE_MAX,
|
MB_WORLD_KEYCLONE_MAX,
|
||||||
MB_USE_RUINS,
|
MB_USE_RUINS,
|
||||||
MB_RULESET,
|
MB_RULESET,
|
||||||
|
MB_STATIC_BUILDINGS,
|
||||||
|
|
||||||
// Mobile AI modifiers
|
// Mobile AI modifiers
|
||||||
MB_AI_CAST_FREQUENCY,
|
MB_AI_CAST_FREQUENCY,
|
||||||
MB_AI_AGGRO_RANGE,
|
MB_AI_AGGRO_RANGE,
|
||||||
|
MB_MINION_SPAWN_TIME,
|
||||||
|
|
||||||
//drop rates
|
//drop rates
|
||||||
MB_NORMAL_EXP_RATE,
|
MB_NORMAL_EXP_RATE,
|
||||||
@@ -165,14 +167,6 @@ public enum ConfigManager {
|
|||||||
|
|
||||||
regex.put(MB_LOGIN_FNAME_REGEX, Pattern.compile(MB_LOGIN_FNAME_REGEX.getValue()));
|
regex.put(MB_LOGIN_FNAME_REGEX, Pattern.compile(MB_LOGIN_FNAME_REGEX.getValue()));
|
||||||
|
|
||||||
Logger.info("Loading WPAK data");
|
|
||||||
|
|
||||||
// *** Needs powermanager collection
|
|
||||||
// defined before activation.
|
|
||||||
// EffectsParser.parseWpakFile();
|
|
||||||
// PowersParser.parseWpakFile();
|
|
||||||
// PowerActionParser.parseWpakFile();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,15 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public enum DbManager {
|
public enum DbManager {
|
||||||
DBMANAGER;
|
DBMANAGER;
|
||||||
|
|
||||||
|
// Static world IDs count down from -2 (-1 means "not found"); runtime negative IDs start below them.
|
||||||
|
public static final int RUNTIME_ID_START = -1_000_000;
|
||||||
|
private static final AtomicInteger lastStaticID = new AtomicInteger(-1);
|
||||||
|
|
||||||
public static final dbAccountHandler AccountQueries = new dbAccountHandler();
|
public static final dbAccountHandler AccountQueries = new dbAccountHandler();
|
||||||
public static final dbBaneHandler BaneQueries = new dbBaneHandler();
|
public static final dbBaneHandler BaneQueries = new dbBaneHandler();
|
||||||
|
|
||||||
@@ -44,10 +49,8 @@ public enum DbManager {
|
|||||||
// Omg refactor this out, somebody!
|
// Omg refactor this out, somebody!
|
||||||
public static final dbCSSessionHandler CSSessionQueries = new dbCSSessionHandler();
|
public static final dbCSSessionHandler CSSessionQueries = new dbCSSessionHandler();
|
||||||
public static final dbEnchantmentHandler EnchantmentQueries = new dbEnchantmentHandler();
|
public static final dbEnchantmentHandler EnchantmentQueries = new dbEnchantmentHandler();
|
||||||
public static final dbEffectsResourceCostHandler EffectsResourceCostsQueries = new dbEffectsResourceCostHandler();
|
|
||||||
public static final dbGuildHandler GuildQueries = new dbGuildHandler();
|
public static final dbGuildHandler GuildQueries = new dbGuildHandler();
|
||||||
public static final dbItemHandler ItemQueries = new dbItemHandler();
|
public static final dbItemHandler ItemQueries = new dbItemHandler();
|
||||||
public static final dbKitHandler KitQueries = new dbKitHandler();
|
|
||||||
public static final dbLootHandler LootQueries = new dbLootHandler();
|
public static final dbLootHandler LootQueries = new dbLootHandler();
|
||||||
public static final dbMenuHandler MenuQueries = new dbMenuHandler();
|
public static final dbMenuHandler MenuQueries = new dbMenuHandler();
|
||||||
public static final dbMineHandler MineQueries = new dbMineHandler();
|
public static final dbMineHandler MineQueries = new dbMineHandler();
|
||||||
@@ -57,9 +60,6 @@ public enum DbManager {
|
|||||||
public static final dbPlayerCharacterHandler PlayerCharacterQueries = new dbPlayerCharacterHandler();
|
public static final dbPlayerCharacterHandler PlayerCharacterQueries = new dbPlayerCharacterHandler();
|
||||||
public static final dbPromotionClassHandler PromotionQueries = new dbPromotionClassHandler();
|
public static final dbPromotionClassHandler PromotionQueries = new dbPromotionClassHandler();
|
||||||
public static final dbRaceHandler RaceQueries = new dbRaceHandler();
|
public static final dbRaceHandler RaceQueries = new dbRaceHandler();
|
||||||
public static final dbResistHandler ResistQueries = new dbResistHandler();
|
|
||||||
public static final dbRuneBaseAttributeHandler RuneBaseAttributeQueries = new dbRuneBaseAttributeHandler();
|
|
||||||
public static final dbRuneBaseEffectHandler RuneBaseEffectQueries = new dbRuneBaseEffectHandler();
|
|
||||||
public static final dbRuneBaseHandler RuneBaseQueries = new dbRuneBaseHandler();
|
public static final dbRuneBaseHandler RuneBaseQueries = new dbRuneBaseHandler();
|
||||||
public static final dbSkillBaseHandler SkillsBaseQueries = new dbSkillBaseHandler();
|
public static final dbSkillBaseHandler SkillsBaseQueries = new dbSkillBaseHandler();
|
||||||
public static final dbSkillReqHandler SkillReqQueries = new dbSkillReqHandler();
|
public static final dbSkillReqHandler SkillReqQueries = new dbSkillReqHandler();
|
||||||
@@ -69,13 +69,59 @@ public enum DbManager {
|
|||||||
public static final dbBlueprintHandler BlueprintQueries = new dbBlueprintHandler();
|
public static final dbBlueprintHandler BlueprintQueries = new dbBlueprintHandler();
|
||||||
public static final dbShrineHandler ShrineQueries = new dbShrineHandler();
|
public static final dbShrineHandler ShrineQueries = new dbShrineHandler();
|
||||||
public static final dbRunegateHandler RunegateQueries = new dbRunegateHandler();
|
public static final dbRunegateHandler RunegateQueries = new dbRunegateHandler();
|
||||||
|
public static final dbStaticWorldHandler StaticWorldQueries = new dbStaticWorldHandler();
|
||||||
|
|
||||||
public static final dbPowerHandler PowerQueries = new dbPowerHandler();
|
|
||||||
public static final dbPetitionHandler PetitionQueries = new dbPetitionHandler();
|
public static final dbPetitionHandler PetitionQueries = new dbPetitionHandler();
|
||||||
private static final EnumMap<GameObjectType, ConcurrentHashMap<Integer, AbstractGameObject>> objectCache = new EnumMap<>(GameObjectType.class);
|
private static final EnumMap<GameObjectType, ConcurrentHashMap<Integer, AbstractGameObject>> objectCache = new EnumMap<>(GameObjectType.class);
|
||||||
public static Hasher hasher;
|
public static Hasher hasher;
|
||||||
private static HikariDataSource connectionPool = null;
|
private static HikariDataSource connectionPool = null;
|
||||||
|
|
||||||
|
// Only the static world factories may call this, in the fixed load order (W2); never renumber.
|
||||||
|
// The key names the object from the data files alone (findings §5, manifest format) and must be unique.
|
||||||
|
public static int nextStaticID(GameObjectType objectType, String manifestKey) {
|
||||||
|
|
||||||
|
int staticID = lastStaticID.decrementAndGet();
|
||||||
|
|
||||||
|
if (staticID <= RUNTIME_ID_START)
|
||||||
|
throw new IllegalStateException("Static world ID " + staticID + " reached the runtime ID range at " + RUNTIME_ID_START);
|
||||||
|
|
||||||
|
StaticManifest.addEntry(staticID, objectType, manifestKey);
|
||||||
|
|
||||||
|
return staticID;
|
||||||
|
}
|
||||||
|
|
||||||
|
// W3: static world objects never reach the DB. Logs the refused handler method and its caller.
|
||||||
|
public static boolean refuseStaticWrite(AbstractWorldObject worldObject) {
|
||||||
|
|
||||||
|
StackTraceElement[] stack;
|
||||||
|
String caller;
|
||||||
|
int frame = 1;
|
||||||
|
|
||||||
|
if (worldObject == null || !worldObject.isStaticWorldObject())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
stack = new Throwable().getStackTrace();
|
||||||
|
|
||||||
|
while (frame < stack.length - 1 && stack[frame].getClassName().equals(DbManager.class.getName()))
|
||||||
|
frame++;
|
||||||
|
|
||||||
|
caller = (frame + 1 < stack.length) ? stack[frame + 1].toString() : "unknown";
|
||||||
|
|
||||||
|
Logger.error("Refused DB write for static " + worldObject.getObjectType() + " " + worldObject.getObjectUUID()
|
||||||
|
+ " in " + stack[frame] + " called from " + caller);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean refuseStaticWrite(GameObjectType objectType, long objectUUID) {
|
||||||
|
|
||||||
|
AbstractGameObject gameObject = getFromCache(objectType, (int) objectUUID);
|
||||||
|
|
||||||
|
if (gameObject instanceof AbstractWorldObject)
|
||||||
|
return refuseStaticWrite((AbstractWorldObject) gameObject);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static AbstractGameObject getObject(GameObjectType objectType, int objectUUID) {
|
public static AbstractGameObject getObject(GameObjectType objectType, int objectUUID) {
|
||||||
|
|
||||||
AbstractGameObject outObject = null;
|
AbstractGameObject outObject = null;
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ public enum DevCmdManager {
|
|||||||
DevCmdManager.registerDevCmd(new SetAdminRuneCmd());
|
DevCmdManager.registerDevCmd(new SetAdminRuneCmd());
|
||||||
DevCmdManager.registerDevCmd(new SetInvulCmd());
|
DevCmdManager.registerDevCmd(new SetInvulCmd());
|
||||||
DevCmdManager.registerDevCmd(new MakeItemCmd());
|
DevCmdManager.registerDevCmd(new MakeItemCmd());
|
||||||
|
DevCmdManager.registerDevCmd(new FillCmd());
|
||||||
DevCmdManager.registerDevCmd(new SetSubRaceCmd());
|
DevCmdManager.registerDevCmd(new SetSubRaceCmd());
|
||||||
// Admin
|
// Admin
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import engine.mbEnums;
|
|||||||
import engine.net.client.msg.ItemProductionMsg;
|
import engine.net.client.msg.ItemProductionMsg;
|
||||||
import engine.objects.City;
|
import engine.objects.City;
|
||||||
import engine.objects.Item;
|
import engine.objects.Item;
|
||||||
import engine.objects.ItemTemplate;
|
|
||||||
import engine.objects.NPC;
|
import engine.objects.NPC;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
import engine.powers.EffectsBase;
|
import engine.powers.EffectsBase;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -49,6 +49,9 @@ public enum ForgeManager implements Runnable {
|
|||||||
public static final ConcurrentHashMap<NPC, ConcurrentHashMap.KeySetView<WorkOrder, Boolean>> vendorWorkOrderLookup = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<NPC, ConcurrentHashMap.KeySetView<WorkOrder, Boolean>> vendorWorkOrderLookup = new ConcurrentHashMap<>();
|
||||||
public static final ConcurrentHashMap<Item, WorkOrder> itemWorkOrderLookup = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<Item, WorkOrder> itemWorkOrderLookup = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
// Server-only data from static_vendor_items; the client templates have no mod table.
|
||||||
|
public static HashMap<Integer, Integer> vendorModTables = new HashMap<>();
|
||||||
|
|
||||||
public static void start() {
|
public static void start() {
|
||||||
|
|
||||||
Thread forgeManager;
|
Thread forgeManager;
|
||||||
@@ -128,6 +131,11 @@ public enum ForgeManager implements Runnable {
|
|||||||
if (city == null)
|
if (city == null)
|
||||||
return 58; //58: The formula is beyond the means of this facility
|
return 58; //58: The formula is beyond the means of this facility
|
||||||
|
|
||||||
|
// NPC buildings have no strongbox to pay from, as in vendor buy, repair and train
|
||||||
|
|
||||||
|
if (workOrder.vendor.building.getProtectionState() == mbEnums.ProtectionState.NPC)
|
||||||
|
return 58;
|
||||||
|
|
||||||
// Concurrency is rightly managed by same lock as warehouse
|
// Concurrency is rightly managed by same lock as warehouse
|
||||||
|
|
||||||
city.transactionLock.writeLock().lock();
|
city.transactionLock.writeLock().lock();
|
||||||
@@ -222,12 +230,12 @@ public enum ForgeManager implements Runnable {
|
|||||||
// Calculate production cost for a single run of the workOrder
|
// Calculate production cost for a single run of the workOrder
|
||||||
|
|
||||||
HashMap<mbEnums.ResourceType, Integer> production_cost = new HashMap<>();
|
HashMap<mbEnums.ResourceType, Integer> production_cost = new HashMap<>();
|
||||||
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID);
|
CObjectTemplate template = CObjectTemplate.lookup(workOrder.templateID);
|
||||||
|
|
||||||
// Add gold and resource costs from template
|
// Add gold and resource costs from template
|
||||||
|
|
||||||
production_cost.put(mbEnums.ResourceType.GOLD, template.item_value);
|
production_cost.put(mbEnums.ResourceType.GOLD, template.getItemValue());
|
||||||
production_cost.putAll(template.item_resource_cost);
|
production_cost.putAll(template.getItemResourceCosts());
|
||||||
|
|
||||||
// Calculate cost of prefix and suffix
|
// Calculate cost of prefix and suffix
|
||||||
|
|
||||||
@@ -248,8 +256,8 @@ public enum ForgeManager implements Runnable {
|
|||||||
|
|
||||||
// Create new virtual item from specified template
|
// Create new virtual item from specified template
|
||||||
|
|
||||||
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID);
|
|
||||||
Item forgedItem = new Item(workOrder.templateID);
|
Item forgedItem = new Item(workOrder.templateID);
|
||||||
|
int modTable = getVendorModTable(workOrder.templateID);
|
||||||
|
|
||||||
// forgedItem gets a negative id; a virtual item which is not persisted
|
// forgedItem gets a negative id; a virtual item which is not persisted
|
||||||
|
|
||||||
@@ -264,13 +272,13 @@ public enum ForgeManager implements Runnable {
|
|||||||
|
|
||||||
// Assign a prefix and suffix to this item if random rolled
|
// Assign a prefix and suffix to this item if random rolled
|
||||||
|
|
||||||
if (workOrder.prefixToken == 0 && workOrder.vendor.getItemModTable().contains((template.modTable)))
|
if (workOrder.prefixToken == 0 && workOrder.vendor.getItemModTable().contains(modTable))
|
||||||
forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable);
|
forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, modTable);
|
||||||
else
|
else
|
||||||
forgedItem.prefixToken = workOrder.prefixToken;
|
forgedItem.prefixToken = workOrder.prefixToken;
|
||||||
|
|
||||||
if (workOrder.suffixToken == 0 && workOrder.vendor.getItemModTable().contains((template.modTable)))
|
if (workOrder.suffixToken == 0 && workOrder.vendor.getItemModTable().contains(modTable))
|
||||||
forgedItem.suffixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.SUFFIX, template.modTable);
|
forgedItem.suffixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.SUFFIX, modTable);
|
||||||
else
|
else
|
||||||
forgedItem.suffixToken = workOrder.suffixToken;
|
forgedItem.suffixToken = workOrder.suffixToken;
|
||||||
|
|
||||||
@@ -364,6 +372,10 @@ public enum ForgeManager implements Runnable {
|
|||||||
DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder);
|
DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getVendorModTable(int templateID) {
|
||||||
|
return vendorModTables.getOrDefault(templateID, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public static int calcRandomMod(NPC vendor, mbEnums.ItemModType itemModType, int modTable) {
|
public static int calcRandomMod(NPC vendor, mbEnums.ItemModType itemModType, int modTable) {
|
||||||
|
|
||||||
// Random prefix or suffix token based on item.template.modtable
|
// Random prefix or suffix token based on item.template.modtable
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ public enum GroupManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item.template.item_type.equals(mbEnums.ItemType.GOLD)) //only split goldItem
|
if (!item.template.getItemType().equals(mbEnums.ItemType.GOLD)) //only split goldItem
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Group group = getGroup(pc);
|
Group group = getGroup(pc);
|
||||||
|
|||||||
@@ -16,7 +16,18 @@ import engine.net.client.ClientConnection;
|
|||||||
import engine.net.client.msg.guild.AcceptInviteToGuildMsg;
|
import engine.net.client.msg.guild.AcceptInviteToGuildMsg;
|
||||||
import engine.net.client.msg.guild.GuildInfoMsg;
|
import engine.net.client.msg.guild.GuildInfoMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import java.time.Instant;
|
import engine.parsers.map.GuildSeedParser;
|
||||||
|
import engine.parsers.objects.CZoneProp;
|
||||||
|
import engine.parsers.objects.GuildSeed;
|
||||||
|
import engine.parsers.objects.GuildSeedEntry;
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
public enum GuildManager {
|
public enum GuildManager {
|
||||||
|
|
||||||
@@ -33,6 +44,95 @@ public enum GuildManager {
|
|||||||
public static final int CREST_RESERVED = 153; //153: Guild crest is reserved
|
public static final int CREST_RESERVED = 153; //153: Guild crest is reserved
|
||||||
public static final int CREST_COLOR_ERROR = 154; //154: All three crest colors cannot be the same
|
public static final int CREST_COLOR_ERROR = 154; //154: All three crest colors cannot be the same
|
||||||
|
|
||||||
|
// NPC guilds by CZONE city_prop_gm_guild / city_prop_gm_nation key (W7)
|
||||||
|
public static final HashMap<Integer, Guild> _npcGuildsByKey = new HashMap<>();
|
||||||
|
public static final HashMap<Integer, Guild> _npcGuildsByNationKey = new HashMap<>();
|
||||||
|
public static final HashSet<Integer> _noGuildKeys = new HashSet<>();
|
||||||
|
|
||||||
|
// Static NPC guilds from maps/<map>.guild. Loaded before zones, so they take the first static IDs. False aborts boot.
|
||||||
|
|
||||||
|
public static boolean loadStaticGuilds(int mapID) {
|
||||||
|
|
||||||
|
GuildSeed guildSeed;
|
||||||
|
Guild guild;
|
||||||
|
|
||||||
|
guildSeed = GuildSeedParser.parseGuildSeed(mapID);
|
||||||
|
|
||||||
|
if (guildSeed == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (GuildSeedEntry seedEntry : guildSeed.guilds) {
|
||||||
|
|
||||||
|
guild = Guild.createStaticGuild(seedEntry);
|
||||||
|
DbManager.addToCache(guild);
|
||||||
|
|
||||||
|
for (int guildKey : seedEntry.guildKeys)
|
||||||
|
if (_npcGuildsByKey.put(guildKey, guild) != null || guildSeed.noGuildKeys.contains(guildKey)) {
|
||||||
|
Logger.error("Guild seed: guild key " + String.format("%08X", guildKey) + " is used twice");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_npcGuildsByNationKey.put(seedEntry.nationKey, guild) != null) {
|
||||||
|
Logger.error("Guild seed: nation key " + String.format("%08X", seedEntry.nationKey) + " is used twice");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_noGuildKeys.addAll(guildSeed.noGuildKeys);
|
||||||
|
|
||||||
|
Logger.info("NPC guilds: " + guildSeed.guilds.size() + " static, " + _npcGuildsByKey.size() + " guild keys");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logs each CITY-prop guild key on the map that has no seed entry; known no-guild keys are only counted.
|
||||||
|
|
||||||
|
public static void logMissingGuildKeys() {
|
||||||
|
|
||||||
|
TreeMap<String, TreeSet<String>> missingKeys = new TreeMap<>();
|
||||||
|
ArrayList<CZoneProp> cityProps = new ArrayList<>();
|
||||||
|
int noGuildProps = 0;
|
||||||
|
|
||||||
|
for (Zone zone : ZoneManager.getAllZones()) {
|
||||||
|
|
||||||
|
if (!zone.isStaticWorldObject() || zone.template == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
cityProps.clear();
|
||||||
|
collectCityProps(zone.template.zone_prop_info, cityProps);
|
||||||
|
|
||||||
|
for (CZoneProp cityProp : cityProps) {
|
||||||
|
|
||||||
|
if (_npcGuildsByKey.containsKey(cityProp.city_prop_gm_guild))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (_noGuildKeys.contains(cityProp.city_prop_gm_guild)) {
|
||||||
|
noGuildProps++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
missingKeys.computeIfAbsent(String.format("%08X", cityProp.city_prop_gm_guild), key -> new TreeSet<>())
|
||||||
|
.add(zone.zoneName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String guildKey : missingKeys.keySet())
|
||||||
|
Logger.warn("CITY prop guild key " + guildKey + " has no guild seed entry; zones: " + missingKeys.get(guildKey));
|
||||||
|
|
||||||
|
Logger.info("CITY props: " + noGuildProps + " with no guild, " + missingKeys.size() + " guild keys missing from the seed");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void collectCityProps(ArrayList<CZoneProp> props, ArrayList<CZoneProp> cityProps) {
|
||||||
|
|
||||||
|
for (CZoneProp prop : props) {
|
||||||
|
|
||||||
|
if (prop.prop_type == mbEnums.ZonePropType.CITY)
|
||||||
|
cityProps.add(prop);
|
||||||
|
|
||||||
|
collectCityProps(prop.prop_content_props, cityProps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean joinGuild(PlayerCharacter pc, Guild guild, GuildHistoryType historyType) {
|
public static boolean joinGuild(PlayerCharacter pc, Guild guild, GuildHistoryType historyType) {
|
||||||
return joinGuild(pc, guild, 0, historyType);
|
return joinGuild(pc, guild, 0, historyType);
|
||||||
}
|
}
|
||||||
@@ -67,8 +167,8 @@ public enum GuildManager {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (playerCharacter.getGuild() != null && !playerCharacter.getGuild().isEmptyGuild()) {
|
if (playerCharacter.getGuild() != null && !playerCharacter.getGuild().isEmptyGuild()) {
|
||||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(playerCharacter.getGuildUUID(), playerCharacter, Instant.now(), GuildHistoryType.LEAVE)) {
|
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(playerCharacter.getGuildUUID(), playerCharacter, DateTime.now(), GuildHistoryType.LEAVE)) {
|
||||||
GuildHistory guildHistory = new GuildHistory(playerCharacter.getGuildUUID(), playerCharacter.getGuild().getName(), Instant.now(), GuildHistoryType.LEAVE);
|
GuildHistory guildHistory = new GuildHistory(playerCharacter.getGuildUUID(), playerCharacter.getGuild().getName(), DateTime.now(), GuildHistoryType.LEAVE);
|
||||||
playerCharacter.getGuildHistory().add(guildHistory);
|
playerCharacter.getGuildHistory().add(guildHistory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,8 +190,8 @@ public enum GuildManager {
|
|||||||
dispatch = Dispatch.borrow(playerCharacter, msg);
|
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||||
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
|
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
|
||||||
}
|
}
|
||||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), playerCharacter, Instant.now(), historyType)) {
|
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), playerCharacter, DateTime.now(), historyType)) {
|
||||||
GuildHistory guildHistory = new GuildHistory(guild.getObjectUUID(), guild.getName(), Instant.now(), historyType);
|
GuildHistory guildHistory = new GuildHistory(guild.getObjectUUID(), guild.getName(), DateTime.now(), historyType);
|
||||||
playerCharacter.getGuildHistory().add(guildHistory);
|
playerCharacter.getGuildHistory().add(guildHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package engine.gameManager;
|
|||||||
|
|
||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
import engine.powers.EffectsBase;
|
import engine.powers.EffectsBase;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -19,68 +20,49 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
public enum ItemManager {
|
public enum ItemManager {
|
||||||
ITEMMANAGER;
|
ITEMMANAGER;
|
||||||
|
|
||||||
public static final AtomicInteger lastNegativeID = new AtomicInteger(0);
|
// Shared by every runtime object with a negative ID: loot, forged and contract items, pets and minions.
|
||||||
|
public static final AtomicInteger lastNegativeID = new AtomicInteger(DbManager.RUNTIME_ID_START);
|
||||||
|
|
||||||
|
// restrict true: the set is a blacklist; false: a whitelist. An empty set allows everyone.
|
||||||
|
|
||||||
public static Boolean ValidRace(Item item, mbEnums.MonsterType race) {
|
public static Boolean ValidRace(Item item, mbEnums.MonsterType race) {
|
||||||
|
|
||||||
if (item.template.item_race_req.isEmpty() && item.template.item_race_res.isEmpty())
|
EnumSet<mbEnums.MonsterType> races = item.template.getItemRaceReq();
|
||||||
|
boolean restrict = item.template.getItemRaceReqRestrict();
|
||||||
|
|
||||||
|
if (races.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (item.template.item_race_req.isEmpty() == false)
|
return races.contains(race) != restrict;
|
||||||
if (item.template.item_race_req.contains(race))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (item.template.item_race_res.isEmpty() == false)
|
|
||||||
if (item.template.item_race_res.contains(race) == false)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean ValidClass(Item item, mbEnums.ClassType base, mbEnums.ClassType profession) {
|
public static Boolean ValidClass(Item item, mbEnums.ClassType base, mbEnums.ClassType profession) {
|
||||||
|
|
||||||
// Early exit if no entry
|
EnumSet<mbEnums.ClassType> classes = item.template.getItemClassReq();
|
||||||
|
boolean restrict = item.template.getItemClassReqRestrict();
|
||||||
|
boolean listed;
|
||||||
|
|
||||||
if (item.template.item_class_req.isEmpty() && item.template.item_class_res.isEmpty())
|
if (classes.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (item.template.item_class_req.isEmpty() == false)
|
listed = classes.contains(base) || classes.contains(profession);
|
||||||
if (item.template.item_class_req.contains(base) || item.template.item_class_req.contains(profession))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (item.template.item_class_res.isEmpty() == false)
|
return listed != restrict;
|
||||||
if (item.template.item_class_res.contains(base) == false && item.template.item_class_res.contains(profession) == false)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean ValidDiscipline(Item item, EnumSet<mbEnums.DisciplineType> discs) {
|
public static Boolean ValidDiscipline(Item item, EnumSet<mbEnums.DisciplineType> discs) {
|
||||||
|
|
||||||
// Early exit if no entry
|
EnumSet<mbEnums.DisciplineType> disciplines = item.template.getItemDiscReq();
|
||||||
|
boolean restrict = item.template.getItemDiscReqRestrict();
|
||||||
|
EnumSet<mbEnums.DisciplineType> workSet;
|
||||||
|
|
||||||
if (item.template.item_disc_req.isEmpty() && item.template.item_disc_res.isEmpty())
|
if (disciplines.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
EnumSet<mbEnums.DisciplineType> workSet = EnumSet.copyOf(discs);
|
workSet = EnumSet.copyOf(discs);
|
||||||
|
workSet.retainAll(disciplines);
|
||||||
|
|
||||||
if (item.template.item_disc_req.isEmpty() == false) {
|
return workSet.isEmpty() == restrict;
|
||||||
|
|
||||||
workSet.retainAll(item.template.item_disc_req);
|
|
||||||
|
|
||||||
if (workSet.isEmpty() == false)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.template.item_disc_res.isEmpty() == false) {
|
|
||||||
|
|
||||||
workSet.retainAll(item.template.item_disc_res);
|
|
||||||
|
|
||||||
if (workSet.isEmpty() == false)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean canCharacterEquip(Item item, AbstractCharacter character) {
|
public static Boolean canCharacterEquip(Item item, AbstractCharacter character) {
|
||||||
@@ -91,12 +73,12 @@ public enum ItemManager {
|
|||||||
|
|
||||||
CharacterSkill characterSkill;
|
CharacterSkill characterSkill;
|
||||||
|
|
||||||
if (item.template.item_skill_required.isEmpty())
|
if (item.template.getItemSkillReq().isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (String skillRequired : item.template.item_skill_required.keySet()) {
|
for (String skillRequired : item.template.getItemSkillReq().keySet()) {
|
||||||
|
|
||||||
int required_value = item.template.item_skill_required.get(skillRequired);
|
int required_value = item.template.getItemSkillReq().get(skillRequired);
|
||||||
characterSkill = skills.get(skillRequired);
|
characterSkill = skills.get(skillRequired);
|
||||||
|
|
||||||
if (characterSkill == null)
|
if (characterSkill == null)
|
||||||
@@ -112,31 +94,31 @@ public enum ItemManager {
|
|||||||
|
|
||||||
public static boolean isTwoHanded(Item item) {
|
public static boolean isTwoHanded(Item item) {
|
||||||
|
|
||||||
if (!item.template.item_type.equals(mbEnums.ItemType.WEAPON))
|
if (!item.template.getItemType().equals(mbEnums.ItemType.WEAPON))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return item.template.item_eq_slots_and.contains(EnumSet.of(mbEnums.EquipSlotType.LHELD, mbEnums.EquipSlotType.RHELD));
|
return item.template.getItemEqSlotsAnd().containsAll(EnumSet.of(mbEnums.EquipSlotType.LHELD, mbEnums.EquipSlotType.RHELD));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isTwoHanded(ItemTemplate template) {
|
public static boolean isTwoHanded(CObjectTemplate template) {
|
||||||
|
|
||||||
if (!template.item_type.equals(mbEnums.ItemType.WEAPON))
|
if (!template.getItemType().equals(mbEnums.ItemType.WEAPON))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return template.item_eq_slots_and.contains(EnumSet.of(mbEnums.EquipSlotType.LHELD, mbEnums.EquipSlotType.RHELD));
|
return template.getItemEqSlotsAnd().containsAll(EnumSet.of(mbEnums.EquipSlotType.LHELD, mbEnums.EquipSlotType.RHELD));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isShield(Item item) {
|
public static boolean isShield(Item item) {
|
||||||
|
|
||||||
if (item.template.item_skill_required.containsKey("Block"))
|
if (item.template.getItemSkillReq().containsKey("Block"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isShield(ItemTemplate template) {
|
public static boolean isShield(CObjectTemplate template) {
|
||||||
|
|
||||||
if (template.item_skill_required.containsKey("Block"))
|
if (template.getItemSkillReq().containsKey("Block"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -150,7 +132,7 @@ public enum ItemManager {
|
|||||||
return false;
|
return false;
|
||||||
//Item not valid for slot
|
//Item not valid for slot
|
||||||
|
|
||||||
if (item.template.item_eq_slots_or.contains(slot) == false)
|
if (item.template.getItemEqSlotsOr().contains(slot) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Slot is taken
|
// Slot is taken
|
||||||
@@ -165,7 +147,7 @@ public enum ItemManager {
|
|||||||
(slot == mbEnums.EquipSlotType.RHELD && equipped.get(mbEnums.EquipSlotType.LHELD) != null)))
|
(slot == mbEnums.EquipSlotType.RHELD && equipped.get(mbEnums.EquipSlotType.LHELD) != null)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (item.template.item_type.equals(mbEnums.ItemType.WEAPON))
|
if (item.template.getItemType().equals(mbEnums.ItemType.WEAPON))
|
||||||
if (equipped.get(slot) != null && equipped.get(slot).equals(item) == false)
|
if (equipped.get(slot) != null && equipped.get(slot).equals(item) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -197,7 +179,7 @@ public enum ItemManager {
|
|||||||
|
|
||||||
//players can't wear 0 value items.
|
//players can't wear 0 value items.
|
||||||
|
|
||||||
return item.template.item_value != 0 || Kit.IsNoobGear(item.templateID);
|
return item.template.getItemValue() != 0 || Kit.IsNoobGear(item.templateID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import engine.mbEnums;
|
|||||||
import engine.net.client.msg.ErrorPopupMsg;
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
import engine.net.client.msg.chat.ChatSystemMsg;
|
import engine.net.client.msg.chat.ChatSystemMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -91,8 +92,8 @@ public enum LootManager {
|
|||||||
//lastly, check mobs inventory for godly or disc runes to send a server announcement
|
//lastly, check mobs inventory for godly or disc runes to send a server announcement
|
||||||
for (Item item : mob.getInventory()) {
|
for (Item item : mob.getInventory()) {
|
||||||
|
|
||||||
if ((item.templateID > 2499 && item.templateID <= 3050) || item.template.item_base_name.toLowerCase().contains("of the gods")) {
|
if ((item.templateID > 2499 && item.templateID <= 3050) || item.template.getItemBaseName().toLowerCase().contains("of the gods")) {
|
||||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + item.template.item_base_name + ". Are you tough enough to take it?");
|
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + item.template.getItemBaseName() + ". Are you tough enough to take it?");
|
||||||
chatMsg.setMessageType(10);
|
chatMsg.setMessageType(10);
|
||||||
chatMsg.setChannel(mbEnums.ChatChannelType.SYSTEM.getChannelID());
|
chatMsg.setChannel(mbEnums.ChatChannelType.SYSTEM.getChannelID());
|
||||||
DispatchManager.dispatchMsgToAll(chatMsg);
|
DispatchManager.dispatchMsgToAll(chatMsg);
|
||||||
@@ -179,12 +180,12 @@ public enum LootManager {
|
|||||||
if (itemUUID == 0)
|
if (itemUUID == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (ItemTemplate.templates.get(itemUUID).item_type.equals(mbEnums.ItemType.RESOURCE)) {
|
if (CObjectTemplate.lookup(itemUUID).getItemType().equals(mbEnums.ItemType.RESOURCE)) {
|
||||||
int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1);
|
int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1);
|
||||||
return new MobLoot(mob, ItemTemplate.templates.get(itemUUID), amount, false);
|
return new MobLoot(mob, CObjectTemplate.lookup(itemUUID), amount, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
outItem = new MobLoot(mob, ItemTemplate.templates.get(itemUUID), false);
|
outItem = new MobLoot(mob, CObjectTemplate.lookup(itemUUID), false);
|
||||||
|
|
||||||
if (selectedRow.pModTable != 0)
|
if (selectedRow.pModTable != 0)
|
||||||
try {
|
try {
|
||||||
@@ -374,7 +375,7 @@ public enum LootManager {
|
|||||||
if (chanceRoll > bse.dropChance)
|
if (chanceRoll > bse.dropChance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MobLoot lootItem = new MobLoot(mob, ItemTemplate.templates.get(bse.templateID), true);
|
MobLoot lootItem = new MobLoot(mob, CObjectTemplate.lookup(bse.templateID), true);
|
||||||
|
|
||||||
if (lootItem != null)
|
if (lootItem != null)
|
||||||
mob.charItemManager.addItemToInventory(lootItem);
|
mob.charItemManager.addItemToInventory(lootItem);
|
||||||
@@ -422,14 +423,14 @@ public enum LootManager {
|
|||||||
|
|
||||||
//create the item from the table, quantity is always 1
|
//create the item from the table, quantity is always 1
|
||||||
|
|
||||||
MobLoot winnings = new MobLoot(playerCharacter, ItemTemplate.templates.get(selectedItem.templateID), 1, false);
|
MobLoot winnings = new MobLoot(playerCharacter, CObjectTemplate.lookup(selectedItem.templateID), 1, false);
|
||||||
|
|
||||||
if (winnings == null)
|
if (winnings == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//early exit if the inventory of the player will not old the item
|
//early exit if the inventory of the player will not old the item
|
||||||
|
|
||||||
if (itemMan.hasRoomInventory(winnings.template.item_wt) == false) {
|
if (itemMan.hasRoomInventory(winnings.template.getItemWt()) == false) {
|
||||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ package engine.gameManager;
|
|||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.loot.WorkOrder;
|
import engine.loot.WorkOrder;
|
||||||
import engine.math.Quaternion;
|
import engine.math.Quaternion;
|
||||||
import engine.math.Vector3f;
|
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
@@ -19,19 +18,19 @@ import engine.net.client.ClientConnection;
|
|||||||
import engine.net.client.msg.ErrorPopupMsg;
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
import engine.net.client.msg.PetMsg;
|
import engine.net.client.msg.PetMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
import engine.powers.EffectsBase;
|
import engine.powers.EffectsBase;
|
||||||
import engine.powers.RuneSkillAdjustEntry;
|
import engine.powers.RuneSkillAdjustEntry;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static engine.math.FastMath.acos;
|
|
||||||
|
|
||||||
public enum NPCManager {
|
public enum NPCManager {
|
||||||
|
|
||||||
NPC_MANAGER;
|
NPC_MANAGER;
|
||||||
@@ -225,11 +224,12 @@ public enum NPCManager {
|
|||||||
|
|
||||||
abstractCharacter.loc = new Vector3fImmutable(abstractCharacter.bindLoc);
|
abstractCharacter.loc = new Vector3fImmutable(abstractCharacter.bindLoc);
|
||||||
|
|
||||||
// Rotate NPC rotation by the building's rotation
|
// Rotate NPC rotation by the building's rotation.
|
||||||
|
// Kept for wire parity: the product's sin θ/2 is read back as cos θ/2, so the yaw sent is not own + building.
|
||||||
|
|
||||||
Quaternion slotRotation = new Quaternion().fromAngles(0, acos(abstractCharacter.getRot().y) * 2, 0);
|
Quaternion slotRotation = new Quaternion().fromAngles(0, abstractCharacter.getRotation().getYaw(), 0);
|
||||||
slotRotation = slotRotation.mult(abstractCharacter.building.getBounds().getQuaternion());
|
slotRotation = slotRotation.mult(abstractCharacter.building.getBounds().getQuaternion());
|
||||||
abstractCharacter.setRot(new Vector3f(0, slotRotation.y, 0));
|
abstractCharacter.setRotation(Quaternion.fromYaw((float) Math.acos(slotRotation.y) * 2));
|
||||||
|
|
||||||
// Configure region and floor/level for this NPC
|
// Configure region and floor/level for this NPC
|
||||||
|
|
||||||
@@ -315,26 +315,26 @@ public enum NPCManager {
|
|||||||
//has main hand weapon
|
//has main hand weapon
|
||||||
Item weapon = guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD);
|
Item weapon = guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD);
|
||||||
|
|
||||||
if (weapon.template.item_primary_attr.equals(mbEnums.AttributeType.Strength))
|
if (engine.parsers.objects.ItemTemplate._items.get(weapon.templateID).item_primary_attr == mbEnums.AttributeType.Strength)
|
||||||
primaryStat = guard.getStatStrCurrent();
|
primaryStat = guard.getStatStrCurrent();
|
||||||
else
|
else
|
||||||
primaryStat = guard.getStatDexCurrent();
|
primaryStat = guard.getStatDexCurrent();
|
||||||
|
|
||||||
guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin() + weapon.template.item_weapon_damage.values().iterator().next()[0]) * rankModifier) + primaryStat;
|
guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin() + engine.parsers.objects.ItemTemplate.getWeapon(weapon.templateID).weapon_damage.get(0).damage_min) * rankModifier) + primaryStat;
|
||||||
guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax() + weapon.template.item_weapon_damage.values().iterator().next()[1]) * rankModifier) + primaryStat;
|
guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax() + engine.parsers.objects.ItemTemplate.getWeapon(weapon.templateID).weapon_damage.get(0).damage_max) * rankModifier) + primaryStat;
|
||||||
guard.speedHandOne = weapon.template.item_weapon_wepspeed;
|
guard.speedHandOne = engine.parsers.objects.ItemTemplate.getWeapon(weapon.templateID).weapon_wepspeed;
|
||||||
guard.rangeHandOne = weapon.template.item_weapon_max_range;
|
guard.rangeHandOne = engine.parsers.objects.ItemTemplate.getWeapon(weapon.templateID).weapon_max_range;
|
||||||
} else if (guard.charItemManager.equipped.containsKey(mbEnums.EquipSlotType.LHELD) && !ItemManager.isShield(guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template)) {
|
} else if (guard.charItemManager.equipped.containsKey(mbEnums.EquipSlotType.LHELD) && !ItemManager.isShield(guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template)) {
|
||||||
//has off hand weapon
|
//has off hand weapon
|
||||||
Item weapon = guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD);
|
Item weapon = guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD);
|
||||||
if (weapon.template.item_primary_attr.equals(mbEnums.AttributeType.Strength))
|
if (engine.parsers.objects.ItemTemplate._items.get(weapon.templateID).item_primary_attr == mbEnums.AttributeType.Strength)
|
||||||
primaryStat = guard.getStatStrCurrent();
|
primaryStat = guard.getStatStrCurrent();
|
||||||
else
|
else
|
||||||
primaryStat = guard.getStatDexCurrent();
|
primaryStat = guard.getStatDexCurrent();
|
||||||
guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin() + weapon.template.item_weapon_damage.values().iterator().next()[0]) * rankModifier) + primaryStat;
|
guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin() + engine.parsers.objects.ItemTemplate.getWeapon(weapon.templateID).weapon_damage.get(0).damage_min) * rankModifier) + primaryStat;
|
||||||
guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax() + weapon.template.item_weapon_damage.values().iterator().next()[1]) * rankModifier) + primaryStat;
|
guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax() + engine.parsers.objects.ItemTemplate.getWeapon(weapon.templateID).weapon_damage.get(0).damage_max) * rankModifier) + primaryStat;
|
||||||
guard.speedHandOne = weapon.template.item_weapon_wepspeed;
|
guard.speedHandOne = engine.parsers.objects.ItemTemplate.getWeapon(weapon.templateID).weapon_wepspeed;
|
||||||
guard.rangeHandOne = weapon.template.item_weapon_max_range;
|
guard.rangeHandOne = engine.parsers.objects.ItemTemplate.getWeapon(weapon.templateID).weapon_max_range;
|
||||||
} else {
|
} else {
|
||||||
primaryStat = guard.getStatStrCurrent();
|
primaryStat = guard.getStatStrCurrent();
|
||||||
guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin()) * rankModifier) + primaryStat;
|
guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin()) * rankModifier) + primaryStat;
|
||||||
@@ -352,8 +352,8 @@ public enum NPCManager {
|
|||||||
int baseDef = guard.mobBase.getDefenseRating();
|
int baseDef = guard.mobBase.getDefenseRating();
|
||||||
int armorDefense = 0;
|
int armorDefense = 0;
|
||||||
for (Item equipped : guard.charItemManager.equipped.values())
|
for (Item equipped : guard.charItemManager.equipped.values())
|
||||||
if (equipped.template.item_type.equals(mbEnums.ItemType.ARMOR) || ItemManager.isShield(equipped.template))
|
if (equipped.template.getItemType().equals(mbEnums.ItemType.ARMOR) || ItemManager.isShield(equipped.template))
|
||||||
armorDefense += equipped.template.item_defense_rating;
|
armorDefense += engine.parsers.objects.ItemTemplate._items.get(equipped.templateID).item_defense_rating;
|
||||||
guard.defenseRating = dexterity + baseDef + armorDefense;
|
guard.defenseRating = dexterity + baseDef + armorDefense;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,9 +361,9 @@ public enum NPCManager {
|
|||||||
int strength = guard.getStatStrCurrent();
|
int strength = guard.getStatStrCurrent();
|
||||||
int baseAtr = guard.mobBase.getAttackRating();
|
int baseAtr = guard.mobBase.getAttackRating();
|
||||||
if (guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD) != null)
|
if (guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD) != null)
|
||||||
guard.atrHandOne = baseAtr + (int) ((strength * 0.5f) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD).template.item_skill_required.values().toArray()[0] * 4) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD).template.item_skill_required.values().toArray()[0] * 3));
|
guard.atrHandOne = baseAtr + (int) ((strength * 0.5f) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD).template.getItemSkillReq().values().toArray()[0] * 4) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD).template.getItemSkillReq().values().toArray()[0] * 3));
|
||||||
else if (guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD) != null && !ItemManager.isShield(guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template))
|
else if (guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD) != null && !ItemManager.isShield(guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template))
|
||||||
guard.atrHandTwo = baseAtr + (int) ((strength * 0.5f) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template.item_skill_required.values().toArray()[0] * 4) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template.item_skill_required.values().toArray()[0] * 3));
|
guard.atrHandTwo = baseAtr + (int) ((strength * 0.5f) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template.getItemSkillReq().values().toArray()[0] * 4) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template.getItemSkillReq().values().toArray()[0] * 3));
|
||||||
else
|
else
|
||||||
guard.atrHandOne = baseAtr;
|
guard.atrHandOne = baseAtr;
|
||||||
}
|
}
|
||||||
@@ -434,28 +434,63 @@ public enum NPCManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mob.isNecroPet())
|
||||||
|
applyNecroPetStats(mob);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No client data grants NECROPETSTATS, yet NEC-018 and DRU-066 require it on the target; the server adds it to necro pets
|
||||||
|
private static void applyNecroPetStats(Mob mob) {
|
||||||
|
|
||||||
|
EffectsBase necroPetStats = PowersManager.getEffectByIDString("NECROPETSTATS");
|
||||||
|
String effectKey;
|
||||||
|
Effect currentEffect;
|
||||||
|
int rank = -1;
|
||||||
|
|
||||||
|
if (necroPetStats == null) {
|
||||||
|
Logger.error("NECROPETSTATS effect not loaded");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GUESS: rank follows the pet's own level ladder (PET_NECRO / PET_NECRO_HARDHIT, from reqLvl 9), as the old DB rows did
|
||||||
|
for (MobBaseEffects mbe : mob.mobBase.effectsList)
|
||||||
|
if (mbe.getReqLvl() > 0 && mbe.getReqLvl() <= (int) mob.level)
|
||||||
|
rank = Math.max(rank, mbe.getRank());
|
||||||
|
|
||||||
|
if (rank < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
effectKey = Integer.toString(necroPetStats.getUUID());
|
||||||
|
currentEffect = mob.effects.get(effectKey);
|
||||||
|
|
||||||
|
if (currentEffect != null) {
|
||||||
|
|
||||||
|
if (currentEffect.getTrains() >= rank)
|
||||||
|
return;
|
||||||
|
|
||||||
|
currentEffect.cancelJob();
|
||||||
|
}
|
||||||
|
|
||||||
|
mob.addEffectNoTimer(effectKey, necroPetStats, rank, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applyEquipmentResists(Mob mob) {
|
public static void applyEquipmentResists(Mob mob) {
|
||||||
|
|
||||||
|
EnumMap<mbEnums.DamageType, Float> armorResists;
|
||||||
|
|
||||||
if (mob.charItemManager.equipped.isEmpty())
|
if (mob.charItemManager.equipped.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Item equipped : mob.charItemManager.equipped.values()) {
|
for (Item equipped : mob.charItemManager.equipped.values()) {
|
||||||
if (equipped.template.item_type.equals(mbEnums.ItemType.ARMOR)) {
|
if (equipped.template.getItemType().equals(mbEnums.ItemType.ARMOR)) {
|
||||||
mob.resists.setResist(mbEnums.DamageType.SLASHING, mob.resists.getResist(mbEnums.DamageType.SLASHING, 0) + equipped.template.combat_attack_resist.get("SLASHING"));
|
armorResists = equipped.template.getCombatAttackResist();
|
||||||
mob.resists.setResist(mbEnums.DamageType.CRUSHING, mob.resists.getResist(mbEnums.DamageType.CRUSHING, 0) + equipped.template.combat_attack_resist.get("CRUSHING"));
|
mob.resists.setResist(mbEnums.DamageType.SLASHING, mob.resists.getResist(mbEnums.DamageType.SLASHING, 0) + armorResists.getOrDefault(mbEnums.DamageType.SLASHING, 0f));
|
||||||
mob.resists.setResist(mbEnums.DamageType.PIERCING, mob.resists.getResist(mbEnums.DamageType.PIERCING, 0) + equipped.template.combat_attack_resist.get("PIERCING"));
|
mob.resists.setResist(mbEnums.DamageType.CRUSHING, mob.resists.getResist(mbEnums.DamageType.CRUSHING, 0) + armorResists.getOrDefault(mbEnums.DamageType.CRUSHING, 0f));
|
||||||
|
mob.resists.setResist(mbEnums.DamageType.PIERCING, mob.resists.getResist(mbEnums.DamageType.PIERCING, 0) + armorResists.getOrDefault(mbEnums.DamageType.PIERCING, 0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applyMobbaseSkill(Mob mob) {
|
|
||||||
SkillsBase baseSkill = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(mob.mobBase.getMobBaseStats().getBaseSkill());
|
|
||||||
if (baseSkill != null)
|
|
||||||
mob.getSkills().put(baseSkill.getName(), new CharacterSkill(baseSkill, mob, mob.mobBase.getMobBaseStats().getBaseSkillAmount()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void applyRuneSkills(Mob mob, int runeID) {
|
public static void applyRuneSkills(Mob mob, int runeID) {
|
||||||
//load mob skill adjustments from mobbase rune
|
//load mob skill adjustments from mobbase rune
|
||||||
if (PowersManager._allRuneSkillAdjusts.containsKey(runeID))
|
if (PowersManager._allRuneSkillAdjusts.containsKey(runeID))
|
||||||
@@ -466,7 +501,7 @@ public enum NPCManager {
|
|||||||
if (skillBase == null)
|
if (skillBase == null)
|
||||||
continue;
|
continue;
|
||||||
if (entry.level <= mob.level)
|
if (entry.level <= mob.level)
|
||||||
if (mob.skills.containsKey(entry.name) == false)
|
if (mob.skills.containsKey(entry.skill_type) == false)
|
||||||
mob.skills.put(entry.skill_type, new CharacterSkill(skillBase, mob, entry.rank));
|
mob.skills.put(entry.skill_type, new CharacterSkill(skillBase, mob, entry.rank));
|
||||||
else
|
else
|
||||||
mob.skills.put(entry.skill_type, new CharacterSkill(skillBase, mob, entry.rank + mob.skills.get(entry.skill_type).getNumTrains()));
|
mob.skills.put(entry.skill_type, new CharacterSkill(skillBase, mob, entry.rank + mob.skills.get(entry.skill_type).getNumTrains()));
|
||||||
@@ -480,6 +515,11 @@ public enum NPCManager {
|
|||||||
npc.runes.add(shopkeeper);
|
npc.runes.add(shopkeeper);
|
||||||
if (NPCManager._runeSetMap.containsKey(npc.runeSetID)) {
|
if (NPCManager._runeSetMap.containsKey(npc.runeSetID)) {
|
||||||
for (int runeID : _runeSetMap.get(npc.runeSetID)) {
|
for (int runeID : _runeSetMap.get(npc.runeSetID)) {
|
||||||
|
|
||||||
|
// Shopkeeper is already applied above and most rune sets repeat it
|
||||||
|
if (runeID == 252620)
|
||||||
|
continue;
|
||||||
|
|
||||||
RuneBase rb = RuneBase.getRuneBase(runeID);
|
RuneBase rb = RuneBase.getRuneBase(runeID);
|
||||||
if (rb != null) {
|
if (rb != null) {
|
||||||
CharacterRune toApply = new CharacterRune(rb, npc.getObjectUUID());
|
CharacterRune toApply = new CharacterRune(rb, npc.getObjectUUID());
|
||||||
@@ -536,14 +576,14 @@ public enum NPCManager {
|
|||||||
|
|
||||||
public static long calcRollingDuration(NPC vendor, int templateID) {
|
public static long calcRollingDuration(NPC vendor, int templateID) {
|
||||||
|
|
||||||
ItemTemplate template = ItemTemplate.templates.get(templateID);
|
CObjectTemplate template = CObjectTemplate.lookup(templateID);
|
||||||
float rollingDuration;
|
float rollingDuration;
|
||||||
|
|
||||||
if (template == null)
|
if (template == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (template.item_bane_rank > 0)
|
if (template.getItemBaneRank() > 0)
|
||||||
return (long) (template.item_bane_rank * 60 * 60 * 3 * 1000 * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()));
|
return (long) (template.getItemBaneRank() * 60 * 60 * 3 * 1000 * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()));
|
||||||
|
|
||||||
if (vendor.building == null)
|
if (vendor.building == null)
|
||||||
return 600;
|
return 600;
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ package engine.gameManager;
|
|||||||
|
|
||||||
import engine.InterestManagement.Terrain;
|
import engine.InterestManagement.Terrain;
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.db.handlers.dbEffectsBaseHandler;
|
|
||||||
import engine.db.handlers.dbPowerHandler;
|
|
||||||
import engine.db.handlers.dbSkillReqHandler;
|
|
||||||
import engine.job.AbstractJob;
|
import engine.job.AbstractJob;
|
||||||
import engine.job.AbstractScheduleJob;
|
import engine.job.AbstractScheduleJob;
|
||||||
import engine.job.JobContainer;
|
import engine.job.JobContainer;
|
||||||
@@ -28,8 +25,12 @@ import engine.net.Dispatch;
|
|||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.msg.*;
|
import engine.net.client.msg.*;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.wpak.EffectTemplate;
|
||||||
|
import engine.parsers.objects.wpak.PowActionCostTemplate;
|
||||||
|
import engine.parsers.objects.wpak.PowerActionTemplate;
|
||||||
|
import engine.parsers.objects.wpak.PowerTemplate;
|
||||||
import engine.powers.*;
|
import engine.powers.*;
|
||||||
import engine.powers.poweractions.AbstractPowerAction;
|
import engine.powers.poweractions.*;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
@@ -53,7 +55,6 @@ public enum PowersManager {
|
|||||||
public static HashMap<String, AbstractPowerAction> powerActionsByIDString = new HashMap<>();
|
public static HashMap<String, AbstractPowerAction> powerActionsByIDString = new HashMap<>();
|
||||||
public static HashMap<Integer, AbstractPowerAction> powerActionsByID = new HashMap<>();
|
public static HashMap<Integer, AbstractPowerAction> powerActionsByID = new HashMap<>();
|
||||||
public static HashMap<String, Integer> ActionTokenByIDString = new HashMap<>();
|
public static HashMap<String, Integer> ActionTokenByIDString = new HashMap<>();
|
||||||
public static HashMap<String, Integer> AnimationOverrides = new HashMap<>();
|
|
||||||
public static HashMap<Integer, ArrayList<RunePowerEntry>> _allRunePowers;
|
public static HashMap<Integer, ArrayList<RunePowerEntry>> _allRunePowers;
|
||||||
public static HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> _allRuneSkillAdjusts;
|
public static HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> _allRuneSkillAdjusts;
|
||||||
public static HashMap<String, HashMap<ResourceType, Integer>> _effect_costMaps = new HashMap<>();
|
public static HashMap<String, HashMap<ResourceType, Integer>> _effect_costMaps = new HashMap<>();
|
||||||
@@ -90,16 +91,200 @@ public enum PowersManager {
|
|||||||
return PowersManager.effectsBaseByToken.get(token);
|
return PowersManager.effectsBaseByToken.get(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This pre-loads only PowersBase for login
|
public static void loadEffectCostMaps() {
|
||||||
public static void InitializeLoginPowers() {
|
|
||||||
|
|
||||||
// get all PowersBase
|
for (PowActionCostTemplate costTemplate : PowActionCostTemplate._costs.values())
|
||||||
ArrayList<PowersBase> pbList = dbSkillReqHandler.getAllPowersBase();
|
PowersManager._effect_costMaps.put(costTemplate.id, new HashMap<>(costTemplate.costs));
|
||||||
|
|
||||||
for (PowersBase pb : pbList) {
|
Logger.info("Loaded " + PowersManager._effect_costMaps.size() + " effect cost maps from PowActionCostInfo.cfg");
|
||||||
if (pb.getToken() != 0)
|
}
|
||||||
PowersManager.powersBaseByToken.put(pb.getToken(), pb);
|
|
||||||
|
// Effects.cfg in file order, then the ApplyEffect/ApplyEffects/Invis actions with no Effects.cfg block
|
||||||
|
private static void loadEffects() {
|
||||||
|
|
||||||
|
int effectID = 0;
|
||||||
|
int actionKeyCount = 0;
|
||||||
|
PowerActionTemplate powerActionTemplate;
|
||||||
|
|
||||||
|
for (EffectTemplate effectTemplate : EffectTemplate._effects.values())
|
||||||
|
addEffect(new EffectsBase(effectTemplate, ++effectID));
|
||||||
|
|
||||||
|
for (String actionID : new TreeSet<>(PowerActionTemplate._powerActions.keySet())) {
|
||||||
|
|
||||||
|
if (EffectTemplate._effects.containsKey(actionID))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
powerActionTemplate = PowerActionTemplate._powerActions.get(actionID);
|
||||||
|
|
||||||
|
switch (powerActionTemplate.action_type) {
|
||||||
|
case ApplyEffect:
|
||||||
|
case ApplyEffects:
|
||||||
|
case Invis:
|
||||||
|
addEffect(new EffectsBase(powerActionTemplate, ++effectID));
|
||||||
|
actionKeyCount++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.info("Loaded " + EffectTemplate._effects.size() + " effects from Effects.cfg and "
|
||||||
|
+ actionKeyCount + " effect keys from PowerActions.cfg");
|
||||||
|
}
|
||||||
|
|
||||||
|
// PowerActions.cfg in id order; ids 1..n, OPENGATE keeps 5000
|
||||||
|
private static void loadPowerActions() {
|
||||||
|
|
||||||
|
int powerActionID = 0;
|
||||||
|
PowerActionTemplate powerActionTemplate;
|
||||||
|
AbstractPowerAction powerAction;
|
||||||
|
AbstractPowerAction openGateAction;
|
||||||
|
|
||||||
|
for (String actionID : new TreeSet<>(PowerActionTemplate._powerActions.keySet())) {
|
||||||
|
|
||||||
|
powerActionTemplate = PowerActionTemplate._powerActions.get(actionID);
|
||||||
|
powerAction = buildPowerAction(powerActionTemplate, ++powerActionID);
|
||||||
|
|
||||||
|
if (powerAction == null) {
|
||||||
|
Logger.error("Power action " + actionID + " has unsupported type " + powerActionTemplate.action_type);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PowersManager.ActionTokenByIDString.put(actionID, DbManager.hasher.SBStringHash(actionID));
|
||||||
|
PowersManager.powerActionsByIDString.put(actionID, powerAction);
|
||||||
|
PowersManager.powerActionsByID.put(powerAction.getUUID(), powerAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
openGateAction = new OpenGatePowerAction(5000, "OPENGATE", "OpenGate", false);
|
||||||
|
PowersManager.powerActionsByIDString.put("OPENGATE", openGateAction);
|
||||||
|
PowersManager.powerActionsByID.put(openGateAction.getUUID(), openGateAction);
|
||||||
|
|
||||||
|
Logger.info("Loaded " + PowersManager.powerActionsByIDString.size() + " power actions from PowerActions.cfg (incl. OPENGATE)");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static AbstractPowerAction buildPowerAction(PowerActionTemplate powerActionTemplate, int id) {
|
||||||
|
|
||||||
|
HashMap<String, EffectsBase> effects = PowersManager.effectsBaseByIDString;
|
||||||
|
|
||||||
|
switch (powerActionTemplate.action_type) {
|
||||||
|
case ApplyEffect:
|
||||||
|
return new ApplyEffectPowerAction(powerActionTemplate, id, effects);
|
||||||
|
case ApplyEffects:
|
||||||
|
return new ApplyEffectsPowerAction(powerActionTemplate, id, effects);
|
||||||
|
case Block:
|
||||||
|
return new BlockPowerAction(powerActionTemplate, id);
|
||||||
|
case Charm:
|
||||||
|
// FEAR and CONFUSION Charm actions stay no-ops, as when the DB typed them Confusion
|
||||||
|
if (powerActionTemplate.effect_ids.get(0).equals("CHARM"))
|
||||||
|
return new CharmPowerAction(powerActionTemplate, id);
|
||||||
|
return new ConfusionPowerAction(powerActionTemplate, id);
|
||||||
|
case ClaimMine:
|
||||||
|
return new ClaimMinePowerAction(powerActionTemplate, id);
|
||||||
|
case ClearAggro:
|
||||||
|
return new ClearAggroPowerAction(powerActionTemplate, id);
|
||||||
|
case ClearNearbyAggro:
|
||||||
|
return new ClearNearbyAggroPowerAction(powerActionTemplate, id);
|
||||||
|
case Confusion:
|
||||||
|
return new ConfusionPowerAction(powerActionTemplate, id);
|
||||||
|
case CreateMob:
|
||||||
|
return new CreateMobPowerAction(powerActionTemplate, id);
|
||||||
|
case DamageOverTime:
|
||||||
|
return new DamageOverTimePowerAction(powerActionTemplate, id, effects);
|
||||||
|
case DeferredPower:
|
||||||
|
return new DeferredPowerPowerAction(powerActionTemplate, id, effects);
|
||||||
|
case DirectDamage:
|
||||||
|
return new DirectDamagePowerAction(powerActionTemplate, id, effects);
|
||||||
|
case Invis:
|
||||||
|
return new InvisPowerAction(powerActionTemplate, id, effects);
|
||||||
|
case MobRecall:
|
||||||
|
return new MobRecallPowerAction(powerActionTemplate, id);
|
||||||
|
case Peek:
|
||||||
|
return new PeekPowerAction(powerActionTemplate, id);
|
||||||
|
case Recall:
|
||||||
|
return new RecallPowerAction(powerActionTemplate, id);
|
||||||
|
case RemoveEffect:
|
||||||
|
return new RemoveEffectPowerAction(powerActionTemplate, id);
|
||||||
|
case Resurrect:
|
||||||
|
return new ResurrectPowerAction(powerActionTemplate, id);
|
||||||
|
case RunegateTeleport:
|
||||||
|
return new RunegateTeleportPowerAction(powerActionTemplate, id);
|
||||||
|
case SetItemFlag:
|
||||||
|
return new SetItemFlagPowerAction(powerActionTemplate, id);
|
||||||
|
case SimpleDamage:
|
||||||
|
return new SimpleDamagePowerAction(powerActionTemplate, id);
|
||||||
|
case SpireDisable:
|
||||||
|
return new SpireDisablePowerAction(powerActionTemplate, id);
|
||||||
|
case Steal:
|
||||||
|
return new StealPowerAction(powerActionTemplate, id);
|
||||||
|
case Summon:
|
||||||
|
return new SummonPowerAction(powerActionTemplate, id);
|
||||||
|
case Teleport:
|
||||||
|
return new TeleportPowerAction(powerActionTemplate, id);
|
||||||
|
case Track:
|
||||||
|
return new TrackPowerAction(powerActionTemplate, id, effects);
|
||||||
|
case TransferStat:
|
||||||
|
return new TransferStatPowerAction(powerActionTemplate, id, effects);
|
||||||
|
case TransferStatOT:
|
||||||
|
return new TransferStatOTPowerAction(powerActionTemplate, id, effects);
|
||||||
|
case Transform:
|
||||||
|
return new TransformPowerAction(powerActionTemplate, id, effects);
|
||||||
|
case TreeChoke:
|
||||||
|
return new TreeChokePowerAction(powerActionTemplate, id);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addEffect(EffectsBase effectsBase) {
|
||||||
|
PowersManager.effectsBaseByToken.put(effectsBase.getToken(), effectsBase);
|
||||||
|
PowersManager.effectsBaseByIDString.put(effectsBase.getIDString(), effectsBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Powers.cfg in file order, ids 1..n (the old static_power_powerbase IDs)
|
||||||
|
private static void loadPowers() {
|
||||||
|
|
||||||
|
int powerID = 0;
|
||||||
|
PowersBase powersBase;
|
||||||
|
|
||||||
|
for (PowerTemplate powerTemplate : PowerTemplate._powers.values()) {
|
||||||
|
powersBase = new PowersBase(powerTemplate, ++powerID);
|
||||||
|
PowersManager.powersBaseByIDString.put(powersBase.getIDString(), powersBase);
|
||||||
|
PowersManager.powersBaseByToken.put(powersBase.getToken(), powersBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.info("Loaded " + PowersManager.powersBaseByIDString.size() + " powers from Powers.cfg");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ACTION= lines in Powers.cfg order, ids 1..n (offset in ActionsBase), then the OPENGATE actions
|
||||||
|
private static void loadActionLists() {
|
||||||
|
|
||||||
|
int actionID = 0;
|
||||||
|
PowersBase powersBase;
|
||||||
|
AbstractPowerAction powerAction;
|
||||||
|
|
||||||
|
for (PowerTemplate powerTemplate : PowerTemplate._powers.values()) {
|
||||||
|
|
||||||
|
powersBase = PowersManager.powersBaseByIDString.get(powerTemplate.power_id);
|
||||||
|
|
||||||
|
for (PowerTemplate.ActionEntry actionEntry : powerTemplate.actions) {
|
||||||
|
|
||||||
|
powerAction = PowersManager.powerActionsByIDString.get(actionEntry.action_id);
|
||||||
|
|
||||||
|
if (powerAction == null) {
|
||||||
|
Logger.error("Power " + powerTemplate.power_id + " lists unknown action " + actionEntry.action_id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
powersBase.getActions().add(new ActionsBase(actionEntry, powerTemplate.power_id, ++actionID, powerAction));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionsBase.addOpenGateActions(PowersManager.powersBaseByIDString);
|
||||||
|
|
||||||
|
Logger.info("Loaded " + actionID + " power action lines from Powers.cfg");
|
||||||
|
}
|
||||||
|
|
||||||
|
// The login server needs only the token map
|
||||||
|
public static void InitializeLoginPowers() {
|
||||||
|
loadPowers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<RunePowerEntry> getPowersForRune(int rune_id) {
|
public static ArrayList<RunePowerEntry> getPowersForRune(int rune_id) {
|
||||||
@@ -115,48 +300,13 @@ public enum PowersManager {
|
|||||||
// This pre-loads all powers and effects
|
// This pre-loads all powers and effects
|
||||||
public static void InitializePowers() {
|
public static void InitializePowers() {
|
||||||
|
|
||||||
// Add EffectsBase
|
loadEffects();
|
||||||
ArrayList<EffectsBase> ebList = dbEffectsBaseHandler.getAllEffectsBase();
|
|
||||||
|
|
||||||
for (EffectsBase eb : ebList) {
|
loadPowerActions();
|
||||||
PowersManager.effectsBaseByToken.put(eb.getToken(), eb);
|
|
||||||
PowersManager.effectsBaseByIDString.put(eb.getIDString(), eb);
|
|
||||||
|
|
||||||
}
|
loadPowers();
|
||||||
|
|
||||||
// Add Fail Conditions
|
|
||||||
EffectsBase.getFailConditions(PowersManager.effectsBaseByIDString);
|
|
||||||
|
|
||||||
// Add Modifiers to Effects
|
|
||||||
dbEffectsBaseHandler.cacheAllEffectModifiers();
|
|
||||||
|
|
||||||
// Add Source Types to Effects
|
|
||||||
dbPowerHandler.addAllSourceTypes();
|
|
||||||
dbPowerHandler.addAllAnimationOverrides();
|
|
||||||
|
|
||||||
// Add PowerActions
|
|
||||||
AbstractPowerAction.getAllPowerActions(PowersManager.powerActionsByIDString, PowersManager.powerActionsByID, PowersManager.effectsBaseByIDString);
|
|
||||||
|
|
||||||
// Load valid Item Flags
|
|
||||||
// AbstractPowerAction.loadValidItemFlags(PowersManager.powerActionsByIDString);
|
|
||||||
|
|
||||||
// get all PowersBase
|
|
||||||
ArrayList<PowersBase> pbList = dbSkillReqHandler.getAllPowersBase();
|
|
||||||
for (PowersBase pb : pbList) {
|
|
||||||
if (pb.getToken() != 0) {
|
|
||||||
PowersManager.powersBaseByIDString.put(pb.getIDString(), pb);
|
|
||||||
PowersManager.powersBaseByToken.put(pb.getToken(), pb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add Power Prereqs
|
|
||||||
PowerPrereq.getAllPowerPrereqs(PowersManager.powersBaseByIDString);
|
|
||||||
// Add Fail Conditions
|
|
||||||
dbSkillReqHandler.getFailConditions(PowersManager.powersBaseByIDString);
|
|
||||||
// Add Actions Base
|
|
||||||
ActionsBase.getActionsBase(PowersManager.powersBaseByIDString,
|
|
||||||
PowersManager.powerActionsByIDString);
|
|
||||||
|
|
||||||
|
loadActionLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EffectsBase setEffectToken(int ID, int token) {
|
public static EffectsBase setEffectToken(int ID, int token) {
|
||||||
@@ -1255,6 +1405,27 @@ public enum PowersManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MONSTERTYPERESTRICTS: mobs use their race rune's monster type, players their RaceType's
|
||||||
|
private static boolean isRestrictedMonsterType(AbstractWorldObject target, PowersBase pb) {
|
||||||
|
|
||||||
|
MonsterType monsterType = null;
|
||||||
|
PlayerCharacter player;
|
||||||
|
|
||||||
|
if (target == null || pb.monsterTypeRestrictions.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (target.getObjectType() == GameObjectType.Mob && ((Mob) target).getMobBase() != null)
|
||||||
|
monsterType = ((Mob) target).getMobBase().monsterType;
|
||||||
|
else if (target.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||||
|
player = (PlayerCharacter) target;
|
||||||
|
|
||||||
|
if (player.race != null && player.race.getRaceType() != null)
|
||||||
|
monsterType = player.race.getRaceType().getMonsterType();
|
||||||
|
}
|
||||||
|
|
||||||
|
return monsterType != null && pb.monsterTypeRestrictions.contains(monsterType);
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendRecyclePower(int token, ClientConnection origin) {
|
public static void sendRecyclePower(int token, ClientConnection origin) {
|
||||||
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(token);
|
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(token);
|
||||||
|
|
||||||
@@ -1580,9 +1751,6 @@ public enum PowersManager {
|
|||||||
//Pet only
|
//Pet only
|
||||||
allTargets = WorldGrid.getObjectsInRangePartial(
|
allTargets = WorldGrid.getObjectsInRangePartial(
|
||||||
targetLoc, pb.getRadius(), MBServerStatics.MASK_PET);
|
targetLoc, pb.getRadius(), MBServerStatics.MASK_PET);
|
||||||
else if (pb.targetNecroPet())
|
|
||||||
allTargets = WorldGrid.getObjectsInRangePartialNecroPets(
|
|
||||||
targetLoc, pb.getRadius());
|
|
||||||
else
|
else
|
||||||
allTargets = WorldGrid.getObjectsInRangePartial(
|
allTargets = WorldGrid.getObjectsInRangePartial(
|
||||||
targetLoc, pb.getRadius(), 0);
|
targetLoc, pb.getRadius(), 0);
|
||||||
@@ -1694,6 +1862,11 @@ public enum PowersManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRestrictedMonsterType(awo, pb)) {
|
||||||
|
awolist.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (awo != null && awo.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
if (awo != null && awo.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||||
|
|
||||||
// Remove players who are in safe mode
|
// Remove players who are in safe mode
|
||||||
@@ -1779,9 +1952,6 @@ public enum PowersManager {
|
|||||||
//Pet only
|
//Pet only
|
||||||
allTargets = WorldGrid.getObjectsInRangePartial(
|
allTargets = WorldGrid.getObjectsInRangePartial(
|
||||||
targetLoc, pb.getRadius(), MBServerStatics.MASK_PET);
|
targetLoc, pb.getRadius(), MBServerStatics.MASK_PET);
|
||||||
else if (pb.targetNecroPet())
|
|
||||||
allTargets = WorldGrid.getObjectsInRangePartialNecroPets(
|
|
||||||
targetLoc, pb.getRadius());
|
|
||||||
else
|
else
|
||||||
allTargets = WorldGrid.getObjectsInRangePartial(
|
allTargets = WorldGrid.getObjectsInRangePartial(
|
||||||
targetLoc, pb.getRadius(), 0);
|
targetLoc, pb.getRadius(), 0);
|
||||||
@@ -1846,6 +2016,11 @@ public enum PowersManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRestrictedMonsterType(awo, pb)) {
|
||||||
|
awolist.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (awo != null && awo.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
if (awo != null && awo.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||||
// Remove players who are in safe mode
|
// Remove players who are in safe mode
|
||||||
PlayerCharacter pcc = (PlayerCharacter) awo;
|
PlayerCharacter pcc = (PlayerCharacter) awo;
|
||||||
@@ -2238,14 +2413,14 @@ public enum PowersManager {
|
|||||||
String outmsg = "Invalid Target";
|
String outmsg = "Invalid Target";
|
||||||
ChatManager.chatSystemInfo(pc, outmsg);
|
ChatManager.chatSystemInfo(pc, outmsg);
|
||||||
return false; // can't target player, stop here
|
return false; // can't target player, stop here
|
||||||
} // target is mob
|
} // target is pet; pets also carry MASK_MOB, so test them first. A pet is still a Mobile (client 0x49E440)
|
||||||
|
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_PET) != 0)
|
||||||
|
return pb.targetPet() || pb.targetMob();
|
||||||
|
|
||||||
|
// target is mob
|
||||||
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_MOB) != 0)
|
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_MOB) != 0)
|
||||||
return pb.targetMob();
|
return pb.targetMob();
|
||||||
|
|
||||||
// target is pet
|
|
||||||
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_PET) != 0)
|
|
||||||
return pb.targetPet();
|
|
||||||
|
|
||||||
// target is Building
|
// target is Building
|
||||||
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_BUILDING) != 0)
|
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_BUILDING) != 0)
|
||||||
return pb.targetBuilding();
|
return pb.targetBuilding();
|
||||||
@@ -2255,12 +2430,12 @@ public enum PowersManager {
|
|||||||
if (pb.targetItem())
|
if (pb.targetItem())
|
||||||
return true;
|
return true;
|
||||||
// TODO add these checks later
|
// TODO add these checks later
|
||||||
else if (pb.targetArmor() && item.template.item_type.equals(ItemType.ARMOR))
|
else if (pb.targetArmor() && item.template.getItemType().equals(ItemType.ARMOR))
|
||||||
return true;
|
return true;
|
||||||
else if (pb.targetJewelry() && item.template.item_type.equals(ItemType.JEWELRY))
|
else if (pb.targetJewelry() && item.template.getItemType().equals(ItemType.JEWELRY))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return pb.targetWeapon() && item.template.item_type.equals(ItemType.WEAPON);
|
return pb.targetWeapon() && item.template.getItemType().equals(ItemType.WEAPON);
|
||||||
} // How did we get here? all valid targets have been covered
|
} // How did we get here? all valid targets have been covered
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -0,0 +1,261 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2026
|
||||||
|
// https://www.magicbane.com
|
||||||
|
|
||||||
|
package engine.gameManager;
|
||||||
|
|
||||||
|
import engine.math.Quaternion;
|
||||||
|
import engine.mbEnums.ZonePropType;
|
||||||
|
import engine.objects.Building;
|
||||||
|
import engine.objects.Guild;
|
||||||
|
import engine.objects.Zone;
|
||||||
|
import engine.parsers.objects.CZoneProp;
|
||||||
|
import engine.parsers.objects.ZoneTreeEntry;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
// World Boot Plan Task 2.3: builds every CZONE prop of the static zones through Building.createStaticBuilding
|
||||||
|
// and compares it with the DB building it replaces. The JSON buildings are discarded and take no static IDs.
|
||||||
|
|
||||||
|
public enum StaticBuildingParity {
|
||||||
|
|
||||||
|
STATICBUILDINGPARITY;
|
||||||
|
|
||||||
|
private static final float POSITION_TOLERANCE = 0.01f;
|
||||||
|
private static final float ROTATION_TOLERANCE = 0.0001f;
|
||||||
|
private static final int EXAMPLES = 5;
|
||||||
|
|
||||||
|
private static final TreeMap<String, ArrayList<String>> differences = new TreeMap<>();
|
||||||
|
private static int propCount;
|
||||||
|
private static int matchCount;
|
||||||
|
private static float maxChildMove;
|
||||||
|
|
||||||
|
public static boolean isEnabled() {
|
||||||
|
return ConfigManager.MB_STATIC_BUILDINGS.getValue().equalsIgnoreCase("parity");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run after NPCs load, so a DB building's owner resolves to its guild.
|
||||||
|
public static void run() {
|
||||||
|
|
||||||
|
Zone zone;
|
||||||
|
ArrayList<Building> dbTopLevel = new ArrayList<>();
|
||||||
|
ArrayList<Building> dbChildren = new ArrayList<>();
|
||||||
|
ArrayList<Building> dbUnmatched = new ArrayList<>();
|
||||||
|
int propIndex;
|
||||||
|
|
||||||
|
for (ZoneTreeEntry treeEntry : ZoneManager.zoneTree) {
|
||||||
|
|
||||||
|
zone = ZoneManager.getZoneByUUID(treeEntry.uid);
|
||||||
|
|
||||||
|
if (zone == null || zone.template == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
dbTopLevel.clear();
|
||||||
|
dbChildren.clear();
|
||||||
|
|
||||||
|
// Mine towers (blueprint 1500100) stay DB objects (Task 2.1, D1); every CZONE prop has blueprint 0.
|
||||||
|
for (Building building : zone.zoneBuildingSet) {
|
||||||
|
|
||||||
|
if (building.blueprintUUID != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (building.parentBuildingID == 0)
|
||||||
|
dbTopLevel.add(building);
|
||||||
|
else
|
||||||
|
dbChildren.add(building);
|
||||||
|
}
|
||||||
|
|
||||||
|
propIndex = 0;
|
||||||
|
|
||||||
|
for (CZoneProp prop : zone.template.zone_prop_info) {
|
||||||
|
compareProp(zone, prop, "prop:" + zone.getObjectUUID() + "/" + propIndex, dbTopLevel, dbChildren);
|
||||||
|
propIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbUnmatched.addAll(dbTopLevel);
|
||||||
|
dbUnmatched.addAll(dbChildren);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Building building : dbUnmatched)
|
||||||
|
addDifference("DB only", building.getObjectUUID() + " zone " + building.parentZoneUUID + " mesh " + building.meshUUID
|
||||||
|
+ " '" + building.getName() + "' at " + building.statLat + ", " + building.statLon + " parent " + building.parentBuildingID);
|
||||||
|
|
||||||
|
Logger.info("Static building parity: " + propCount + " props, " + matchCount + " matched, max child x/z move from the parent yaw " + maxChildMove);
|
||||||
|
|
||||||
|
for (Map.Entry<String, ArrayList<String>> entry : differences.entrySet()) {
|
||||||
|
|
||||||
|
Logger.info(" " + entry.getKey() + ": " + entry.getValue().size());
|
||||||
|
|
||||||
|
for (int i = 0; i < Math.min(EXAMPLES, entry.getValue().size()); i++)
|
||||||
|
Logger.info(" " + entry.getValue().get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
differences.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void compareProp(Zone zone, CZoneProp prop, String key, ArrayList<Building> dbTopLevel, ArrayList<Building> dbChildren) {
|
||||||
|
|
||||||
|
Building jsonBuilding;
|
||||||
|
Building dbBuilding;
|
||||||
|
Building jsonChild;
|
||||||
|
Building dbChild;
|
||||||
|
ArrayList<Building> dbChildCandidates = new ArrayList<>();
|
||||||
|
String childKey;
|
||||||
|
float childMove;
|
||||||
|
int childIndex;
|
||||||
|
|
||||||
|
jsonBuilding = Building.createStaticBuilding(zone, prop, null);
|
||||||
|
dbBuilding = takeMatch(jsonBuilding, dbTopLevel);
|
||||||
|
propCount++;
|
||||||
|
|
||||||
|
if (dbBuilding == null)
|
||||||
|
addDifference("JSON only", key + " mesh " + jsonBuilding.meshUUID + " '" + jsonBuilding.getName() + "'");
|
||||||
|
else {
|
||||||
|
compareBuilding(key, prop, dbBuilding, jsonBuilding);
|
||||||
|
|
||||||
|
if (dbBuilding.getLoc().distance2D(jsonBuilding.getLoc()) > POSITION_TOLERANCE
|
||||||
|
|| Math.abs(dbBuilding.getLoc().y - jsonBuilding.getLoc().y) > POSITION_TOLERANCE)
|
||||||
|
addDifference("top-level world location", key + " DB " + dbBuilding.getLoc() + " JSON " + jsonBuilding.getLoc());
|
||||||
|
|
||||||
|
for (Building candidate : dbChildren)
|
||||||
|
if (candidate.parentBuildingID == dbBuilding.getObjectUUID())
|
||||||
|
dbChildCandidates.add(candidate);
|
||||||
|
}
|
||||||
|
|
||||||
|
childIndex = 0;
|
||||||
|
|
||||||
|
for (CZoneProp childProp : prop.prop_content_props) {
|
||||||
|
|
||||||
|
childKey = key + "/" + childIndex;
|
||||||
|
jsonChild = Building.createStaticBuilding(zone, childProp, jsonBuilding);
|
||||||
|
dbChild = takeMatch(jsonChild, dbChildCandidates);
|
||||||
|
|
||||||
|
propCount++;
|
||||||
|
childIndex++;
|
||||||
|
|
||||||
|
if (dbChild == null) {
|
||||||
|
addDifference("JSON only", childKey + " mesh " + jsonChild.meshUUID + " '" + jsonChild.getName() + "'");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbChildren.remove(dbChild);
|
||||||
|
compareBuilding(childKey, childProp, dbChild, jsonChild);
|
||||||
|
|
||||||
|
if (Math.abs(dbChild.getStatAlt() - jsonChild.getStatAlt()) > POSITION_TOLERANCE)
|
||||||
|
addDifference("child local Y", childKey + " DB " + dbChild.getStatAlt() + " JSON " + jsonChild.getStatAlt());
|
||||||
|
|
||||||
|
// Today's runAfterLoad adds the child offset without the parent's yaw.
|
||||||
|
childMove = dbChild.getLoc().distance2D(jsonChild.getLoc());
|
||||||
|
|
||||||
|
if (childMove > POSITION_TOLERANCE) {
|
||||||
|
addDifference("child world x/z (parent yaw)", childKey + " moved " + childMove);
|
||||||
|
maxChildMove = Math.max(maxChildMove, childMove);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same mesh and local x/z; removes and returns the closest DB building, or null.
|
||||||
|
private static Building takeMatch(Building jsonBuilding, ArrayList<Building> candidates) {
|
||||||
|
|
||||||
|
Building found = null;
|
||||||
|
float foundDistance = Float.MAX_VALUE;
|
||||||
|
float distance;
|
||||||
|
|
||||||
|
for (Building candidate : candidates) {
|
||||||
|
|
||||||
|
if (candidate.meshUUID != jsonBuilding.meshUUID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
distance = Math.max(Math.abs(candidate.statLat - jsonBuilding.statLat), Math.abs(candidate.statLon - jsonBuilding.statLon));
|
||||||
|
|
||||||
|
if (distance <= POSITION_TOLERANCE && distance < foundDistance) {
|
||||||
|
found = candidate;
|
||||||
|
foundDistance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found != null) {
|
||||||
|
candidates.remove(found);
|
||||||
|
matchCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void compareBuilding(String key, CZoneProp prop, Building dbBuilding, Building jsonBuilding) {
|
||||||
|
|
||||||
|
String prefix = key + " (DB " + dbBuilding.getObjectUUID() + ")";
|
||||||
|
String dbGuild = guildName(dbBuilding);
|
||||||
|
String jsonGuild = "";
|
||||||
|
|
||||||
|
if (!sameRotation(dbBuilding.getRotation(), jsonBuilding.getRotation()))
|
||||||
|
addDifference("rotation", prefix + " DB " + rotationText(dbBuilding.getRotation()) + " JSON " + rotationText(jsonBuilding.getRotation()));
|
||||||
|
|
||||||
|
if (!dbBuilding.getMeshScale().equals(jsonBuilding.getMeshScale()))
|
||||||
|
addDifference("scale", prefix + " DB " + dbBuilding.getMeshScale() + " JSON " + jsonBuilding.getMeshScale());
|
||||||
|
|
||||||
|
if (dbBuilding.rank != jsonBuilding.rank)
|
||||||
|
addDifference("rank", prefix + " DB " + dbBuilding.rank + " JSON " + jsonBuilding.rank);
|
||||||
|
|
||||||
|
if (dbBuilding.getStrongboxValue() != jsonBuilding.getStrongboxValue())
|
||||||
|
addDifference("strongbox", prefix + " DB " + dbBuilding.getStrongboxValue() + " JSON " + jsonBuilding.getStrongboxValue());
|
||||||
|
|
||||||
|
if (!dbBuilding.getName().equals(jsonBuilding.getName()))
|
||||||
|
addDifference("name", prefix + " DB '" + dbBuilding.getName() + "' JSON '" + jsonBuilding.getName() + "'");
|
||||||
|
|
||||||
|
if (dbBuilding.floor != jsonBuilding.floor || dbBuilding.level != jsonBuilding.level)
|
||||||
|
addDifference("floor/level", prefix + " DB " + dbBuilding.floor + "/" + dbBuilding.level + " JSON " + jsonBuilding.floor + "/" + jsonBuilding.level);
|
||||||
|
|
||||||
|
if (dbBuilding.protectionState != jsonBuilding.protectionState)
|
||||||
|
addDifference("protection", prefix + " DB " + dbBuilding.protectionState + " JSON " + jsonBuilding.protectionState);
|
||||||
|
|
||||||
|
if (dbBuilding.isFurniture != jsonBuilding.isFurniture)
|
||||||
|
addDifference("furniture flag", prefix + " DB " + dbBuilding.isFurniture + " JSON " + jsonBuilding.isFurniture);
|
||||||
|
|
||||||
|
// Owners are wired in 2.4; until then compare the guild the CITY prop's key names.
|
||||||
|
if (prop.prop_type == ZonePropType.CITY && GuildManager._npcGuildsByKey.containsKey(prop.city_prop_gm_guild))
|
||||||
|
jsonGuild = GuildManager._npcGuildsByKey.get(prop.city_prop_gm_guild).getName();
|
||||||
|
|
||||||
|
if (!dbGuild.equals(jsonGuild))
|
||||||
|
addDifference("owner guild", prefix + " DB '" + dbGuild + "' JSON '" + jsonGuild + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
// q and -q are the same rotation.
|
||||||
|
private static boolean sameRotation(Quaternion a, Quaternion b) {
|
||||||
|
|
||||||
|
boolean same = Math.abs(a.w - b.w) < ROTATION_TOLERANCE && Math.abs(a.x - b.x) < ROTATION_TOLERANCE
|
||||||
|
&& Math.abs(a.y - b.y) < ROTATION_TOLERANCE && Math.abs(a.z - b.z) < ROTATION_TOLERANCE;
|
||||||
|
boolean negated = Math.abs(a.w + b.w) < ROTATION_TOLERANCE && Math.abs(a.x + b.x) < ROTATION_TOLERANCE
|
||||||
|
&& Math.abs(a.y + b.y) < ROTATION_TOLERANCE && Math.abs(a.z + b.z) < ROTATION_TOLERANCE;
|
||||||
|
|
||||||
|
return same || negated;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String rotationText(Quaternion rotation) {
|
||||||
|
return "(w " + rotation.w + ", x " + rotation.x + ", y " + rotation.y + ", z " + rotation.z + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String guildName(Building building) {
|
||||||
|
|
||||||
|
Guild guild;
|
||||||
|
|
||||||
|
if (building.getOwnerUUID() == 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
guild = building.getGuild();
|
||||||
|
|
||||||
|
return guild == null || guild.isEmptyGuild() ? "" : guild.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addDifference(String differenceClass, String line) {
|
||||||
|
differences.computeIfAbsent(differenceClass, k -> new ArrayList<>()).add(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,246 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2026
|
||||||
|
// https://www.magicbane.com
|
||||||
|
|
||||||
|
package engine.gameManager;
|
||||||
|
|
||||||
|
import engine.mbEnums.GameObjectType;
|
||||||
|
import engine.parsers.cache.CacheParserUtil;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
// W2 safety net: every static ID with its natural key, in load order, written to maps/<map>.manifest at boot.
|
||||||
|
// Diffing against the previous boot's file shows IDs that moved; the orphan check shows DB references they broke.
|
||||||
|
|
||||||
|
public enum StaticManifest {
|
||||||
|
|
||||||
|
STATICMANIFEST;
|
||||||
|
|
||||||
|
private static final String mapPath = ConfigManager.DEFAULT_DATA_DIR + "maps/";
|
||||||
|
|
||||||
|
// Player data columns that can hold a static ID (findings §5, Task 2.1). A null type accepts any static object.
|
||||||
|
private static final String[][] referenceColumns = {
|
||||||
|
{"object", "parent", null},
|
||||||
|
{"obj_character", "char_bindBuilding", "Building"},
|
||||||
|
{"obj_character", "guildUID", "Guild"},
|
||||||
|
{"dyn_character_guildhistory", "GuildID", "Guild"},
|
||||||
|
{"dyn_guild_allianceenemylist", "OtherGuildID", "Guild"},
|
||||||
|
{"dyn_guild_guildkoslist", "KOSGuildID", "Guild"},
|
||||||
|
{"obj_mob", "mob_buildingID", "Building"},
|
||||||
|
{"obj_mob", "mob_guildUID", "Guild"},
|
||||||
|
{"obj_npc", "npc_buildingID", "Building"},
|
||||||
|
{"obj_npc", "npc_guildID", "Guild"},
|
||||||
|
{"obj_city", "treeOfLifeUUID", "Building"},
|
||||||
|
{"static_runegate_portals", "sourceBuilding", "Building"},
|
||||||
|
{"static_runegate_portals", "targetBuilding", "Building"},
|
||||||
|
{"obj_mine", "mine_buildingUID", "Building"}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final ArrayList<ManifestEntry> entries = new ArrayList<>();
|
||||||
|
private static final HashMap<Integer, ManifestEntry> entriesByID = new HashMap<>();
|
||||||
|
private static final HashMap<String, ManifestEntry> entriesByKey = new HashMap<>();
|
||||||
|
|
||||||
|
public static void addEntry(int staticID, GameObjectType objectType, String key) {
|
||||||
|
|
||||||
|
ManifestEntry entry = new ManifestEntry(staticID, objectType.name(), key);
|
||||||
|
|
||||||
|
if (entriesByKey.containsKey(key))
|
||||||
|
throw new IllegalStateException("Static manifest key " + key + " is used twice");
|
||||||
|
|
||||||
|
entries.add(entry);
|
||||||
|
entriesByID.put(staticID, entry);
|
||||||
|
entriesByKey.put(key, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logs moved, vanished and re-targeted IDs against the previous manifest, then replaces it (old copy kept as .prev).
|
||||||
|
|
||||||
|
public static void writeManifest(int mapID) {
|
||||||
|
|
||||||
|
File manifestFile = new File(mapPath + mapID + ".manifest");
|
||||||
|
File previousFile = new File(mapPath + mapID + ".manifest.prev");
|
||||||
|
HashMap<String, ManifestEntry> previousByKey;
|
||||||
|
StringBuilder manifestText = new StringBuilder();
|
||||||
|
|
||||||
|
previousByKey = readManifest(manifestFile, mapID);
|
||||||
|
|
||||||
|
if (previousByKey != null)
|
||||||
|
diffManifest(previousByKey);
|
||||||
|
|
||||||
|
manifestText.append("{\n \"map\": ").append(mapID).append(",\n \"count\": ").append(entries.size())
|
||||||
|
.append(",\n \"statics\": [\n");
|
||||||
|
|
||||||
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
|
manifestText.append(" ").append(entries.get(i).toJson());
|
||||||
|
manifestText.append(i < entries.size() - 1 ? ",\n" : "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
manifestText.append(" ]\n}\n");
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (manifestFile.exists())
|
||||||
|
Files.copy(manifestFile.toPath(), previousFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
|
Files.write(manifestFile.toPath(), manifestText.toString().getBytes(StandardCharsets.UTF_8));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.error("Static manifest not written: " + manifestFile.getAbsolutePath() + ": " + e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.info("Static manifest: " + entries.size() + " static IDs written to " + manifestFile.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logs every negative DB reference (below -1, which means "none") that no loaded static object of the right type holds.
|
||||||
|
|
||||||
|
public static void logOrphanReferences() {
|
||||||
|
|
||||||
|
HashMap<Integer, Integer> negativeValues;
|
||||||
|
ManifestEntry entry;
|
||||||
|
String expectedType;
|
||||||
|
String problem;
|
||||||
|
int orphanColumns = 0;
|
||||||
|
int orphanRows = 0;
|
||||||
|
|
||||||
|
for (String[] referenceColumn : referenceColumns) {
|
||||||
|
|
||||||
|
expectedType = referenceColumn[2];
|
||||||
|
negativeValues = DbManager.StaticWorldQueries.GET_NEGATIVE_REFERENCES(referenceColumn[0], referenceColumn[1]);
|
||||||
|
|
||||||
|
if (negativeValues == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (Map.Entry<Integer, Integer> negativeValue : negativeValues.entrySet()) {
|
||||||
|
|
||||||
|
entry = entriesByID.get(negativeValue.getKey());
|
||||||
|
|
||||||
|
if (entry == null)
|
||||||
|
problem = "no static object";
|
||||||
|
else if (DbManager.getFromCache(GameObjectType.valueOf(entry.type), entry.id) == null)
|
||||||
|
problem = entry.type + " " + entry.key + " is not loaded";
|
||||||
|
else if (expectedType != null && !expectedType.equals(entry.type))
|
||||||
|
problem = "points at " + entry.type + " " + entry.key + ", expected " + expectedType;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Logger.warn("Orphan reference: " + referenceColumn[0] + "." + referenceColumn[1] + " = "
|
||||||
|
+ negativeValue.getKey() + " on " + negativeValue.getValue() + " rows: " + problem);
|
||||||
|
orphanColumns++;
|
||||||
|
orphanRows += negativeValue.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.info("Static orphan check: " + orphanColumns + " orphan values on " + orphanRows + " rows");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HashMap<String, ManifestEntry> readManifest(File manifestFile, int mapID) {
|
||||||
|
|
||||||
|
HashMap<String, ManifestEntry> previousByKey = new HashMap<>();
|
||||||
|
JSONObject manifestJson;
|
||||||
|
JSONArray staticsJson;
|
||||||
|
JSONObject entryJson;
|
||||||
|
|
||||||
|
if (!manifestFile.exists()) {
|
||||||
|
Logger.info("Static manifest: no previous " + manifestFile.getName() + ", nothing to diff");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
manifestJson = CacheParserUtil.readJsonFile(manifestFile);
|
||||||
|
|
||||||
|
if (manifestJson.getInt("map") != mapID) {
|
||||||
|
Logger.error(manifestFile.getName() + ": map " + manifestJson.getInt("map") + " does not match MB_WORLD_MAPID " + mapID);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
staticsJson = manifestJson.getJSONArray("statics");
|
||||||
|
|
||||||
|
for (int i = 0; i < staticsJson.length(); i++) {
|
||||||
|
entryJson = staticsJson.getJSONObject(i);
|
||||||
|
previousByKey.put(entryJson.getString("key"),
|
||||||
|
new ManifestEntry(entryJson.getInt("id"), entryJson.getString("type"), entryJson.getString("key")));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.error("Previous static manifest unreadable, nothing to diff: " + manifestFile.getName() + ": " + e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return previousByKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A re-targeted ID is the dangerous case: player references to it now silently point at a different object.
|
||||||
|
|
||||||
|
private static void diffManifest(HashMap<String, ManifestEntry> previousByKey) {
|
||||||
|
|
||||||
|
HashMap<Integer, ManifestEntry> previousByID = new HashMap<>();
|
||||||
|
ManifestEntry currentEntry;
|
||||||
|
ManifestEntry previousEntry;
|
||||||
|
int moved = 0;
|
||||||
|
int vanished = 0;
|
||||||
|
int retargeted = 0;
|
||||||
|
int added = 0;
|
||||||
|
|
||||||
|
for (ManifestEntry entry : previousByKey.values())
|
||||||
|
previousByID.put(entry.id, entry);
|
||||||
|
|
||||||
|
for (ManifestEntry entry : previousByKey.values()) {
|
||||||
|
|
||||||
|
currentEntry = entriesByKey.get(entry.key);
|
||||||
|
|
||||||
|
if (currentEntry == null) {
|
||||||
|
Logger.warn("Static manifest: " + entry.type + " " + entry.key + " (was " + entry.id + ") vanished");
|
||||||
|
vanished++;
|
||||||
|
} else if (currentEntry.id != entry.id) {
|
||||||
|
Logger.warn("Static manifest: " + entry.type + " " + entry.key + " moved " + entry.id + " -> " + currentEntry.id);
|
||||||
|
moved++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ManifestEntry entry : entries) {
|
||||||
|
|
||||||
|
previousEntry = previousByID.get(entry.id);
|
||||||
|
|
||||||
|
if (!previousByKey.containsKey(entry.key))
|
||||||
|
added++;
|
||||||
|
|
||||||
|
if (previousEntry != null && !previousEntry.key.equals(entry.key)) {
|
||||||
|
Logger.warn("Static manifest: ID " + entry.id + " re-targeted from " + previousEntry.type + " "
|
||||||
|
+ previousEntry.key + " to " + entry.type + " " + entry.key);
|
||||||
|
retargeted++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.info("Static manifest diff: " + moved + " moved, " + vanished + " vanished, " + retargeted
|
||||||
|
+ " re-targeted, " + added + " new");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ManifestEntry {
|
||||||
|
|
||||||
|
private final int id;
|
||||||
|
private final String type;
|
||||||
|
private final String key;
|
||||||
|
|
||||||
|
private ManifestEntry(int id, String type, String key) {
|
||||||
|
this.id = id;
|
||||||
|
this.type = type;
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toJson() {
|
||||||
|
return "{\"id\": " + id + ", \"type\": " + JSONObject.quote(type) + ", \"key\": " + JSONObject.quote(key) + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,7 +17,9 @@ import engine.mbEnums;
|
|||||||
import engine.objects.Building;
|
import engine.objects.Building;
|
||||||
import engine.objects.City;
|
import engine.objects.City;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import engine.objects.ZoneTemplate;
|
import engine.parsers.map.ZoneTreeParser;
|
||||||
|
import engine.parsers.objects.CZoneTemplate;
|
||||||
|
import engine.parsers.objects.ZoneTreeEntry;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -36,7 +38,8 @@ public enum ZoneManager {
|
|||||||
|
|
||||||
ZONEMANAGER;
|
ZONEMANAGER;
|
||||||
|
|
||||||
public static HashMap<Integer, ZoneTemplate> _zone_templates = new HashMap<>();
|
public static HashMap<Integer, CZoneTemplate> _zone_templates = new HashMap<>();
|
||||||
|
public static ArrayList<ZoneTreeEntry> zoneTree;
|
||||||
|
|
||||||
public static final Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
public static final Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
private static final ConcurrentHashMap<Integer, Zone> zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
private static final ConcurrentHashMap<Integer, Zone> zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||||
@@ -51,6 +54,76 @@ public enum ZoneManager {
|
|||||||
/* Instance variables */
|
/* Instance variables */
|
||||||
public static Zone seaFloor = null;
|
public static Zone seaFloor = null;
|
||||||
|
|
||||||
|
// CZONE templates plus the server's player-city template 0, which has no CZONE file
|
||||||
|
|
||||||
|
public static void loadZoneTemplates() {
|
||||||
|
|
||||||
|
CZoneTemplate playerCityTemplate = new CZoneTemplate();
|
||||||
|
|
||||||
|
_zone_templates.putAll(CZoneTemplate._zones);
|
||||||
|
|
||||||
|
playerCityTemplate.template_id = 0;
|
||||||
|
playerCityTemplate.zone_sea_level_type = mbEnums.SeaLevelType.PARENT;
|
||||||
|
playerCityTemplate.zone_sea_level = 0;
|
||||||
|
playerCityTemplate.zone_max_blend = 128;
|
||||||
|
playerCityTemplate.zone_min_blend = 128;
|
||||||
|
playerCityTemplate.terrain_max_y = 5;
|
||||||
|
playerCityTemplate.zone_major_radius = (int) mbEnums.CityBoundsType.ZONE.halfExtents;
|
||||||
|
playerCityTemplate.zone_minor_radius = (int) mbEnums.CityBoundsType.ZONE.halfExtents;
|
||||||
|
playerCityTemplate.terrain_type = mbEnums.TerrainGenType.PLANAR;
|
||||||
|
|
||||||
|
_zone_templates.put(playerCityTemplate.template_id, playerCityTemplate);
|
||||||
|
|
||||||
|
Logger.info("Zone templates: " + _zone_templates.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read before the zone templates, so only the templates this map uses are parsed. False aborts boot.
|
||||||
|
|
||||||
|
public static boolean loadZoneTree(int mapID) {
|
||||||
|
|
||||||
|
zoneTree = ZoneTreeParser.parseZoneTree(mapID);
|
||||||
|
|
||||||
|
return zoneTree != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TreeSet<Integer> getZoneTreeTemplateIDs() {
|
||||||
|
|
||||||
|
TreeSet<Integer> templateIDs = new TreeSet<>();
|
||||||
|
|
||||||
|
for (ZoneTreeEntry treeEntry : zoneTree)
|
||||||
|
templateIDs.add(treeEntry.template);
|
||||||
|
|
||||||
|
return templateIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static zones from the map's zone tree, then player-city zones from the DB. False aborts boot.
|
||||||
|
|
||||||
|
public static boolean loadZones() {
|
||||||
|
|
||||||
|
ArrayList<Zone> cityZones;
|
||||||
|
Zone zone;
|
||||||
|
int staticCount = 0;
|
||||||
|
|
||||||
|
for (ZoneTreeEntry treeEntry : zoneTree) {
|
||||||
|
|
||||||
|
if (treeEntry.parent != 0 && getZoneByUUID(treeEntry.parent) == null) {
|
||||||
|
Logger.error("Zone " + treeEntry.uid + " (" + treeEntry.name + ") has no parent zone " + treeEntry.parent);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
zone = Zone.createStaticZone(treeEntry);
|
||||||
|
DbManager.addToCache(zone);
|
||||||
|
zone.runAfterLoad();
|
||||||
|
staticCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cityZones = DbManager.ZoneQueries.GET_PLAYER_CITY_ZONES();
|
||||||
|
|
||||||
|
Logger.info("Zones: " + staticCount + " static, " + cityZones.size() + " player city");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Find all zones coordinates fit into, starting with Sea Floor
|
// Find all zones coordinates fit into, starting with Sea Floor
|
||||||
|
|
||||||
public static ArrayList<Zone> getAllZonesIn(final Vector3fImmutable loc) {
|
public static ArrayList<Zone> getAllZonesIn(final Vector3fImmutable loc) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ package engine.jobs;
|
|||||||
|
|
||||||
import engine.job.AbstractScheduleJob;
|
import engine.job.AbstractScheduleJob;
|
||||||
import engine.objects.Bane;
|
import engine.objects.Bane;
|
||||||
import java.time.LocalDateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
public class BaneDefaultTimeJob extends AbstractScheduleJob {
|
public class BaneDefaultTimeJob extends AbstractScheduleJob {
|
||||||
|
|
||||||
@@ -31,8 +31,11 @@ public class BaneDefaultTimeJob extends AbstractScheduleJob {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDateTime defaultTime = this.bane.getPlacementDate()
|
DateTime defaultTime = new DateTime(this.bane.getPlacementDate());
|
||||||
.plusDays(2).withHour(22).withMinute(0).withSecond(0).withNano(0);
|
defaultTime = defaultTime.plusDays(2);
|
||||||
|
defaultTime = defaultTime.hourOfDay().setCopy(22);
|
||||||
|
defaultTime = defaultTime.minuteOfHour().setCopy(0);
|
||||||
|
defaultTime = defaultTime.secondOfMinute().setCopy(0);
|
||||||
this.bane.setLiveDate(defaultTime);
|
this.bane.setLiveDate(defaultTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,11 +82,7 @@ public class ChantJob extends AbstractEffectJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (AbstractWorldObject.IsAbstractCharacter(source))
|
if (AbstractWorldObject.IsAbstractCharacter(source))
|
||||||
//handle invul
|
((AbstractCharacter) this.source).setLastChant((int) (this.power.getChantDuration()) * 1000, this);
|
||||||
if (power.getUUID() != 334)
|
|
||||||
((AbstractCharacter) this.source).setLastChant((int) (this.power.getChantDuration()) * 1000, this);
|
|
||||||
else
|
|
||||||
((AbstractCharacter) this.source).setLastChant((int) (this.power.getChantDuration()) * 1000, this);
|
|
||||||
} else {
|
} else {
|
||||||
PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains);
|
PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains);
|
||||||
if (AbstractWorldObject.IsAbstractCharacter(source)) {
|
if (AbstractWorldObject.IsAbstractCharacter(source)) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class DamageOverTimeJob extends AbstractEffectJob {
|
|||||||
private final DamageOverTimePowerAction dot;
|
private final DamageOverTimePowerAction dot;
|
||||||
private int iteration = 0;
|
private int iteration = 0;
|
||||||
private int liveCounter = 0;
|
private int liveCounter = 0;
|
||||||
|
private final int tickLength;
|
||||||
|
|
||||||
public DamageOverTimeJob(AbstractWorldObject source, AbstractWorldObject target, String stackType, int trains, ActionsBase action, PowersBase power, EffectsBase eb, DamageOverTimePowerAction dot) {
|
public DamageOverTimeJob(AbstractWorldObject source, AbstractWorldObject target, String stackType, int trains, ActionsBase action, PowersBase power, EffectsBase eb, DamageOverTimePowerAction dot) {
|
||||||
super(source, target, stackType, trains, action, power, eb);
|
super(source, target, stackType, trains, action, power, eb);
|
||||||
@@ -33,7 +34,9 @@ public class DamageOverTimeJob extends AbstractEffectJob {
|
|||||||
if (this.target != null && AbstractWorldObject.IsAbstractCharacter(target))
|
if (this.target != null && AbstractWorldObject.IsAbstractCharacter(target))
|
||||||
this.liveCounter = ((AbstractCharacter) target).getLiveCounter();
|
this.liveCounter = ((AbstractCharacter) target).getLiveCounter();
|
||||||
|
|
||||||
this.iteration = action.getDurationInSeconds(trains) / this.dot.getNumIterations();
|
// PowerActions.cfg gives the tick count; the ticks split the action's duration
|
||||||
|
this.iteration = this.dot.getNumIterations();
|
||||||
|
this.tickLength = action.getDuration(trains) / Math.max(1, this.dot.getNumIterations());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,7 +85,7 @@ public class DamageOverTimeJob extends AbstractEffectJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getTickLength() {
|
public int getTickLength() {
|
||||||
return this.dot.getNumIterations() * 1000;
|
return this.tickLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int inc() {
|
public int inc() {
|
||||||
|
|||||||
@@ -21,11 +21,15 @@ public class TransferStatOTJob extends AbstractEffectJob {
|
|||||||
|
|
||||||
private final TransferStatOTPowerAction dot;
|
private final TransferStatOTPowerAction dot;
|
||||||
private int iteration = 0;
|
private int iteration = 0;
|
||||||
|
private final int tickLength;
|
||||||
|
|
||||||
public TransferStatOTJob(AbstractWorldObject source, AbstractWorldObject target, String stackType, int trains, ActionsBase action, PowersBase power, EffectsBase eb, TransferStatOTPowerAction dot) {
|
public TransferStatOTJob(AbstractWorldObject source, AbstractWorldObject target, String stackType, int trains, ActionsBase action, PowersBase power, EffectsBase eb, TransferStatOTPowerAction dot) {
|
||||||
super(source, target, stackType, trains, action, power, eb);
|
super(source, target, stackType, trains, action, power, eb);
|
||||||
this.dot = dot;
|
this.dot = dot;
|
||||||
this.iteration = action.getDurationInSeconds(trains) / this.dot.getNumIterations();
|
|
||||||
|
// PowerActions.cfg gives the tick count; the ticks split the action's duration
|
||||||
|
this.iteration = this.dot.getNumIterations();
|
||||||
|
this.tickLength = action.getDuration(trains) / Math.max(1, this.dot.getNumIterations());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -64,7 +68,7 @@ public class TransferStatOTJob extends AbstractEffectJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getTickLength() {
|
public int getTickLength() {
|
||||||
return this.dot.getNumIterations() * 1000;
|
return this.tickLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int inc() {
|
public int inc() {
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import engine.gameManager.DbManager;
|
|||||||
import engine.gameManager.ForgeManager;
|
import engine.gameManager.ForgeManager;
|
||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.objects.Item;
|
import engine.objects.Item;
|
||||||
import engine.objects.ItemTemplate;
|
|
||||||
import engine.objects.NPC;
|
import engine.objects.NPC;
|
||||||
import engine.objects.Warehouse;
|
import engine.objects.Warehouse;
|
||||||
|
import engine.parsers.objects.CObjectTemplate;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -127,16 +127,16 @@ public class WorkOrder implements Delayed {
|
|||||||
|
|
||||||
int validation_result = 0;
|
int validation_result = 0;
|
||||||
|
|
||||||
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID);
|
CObjectTemplate template = CObjectTemplate.lookup(workOrder.templateID);
|
||||||
|
|
||||||
if (workOrder.vendor.getBuilding() == null)
|
if (workOrder.vendor.getBuilding() == null)
|
||||||
return 58; //58: The formula is beyond the means of this facility
|
return 58; //58: The formula is beyond the means of this facility
|
||||||
|
|
||||||
if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt))
|
if (!workOrder.vendor.charItemManager.hasRoomInventory(template.getItemWt()))
|
||||||
return 30; //30: That person cannot carry that item
|
return 30; //30: That person cannot carry that item
|
||||||
|
|
||||||
if ((workOrder.prefixToken != 0 || workOrder.suffixToken != 0) &&
|
if ((workOrder.prefixToken != 0 || workOrder.suffixToken != 0) &&
|
||||||
!workOrder.vendor.getItemModTable().contains((template.modTable)))
|
!workOrder.vendor.getItemModTable().contains(ForgeManager.getVendorModTable(workOrder.templateID)))
|
||||||
return 59; //59: This hireling does not have this formula
|
return 59; //59: This hireling does not have this formula
|
||||||
|
|
||||||
if (!Warehouse.calcCostOverrun(workOrder).isEmpty())
|
if (!Warehouse.calcCostOverrun(workOrder).isEmpty())
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ public class Bounds {
|
|||||||
|
|
||||||
blueprint = building.getBlueprint();
|
blueprint = building.getBlueprint();
|
||||||
|
|
||||||
this.quaternion = new Quaternion(building.getRot().x, building.getRot().y, building.getRot().z, building.getw());
|
this.quaternion = new Quaternion(building.getRotation().x, building.getRotation().y, building.getRotation().z, building.getRotation().w);
|
||||||
|
|
||||||
// Calculate Bounds for non-blueprint objects
|
// Calculate Bounds for non-blueprint objects
|
||||||
|
|
||||||
@@ -437,7 +437,7 @@ public class Bounds {
|
|||||||
|
|
||||||
// The rotation is reset after the new aabb is calculated.
|
// The rotation is reset after the new aabb is calculated.
|
||||||
|
|
||||||
this.rotation = building.getRot().y;
|
this.rotation = building.getRotation().y;
|
||||||
|
|
||||||
// Caclculate and set the new half halfExtents for the rotated bounding box
|
// Caclculate and set the new half halfExtents for the rotated bounding box
|
||||||
// and reset the rotation to 0 for this bounds.
|
// and reset the rotation to 0 for this bounds.
|
||||||
@@ -451,7 +451,7 @@ public class Bounds {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.origin.set(building.getLoc().x, building.getLoc().z);
|
this.origin.set(building.getLoc().x, building.getLoc().z);
|
||||||
this.rotation = building.getRot().y;
|
this.rotation = building.getRotation().y;
|
||||||
this.halfExtents.set(blueprint.getExtents());
|
this.halfExtents.set(blueprint.getExtents());
|
||||||
this.flipExtents = Bounds.calculateFlipExtents(this);
|
this.flipExtents = Bounds.calculateFlipExtents(this);
|
||||||
|
|
||||||
|
|||||||
@@ -583,36 +583,6 @@ final public class FastMath {
|
|||||||
return ret.normalize();
|
return ret.normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns a String into an Integer hash that the client will recognize.
|
|
||||||
*
|
|
||||||
* @param s The String to hash
|
|
||||||
* @return the Integer hash
|
|
||||||
*/
|
|
||||||
public static int hash(String s) {
|
|
||||||
int out = 0, pad = 0;
|
|
||||||
for (char c : s.toCharArray()) {
|
|
||||||
if (c == ' ' || c == '\\') {
|
|
||||||
pad += 5;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c > 0x40 && c < 0x60)
|
|
||||||
out ^= _rotl((byte) 0x60, pad);
|
|
||||||
out ^= _rotl((byte) (c & 0xDF), pad);
|
|
||||||
pad += 5;
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility function for making hashes
|
|
||||||
*/
|
|
||||||
private static int _rotl(int value, int shift) {
|
|
||||||
if ((shift &= 31) == 0)
|
|
||||||
return value;
|
|
||||||
return (value << shift) | (value >> (32 - shift));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets number of seconds until next hours
|
* Gets number of seconds until next hours
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1142,6 +1142,17 @@ public class Quaternion {
|
|||||||
return opposite(this);
|
return opposite(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Client MakeRotateY (Math.dll 0x10002960): w = cos θ/2, y = sin θ/2, radians.
|
||||||
|
// Math rather than FastMath: FastMath.reduceSinAngle mis-reduces angles below -π.
|
||||||
|
public static Quaternion fromYaw(float yaw) {
|
||||||
|
return new Quaternion(0f, (float) Math.sin(yaw * 0.5), 0f, (float) Math.cos(yaw * 0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
// The angle MakeRotateY would need to produce this rotation; characters send it as one float.
|
||||||
|
public float getYaw() {
|
||||||
|
return 2 * FastMath.atan2(y, w);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Quaternion clone() {
|
public Quaternion clone() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2026
|
||||||
|
// https://www.magicbane.com
|
||||||
|
|
||||||
|
package engine.math;
|
||||||
|
|
||||||
|
// The client's placement (ArcObjectInfo +0x28/+0x34/+0x44, math::Transformation); see MBDATA/specs/WorldPlacement.md §7.
|
||||||
|
|
||||||
|
public class Transform {
|
||||||
|
|
||||||
|
public final Vector3fImmutable location;
|
||||||
|
public final Quaternion rotation;
|
||||||
|
public final Vector3f scale;
|
||||||
|
|
||||||
|
public Transform(Vector3fImmutable location, Quaternion rotation, Vector3f scale) {
|
||||||
|
this.location = location;
|
||||||
|
this.rotation = rotation;
|
||||||
|
this.scale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Transform fromYaw(Vector3fImmutable location, float yaw) {
|
||||||
|
return new Transform(location, Quaternion.fromYaw(yaw), new Vector3f(1.0f, 1.0f, 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
// world = parent × local, as the client composes zone and object transforms (sb.exe 0x6516C0).
|
||||||
|
public static Transform mult(Transform parent, Transform local) {
|
||||||
|
|
||||||
|
Vector3f scaledLocation;
|
||||||
|
Vector3f rotatedLocation;
|
||||||
|
Quaternion rotation;
|
||||||
|
Vector3f scale;
|
||||||
|
|
||||||
|
scaledLocation = new Vector3f(local.location).mult(parent.scale);
|
||||||
|
rotatedLocation = parent.rotation.mult(scaledLocation);
|
||||||
|
rotation = parent.rotation.mult(local.rotation);
|
||||||
|
scale = parent.scale.mult(local.scale);
|
||||||
|
|
||||||
|
return new Transform(parent.location.add(rotatedLocation), rotation, scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+126
-40
@@ -15,10 +15,10 @@ import engine.math.Vector2f;
|
|||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.objects.AbstractCharacter;
|
import engine.objects.AbstractCharacter;
|
||||||
import engine.objects.ItemTemplate;
|
|
||||||
import engine.objects.Shrine;
|
import engine.objects.Shrine;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import engine.powers.EffectsBase;
|
import engine.powers.EffectsBase;
|
||||||
|
import engine.powers.RunePowerEntry;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -824,6 +824,7 @@ public class mbEnums {
|
|||||||
ACID,
|
ACID,
|
||||||
DISEASE,
|
DISEASE,
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
|
ANTISIEGE,
|
||||||
// these added for immunities
|
// these added for immunities
|
||||||
ATTACK,
|
ATTACK,
|
||||||
POWERS,
|
POWERS,
|
||||||
@@ -842,34 +843,26 @@ public class mbEnums {
|
|||||||
|
|
||||||
public static DamageType getDamageType(String modName) {
|
public static DamageType getDamageType(String modName) {
|
||||||
|
|
||||||
|
String name;
|
||||||
|
|
||||||
if (modName.isEmpty())
|
if (modName.isEmpty())
|
||||||
return DamageType.NONE;
|
return DamageType.NONE;
|
||||||
|
|
||||||
if(modName.toLowerCase().equals("blind"))
|
// Client and DB strings vary in case and punctuation ("Fire", "Anti-Siege")
|
||||||
modName = "BLINDNESS";
|
|
||||||
|
|
||||||
if(modName.toLowerCase().equals("powerblock"))
|
name = modName.replaceAll("[\\s,-]", "").toUpperCase();
|
||||||
modName = "POWERINHIBITOR";
|
|
||||||
|
|
||||||
//validity check for not looking up damage type that doesn't exist
|
if (name.equals("BLIND"))
|
||||||
boolean valid = false;
|
name = "BLINDNESS";
|
||||||
for(DamageType type : DamageType.values()){
|
|
||||||
if(type.name().equals(modName))
|
|
||||||
valid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!valid)
|
if (name.equals("POWERBLOCK"))
|
||||||
return DamageType.NONE;
|
name = "POWERINHIBITOR";
|
||||||
|
|
||||||
DamageType damageType;
|
for (DamageType type : DamageType.values())
|
||||||
|
if (type.name().equals(name))
|
||||||
|
return type;
|
||||||
|
|
||||||
try {
|
return DamageType.NONE;
|
||||||
damageType = DamageType.valueOf(modName.replace(",", "").toUpperCase());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e);
|
|
||||||
return DamageType.NONE;
|
|
||||||
}
|
|
||||||
return damageType;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1104,11 +1097,28 @@ public class mbEnums {
|
|||||||
|
|
||||||
public static EffectSourceType GetEffectSourceType(String modName) {
|
public static EffectSourceType GetEffectSourceType(String modName) {
|
||||||
EffectSourceType returnMod;
|
EffectSourceType returnMod;
|
||||||
|
String name;
|
||||||
|
|
||||||
if (modName.isEmpty())
|
if (modName.isEmpty())
|
||||||
return EffectSourceType.None;
|
return EffectSourceType.None;
|
||||||
|
|
||||||
|
name = modName.replace(",", "").replace("-", "").trim();
|
||||||
|
|
||||||
|
// Effects.cfg SOURCE blocks use the short damage names
|
||||||
|
switch (name) {
|
||||||
|
case "Crush":
|
||||||
|
name = "Crushing";
|
||||||
|
break;
|
||||||
|
case "Pierce":
|
||||||
|
name = "Piercing";
|
||||||
|
break;
|
||||||
|
case "Slash":
|
||||||
|
name = "Slashing";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
returnMod = EffectSourceType.valueOf(modName.replace(",", ""));
|
returnMod = EffectSourceType.valueOf(name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
return EffectSourceType.None;
|
return EffectSourceType.None;
|
||||||
@@ -1138,6 +1148,7 @@ public class mbEnums {
|
|||||||
BMHealing,
|
BMHealing,
|
||||||
Charm,
|
Charm,
|
||||||
ClassBoon,
|
ClassBoon,
|
||||||
|
ColdDeBuff,
|
||||||
Confusion,
|
Confusion,
|
||||||
DamageAbsorber,
|
DamageAbsorber,
|
||||||
DamageDebuff,
|
DamageDebuff,
|
||||||
@@ -1152,6 +1163,7 @@ public class mbEnums {
|
|||||||
ElementalDeBuff,
|
ElementalDeBuff,
|
||||||
EnchantWeapon,
|
EnchantWeapon,
|
||||||
Fear,
|
Fear,
|
||||||
|
FireDeBuff,
|
||||||
Flight,
|
Flight,
|
||||||
Frenzy,
|
Frenzy,
|
||||||
GroupHeal,
|
GroupHeal,
|
||||||
@@ -1159,12 +1171,16 @@ public class mbEnums {
|
|||||||
HealOverTime,
|
HealOverTime,
|
||||||
HealResBuff,
|
HealResBuff,
|
||||||
HealthPotion,
|
HealthPotion,
|
||||||
|
HolyDeBuff,
|
||||||
IgnoreStack,
|
IgnoreStack,
|
||||||
Invisible,
|
Invisible,
|
||||||
|
LightningDeBuff,
|
||||||
|
MagicDeBuff,
|
||||||
ManaPotion,
|
ManaPotion,
|
||||||
MangonelFire,
|
MangonelFire,
|
||||||
MeleeDamageDeBuff,
|
MeleeDamageDeBuff,
|
||||||
MeleeDeBuff,
|
MeleeDeBuff,
|
||||||
|
MentalDeBuff,
|
||||||
MoveBuff,
|
MoveBuff,
|
||||||
MoveDebuff,
|
MoveDebuff,
|
||||||
NoFear,
|
NoFear,
|
||||||
@@ -1177,6 +1193,9 @@ public class mbEnums {
|
|||||||
NoTrack,
|
NoTrack,
|
||||||
PassiveDefense,
|
PassiveDefense,
|
||||||
PersAttrSPRBuff,
|
PersAttrSPRBuff,
|
||||||
|
PersonalAttrCONBuff,
|
||||||
|
PersonalAttrDEXBuff,
|
||||||
|
PersonalAttrSTRBuff,
|
||||||
PetBuff,
|
PetBuff,
|
||||||
PierceResistanceDebuff,
|
PierceResistanceDebuff,
|
||||||
PoisonBuchinine,
|
PoisonBuchinine,
|
||||||
@@ -1199,7 +1218,6 @@ public class mbEnums {
|
|||||||
RecoveryStaminaDeBuff,
|
RecoveryStaminaDeBuff,
|
||||||
ResistanceBuff,
|
ResistanceBuff,
|
||||||
ResistanceDeBuff,
|
ResistanceDeBuff,
|
||||||
ResistanceDebuff,
|
|
||||||
Root,
|
Root,
|
||||||
SafeMode,
|
SafeMode,
|
||||||
SelfOneAttrBuff,
|
SelfOneAttrBuff,
|
||||||
@@ -1223,6 +1241,7 @@ public class mbEnums {
|
|||||||
Stun,
|
Stun,
|
||||||
Track,
|
Track,
|
||||||
Transform,
|
Transform,
|
||||||
|
UnholyDeBuff,
|
||||||
WeaponMove;
|
WeaponMove;
|
||||||
|
|
||||||
public static StackType GetStackType(String modName) {
|
public static StackType GetStackType(String modName) {
|
||||||
@@ -1509,6 +1528,15 @@ public class mbEnums {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rune_type values from the client cache data (COBJECTS/RUNE)
|
||||||
|
|
||||||
|
public enum RuneType {
|
||||||
|
CLASS,
|
||||||
|
DISCIPLINE,
|
||||||
|
RACE,
|
||||||
|
TALENT
|
||||||
|
}
|
||||||
|
|
||||||
public enum ShrineType {
|
public enum ShrineType {
|
||||||
|
|
||||||
Aelfborn(1701900, -75506007, true),
|
Aelfborn(1701900, -75506007, true),
|
||||||
@@ -2632,55 +2660,61 @@ public class mbEnums {
|
|||||||
|
|
||||||
public enum MinionType {
|
public enum MinionType {
|
||||||
AELFBORNGUARD(951, 1637, MinionClass.MELEE, "Guard", "Aelfborn"),
|
AELFBORNGUARD(951, 1637, MinionClass.MELEE, "Guard", "Aelfborn"),
|
||||||
AELFBORNMAGE(952, 1635, MinionClass.MAGE, "Adept", "Aelfborn"),
|
AELFBORNMAGE(952, 1635, MinionClass.MAGE, "Adept", "Aelfborn", "WIZ-016", "WIZ-061", "WIZ-025", "WIZ-020"),
|
||||||
AMAZONGUARD(1500, 1670, MinionClass.MELEE, "Guard", "Amazon"),
|
AMAZONGUARD(1500, 1670, MinionClass.MELEE, "Guard", "Amazon"),
|
||||||
AMAZONMAGE(1502, 1638, MinionClass.MAGE, "Fury", "Amazon"),
|
AMAZONMAGE(1502, 1638, MinionClass.MAGE, "Fury", "Amazon", "FUR-003", "FUR-011", "FUR-009", "FUR-005"),
|
||||||
ARACOIXGUARD(1600, 1672, MinionClass.MELEE, "Guard", "Aracoix"), //used guard captain equipset.
|
ARACOIXGUARD(1600, 1672, MinionClass.MELEE, "Guard", "Aracoix"), //used guard captain equipset.
|
||||||
ARACOIXMAGE(1602, 885, MinionClass.MAGE, "Adept", "Aracoix"),
|
ARACOIXMAGE(1602, 885, MinionClass.MAGE, "Adept", "Aracoix", "WLR-029", "WLR-019", "WLR-027", "WLR-012"),
|
||||||
CENTAURGUARD(1650, 1642, MinionClass.MELEE, "Guard", "Centaur"),
|
CENTAURGUARD(1650, 1642, MinionClass.MELEE, "Guard", "Centaur"),
|
||||||
CENTAURMAGE(1652, 1640, MinionClass.MAGE, "Druid", "Centaur"),
|
CENTAURMAGE(1652, 1640, MinionClass.MAGE, "Druid", "Centaur", "PRL-017", "PRL-046", "PRL-033", "PRL-009"),
|
||||||
DWARVENARCHER(845, 1644, MinionClass.ARCHER, "Marksman", "Dwarven"),
|
DWARVENARCHER(845, 1644, MinionClass.ARCHER, "Marksman", "Dwarven"),
|
||||||
DWARVENGUARD(1050, 1666, MinionClass.MELEE, "Guard", "Dwarven"),
|
DWARVENGUARD(1050, 1666, MinionClass.MELEE, "Guard", "Dwarven"),
|
||||||
DWARVENMAGE(1052, 1643, MinionClass.MAGE, "War Priest", "Dwarven"),
|
DWARVENMAGE(1052, 1643, MinionClass.MAGE, "War Priest", "Dwarven", "PRL-017", "PRL-046", "PRL-033", "PRL-009"),
|
||||||
ELFGUARD(1180, 1671, MinionClass.MELEE, "Guard", "Elven"), //old 1645
|
ELFGUARD(1180, 1671, MinionClass.MELEE, "Guard", "Elven"), //old 1645
|
||||||
ELFMAGE(1182, 1667, MinionClass.MAGE, "Adept", "Elven"),
|
ELFMAGE(1182, 1667, MinionClass.MAGE, "Adept", "Elven", "WIZ-020", "WIZ-025", "WIZ-016", "WIZ-061"),
|
||||||
FORESTGUARD(1550, 1668, MinionClass.MELEE, "Guard", "Forest"), //captain changed to guard equipset
|
FORESTGUARD(1550, 1668, MinionClass.MELEE, "Guard", "Forest"), //captain changed to guard equipset
|
||||||
FORESTMAGE(1552, 436, MinionClass.MAGE, "Adept", "Forest"),
|
FORESTMAGE(1552, 436, MinionClass.MAGE, "Adept", "Forest", "DRU-009", "DRU-023", "DRU-036", "DRU-015"),
|
||||||
HOLYGUARD(1525, 1658, MinionClass.MELEE, "Guard", "Holy Church"),
|
HOLYGUARD(1525, 1658, MinionClass.MELEE, "Guard", "Holy Church"),
|
||||||
HOLYMAGE(1527, 1646, MinionClass.MAGE, "Prelate", "Holy Church"),
|
HOLYMAGE(1527, 1646, MinionClass.MAGE, "Prelate", "Holy Church", "PRL-017", "PRL-046", "PRL-033", "PRL-009"),
|
||||||
HUMANARCHER(846, 1654, MinionClass.ARCHER, "Archer", "Human"),
|
HUMANARCHER(846, 1654, MinionClass.ARCHER, "Archer", "Human"),
|
||||||
HUMANGUARD(840, 1665, MinionClass.MELEE, "Guard", "Human"),
|
HUMANGUARD(840, 1665, MinionClass.MELEE, "Guard", "Human"),
|
||||||
HUMANMAGE(848, 1655, MinionClass.MAGE, "Adept", "Human"),
|
HUMANMAGE(848, 1655, MinionClass.MAGE, "Adept", "Human", "WIZ-016", "WIZ-025", "WIZ-020", "WIZ-061"),
|
||||||
IREKEIGUARD(1350, 1659, MinionClass.MELEE, "Guard", "Irekei"),
|
IREKEIGUARD(1350, 1659, MinionClass.MELEE, "Guard", "Irekei"),
|
||||||
IREKEIMAGE(1352, 1660, MinionClass.MAGE, "Adept", "Irekei"),
|
IREKEIMAGE(1352, 1660, MinionClass.MAGE, "Adept", "Irekei", "WIZ-061", "WIZ-016", "WIZ-025", "WIZ-020"),
|
||||||
MINOTAURARCHER(1701, 0, MinionClass.ARCHER, "Archer", "Minotaur"),
|
MINOTAURARCHER(1701, 0, MinionClass.ARCHER, "Archer", "Minotaur"),
|
||||||
MINOTAURGUARD(1700, 1673, MinionClass.MELEE, "Guard", "Minotaur"),
|
MINOTAURGUARD(1700, 1673, MinionClass.MELEE, "Guard", "Minotaur"),
|
||||||
NORTHMANGUARD(1250, 1669, MinionClass.MELEE, "Guard", "Northman"),
|
NORTHMANGUARD(1250, 1669, MinionClass.MELEE, "Guard", "Northman"),
|
||||||
NORTHMANMAGE(1252, 1650, MinionClass.MAGE, "Runecaster", "Northman"),
|
NORTHMANMAGE(1252, 1650, MinionClass.MAGE, "Runecaster", "Northman", "WIZ-061", "WIZ-016", "WIZ-025", "WIZ-020"),
|
||||||
SHADEGUARD(1450, 1662, MinionClass.MELEE, "Guard", "Shade"),
|
SHADEGUARD(1450, 1662, MinionClass.MELEE, "Guard", "Shade"),
|
||||||
SHADEMAGE(1452, 1664, MinionClass.MAGE, "Adept", "Shade"),
|
SHADEMAGE(1452, 1664, MinionClass.MAGE, "Adept", "Shade", "NEC-001", "NEC-003", "MAG-013", "MAG-025"),
|
||||||
TEMPLARGUARD(841, 1564, MinionClass.MELEE, "Marksman", "Templar"),
|
TEMPLARGUARD(841, 1564, MinionClass.MELEE, "Marksman", "Templar"),
|
||||||
TEMPLEGUARD(1575, 1652, MinionClass.MELEE, "Guard", "Temple"),
|
TEMPLEGUARD(1575, 1652, MinionClass.MELEE, "Guard", "Temple"),
|
||||||
TEMPLEMAGE(1577, 1656, MinionClass.MAGE, "Confessor", "Temple"),
|
TEMPLEMAGE(1577, 1656, MinionClass.MAGE, "Confessor", "Temple", "CON-048", "CON-015", "CON-012", "CON-051"),
|
||||||
UNDEADGUARD(980100, 1674, MinionClass.MELEE, "Guard", "Undead"),
|
UNDEADGUARD(980100, 1674, MinionClass.MELEE, "Guard", "Undead"),
|
||||||
UNDEADMAGE(980102, 1675, MinionClass.MAGE, "Adept", "Undead"),
|
UNDEADMAGE(980102, 1675, MinionClass.MAGE, "Adept", "Undead", "NEC-001", "NEC-003", "MAG-013", "MAG-025"),
|
||||||
WEREWOLFGUARD(980104, 0, MinionClass.MELEE, "Guard", "Werewolf"),
|
WEREWOLFGUARD(980104, 0, MinionClass.MELEE, "Guard", "Werewolf"),
|
||||||
WEREBEARGUARD(980103, 0, MinionClass.MELEE, "Guard", "Werebear");
|
WEREBEARGUARD(980103, 0, MinionClass.MELEE, "Guard", "Werebear");
|
||||||
public static HashMap<Integer, MinionType> ContractToMinionMap = new HashMap<>();
|
public static HashMap<Integer, MinionType> ContractToMinionMap = new HashMap<>();
|
||||||
|
private static final int CAPTAIN_POWER_RANK = 40;
|
||||||
private final int captainContractID;
|
private final int captainContractID;
|
||||||
private final int equipSetID;
|
private final int equipSetID;
|
||||||
private final MinionClass minionClass;
|
private final MinionClass minionClass;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String race;
|
private final String race;
|
||||||
|
private final ArrayList<RunePowerEntry> captainPowers;
|
||||||
|
|
||||||
MinionType(int captainContractID, int equipSetID, MinionClass minionClass, String name, String race) {
|
// Captain powers were hand-made by the server team; no client rune or deed lists them
|
||||||
|
MinionType(int captainContractID, int equipSetID, MinionClass minionClass, String name, String race, String... captainPowerTypes) {
|
||||||
|
|
||||||
this.captainContractID = captainContractID;
|
this.captainContractID = captainContractID;
|
||||||
this.equipSetID = equipSetID;
|
this.equipSetID = equipSetID;
|
||||||
this.minionClass = minionClass;
|
this.minionClass = minionClass;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.race = race;
|
this.race = race;
|
||||||
|
this.captainPowers = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String powerType : captainPowerTypes)
|
||||||
|
this.captainPowers.add(new RunePowerEntry(race + " " + name, powerType, CAPTAIN_POWER_RANK));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InitializeMinions() {
|
public static void InitializeMinions() {
|
||||||
@@ -2689,6 +2723,17 @@ public class mbEnums {
|
|||||||
ContractToMinionMap.put(minionType.captainContractID, minionType);
|
ContractToMinionMap.put(minionType.captainContractID, minionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The powers a guard captain's contract casts, shared by its minions; empty for non-caster contracts
|
||||||
|
public static ArrayList<RunePowerEntry> getCaptainPowers(int captainContractID) {
|
||||||
|
|
||||||
|
MinionType minionType = ContractToMinionMap.get(captainContractID);
|
||||||
|
|
||||||
|
if (minionType == null)
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
return minionType.captainPowers;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -2761,7 +2806,6 @@ public class mbEnums {
|
|||||||
public static HashMap<Integer, ResourceType> templateHashLookup = new HashMap<>();
|
public static HashMap<Integer, ResourceType> templateHashLookup = new HashMap<>();
|
||||||
public static HashMap<Integer, ResourceType> resourceHashLookup = new HashMap<>();
|
public static HashMap<Integer, ResourceType> resourceHashLookup = new HashMap<>();
|
||||||
public int templateID;
|
public int templateID;
|
||||||
public ItemTemplate template;
|
|
||||||
public int resourceHash;
|
public int resourceHash;
|
||||||
public int templateHash;
|
public int templateHash;
|
||||||
public int deposit_limit;
|
public int deposit_limit;
|
||||||
@@ -2769,7 +2813,6 @@ public class mbEnums {
|
|||||||
|
|
||||||
ResourceType(int templateID, int resourceHash, int templateHash, int deposit_limit, int mine_production) {
|
ResourceType(int templateID, int resourceHash, int templateHash, int deposit_limit, int mine_production) {
|
||||||
this.templateID = templateID;
|
this.templateID = templateID;
|
||||||
this.template = ItemTemplate.templates.get(this.templateID);
|
|
||||||
this.resourceHash = resourceHash;
|
this.resourceHash = resourceHash;
|
||||||
this.templateHash = templateHash;
|
this.templateHash = templateHash;
|
||||||
this.deposit_limit = deposit_limit;
|
this.deposit_limit = deposit_limit;
|
||||||
@@ -2908,6 +2951,14 @@ public class mbEnums {
|
|||||||
EMPTY_NEWITEM;
|
EMPTY_NEWITEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cache JSON names. UNKNOWN is raw 0, which the client treats as no slot (sb.exe 0x4AC810).
|
||||||
|
public enum SheathSlot {
|
||||||
|
UNKNOWN,
|
||||||
|
BACK,
|
||||||
|
WAIST,
|
||||||
|
NONE
|
||||||
|
}
|
||||||
|
|
||||||
public enum AttributeType {
|
public enum AttributeType {
|
||||||
None,
|
None,
|
||||||
Strength,
|
Strength,
|
||||||
@@ -3096,6 +3147,41 @@ public class mbEnums {
|
|||||||
MULTIPLY
|
MULTIPLY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CZONE value sets; only the values present in the shipped cache.
|
||||||
|
|
||||||
|
public enum ZoneShapeType {
|
||||||
|
ELLIPTICAL,
|
||||||
|
RECTANGULAR
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SeaLevelType {
|
||||||
|
PARENT,
|
||||||
|
SELF,
|
||||||
|
WORLD
|
||||||
|
}
|
||||||
|
|
||||||
|
// NONE is the server's marker for a zone with no zone_terrain_gen block
|
||||||
|
|
||||||
|
public enum TerrainGenType {
|
||||||
|
NONE,
|
||||||
|
TARGA,
|
||||||
|
PLANAR
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ZonePropType {
|
||||||
|
PROP,
|
||||||
|
CITY
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ZoneMobileType {
|
||||||
|
MOBILE,
|
||||||
|
TRAINER
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PointSetType {
|
||||||
|
POINTS_ORDEREDREV
|
||||||
|
}
|
||||||
|
|
||||||
public enum ServerConfig {
|
public enum ServerConfig {
|
||||||
MBDB_108("AERYNTH", "ARAC", "MOURNING", 300000),
|
MBDB_108("AERYNTH", "ARAC", "MOURNING", 300000),
|
||||||
MBDB_192("DALGOTH", "ARAC", "GOOK", 300001),
|
MBDB_192("DALGOTH", "ARAC", "GOOK", 300001),
|
||||||
|
|||||||
@@ -14,13 +14,12 @@ import engine.gameManager.*;
|
|||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.mbEnums.DispatchChannel;
|
|
||||||
import engine.mobileAI.Threads.MobAIThread;
|
import engine.mobileAI.Threads.MobAIThread;
|
||||||
import engine.mobileAI.Threads.ReSpawner;
|
import engine.mobileAI.Threads.ReSpawner;
|
||||||
import engine.mobileAI.utilities.MovementUtilities;
|
import engine.mobileAI.utilities.MovementUtilities;
|
||||||
import engine.net.client.msg.PerformActionMsg;
|
import engine.net.client.msg.PerformActionMsg;
|
||||||
import engine.net.client.msg.PowerProjectileMsg;
|
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.RuneTemplate;
|
||||||
import engine.powers.ActionsBase;
|
import engine.powers.ActionsBase;
|
||||||
import engine.powers.PowersBase;
|
import engine.powers.PowersBase;
|
||||||
import engine.powers.RunePowerEntry;
|
import engine.powers.RunePowerEntry;
|
||||||
@@ -46,6 +45,13 @@ public class MobAI {
|
|||||||
//
|
//
|
||||||
// CombatManager.class implements shared combat routines for all avatars.
|
// CombatManager.class implements shared combat routines for all avatars.
|
||||||
|
|
||||||
|
// Pet aggro scan in checkForAggro stays off until it checks rune enemy lists,
|
||||||
|
// filters its targets and keeps pet targets (MBDATA/docs/plan-mask-pet.md steps 2-4).
|
||||||
|
|
||||||
|
private static final boolean PET_AGGRO_ENABLED = false;
|
||||||
|
|
||||||
|
private static final int STANDING_GUARD_RUNE_ID = 252623;
|
||||||
|
|
||||||
private static void attackTarget(Mob mob, AbstractWorldObject target) {
|
private static void attackTarget(Mob mob, AbstractWorldObject target) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -93,7 +99,7 @@ public class MobAI {
|
|||||||
mob.updateLocation();
|
mob.updateLocation();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +118,9 @@ public class MobAI {
|
|||||||
if (mob.behaviourType.callsForHelp)
|
if (mob.behaviourType.callsForHelp)
|
||||||
mobCallForHelp(mob);
|
mobCallForHelp(mob);
|
||||||
|
|
||||||
if (!MovementUtilities.inRangeDropAggro(mob, target)) {
|
// siege engines drop targets on their own attack range in determineAction
|
||||||
|
|
||||||
|
if (!mob.isSiege() && !MovementUtilities.inRangeDropAggro(mob, target)) {
|
||||||
mob.setCombatTarget(null);
|
mob.setCombatTarget(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -133,7 +141,7 @@ public class MobAI {
|
|||||||
target.getPet().setCombatTarget(mob);
|
target.getPet().setCombatTarget(mob);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -155,20 +163,10 @@ public class MobAI {
|
|||||||
if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild()))
|
if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild()))
|
||||||
guard.setCombatTarget(mob);
|
guard.setCombatTarget(mob);
|
||||||
|
|
||||||
if (mob.isSiege())
|
|
||||||
MovementManager.sendRWSSMsg(mob);
|
|
||||||
|
|
||||||
|
|
||||||
CombatManager.combatCycle(mob, target);
|
CombatManager.combatCycle(mob, target);
|
||||||
|
|
||||||
if (mob.isSiege()) {
|
|
||||||
PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target);
|
|
||||||
ppm.setRange(50);
|
|
||||||
DispatchManager.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +184,7 @@ public class MobAI {
|
|||||||
CombatManager.combatCycle(mob, target);
|
CombatManager.combatCycle(mob, target);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +246,7 @@ public class MobAI {
|
|||||||
MovementUtilities.aiMove(mob, mob.destination, true);
|
MovementUtilities.aiMove(mob, mob.destination, true);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: Patrol");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,7 +279,7 @@ public class MobAI {
|
|||||||
|
|
||||||
// Mobile has no powers defined in mobbase or contract..
|
// Mobile has no powers defined in mobbase or contract..
|
||||||
|
|
||||||
if (PowersManager.getPowersForRune(mob.getMobBaseID()).isEmpty() && PowersManager.getPowersForRune(contractID).isEmpty())
|
if (PowersManager.getPowersForRune(mob.getMobBaseID()).isEmpty() && mbEnums.MinionType.getCaptainPowers(contractID).isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (mob.nextCastTime == 0)
|
if (mob.nextCastTime == 0)
|
||||||
@@ -290,7 +288,7 @@ public class MobAI {
|
|||||||
return mob.nextCastTime <= System.currentTimeMillis();
|
return mob.nextCastTime <= System.currentTimeMillis();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: canCast" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: canCast");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -314,18 +312,17 @@ public class MobAI {
|
|||||||
powerEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.getMobBaseID()));
|
powerEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.getMobBaseID()));
|
||||||
purgeEntries = new ArrayList<>();
|
purgeEntries = new ArrayList<>();
|
||||||
|
|
||||||
// Additional powers may come from the contract ID. This is to support
|
// Player guards also cast their captain contract's powers, irrespective of the mobbase used.
|
||||||
// powers for player guards irrespective of the mobbase used.
|
|
||||||
|
|
||||||
if (mob.isPlayerGuard()) {
|
if (mob.isPlayerGuard()) {
|
||||||
|
|
||||||
ArrayList<RunePowerEntry> contractEntries = new ArrayList<>();
|
ArrayList<RunePowerEntry> contractEntries = new ArrayList<>();
|
||||||
|
|
||||||
if (mob.contract != null)
|
if (mob.contract != null)
|
||||||
contractEntries = PowersManager.getPowersForRune(mob.contractUUID);
|
contractEntries = mbEnums.MinionType.getCaptainPowers(mob.contractUUID);
|
||||||
|
|
||||||
if (mob.agentType.equals(mbEnums.AIAgentType.GUARDMINION))
|
if (mob.agentType.equals(mbEnums.AIAgentType.GUARDMINION))
|
||||||
contractEntries = PowersManager.getPowersForRune(mob.guardCaptain.contractUUID);
|
contractEntries = mbEnums.MinionType.getCaptainPowers(mob.guardCaptain.contractUUID);
|
||||||
|
|
||||||
powerEntries.addAll(contractEntries);
|
powerEntries.addAll(contractEntries);
|
||||||
|
|
||||||
@@ -362,7 +359,7 @@ public class MobAI {
|
|||||||
int powerRank = runePowerEntry.rank;
|
int powerRank = runePowerEntry.rank;
|
||||||
|
|
||||||
if (mob.isPlayerGuard())
|
if (mob.isPlayerGuard())
|
||||||
powerRank = getGuardPowerRank(mob);
|
powerRank = getGuardPowerRank(mob, mobPower);
|
||||||
|
|
||||||
// Cast the spell
|
// Cast the spell
|
||||||
|
|
||||||
@@ -387,38 +384,32 @@ public class MobAI {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCast" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCast");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getGuardPowerRank(Mob mob) {
|
// Client power rank adds every POWERSADJ step at or below the level (0x4B34B0). The Standing Guard rune's
|
||||||
int powerRank = 1;
|
// Wizard steps are the curve for every captain spell, capped at MaxLevel as player casts are.
|
||||||
|
public static int getGuardPowerRank(Mob mob, PowersBase power) {
|
||||||
|
|
||||||
switch (mob.getRank()) {
|
RuneTemplate guardRune = RuneTemplate._runes.get(STANDING_GUARD_RUNE_ID);
|
||||||
case 1:
|
ArrayList<int[]> rankSteps;
|
||||||
powerRank = 10;
|
int powerRank = 0;
|
||||||
break;
|
|
||||||
case 2:
|
if (guardRune == null || guardRune.item_power_action.isEmpty())
|
||||||
powerRank = 15;
|
return 1;
|
||||||
break;
|
|
||||||
case 3:
|
rankSteps = guardRune.item_power_action.get(power.getIDString());
|
||||||
powerRank = 20;
|
|
||||||
break;
|
if (rankSteps == null)
|
||||||
case 4:
|
rankSteps = guardRune.item_power_action.values().iterator().next();
|
||||||
powerRank = 25;
|
|
||||||
break;
|
for (int[] rankStep : rankSteps)
|
||||||
case 5:
|
if (rankStep[1] <= mob.getLevel())
|
||||||
powerRank = 30;
|
powerRank += rankStep[0];
|
||||||
break;
|
|
||||||
case 6:
|
return Math.max(1, Math.min(powerRank, power.getMaxTrains()));
|
||||||
powerRank = 35;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
powerRank = 40;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return powerRank;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void mobCallForHelp(Mob mob) {
|
public static void mobCallForHelp(Mob mob) {
|
||||||
@@ -452,7 +443,7 @@ public class MobAI {
|
|||||||
mob.nextCallForHelp = System.currentTimeMillis() + 60000;
|
mob.nextCallForHelp = System.currentTimeMillis() + 60000;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCallForHelp" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCallForHelp");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +466,7 @@ public class MobAI {
|
|||||||
|
|
||||||
//trebuchet spawn handler
|
//trebuchet spawn handler
|
||||||
|
|
||||||
if (mob.despawned && mob.getMobBase().getLoadID() == 13171) {
|
if (mob.despawned && mob.getMobBase().getObjectUUID() == 13171) {
|
||||||
checkForRespawn(mob);
|
checkForRespawn(mob);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -518,7 +509,16 @@ public class MobAI {
|
|||||||
boolean bypassLoadedPlayerCheck = false;
|
boolean bypassLoadedPlayerCheck = false;
|
||||||
if (mob.isPlayerGuard() || mob.isSiege()) {
|
if (mob.isPlayerGuard() || mob.isSiege()) {
|
||||||
bypassLoadedPlayerCheck = true;
|
bypassLoadedPlayerCheck = true;
|
||||||
if (mob.combatTarget != null && mob.combatTarget.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter))
|
|
||||||
|
if (mob.isSiege()) {
|
||||||
|
|
||||||
|
// siege engines hold a character target until it dies or leaves their attack range
|
||||||
|
|
||||||
|
if (mob.combatTarget != null && AbstractCharacter.IsAbstractCharacter(mob.combatTarget))
|
||||||
|
if (mob.combatTarget.loc.distanceSquared(mob.loc) > mob.getRange() * mob.getRange())
|
||||||
|
mob.setCombatTarget(null);
|
||||||
|
|
||||||
|
} else if (mob.combatTarget != null && mob.combatTarget.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter))
|
||||||
if (mob.combatTarget.loc.distanceSquared(mob.loc) > 10000)
|
if (mob.combatTarget.loc.distanceSquared(mob.loc) > 10000)
|
||||||
mob.setCombatTarget(null);
|
mob.setCombatTarget(null);
|
||||||
}
|
}
|
||||||
@@ -544,7 +544,7 @@ public class MobAI {
|
|||||||
|
|
||||||
PlayerCharacter target = (PlayerCharacter) mob.getCombatTarget();
|
PlayerCharacter target = (PlayerCharacter) mob.getCombatTarget();
|
||||||
|
|
||||||
if (!mob.playerAgroMap.containsKey(target.getObjectUUID())) {
|
if (!mob.isSiege() && !mob.playerAgroMap.containsKey(target.getObjectUUID())) {
|
||||||
mob.setCombatTarget(null);
|
mob.setCombatTarget(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -575,7 +575,7 @@ public class MobAI {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,7 +630,7 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aiAgent.getCombatTarget() == null) {
|
if (PET_AGGRO_ENABLED && aiAgent.getCombatTarget() == null) {
|
||||||
|
|
||||||
//look for pets to aggro if no players found to aggro
|
//look for pets to aggro if no players found to aggro
|
||||||
|
|
||||||
@@ -649,7 +649,7 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForAggro" + " " + e.getMessage());
|
Logger.error(e, aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForAggro");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,7 +702,7 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,7 +746,7 @@ public class MobAI {
|
|||||||
ReSpawner.respawnQueue.put(aiAgent);
|
ReSpawner.respawnQueue.put(aiAgent);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn" + " " + e.getMessage());
|
Logger.error(e, aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -761,7 +761,7 @@ public class MobAI {
|
|||||||
if (mob.getCombatTarget() == null)
|
if (mob.getCombatTarget() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mob.getCombatTarget().getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && !MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) && !mob.agentType.equals(mbEnums.AIAgentType.PET)) {
|
if (mob.getCombatTarget().getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && !MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) && !mob.agentType.equals(mbEnums.AIAgentType.PET) && !mob.isSiege()) {
|
||||||
|
|
||||||
mob.setCombatTarget(null);
|
mob.setCombatTarget(null);
|
||||||
return;
|
return;
|
||||||
@@ -769,7 +769,7 @@ public class MobAI {
|
|||||||
attackTarget(mob, mob.getCombatTarget());
|
attackTarget(mob, mob.getCombatTarget());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForAttack" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForAttack");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -812,7 +812,7 @@ public class MobAI {
|
|||||||
mob.playerAgroMap.replaceAll((e, v) -> 0f);
|
mob.playerAgroMap.replaceAll((e, v) -> 0f);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -851,7 +851,7 @@ public class MobAI {
|
|||||||
mob.updateMovementState();
|
mob.updateMovementState();
|
||||||
mob.updateLocation();
|
mob.updateLocation();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: chaseTarget" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: chaseTarget");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -877,13 +877,17 @@ public class MobAI {
|
|||||||
if (aggroMob.agentType.equals(mbEnums.AIAgentType.PET))
|
if (aggroMob.agentType.equals(mbEnums.AIAgentType.PET))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
//don't attack siege engines
|
||||||
|
if (aggroMob.isSiege())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50))
|
if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mob.setCombatTarget(aggroMob);
|
mob.setCombatTarget(aggroMob);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: SafeGuardAggro" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: SafeGuardAggro");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -913,7 +917,7 @@ public class MobAI {
|
|||||||
checkForAttack(mob); //only check to attack if combat target is not null
|
checkForAttack(mob); //only check to attack if combat target is not null
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardLogic" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardLogic");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -946,7 +950,7 @@ public class MobAI {
|
|||||||
mob.setHealth(mob.getHealthMax());
|
mob.setHealth(mob.getHealthMax());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -970,7 +974,7 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
checkForAttack(mob);
|
checkForAttack(mob);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: HamletGuardLogic" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: HamletGuardLogic");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1043,7 +1047,7 @@ public class MobAI {
|
|||||||
checkForAttack(mob);
|
checkForAttack(mob);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1099,25 +1103,11 @@ public class MobAI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mob.getCombatTarget() == null) {
|
|
||||||
|
|
||||||
//look for siege equipment to aggro if no players found to aggro
|
// guards never auto-aggro siege engines; they only respond when one damages a city building
|
||||||
|
|
||||||
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(mob, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_SIEGE);
|
|
||||||
|
|
||||||
for (AbstractWorldObject awoMob : awoList) {
|
|
||||||
|
|
||||||
|
|
||||||
Mob aggroMob = (Mob) awoMob;
|
|
||||||
if (guardCanAggro(mob, aggroMob)) {
|
|
||||||
mob.setCombatTarget(aggroMob);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForPlayerGuardAggro" + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForPlayerGuardAggro");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1180,7 +1170,7 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCanAggro" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCanAggro");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1232,7 +1222,7 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints" + " " + e);
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1267,7 +1257,7 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
return mostHatedTarget;
|
return mostHatedTarget;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: ChangeTargetFromMostHated" + " " + e.getMessage());
|
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: ChangeTargetFromMostHated");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ package engine.net;
|
|||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.util.ByteBufferUtils;
|
import engine.util.ByteBufferUtils;
|
||||||
import java.time.Instant;
|
import org.joda.time.DateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -58,13 +57,13 @@ public class ByteBufferWriter {
|
|||||||
this.bb.putLong(x);
|
this.bb.putLong(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void putDateTime(Instant dateTime) {
|
public synchronized void putDateTime(DateTime dateTime) {
|
||||||
this.put((byte) dateTime.atZone(ZoneId.systemDefault()).toLocalDate().getDayOfMonth());
|
this.put((byte) dateTime.getDayOfMonth());
|
||||||
this.put((byte) ((byte) dateTime.atZone(ZoneId.systemDefault()).toLocalDate().getMonthValue() - 1));
|
this.put((byte) ((byte) dateTime.getMonthOfYear() - 1));
|
||||||
this.putInt(dateTime.atZone(ZoneId.systemDefault()).toLocalDate().getYear() - 1900);
|
this.putInt(dateTime.getYear() - 1900);
|
||||||
this.put((byte) dateTime.atZone(ZoneId.systemDefault()).toLocalTime().getHour());
|
this.put((byte) dateTime.getHourOfDay());
|
||||||
this.put((byte) dateTime.atZone(ZoneId.systemDefault()).toLocalTime().getMinute());
|
this.put((byte) dateTime.getMinuteOfHour());
|
||||||
this.put((byte) dateTime.atZone(ZoneId.systemDefault()).toLocalTime().getSecond());
|
this.put((byte) dateTime.getSecondOfDay());
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void putLocalDateTime(LocalDateTime dateTime) {
|
public synchronized void putLocalDateTime(LocalDateTime dateTime) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import engine.gameManager.ChatManager;
|
|||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import java.time.Instant;
|
import org.joda.time.DateTime;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@@ -85,7 +85,7 @@ public class NetMsgFactory {
|
|||||||
|
|
||||||
if (protocolMsg == Protocol.NONE) {
|
if (protocolMsg == Protocol.NONE) {
|
||||||
|
|
||||||
String errorString = Instant.now().toString() + origin.lastProtocol.name();
|
String errorString = DateTime.now().toString() + origin.lastProtocol.name();
|
||||||
|
|
||||||
int errorCode = errorString.hashCode();
|
int errorCode = errorString.hashCode();
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import engine.net.client.msg.guild.GuildInfoMsg;
|
|||||||
import engine.objects.Guild;
|
import engine.objects.Guild;
|
||||||
import engine.objects.GuildHistory;
|
import engine.objects.GuildHistory;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
import java.time.Instant;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
public class AcceptInviteToGuildHandler extends AbstractClientMsgHandler {
|
public class AcceptInviteToGuildHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
@@ -90,8 +90,8 @@ public class AcceptInviteToGuildHandler extends AbstractClientMsgHandler {
|
|||||||
//Add to guild History
|
//Add to guild History
|
||||||
|
|
||||||
if (player.getGuild() != null) {
|
if (player.getGuild() != null) {
|
||||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(player.getGuildUUID(), player, Instant.now(), GuildHistoryType.JOIN)) {
|
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(player.getGuildUUID(), player, DateTime.now(), GuildHistoryType.JOIN)) {
|
||||||
GuildHistory guildHistory = new GuildHistory(player.getGuildUUID(), player.getGuild().getName(), Instant.now(), GuildHistoryType.JOIN);
|
GuildHistory guildHistory = new GuildHistory(player.getGuildUUID(), player.getGuild().getName(), DateTime.now(), GuildHistoryType.JOIN);
|
||||||
player.getGuildHistory().add(guildHistory);
|
player.getGuildHistory().add(guildHistory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
|
|||||||
// Filter hirelings by slot type
|
// Filter hirelings by slot type
|
||||||
|
|
||||||
for (Item hirelings : player.getInventory()) {
|
for (Item hirelings : player.getInventory()) {
|
||||||
if (hirelings.template.item_type.equals(ItemType.EMPLOYMENTCONTRACT)) {
|
if (hirelings.template.getItemType().equals(ItemType.EMPLOYMENTCONTRACT)) {
|
||||||
|
|
||||||
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templateID);
|
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templateID);
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class AddItemToTradeWindowMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (!item.validForInventory(source.getClientConnection(), source, source.charItemManager))
|
if (!item.validForInventory(source.getClientConnection(), source, source.charItemManager))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!tradingWith.hasRoomTrade(item.template.item_wt)) {
|
if (!tradingWith.hasRoomTrade(item.template.getItemWt())) {
|
||||||
dispatch = Dispatch.borrow(source, msg);
|
dispatch = Dispatch.borrow(source, msg);
|
||||||
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.PRIMARY);
|
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.PRIMARY);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import engine.objects.Guild;
|
|||||||
import engine.objects.GuildHistory;
|
import engine.objects.GuildHistory;
|
||||||
import engine.objects.GuildStatusController;
|
import engine.objects.GuildStatusController;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
import java.time.Instant;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
public class BanishUnbanishHandler extends AbstractClientMsgHandler {
|
public class BanishUnbanishHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
@@ -95,8 +95,8 @@ public class BanishUnbanishHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
//Set guild history
|
//Set guild history
|
||||||
|
|
||||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), toBanish, Instant.now(), GuildHistoryType.BANISHED)) {
|
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), toBanish, DateTime.now(), GuildHistoryType.BANISHED)) {
|
||||||
GuildHistory guildHistory = new GuildHistory(toBanish.getGuildUUID(), toBanish.getGuild().getName(), Instant.now(), GuildHistoryType.BANISHED);
|
GuildHistory guildHistory = new GuildHistory(toBanish.getGuildUUID(), toBanish.getGuild().getName(), DateTime.now(), GuildHistoryType.BANISHED);
|
||||||
toBanish.getGuildHistory().add(guildHistory);
|
toBanish.getGuildHistory().add(guildHistory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,9 +97,13 @@ public class DestroyBuildingHandler extends AbstractClientMsgHandler {
|
|||||||
if (city == null)
|
if (city == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
|
Warehouse.destroyedWarehouses.remove(building.getObjectUUID());
|
||||||
|
|
||||||
city.warehouse = null;
|
// Rubble no longer owns city.warehouse, which may be null or a newly placed warehouse
|
||||||
|
if (city.warehouse != null && building.getRank() != -1) {
|
||||||
|
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
|
||||||
|
city.warehouse = null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import engine.net.client.msg.guild.GuildInfoMsg;
|
|||||||
import engine.objects.Guild;
|
import engine.objects.Guild;
|
||||||
import engine.objects.Item;
|
import engine.objects.Item;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.parsers.objects.DeedTemplate;
|
||||||
import engine.util.StringUtils;
|
import engine.util.StringUtils;
|
||||||
|
|
||||||
public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
|
public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
|
||||||
@@ -42,6 +43,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
|
|||||||
Guild playerGuild;
|
Guild playerGuild;
|
||||||
|
|
||||||
Item charter;
|
Item charter;
|
||||||
|
DeedTemplate charterDeed;
|
||||||
Dispatch dispatch;
|
Dispatch dispatch;
|
||||||
|
|
||||||
msg = (GuildCreationFinalizeMsg) baseMsg;
|
msg = (GuildCreationFinalizeMsg) baseMsg;
|
||||||
@@ -65,7 +67,9 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
// Item must be a valid charterType (type 10 in db)
|
// Item must be a valid charterType (type 10 in db)
|
||||||
|
|
||||||
if (charter == null || (charter.template.item_type.equals(ItemType.CHARTER) == false)) {
|
charterDeed = DeedTemplate._deeds.get(charter.templateID);
|
||||||
|
|
||||||
|
if (charterDeed == null || (charterDeed.item_type.equals(ItemType.CHARTER) == false)) {
|
||||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,12 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (vendor == null)
|
if (vendor == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// Same access rule as opening the vendor's management window (OrderNPCMsgHandler); never trust the client
|
||||||
|
|
||||||
|
if (!BuildingManager.PlayerCanControlNotOwner(vendor.getBuilding(), player)
|
||||||
|
&& !BuildingManager.playerCanManage(player, vendor.getBuilding()))
|
||||||
|
return true;
|
||||||
|
|
||||||
// Process Request
|
// Process Request
|
||||||
|
|
||||||
switch (msg.actionType) {
|
switch (msg.actionType) {
|
||||||
@@ -238,10 +244,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (targetItem == null)
|
if (targetItem == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (targetItem.template.item_type.equals(ItemType.GOLD))
|
if (targetItem.template.getItemType().equals(ItemType.GOLD))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!vendor.charItemManager.hasRoomInventory(targetItem.template.item_wt)) {
|
if (!vendor.charItemManager.hasRoomInventory(targetItem.template.getItemWt())) {
|
||||||
ErrorPopupMsg.sendErrorPopup(player, 21);
|
ErrorPopupMsg.sendErrorPopup(player, 21);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -299,6 +305,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (vendor.getBuilding() == null)
|
if (vendor.getBuilding() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// NPC buildings have no strongbox to refund into
|
||||||
|
|
||||||
|
if (vendor.getBuilding().getProtectionState() == mbEnums.ProtectionState.NPC)
|
||||||
|
return;
|
||||||
|
|
||||||
PlayerCharacter player = origin.getPlayerCharacter();
|
PlayerCharacter player = origin.getPlayerCharacter();
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
@@ -319,7 +330,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (targetItem == null)
|
if (targetItem == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (targetItem.template.item_type.equals(ItemType.GOLD))
|
if (targetItem.template.getItemType().equals(ItemType.GOLD))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID()))
|
if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID()))
|
||||||
@@ -328,14 +339,14 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (!vendor.charItemManager.inventoryContains(targetItem))
|
if (!vendor.charItemManager.inventoryContains(targetItem))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
itemValue = targetItem.template.item_value;
|
itemValue = targetItem.template.getItemValue();
|
||||||
|
|
||||||
if (vendor.getBuilding().getStrongboxValue() + itemValue > vendor.getBuilding().getMaxGold()) {
|
if (vendor.getBuilding().getStrongboxValue() + itemValue > vendor.getBuilding().getMaxGold()) {
|
||||||
ErrorPopupMsg.sendErrorPopup(player, 201);
|
ErrorPopupMsg.sendErrorPopup(player, 201);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (targetItem.template.item_type) {
|
switch (targetItem.template.getItemType()) {
|
||||||
case EMPLOYMENTCONTRACT:
|
case EMPLOYMENTCONTRACT:
|
||||||
case CHARTER:
|
case CHARTER:
|
||||||
case DEED:
|
case DEED:
|
||||||
@@ -465,13 +476,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (targetItem == null)
|
if (targetItem == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (targetItem.template.item_type.equals(ItemType.GOLD))
|
if (targetItem.template.getItemType().equals(ItemType.GOLD))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!vendor.charItemManager.inventoryContains(targetItem))
|
if (!vendor.charItemManager.inventoryContains(targetItem))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!player.charItemManager.hasRoomInventory(targetItem.template.item_wt))
|
if (!player.charItemManager.hasRoomInventory(targetItem.template.getItemWt()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player.charItemManager.buyFromNPC(targetItem, vendor);
|
player.charItemManager.buyFromNPC(targetItem, vendor);
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public class LootMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (itemRet == null)
|
if (itemRet == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (item.template.item_type.equals(mbEnums.ItemType.GOLD)) {
|
if (item.template.getItemType().equals(mbEnums.ItemType.GOLD)) {
|
||||||
// this is done to prevent the temporary goldItem item
|
// this is done to prevent the temporary goldItem item
|
||||||
// (from the mob) from appearing in player's inventory.
|
// (from the mob) from appearing in player's inventory.
|
||||||
// It also updates the goldItem quantity display
|
// It also updates the goldItem quantity display
|
||||||
@@ -187,7 +187,7 @@ public class LootMsgHandler extends AbstractClientMsgHandler {
|
|||||||
//TODO send group loot message if player is grouped and visible
|
//TODO send group loot message if player is grouped and visible
|
||||||
Group group = GroupManager.getGroup(player);
|
Group group = GroupManager.getGroup(player);
|
||||||
|
|
||||||
if (group != null && group.getSplitGold() && (item.template.item_type.equals(mbEnums.ItemType.GOLD) == false)) {
|
if (group != null && group.getSplitGold() && (item.template.getItemType().equals(mbEnums.ItemType.GOLD) == false)) {
|
||||||
String name = item.getName();
|
String name = item.getName();
|
||||||
String text = player.getFirstName() + " has looted " + name + '.';
|
String text = player.getFirstName() + " has looted " + name + '.';
|
||||||
ChatManager.chatGroupInfoCanSee(player, text);
|
ChatManager.chatGroupInfoCanSee(player, text);
|
||||||
@@ -202,7 +202,7 @@ public class LootMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (itemRet == null)
|
if (itemRet == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (item.template.item_type.equals(mbEnums.ItemType.GOLD)) {
|
if (item.template.getItemType().equals(mbEnums.ItemType.GOLD)) {
|
||||||
// this is done to prevent the temporary goldItem item
|
// this is done to prevent the temporary goldItem item
|
||||||
// (from the mob) from appearing in player's inventory.
|
// (from the mob) from appearing in player's inventory.
|
||||||
// It also updates the goldItem quantity display
|
// It also updates the goldItem quantity display
|
||||||
@@ -241,7 +241,7 @@ public class LootMsgHandler extends AbstractClientMsgHandler {
|
|||||||
//TODO send group loot message if player is grouped and visible
|
//TODO send group loot message if player is grouped and visible
|
||||||
Group group = GroupManager.getGroup(player);
|
Group group = GroupManager.getGroup(player);
|
||||||
|
|
||||||
if (group != null && group.getSplitGold() && (item.template.item_type.equals(mbEnums.ItemType.GOLD) == false)) {
|
if (group != null && group.getSplitGold() && (item.template.getItemType().equals(mbEnums.ItemType.GOLD) == false)) {
|
||||||
String name = item.getName();
|
String name = item.getName();
|
||||||
String text = player.getFirstName() + " has looted " + name + '.';
|
String text = player.getFirstName() + " has looted " + name + '.';
|
||||||
ChatManager.chatGroupInfoCanSee(player, text);
|
ChatManager.chatGroupInfoCanSee(player, text);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import engine.net.client.msg.ErrorPopupMsg;
|
|||||||
import engine.net.client.msg.ManageCityAssetsMsg;
|
import engine.net.client.msg.ManageCityAssetsMsg;
|
||||||
import engine.net.client.msg.PlaceAssetMsg;
|
import engine.net.client.msg.PlaceAssetMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import java.time.LocalDateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @Author:
|
* @Author:
|
||||||
@@ -141,17 +141,9 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
City city = building.getCity();
|
Warehouse warehouse = Warehouse.destroyedWarehouses.get(building.getObjectUUID());
|
||||||
|
|
||||||
if (city == null)
|
if (warehouse == null || Warehouse.isEmpty(warehouse)) {
|
||||||
return true;
|
|
||||||
|
|
||||||
Warehouse warehouse = city.warehouse;
|
|
||||||
|
|
||||||
if (warehouse == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (Warehouse.isEmpty(warehouse)) {
|
|
||||||
ErrorPopupMsg.sendErrorPopup(player, 167); // no more resources.
|
ErrorPopupMsg.sendErrorPopup(player, 167); // no more resources.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -251,10 +243,11 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDateTime baneLive = bane.getPlacementDate();
|
DateTime baneLive = new DateTime(bane.getPlacementDate());
|
||||||
baneLive = baneHour == 24 ? baneLive.plusDays(3) : baneLive.plusDays(2);
|
baneLive = baneHour == 24 ? baneLive.plusDays(3) : baneLive.plusDays(2);
|
||||||
baneLive = baneHour == 24 ? baneLive.withHour(0) : baneLive.withHour(baneHour);
|
baneLive = baneHour == 24 ? baneLive.hourOfDay().setCopy(0) : baneLive.hourOfDay().setCopy(baneHour);
|
||||||
baneLive = baneLive.withMinute(0).withSecond(1).withNano(0);
|
baneLive = baneLive.minuteOfHour().setCopy(0);
|
||||||
|
baneLive = baneLive.secondOfMinute().setCopy(1);
|
||||||
bane.setLiveDate(baneLive);
|
bane.setLiveDate(baneLive);
|
||||||
outMsg.actionType = 18;
|
outMsg.actionType = 18;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import engine.net.Dispatch;
|
|||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.msg.*;
|
import engine.net.client.msg.*;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.DeedTemplate;
|
||||||
import engine.powers.PowersBase;
|
import engine.powers.PowersBase;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -78,7 +79,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
int uuid = item.templateID;
|
int uuid = item.templateID;
|
||||||
|
|
||||||
switch (item.template.item_type) {
|
switch (item.template.getItemType()) {
|
||||||
|
|
||||||
case DEED: //buildings
|
case DEED: //buildings
|
||||||
//Call add building screen here, ib.getUseID() get's building ID
|
//Call add building screen here, ib.getUseID() get's building ID
|
||||||
@@ -99,7 +100,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
pam.setX(loc.getX() + 64); //offset grid from tol
|
pam.setX(loc.getX() + 64); //offset grid from tol
|
||||||
pam.setY(loc.getY());
|
pam.setY(loc.getY());
|
||||||
pam.setZ(loc.getZ() + 64); //offset grid from tol
|
pam.setZ(loc.getZ() + 64); //offset grid from tol
|
||||||
pam.addPlacementInfo(item.template.deed_structure_id);
|
pam.addPlacementInfo(DeedTemplate._deeds.get(item.templateID).deed_structure_id);
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(player, pam);
|
dispatch = Dispatch.borrow(player, pam);
|
||||||
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
|
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
|
||||||
@@ -187,14 +188,14 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (uuid > 680069 && uuid < 680074) //Handle Charter, Deed, Petition, Warrant here
|
if (uuid > 680069 && uuid < 680074) //Handle Charter, Deed, Petition, Warrant here
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (item.template.item_bane_rank > 0) {
|
if (item.template.getItemBaneRank() > 0) {
|
||||||
|
|
||||||
// Only one banestone at a time
|
// Only one banestone at a time
|
||||||
|
|
||||||
lock.writeLock().lock();
|
lock.writeLock().lock();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Bane.summonBanestone(player, origin, item.template.item_bane_rank) == true)
|
if (Bane.summonBanestone(player, origin, item.template.getItemBaneRank()) == true)
|
||||||
itemMan.consume(item);
|
itemMan.consume(item);
|
||||||
} finally {
|
} finally {
|
||||||
lock.writeLock().unlock();
|
lock.writeLock().unlock();
|
||||||
@@ -225,7 +226,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
// Bypass for waterbuckets
|
// Bypass for waterbuckets
|
||||||
|
|
||||||
if (item.template.item_type.equals(mbEnums.ItemType.BUCKET)) {
|
if (item.template.getItemType().equals(mbEnums.ItemType.BUCKET)) {
|
||||||
|
|
||||||
// test for valid target type
|
// test for valid target type
|
||||||
if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter)
|
if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter)
|
||||||
@@ -250,10 +251,9 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (waterbucketBypass == false) {
|
if (waterbucketBypass == false) {
|
||||||
String powerString = item.template.item_power_grant.keySet().iterator().next();
|
engine.parsers.objects.PowerGrant powerGrant = item.template.getItemPowerGrant().get(0);
|
||||||
PowersBase powerAction = PowersManager.powersBaseByIDString.get(powerString);
|
PowersBase powerAction = PowersManager.powersBaseByIDString.get(powerGrant.power_type);
|
||||||
int powerValue = item.template.item_power_grant.get(powerString);
|
PowersManager.applyPower(player, target, Vector3fImmutable.ZERO, powerAction.getToken(), powerGrant.power_value, true);
|
||||||
PowersManager.applyPower(player, target, Vector3fImmutable.ZERO, powerAction.getToken(), powerValue, true);
|
|
||||||
}
|
}
|
||||||
itemMan.consume(item);
|
itemMan.consume(item);
|
||||||
} else //just remove the item at this point
|
} else //just remove the item at this point
|
||||||
@@ -266,7 +266,8 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
case RUNE:
|
case RUNE:
|
||||||
if(ApplyRuneMsg.applyRune(uuid, origin, player)) {
|
if(ApplyRuneMsg.applyRune(uuid, origin, player)) {
|
||||||
itemMan.consume(item);
|
itemMan.consume(item);
|
||||||
}
|
} else
|
||||||
|
ErrorPopupMsg.sendErrorPopup(player, 161);
|
||||||
break;
|
break;
|
||||||
default: //shouldn't be here, consume item
|
default: //shouldn't be here, consume item
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ import engine.net.client.msg.ErrorPopupMsg;
|
|||||||
import engine.net.client.msg.PlaceAssetMsg;
|
import engine.net.client.msg.PlaceAssetMsg;
|
||||||
import engine.net.client.msg.PlaceAssetMsg.PlacementInfo;
|
import engine.net.client.msg.PlaceAssetMsg.PlacementInfo;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
import engine.parsers.objects.DeedTemplate;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import java.time.Instant;
|
import org.joda.time.DateTime;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -135,6 +136,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
private static boolean validateBuildingPlacement(Zone serverZone, PlaceAssetMsg msg, ClientConnection origin, PlayerCharacter player, PlacementInfo placementInfo) {
|
private static boolean validateBuildingPlacement(Zone serverZone, PlaceAssetMsg msg, ClientConnection origin, PlayerCharacter player, PlacementInfo placementInfo) {
|
||||||
|
|
||||||
|
Bane bane;
|
||||||
|
|
||||||
if (serverZone.guild_zone == false) {
|
if (serverZone.guild_zone == false) {
|
||||||
PlaceAssetMsg.sendPlaceAssetError(origin, 52, player.getName());
|
PlaceAssetMsg.sendPlaceAssetError(origin, 52, player.getName());
|
||||||
return false;
|
return false;
|
||||||
@@ -205,6 +208,15 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Siege equipment has its own validation and never reaches here
|
||||||
|
|
||||||
|
bane = city.getBane();
|
||||||
|
|
||||||
|
if (bane != null) {
|
||||||
|
PlaceAssetMsg.sendPlaceAssetError(origin, 74, ""); //"Only buildings of war may be placed during a bane"
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (placementCollisionCheck(serverZone, origin, placementInfo)) {
|
if (placementCollisionCheck(serverZone, origin, placementInfo)) {
|
||||||
PlaceAssetMsg.sendPlaceAssetError(origin, 3, ""); // Conflict between proposed assets
|
PlaceAssetMsg.sendPlaceAssetError(origin, 3, ""); // Conflict between proposed assets
|
||||||
return false;
|
return false;
|
||||||
@@ -345,8 +357,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
Item contract = null;
|
Item contract = null;
|
||||||
|
|
||||||
for (Item inventoryItem : playerCharacter.getInventory()) {
|
for (Item inventoryItem : playerCharacter.getInventory()) {
|
||||||
if (inventoryItem.template.item_type.equals(ItemType.DEED) &&
|
if (inventoryItem.template.getItemType().equals(ItemType.DEED) &&
|
||||||
inventoryItem.template.deed_structure_id == buildingList.getBlueprintUUID()) {
|
DeedTemplate._deeds.get(inventoryItem.templateID).deed_structure_id == buildingList.getBlueprintUUID()) {
|
||||||
contract = inventoryItem;
|
contract = inventoryItem;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1142,7 +1154,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
Blueprint blueprint;
|
Blueprint blueprint;
|
||||||
Building newMesh;
|
Building newMesh;
|
||||||
Instant completionDate;
|
DateTime completionDate;
|
||||||
float vendorRotation;
|
float vendorRotation;
|
||||||
float buildingRotation;
|
float buildingRotation;
|
||||||
|
|
||||||
@@ -1157,9 +1169,9 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
if ((blueprint.getBuildingGroup().equals(BuildingGroup.SIEGETENT))
|
if ((blueprint.getBuildingGroup().equals(BuildingGroup.SIEGETENT))
|
||||||
|| (blueprint.getBuildingGroup().equals(BuildingGroup.BULWARK)))
|
|| (blueprint.getBuildingGroup().equals(BuildingGroup.BULWARK)))
|
||||||
completionDate = Instant.now().plusSeconds(15 * 60);
|
completionDate = DateTime.now().plusMinutes(15);
|
||||||
else
|
else
|
||||||
completionDate = Instant.now().plusSeconds(blueprint.getRankTime(1) * 3600);
|
completionDate = DateTime.now().plusHours(blueprint.getRankTime(1));
|
||||||
|
|
||||||
Vector3fImmutable localLoc = new Vector3fImmutable(ZoneManager.worldToLocal(buildingInfo.getLoc(), currentZone));
|
Vector3fImmutable localLoc = new Vector3fImmutable(ZoneManager.worldToLocal(buildingInfo.getLoc(), currentZone));
|
||||||
|
|
||||||
@@ -1168,10 +1180,10 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
// if W return is negative, this is a -90 rotation not a 90?
|
// if W return is negative, this is a -90 rotation not a 90?
|
||||||
|
|
||||||
newMesh = DbManager.BuildingQueries.CREATE_BUILDING(
|
newMesh = Building.persistBuilding(Building.createBuilding(
|
||||||
currentZone.getObjectUUID(), playerCharacter.getObjectUUID(), blueprint.getName(), blueprint.getMeshForRank(0),
|
currentZone, playerCharacter.getObjectUUID(), blueprint.getName(), blueprint.getMeshForRank(0),
|
||||||
localLoc, 1.0f, blueprint.getMaxHealth(0), ProtectionState.NONE, 0, 0,
|
localLoc, 1.0f, blueprint.getMaxHealth(0), ProtectionState.NONE, 0, 0,
|
||||||
completionDate, blueprint.getMeshForRank(0), vendorRotation, buildingRotation);
|
completionDate, blueprint.getMeshForRank(0), vendorRotation, buildingRotation));
|
||||||
|
|
||||||
// Make sure we have a valid mesh
|
// Make sure we have a valid mesh
|
||||||
|
|
||||||
@@ -1228,7 +1240,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
ArrayList<AbstractGameObject> shrineObjects = DbManager.ShrineQueries.CREATE_SHRINE(
|
ArrayList<AbstractGameObject> shrineObjects = DbManager.ShrineQueries.CREATE_SHRINE(
|
||||||
currentZone.getObjectUUID(), player.getObjectUUID(), blueprint.getName(), blueprint.getMeshForRank(0),
|
currentZone.getObjectUUID(), player.getObjectUUID(), blueprint.getName(), blueprint.getMeshForRank(0),
|
||||||
localLoc, 1.0f, blueprint.getMaxHealth(0), ProtectionState.PROTECTED, 0, 0,
|
localLoc, 1.0f, blueprint.getMaxHealth(0), ProtectionState.PROTECTED, 0, 0,
|
||||||
Instant.now().plusSeconds(blueprint.getRankTime(1) * 3600), blueprint.getMeshForRank(0), vendorRotation, buildingRotation, shrineType.name());
|
DateTime.now().plusHours(blueprint.getRankTime(1)), blueprint.getMeshForRank(0), vendorRotation, buildingRotation, shrineType.name());
|
||||||
|
|
||||||
if (shrineObjects == null) {
|
if (shrineObjects == null) {
|
||||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||||
@@ -1288,13 +1300,13 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
float buildingRotation = buildingInfo.getRot().y;
|
float buildingRotation = buildingInfo.getRot().y;
|
||||||
float vendorRotation = buildingInfo.getW();
|
float vendorRotation = buildingInfo.getW();
|
||||||
Instant completionDate = Instant.now().plusSeconds(blueprint.getRankTime(1) * 3600);
|
DateTime completionDate = DateTime.now().plusHours(blueprint.getRankTime(1));
|
||||||
|
|
||||||
|
|
||||||
newMesh = DbManager.BuildingQueries.CREATE_BUILDING(
|
newMesh = Building.persistBuilding(Building.createBuilding(
|
||||||
currentZone.getObjectUUID(), player.getObjectUUID(), blueprint.getName(), blueprint.getMeshForRank(0),
|
currentZone, player.getObjectUUID(), blueprint.getName(), blueprint.getMeshForRank(0),
|
||||||
localLoc, 1.0f, blueprint.getMaxHealth(0), ProtectionState.PROTECTED, 0, 0,
|
localLoc, 1.0f, blueprint.getMaxHealth(0), ProtectionState.PROTECTED, 0, 0,
|
||||||
completionDate, blueprint.getMeshForRank(0), vendorRotation, buildingRotation);
|
completionDate, blueprint.getMeshForRank(0), vendorRotation, buildingRotation));
|
||||||
|
|
||||||
// Make sure we have a valid mesh
|
// Make sure we have a valid mesh
|
||||||
if (newMesh == null) {
|
if (newMesh == null) {
|
||||||
@@ -1330,10 +1342,10 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
City city = City.getCity(currentZone.playerCityUUID);
|
City city = City.getCity(currentZone.playerCityUUID);
|
||||||
|
|
||||||
warehouseBuilding = DbManager.BuildingQueries.CREATE_BUILDING(
|
warehouseBuilding = Building.persistBuilding(Building.createBuilding(
|
||||||
currentZone.getObjectUUID(), player.getObjectUUID(), blueprint.getName(), blueprint.getMeshForRank(0),
|
currentZone, player.getObjectUUID(), blueprint.getName(), blueprint.getMeshForRank(0),
|
||||||
localLoc, 1.0f, blueprint.getMaxHealth(0), ProtectionState.NONE, 0, 0,
|
localLoc, 1.0f, blueprint.getMaxHealth(0), ProtectionState.NONE, 0, 0,
|
||||||
Instant.now().plusSeconds(blueprint.getRankTime(1) * 3600), blueprint.getMeshForRank(0), vendorRotation, buildingRotation);
|
DateTime.now().plusHours(blueprint.getRankTime(1)), blueprint.getMeshForRank(0), vendorRotation, buildingRotation));
|
||||||
|
|
||||||
if (warehouseBuilding == null) {
|
if (warehouseBuilding == null) {
|
||||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||||
@@ -1341,6 +1353,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Warehouse warehouse = new Warehouse(warehouseBuilding);
|
Warehouse warehouse = new Warehouse(warehouseBuilding);
|
||||||
|
Warehouse.destroyedWarehouses.values().removeIf(destroyed -> destroyed.city == city);
|
||||||
city.warehouse = warehouse;
|
city.warehouse = warehouse;
|
||||||
DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse);
|
DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse);
|
||||||
|
|
||||||
@@ -1350,7 +1363,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
MaintenanceManager.setMaintDateTime(warehouseBuilding, LocalDateTime.now().plusDays(7));
|
MaintenanceManager.setMaintDateTime(warehouseBuilding, LocalDateTime.now().plusDays(7));
|
||||||
warehouseBuilding.setLoc(warehouseBuilding.getLoc());
|
warehouseBuilding.setLoc(warehouseBuilding.getLoc());
|
||||||
InterestManager.setObjectDirty(warehouseBuilding);
|
InterestManager.setObjectDirty(warehouseBuilding);
|
||||||
warehouseBuilding.runAfterLoad();
|
|
||||||
|
|
||||||
if (city == null)
|
if (city == null)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import engine.mbEnums;
|
|||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.msg.ClientNetMsg;
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
import engine.net.client.msg.RefineMsg;
|
import engine.net.client.msg.RefineMsg;
|
||||||
import engine.net.client.msg.RefinerScreenMsg;
|
import engine.net.client.msg.RefinerScreenMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
@@ -88,6 +89,9 @@ public class RefineMsgHandler extends AbstractClientMsgHandler {
|
|||||||
public static boolean refineSkill(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) {
|
public static boolean refineSkill(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) {
|
||||||
CharacterSkill skill = null;
|
CharacterSkill skill = null;
|
||||||
ConcurrentHashMap<String, CharacterSkill> skills = pc.getSkills();
|
ConcurrentHashMap<String, CharacterSkill> skills = pc.getSkills();
|
||||||
|
int refinedAmount;
|
||||||
|
int requiredAmount;
|
||||||
|
|
||||||
for (CharacterSkill sk : skills.values()) {
|
for (CharacterSkill sk : skills.values()) {
|
||||||
if (sk == null)
|
if (sk == null)
|
||||||
continue;
|
continue;
|
||||||
@@ -106,17 +110,16 @@ public class RefineMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
//TODO verify if any skills have this as prereq
|
//TODO verify if any skills have this as prereq
|
||||||
|
|
||||||
//TODO verify if any powers have this as a prereq
|
// Dropping below a trained power's skill requirement would make calculatePowers delete the power and its trains
|
||||||
//get all players powers
|
refinedAmount = Math.round(skill.getBaseAmountBeforeMods() + skill.calculateAmountAfterTrains(skill.getNumTrains() - 1));
|
||||||
|
|
||||||
for (CharacterPower power : pc.getPowers().values()) {
|
for (CharacterPower power : pc.getPowers().values()) {
|
||||||
ArrayList<PowerReq> reqs = PowerReq.getPowerReqsForRune(power.getPowerID());
|
if (power.getTrains() < 1)
|
||||||
for (PowerReq req : reqs) {
|
continue;
|
||||||
ConcurrentHashMap<String, CharacterSkill> playerSkills = pc.getSkills();
|
requiredAmount = getRequiredSkillAmount(pc, power.getPower().getToken(), token);
|
||||||
CharacterSkill playerSkill = playerSkills.get(token);
|
if (refinedAmount < requiredAmount) {
|
||||||
int currentSkillLevel = playerSkill.getTotalSkillPercet();
|
ErrorPopupMsg.sendErrorMsg(pc, "You must refine " + power.getPower().getName() + " to 0 before refining any more from this skill.");
|
||||||
if (token == req.getToken() && req.getLevel() == currentSkillLevel) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +127,36 @@ public class RefineMsgHandler extends AbstractClientMsgHandler {
|
|||||||
return skill.refine(pc);
|
return skill.refine(pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getRequiredSkillAmount(PlayerCharacter pc, int powerToken, int skillToken) {
|
||||||
|
int requiredAmount = 0;
|
||||||
|
|
||||||
|
if (pc.race != null)
|
||||||
|
requiredAmount = Math.max(requiredAmount, getRequiredSkillAmount(pc.race.getPowersGranted(), powerToken, skillToken));
|
||||||
|
if (pc.baseClass != null)
|
||||||
|
requiredAmount = Math.max(requiredAmount, getRequiredSkillAmount(pc.baseClass.getPowersGranted(), powerToken, skillToken));
|
||||||
|
if (pc.promotionClass != null)
|
||||||
|
requiredAmount = Math.max(requiredAmount, getRequiredSkillAmount(pc.promotionClass.getPowersGranted(), powerToken, skillToken));
|
||||||
|
if (pc.getRunes() != null)
|
||||||
|
for (CharacterRune rune : pc.getRunes())
|
||||||
|
requiredAmount = Math.max(requiredAmount, getRequiredSkillAmount(rune.getPowersGranted(), powerToken, skillToken));
|
||||||
|
|
||||||
|
return requiredAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getRequiredSkillAmount(ArrayList<PowerReq> powersGranted, int powerToken, int skillToken) {
|
||||||
|
Byte requiredAmount;
|
||||||
|
|
||||||
|
for (PowerReq powerReq : powersGranted) {
|
||||||
|
if (powerReq.getToken() != powerToken)
|
||||||
|
continue;
|
||||||
|
requiredAmount = powerReq.getSkillReqs().get(skillToken);
|
||||||
|
if (requiredAmount != null)
|
||||||
|
return requiredAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean refinePower(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) {
|
public static boolean refinePower(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) {
|
||||||
CharacterPower power = null;
|
CharacterPower power = null;
|
||||||
ConcurrentHashMap<Integer, CharacterPower> powers = pc.getPowers();
|
ConcurrentHashMap<Integer, CharacterPower> powers = pc.getPowers();
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class RepairMsgHandler extends AbstractClientMsgHandler {
|
|||||||
//make sure item is damaged and not destroyed
|
//make sure item is damaged and not destroyed
|
||||||
|
|
||||||
short dur = (short) toRepair.combat_health_current;
|
short dur = (short) toRepair.combat_health_current;
|
||||||
short max = (short) toRepair.template.combat_health_full;
|
short max = (short) toRepair.template.getCombatHealthFull();
|
||||||
|
|
||||||
//account for durability modifications
|
//account for durability modifications
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class TransferItemFromBankMsgHandler extends AbstractClientMsgHandler {
|
|||||||
return true;
|
return true;
|
||||||
;
|
;
|
||||||
|
|
||||||
if (item.template.item_type.equals(mbEnums.ItemType.GOLD)) {
|
if (item.template.getItemType().equals(mbEnums.ItemType.GOLD)) {
|
||||||
|
|
||||||
if (!itemManager.moveGoldToInventory(item, msg.getNumItems()))
|
if (!itemManager.moveGoldToInventory(item, msg.getNumItems()))
|
||||||
return true;
|
return true;
|
||||||
@@ -85,7 +85,7 @@ public class TransferItemFromBankMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
// Not gold, process update here
|
// Not gold, process update here
|
||||||
|
|
||||||
if (!itemManager.hasRoomInventory(item.template.item_wt))
|
if (!itemManager.hasRoomInventory(item.template.getItemWt()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (itemManager.moveItemToInventory(item) == false)
|
if (itemManager.moveItemToInventory(item) == false)
|
||||||
|
|||||||
Loaded 100 of 327 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user