Browse Source

Handler created for PetCmdMsg

combat-2
MagicBot 8 months ago
parent
commit
5a1806d11b
  1. 50
      src/engine/net/client/ClientMessagePump.java
  2. 2
      src/engine/net/client/Protocol.java
  3. 84
      src/engine/net/client/handlers/PetCmdMsgHandler.java

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

@ -11,7 +11,6 @@ package engine.net.client;
import engine.Enum.DispatchChannel; import engine.Enum.DispatchChannel;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.InterestManagement.WorldGrid;
import engine.exception.MsgSendException; import engine.exception.MsgSendException;
import engine.gameManager.*; import engine.gameManager.*;
import engine.job.JobScheduler; import engine.job.JobScheduler;
@ -207,52 +206,6 @@ public class ClientMessagePump implements NetMsgHandler {
return; 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 //Handle RepairObject Window and RepairObject Requests
@Override @Override
@ -373,9 +326,6 @@ public class ClientMessagePump implements NetMsgHandler {
case ARCPETATTACK: case ARCPETATTACK:
petAttack((PetAttackMsg) msg, origin); petAttack((PetAttackMsg) msg, origin);
break; break;
case ARCPETCMD:
petCmd((PetCmdMsg) msg, origin);
break;
case CHANNELMUTE: case CHANNELMUTE:
break; break;
case KEEPALIVESERVERCLIENT: case KEEPALIVESERVERCLIENT:

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

@ -38,7 +38,7 @@ public enum Protocol {
ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, MineWindowChangeHandler.class), ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, MineWindowChangeHandler.class),
ARCOWNEDMINESLIST(0x59184455, ArcOwnedMinesListMsg.class, ArcOwnedMinesListHandler.class), ARCOWNEDMINESLIST(0x59184455, ArcOwnedMinesListMsg.class, ArcOwnedMinesListHandler.class),
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, PetCmdMsgHandler.class), // Stop ArcPetAttack, Toggle Assist, Toggle Rest
ARCPOWERPROJECTILE(0xA2312D3B, null, null), ARCPOWERPROJECTILE(0xA2312D3B, null, null),
ARCPROMPTRECALL(0xE3196B6E, PromptRecallMsg.class, PromptRecallMsgHandler.class), //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

84
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;
}
}
Loading…
Cancel
Save