MagicBot
8 months ago
5 changed files with 118 additions and 12 deletions
@ -0,0 +1,57 @@ |
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers; |
||||||
|
|
||||||
|
import engine.Enum; |
||||||
|
import engine.exception.MsgSendException; |
||||||
|
import engine.net.DispatchMessage; |
||||||
|
import engine.net.client.ClientConnection; |
||||||
|
import engine.net.client.msg.ClientNetMsg; |
||||||
|
import engine.net.client.msg.SetCombatModeMsg; |
||||||
|
import engine.net.client.msg.UpdateStateMsg; |
||||||
|
import engine.objects.PlayerCharacter; |
||||||
|
import engine.server.MBServerStatics; |
||||||
|
|
||||||
|
public class SetCombatModeMsgHandler extends AbstractClientMsgHandler { |
||||||
|
|
||||||
|
public SetCombatModeMsgHandler() { |
||||||
|
super(SetCombatModeMsg.class); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
SetCombatModeMsg msg; |
||||||
|
boolean toggle; |
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (SetCombatModeMsg) baseMsg; |
||||||
|
|
||||||
|
if (playerCharacter == null) |
||||||
|
return true; |
||||||
|
|
||||||
|
toggle = msg.getToggle(); |
||||||
|
playerCharacter.setCombat(toggle); |
||||||
|
|
||||||
|
if (!toggle) // toggle is move it to false so clear combat target
|
||||||
|
playerCharacter.setCombatTarget(null); //clear last combat target
|
||||||
|
|
||||||
|
UpdateStateMsg rwss = new UpdateStateMsg(); |
||||||
|
rwss.setPlayer(playerCharacter); |
||||||
|
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers; |
||||||
|
|
||||||
|
import engine.Enum; |
||||||
|
import engine.exception.MsgSendException; |
||||||
|
import engine.net.DispatchMessage; |
||||||
|
import engine.net.client.ClientConnection; |
||||||
|
import engine.net.client.msg.ClientNetMsg; |
||||||
|
import engine.net.client.msg.ToggleCombatMsg; |
||||||
|
import engine.net.client.msg.UpdateStateMsg; |
||||||
|
import engine.objects.PlayerCharacter; |
||||||
|
import engine.server.MBServerStatics; |
||||||
|
|
||||||
|
public class ToggleCombatMsgHandler extends AbstractClientMsgHandler { |
||||||
|
|
||||||
|
public ToggleCombatMsgHandler() { |
||||||
|
super(ToggleCombatMsg.class); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
ToggleCombatMsg msg; |
||||||
|
boolean toggle; |
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (ToggleCombatMsg) baseMsg; |
||||||
|
|
||||||
|
if (playerCharacter == null) |
||||||
|
return true; |
||||||
|
|
||||||
|
toggle = msg.toggleCombat(); |
||||||
|
playerCharacter.setCombat(toggle); |
||||||
|
|
||||||
|
if (!toggle) // toggle is move it to false so clear combat target
|
||||||
|
playerCharacter.setCombatTarget(null); //clear last combat target
|
||||||
|
|
||||||
|
UpdateStateMsg rwss = new UpdateStateMsg(); |
||||||
|
rwss.setPlayer(playerCharacter); |
||||||
|
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue