Compare commits

..

4 Commits

Author SHA1 Message Date
Preston Driver 549a381174 Updated .gitignore. 2024-09-18 22:55:36 -05:00
Preston Driver 43563aeb14 Updated dependencies since it appears that old build failed to. 2024-09-18 22:50:18 -05:00
Preston Driver 7a4c2fe72a Attempt to push to docker container. 2024-09-17 20:52:47 -05:00
Preston Driver 24cc6af147 Added player collision with other players in PlayerCharacter class. 2024-09-16 23:06:07 -05:00
5 changed files with 44 additions and 20 deletions
+4
View File
@@ -24,3 +24,7 @@
hs_err_pid*
replay_pid*
*.idea/
Server.iml
*.gitignore
prestonbane.iml
+2 -6
View File
@@ -243,12 +243,8 @@ public class dbNPCHandler extends dbHandlerBase {
public boolean UPDATE_EQUIPSET(NPC npc, int equipSetID) {
// Column name must match what NPC/Mob loaders read ("equipmentSet").
// Using the wrong column here causes the update to fail silently and
// dev command to report "Unable to find Equipset" despite a valid ID.
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipmentSet`=? WHERE `UID`=?")) {
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipsetID`=? WHERE `UID`=?")) {
preparedStatement.setInt(1, equipSetID);
preparedStatement.setLong(2, npc.getObjectUUID());
@@ -471,4 +467,4 @@ public class dbNPCHandler extends dbHandlerBase {
return false;
}
}
}
}
+1 -11
View File
@@ -541,18 +541,8 @@ public class Mob extends AbstractIntelligenceAgent {
mobWithoutID.parentZone = parent;
mobWithoutID.parentZoneID = parent.getObjectUUID();
// Ensure spawn coordinates are persisted for DB insert
// statLat/statAlt/statLon represent local (zone-relative) spawn
// coordinates used by the DB handler when creating the mob row.
if (spawn != null && parent != null) {
// Convert world coordinates to zone-local spawn coordinates
Vector3fImmutable localSpawn = spawn.subtract(parent.getLoc());
mobWithoutID.statLat = localSpawn.x;
mobWithoutID.statAlt = localSpawn.y;
mobWithoutID.statLon = localSpawn.z;
}
// NPC in a Building derives position from slot
if (mobWithoutID.building != null)
mobWithoutID.bindLoc = Vector3fImmutable.ZERO;
+2 -3
View File
@@ -470,8 +470,7 @@ public class NPC extends AbstractCharacter {
newNPC.bindLoc = Vector3fImmutable.ZERO;
newNPC.parentZoneUUID = parent.getObjectUUID();
// guild may be null when spawning via ./npc; default to 0
newNPC.guildUUID = (guild != null) ? guild.getObjectUUID() : 0;
newNPC.guildUUID = guild.getObjectUUID();
if (building == null)
newNPC.buildingUUID = 0;
@@ -1348,4 +1347,4 @@ public class NPC extends AbstractCharacter {
}
}
}
}
+35
View File
@@ -174,6 +174,7 @@ public class PlayerCharacter extends AbstractCharacter {
private boolean isTeleporting = false;
private boolean dirtyLoad = true;
private final ReadWriteLock dirtyLock = new ReentrantReadWriteLock(true);
private Bounds playerBounds;
/**
* No Id Constructor
@@ -206,6 +207,10 @@ public class PlayerCharacter extends AbstractCharacter {
this.guildStatus = new AtomicInteger(0);
this.bindBuildingID = -1;
this.playerBounds = Bounds.borrow();
playerBounds.setBounds(this.getLoc());
this.playerBounds.setBounds(this);
}
/**
@@ -269,11 +274,40 @@ public class PlayerCharacter extends AbstractCharacter {
this.hash = rs.getString("hash");
this.playerBounds = Bounds.borrow();
playerBounds.setBounds(this.getLoc());
this.playerBounds.setBounds(this);
// For debugging skills
// CharacterSkill.printSkills(this);
}
public void updateBounds() {
this.playerBounds.setBounds(this);
this.checkCollisionsWithOtherPlayers();
// This is a test to see if it will push to the docker container
}
public void checkCollisionsWithOtherPlayers() {
HashSet<AbstractWorldObject> nearbyObjects = WorldGrid.getObjectsInRangePartial(this, MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER);
for (AbstractWorldObject obj : nearbyObjects) {
if (obj instanceof PlayerCharacter && obj != this) {
PlayerCharacter otherPlayer = (PlayerCharacter) obj;
if (Bounds.collide(this.getBounds(), otherPlayer.getBounds(), 0.1f)) {
// Handle collision with other player
handleCollisionWithPlayer(otherPlayer);
}
}
}
}
private void handleCollisionWithPlayer(PlayerCharacter otherPlayer) {
// Implement collision response here
System.out.println("Collision detected with player: " + otherPlayer.getFirstName());
ChatManager.chatSystemInfo(otherPlayer, "Has Collided with YOU");
}
public static Building getUpdatedBindBuilding(PlayerCharacter player) {
Building returnBuilding = null;
@@ -4882,6 +4916,7 @@ public class PlayerCharacter extends AbstractCharacter {
@Override
public void updateLocation() {
this.updateBounds();
if (!this.isMoving())
return;