Browse Source

Handler created for PetAttackMsg

combat-2
MagicBot 8 months ago
parent
commit
56bc38ab73
  1. 46
      src/engine/net/client/ClientMessagePump.java
  2. 2
      src/engine/net/client/Protocol.java
  3. 75
      src/engine/net/client/handlers/PetAttackMsgHandler.java

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

@ -9,15 +9,11 @@ @@ -9,15 +9,11 @@
package engine.net.client;
import engine.Enum.GameObjectType;
import engine.exception.MsgSendException;
import engine.gameManager.*;
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.Mob;
import engine.objects.PlayerCharacter;
import engine.server.world.WorldServer;
import engine.session.Session;
import engine.util.StringUtils;
@ -40,45 +36,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -40,45 +36,6 @@ public class ClientMessagePump implements NetMsgHandler {
this.server = server;
}
protected static void petAttack(PetAttackMsg 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 ((pc.inSafeZone())
&& (msg.getTargetType() == GameObjectType.PlayerCharacter.ordinal()))
return;
//CombatManager.setAttackTarget(msg, conn);
if (msg.getTargetType() == GameObjectType.Building.ordinal()) {
conn.getPlayerCharacter().getPet().setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
}
switch (msg.getTargetType()) {
case 53: //player character
conn.getPlayerCharacter().getPet().setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
break;
case 37://mob
conn.getPlayerCharacter().getPet().setCombatTarget(Mob.getMob(msg.getTargetID()));
break;
case 8://mob
conn.getPlayerCharacter().getPet().setCombatTarget(BuildingManager.getBuilding(msg.getTargetID()));
break;
}
if (pet.getCombatTarget() == null)
return;
}
//Handle RepairObject Window and RepairObject Requests
@Override
@ -184,9 +141,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -184,9 +141,6 @@ public class ClientMessagePump implements NetMsgHandler {
case STUCK:
MovementManager.stuck(origin);
break;
case ARCPETATTACK:
petAttack((PetAttackMsg) msg, origin);
break;
case CHANNELMUTE:
break;
case KEEPALIVESERVERCLIENT:

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

@ -37,7 +37,7 @@ public enum Protocol { @@ -37,7 +37,7 @@ public enum Protocol {
ARCMINEWINDOWAVAILABLETIME(0x6C909DE7, ArcMineWindowAvailableTimeMsg.class, ArcMineWindowAvailableTimeHandler.class),
ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, MineWindowChangeHandler.class),
ARCOWNEDMINESLIST(0x59184455, ArcOwnedMinesListMsg.class, ArcOwnedMinesListHandler.class),
ARCPETATTACK(0x18CD61AD, PetAttackMsg.class, null), // Pet Attack
ARCPETATTACK(0x18CD61AD, PetAttackMsg.class, PetAttackMsgHandler.class), // Pet Attack
ARCPETCMD(0x4E80E001, PetCmdMsg.class, PetCmdMsgHandler.class), // Stop ArcPetAttack, Toggle Assist, Toggle Rest
ARCPOWERPROJECTILE(0xA2312D3B, null, null),
ARCPROMPTRECALL(0xE3196B6E, PromptRecallMsg.class, PromptRecallMsgHandler.class), //Recall Prompt

75
src/engine/net/client/handlers/PetAttackMsgHandler.java

@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.Enum;
import engine.exception.MsgSendException;
import engine.gameManager.BuildingManager;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.PetAttackMsg;
import engine.objects.Mob;
import engine.objects.PlayerCharacter;
public class PetAttackMsgHandler extends AbstractClientMsgHandler {
public PetAttackMsgHandler() {
super(PetAttackMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
// Member variable declaration
PetAttackMsg msg;
// Member variable assignment
msg = (PetAttackMsg) baseMsg;
if (playerCharacter == null)
return true;
Mob pet = playerCharacter.getPet();
if (pet == null)
return true;
if (!pet.isAlive())
return true;
if (pet.getCombatTarget() == null)
return true;
if ((playerCharacter.inSafeZone())
&& (msg.getTargetType() == Enum.GameObjectType.PlayerCharacter.ordinal()))
return true;
if (msg.getTargetType() == Enum.GameObjectType.Building.ordinal())
pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
switch (msg.getTargetType()) {
case 53: //player character
pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
break;
case 37://mob
pet.setCombatTarget(Mob.getMob(msg.getTargetID()));
break;
case 8://mob
pet.setCombatTarget(BuildingManager.getBuilding(msg.getTargetID()));
break;
}
return true;
}
}
Loading…
Cancel
Save