MagicBot
8 months ago
3 changed files with 85 additions and 51 deletions
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.InterestManagement.WorldGrid; |
||||
import engine.exception.MsgSendException; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.PetCmdMsg; |
||||
import engine.net.client.msg.UpdateStateMsg; |
||||
import engine.objects.Mob; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class PetCmdMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public PetCmdMsgHandler() { |
||||
super(PetCmdMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
PetCmdMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (PetCmdMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
Mob pet = playerCharacter.getPet(); |
||||
|
||||
if (pet == null) |
||||
return true; |
||||
|
||||
if (!pet.isAlive()) |
||||
return true; |
||||
|
||||
//if (pet.state == STATE.Disabled)
|
||||
// return;
|
||||
|
||||
int type = msg.getType(); |
||||
|
||||
if (type == 1) { //stop attack
|
||||
pet.setCombatTarget(null); |
||||
playerCharacter.setCombat(false); |
||||
|
||||
} else if (type == 2) { //dismiss
|
||||
pet.dismiss(); |
||||
playerCharacter.dismissPet(); |
||||
|
||||
if (pet.isAlive()) |
||||
WorldGrid.updateObject(pet); |
||||
} else if (type == 3) //toggle assist
|
||||
pet.toggleAssist(); |
||||
else if (type == 5) { //rest
|
||||
boolean sit = (!(pet.isSit())); |
||||
pet.setSit(sit); |
||||
|
||||
// cancel effects that break on sit
|
||||
if (pet.isSit()) |
||||
pet.cancelOnSit(); |
||||
|
||||
UpdateStateMsg rwss = new UpdateStateMsg(); |
||||
rwss.setPlayer(pet); |
||||
DispatchMessage.sendToAllInRange(pet, rwss); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue