|
|
@ -38,6 +38,79 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { |
|
|
|
super(ItemProductionMsg.class); |
|
|
|
super(ItemProductionMsg.class); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Member variable declaration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PlayerCharacter player; |
|
|
|
|
|
|
|
NPC vendorNPC; |
|
|
|
|
|
|
|
ItemProductionMsg msg; |
|
|
|
|
|
|
|
Dispatch dispatch; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Member variable assignment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
msg = (ItemProductionMsg) baseMsg; |
|
|
|
|
|
|
|
player = origin.getPlayerCharacter(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (player == null) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Grab reference to vendor we are interacting with
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendorNPC = (NPC) DbManager.getObject(mbEnums.GameObjectType.NPC, msg.npcUUID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Oops?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (vendorNPC == null) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Process Request
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (msg.actionType) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case PRODUCE: |
|
|
|
|
|
|
|
boolean isRandom = false; |
|
|
|
|
|
|
|
if (msg.unknown03 != 0 && msg.pToken == 0 && msg.sToken == 0) |
|
|
|
|
|
|
|
isRandom = true; |
|
|
|
|
|
|
|
//Create Multiple Item Function.. Fill all empty slots
|
|
|
|
|
|
|
|
if (msg.size > 0) { |
|
|
|
|
|
|
|
int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size(); |
|
|
|
|
|
|
|
if (emptySlots > 0) { |
|
|
|
|
|
|
|
for (int i = 0; i < emptySlots; i++) { |
|
|
|
|
|
|
|
vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case JUNK: |
|
|
|
|
|
|
|
junkItem(msg.templateID, vendorNPC, origin); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case RECYCLE: |
|
|
|
|
|
|
|
recycleItem(msg.items, vendorNPC, origin); |
|
|
|
|
|
|
|
msg.actionType = mbEnums.ProductionActionType.TAKE; |
|
|
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg); |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case COMPLETE: |
|
|
|
|
|
|
|
vendorNPC.completeItem(msg.templateID); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case DEPOSIT: |
|
|
|
|
|
|
|
depositItem(msg.templateID, vendorNPC, origin); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case SETPRICE: |
|
|
|
|
|
|
|
setItemPrice(msg.itemType, msg.templateID, msg.itemPrice, vendorNPC, origin); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case TAKE: |
|
|
|
|
|
|
|
takeItem(msg.items, vendorNPC, origin); |
|
|
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg); |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { |
|
|
|
private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { |
|
|
|
|
|
|
|
|
|
|
|
Item targetItem; |
|
|
|
Item targetItem; |
|
|
@ -323,86 +396,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { |
|
|
|
|
|
|
|
|
|
|
|
player.charItemManager.updateInventory(); |
|
|
|
player.charItemManager.updateInventory(); |
|
|
|
|
|
|
|
|
|
|
|
// Update NPC inventory to client
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Method removes item from an NPC's inventory and transferes it to a player
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Member variable declaration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PlayerCharacter player; |
|
|
|
|
|
|
|
NPC vendorNPC; |
|
|
|
|
|
|
|
ItemProductionMsg msg; |
|
|
|
|
|
|
|
Dispatch dispatch; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Member variable assignment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
msg = (ItemProductionMsg) baseMsg; |
|
|
|
|
|
|
|
player = origin.getPlayerCharacter(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (player == null) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Grab reference to vendor we are interacting with
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendorNPC = (NPC) DbManager.getObject(mbEnums.GameObjectType.NPC, msg.npcUUID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Oops?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (vendorNPC == null) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Process Request
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (msg.actionType) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case PRODUCE: |
|
|
|
|
|
|
|
boolean isRandom = false; |
|
|
|
|
|
|
|
if (msg.unknown03 != 0 && msg.pToken == 0 && msg.sToken == 0) |
|
|
|
|
|
|
|
isRandom = true; |
|
|
|
|
|
|
|
//Create Multiple Item Function.. Fill all empty slots
|
|
|
|
|
|
|
|
if (msg.size > 0) { |
|
|
|
|
|
|
|
int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size(); |
|
|
|
|
|
|
|
if (emptySlots > 0) { |
|
|
|
|
|
|
|
for (int i = 0; i < emptySlots; i++) { |
|
|
|
|
|
|
|
vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case JUNK: |
|
|
|
|
|
|
|
junkItem(msg.templateID, vendorNPC, origin); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case RECYCLE: |
|
|
|
|
|
|
|
recycleItem(msg.items, vendorNPC, origin); |
|
|
|
|
|
|
|
msg.actionType = mbEnums.ProductionActionType.TAKE; |
|
|
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg); |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case COMPLETE: |
|
|
|
|
|
|
|
vendorNPC.completeItem(msg.templateID); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case DEPOSIT: |
|
|
|
|
|
|
|
depositItem(msg.templateID, vendorNPC, origin); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case SETPRICE: |
|
|
|
|
|
|
|
setItemPrice(msg.itemType, msg.templateID, msg.itemPrice, vendorNPC, origin); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case TAKE: |
|
|
|
|
|
|
|
takeItem(msg.items, vendorNPC, origin); |
|
|
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg); |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Method handles rolling item requests from the client
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|