Browse Source

Handler created for equip to inventory message.

combat-2
MagicBot 8 months ago
parent
commit
3500bf0ede
  1. 60
      src/engine/net/client/ClientMessagePump.java
  2. 2
      src/engine/net/client/Protocol.java
  3. 100
      src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java

60
src/engine/net/client/ClientMessagePump.java

@ -9,7 +9,6 @@
package engine.net.client; package engine.net.client;
import engine.Enum;
import engine.Enum.*; import engine.Enum.*;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.exception.MsgSendException; import engine.exception.MsgSendException;
@ -156,62 +155,6 @@ public class ClientMessagePump implements NetMsgHandler {
DispatchMessage.dispatchMsgToInterestArea(pc, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, true); DispatchMessage.dispatchMsgToInterestArea(pc, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, true);
} }
private static void TransferItemFromEquipToInventory(TransferItemFromEquipToInventoryMsg msg, ClientConnection origin) {
PlayerCharacter pc = origin.getPlayerCharacter();
if (pc == null)
return;
CharacterItemManager itemManager = pc.getCharItemManager();
if (itemManager == null)
return;
Enum.EquipSlotType slot = msg.slot;
Item i = itemManager.getItemFromEquipped(slot);
if (i == null)
return;
if (!itemManager.doesCharOwnThisItem(i.getObjectUUID()))
return;
//dupe check
if (!i.validForEquip(origin, pc, itemManager))
return;
if (i.containerType == ItemContainerType.EQUIPPED)
itemManager.moveItemToInventory(i);
int ItemType = i.getObjectType().ordinal();
int ItemID = i.getObjectUUID();
for (String name : i.getEffects().keySet()) {
Effect eff = i.getEffects().get(name);
if (eff == null)
return;
ApplyEffectMsg pum = new ApplyEffectMsg();
pum.setEffectID(eff.getEffectToken());
pum.setSourceType(pc.getObjectType().ordinal());
pum.setSourceID(pc.getObjectUUID());
pum.setTargetType(pc.getObjectType().ordinal());
pum.setTargetID(pc.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(pc, pum, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
;
}
// Update player formulas
pc.applyBonuses();
DispatchMessage.dispatchMsgToInterestArea(pc, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
}
public static Boolean NPCVaultBankRangeCheck(PlayerCharacter pc, ClientConnection origin, String bankorvault) { public static Boolean NPCVaultBankRangeCheck(PlayerCharacter pc, ClientConnection origin, String bankorvault) {
if (pc == null) if (pc == null)
@ -1831,9 +1774,6 @@ public class ClientMessagePump implements NetMsgHandler {
case IGNORE: case IGNORE:
((IgnoreMsg) msg).handleRequest(origin); ((IgnoreMsg) msg).handleRequest(origin);
break; break;
case UNEQUIP:
TransferItemFromEquipToInventory((TransferItemFromEquipToInventoryMsg) msg, origin);
break;
case DELETEOBJECT: case DELETEOBJECT:
DeleteItem((DeleteItemMsg) msg, origin); DeleteItem((DeleteItemMsg) msg, origin);
break; break;

2
src/engine/net/client/Protocol.java

@ -226,7 +226,7 @@ public enum Protocol {
TRANSFERITEMFROMBANK(0x9D04977B, TransferItemFromBankToInventoryMsg.class, null), // Transfer Item from Bank to Inventory TRANSFERITEMFROMBANK(0x9D04977B, TransferItemFromBankToInventoryMsg.class, null), // Transfer Item from Bank to Inventory
TRANSFERITEMFROMVAULTTOINVENTORY(0x0119A64D, TransferItemFromVaultToInventoryMsg.class, null), // Transfer Item from Vault to Inventory TRANSFERITEMFROMVAULTTOINVENTORY(0x0119A64D, TransferItemFromVaultToInventoryMsg.class, null), // Transfer Item from Vault to Inventory
TRANSFERITEMTOBANK(0xD48C46FA, TransferItemFromInventoryToBankMsg.class, null), // Transfer Item from Inventory to Bank TRANSFERITEMTOBANK(0xD48C46FA, TransferItemFromInventoryToBankMsg.class, null), // Transfer Item from Inventory to Bank
UNEQUIP(0xC6BFB907, TransferItemFromEquipToInventoryMsg.class, null), // Transfer Item from Equip to Inventory UNEQUIP(0xC6BFB907, TransferItemFromEquipToInventoryMsg.class, TransferItemFromEquipToInventoryHandler.class), // Transfer Item from Equip to Inventory
UNKNOWN(0x238C9259, UnknownMsg.class, null), UNKNOWN(0x238C9259, UnknownMsg.class, null),
UPDATECHARORMOB(0xB6D78961, null, null), UPDATECHARORMOB(0xB6D78961, null, null),
UPDATECLIENTALLIANCES(0xF3FEB5D4, null, GuildUnknownHandler.class), //AlliancesMsg UPDATECLIENTALLIANCES(0xF3FEB5D4, null, GuildUnknownHandler.class), //AlliancesMsg

100
src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java

@ -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…
Cancel
Save