* transformation
* @return L2ItemInstance corresponding to the new item or the updated item in inventory
*/
public L2ItemInstance addItem(String process, int itemId, int count, L2PcInstance actor, L2Object reference)
{
L2ItemInstance item = getItemByItemId(itemId);
// If stackable item is found in inventory just add to current quantity
if(item != null && item.isStackable())
{
item.changeCount(process, count, actor, reference);
item.setLastChange(L2ItemInstance.MODIFIED);
// Updates database
if(itemId == 57 && count < 10000 * Config.RATE_DROP_ADENA)
{
// Small adena changes won't be saved to database all the time
if(GameTimeController.getGameTicks() % 5 == 0)
{
item.updateDatabase();
}
}
else
{
item.updateDatabase();
}
}
// If item hasn't be found in inventory, create new one
else
{
for(int i = 0; i < count; i++)
{
L2Item template = ItemTable.getInstance().getTemplate(itemId);
if(template == null)
{
_log.log(Level.WARNING, (actor != null ? "[" + actor.getName() + "] " : "") + "Invalid ItemId requested: ", itemId);
return null;
}
item = ItemTable.getInstance().createItem(process, itemId, template.isStackable() ? count : 1, actor, reference);
item.setOwnerId(getOwnerId());
if(process.equals("AutoLoot")){
item.setLocation(ItemLocation.INVENTORY);
}else
item.setLocation(getBaseLocation());
item.setLastChange(L2ItemInstance.ADDED);
// Add item in inventory
addItem(item);
// Updates database
item.updateDatabase();
// If stackable, end loop as entire count is included in 1 instance of item
if(template.isStackable() || !Config.MULTIPLE_ITEM_DROP)
{
break;