diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index be5270aa..894270b6 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -11,7 +11,6 @@ package engine.net.client; import engine.Enum.DispatchChannel; import engine.Enum.GameObjectType; -import engine.InterestManagement.WorldGrid; import engine.exception.MsgSendException; import engine.gameManager.*; import engine.job.JobScheduler; @@ -207,52 +206,6 @@ public class ClientMessagePump implements NetMsgHandler { return; } - protected static void petCmd(PetCmdMsg msg, ClientConnection conn) throws MsgSendException { - - PlayerCharacter pc = SessionManager.getPlayerCharacter(conn); - - if (pc == null) - return; - - Mob pet = pc.getPet(); - - if (pet == null) - return; - - if (!pet.isAlive()) - return; - - //if (pet.state == STATE.Disabled) - // return; - - int type = msg.getType(); - - if (type == 1) { //stop attack - pet.setCombatTarget(null); - pc.setCombat(false); - - } else if (type == 2) { //dismiss - pet.dismiss(); - pc.dismissPet(); - - if (pet.isAlive()) - WorldGrid.updateObject(pet); - } else if (type == 3) //toggle assist - pet.toggleAssist(); - else if (type == 5) { //rest - boolean sit = (!(pet.isSit())); - pet.setSit(sit); - - // cancel effects that break on sit - if (pet.isSit()) - pet.cancelOnSit(); - - UpdateStateMsg rwss = new UpdateStateMsg(); - rwss.setPlayer(pet); - DispatchMessage.sendToAllInRange(pet, rwss); - } - } - //Handle RepairObject Window and RepairObject Requests @Override @@ -373,9 +326,6 @@ public class ClientMessagePump implements NetMsgHandler { case ARCPETATTACK: petAttack((PetAttackMsg) msg, origin); break; - case ARCPETCMD: - petCmd((PetCmdMsg) msg, origin); - break; case CHANNELMUTE: break; case KEEPALIVESERVERCLIENT: diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index a7fb326e..e6031cc5 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -38,7 +38,7 @@ public enum Protocol { ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, MineWindowChangeHandler.class), ARCOWNEDMINESLIST(0x59184455, ArcOwnedMinesListMsg.class, ArcOwnedMinesListHandler.class), ARCPETATTACK(0x18CD61AD, PetAttackMsg.class, null), // Pet Attack - ARCPETCMD(0x4E80E001, PetCmdMsg.class, null), // Stop ArcPetAttack, Toggle Assist, Toggle Rest + ARCPETCMD(0x4E80E001, PetCmdMsg.class, PetCmdMsgHandler.class), // Stop ArcPetAttack, Toggle Assist, Toggle Rest ARCPOWERPROJECTILE(0xA2312D3B, null, null), ARCPROMPTRECALL(0xE3196B6E, PromptRecallMsg.class, PromptRecallMsgHandler.class), //Recall Prompt ARCREQUESTTRADEBUSY(0xD4BAB4DF, InvalidTradeRequestMsg.class, null), // Attempt trade with someone who is already trading diff --git a/src/engine/net/client/handlers/PetCmdMsgHandler.java b/src/engine/net/client/handlers/PetCmdMsgHandler.java new file mode 100644 index 00000000..3dcf8e42 --- /dev/null +++ b/src/engine/net/client/handlers/PetCmdMsgHandler.java @@ -0,0 +1,84 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.net.client.handlers; + +import engine.InterestManagement.WorldGrid; +import engine.exception.MsgSendException; +import engine.net.DispatchMessage; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.PetCmdMsg; +import engine.net.client.msg.UpdateStateMsg; +import engine.objects.Mob; +import engine.objects.PlayerCharacter; + +public class PetCmdMsgHandler extends AbstractClientMsgHandler { + + public PetCmdMsgHandler() { + super(PetCmdMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + PlayerCharacter playerCharacter = origin.getPlayerCharacter(); + + // Member variable declaration + + PetCmdMsg msg; + + // Member variable assignment + + msg = (PetCmdMsg) baseMsg; + + if (playerCharacter == null) + return true; + + Mob pet = playerCharacter.getPet(); + + if (pet == null) + return true; + + if (!pet.isAlive()) + return true; + + //if (pet.state == STATE.Disabled) + // return; + + int type = msg.getType(); + + if (type == 1) { //stop attack + pet.setCombatTarget(null); + playerCharacter.setCombat(false); + + } else if (type == 2) { //dismiss + pet.dismiss(); + playerCharacter.dismissPet(); + + if (pet.isAlive()) + WorldGrid.updateObject(pet); + } else if (type == 3) //toggle assist + pet.toggleAssist(); + else if (type == 5) { //rest + boolean sit = (!(pet.isSit())); + pet.setSit(sit); + + // cancel effects that break on sit + if (pet.isSit()) + pet.cancelOnSit(); + + UpdateStateMsg rwss = new UpdateStateMsg(); + rwss.setPlayer(pet); + DispatchMessage.sendToAllInRange(pet, rwss); + } + + return true; + } + +} \ No newline at end of file