Browse Source

Handler created for PromptRecallMsg

combat-2
MagicBot 8 months ago
parent
commit
507ec302e7
  1. 51
      src/engine/gameManager/MovementManager.java
  2. 15
      src/engine/net/client/ClientMessagePump.java
  3. 2
      src/engine/net/client/Protocol.java
  4. 85
      src/engine/net/client/handlers/PromptRecallMsgHandler.java

51
src/engine/gameManager/MovementManager.java

@ -23,7 +23,6 @@ import engine.math.Vector3fImmutable;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.ClientConnection; import engine.net.client.ClientConnection;
import engine.net.client.msg.MoveToPointMsg; import engine.net.client.msg.MoveToPointMsg;
import engine.net.client.msg.PromptRecallMsg;
import engine.net.client.msg.TeleportToPointMsg; import engine.net.client.msg.TeleportToPointMsg;
import engine.net.client.msg.UpdateStateMsg; import engine.net.client.msg.UpdateStateMsg;
import engine.objects.*; import engine.objects.*;
@ -489,56 +488,6 @@ public enum MovementManager {
ac.teleport(ac.getLoc()); ac.teleport(ac.getLoc());
} }
public static void HandlePromptRecall(PromptRecallMsg msg, ClientConnection origin) throws MsgSendException {
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
boolean recallAccepted;
if (player == null)
return;
boolean confirmed = msg.getConfirmed();
if (confirmed == true) {
long timeElapsed = System.currentTimeMillis() - player.getTimeStamp("PromptRecall");
//send fail message
recallAccepted = timeElapsed < 15000;
} else
recallAccepted = false;
if (recallAccepted == true) {
//handle recall
long type = player.getTimeStamp("LastRecallType");
if (type == 1) { //recall to bind
player.teleport(player.getBindLoc());
player.setSafeMode();
} else { //recall to rg
float dist = 9999999999f;
Building rg = null;
Vector3fImmutable rgLoc;
for (Runegate runegate : Runegate._runegates.values()) {
rgLoc = runegate.gateBuilding.getLoc();
float distanceSquaredToRunegate = player.getLoc().distanceSquared2D(rgLoc);
if (distanceSquaredToRunegate < sqr(dist))
rg = runegate.gateBuilding;
}
//nearest runegate found. teleport characterTarget
if (rg != null) {
player.teleport(rg.getLoc());
player.setSafeMode();
}
}
}
}
public static void stuck(ClientConnection origin) { public static void stuck(ClientConnection origin) {
PlayerCharacter sourcePlayer = origin.getPlayerCharacter(); PlayerCharacter sourcePlayer = origin.getPlayerCharacter();

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

@ -916,12 +916,6 @@ public class ClientMessagePump implements NetMsgHandler {
case ARCPETCMD: case ARCPETCMD:
petCmd((PetCmdMsg) msg, origin); petCmd((PetCmdMsg) msg, origin);
break; break;
case MANAGENPC:
ManageNPCCmd((ManageNPCMsg) msg, origin);
break;
case ARCPROMPTRECALL:
MovementManager.HandlePromptRecall((PromptRecallMsg) msg, origin);
break;
case CHANNELMUTE: case CHANNELMUTE:
break; break;
case KEEPALIVESERVERCLIENT: case KEEPALIVESERVERCLIENT:
@ -947,15 +941,6 @@ public class ClientMessagePump implements NetMsgHandler {
return true; return true;
} }
//TODO what is this used for?
private void ManageNPCCmd(ManageNPCMsg msg, ClientConnection origin) {
}
//call this if the transfer fails server side to kick the item back to inventory from equip
private void forceTransferFromInventoryToEquip(TransferItemFromEquipToInventoryMsg msg, ClientConnection origin, String reason) {
//TODO add this later
//PATCHED CODEZZ
}
} }

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

@ -40,7 +40,7 @@ public enum Protocol {
ARCPETATTACK(0x18CD61AD, PetAttackMsg.class, null), // Pet Attack ARCPETATTACK(0x18CD61AD, PetAttackMsg.class, null), // Pet Attack
ARCPETCMD(0x4E80E001, PetCmdMsg.class, null), // Stop ArcPetAttack, Toggle Assist, Toggle Rest ARCPETCMD(0x4E80E001, PetCmdMsg.class, null), // Stop ArcPetAttack, Toggle Assist, Toggle Rest
ARCPOWERPROJECTILE(0xA2312D3B, null, null), ARCPOWERPROJECTILE(0xA2312D3B, null, null),
ARCPROMPTRECALL(0xE3196B6E, PromptRecallMsg.class, null), //Recall Prompt ARCPROMPTRECALL(0xE3196B6E, PromptRecallMsg.class, PromptRecallMsgHandler.class), //Recall Prompt
ARCREQUESTTRADEBUSY(0xD4BAB4DF, InvalidTradeRequestMsg.class, null), // Attempt trade with someone who is already trading ARCREQUESTTRADEBUSY(0xD4BAB4DF, InvalidTradeRequestMsg.class, null), // Attempt trade with someone who is already trading
ARCSERVERSTATUS(0x87BA4462, null, null), //Update Server Status ARCSERVERSTATUS(0x87BA4462, null, null), //Update Server Status
ARCSIEGESPIRE(0x36A49BC6, ArcSiegeSpireMsg.class, ArcSiegeSpireMsgHandler.class), // Activate/Deactivate Spires ARCSIEGESPIRE(0x36A49BC6, ArcSiegeSpireMsg.class, ArcSiegeSpireMsgHandler.class), // Activate/Deactivate Spires

85
src/engine/net/client/handlers/PromptRecallMsgHandler.java

@ -0,0 +1,85 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.exception.MsgSendException;
import engine.gameManager.SessionManager;
import engine.math.Vector3fImmutable;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.PromptRecallMsg;
import engine.objects.Building;
import engine.objects.PlayerCharacter;
import engine.objects.Runegate;
import static engine.math.FastMath.sqr;
public class PromptRecallMsgHandler extends AbstractClientMsgHandler {
public PromptRecallMsgHandler() {
super(PromptRecallMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
// Member variable assignment
PromptRecallMsg msg = (PromptRecallMsg) baseMsg;
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
boolean recallAccepted;
if (player == null)
return true;
boolean confirmed = msg.getConfirmed();
if (confirmed == true) {
long timeElapsed = System.currentTimeMillis() - player.getTimeStamp("PromptRecall");
//send fail message
recallAccepted = timeElapsed < 15000;
} else
recallAccepted = false;
if (recallAccepted == true) {
//handle recall
long type = player.getTimeStamp("LastRecallType");
if (type == 1) { //recall to bind
player.teleport(player.getBindLoc());
player.setSafeMode();
} else { //recall to rg
float dist = 9999999999f;
Building rg = null;
Vector3fImmutable rgLoc;
for (Runegate runegate : Runegate._runegates.values()) {
rgLoc = runegate.gateBuilding.getLoc();
float distanceSquaredToRunegate = player.getLoc().distanceSquared2D(rgLoc);
if (distanceSquaredToRunegate < sqr(dist))
rg = runegate.gateBuilding;
}
//nearest runegate found. teleport characterTarget
if (rg != null) {
player.teleport(rg.getLoc());
player.setSafeMode();
}
}
}
return true;
}
}
Loading…
Cancel
Save