Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d22ff916bf | |||
| 2d1da7679e | |||
| 549a381174 | |||
| 43563aeb14 | |||
| 7a4c2fe72a | |||
| 24cc6af147 |
@@ -24,3 +24,7 @@
|
|||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
replay_pid*
|
replay_pid*
|
||||||
|
|
||||||
|
*.idea/
|
||||||
|
Server.iml
|
||||||
|
*.gitignore
|
||||||
|
prestonbane.iml
|
||||||
@@ -243,12 +243,8 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public boolean UPDATE_EQUIPSET(NPC npc, int equipSetID) {
|
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();
|
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.setInt(1, equipSetID);
|
||||||
preparedStatement.setLong(2, npc.getObjectUUID());
|
preparedStatement.setLong(2, npc.getObjectUUID());
|
||||||
@@ -471,4 +467,4 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -541,18 +541,8 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
mobWithoutID.parentZone = parent;
|
mobWithoutID.parentZone = parent;
|
||||||
mobWithoutID.parentZoneID = parent.getObjectUUID();
|
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
|
// NPC in a Building derives position from slot
|
||||||
|
|
||||||
if (mobWithoutID.building != null)
|
if (mobWithoutID.building != null)
|
||||||
mobWithoutID.bindLoc = Vector3fImmutable.ZERO;
|
mobWithoutID.bindLoc = Vector3fImmutable.ZERO;
|
||||||
|
|
||||||
|
|||||||
@@ -470,8 +470,7 @@ public class NPC extends AbstractCharacter {
|
|||||||
newNPC.bindLoc = Vector3fImmutable.ZERO;
|
newNPC.bindLoc = Vector3fImmutable.ZERO;
|
||||||
|
|
||||||
newNPC.parentZoneUUID = parent.getObjectUUID();
|
newNPC.parentZoneUUID = parent.getObjectUUID();
|
||||||
// guild may be null when spawning via ./npc; default to 0
|
newNPC.guildUUID = guild.getObjectUUID();
|
||||||
newNPC.guildUUID = (guild != null) ? guild.getObjectUUID() : 0;
|
|
||||||
|
|
||||||
if (building == null)
|
if (building == null)
|
||||||
newNPC.buildingUUID = 0;
|
newNPC.buildingUUID = 0;
|
||||||
@@ -1348,4 +1347,4 @@ public class NPC extends AbstractCharacter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
private boolean isTeleporting = false;
|
private boolean isTeleporting = false;
|
||||||
private boolean dirtyLoad = true;
|
private boolean dirtyLoad = true;
|
||||||
private final ReadWriteLock dirtyLock = new ReentrantReadWriteLock(true);
|
private final ReadWriteLock dirtyLock = new ReentrantReadWriteLock(true);
|
||||||
|
private Bounds playerBounds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No Id Constructor
|
* No Id Constructor
|
||||||
@@ -206,6 +207,10 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
|
|
||||||
this.guildStatus = new AtomicInteger(0);
|
this.guildStatus = new AtomicInteger(0);
|
||||||
this.bindBuildingID = -1;
|
this.bindBuildingID = -1;
|
||||||
|
|
||||||
|
this.playerBounds = Bounds.borrow();
|
||||||
|
playerBounds.setBounds(this.getLoc());
|
||||||
|
this.playerBounds.setBounds(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -269,11 +274,60 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
|
|
||||||
this.hash = rs.getString("hash");
|
this.hash = rs.getString("hash");
|
||||||
|
|
||||||
|
this.playerBounds = Bounds.borrow();
|
||||||
|
playerBounds.setBounds(this.getLoc());
|
||||||
|
this.playerBounds.setBounds(this);
|
||||||
|
|
||||||
|
|
||||||
// For debugging skills
|
// For debugging skills
|
||||||
// CharacterSkill.printSkills(this);
|
// CharacterSkill.printSkills(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateBounds() {
|
||||||
|
this.playerBounds.setBounds(this);
|
||||||
|
this.checkCollisionsWithOtherPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
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)) {
|
||||||
|
System.out.println("Collision detected with player: " + otherPlayer.getFirstName());
|
||||||
|
ChatManager.chatSystemInfo(otherPlayer, "Has Collided with YOU");
|
||||||
|
// Handle collision with other player
|
||||||
|
handleCollisionWithPlayer(otherPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleCollisionWithPlayer(PlayerCharacter otherPlayer) {
|
||||||
|
Vector3fImmutable myPos = this.getLoc();
|
||||||
|
Vector3fImmutable otherPlayerPos = otherPlayer.getLoc();
|
||||||
|
|
||||||
|
// Calculate direction vector
|
||||||
|
Vector3fImmutable direction = myPos.subtract(otherPlayerPos).normalize();
|
||||||
|
|
||||||
|
// Move players apart
|
||||||
|
float separationDistance = 1.0f; // Adjust this value as needed
|
||||||
|
Vector3fImmutable myNewPos = myPos.add(direction.mult(separationDistance / 2));
|
||||||
|
Vector3fImmutable otherPlayerNewPos = otherPlayerPos.subtract(direction.mult(separationDistance / 2.0f));
|
||||||
|
|
||||||
|
// Update positions
|
||||||
|
this.setLoc(myNewPos);
|
||||||
|
otherPlayer.setLoc(otherPlayerNewPos);
|
||||||
|
|
||||||
|
// Refresh both players in the world
|
||||||
|
WorldGrid.updateObject(this);
|
||||||
|
WorldGrid.updateObject(otherPlayer);
|
||||||
|
|
||||||
|
// Refresh both players in the world
|
||||||
|
WorldGrid.updateObject(this);
|
||||||
|
WorldGrid.updateObject(otherPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
public static Building getUpdatedBindBuilding(PlayerCharacter player) {
|
public static Building getUpdatedBindBuilding(PlayerCharacter player) {
|
||||||
Building returnBuilding = null;
|
Building returnBuilding = null;
|
||||||
|
|
||||||
@@ -4882,6 +4936,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
@Override
|
@Override
|
||||||
public void updateLocation() {
|
public void updateLocation() {
|
||||||
|
|
||||||
|
this.updateBounds();
|
||||||
|
|
||||||
if (!this.isMoving())
|
if (!this.isMoving())
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user