forked from MagicBane/Server
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.
83 lines
2.6 KiB
83 lines
2.6 KiB
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . |
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· |
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ |
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ |
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ |
|
// Magicbane Emulator Project © 2013 - 2022 |
|
// www.magicbane.com |
|
|
|
package engine.net.client.handlers; |
|
|
|
import engine.InterestManagement.WorldGrid; |
|
import engine.gameManager.DispatchManager; |
|
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(); |
|
} |
|
|
|
@Override |
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) { |
|
|
|
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); |
|
DispatchManager.sendToAllInRange(pet, rwss); |
|
} |
|
|
|
return true; |
|
} |
|
|
|
} |