forked from MagicBane/Server
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 250e3407fa | |||
| fcd37cbae2 | |||
| 70e76d9a1a | |||
| 6a3bd89095 | |||
| 4ccf03dfd3 | |||
| f845c0ad80 | |||
| 165752f6d6 | |||
| c0ee8b82f8 | |||
| cc1e0d8986 | |||
| 7f6fbd2bff | |||
| 92d8ed9e3f | |||
| 45b2443982 | |||
| 3775fb336b | |||
| f7a8ca33fc | |||
| c45265b085 | |||
| 79400b6b0e | |||
| 2bff826a10 | |||
| d5fc87c233 | |||
| 78a0416b19 | |||
| eb5bc14974 | |||
| 7e99e8c7a4 | |||
| 9b0f4d5aef | |||
| b58049968f | |||
| 9bf0d3f7d1 | |||
| 8300c47e4a | |||
| c73fcc19f2 | |||
| f93573177a | |||
| fe9c6437d8 | |||
| c110ffc4b1 |
@@ -15,7 +15,6 @@ import engine.Enum.ProtectionState;
|
|||||||
import engine.Enum.TaxType;
|
import engine.Enum.TaxType;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.math.Vector2f;
|
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
@@ -549,86 +548,6 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void POPULATE_RENDER_LOOKUP() {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_structure_renders`")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
|
|
||||||
int structureID = rs.getInt("structureID");
|
|
||||||
int renderID = rs.getInt("renderID");
|
|
||||||
|
|
||||||
if (!BuildingManager._render_lookup.containsKey(structureID))
|
|
||||||
BuildingManager._render_lookup.put(structureID, new ArrayList<>());
|
|
||||||
|
|
||||||
BuildingManager._render_lookup.get(structureID).add(renderID);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LOAD_MESH_HULLS() {
|
|
||||||
|
|
||||||
int recordsRead = 0;
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_verts")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
|
|
||||||
recordsRead++;
|
|
||||||
|
|
||||||
int propID = rs.getInt("propID");
|
|
||||||
String[] vertStrings = rs.getString("vertices").split(";");
|
|
||||||
ArrayList<Vector2f> vertArrayList = new ArrayList<>();
|
|
||||||
|
|
||||||
// Filter things that couldn't be wrapped
|
|
||||||
|
|
||||||
if (vertStrings.length < 3) {
|
|
||||||
Logger.error("Prop : " + propID + " has less than 3 vertices.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ArrayList<Vector2f> vectors = new ArrayList<>();
|
|
||||||
ArrayList<Float> floats = new ArrayList<>();
|
|
||||||
for(String read : vertStrings){
|
|
||||||
floats.add(Float.parseFloat(read));
|
|
||||||
if(floats.size() == 2) {
|
|
||||||
vectors.add(new Vector2f(floats.get(0), floats.get(1)));
|
|
||||||
floats = new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//for (int i = 0; i < vertStrings.length; i += 2)
|
|
||||||
// vertArrayList.add(new Vector2f(Float.parseFloat(vertStrings[i]), Float.parseFloat(vertStrings[1 + 1])));
|
|
||||||
|
|
||||||
ArrayList<ArrayList<Vector2f>> meshList;
|
|
||||||
|
|
||||||
if (BuildingManager._hull_data.get(propID) == null) {
|
|
||||||
meshList = new ArrayList<>();
|
|
||||||
meshList.add(vectors);
|
|
||||||
BuildingManager._hull_data.put(propID, meshList);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
meshList = BuildingManager._hull_data.get(propID);
|
|
||||||
meshList.add(vectors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.info("read: " + recordsRead + " cached: " + BuildingManager._hull_data.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<Integer, ArrayList<BuildingRegions>> LOAD_BUILDING_REGIONS() {
|
public HashMap<Integer, ArrayList<BuildingRegions>> LOAD_BUILDING_REGIONS() {
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<BuildingRegions>> regionList = new HashMap<>();
|
HashMap<Integer, ArrayList<BuildingRegions>> regionList = new HashMap<>();
|
||||||
|
|||||||
@@ -34,16 +34,19 @@ public class dbCityHandler extends dbHandlerBase {
|
|||||||
case "zone":
|
case "zone":
|
||||||
Zone zone = new Zone(rs);
|
Zone zone = new Zone(rs);
|
||||||
DbManager.addToCache(zone);
|
DbManager.addToCache(zone);
|
||||||
|
zone.runAfterLoad();
|
||||||
list.add(zone);
|
list.add(zone);
|
||||||
break;
|
break;
|
||||||
case "building":
|
case "building":
|
||||||
Building building = new Building(rs);
|
Building building = new Building(rs);
|
||||||
DbManager.addToCache(building);
|
DbManager.addToCache(building);
|
||||||
|
building.runAfterLoad();
|
||||||
list.add(building);
|
list.add(building);
|
||||||
break;
|
break;
|
||||||
case "city":
|
case "city":
|
||||||
City city = new City(rs);
|
City city = new City(rs);
|
||||||
DbManager.addToCache(city);
|
DbManager.addToCache(city);
|
||||||
|
city.runAfterLoad();
|
||||||
list.add(city);
|
list.add(city);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_locks`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_locks`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, locks);
|
preparedStatement.setLong(1, locks);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_gold`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_gold`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_stone`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_stone`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_truesteel`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_truesteel`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_iron`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_iron`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_adamant`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_adamant`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_lumber`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_lumber`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_oak`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_oak`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_bronzewood`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_bronzewood`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_mandrake`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_mandrake`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -269,7 +269,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_coal`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_coal`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -285,7 +285,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_agate`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_agate`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_diamond`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_diamond`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -317,7 +317,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_onyx`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_onyx`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_azoth`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_azoth`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -349,7 +349,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_orichalk`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_orichalk`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_antimony`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_antimony`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -381,7 +381,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_sulfur`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_sulfur`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -397,7 +397,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_quicksilver`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_quicksilver`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -413,7 +413,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_galvor`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_galvor`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -429,7 +429,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_wormwood`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_wormwood`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -445,7 +445,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_obsidian`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_obsidian`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -461,7 +461,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_bloodstone`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_bloodstone`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -477,7 +477,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_mithril`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_mithril`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, amount);
|
preparedStatement.setInt(1, amount);
|
||||||
preparedStatement.setInt(2, wh.getUID());
|
preparedStatement.setInt(2, wh.UID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -545,7 +545,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
|||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
warehouse = new Warehouse(rs);
|
warehouse = new Warehouse(rs);
|
||||||
warehouse.runAfterLoad();
|
warehouse.runAfterLoad();
|
||||||
warehouse.loadAllTransactions();
|
Warehouse.loadAllTransactions(warehouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|||||||
@@ -10,18 +10,15 @@
|
|||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.Enum.GameObjectType;
|
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.ChatManager;
|
import engine.gameManager.ChatManager;
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.objects.AbstractGameObject;
|
||||||
import engine.objects.*;
|
import engine.objects.Mob;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.objects.Zone;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Eighty
|
|
||||||
*/
|
|
||||||
public class AddMobCmd extends AbstractDevCmd {
|
public class AddMobCmd extends AbstractDevCmd {
|
||||||
|
|
||||||
public AddMobCmd() {
|
public AddMobCmd() {
|
||||||
@@ -38,27 +35,8 @@ public class AddMobCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
|
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||||
|
|
||||||
if (words[0].equals("all")) {
|
|
||||||
|
|
||||||
for (AbstractGameObject mobbaseAGO : DbManager.getList(GameObjectType.MobBase)) {
|
|
||||||
MobBase mb = (MobBase) mobbaseAGO;
|
|
||||||
int loadID = mb.getObjectUUID();
|
|
||||||
Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
|
|
||||||
null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE);
|
|
||||||
if (mob != null) {
|
|
||||||
mob.updateDatabase();
|
|
||||||
this.setResult(String.valueOf(mob.getDBID()));
|
|
||||||
} else {
|
|
||||||
throwbackError(pc, "Failed to create mob of type " + loadID);
|
|
||||||
Logger.error("Failed to create mob of type "
|
|
||||||
+ loadID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int loadID;
|
int loadID;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loadID = Integer.parseInt(words[0]);
|
loadID = Integer.parseInt(words[0]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
@@ -72,7 +50,6 @@ public class AddMobCmd extends AbstractDevCmd {
|
|||||||
return; // NaN
|
return; // NaN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (zone == null) {
|
if (zone == null) {
|
||||||
throwbackError(pc, "Failed to find zone to place mob in.");
|
throwbackError(pc, "Failed to find zone to place mob in.");
|
||||||
return;
|
return;
|
||||||
@@ -83,9 +60,9 @@ public class AddMobCmd extends AbstractDevCmd {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Mob mob = Mob.createMob(loadID, pc.getLoc(),
|
Mob mob = Mob.createMob(loadID, pc.getLoc(),
|
||||||
null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE);
|
null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE);
|
||||||
|
|
||||||
if (mob != null) {
|
if (mob != null) {
|
||||||
mob.updateDatabase();
|
mob.updateDatabase();
|
||||||
ChatManager.chatSayInfo(pc,
|
ChatManager.chatSayInfo(pc,
|
||||||
|
|||||||
@@ -12,22 +12,10 @@ package engine.devcmd.cmds;
|
|||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
import engine.gameManager.NavigationManager;
|
|
||||||
import engine.gameManager.ZoneManager;
|
|
||||||
import engine.math.Vector3f;
|
|
||||||
import engine.math.Vector3fImmutable;
|
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.geom.AffineTransform;
|
|
||||||
import java.awt.geom.Area;
|
|
||||||
import java.awt.geom.Path2D;
|
|
||||||
import java.awt.geom.Rectangle2D;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import static java.awt.geom.Path2D.WIND_EVEN_ODD;
|
|
||||||
import static java.awt.geom.Path2D.WIND_NON_ZERO;
|
|
||||||
|
|
||||||
public class RegionCmd extends AbstractDevCmd {
|
public class RegionCmd extends AbstractDevCmd {
|
||||||
|
|
||||||
public RegionCmd() {
|
public RegionCmd() {
|
||||||
@@ -47,36 +35,20 @@ public class RegionCmd extends AbstractDevCmd {
|
|||||||
this.throwbackInfo(pc, "No Building At This Location.") ;
|
this.throwbackInfo(pc, "No Building At This Location.") ;
|
||||||
}
|
}
|
||||||
Regions region = ((AbstractCharacter)target).region;
|
Regions region = ((AbstractCharacter)target).region;
|
||||||
output += "In Floor: " + ((AbstractCharacter) target).getInFloorID() + newline;
|
|
||||||
output += "In Building: " + ((AbstractCharacter) target).getInBuilding() + newline;
|
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
output += "No Region Found." + newline;
|
this.throwbackInfo(pc, "No Region Found.");
|
||||||
}else{
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(region != null) {
|
||||||
output += "Player Info: " + ((AbstractCharacter) target).getName() + newline;
|
output += "Player Info: " + ((AbstractCharacter) target).getName() + newline;
|
||||||
output += "Region Building: " + building.getName() + newline;
|
output += "Region Building: " + building.getName() + newline;
|
||||||
output += "Region Height: " + region.lerpY(((AbstractCharacter)target).loc) + newline;
|
output += "Region Height: " + region.lerpY((AbstractCharacter)target) + newline;
|
||||||
output += "is Stairs: " + region.isStairs() + newline;
|
output += "is Stairs: " + region.isStairs() + newline;
|
||||||
output += "is Outside: " + region.isOutside() + newline;
|
output += "is Outside: " + region.isOutside();
|
||||||
output += "is Entrance: " + region.isExit() + newline;
|
|
||||||
for(Vector3f point : region.regionPoints)
|
|
||||||
output += point + newline;
|
|
||||||
output += "NavMesh Data" + newline;
|
|
||||||
this.throwbackInfo(pc, output);
|
this.throwbackInfo(pc, output);
|
||||||
}
|
}
|
||||||
//Zone zone = ZoneManager.findSmallestZone(((AbstractCharacter) target).loc);
|
|
||||||
//if(zone != null) {
|
|
||||||
// output += "zone: " + zone.zoneName + newline;
|
|
||||||
// output += "on navmesh: " + zone.navMesh.contains(((AbstractCharacter) target).loc.x,((AbstractCharacter) target).loc.z) + newline;
|
|
||||||
//}else {
|
|
||||||
// output += "zone: null" + newline;
|
|
||||||
//}
|
|
||||||
|
|
||||||
output += "pointBlocked: " + NavigationManager.pointIsBlocked(((AbstractCharacter)target).loc);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.throwbackInfo(pc, output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ import engine.Enum.BuildingGroup;
|
|||||||
import engine.Enum.DbObjectType;
|
import engine.Enum.DbObjectType;
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.*;
|
||||||
import engine.gameManager.ChatManager;
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.gameManager.ZoneManager;
|
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ import engine.Enum;
|
|||||||
import engine.Enum.GameObjectType;
|
import engine.Enum.GameObjectType;
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.PowersManager;
|
import engine.gameManager.PowersManager;
|
||||||
import engine.math.Vector3fImmutable;
|
|
||||||
import engine.mobileAI.MobAI;
|
import engine.mobileAI.MobAI;
|
||||||
import engine.mobileAI.utilities.PathingUtilities;
|
|
||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.AbstractGameObject;
|
||||||
import engine.objects.Mob;
|
import engine.objects.Mob;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
@@ -152,10 +150,7 @@ public class aiInfoCmd extends AbstractDevCmd {
|
|||||||
for (Integer outlawUUID : outlaws)
|
for (Integer outlawUUID : outlaws)
|
||||||
output += outlawUUID + newline;
|
output += outlawUUID + newline;
|
||||||
}
|
}
|
||||||
output += "Walking: " + ((Mob) target).isMoving() + newline;
|
|
||||||
output += "Destination: " + ((Mob) target).destination + newline;
|
|
||||||
output += "is Pathing: " + mob.isPathing + newline;
|
|
||||||
((Mob) target).isPathing = false;
|
|
||||||
throwbackInfo(playerCharacter, output);
|
throwbackInfo(playerCharacter, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ import engine.job.JobContainer;
|
|||||||
import engine.job.JobScheduler;
|
import engine.job.JobScheduler;
|
||||||
import engine.jobs.UpgradeBuildingJob;
|
import engine.jobs.UpgradeBuildingJob;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.Vector2f;
|
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.mobileAI.utilities.PathingUtilities;
|
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.msg.ErrorPopupMsg;
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
import engine.net.client.msg.ManageCityAssetsMsg;
|
import engine.net.client.msg.ManageCityAssetsMsg;
|
||||||
@@ -29,7 +27,6 @@ import engine.objects.*;
|
|||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.awt.geom.Path2D;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -41,8 +38,6 @@ public enum BuildingManager {
|
|||||||
|
|
||||||
BUILDINGMANAGER;
|
BUILDINGMANAGER;
|
||||||
|
|
||||||
public static HashMap<Integer, ArrayList<Integer>> _render_lookup = new HashMap<>();
|
|
||||||
public static HashMap<Integer, ArrayList<ArrayList<Vector2f>>> _hull_data = new HashMap<>();
|
|
||||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _stuckLocations = new HashMap<>();
|
public static HashMap<Integer, ArrayList<BuildingLocation>> _stuckLocations = new HashMap<>();
|
||||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations = new HashMap<>();
|
public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations = new HashMap<>();
|
||||||
|
|
||||||
@@ -239,15 +234,15 @@ public enum BuildingManager {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
if (warehouse.getResources().get(resourceBase) == null)
|
if (warehouse.resources.get(resourceBase) == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int resourceAmount = warehouse.getResources().get(resourceBase);
|
int resourceAmount = warehouse.resources.get(resourceBase);
|
||||||
|
|
||||||
if (resourceAmount <= 0)
|
if (resourceAmount <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (warehouse.loot(player, resourceBase, resourceAmount, true))
|
if (Warehouse.loot(warehouse, player, resourceBase, resourceAmount, true))
|
||||||
ChatManager.chatInfoInfo(player, "You have looted " + resourceAmount + ' ' + resourceBase.getName());
|
ChatManager.chatInfoInfo(player, "You have looted " + resourceAmount + ' ' + resourceBase.getName());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -550,7 +545,7 @@ public enum BuildingManager {
|
|||||||
|
|
||||||
NPC npc = null;
|
NPC npc = null;
|
||||||
|
|
||||||
npc = NPC.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, null, zone, (short) rank, building);
|
npc = NPC.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, building.getGuild(), zone, (short) rank, building);
|
||||||
|
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
return false;
|
return false;
|
||||||
@@ -965,63 +960,4 @@ public enum BuildingManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bakeNavMesh(Building building) {
|
|
||||||
building.meshes = new ArrayList<>();
|
|
||||||
if (building.parentZone == null) {
|
|
||||||
Logger.error("Attempt to bake navmesh with no parent: " + building.getObjectUUID());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build up navmesh by stencil of the
|
|
||||||
// convex hull meshes that comprise the prop.
|
|
||||||
|
|
||||||
ArrayList<ArrayList<Vector2f>> convexHullList;
|
|
||||||
convexHullList = _hull_data.get(building.meshUUID);
|
|
||||||
|
|
||||||
if (convexHullList == null) {
|
|
||||||
Logger.error("Attempt to bake navmesh with no meshes: " + building.getObjectUUID());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ArrayList<Vector2f> meshEntry : convexHullList) {
|
|
||||||
Path2D.Float meshBound = new Path2D.Float();
|
|
||||||
Vector3fImmutable offsetVect = new Vector3fImmutable(meshEntry.get(0).x + building.loc.x, building.loc.y,meshEntry.get(0).y + building.loc.z);
|
|
||||||
Vector3fImmutable rotatedStart = Vector3fImmutable.rotateAroundPoint(building.loc,offsetVect,building.getRot().y);
|
|
||||||
meshBound.moveTo(rotatedStart.x,rotatedStart.z);
|
|
||||||
for (Vector2f vect : meshEntry) {
|
|
||||||
if(meshEntry.indexOf(vect) == 0){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Vector3fImmutable pos = new Vector3fImmutable(vect.x + building.loc.x, building.loc.y,vect.y + building.loc.z);
|
|
||||||
Vector3fImmutable rotatedPos = Vector3fImmutable.rotateAroundPoint(building.loc,pos,building.getRot().getRotation());
|
|
||||||
meshBound.lineTo(rotatedPos.x,rotatedPos.z);
|
|
||||||
}
|
|
||||||
meshBound.lineTo(rotatedStart.x,rotatedStart.z);
|
|
||||||
meshBound.closePath();
|
|
||||||
building.meshes.add(meshBound);
|
|
||||||
building.parentZone.navObstacles.add(meshBound);
|
|
||||||
}
|
|
||||||
//add navNodes to parent zone list
|
|
||||||
float X = building.getBounds().getHalfExtents().x;
|
|
||||||
float Y = building.getBounds().getHalfExtents().y;
|
|
||||||
ArrayList<Vector2f> cornersAndFaces = new ArrayList<>();
|
|
||||||
cornersAndFaces.add(new Vector2f(building.loc.x - X,building.loc.z - Y));
|
|
||||||
cornersAndFaces.add(new Vector2f(building.loc.x + X,building.loc.z + Y));
|
|
||||||
cornersAndFaces.add(new Vector2f(building.loc.x + X,building.loc.z - Y));
|
|
||||||
cornersAndFaces.add(new Vector2f(building.loc.x - X,building.loc.z + Y));
|
|
||||||
cornersAndFaces.add(new Vector2f(building.loc.x - X,building.loc.z));
|
|
||||||
cornersAndFaces.add(new Vector2f(building.loc.x + X,building.loc.z));
|
|
||||||
cornersAndFaces.add(new Vector2f(building.loc.x,building.loc.z - Y));
|
|
||||||
cornersAndFaces.add(new Vector2f(building.loc.x,building.loc.z + Y));
|
|
||||||
for(Vector2f point : cornersAndFaces){
|
|
||||||
if(!NavigationManager.pointIsBlocked(new Vector3fImmutable(point.x,building.loc.y,point.y))){
|
|
||||||
building.parentZone.navNodes.add(new PathingUtilities.Node(point,null,building));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//add region centers to the zones navNodes list
|
|
||||||
for(Regions region : building.getBounds().getRegions()){
|
|
||||||
building.parentZone.navNodes.add(new PathingUtilities.Node(new Vector2f(region.center.x,region.center.z),region,building));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,22 +45,27 @@ public enum MaintenanceManager {
|
|||||||
// Deduct upkeep and build list of buildings
|
// Deduct upkeep and build list of buildings
|
||||||
// which did not have funds available
|
// which did not have funds available
|
||||||
|
|
||||||
for (Building building : maintList) {
|
try {
|
||||||
|
for (Building building : maintList)
|
||||||
if (chargeUpkeep(building) == false)
|
if (chargeUpkeep(building) == false)
|
||||||
derankList.add(building);
|
derankList.add(building);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
// Reset maintenance dates for these buildings
|
// Reset maintenance dates for these buildings
|
||||||
|
|
||||||
for (Building building : maintList) {
|
for (Building building : maintList)
|
||||||
setMaintDateTime(building, LocalDateTime.now().plusDays(7));
|
setMaintDateTime(building, LocalDateTime.now().plusDays(7));
|
||||||
|
|
||||||
}
|
|
||||||
// Derak or destroy buildings that did not
|
// Derak or destroy buildings that did not
|
||||||
// have funds available.
|
// have funds available.
|
||||||
|
|
||||||
for (Building building : derankList)
|
try {
|
||||||
building.destroyOrDerank(null);
|
for (Building building : derankList)
|
||||||
|
building.destroyOrDerank(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size());
|
Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size());
|
||||||
}
|
}
|
||||||
@@ -179,7 +184,7 @@ public enum MaintenanceManager {
|
|||||||
if ((overDraft > 0))
|
if ((overDraft > 0))
|
||||||
if ((building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.SHRINE) == false) &&
|
if ((building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.SHRINE) == false) &&
|
||||||
(warehouse != null) && building.assetIsProtected() == true &&
|
(warehouse != null) && building.assetIsProtected() == true &&
|
||||||
(warehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) >= overDraft) {
|
(warehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) >= overDraft) {
|
||||||
hasFunds = true;
|
hasFunds = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,22 +199,22 @@ public enum MaintenanceManager {
|
|||||||
hasResources = false;
|
hasResources = false;
|
||||||
else {
|
else {
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.stoneIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580000));
|
||||||
|
|
||||||
if (resourceValue < 1500)
|
if (resourceValue < 1500)
|
||||||
hasResources = false;
|
hasResources = false;
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.lumberIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580004));
|
||||||
|
|
||||||
if (resourceValue < 1500)
|
if (resourceValue < 1500)
|
||||||
hasResources = false;
|
hasResources = false;
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.galvorIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580017));
|
||||||
|
|
||||||
if (resourceValue < 5)
|
if (resourceValue < 5)
|
||||||
hasResources = false;
|
hasResources = false;
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.wormwoodIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580018));
|
||||||
|
|
||||||
if (resourceValue < 5)
|
if (resourceValue < 5)
|
||||||
hasResources = false;
|
hasResources = false;
|
||||||
@@ -242,11 +247,11 @@ public enum MaintenanceManager {
|
|||||||
|
|
||||||
if (overDraft > 0) {
|
if (overDraft > 0) {
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.goldIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(7));
|
||||||
|
|
||||||
if (DbManager.WarehouseQueries.updateGold(warehouse, resourceValue - overDraft) == true) {
|
if (DbManager.WarehouseQueries.updateGold(warehouse, resourceValue - overDraft) == true) {
|
||||||
warehouse.getResources().put(Warehouse.goldIB, resourceValue - overDraft);
|
warehouse.resources.put(ItemBase.getItemBase(7), resourceValue - overDraft);
|
||||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GOLD, overDraft);
|
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GOLD, overDraft);
|
||||||
} else {
|
} else {
|
||||||
Logger.error("gold update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
Logger.error("gold update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||||
return true;
|
return true;
|
||||||
@@ -262,11 +267,11 @@ public enum MaintenanceManager {
|
|||||||
|
|
||||||
// Withdraw Stone
|
// Withdraw Stone
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.stoneIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580000));
|
||||||
|
|
||||||
if (DbManager.WarehouseQueries.updateStone(warehouse, resourceValue - 1500) == true) {
|
if (DbManager.WarehouseQueries.updateStone(warehouse, resourceValue - 1500) == true) {
|
||||||
warehouse.getResources().put(Warehouse.stoneIB, resourceValue - 1500);
|
warehouse.resources.put(ItemBase.getItemBase(1580000), resourceValue - 1500);
|
||||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.STONE, 1500);
|
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.STONE, 1500);
|
||||||
} else {
|
} else {
|
||||||
Logger.error("stone update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
Logger.error("stone update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||||
return true;
|
return true;
|
||||||
@@ -274,11 +279,11 @@ public enum MaintenanceManager {
|
|||||||
|
|
||||||
// Withdraw Lumber
|
// Withdraw Lumber
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.lumberIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580004));
|
||||||
|
|
||||||
if (DbManager.WarehouseQueries.updateLumber(warehouse, resourceValue - 1500) == true) {
|
if (DbManager.WarehouseQueries.updateLumber(warehouse, resourceValue - 1500) == true) {
|
||||||
warehouse.getResources().put(Warehouse.lumberIB, resourceValue - 1500);
|
warehouse.resources.put(ItemBase.getItemBase(1580004), resourceValue - 1500);
|
||||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.LUMBER, 1500);
|
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.LUMBER, 1500);
|
||||||
} else {
|
} else {
|
||||||
Logger.error("lumber update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
Logger.error("lumber update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||||
return true;
|
return true;
|
||||||
@@ -286,21 +291,21 @@ public enum MaintenanceManager {
|
|||||||
|
|
||||||
// Withdraw Galvor
|
// Withdraw Galvor
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.galvorIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580017));
|
||||||
|
|
||||||
if (DbManager.WarehouseQueries.updateGalvor(warehouse, resourceValue - 5) == true) {
|
if (DbManager.WarehouseQueries.updateGalvor(warehouse, resourceValue - 5) == true) {
|
||||||
warehouse.getResources().put(Warehouse.galvorIB, resourceValue - 5);
|
warehouse.resources.put(ItemBase.getItemBase(1580017), resourceValue - 5);
|
||||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GALVOR, 5);
|
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GALVOR, 5);
|
||||||
} else {
|
} else {
|
||||||
Logger.error("galvor update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
Logger.error("galvor update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.wormwoodIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580018));
|
||||||
|
|
||||||
if (DbManager.WarehouseQueries.updateWormwood(warehouse, resourceValue - 5) == true) {
|
if (DbManager.WarehouseQueries.updateWormwood(warehouse, resourceValue - 5) == true) {
|
||||||
warehouse.getResources().put(Warehouse.wormwoodIB, resourceValue - 5);
|
warehouse.resources.put(ItemBase.getItemBase(1580018), resourceValue - 5);
|
||||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.WORMWOOD, 5);
|
Warehouse.AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.WORMWOOD, 5);
|
||||||
} else {
|
} else {
|
||||||
Logger.error("wyrmwood update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
Logger.error("wyrmwood update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,137 +0,0 @@
|
|||||||
package engine.gameManager;
|
|
||||||
|
|
||||||
import engine.Enum;
|
|
||||||
import engine.math.Vector3fImmutable;
|
|
||||||
import engine.mobileAI.MobAI;
|
|
||||||
import engine.net.client.msg.MoveToPointMsg;
|
|
||||||
import engine.objects.*;
|
|
||||||
import java.awt.geom.Path2D;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
|
|
||||||
public class NavigationManager {
|
|
||||||
|
|
||||||
private static final int cellGap = 1;
|
|
||||||
private static final int stepHeight = 2;
|
|
||||||
|
|
||||||
public static void pathfind(AbstractCharacter character, Vector3fImmutable goal) {
|
|
||||||
if(!pathBlocked(character.loc,goal)){
|
|
||||||
character.destination = goal;
|
|
||||||
MobAI.directMove((Mob)character,character.combatTarget != null);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
ArrayList<Vector3fImmutable> path = getPath(character.loc, goal);//getOptimizedPath(getPath(character.loc, goal), getPath(goal, character.loc));
|
|
||||||
if (path.isEmpty()) {
|
|
||||||
MobAI.directMove((Mob)character,character.combatTarget != null);
|
|
||||||
return; //no points to walk to
|
|
||||||
}
|
|
||||||
//character.navPath = path;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
//something failed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<Vector3fImmutable> getOptimizedPath(ArrayList<Vector3fImmutable> startToGoal, ArrayList<Vector3fImmutable> goalToStart) {
|
|
||||||
ArrayList<Vector3fImmutable> optimalPath = new ArrayList<>();
|
|
||||||
optimalPath.add(startToGoal.get(0));
|
|
||||||
for (Vector3fImmutable point : startToGoal) {
|
|
||||||
if (goalToStart.contains(point) && !optimalPath.contains(point)) {
|
|
||||||
optimalPath.add(point);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//optimize the path to its smallest possible amount of points
|
|
||||||
|
|
||||||
|
|
||||||
return optimalPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ArrayList<Vector3fImmutable> getPath(Vector3fImmutable start, Vector3fImmutable goal) {
|
|
||||||
ArrayList<Vector3fImmutable> path = new ArrayList<>();
|
|
||||||
path.add(start);
|
|
||||||
Vector3fImmutable current = start;
|
|
||||||
boolean obstructed = false;
|
|
||||||
int count = 0;
|
|
||||||
while (current.distanceSquared(goal) > 9 && count < 250) {
|
|
||||||
//gather the 8 cells around the player
|
|
||||||
ArrayList<Vector3fImmutable> surroundingCells = new ArrayList<>();
|
|
||||||
surroundingCells.add(current.add(new Vector3fImmutable(cellGap, 0, 0)));
|
|
||||||
surroundingCells.add(current.add(new Vector3fImmutable(cellGap, 0, cellGap)));
|
|
||||||
surroundingCells.add(current.add(new Vector3fImmutable(0, 0, cellGap)));
|
|
||||||
surroundingCells.add(current.add(new Vector3fImmutable(-cellGap, 0, 0)));
|
|
||||||
surroundingCells.add(current.add(new Vector3fImmutable(-cellGap, 0, -cellGap)));
|
|
||||||
surroundingCells.add(current.add(new Vector3fImmutable(0, 0, -cellGap)));
|
|
||||||
surroundingCells.add(current.add(new Vector3fImmutable(-cellGap, 0, cellGap)));
|
|
||||||
surroundingCells.add(current.add(new Vector3fImmutable(cellGap, 0, -cellGap)));
|
|
||||||
Vector3fImmutable cheapest = new Vector3fImmutable(Vector3fImmutable.ZERO);
|
|
||||||
for (Vector3fImmutable point : surroundingCells) {
|
|
||||||
count++;
|
|
||||||
|
|
||||||
if (path.contains(point))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (pointIsBlocked(point)) {
|
|
||||||
obstructed = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getCost(cheapest, current, goal) > getCost(point, current, goal))
|
|
||||||
cheapest = point;
|
|
||||||
}
|
|
||||||
current = cheapest;
|
|
||||||
path.add(cheapest);
|
|
||||||
}
|
|
||||||
if (obstructed) {
|
|
||||||
return path;
|
|
||||||
} else {
|
|
||||||
ArrayList<Vector3fImmutable> goalPath = new ArrayList<>();
|
|
||||||
goalPath.add(start);
|
|
||||||
goalPath.add(start.moveTowards(goal,32));
|
|
||||||
goalPath.add(goal);
|
|
||||||
return goalPath; //if the path isn't obstructed we can walk directly from start to the goal
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getCost(Vector3fImmutable point, Vector3fImmutable start, Vector3fImmutable goal) {
|
|
||||||
float gCost = start.distanceSquared(point);
|
|
||||||
float hCost = goal.distanceSquared(point);
|
|
||||||
return gCost + hCost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean pathBlocked(Vector3fImmutable start, Vector3fImmutable end){
|
|
||||||
Zone zone = ZoneManager.findSmallestZone(start);
|
|
||||||
if(zone != null) {
|
|
||||||
for (Path2D.Float obstacle : zone.navObstacles)
|
|
||||||
if(obstacle.intersects(start.x,start.z,end.x,end.z))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public static boolean pointIsBlocked(Vector3fImmutable point) {
|
|
||||||
Zone zone = ZoneManager.findSmallestZone(point);
|
|
||||||
if(zone != null){
|
|
||||||
for(Path2D.Float obstacle : zone.navObstacles)
|
|
||||||
if (obstacle.contains(point.x,point.z)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Building building = BuildingManager.getBuildingAtLocation(point);
|
|
||||||
//if(building != null) {
|
|
||||||
//for (Path2D.Float mesh : building.meshes) {
|
|
||||||
//if (mesh.contains(point.x,point.z)) {
|
|
||||||
//return true;
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
//for (Regions region : building.getBounds().getRegions()) {
|
|
||||||
//if (region.isPointInPolygon(point))
|
|
||||||
//if (Math.abs(region.lerpY(point) - point.y) > stepHeight) // get the height distance between current height and target location height
|
|
||||||
//return true;
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,6 @@ import engine.math.Bounds;
|
|||||||
import engine.math.Vector2f;
|
import engine.math.Vector2f;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.mobileAI.utilities.PathingUtilities;
|
|
||||||
import engine.objects.Building;
|
import engine.objects.Building;
|
||||||
import engine.objects.City;
|
import engine.objects.City;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
@@ -22,7 +21,6 @@ import engine.objects.ZoneTemplate;
|
|||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.awt.geom.Path2D;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class Bounds {
|
|||||||
private boolean flipExtents;
|
private boolean flipExtents;
|
||||||
|
|
||||||
private ArrayList<Regions> regions = new ArrayList<>();
|
private ArrayList<Regions> regions = new ArrayList<>();
|
||||||
public ArrayList<Colliders> colliders = new ArrayList<>();
|
private ArrayList<Colliders> colliders = new ArrayList<>();
|
||||||
|
|
||||||
// Default constructor
|
// Default constructor
|
||||||
|
|
||||||
|
|||||||
+23
-122
@@ -11,16 +11,14 @@ package engine.mobileAI;
|
|||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.Enum.DispatchChannel;
|
import engine.Enum.DispatchChannel;
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.exception.MsgSendException;
|
|
||||||
import engine.gameManager.*;
|
import engine.gameManager.*;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.mobileAI.Threads.MobAIThread;
|
import engine.mobileAI.Threads.MobAIThread;
|
||||||
import engine.mobileAI.Threads.Respawner;
|
import engine.mobileAI.Threads.Respawner;
|
||||||
import engine.mobileAI.utilities.CombatUtilities;
|
import engine.mobileAI.utilities.CombatUtilities;
|
||||||
import engine.mobileAI.utilities.PathingUtilities;
|
import engine.mobileAI.utilities.MovementUtilities;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
import engine.net.client.msg.MoveToPointMsg;
|
|
||||||
import engine.net.client.msg.PerformActionMsg;
|
import engine.net.client.msg.PerformActionMsg;
|
||||||
import engine.net.client.msg.PowerProjectileMsg;
|
import engine.net.client.msg.PowerProjectileMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
@@ -105,7 +103,7 @@ public class MobAI {
|
|||||||
if (mob.behaviourType.callsForHelp)
|
if (mob.behaviourType.callsForHelp)
|
||||||
MobCallForHelp(mob);
|
MobCallForHelp(mob);
|
||||||
|
|
||||||
if (inRangeDropAggro(mob, target)) {
|
if (!MovementUtilities.inRangeDropAggro(mob, target)) {
|
||||||
mob.setCombatTarget(null);
|
mob.setCombatTarget(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -305,7 +303,7 @@ public class MobAI {
|
|||||||
MobAI.Patrol(minion);
|
MobAI.Patrol(minion);
|
||||||
}
|
}
|
||||||
|
|
||||||
aiMove(mob, true,0);
|
MovementUtilities.aiMove(mob, mob.destination, true);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage());
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage());
|
||||||
@@ -586,7 +584,7 @@ public class MobAI {
|
|||||||
if(mob.isPlayerGuard() || mob.isSiege()) {
|
if(mob.isPlayerGuard() || mob.isSiege()) {
|
||||||
bypassLoadedPlayerCheck = true;
|
bypassLoadedPlayerCheck = true;
|
||||||
if(mob.combatTarget != null && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
if(mob.combatTarget != null && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
||||||
if(mob.combatTarget.loc.distanceSquared(mob.loc) > 62500)
|
if(mob.combatTarget.loc.distanceSquared(mob.loc) > 10000)
|
||||||
mob.setCombatTarget(null);
|
mob.setCombatTarget(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,7 +689,7 @@ public class MobAI {
|
|||||||
if (aiAgent.enemy.size() > 0 && aiAgent.enemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == false)
|
if (aiAgent.enemy.size() > 0 && aiAgent.enemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (inRangeToAggro(aiAgent, loadedPlayer)) {
|
if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) {
|
||||||
aiAgent.setCombatTarget(loadedPlayer);
|
aiAgent.setCombatTarget(loadedPlayer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -724,7 +722,7 @@ public class MobAI {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!canMove(mob))
|
if (!MovementUtilities.canMove(mob))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mob.updateLocation();
|
mob.updateLocation();
|
||||||
@@ -751,7 +749,7 @@ public class MobAI {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
mob.destination = mob.guardCaptain.getLoc();
|
mob.destination = mob.guardCaptain.getLoc();
|
||||||
aiMove(mob, false,5);
|
MovementUtilities.moveToLocation(mob, mob.destination, 5, false);
|
||||||
} else
|
} else
|
||||||
chaseTarget(mob);
|
chaseTarget(mob);
|
||||||
break;
|
break;
|
||||||
@@ -836,7 +834,7 @@ public class MobAI {
|
|||||||
if (mob.getCombatTarget() == null)
|
if (mob.getCombatTarget() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) &&
|
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false &&
|
||||||
mob.agentType.equals(Enum.AIAgentType.PET) == false) {
|
mob.agentType.equals(Enum.AIAgentType.PET) == false) {
|
||||||
|
|
||||||
mob.setCombatTarget(null);
|
mob.setCombatTarget(null);
|
||||||
@@ -879,7 +877,7 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (inRangeOfBindLocation(mob) == false) {
|
} else if (MovementUtilities.inRangeOfBindLocation(mob) == false) {
|
||||||
|
|
||||||
PowersBase recall = PowersManager.getPowerByToken(-1994153779);
|
PowersBase recall = PowersManager.getPowerByToken(-1994153779);
|
||||||
PowersManager.useMobPower(mob, mob, recall, 40);
|
PowersManager.useMobPower(mob, mob, recall, 40);
|
||||||
@@ -907,7 +905,7 @@ public class MobAI {
|
|||||||
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
|
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
|
||||||
if (mob.getRange() > 15) {
|
if (mob.getRange() > 15) {
|
||||||
mob.destination = mob.getCombatTarget().getLoc();
|
mob.destination = mob.getCombatTarget().getLoc();
|
||||||
aiMove(mob, false,0);
|
MovementUtilities.moveToLocation(mob, mob.destination, 0, false);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//check if building
|
//check if building
|
||||||
@@ -915,12 +913,12 @@ public class MobAI {
|
|||||||
switch (mob.getCombatTarget().getObjectType()) {
|
switch (mob.getCombatTarget().getObjectType()) {
|
||||||
case PlayerCharacter:
|
case PlayerCharacter:
|
||||||
case Mob:
|
case Mob:
|
||||||
mob.destination = mob.combatTarget.loc;//GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget());
|
mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget());
|
||||||
aiMove(mob, false,mob.getRange() + 1);
|
MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange() + 1, false);
|
||||||
break;
|
break;
|
||||||
case Building:
|
case Building:
|
||||||
mob.destination = mob.getCombatTarget().getLoc();
|
mob.destination = mob.getCombatTarget().getLoc();
|
||||||
aiMove(mob, false,0);
|
MovementUtilities.moveToLocation(mob, mob.getCombatTarget().getLoc(), 0, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -941,16 +939,16 @@ public class MobAI {
|
|||||||
|
|
||||||
//dont scan self.
|
//dont scan self.
|
||||||
|
|
||||||
if (mob.equals(awoMob) || (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)) == true)
|
if (mob.equals(awoMob))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Mob aggroMob = (Mob) awoMob;
|
Mob aggroMob = (Mob) awoMob;
|
||||||
|
|
||||||
//don't attack other guards
|
//don't attack other guards
|
||||||
|
if (aggroMob.isGuard() == true)
|
||||||
if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
//don't attack pets
|
||||||
if (aggroMob.agentType.equals(Enum.AIAgentType.PET))
|
if (aggroMob.agentType.equals(Enum.AIAgentType.PET))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1002,7 +1000,7 @@ public class MobAI {
|
|||||||
if (ZoneManager.seaFloor.zoneMobSet.contains(mob))
|
if (ZoneManager.seaFloor.zoneMobSet.contains(mob))
|
||||||
mob.killCharacter("no owner");
|
mob.killCharacter("no owner");
|
||||||
|
|
||||||
if (canMove(mob) && mob.behaviourType.canRoam)
|
if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam)
|
||||||
CheckMobMovement(mob);
|
CheckMobMovement(mob);
|
||||||
|
|
||||||
CheckForAttack(mob);
|
CheckForAttack(mob);
|
||||||
@@ -1132,7 +1130,7 @@ public class MobAI {
|
|||||||
if (GuardCanAggro(mob, loadedPlayer) == false)
|
if (GuardCanAggro(mob, loadedPlayer) == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (inRangeToAggro(mob, loadedPlayer) && mob.getCombatTarget() == null) {
|
if (MovementUtilities.inRangeToAggro(mob, loadedPlayer) && mob.getCombatTarget() == null) {
|
||||||
mob.setCombatTarget(loadedPlayer);
|
mob.setCombatTarget(loadedPlayer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1242,9 +1240,9 @@ public class MobAI {
|
|||||||
float xPoint = ThreadLocalRandom.current().nextInt(400) - 200;
|
float xPoint = ThreadLocalRandom.current().nextInt(400) - 200;
|
||||||
float zPoint = ThreadLocalRandom.current().nextInt(400) - 200;
|
float zPoint = ThreadLocalRandom.current().nextInt(400) - 200;
|
||||||
Vector3fImmutable TreePos = mob.getGuild().getOwnedCity().getLoc();
|
Vector3fImmutable TreePos = mob.getGuild().getOwnedCity().getLoc();
|
||||||
mob.destination = new Vector3fImmutable(TreePos.x + xPoint, TreePos.y, TreePos.z + zPoint);
|
mob.destination = new Vector3fImmutable(TreePos.x + xPoint, TreePos.y, TreePos.z + zPoint);
|
||||||
|
|
||||||
aiMove(mob, true,0);
|
MovementUtilities.aiMove(mob, mob.destination, true);
|
||||||
|
|
||||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)) {
|
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)) {
|
||||||
for (Integer minionUUID : mob.minions) {
|
for (Integer minionUUID : mob.minions) {
|
||||||
@@ -1254,12 +1252,11 @@ public class MobAI {
|
|||||||
//make sure mob is out of combat stance
|
//make sure mob is out of combat stance
|
||||||
|
|
||||||
if (minion.despawned == false) {
|
if (minion.despawned == false) {
|
||||||
if (canMove(minion)) {
|
if (MovementUtilities.canMove(minion)) {
|
||||||
Vector3f minionOffset = Formation.getOffset(2, mob.minions.indexOf(minionUUID) + 3);
|
Vector3f minionOffset = Formation.getOffset(2, mob.minions.indexOf(minionUUID) + 3);
|
||||||
minion.updateLocation();
|
minion.updateLocation();
|
||||||
Vector3fImmutable formationPatrolPoint = new Vector3fImmutable(mob.destination.x + minionOffset.x, mob.destination.y, mob.destination.z + minionOffset.z);
|
Vector3fImmutable formationPatrolPoint = new Vector3fImmutable(mob.destination.x + minionOffset.x, mob.destination.y, mob.destination.z + minionOffset.z);
|
||||||
minion.destination = formationPatrolPoint;
|
MovementUtilities.aiMove(minion, formationPatrolPoint, true);
|
||||||
aiMove(minion, true,0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1287,7 +1284,7 @@ public class MobAI {
|
|||||||
if (potentialTarget.equals(mob.getCombatTarget()))
|
if (potentialTarget.equals(mob.getCombatTarget()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && inRangeToAggro(mob, potentialTarget)) {
|
if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
|
||||||
CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue();
|
CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue();
|
||||||
mostHatedTarget = potentialTarget;
|
mostHatedTarget = potentialTarget;
|
||||||
}
|
}
|
||||||
@@ -1299,100 +1296,4 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean inRangeDropAggro(Mob agent, AbstractCharacter target) {
|
|
||||||
float rangeSquared = MobAIThread.AI_BASE_AGGRO_RANGE * MobAIThread.AI_BASE_AGGRO_RANGE;
|
|
||||||
if(agent.isPlayerGuard())
|
|
||||||
rangeSquared = 62500;
|
|
||||||
if(agent.isSiege())
|
|
||||||
rangeSquared = agent.getRange() * agent.getRange();
|
|
||||||
|
|
||||||
return agent.loc.distanceSquared(target.loc) > rangeSquared;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean inRangeToAggro(Mob agent, PlayerCharacter target) {
|
|
||||||
return MobAIThread.AI_BASE_AGGRO_RANGE * MobAIThread.AI_BASE_AGGRO_RANGE > agent.loc.distanceSquared(target.loc) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean inRangeOfBindLocation(Mob agent) {
|
|
||||||
if(agent.isPlayerGuard() && agent.guardedCity.isLocationOnCityZone(agent.loc))
|
|
||||||
return true;
|
|
||||||
float bindRangeSquared = (agent.parentZone.getBounds().getHalfExtents().x * agent.parentZone.getBounds().getHalfExtents().x) + (MobAIThread.AI_DROP_AGGRO_RANGE * MobAIThread.AI_DROP_AGGRO_RANGE);
|
|
||||||
return agent.loc.distanceSquared(agent.bindLoc) < bindRangeSquared;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canMove(Mob agent) {
|
|
||||||
if (!agent.behaviourType.canRoam)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return (agent.isAlive() && !agent.getBonuses().getBool(Enum.ModType.Stunned, Enum.SourceType.None) && !agent.getBonuses().getBool(Enum.ModType.CannotMove, Enum.SourceType.None));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector3fImmutable GetDestinationToCharacter(Mob aiAgent, AbstractCharacter character) {
|
|
||||||
|
|
||||||
if (!character.isMoving())
|
|
||||||
return character.getLoc();
|
|
||||||
|
|
||||||
|
|
||||||
float agentDistanceEndLoc = aiAgent.getLoc().distanceSquared2D(character.getEndLoc());
|
|
||||||
float characterDistanceEndLoc = character.getLoc().distanceSquared2D(character.getEndLoc());
|
|
||||||
|
|
||||||
if (agentDistanceEndLoc > characterDistanceEndLoc)
|
|
||||||
return character.getEndLoc();
|
|
||||||
|
|
||||||
return character.getLoc();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void aiMove(Mob mob, boolean isWalking, float offset) {
|
|
||||||
|
|
||||||
if(mob.isMoving()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(!mob.isPathing){
|
|
||||||
ArrayList<PathingUtilities.Node> path = PathingUtilities.getPath(mob, mob.destination);
|
|
||||||
if(path != null && path.size() > 0)
|
|
||||||
PathingUtilities.followPath(mob,path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void directMove(AbstractCharacter mob,boolean isWalking){
|
|
||||||
//update our walk/run state.
|
|
||||||
if (isWalking && !mob.isWalk()) {
|
|
||||||
mob.setWalkMode(true);
|
|
||||||
MovementManager.sendRWSSMsg(mob);
|
|
||||||
} else if (!isWalking && mob.isWalk()) {
|
|
||||||
mob.setWalkMode(false);
|
|
||||||
MovementManager.sendRWSSMsg(mob);
|
|
||||||
}
|
|
||||||
mob.endLoc = mob.destination;
|
|
||||||
|
|
||||||
MoveToPointMsg msg = new MoveToPointMsg();
|
|
||||||
|
|
||||||
msg.setSourceType(Enum.GameObjectType.Mob.ordinal());
|
|
||||||
msg.setSourceID(mob.getObjectUUID());
|
|
||||||
msg.setStartCoord(mob.loc);
|
|
||||||
msg.setEndCoord(mob.destination);
|
|
||||||
Regions region = Regions.getRegionAtLocation(mob.destination);
|
|
||||||
if(region != null){
|
|
||||||
msg.setInBuildingFloor(region.room);
|
|
||||||
msg.setInBuilding(region.level);
|
|
||||||
msg.setStartLocType(0);
|
|
||||||
msg.setInBuildingUUID(region.parentBuildingID);
|
|
||||||
} else{
|
|
||||||
msg.setInBuildingFloor(-1);
|
|
||||||
msg.setInBuilding(-1);
|
|
||||||
msg.setStartLocType(0);
|
|
||||||
msg.setInBuildingUUID(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
MovementManager.movement(msg, mob);
|
|
||||||
} catch (MsgSendException e) {
|
|
||||||
// TODO Figure out how we want to handle the msg send exception
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,295 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
|
||||||
|
package engine.mobileAI.utilities;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.Enum.GameObjectType;
|
||||||
|
import engine.Enum.ModType;
|
||||||
|
import engine.Enum.SourceType;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.MovementManager;
|
||||||
|
import engine.math.Vector3fImmutable;
|
||||||
|
import engine.mobileAI.Threads.MobAIThread;
|
||||||
|
import engine.net.client.msg.MoveToPointMsg;
|
||||||
|
import engine.objects.*;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
import static engine.math.FastMath.sqr;
|
||||||
|
import static engine.math.FastMath.sqrt;
|
||||||
|
|
||||||
|
public class MovementUtilities {
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean inRangeOfBindLocation(Mob agent) {
|
||||||
|
|
||||||
|
|
||||||
|
if (agent.isPlayerGuard()) {
|
||||||
|
|
||||||
|
Mob guardCaptain = null;
|
||||||
|
if (agent.getContract() != null)
|
||||||
|
guardCaptain = agent;
|
||||||
|
else
|
||||||
|
guardCaptain = (Mob) agent.guardCaptain;
|
||||||
|
|
||||||
|
if (guardCaptain != null) {
|
||||||
|
Building barracks = guardCaptain.building;
|
||||||
|
|
||||||
|
if (barracks != null) {
|
||||||
|
City city = barracks.getCity();
|
||||||
|
|
||||||
|
if (city != null) {
|
||||||
|
Building tol = city.getTOL();
|
||||||
|
|
||||||
|
//Guards recall distance = 814.
|
||||||
|
if (tol != null) {
|
||||||
|
return !(agent.getLoc().distanceSquared2D(tol.getLoc()) > sqr(Enum.CityBoundsType.ZONE.halfExtents));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3fImmutable sl = new Vector3fImmutable(agent.getLoc().getX(), 0, agent.getLoc().getZ());
|
||||||
|
Vector3fImmutable tl = new Vector3fImmutable(agent.getTrueBindLoc().x, 0, agent.getTrueBindLoc().z);
|
||||||
|
|
||||||
|
float distanceSquaredToTarget = sl.distanceSquared2D(tl); //distance to center of target
|
||||||
|
float zoneRange = 250;
|
||||||
|
|
||||||
|
if (agent.getParentZone() != null) {
|
||||||
|
if (agent.getParentZone().bounds != null)
|
||||||
|
zoneRange = agent.getParentZone().bounds.getHalfExtents().x * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zoneRange > 300)
|
||||||
|
zoneRange = 300;
|
||||||
|
|
||||||
|
if (agent.getSpawnRadius() > zoneRange)
|
||||||
|
zoneRange = agent.getSpawnRadius();
|
||||||
|
|
||||||
|
|
||||||
|
return distanceSquaredToTarget < sqr(MobAIThread.AI_DROP_AGGRO_RANGE + zoneRange);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean inRangeToAggro(Mob agent, PlayerCharacter target) {
|
||||||
|
|
||||||
|
Vector3fImmutable sl = agent.getLoc();
|
||||||
|
Vector3fImmutable tl = target.getLoc();
|
||||||
|
|
||||||
|
float distanceSquaredToTarget = sl.distanceSquared2D(tl) - sqr(agent.calcHitBox() + target.calcHitBox()); //distance to center of target
|
||||||
|
float range = MobAIThread.AI_BASE_AGGRO_RANGE;
|
||||||
|
|
||||||
|
if (agent.isPlayerGuard())
|
||||||
|
range = 150;
|
||||||
|
|
||||||
|
return distanceSquaredToTarget < sqr(range);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean inRangeDropAggro(Mob agent, AbstractCharacter target) {
|
||||||
|
|
||||||
|
Vector3fImmutable sl = agent.getLoc();
|
||||||
|
Vector3fImmutable tl = target.getLoc();
|
||||||
|
|
||||||
|
float distanceSquaredToTarget = sl.distanceSquared2D(tl) - sqr(agent.calcHitBox() + target.calcHitBox()); //distance to center of target
|
||||||
|
|
||||||
|
float range = agent.getRange() + 150;
|
||||||
|
|
||||||
|
if (range > 200)
|
||||||
|
range = 200;
|
||||||
|
|
||||||
|
|
||||||
|
return distanceSquaredToTarget < sqr(range);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3fImmutable GetMoveLocation(Mob aiAgent, AbstractCharacter aggroTarget) {
|
||||||
|
|
||||||
|
// Player isnt moving and neither is mob. Just return
|
||||||
|
// the mobile's current location. Ain't goin nowhere!
|
||||||
|
// *** Refactor: Check to ensure methods calling us
|
||||||
|
// all don't sent move messages when not moving.
|
||||||
|
|
||||||
|
if ((aggroTarget.isMoving() == false))
|
||||||
|
return aggroTarget.getLoc();
|
||||||
|
|
||||||
|
if (aggroTarget.getEndLoc().x != 0) {
|
||||||
|
|
||||||
|
float aggroTargetDistanceSquared = aggroTarget.getLoc().distanceSquared2D(aggroTarget.getEndLoc());
|
||||||
|
float aiAgentDistanceSquared = aiAgent.getLoc().distanceSquared2D(aggroTarget.getEndLoc());
|
||||||
|
|
||||||
|
if (aiAgentDistanceSquared >= aggroTargetDistanceSquared)
|
||||||
|
return aggroTarget.getEndLoc();
|
||||||
|
else {
|
||||||
|
float distanceToMove = sqrt(aggroTargetDistanceSquared + aiAgentDistanceSquared) * .5f;
|
||||||
|
|
||||||
|
return aggroTarget.getFaceDir().scaleAdd(distanceToMove, aggroTarget.getLoc());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// One of us is moving so let's calculate our destination loc for this
|
||||||
|
// simulation frame. We will simply project our position onto the
|
||||||
|
// character's movement vector and return the closest point.
|
||||||
|
|
||||||
|
return aiAgent.getLoc().ClosestPointOnLine(aggroTarget.getLoc(), aggroTarget.getEndLoc());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void moveToLocation(Mob agent, Vector3fImmutable newLocation, float offset, boolean isWalking) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
//don't move farther than 30 units from player.
|
||||||
|
if (offset > 30)
|
||||||
|
offset = 30;
|
||||||
|
Vector3fImmutable newLoc = Vector3fImmutable.getRandomPointInCircle(newLocation, offset);
|
||||||
|
|
||||||
|
|
||||||
|
agent.setFaceDir(newLoc.subtract2D(agent.getLoc()).normalize());
|
||||||
|
|
||||||
|
aiMove(agent, newLoc, isWalking);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.error(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean canMove(Mob agent) {
|
||||||
|
if (agent.getMobBase() != null && Enum.MobFlagType.SENTINEL.elementOf(agent.getMobBase().getFlags()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.None));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3fImmutable randomPatrolLocation(Mob agent, Vector3fImmutable center, float radius) {
|
||||||
|
|
||||||
|
//Determing where I want to move.
|
||||||
|
return new Vector3fImmutable((center.x - radius) + ((ThreadLocalRandom.current().nextFloat() + .1f * 2) * radius),
|
||||||
|
center.y,
|
||||||
|
(center.z - radius) + ((ThreadLocalRandom.current().nextFloat() + .1f * 2) * radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Long estimateMovementTime(Mob agent) {
|
||||||
|
if (agent.getEndLoc().x == 0 && agent.getEndLoc().y == 0)
|
||||||
|
return 0L;
|
||||||
|
|
||||||
|
return (long) ((agent.getLoc().distance2D(agent.getEndLoc()) * 1000) / agent.getSpeed());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void aiMove(Mob agent, Vector3fImmutable vect, boolean isWalking) {
|
||||||
|
|
||||||
|
//update our walk/run state.
|
||||||
|
if (isWalking && !agent.isWalk()) {
|
||||||
|
agent.setWalkMode(true);
|
||||||
|
MovementManager.sendRWSSMsg(agent);
|
||||||
|
} else if (!isWalking && agent.isWalk()) {
|
||||||
|
agent.setWalkMode(false);
|
||||||
|
MovementManager.sendRWSSMsg(agent);
|
||||||
|
}
|
||||||
|
|
||||||
|
MoveToPointMsg msg = new MoveToPointMsg();
|
||||||
|
|
||||||
|
|
||||||
|
// Regions currentRegion = Mob.InsideBuildingRegion(agent);
|
||||||
|
//
|
||||||
|
// if (currentRegion != null){
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if (currentRegion.isGroundLevel()){
|
||||||
|
// agent.setInBuilding(0);
|
||||||
|
// agent.setInFloorID(-1);
|
||||||
|
// }else{
|
||||||
|
// agent.setInBuilding(currentRegion.getLevel());
|
||||||
|
// agent.setInFloorID(currentRegion.getRoom());
|
||||||
|
// }
|
||||||
|
// }else{
|
||||||
|
// agent.setInBuilding(-1);
|
||||||
|
// agent.setInFloorID(-1);
|
||||||
|
// agent.setInBuildingID(0);
|
||||||
|
// }
|
||||||
|
// agent.setLastRegion(currentRegion);
|
||||||
|
|
||||||
|
|
||||||
|
Vector3fImmutable startLoc = null;
|
||||||
|
Vector3fImmutable endLoc = null;
|
||||||
|
|
||||||
|
// if (agent.getLastRegion() != null){
|
||||||
|
// Building inBuilding = Building.getBuildingFromCache(agent.getInBuildingID());
|
||||||
|
// if (inBuilding != null){
|
||||||
|
// startLoc = ZoneManager.convertWorldToLocal(inBuilding, agent.getLoc());
|
||||||
|
// endLoc = ZoneManager.convertWorldToLocal(inBuilding, vect);
|
||||||
|
// }
|
||||||
|
// }else{
|
||||||
|
// agent.setBuildingID(0);
|
||||||
|
// agent.setInBuildingID(0);
|
||||||
|
// startLoc = agent.getLoc();
|
||||||
|
// endLoc = vect;
|
||||||
|
// }
|
||||||
|
|
||||||
|
startLoc = agent.getLoc();
|
||||||
|
endLoc = vect;
|
||||||
|
|
||||||
|
msg.setSourceType(GameObjectType.Mob.ordinal());
|
||||||
|
msg.setSourceID(agent.getObjectUUID());
|
||||||
|
msg.setStartCoord(startLoc);
|
||||||
|
msg.setEndCoord(endLoc);
|
||||||
|
msg.setInBuildingFloor(-1);
|
||||||
|
msg.setInBuilding(-1);
|
||||||
|
msg.setStartLocType(0);
|
||||||
|
msg.setInBuildingUUID(0);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
MovementManager.movement(msg, agent);
|
||||||
|
} catch (MsgSendException e) {
|
||||||
|
// TODO Figure out how we want to handle the msg send exception
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3fImmutable GetDestinationToCharacter(Mob aiAgent, AbstractCharacter character) {
|
||||||
|
|
||||||
|
if (!character.isMoving())
|
||||||
|
return character.getLoc();
|
||||||
|
|
||||||
|
|
||||||
|
float agentDistanceEndLoc = aiAgent.getLoc().distanceSquared2D(character.getEndLoc());
|
||||||
|
float characterDistanceEndLoc = character.getLoc().distanceSquared2D(character.getEndLoc());
|
||||||
|
|
||||||
|
if (agentDistanceEndLoc > characterDistanceEndLoc)
|
||||||
|
return character.getEndLoc();
|
||||||
|
|
||||||
|
return character.getLoc();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean updateMovementToCharacter(Mob aiAgent, AbstractCharacter aggroTarget) {
|
||||||
|
|
||||||
|
if (aiAgent.destination.equals(Vector3fImmutable.ZERO))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!aiAgent.isMoving())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
if (aggroTarget.isMoving()) {
|
||||||
|
return !aiAgent.destination.equals(aggroTarget.getEndLoc()) && !aiAgent.destination.equals(aggroTarget.getLoc());
|
||||||
|
} else {
|
||||||
|
if (aiAgent.destination.equals(aggroTarget.getLoc()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,160 +0,0 @@
|
|||||||
package engine.mobileAI.utilities;
|
|
||||||
import engine.Enum;
|
|
||||||
import engine.exception.MsgSendException;
|
|
||||||
import engine.gameManager.BuildingManager;
|
|
||||||
import engine.gameManager.MovementManager;
|
|
||||||
import engine.gameManager.ZoneManager;
|
|
||||||
import engine.math.Vector2f;
|
|
||||||
import engine.math.Vector3fImmutable;
|
|
||||||
import engine.mobileAI.MobAI;
|
|
||||||
import engine.net.client.msg.MoveToPointMsg;
|
|
||||||
import engine.objects.AbstractCharacter;
|
|
||||||
import engine.objects.Building;
|
|
||||||
import engine.objects.Regions;
|
|
||||||
import engine.objects.Zone;
|
|
||||||
import org.pmw.tinylog.Logger;
|
|
||||||
|
|
||||||
import java.awt.geom.Path2D;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class PathingUtilities {
|
|
||||||
public static class Node {
|
|
||||||
public Vector2f location;
|
|
||||||
public ArrayList<Node> neighbors;
|
|
||||||
public Regions region;
|
|
||||||
public Building parentBuilding;
|
|
||||||
|
|
||||||
public Node(Vector2f loc, Regions reg, Building parent){
|
|
||||||
this.location = loc;
|
|
||||||
this.region = reg;
|
|
||||||
this.parentBuilding = parent;
|
|
||||||
this.neighbors = new ArrayList<>();
|
|
||||||
}
|
|
||||||
public Node(Node clone){
|
|
||||||
this.location = clone.location;
|
|
||||||
this.region = clone.region;
|
|
||||||
this.parentBuilding = clone.parentBuilding;
|
|
||||||
this.neighbors = (ArrayList<Node>) clone.neighbors.clone();
|
|
||||||
}
|
|
||||||
public ArrayList<Node> getNeighbors(){
|
|
||||||
if(neighbors.size() == 0){
|
|
||||||
Zone zone = ZoneManager.findSmallestZone(new Vector3fImmutable(this.location.x,0,this.location.y));
|
|
||||||
if(zone == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
for(Node potentialNeighbor : zone.navNodes){
|
|
||||||
for (Path2D.Float obstacle : zone.navObstacles) {
|
|
||||||
if (!this.equals(potentialNeighbor) && !obstacle.intersects(this.location.x, this.location.y, potentialNeighbor.location.x, potentialNeighbor.location.y) && this.location.distance(potentialNeighbor.location) < 65) {
|
|
||||||
this.neighbors.add(potentialNeighbor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.neighbors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Node getClosestNode(Vector3fImmutable loc){
|
|
||||||
Zone zone = ZoneManager.findSmallestZone(loc);
|
|
||||||
Regions region = Regions.getRegionAtLocation(loc);
|
|
||||||
if(region != null){
|
|
||||||
for(Node node : zone.navNodes){
|
|
||||||
if(node.location == new Vector2f(region.center.x,region.center.z))
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
float disSq = 10000000;
|
|
||||||
Node closest = null;
|
|
||||||
for(Node node : zone.navNodes){
|
|
||||||
if(node.location.distanceSquared(new Vector2f(loc.x,loc.z)) < disSq)
|
|
||||||
closest = node;
|
|
||||||
}
|
|
||||||
return closest;
|
|
||||||
}
|
|
||||||
public static ArrayList<Node> getPath(AbstractCharacter mover, Vector3fImmutable goal){
|
|
||||||
ArrayList<Node> path = new ArrayList<>();
|
|
||||||
Node startNode = getClosestNode(mover.loc);
|
|
||||||
Node goalNode = getClosestNode(goal);
|
|
||||||
if(goalNode == null)
|
|
||||||
move(mover,goal);
|
|
||||||
Node currentNode = new Node(startNode);
|
|
||||||
path.add(startNode);
|
|
||||||
int attempts = 0;
|
|
||||||
while(!currentNode.equals(goalNode) && attempts < 250){
|
|
||||||
attempts ++;
|
|
||||||
currentNode = getCheapestNeighbor(currentNode,new Vector2f(goal.x,goal.z));
|
|
||||||
path.add(currentNode);
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
public static Node getCheapestNeighbor(Node node, Vector2f goal){
|
|
||||||
Node cheapest = null;
|
|
||||||
for(Node neighbor : node.getNeighbors()){
|
|
||||||
if(cheapest == null) {
|
|
||||||
cheapest = neighbor;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(getCost(cheapest.location,node.location,goal) > getCost(neighbor.location,node.location,goal)){
|
|
||||||
cheapest = neighbor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cheapest;
|
|
||||||
}
|
|
||||||
public static float getCost(Vector2f point, Vector2f start, Vector2f goal) {
|
|
||||||
float gCost = start.distanceSquared(point);
|
|
||||||
float hCost = goal.distanceSquared(point);
|
|
||||||
return gCost + hCost;
|
|
||||||
}
|
|
||||||
public static void followPath(AbstractCharacter character, ArrayList<Node> path){
|
|
||||||
character.isPathing = true;
|
|
||||||
while(new Vector2f(character.loc.x,character.loc.z).distanceSquared(path.get(path.size() - 1).location) > 9 && path.size() > 0){
|
|
||||||
if( character.isMoving())
|
|
||||||
continue;
|
|
||||||
if(character.combatTarget != null){
|
|
||||||
//need ot adjust new path for a moving combat target
|
|
||||||
if(character.combatTarget.loc.distanceSquared2D(new Vector3fImmutable(path.get(path.size() - 1).location.x,0,path.get(path.size() - 1).location.y)) > 625){
|
|
||||||
character.isPathing = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
move(character,new Vector3fImmutable(path.get(0).location.x,0,path.get(0).location.y));
|
|
||||||
path.remove(0);
|
|
||||||
}
|
|
||||||
character.isPathing = false;
|
|
||||||
}
|
|
||||||
public static void move(AbstractCharacter mob, Vector3fImmutable goal) {
|
|
||||||
mob.destination = goal;
|
|
||||||
if (mob.getObjectType().equals(Enum.GameObjectType.Mob)) {
|
|
||||||
mob.setWalkMode(!(mob.combatTarget == null));
|
|
||||||
MovementManager.sendRWSSMsg(mob);
|
|
||||||
}
|
|
||||||
mob.endLoc = goal;
|
|
||||||
|
|
||||||
MoveToPointMsg msg = new MoveToPointMsg();
|
|
||||||
|
|
||||||
msg.setSourceType(Enum.GameObjectType.Mob.ordinal());
|
|
||||||
msg.setSourceID(mob.getObjectUUID());
|
|
||||||
msg.setStartCoord(mob.loc);
|
|
||||||
msg.setEndCoord(goal);
|
|
||||||
Regions region = Regions.getRegionAtLocation(goal);
|
|
||||||
if (region != null) {
|
|
||||||
msg.setInBuildingFloor(region.room);
|
|
||||||
msg.setInBuilding(region.level);
|
|
||||||
msg.setStartLocType(0);
|
|
||||||
msg.setInBuildingUUID(region.parentBuildingID);
|
|
||||||
} else {
|
|
||||||
msg.setInBuildingFloor(-1);
|
|
||||||
msg.setInBuilding(-1);
|
|
||||||
msg.setStartLocType(0);
|
|
||||||
msg.setInBuildingUUID(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
MovementManager.movement(msg, mob);
|
|
||||||
} catch (MsgSendException e) {
|
|
||||||
// TODO Figure out how we want to handle the msg send exception
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -79,7 +79,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
|||||||
float startAlt = 0;
|
float startAlt = 0;
|
||||||
Building regionBuilding = Regions.GetBuildingForRegion(upRegion);
|
Building regionBuilding = Regions.GetBuildingForRegion(upRegion);
|
||||||
if (upRegion != null)
|
if (upRegion != null)
|
||||||
startAlt = upRegion.lerpY(pc.loc) - regionBuilding.getLoc().y;
|
startAlt = upRegion.lerpY(pc) - regionBuilding.getLoc().y;
|
||||||
float rounded = startAlt * .10f;
|
float rounded = startAlt * .10f;
|
||||||
|
|
||||||
rounded = ((int) rounded) * 10;
|
rounded = ((int) rounded) * 10;
|
||||||
@@ -143,7 +143,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
|||||||
float landingAltitude = 0;
|
float landingAltitude = 0;
|
||||||
Building building = Regions.GetBuildingForRegion(region);
|
Building building = Regions.GetBuildingForRegion(region);
|
||||||
if (building != null)
|
if (building != null)
|
||||||
landingAltitude = region.lerpY(pc.loc) - building.getLoc().y;
|
landingAltitude = region.lerpY(pc) - building.getLoc().y;
|
||||||
|
|
||||||
if (landingAltitude >= targetAlt) {
|
if (landingAltitude >= targetAlt) {
|
||||||
pc.landingRegion = region;
|
pc.landingRegion = region;
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (warehouse == null)
|
if (warehouse == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (warehouse.isEmpty()) {
|
if (Warehouse.isEmpty(warehouse)) {
|
||||||
ErrorPopupMsg.sendErrorPopup(player, 167); // no more resources.
|
ErrorPopupMsg.sendErrorPopup(player, 167); // no more resources.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -437,13 +437,13 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
|
|||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
break;
|
break;
|
||||||
case 17:
|
case 17:
|
||||||
Warehouse.warehouseWithdraw(msg, player, npc, origin);
|
Warehouse.warehouseWithdraw(msg, player, npc);
|
||||||
break;
|
break;
|
||||||
case 18:
|
case 18:
|
||||||
Warehouse.warehouseDeposit(msg, player, npc, origin);
|
Warehouse.warehouseDeposit(msg, player, npc);
|
||||||
break;
|
break;
|
||||||
case 19:
|
case 19:
|
||||||
Warehouse.warehouseLock(msg, player, npc, origin);
|
Warehouse.warehouseLock(msg, player, npc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,27 +98,27 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.goldIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(7));
|
||||||
|
|
||||||
if (resourceValue < 5000000)
|
if (resourceValue < 5000000)
|
||||||
hasResources = false;
|
hasResources = false;
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.stoneIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580000));
|
||||||
|
|
||||||
if (resourceValue < 8000)
|
if (resourceValue < 8000)
|
||||||
hasResources = false;
|
hasResources = false;
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.lumberIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580004));
|
||||||
|
|
||||||
if (resourceValue < 8000)
|
if (resourceValue < 8000)
|
||||||
hasResources = false;
|
hasResources = false;
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.galvorIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580017));
|
||||||
|
|
||||||
if (resourceValue < 15)
|
if (resourceValue < 15)
|
||||||
hasResources = false;
|
hasResources = false;
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.wormwoodIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580018));
|
||||||
|
|
||||||
if (resourceValue < 15)
|
if (resourceValue < 15)
|
||||||
hasResources = false;
|
hasResources = false;
|
||||||
@@ -130,51 +130,51 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
// Remove resources from warehouse before claiming realm
|
// Remove resources from warehouse before claiming realm
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.goldIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(7));
|
||||||
|
|
||||||
if (DbManager.WarehouseQueries.updateGold(warehouse, resourceValue - 5000000) == true) {
|
if (DbManager.WarehouseQueries.updateGold(warehouse, resourceValue - 5000000) == true) {
|
||||||
warehouse.getResources().put(Warehouse.goldIB, resourceValue - 5000000);
|
warehouse.resources.put(ItemBase.getItemBase(7), resourceValue - 5000000);
|
||||||
warehouse.AddTransactionToWarehouse(engine.Enum.GameObjectType.Building, tol.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GOLD, 5000000);
|
Warehouse.AddTransactionToWarehouse(warehouse, engine.Enum.GameObjectType.Building, tol.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GOLD, 5000000);
|
||||||
} else {
|
} else {
|
||||||
Logger.error("gold update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
Logger.error("gold update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.stoneIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580000));
|
||||||
|
|
||||||
if (DbManager.WarehouseQueries.updateStone(warehouse, resourceValue - 8000) == true) {
|
if (DbManager.WarehouseQueries.updateStone(warehouse, resourceValue - 8000) == true) {
|
||||||
warehouse.getResources().put(Warehouse.stoneIB, resourceValue - 8000);
|
warehouse.resources.put(ItemBase.getItemBase(1580000), resourceValue - 8000);
|
||||||
warehouse.AddTransactionToWarehouse(engine.Enum.GameObjectType.Building, tol.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.STONE, 8000);
|
Warehouse.AddTransactionToWarehouse(warehouse, engine.Enum.GameObjectType.Building, tol.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.STONE, 8000);
|
||||||
} else {
|
} else {
|
||||||
Logger.error("stone update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
Logger.error("stone update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.lumberIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580004));
|
||||||
|
|
||||||
if (DbManager.WarehouseQueries.updateLumber(warehouse, resourceValue - 8000) == true) {
|
if (DbManager.WarehouseQueries.updateLumber(warehouse, resourceValue - 8000) == true) {
|
||||||
warehouse.getResources().put(Warehouse.lumberIB, resourceValue - 8000);
|
warehouse.resources.put(ItemBase.getItemBase(1580004), resourceValue - 8000);
|
||||||
warehouse.AddTransactionToWarehouse(engine.Enum.GameObjectType.Building, tol.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.LUMBER, 8000);
|
Warehouse.AddTransactionToWarehouse(warehouse, engine.Enum.GameObjectType.Building, tol.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.LUMBER, 8000);
|
||||||
} else {
|
} else {
|
||||||
Logger.error("lumber update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
Logger.error("lumber update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.galvorIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580017));
|
||||||
|
|
||||||
if (DbManager.WarehouseQueries.updateGalvor(warehouse, resourceValue - 15) == true) {
|
if (DbManager.WarehouseQueries.updateGalvor(warehouse, resourceValue - 15) == true) {
|
||||||
warehouse.getResources().put(Warehouse.galvorIB, resourceValue - 15);
|
warehouse.resources.put(ItemBase.getItemBase(1580017), resourceValue - 15);
|
||||||
warehouse.AddTransactionToWarehouse(engine.Enum.GameObjectType.Building, tol.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GALVOR, 15);
|
Warehouse.AddTransactionToWarehouse(warehouse, engine.Enum.GameObjectType.Building, tol.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GALVOR, 15);
|
||||||
} else {
|
} else {
|
||||||
Logger.error("galvor update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
Logger.error("galvor update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceValue = warehouse.getResources().get(Warehouse.wormwoodIB);
|
resourceValue = warehouse.resources.get(ItemBase.getItemBase(1580018));
|
||||||
|
|
||||||
if (DbManager.WarehouseQueries.updateWormwood(warehouse, resourceValue - 15) == true) {
|
if (DbManager.WarehouseQueries.updateWormwood(warehouse, resourceValue - 15) == true) {
|
||||||
warehouse.getResources().put(Warehouse.wormwoodIB, resourceValue - 15);
|
warehouse.resources.put(ItemBase.getItemBase(1580018), resourceValue - 15);
|
||||||
warehouse.AddTransactionToWarehouse(engine.Enum.GameObjectType.Building, tol.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.WORMWOOD, 15);
|
Warehouse.AddTransactionToWarehouse(warehouse, engine.Enum.GameObjectType.Building, tol.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.WORMWOOD, 15);
|
||||||
} else {
|
} else {
|
||||||
Logger.error("wormwood update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
Logger.error("wormwood update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -766,8 +766,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
cityObjectMap.put(gameObject.getObjectType(), gameObject);
|
cityObjectMap.put(gameObject.getObjectType(), gameObject);
|
||||||
|
|
||||||
treeObject = (Building) cityObjectMap.get(GameObjectType.Building);
|
treeObject = (Building) cityObjectMap.get(GameObjectType.Building);
|
||||||
treeObject.runAfterLoad();
|
|
||||||
|
|
||||||
cityObject = (City) cityObjectMap.get(GameObjectType.City);
|
cityObject = (City) cityObjectMap.get(GameObjectType.City);
|
||||||
zoneObject = (Zone) cityObjectMap.get(GameObjectType.Zone);
|
zoneObject = (Zone) cityObjectMap.get(GameObjectType.Zone);
|
||||||
|
|
||||||
@@ -799,6 +797,10 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
City.lastCityUpdate = System.currentTimeMillis();
|
City.lastCityUpdate = System.currentTimeMillis();
|
||||||
treeObject.setLoc(treeObject.getLoc());
|
treeObject.setLoc(treeObject.getLoc());
|
||||||
|
|
||||||
|
// As this is a new static object set it's dirtyFlag
|
||||||
|
// so players already near it will have the object loaded.
|
||||||
|
|
||||||
InterestManager.setObjectDirty(treeObject);
|
InterestManager.setObjectDirty(treeObject);
|
||||||
|
|
||||||
serverRealm.addCity(cityObject.getObjectUUID());
|
serverRealm.addCity(cityObject.getObjectUUID());
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class TaxCityMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
||||||
vrm.setGuild(building.getGuild());
|
vrm.setGuild(building.getGuild());
|
||||||
vrm.setWarehouseBuilding(BuildingManager.getBuildingFromCache(building.getCity().getWarehouse().getBuildingUID()));
|
vrm.setWarehouseBuilding(BuildingManager.getBuildingFromCache(building.getCity().getWarehouse().buildingUID));
|
||||||
vrm.configure();
|
vrm.configure();
|
||||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ public class ArcViewAssetTransactionsMsg extends ClientNetMsg {
|
|||||||
|
|
||||||
public void configure() {
|
public void configure() {
|
||||||
|
|
||||||
warehouseBuilding = BuildingManager.getBuilding(this.warehouse.getBuildingUID());
|
warehouseBuilding = BuildingManager.getBuilding(this.warehouse.buildingUID);
|
||||||
transactions = new ArrayList<>(50);
|
transactions = new ArrayList<>(50);
|
||||||
|
|
||||||
if (this.warehouse.getTransactions().size() > 150) {
|
if (this.warehouse.transactions.size() > 150) {
|
||||||
transactions.addAll(this.warehouse.getTransactions().subList(this.warehouse.getTransactions().size() - 150, this.warehouse.getTransactions().size()));
|
transactions.addAll(this.warehouse.transactions.subList(this.warehouse.transactions.size() - 150, this.warehouse.transactions.size()));
|
||||||
} else
|
} else
|
||||||
transactions = this.warehouse.getTransactions();
|
transactions = this.warehouse.transactions;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ public class ArcViewAssetTransactionsMsg extends ClientNetMsg {
|
|||||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||||
|
|
||||||
writer.putInt(this.transactionID);
|
writer.putInt(this.transactionID);
|
||||||
writer.putInt(this.warehouse.getBuildingUID());
|
writer.putInt(this.warehouse.buildingUID);
|
||||||
writer.putInt(transactions.size()); //list Size
|
writer.putInt(transactions.size()); //list Size
|
||||||
|
|
||||||
for (Transaction transaction : transactions) {
|
for (Transaction transaction : transactions) {
|
||||||
@@ -124,7 +124,7 @@ public class ArcViewAssetTransactionsMsg extends ClientNetMsg {
|
|||||||
writer.putInt(transaction.getTargetUUID()); //ID
|
writer.putInt(transaction.getTargetUUID()); //ID
|
||||||
writer.putString(name); //Name of depositer/withdrawler or mine name
|
writer.putString(name); //Name of depositer/withdrawler or mine name
|
||||||
writer.putInt(GameObjectType.Building.ordinal()); //Type
|
writer.putInt(GameObjectType.Building.ordinal()); //Type
|
||||||
writer.putInt(warehouse.getBuildingUID()); //ID
|
writer.putInt(warehouse.buildingUID); //ID
|
||||||
writer.putString(warehouseBuilding.getName()); //warehouse
|
writer.putString(warehouseBuilding.getName()); //warehouse
|
||||||
writer.putInt(transaction.getTransactionType().getID()); //79,80 withdrew, 81 mine produced, 82 deposit
|
writer.putInt(transaction.getTransactionType().getID()); //79,80 withdrew, 81 mine produced, 82 deposit
|
||||||
writer.putInt(transaction.getAmount()); //amount
|
writer.putInt(transaction.getAmount()); //amount
|
||||||
|
|||||||
@@ -89,23 +89,23 @@ public class ViewResourcesMessage extends ClientNetMsg {
|
|||||||
@Override
|
@Override
|
||||||
protected void _serialize(ByteBufferWriter writer) {
|
protected void _serialize(ByteBufferWriter writer) {
|
||||||
|
|
||||||
writer.putInt(warehouseObject.getResources().size());
|
writer.putInt(warehouseObject.resources.size());
|
||||||
|
|
||||||
for (ItemBase ib : (warehouseObject.getResources().keySet())) {
|
for (ItemBase ib : (warehouseObject.resources.keySet())) {
|
||||||
|
|
||||||
writer.putInt(ib.getHashID());
|
writer.putInt(ib.getHashID());
|
||||||
writer.putInt((warehouseObject.getResources().get(ib)));
|
writer.putInt((warehouseObject.resources.get(ib)));
|
||||||
|
|
||||||
|
|
||||||
if (warehouseObject.isResourceLocked(ib) == true)
|
if (Warehouse.isResourceLocked(warehouseObject, ib) == true)
|
||||||
writer.put((byte) 1);
|
writer.put((byte) 1);
|
||||||
else
|
else
|
||||||
writer.put((byte) 0);
|
writer.put((byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.putInt(warehouseObject.getResources().size());
|
writer.putInt(warehouseObject.resources.size());
|
||||||
|
|
||||||
for (ItemBase ib : warehouseObject.getResources().keySet()) {
|
for (ItemBase ib : warehouseObject.resources.keySet()) {
|
||||||
writer.putInt(ib.getHashID());
|
writer.putInt(ib.getHashID());
|
||||||
writer.putInt(0); //available?
|
writer.putInt(0); //available?
|
||||||
writer.putInt(Warehouse.getMaxResources().get(ib.getUUID())); //max?
|
writer.putInt(Warehouse.getMaxResources().get(ib.getUUID())); //max?
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import engine.jobs.TrackJob;
|
|||||||
import engine.math.AtomicFloat;
|
import engine.math.AtomicFloat;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.mobileAI.utilities.PathingUtilities;
|
|
||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
import engine.net.client.msg.ErrorPopupMsg;
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
@@ -121,16 +120,11 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
private long lastHateUpdate = 0;
|
private long lastHateUpdate = 0;
|
||||||
private byte aoecntr = 0;
|
private byte aoecntr = 0;
|
||||||
|
|
||||||
public Vector3fImmutable destination = Vector3fImmutable.ZERO;
|
|
||||||
|
|
||||||
public int hidden = 0; // current rank of hide/sneak/invis
|
public int hidden = 0; // current rank of hide/sneak/invis
|
||||||
public CopyOnWriteArrayList<Integer> minions = new CopyOnWriteArrayList();
|
public CopyOnWriteArrayList<Integer> minions = new CopyOnWriteArrayList();
|
||||||
|
|
||||||
public ArrayList<CharacterRune> runes;
|
public ArrayList<CharacterRune> runes;
|
||||||
|
|
||||||
public ArrayList<PathingUtilities.Node> navPath = new ArrayList<>();
|
|
||||||
public boolean isPathing = false;
|
|
||||||
|
|
||||||
public AbstractCharacter() {
|
public AbstractCharacter() {
|
||||||
super();
|
super();
|
||||||
this.firstName = "";
|
this.firstName = "";
|
||||||
@@ -840,10 +834,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
if (this.isCasting && this.getObjectType().equals(GameObjectType.PlayerCharacter))
|
if (this.isCasting && this.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(this.getObjectType().equals(GameObjectType.Mob)){
|
|
||||||
if(this.destination.equals(Vector3fImmutable.ZERO))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -997,11 +987,22 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
@Override
|
@Override
|
||||||
public final void setLoc(final Vector3fImmutable value) {
|
public final void setLoc(final Vector3fImmutable value) {
|
||||||
|
|
||||||
Regions region = Regions.getRegionAtLocation(value);
|
Building building = BuildingManager.getBuildingAtLocation(this.loc);
|
||||||
|
Regions region = null;
|
||||||
|
if(building != null) {
|
||||||
|
//look for region in the building we are in
|
||||||
|
for (Regions regionCycle : building.getBounds().getRegions()) {
|
||||||
|
float regionHeight = regionCycle.highLerp.y - regionCycle.lowLerp.y;
|
||||||
|
if(regionHeight < 10)
|
||||||
|
regionHeight = 10;
|
||||||
|
if (regionCycle.isPointInPolygon(value) && Math.abs(regionCycle.highLerp.y - value.y) < regionHeight)
|
||||||
|
region = regionCycle;
|
||||||
|
}
|
||||||
|
}
|
||||||
float regionHeightOffset = 0;
|
float regionHeightOffset = 0;
|
||||||
if(region != null){
|
if(region != null){
|
||||||
this.region = region;
|
this.region = region;
|
||||||
regionHeightOffset = region.lerpY(this.loc);
|
regionHeightOffset = region.lerpY(this);
|
||||||
this.inBuilding = region.level; // -1 not in building 0 on ground floor, 1 on first floor etc
|
this.inBuilding = region.level; // -1 not in building 0 on ground floor, 1 on first floor etc
|
||||||
this.inBuildingID = region.parentBuildingID;
|
this.inBuildingID = region.parentBuildingID;
|
||||||
this.inFloorID = region.room;
|
this.inFloorID = region.room;
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
|||||||
if (region.center.y == region.highLerp.y)
|
if (region.center.y == region.highLerp.y)
|
||||||
worldObject.loc = worldObject.loc.setY(region.center.y + worldObject.getAltitude());
|
worldObject.loc = worldObject.loc.setY(region.center.y + worldObject.getAltitude());
|
||||||
else
|
else
|
||||||
worldObject.loc = worldObject.loc.setY(region.lerpY(worldObject.loc) + worldObject.getAltitude());
|
worldObject.loc = worldObject.loc.setY(region.lerpY(worldObject) + worldObject.getAltitude());
|
||||||
|
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
@@ -504,7 +504,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
|||||||
this.loc = loc;
|
this.loc = loc;
|
||||||
|
|
||||||
if(this instanceof AbstractCharacter && this.region != null){
|
if(this instanceof AbstractCharacter && this.region != null){
|
||||||
this.loc = this.loc.setY(this.region.lerpY(this.loc) + this.getAltitude());
|
this.loc = this.loc.setY(this.region.lerpY(this) + this.getAltitude());
|
||||||
} else{
|
} else{
|
||||||
this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude());
|
this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ import engine.net.client.msg.UpdateObjectMsg;
|
|||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.awt.geom.Area;
|
|
||||||
import java.awt.geom.Path2D;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -101,8 +99,6 @@ public class Building extends AbstractWorldObject {
|
|||||||
private ConcurrentHashMap<Integer, Condemned> condemned;
|
private ConcurrentHashMap<Integer, Condemned> condemned;
|
||||||
private ArrayList<Building> children = null;
|
private ArrayList<Building> children = null;
|
||||||
|
|
||||||
public ArrayList<Path2D.Float> meshes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResultSet Constructor
|
* ResultSet Constructor
|
||||||
*/
|
*/
|
||||||
@@ -1007,8 +1003,6 @@ public class Building extends AbstractWorldObject {
|
|||||||
|
|
||||||
if (this.upgradeDateTime != null)
|
if (this.upgradeDateTime != null)
|
||||||
BuildingManager.submitUpgradeJob(this);
|
BuildingManager.submitUpgradeJob(this);
|
||||||
|
|
||||||
BuildingManager.bakeNavMesh(this); // update the navmesh of the parent zone
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean setOwner(AbstractCharacter newOwner) {
|
public synchronized boolean setOwner(AbstractCharacter newOwner) {
|
||||||
@@ -1435,18 +1429,18 @@ public class Building extends AbstractWorldObject {
|
|||||||
if (this.getCity().getWarehouse() == null)
|
if (this.getCity().getWarehouse() == null)
|
||||||
return amount;
|
return amount;
|
||||||
|
|
||||||
if (this.getCity().getWarehouse().getResources().get(ItemBase.getGoldItemBase()) >= Warehouse.getMaxResources().get(ItemBase.getGoldItemBase().getUUID()))
|
if (this.getCity().getWarehouse().resources.get(ItemBase.getGoldItemBase()) >= Warehouse.getMaxResources().get(ItemBase.getGoldItemBase().getUUID()))
|
||||||
return amount;
|
return amount;
|
||||||
|
|
||||||
int profitAmount = (int) (amount * (taxAmount * .01f));
|
int profitAmount = (int) (amount * (taxAmount * .01f));
|
||||||
|
|
||||||
if (this.getCity().getWarehouse().getResources().get(ItemBase.getGoldItemBase()) + profitAmount <= Warehouse.getMaxResources().get(ItemBase.getGoldItemBase().getUUID())) {
|
if (this.getCity().getWarehouse().resources.get(ItemBase.getGoldItemBase()) + profitAmount <= Warehouse.getMaxResources().get(ItemBase.getGoldItemBase().getUUID())) {
|
||||||
this.getCity().getWarehouse().depositProfitTax(ItemBase.getGoldItemBase(), profitAmount, this);
|
Warehouse.depositProfitTax(ItemBase.getGoldItemBase(), profitAmount, this,this.getCity().getWarehouse());
|
||||||
return amount - profitAmount;
|
return amount - profitAmount;
|
||||||
}
|
}
|
||||||
//overDrafting
|
//overDrafting
|
||||||
int warehouseDeposit = Warehouse.getMaxResources().get(ItemBase.getGoldItemBase().getUUID()) - this.getCity().getWarehouse().getResources().get(ItemBase.getGoldItemBase());
|
int warehouseDeposit = Warehouse.getMaxResources().get(ItemBase.getGoldItemBase().getUUID()) - this.getCity().getWarehouse().resources.get(ItemBase.getGoldItemBase());
|
||||||
this.getCity().getWarehouse().depositProfitTax(ItemBase.getGoldItemBase(), warehouseDeposit, this);
|
Warehouse.depositProfitTax(ItemBase.getGoldItemBase(), warehouseDeposit, this,this.getCity().getWarehouse());
|
||||||
return amount - warehouseDeposit;
|
return amount - warehouseDeposit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1536,5 +1530,4 @@ public class Building extends AbstractWorldObject {
|
|||||||
public void RemoveFromBarracksList() {
|
public void RemoveFromBarracksList() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,7 @@ package engine.objects;
|
|||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.Enum.GameObjectType;
|
import engine.Enum.GameObjectType;
|
||||||
import engine.Enum.ItemType;
|
import engine.Enum.ItemType;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.*;
|
||||||
import engine.gameManager.ChatManager;
|
|
||||||
import engine.gameManager.ConfigManager;
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
@@ -345,13 +342,13 @@ public class CharacterItemManager {
|
|||||||
Warehouse warehouse = (Warehouse) object;
|
Warehouse warehouse = (Warehouse) object;
|
||||||
|
|
||||||
if (amount < 0) {
|
if (amount < 0) {
|
||||||
if (!warehouse.deposit((PlayerCharacter) this.absCharacter, this.getGoldInventory(), amount * -1, true, true)) {
|
if (!Warehouse.deposit((PlayerCharacter) this.absCharacter, this.getGoldInventory(), amount * -1, true, true,warehouse)) {
|
||||||
|
|
||||||
ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.absCharacter, 203);
|
ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.absCharacter, 203);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!warehouse.withdraw((PlayerCharacter) this.absCharacter, this.getGoldInventory().getItemBase(), amount * -1, true, true)) {
|
if (!Warehouse.withdraw(warehouse, (PlayerCharacter) this.absCharacter, this.getGoldInventory().getItemBase(), amount * -1, true, true)) {
|
||||||
|
|
||||||
ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.absCharacter, 203);
|
ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.absCharacter, 203);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1358,7 +1358,7 @@ public class City extends AbstractWorldObject {
|
|||||||
ItemBase ib = ItemBase.getItemBase(itemBaseID);
|
ItemBase ib = ItemBase.getItemBase(itemBaseID);
|
||||||
if (ib == null)
|
if (ib == null)
|
||||||
continue;
|
continue;
|
||||||
if (ruledWarehouse.isAboveCap(ib, (int) (city.getWarehouse().getResources().get(ib) * taxPercent))) {
|
if (Warehouse.isAboveCap(ruledWarehouse, ib, (int) (city.getWarehouse().resources.get(ib) * taxPercent))) {
|
||||||
ErrorPopupMsg.sendErrorMsg(player, "You're warehouse has enough " + ib.getName() + " already!");
|
ErrorPopupMsg.sendErrorMsg(player, "You're warehouse has enough " + ib.getName() + " already!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1371,7 +1371,7 @@ public class City extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
city.getWarehouse().transferResources(player, msg, resources, taxPercent, ruledWarehouse);
|
Warehouse.transferResources(city.getWarehouse(), player, msg, resources, taxPercent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(e.getMessage());
|
Logger.info(e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -1380,7 +1380,7 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
||||||
vrm.setGuild(building.getGuild());
|
vrm.setGuild(building.getGuild());
|
||||||
vrm.setWarehouseBuilding(BuildingManager.getBuildingFromCache(building.getCity().getWarehouse().getBuildingUID()));
|
vrm.setWarehouseBuilding(BuildingManager.getBuildingFromCache(building.getCity().getWarehouse().buildingUID));
|
||||||
vrm.configure();
|
vrm.configure();
|
||||||
Dispatch dispatch = Dispatch.borrow(player, vrm);
|
Dispatch dispatch = Dispatch.borrow(player, vrm);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class ItemFactory {
|
|||||||
// ROLL BANE SCROLL.
|
// ROLL BANE SCROLL.
|
||||||
|
|
||||||
if (ib.getUUID() > 910010 && ib.getUUID() < 910019) {
|
if (ib.getUUID() > 910010 && ib.getUUID() < 910019) {
|
||||||
ConcurrentHashMap<ItemBase, Integer> resources = cityWarehouse.getResources();
|
ConcurrentHashMap<ItemBase, Integer> resources = cityWarehouse.resources;
|
||||||
|
|
||||||
|
|
||||||
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, ib.getBaseValue());
|
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, ib.getBaseValue());
|
||||||
@@ -131,7 +131,7 @@ public class ItemFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
|
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + " " + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + " " + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
@@ -167,9 +167,9 @@ public class ItemFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (overdraft > 0)
|
if (overdraft > 0)
|
||||||
if (!cityWarehouse.withdraw(npc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
||||||
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
||||||
Logger.error("Warehouse With UID of " + cityWarehouse.getUID() + " Failed to Create Item." + ib.getName());
|
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,13 +263,13 @@ public class ItemFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (galvorAmount > 0) {
|
if (galvorAmount > 0) {
|
||||||
if (cityWarehouse.isResourceLocked(galvor)) {
|
if (Warehouse.isResourceLocked(cityWarehouse, galvor)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cityWarehouse.getResources().get(galvor) < galvorAmount) {
|
if (cityWarehouse.resources.get(galvor) < galvorAmount) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
@@ -277,13 +277,13 @@ public class ItemFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wormwoodAmount > 0) {
|
if (wormwoodAmount > 0) {
|
||||||
if (cityWarehouse.isResourceLocked(wormwood)) {
|
if (Warehouse.isResourceLocked(cityWarehouse, wormwood)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Wormwood is locked." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Wormwood is locked." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cityWarehouse.getResources().get(wormwood) < wormwoodAmount) {
|
if (cityWarehouse.resources.get(wormwood) < wormwoodAmount) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Wormwood in warehouse to roll this item." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Wormwood in warehouse to roll this item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
@@ -320,20 +320,20 @@ public class ItemFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
|
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
|
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
prefixResourceCosts = prefix.getResourcesForEffect();
|
prefixResourceCosts = prefix.getResourcesForEffect();
|
||||||
for (ItemBase ibResources : prefixResourceCosts.keySet()) {
|
for (ItemBase ibResources : prefixResourceCosts.keySet()) {
|
||||||
int warehouseAmount = cityWarehouse.getResources().get(ibResources);
|
int warehouseAmount = cityWarehouse.resources.get(ibResources);
|
||||||
int creationAmount = prefixResourceCosts.get(ibResources);
|
int creationAmount = prefixResourceCosts.get(ibResources);
|
||||||
//ChatManager.chatInfoError(pc, "Prefix : " + ibResources.getName() + " / " + creationAmount);
|
//ChatManager.chatInfoError(pc, "Prefix : " + ibResources.getName() + " / " + creationAmount);
|
||||||
if (warehouseAmount < creationAmount) {
|
if (warehouseAmount < creationAmount) {
|
||||||
@@ -374,13 +374,13 @@ public class ItemFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
|
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
|
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
@@ -388,7 +388,7 @@ public class ItemFactory {
|
|||||||
|
|
||||||
|
|
||||||
for (ItemBase ibResources : suffixResourceCosts.keySet()) {
|
for (ItemBase ibResources : suffixResourceCosts.keySet()) {
|
||||||
int warehouseAmount = cityWarehouse.getResources().get(ibResources);
|
int warehouseAmount = cityWarehouse.resources.get(ibResources);
|
||||||
int creationAmount = suffixResourceCosts.get(ibResources);
|
int creationAmount = suffixResourceCosts.get(ibResources);
|
||||||
if (warehouseAmount < creationAmount) {
|
if (warehouseAmount < creationAmount) {
|
||||||
// if (pc != null)
|
// if (pc != null)
|
||||||
@@ -414,13 +414,13 @@ public class ItemFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overdraft > 0 && useWarehouse && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
|
if (overdraft > 0 && useWarehouse && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useWarehouse && overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
|
if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
@@ -440,7 +440,7 @@ public class ItemFactory {
|
|||||||
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
if (overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
|
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -448,9 +448,9 @@ public class ItemFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (overdraft > 0 && useWarehouse)
|
if (overdraft > 0 && useWarehouse)
|
||||||
if (!cityWarehouse.withdraw(npc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
||||||
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
||||||
Logger.error("Warehouse With UID of " + cityWarehouse.getUID() + " Failed to Create Item." + ib.getName());
|
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,18 +467,18 @@ public class ItemFactory {
|
|||||||
|
|
||||||
int creationAmount = prefixResourceCosts.get(ibResources);
|
int creationAmount = prefixResourceCosts.get(ibResources);
|
||||||
|
|
||||||
if (cityWarehouse.isResourceLocked(ibResources) == true)
|
if (Warehouse.isResourceLocked(cityWarehouse, ibResources) == true)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
int oldAmount = cityWarehouse.getResources().get(ibResources);
|
int oldAmount = cityWarehouse.resources.get(ibResources);
|
||||||
int amount = creationAmount;
|
int amount = creationAmount;
|
||||||
|
|
||||||
if (oldAmount < amount)
|
if (oldAmount < amount)
|
||||||
amount = oldAmount;
|
amount = oldAmount;
|
||||||
|
|
||||||
if (!cityWarehouse.withdraw(npc, ibResources, amount, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) {
|
||||||
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
||||||
Logger.error("Warehouse With UID of " + cityWarehouse.getUID() + " Failed to Create Item." + ib.getName());
|
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -489,18 +489,18 @@ public class ItemFactory {
|
|||||||
for (ItemBase ibResources : suffixResourceCosts.keySet()) {
|
for (ItemBase ibResources : suffixResourceCosts.keySet()) {
|
||||||
int creationAmount = suffixResourceCosts.get(ibResources);
|
int creationAmount = suffixResourceCosts.get(ibResources);
|
||||||
|
|
||||||
if (cityWarehouse.isResourceLocked(ibResources) == true) {
|
if (Warehouse.isResourceLocked(cityWarehouse, ibResources) == true) {
|
||||||
ChatManager.chatSystemError(pc, ibResources.getName() + " is locked!" + ib.getName());
|
ChatManager.chatSystemError(pc, ibResources.getName() + " is locked!" + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int oldAmount = cityWarehouse.getResources().get(ibResources);
|
int oldAmount = cityWarehouse.resources.get(ibResources);
|
||||||
int amount = creationAmount;
|
int amount = creationAmount;
|
||||||
if (oldAmount < amount)
|
if (oldAmount < amount)
|
||||||
amount = oldAmount;
|
amount = oldAmount;
|
||||||
if (!cityWarehouse.withdraw(npc, ibResources, amount, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) {
|
||||||
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
||||||
Logger.error("Warehouse With UID of " + cityWarehouse.getUID() + " Failed to Create Item." + ib.getName());
|
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -522,14 +522,14 @@ public class ItemFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
|
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||||
|
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useWarehouse && overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
|
if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
|
||||||
|
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
|
||||||
@@ -544,7 +544,7 @@ public class ItemFactory {
|
|||||||
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
if (overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
|
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -552,16 +552,16 @@ public class ItemFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (overdraft > 0)
|
if (overdraft > 0)
|
||||||
if (!cityWarehouse.withdraw(npc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
||||||
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
||||||
Logger.error("Warehouse With UID of " + cityWarehouse.getUID() + " Failed to Create Item." + ib.getName());
|
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatManager.chatGuildInfo(pc, "Gold Cost = " + total);
|
// ChatManager.chatGuildInfo(pc, "Gold Cost = " + total);
|
||||||
|
|
||||||
if (galvorAmount > 0) {
|
if (galvorAmount > 0) {
|
||||||
if (!cityWarehouse.withdraw(npc, galvor, galvorAmount, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, galvor, galvorAmount, true)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + ib.getName());
|
||||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||||
return null;
|
return null;
|
||||||
@@ -569,7 +569,7 @@ public class ItemFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wormwoodAmount > 0) {
|
if (wormwoodAmount > 0) {
|
||||||
if (!cityWarehouse.withdraw(npc, wormwood, wormwoodAmount, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, wormwood, wormwoodAmount, true)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse!" + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse!" + ib.getName());
|
||||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||||
return null;
|
return null;
|
||||||
@@ -815,7 +815,7 @@ public class ItemFactory {
|
|||||||
ConcurrentHashMap<ItemBase, Integer> resources = null;
|
ConcurrentHashMap<ItemBase, Integer> resources = null;
|
||||||
|
|
||||||
if (useWarehouse)
|
if (useWarehouse)
|
||||||
resources = cityWarehouse.getResources();
|
resources = cityWarehouse.resources;
|
||||||
|
|
||||||
int galvorAmount = 0;
|
int galvorAmount = 0;
|
||||||
int wormwoodAmount = 0;
|
int wormwoodAmount = 0;
|
||||||
@@ -852,24 +852,24 @@ public class ItemFactory {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (galvorAmount > 0) {
|
if (galvorAmount > 0) {
|
||||||
if (cityWarehouse.isResourceLocked(galvor)) {
|
if (Warehouse.isResourceLocked(cityWarehouse, galvor)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cityWarehouse.getResources().get(galvor) < galvorAmount) {
|
if (cityWarehouse.resources.get(galvor) < galvorAmount) {
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wormwoodAmount > 0) {
|
if (wormwoodAmount > 0) {
|
||||||
if (cityWarehouse.isResourceLocked(wormwood)) {
|
if (Warehouse.isResourceLocked(cityWarehouse, wormwood)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cityWarehouse.getResources().get(wormwood) < wormwoodAmount) {
|
if (cityWarehouse.resources.get(wormwood) < wormwoodAmount) {
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -908,7 +908,7 @@ public class ItemFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useWarehouse && overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
|
if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
@@ -936,12 +936,12 @@ public class ItemFactory {
|
|||||||
// there was an overdraft, withdraw the rest from warehouse.
|
// there was an overdraft, withdraw the rest from warehouse.
|
||||||
if (overdraft > 0) {
|
if (overdraft > 0) {
|
||||||
if (pc != null) {
|
if (pc != null) {
|
||||||
if (!cityWarehouse.withdraw(pc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, pc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
|
||||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!cityWarehouse.withdraw(npc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
||||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -959,7 +959,7 @@ public class ItemFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useWarehouse && overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
|
if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
|
||||||
return null;
|
return null;
|
||||||
@@ -987,12 +987,12 @@ public class ItemFactory {
|
|||||||
if (overdraft > 0 && useWarehouse) {
|
if (overdraft > 0 && useWarehouse) {
|
||||||
|
|
||||||
if (pc != null) {
|
if (pc != null) {
|
||||||
if (!cityWarehouse.withdraw(pc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, pc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
|
||||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!cityWarehouse.withdraw(npc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
||||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1002,7 +1002,7 @@ public class ItemFactory {
|
|||||||
|
|
||||||
if (galvorAmount > 0 && useWarehouse) {
|
if (galvorAmount > 0 && useWarehouse) {
|
||||||
//ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse");
|
//ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse");
|
||||||
if (!cityWarehouse.withdraw(npc, galvor, galvorAmount, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, galvor, galvorAmount, true)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + ib.getName());
|
||||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||||
return null;
|
return null;
|
||||||
@@ -1011,7 +1011,7 @@ public class ItemFactory {
|
|||||||
|
|
||||||
if (wormwoodAmount > 0 && useWarehouse) {
|
if (wormwoodAmount > 0 && useWarehouse) {
|
||||||
//ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse");
|
//ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse");
|
||||||
if (!cityWarehouse.withdraw(npc, wormwood, wormwoodAmount, false, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, wormwood, wormwoodAmount, true)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse for " + ib.getName());
|
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse for " + ib.getName());
|
||||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ package engine.objects;
|
|||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.geom.Area;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
@@ -47,10 +45,5 @@ public class MeshBounds {
|
|||||||
Bounds.meshBoundsCache = DbManager.BuildingQueries.LOAD_MESH_BOUNDS();
|
Bounds.meshBoundsCache = DbManager.BuildingQueries.LOAD_MESH_BOUNDS();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Area getArea(float x, float z){
|
|
||||||
Polygon area = new Polygon();
|
|
||||||
area.addPoint((int)(x + this.minX), (int) (z + this.minZ));
|
|
||||||
area.addPoint((int)(x + this.maxX), (int)(z + this.maxZ));
|
|
||||||
return new Area(area);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ package engine.objects;
|
|||||||
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.*;
|
||||||
import engine.gameManager.ChatManager;
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.gameManager.ZoneManager;
|
|
||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.net.client.msg.ErrorPopupMsg;
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
@@ -483,7 +480,7 @@ public class Mine extends AbstractGameObject {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
ItemBase resourceIB = ItemBase.getItemBase(this.production.UUID);
|
ItemBase resourceIB = ItemBase.getItemBase(this.production.UUID);
|
||||||
return this.owningGuild.getOwnedCity().getWarehouse().depositFromMine(this, resourceIB, this.getModifiedProductionAmount());
|
return Warehouse.depositFromMine(this, resourceIB, this.getModifiedProductionAmount(),this.owningGuild.getOwnedCity().getWarehouse());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateGuildOwner(PlayerCharacter playerCharacter) {
|
public boolean updateGuildOwner(PlayerCharacter playerCharacter) {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
public long nextCallForHelp = 0;
|
public long nextCallForHelp = 0;
|
||||||
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
||||||
public boolean despawned = false;
|
public boolean despawned = false;
|
||||||
|
public Vector3fImmutable destination = Vector3fImmutable.ZERO;
|
||||||
public MobBase mobBase;
|
public MobBase mobBase;
|
||||||
public int spawnDelay;
|
public int spawnDelay;
|
||||||
public Zone parentZone;
|
public Zone parentZone;
|
||||||
@@ -406,7 +406,6 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
|
|
||||||
Mob mobile = new Mob();
|
Mob mobile = new Mob();
|
||||||
mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
|
mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
|
||||||
//mobile.agentType = AIAgentType.MOBILE; this method is only called to make guard captains and wall archers
|
|
||||||
mobile.agentType = mobType;
|
mobile.agentType = mobType;
|
||||||
mobile.behaviourType = MobBehaviourType.None;
|
mobile.behaviourType = MobBehaviourType.None;
|
||||||
mobile.loadID = loadID;
|
mobile.loadID = loadID;
|
||||||
@@ -418,12 +417,17 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
mobile.guildUUID = guild.getObjectUUID();
|
mobile.guildUUID = guild.getObjectUUID();
|
||||||
|
|
||||||
mobile.parentZoneUUID = parent.getObjectUUID();
|
mobile.parentZoneUUID = parent.getObjectUUID();
|
||||||
mobile.buildingUUID = building.getObjectUUID();
|
|
||||||
|
if (building == null)
|
||||||
|
mobile.buildingUUID = 0;
|
||||||
|
else
|
||||||
|
mobile.buildingUUID = building.getObjectUUID();
|
||||||
|
|
||||||
if (mobile.buildingUUID != 0)
|
if (mobile.buildingUUID != 0)
|
||||||
mobile.bindLoc = Vector3fImmutable.ZERO;
|
mobile.bindLoc = Vector3fImmutable.ZERO;
|
||||||
else
|
else
|
||||||
mobile.bindLoc = spawn;
|
mobile.bindLoc = ZoneManager.worldToLocal(spawn, parent);
|
||||||
|
;
|
||||||
|
|
||||||
mobile.firstName = pirateName;
|
mobile.firstName = pirateName;
|
||||||
|
|
||||||
@@ -1889,6 +1893,19 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean isGuard(){
|
||||||
|
|
||||||
|
switch(this.behaviourType){
|
||||||
|
case GuardMinion:
|
||||||
|
case GuardCaptain:
|
||||||
|
case GuardWallArcher:
|
||||||
|
case HamletGuard:
|
||||||
|
case SimpleStandingGuard:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getDelay(@NotNull TimeUnit unit) {
|
public long getDelay(@NotNull TimeUnit unit) {
|
||||||
long timeRemaining = this.respawnTime - System.currentTimeMillis();
|
long timeRemaining = this.respawnTime - System.currentTimeMillis();
|
||||||
@@ -1899,5 +1916,4 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
public int compareTo(@NotNull Delayed o) {
|
public int compareTo(@NotNull Delayed o) {
|
||||||
return toIntExact(this.respawnTime - ((Mob) o).respawnTime);
|
return toIntExact(this.respawnTime - ((Mob) o).respawnTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-26
@@ -461,16 +461,20 @@ public class NPC extends AbstractCharacter {
|
|||||||
|
|
||||||
NPC newNPC = new NPC();
|
NPC newNPC = new NPC();
|
||||||
|
|
||||||
|
newNPC.parentZoneUUID = parent.getObjectUUID();
|
||||||
|
|
||||||
newNPC.name = name;
|
newNPC.name = name;
|
||||||
newNPC.contractUUID = contractID;
|
newNPC.contractUUID = contractID;
|
||||||
|
|
||||||
if (building == null)
|
if (building == null)
|
||||||
newNPC.bindLoc = spawn;
|
newNPC.bindLoc = ZoneManager.worldToLocal(spawn, parent);
|
||||||
else
|
else
|
||||||
newNPC.bindLoc = Vector3fImmutable.ZERO;
|
newNPC.bindLoc = Vector3fImmutable.ZERO;
|
||||||
|
|
||||||
newNPC.parentZoneUUID = parent.getObjectUUID();
|
if (guild == null)
|
||||||
newNPC.guildUUID = guild.getObjectUUID();
|
newNPC.guildUUID = 0;
|
||||||
|
else
|
||||||
|
newNPC.guildUUID = guild.getObjectUUID();
|
||||||
|
|
||||||
if (building == null)
|
if (building == null)
|
||||||
newNPC.buildingUUID = 0;
|
newNPC.buildingUUID = 0;
|
||||||
@@ -842,7 +846,6 @@ public class NPC extends AbstractCharacter {
|
|||||||
else
|
else
|
||||||
this.guild = Guild.getGuild(this.guildUUID);
|
this.guild = Guild.getGuild(this.guildUUID);
|
||||||
|
|
||||||
|
|
||||||
if (this.guild == null)
|
if (this.guild == null)
|
||||||
this.guild = Guild.getErrantGuild();
|
this.guild = Guild.getErrantGuild();
|
||||||
|
|
||||||
@@ -872,27 +875,23 @@ public class NPC extends AbstractCharacter {
|
|||||||
if (this.building != null)
|
if (this.building != null)
|
||||||
NPCManager.slotCharacterInBuilding(this);
|
NPCManager.slotCharacterInBuilding(this);
|
||||||
|
|
||||||
if (this.contract != null) {
|
this.symbol = this.contract.getIconID();
|
||||||
this.symbol = this.contract.getIconID();
|
this.modTypeTable = this.contract.getNPCModTypeTable();
|
||||||
this.modTypeTable = this.contract.getNPCModTypeTable();
|
this.modSuffixTable = this.contract.getNpcModSuffixTable();
|
||||||
this.modSuffixTable = this.contract.getNpcModSuffixTable();
|
this.itemModTable = this.contract.getItemModTable();
|
||||||
this.itemModTable = this.contract.getItemModTable();
|
int VID = this.contract.getVendorID();
|
||||||
int VID = this.contract.getVendorID();
|
|
||||||
|
|
||||||
if (VID != 0)
|
if (VID != 0)
|
||||||
this.vendorID = VID;
|
this.vendorID = VID;
|
||||||
else
|
else
|
||||||
this.vendorID = 1; //no vendor items
|
this.vendorID = 1; //no vendor items
|
||||||
}
|
|
||||||
|
|
||||||
if (this.mobBase != null) {
|
this.healthMax = this.mobBase.getHealthMax();
|
||||||
this.healthMax = this.mobBase.getHealthMax();
|
this.manaMax = 0;
|
||||||
this.manaMax = 0;
|
this.staminaMax = 0;
|
||||||
this.staminaMax = 0;
|
this.setHealth(this.healthMax);
|
||||||
this.setHealth(this.healthMax);
|
this.mana.set(this.manaMax);
|
||||||
this.mana.set(this.manaMax);
|
this.stamina.set(this.staminaMax);
|
||||||
this.stamina.set(this.staminaMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.parentZone.guild_zone)
|
if (this.parentZone.guild_zone)
|
||||||
if (NPC.GetNPCProfits(this) == null)
|
if (NPC.GetNPCProfits(this) == null)
|
||||||
@@ -911,10 +910,10 @@ public class NPC extends AbstractCharacter {
|
|||||||
|
|
||||||
this.charItemManager.load();
|
this.charItemManager.load();
|
||||||
|
|
||||||
this.equip = loadEquipmentSet(this.equipmentSetID);
|
if (equipmentSetID != 0 && LootManager._bootySetMap.get(equipmentSetID) == null)
|
||||||
|
Logger.error("Invalid equipSet: " + equipmentSetID + " contract: " + this.contractUUID + " npc: " + this.getObjectUUID());
|
||||||
|
|
||||||
if (this.equip == null)
|
this.equip = loadEquipmentSet(this.equipmentSetID);
|
||||||
this.equip = new HashMap<>();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|||||||
@@ -4828,7 +4828,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
if (this.landingRegion != null) {
|
if (this.landingRegion != null) {
|
||||||
this.altitude = 0;
|
this.altitude = 0;
|
||||||
this.region = this.landingRegion;
|
this.region = this.landingRegion;
|
||||||
this.loc = this.loc.setY(this.landingRegion.lerpY(this.loc));
|
this.loc = this.loc.setY(this.landingRegion.lerpY(this));
|
||||||
} else
|
} else
|
||||||
this.altitude = this.getDesiredAltitude();
|
this.altitude = this.getDesiredAltitude();
|
||||||
|
|
||||||
|
|||||||
@@ -9,18 +9,14 @@
|
|||||||
|
|
||||||
package engine.objects;
|
package engine.objects;
|
||||||
|
|
||||||
import engine.InterestManagement.Terrain;
|
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.FastMath;
|
import engine.math.FastMath;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.mobileAI.utilities.PathingUtilities;
|
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.geom.Area;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@@ -182,7 +178,7 @@ public class Regions {
|
|||||||
boolean movingUp = false;
|
boolean movingUp = false;
|
||||||
|
|
||||||
boolean movingDown = false;
|
boolean movingDown = false;
|
||||||
float yLerp = worldObject.region.lerpY(worldObject.loc);
|
float yLerp = worldObject.region.lerpY(worldObject);
|
||||||
|
|
||||||
if (yLerp == (worldObject.region.highLerp.y))
|
if (yLerp == (worldObject.region.highLerp.y))
|
||||||
movingUp = true;
|
movingUp = true;
|
||||||
@@ -274,18 +270,32 @@ public class Regions {
|
|||||||
return BuildingManager.getBuildingFromCache(region.parentBuildingID);
|
return BuildingManager.getBuildingFromCache(region.parentBuildingID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Regions getRegionAtLocation(Vector3fImmutable location) {
|
public static Regions GetRegionForTeleport(Vector3fImmutable location) {
|
||||||
Regions region = null;
|
Regions region = null;
|
||||||
Building building = BuildingManager.getBuildingAtLocation(location);
|
|
||||||
if(building != null) {
|
|
||||||
//look for region in the building we are in
|
//Find building
|
||||||
for (Regions regionCycle : building.getBounds().getRegions()) {
|
for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(location, 128, MBServerStatics.MASK_BUILDING)) {
|
||||||
float regionHeight = regionCycle.highLerp.y - regionCycle.lowLerp.y;
|
Building building = (Building) awo;
|
||||||
if(regionHeight < 10)
|
if (!Bounds.collide(location, building.getBounds()))
|
||||||
regionHeight = 10;
|
continue;
|
||||||
if (regionCycle.isPointInPolygon(location) && Math.abs(regionCycle.highLerp.y - location.y) < regionHeight)
|
if(building != null) {
|
||||||
region = regionCycle;
|
region = BuildingManager.GetRegion(building, location.x, location.y, location.z);
|
||||||
}
|
}
|
||||||
|
//find regions that intersect x and z, check if object can enter.
|
||||||
|
//for (Regions toEnter : building.getBounds().getRegions()) {
|
||||||
|
// if (toEnter.isPointInPolygon(location)) {
|
||||||
|
|
||||||
|
// if (region == null)
|
||||||
|
// region = toEnter;
|
||||||
|
// else // we're using a low level to high level tree structure, database not always in order low to high.
|
||||||
|
//check for highest level index.
|
||||||
|
// if (region != null && toEnter.highLerp.y > region.highLerp.y)
|
||||||
|
// region = toEnter;
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
@@ -340,10 +350,10 @@ public class Regions {
|
|||||||
return inside;
|
return inside;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float lerpY(Vector3fImmutable lerper) {
|
public float lerpY(AbstractWorldObject lerper) {
|
||||||
|
|
||||||
Vector3fImmutable lengthVector = this.highLerp.subtract2D(this.lowLerp);
|
Vector3fImmutable lengthVector = this.highLerp.subtract2D(this.lowLerp);
|
||||||
Vector3fImmutable characterVector = lerper.subtract2D(this.lowLerp);
|
Vector3fImmutable characterVector = lerper.getLoc().subtract2D(this.lowLerp);
|
||||||
float lengthVectorMagnitude = lengthVector.magnitude();
|
float lengthVectorMagnitude = lengthVector.magnitude();
|
||||||
float characterVectorMagnitude = characterVector.magnitude();
|
float characterVectorMagnitude = characterVector.magnitude();
|
||||||
float percentDistance = characterVectorMagnitude / lengthVectorMagnitude;
|
float percentDistance = characterVectorMagnitude / lengthVectorMagnitude;
|
||||||
@@ -364,12 +374,4 @@ public class Regions {
|
|||||||
public boolean isExit() {
|
public boolean isExit() {
|
||||||
return exit;
|
return exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Area getArea(){
|
|
||||||
Polygon area = new Polygon();
|
|
||||||
for( Vector3f point : this.regionPoints){
|
|
||||||
area.addPoint((int) point.x, (int) point.z);
|
|
||||||
}
|
|
||||||
return new Area(area);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+327
-743
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
package engine.objects;
|
package engine.objects;
|
||||||
|
|
||||||
import java.awt.geom.Area;
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.InterestManagement.Terrain;
|
import engine.InterestManagement.Terrain;
|
||||||
import engine.db.archive.DataWarehouse;
|
import engine.db.archive.DataWarehouse;
|
||||||
@@ -17,12 +16,10 @@ import engine.gameManager.ZoneManager;
|
|||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.Vector2f;
|
import engine.math.Vector2f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.mobileAI.utilities.PathingUtilities;
|
|
||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.geom.Path2D;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -40,8 +37,8 @@ public class Zone extends AbstractWorldObject {
|
|||||||
|
|
||||||
public final int playerCityUUID;
|
public final int playerCityUUID;
|
||||||
public final String zoneName;
|
public final String zoneName;
|
||||||
public final float major_radius;
|
public float major_radius;
|
||||||
public final float minor_radius;
|
public float minor_radius;
|
||||||
public final float xOffset;
|
public final float xOffset;
|
||||||
public final float zOffset;
|
public final float zOffset;
|
||||||
public final float yOffset;
|
public final float yOffset;
|
||||||
@@ -67,8 +64,6 @@ public class Zone extends AbstractWorldObject {
|
|||||||
public float sea_level;
|
public float sea_level;
|
||||||
|
|
||||||
public Terrain terrain = null;
|
public Terrain terrain = null;
|
||||||
public ArrayList<Path2D.Float> navObstacles = new ArrayList<>();
|
|
||||||
public ArrayList<PathingUtilities.Node> navNodes = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResultSet Constructor
|
* ResultSet Constructor
|
||||||
@@ -81,9 +76,6 @@ public class Zone extends AbstractWorldObject {
|
|||||||
this.templateID = rs.getInt("template");
|
this.templateID = rs.getInt("template");
|
||||||
this.zoneName = rs.getString("zone_name");
|
this.zoneName = rs.getString("zone_name");
|
||||||
this.peace_zone = rs.getByte("peace_zone");
|
this.peace_zone = rs.getByte("peace_zone");
|
||||||
|
|
||||||
this.major_radius = rs.getFloat("major_radius");
|
|
||||||
this.minor_radius = rs.getFloat("minor_radius");
|
|
||||||
this.xOffset = rs.getFloat("xOffset");
|
this.xOffset = rs.getFloat("xOffset");
|
||||||
this.zOffset = rs.getFloat("zOffset");
|
this.zOffset = rs.getFloat("zOffset");
|
||||||
this.yOffset = rs.getFloat("yOffset");
|
this.yOffset = rs.getFloat("yOffset");
|
||||||
@@ -168,6 +160,18 @@ public class Zone extends AbstractWorldObject {
|
|||||||
if (ZoneManager.seaFloor == null)
|
if (ZoneManager.seaFloor == null)
|
||||||
ZoneManager.seaFloor = this;
|
ZoneManager.seaFloor = this;
|
||||||
|
|
||||||
|
// Guild zones use the enum CityBoundsType to adjust
|
||||||
|
// city size. All other zones derive from the JSON
|
||||||
|
// stored within its template.
|
||||||
|
|
||||||
|
if (this.template == null) {
|
||||||
|
this.minor_radius = Enum.CityBoundsType.ZONE.halfExtents;
|
||||||
|
this.major_radius = Enum.CityBoundsType.ZONE.halfExtents;
|
||||||
|
} else {
|
||||||
|
this.minor_radius = this.template.minor_radius;
|
||||||
|
this.major_radius = this.template.major_radius;
|
||||||
|
}
|
||||||
|
|
||||||
this.setParent();
|
this.setParent();
|
||||||
this.setBounds();
|
this.setBounds();
|
||||||
|
|
||||||
@@ -185,7 +189,9 @@ public class Zone extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ZoneManager.populateZoneCollections(this);
|
ZoneManager.populateZoneCollections(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Method sets a default value for player cities
|
/* Method sets a default value for player cities
|
||||||
* otherwise using values derived from the loadnum
|
* otherwise using values derived from the loadnum
|
||||||
* field in the obj_zone database table.
|
* field in the obj_zone database table.
|
||||||
@@ -195,7 +201,7 @@ public class Zone extends AbstractWorldObject {
|
|||||||
// Set initial bounds object
|
// Set initial bounds object
|
||||||
|
|
||||||
this.bounds = Bounds.borrow();
|
this.bounds = Bounds.borrow();
|
||||||
this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(this.template.major_radius, this.template.minor_radius), 0.0f);
|
this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(this.major_radius, this.minor_radius), 0.0f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public class TeleportPowerAction extends AbstractPowerAction {
|
|||||||
|
|
||||||
//TODO verify target loc is valid loc
|
//TODO verify target loc is valid loc
|
||||||
|
|
||||||
Regions region = Regions.getRegionAtLocation(targetLoc);
|
Regions region = Regions.GetRegionForTeleport(targetLoc);
|
||||||
|
|
||||||
if (region != null && !region.isOutside())
|
if (region != null && !region.isOutside())
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -403,12 +403,6 @@ public class WorldServer {
|
|||||||
Logger.info("Loading building slot/stuck location data.");
|
Logger.info("Loading building slot/stuck location data.");
|
||||||
BuildingLocation.loadBuildingLocations();
|
BuildingLocation.loadBuildingLocations();
|
||||||
|
|
||||||
Logger.info("Populating structure to render lookup.");
|
|
||||||
DbManager.BuildingQueries.POPULATE_RENDER_LOOKUP();
|
|
||||||
|
|
||||||
Logger.info("Loading mesh hulls.");
|
|
||||||
DbManager.BuildingQueries.LOAD_MESH_HULLS();
|
|
||||||
|
|
||||||
// Starting before loading of structures/guilds/characters
|
// Starting before loading of structures/guilds/characters
|
||||||
// so the database connections are available to write
|
// so the database connections are available to write
|
||||||
// historical data.
|
// historical data.
|
||||||
|
|||||||
Reference in New Issue
Block a user