MagicBot
8 months ago
3 changed files with 76 additions and 47 deletions
@ -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…
Reference in new issue