Browse Source

force respawn after 10 minutes of unreleased corpse

lakebane-strongholds
FatBoy-DOTC 3 months ago
parent
commit
5ce42475c4
  1. 2
      src/engine/net/client/ClientMessagePump.java
  2. 51
      src/engine/objects/PlayerCharacter.java

2
src/engine/net/client/ClientMessagePump.java

@ -672,6 +672,8 @@ public class ClientMessagePump implements NetMsgHandler { @@ -672,6 +672,8 @@ public class ClientMessagePump implements NetMsgHandler {
JobScheduler.getInstance().scheduleJob(new RefreshGroupJob(sourcePlayer), MBServerStatics.LOAD_OBJECT_DELAY);
}
private static void lootWindowRequest(LootWindowRequestMsg msg, ClientConnection origin) throws MsgSendException {
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);

51
src/engine/objects/PlayerCharacter.java

@ -26,6 +26,7 @@ import engine.job.JobScheduler; @@ -26,6 +26,7 @@ import engine.job.JobScheduler;
import engine.jobs.DeferredPowerJob;
import engine.jobs.FinishSpireEffectJob;
import engine.jobs.NoTimeJob;
import engine.jobs.RefreshGroupJob;
import engine.math.Bounds;
import engine.math.FastMath;
import engine.math.Vector3fImmutable;
@ -4809,15 +4810,61 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4809,15 +4810,61 @@ public class PlayerCharacter extends AbstractCharacter {
return false;
}
private static void forceRespawn(PlayerCharacter sourcePlayer) throws MsgSendException {
if (sourcePlayer == null)
return;
if (sourcePlayer.isAlive()) {
Logger.error("Player " + sourcePlayer.getObjectUUID() + " respawning while alive");
return;
}
// ResetAfterDeath player
sourcePlayer.respawnLock.writeLock().lock();
try {
sourcePlayer.respawn(true, false, true);
} catch (Exception e) {
Logger.error(e);
} finally {
sourcePlayer.respawnLock.writeLock().unlock();
}
RespawnMsg msg = new RespawnMsg();
// Echo ResetAfterDeath message back
msg.setPlayerHealth(sourcePlayer.getHealth());
// TODO calculate any experience loss before this point
msg.setPlayerExp(sourcePlayer.getExp() + sourcePlayer.getOverFlowEXP());
Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
MoveToPointMsg moveMsg = new MoveToPointMsg();
moveMsg.setPlayer(sourcePlayer);
moveMsg.setStartCoord(sourcePlayer.getLoc());
moveMsg.setEndCoord(sourcePlayer.getLoc());
moveMsg.setInBuilding(-1);
moveMsg.setUnknown01(-1);
dispatch = Dispatch.borrow(sourcePlayer, moveMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
MovementManager.sendRWSSMsg(sourcePlayer);
// refresh the whole group with what just happened
JobScheduler.getInstance().scheduleJob(new RefreshGroupJob(sourcePlayer), MBServerStatics.LOAD_OBJECT_DELAY);
}
@Override
public void update() {
if (this.updateLock.writeLock().tryLock()) {
try {
if (!this.isAlive())
if (!this.isAlive()) {
if((System.currentTimeMillis() - this.timestamps.get("DeathTime")) > 600000)
forceRespawn(this);
return;
}
updateLocation();
updateMovementState();
updateRegen();

Loading…
Cancel
Save