Browse Source

Handler created for ShowMsg

combat-2
MagicBot 8 months ago
parent
commit
01fd6997a8
  1. 41
      src/engine/net/client/ClientMessagePump.java
  2. 2
      src/engine/net/client/Protocol.java
  3. 72
      src/engine/net/client/handlers/ShowMsgHandler.java

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

@ -9,19 +9,14 @@ @@ -9,19 +9,14 @@
package engine.net.client;
import engine.Enum.DispatchChannel;
import engine.Enum.GameObjectType;
import engine.exception.MsgSendException;
import engine.gameManager.*;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
import engine.net.NetMsgHandler;
import engine.net.client.handlers.AbstractClientMsgHandler;
import engine.net.client.msg.*;
import engine.net.client.msg.chat.AbstractChatMsg;
import engine.objects.AbstractCharacter;
import engine.objects.Mob;
import engine.objects.NPC;
import engine.objects.PlayerCharacter;
import engine.server.world.WorldServer;
import engine.session.Session;
@ -45,39 +40,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -45,39 +40,6 @@ public class ClientMessagePump implements NetMsgHandler {
this.server = server;
}
// called when player types /show
private static void show(ShowMsg msg, ClientConnection origin) throws MsgSendException {
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
if (pc == null)
return;
int targetType = msg.getTargetType();
AbstractCharacter tar = null;
if (targetType == GameObjectType.PlayerCharacter.ordinal())
tar = PlayerCharacter.getFromCache(msg.getTargetID());
else if (targetType == GameObjectType.NPC.ordinal())
tar = NPC.getFromCache(msg.getTargetID());
else if (targetType == GameObjectType.Mob.ordinal())
tar = Mob.getFromCache(msg.getTargetID());
if (tar == null || !tar.isAlive() || !tar.isActive())
return;
msg.setUnknown01(pc.getLoc());
msg.setUnknown02(pc.getLoc());
msg.setRange01(pc.getRange());
msg.setUnknown03(tar.getLoc());
msg.setUnknown04(tar.getLoc());
msg.setRange01(tar.getRange());
Dispatch dispatch = Dispatch.borrow(pc, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
protected static void petAttack(PetAttackMsg msg, ClientConnection conn) throws MsgSendException {
PlayerCharacter pc = SessionManager.getPlayerCharacter(conn);
@ -174,9 +136,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -174,9 +136,6 @@ public class ClientMessagePump implements NetMsgHandler {
break;
case OPENVAULT:
break;
case SHOWCOMBATINFO:
show((ShowMsg) msg, origin);
break;
case REQUESTTOTRADE:
TradeManager.tradeRequest((TradeRequestMsg) msg, origin);
break;

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

@ -196,7 +196,7 @@ public enum Protocol { @@ -196,7 +196,7 @@ public enum Protocol {
SETOBJVAL(0x08A50FD1, null, null),
SETRUNE(0x888E7C64, ApplyRuneMsg.class, null), //Apply Promotion, Stat Rune (maybe disc also)
TARGETOBJECT(0x64E10938, TargetObjectMsg.class, TargetObjectMsgHandler.class), // Target an object
SHOWCOMBATINFO(0x9BF1E5EA, ShowMsg.class, null), // Request/Response /show
SHOWCOMBATINFO(0x9BF1E5EA, ShowMsg.class, ShowMsgHandler.class), // Request/Response /show
SHOWVAULTINVENTORY(0xD1FB4842, null, null), // Show Vault Inventory
SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, SocialMsgHandler.class), // Socials
STANDARDALERT(0xFA0A24BB, ErrorPopupMsg.class, null), //Popup messages

72
src/engine/net/client/handlers/ShowMsgHandler.java

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.Enum;
import engine.Enum.DispatchChannel;
import engine.exception.MsgSendException;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.ShowMsg;
import engine.objects.AbstractCharacter;
import engine.objects.Mob;
import engine.objects.NPC;
import engine.objects.PlayerCharacter;
public class ShowMsgHandler extends AbstractClientMsgHandler {
public ShowMsgHandler() {
super(ShowMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
// Member variable declaration
ShowMsg msg;
// Member variable assignment
msg = (ShowMsg) baseMsg;
if (playerCharacter == null)
return true;
int targetType = msg.getTargetType();
AbstractCharacter tar = null;
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal())
tar = PlayerCharacter.getFromCache(msg.getTargetID());
else if (targetType == Enum.GameObjectType.NPC.ordinal())
tar = NPC.getFromCache(msg.getTargetID());
else if (targetType == Enum.GameObjectType.Mob.ordinal())
tar = Mob.getFromCache(msg.getTargetID());
if (tar == null || !tar.isAlive() || !tar.isActive())
return true;
msg.setUnknown01(playerCharacter.getLoc());
msg.setUnknown02(playerCharacter.getLoc());
msg.setRange01(playerCharacter.getRange());
msg.setUnknown03(tar.getLoc());
msg.setUnknown04(tar.getLoc());
msg.setRange01(tar.getRange());
Dispatch dispatch = Dispatch.borrow(playerCharacter, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
return true;
}
}
Loading…
Cancel
Save