MagicBot
8 months ago
3 changed files with 101 additions and 61 deletions
@ -0,0 +1,100 @@
@@ -0,0 +1,100 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ApplyEffectMsg; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.TransferItemFromEquipToInventoryMsg; |
||||
import engine.objects.CharacterItemManager; |
||||
import engine.objects.Effect; |
||||
import engine.objects.Item; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
|
||||
public class TransferItemFromEquipToInventoryHandler extends AbstractClientMsgHandler { |
||||
|
||||
public TransferItemFromEquipToInventoryHandler() { |
||||
super(TransferItemFromEquipToInventoryMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter(); |
||||
|
||||
if (player == null) |
||||
return true; |
||||
|
||||
TransferItemFromEquipToInventoryMsg msg = (TransferItemFromEquipToInventoryMsg) baseMsg; |
||||
|
||||
CharacterItemManager itemManager = player.getCharItemManager(); |
||||
|
||||
if (itemManager == null) |
||||
return true; |
||||
|
||||
Enum.EquipSlotType slot = msg.slot; |
||||
|
||||
Item item = itemManager.getItemFromEquipped(slot); |
||||
|
||||
if (item == null) |
||||
return true; |
||||
|
||||
if (!itemManager.doesCharOwnThisItem(item.getObjectUUID())) |
||||
return true; |
||||
|
||||
//dupe check
|
||||
|
||||
if (!item.validForEquip(origin, player, itemManager)) |
||||
return true; |
||||
|
||||
if (item.containerType == Enum.ItemContainerType.EQUIPPED) |
||||
itemManager.moveItemToInventory(item); |
||||
|
||||
int ItemType = item.getObjectType().ordinal(); |
||||
int ItemID = item.getObjectUUID(); |
||||
|
||||
for (String name : item.getEffects().keySet()) { |
||||
|
||||
Effect eff = item.getEffects().get(name); |
||||
|
||||
if (eff == null) |
||||
return true; |
||||
|
||||
ApplyEffectMsg pum = new ApplyEffectMsg(); |
||||
|
||||
pum.setEffectID(eff.getEffectToken()); |
||||
pum.setSourceType(player.getObjectType().ordinal()); |
||||
pum.setSourceID(player.getObjectUUID()); |
||||
pum.setTargetType(player.getObjectType().ordinal()); |
||||
pum.setTargetID(player.getObjectUUID()); |
||||
pum.setNumTrains(eff.getTrains()); |
||||
pum.setUnknown05(1); |
||||
pum.setUnknown02(2); |
||||
pum.setUnknown06((byte) 1); |
||||
pum.setEffectSourceType(ItemType); |
||||
pum.setEffectSourceID(ItemID); |
||||
pum.setDuration(-1); |
||||
|
||||
DispatchMessage.dispatchMsgToInterestArea(player, pum, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); |
||||
|
||||
} |
||||
|
||||
// Update player formulas
|
||||
player.applyBonuses(); |
||||
DispatchMessage.dispatchMsgToInterestArea(player, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue