You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.5 KiB
71 lines
2.5 KiB
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . |
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· |
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ |
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ |
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ |
|
// Magicbane Emulator Project © 2013 - 2022 |
|
// www.magicbane.com |
|
|
|
package engine.net.client.handlers; |
|
|
|
import engine.gameManager.BuildingManager; |
|
import engine.mbEnums; |
|
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(); |
|
} |
|
|
|
@Override |
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) { |
|
|
|
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 ((playerCharacter.inSafeZone()) |
|
&& (msg.getTargetType() == mbEnums.GameObjectType.PlayerCharacter.ordinal())) |
|
return true; |
|
|
|
if (msg.getTargetType() == mbEnums.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; |
|
} |
|
|
|
} |