MagicBot
8 months ago
3 changed files with 73 additions and 42 deletions
@ -0,0 +1,72 @@ |
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers; |
||||||
|
|
||||||
|
import engine.Enum; |
||||||
|
import engine.Enum.DispatchChannel; |
||||||
|
import engine.exception.MsgSendException; |
||||||
|
import engine.net.Dispatch; |
||||||
|
import engine.net.DispatchMessage; |
||||||
|
import engine.net.client.ClientConnection; |
||||||
|
import engine.net.client.msg.ClientNetMsg; |
||||||
|
import engine.net.client.msg.ShowMsg; |
||||||
|
import engine.objects.AbstractCharacter; |
||||||
|
import engine.objects.Mob; |
||||||
|
import engine.objects.NPC; |
||||||
|
import engine.objects.PlayerCharacter; |
||||||
|
|
||||||
|
public class ShowMsgHandler extends AbstractClientMsgHandler { |
||||||
|
|
||||||
|
public ShowMsgHandler() { |
||||||
|
super(ShowMsg.class); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
ShowMsg msg; |
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (ShowMsg) baseMsg; |
||||||
|
|
||||||
|
if (playerCharacter == null) |
||||||
|
return true; |
||||||
|
|
||||||
|
int targetType = msg.getTargetType(); |
||||||
|
AbstractCharacter tar = null; |
||||||
|
|
||||||
|
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal()) |
||||||
|
tar = PlayerCharacter.getFromCache(msg.getTargetID()); |
||||||
|
else if (targetType == Enum.GameObjectType.NPC.ordinal()) |
||||||
|
tar = NPC.getFromCache(msg.getTargetID()); |
||||||
|
else if (targetType == Enum.GameObjectType.Mob.ordinal()) |
||||||
|
tar = Mob.getFromCache(msg.getTargetID()); |
||||||
|
|
||||||
|
if (tar == null || !tar.isAlive() || !tar.isActive()) |
||||||
|
return true; |
||||||
|
|
||||||
|
msg.setUnknown01(playerCharacter.getLoc()); |
||||||
|
msg.setUnknown02(playerCharacter.getLoc()); |
||||||
|
msg.setRange01(playerCharacter.getRange()); |
||||||
|
msg.setUnknown03(tar.getLoc()); |
||||||
|
msg.setUnknown04(tar.getLoc()); |
||||||
|
msg.setRange01(tar.getRange()); |
||||||
|
|
||||||
|
Dispatch dispatch = Dispatch.borrow(playerCharacter, msg); |
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue