public static IItemsContainer ServerTryDropOnGroundContainerContent(Tile tile, IItemsContainer otherContainer) { var otherContainerOccupiedSlotsCount = otherContainer.OccupiedSlotsCount; if (otherContainerOccupiedSlotsCount == 0) { // nothing to drop there return(null); } var groundContainer = ServerTryGetOrCreateGroundContainerAtTileOrNeighbors(forCharacter: null, tile); if (groundContainer is null) { // cannot drop items there return(null); } ServerItems.TryMoveAllItems( containerFrom: otherContainer, containerTo: groundContainer); SharedLootDropNotifyHelper.ServerOnLootDropped(groundContainer); return(groundContainer); }
public static IItemsContainer ServerTryDropOnGroundContainerContent(Tile tile, IItemsContainer otherContainer) { var otherContainerOccupiedSlotsCount = otherContainer.OccupiedSlotsCount; if (otherContainerOccupiedSlotsCount == 0) { // nothing to drop there return(null); } var groundContainer = ServerTryGetOrCreateGroundContainerAtTileOrNeighbors(tile); if (groundContainer == null) { // cannot drop items there return(null); } // change ground container type (prevent from placing new items there) ServerItemsService.SetContainerType <ItemsContainerOutputPublic>(groundContainer); // set exact slots count ServerItemsService.SetSlotsCount( groundContainer, (byte)Math.Min(byte.MaxValue, otherContainerOccupiedSlotsCount + groundContainer.OccupiedSlotsCount)); ServerItemsService.TryMoveAllItems( containerFrom: otherContainer, containerTo: groundContainer); SharedLootDropNotifyHelper.ServerOnLootDropped(groundContainer); return(groundContainer); }
public static IItemsContainer ServerTryDropOnGroundContainerContent( Tile tile, IItemsContainer otherContainer, double?destroyTimeout = null) { var otherContainerOccupiedSlotsCount = otherContainer?.OccupiedSlotsCount ?? 0; if (otherContainerOccupiedSlotsCount == 0) { // nothing to drop there return(null); } var groundContainer = ServerTryGetOrCreateGroundContainerAtTileOrNeighbors(forCharacter: null, tile); if (groundContainer is null) { // cannot drop items there return(null); } ServerItems.TryMoveAllItems( containerFrom: otherContainer, containerTo: groundContainer); SharedLootDropNotifyHelper.ServerOnLootDropped(groundContainer); if (destroyTimeout.HasValue) { ServerSetDestructionTimeout( (IStaticWorldObject)groundContainer.Owner, destroyTimeout.Value); } return(groundContainer); }
private static void DropPlayerLoot(ICharacter character) { var containerEquipment = character.SharedGetPlayerContainerEquipment(); var containerHand = character.SharedGetPlayerContainerHand(); var containerHotbar = character.SharedGetPlayerContainerHotbar(); var containerInventory = character.SharedGetPlayerContainerInventory(); if (PveSystem.ServerIsPvE) { // don't drop player loot on death in PvE Api.Logger.Important("Player character is dead - reduce durability for the equipped items", character); // process items and drop loot ProcessContainerItemsOnDeathInPvE(isEquipmentContainer: true, fromContainer: containerEquipment); ProcessContainerItemsOnDeathInPvE(isEquipmentContainer: false, fromContainer: containerHand); ProcessContainerItemsOnDeathInPvE(isEquipmentContainer: false, fromContainer: containerHotbar); ProcessContainerItemsOnDeathInPvE(isEquipmentContainer: false, fromContainer: containerInventory); return; } Api.Logger.Important("Player character is dead - drop loot", character); CraftingMechanics.ServerCancelCraftingQueue(character); var characterContainersOccupiedSlotsCount = containerEquipment.OccupiedSlotsCount + containerHand.OccupiedSlotsCount + containerHotbar.OccupiedSlotsCount + containerInventory.OccupiedSlotsCount; if (characterContainersOccupiedSlotsCount == 0) { Api.Logger.Important("No need to drop loot for dead character (no items to drop)", character); return; } var lootContainer = ObjectPlayerLootContainer.ServerTryCreateLootContainer(character); if (lootContainer is null) { Api.Logger.Error("Unable to drop loot for dead character", character); return; } // set slots count matching the total occupied slots count ServerItems.SetSlotsCount( lootContainer, (byte)characterContainersOccupiedSlotsCount); // process items and drop loot ProcessContainerItemsOnDeathInPvP(isEquipmentContainer: true, fromContainer: containerEquipment, toContainer: lootContainer); ProcessContainerItemsOnDeathInPvP(isEquipmentContainer: false, fromContainer: containerHand, toContainer: lootContainer); ProcessContainerItemsOnDeathInPvP(isEquipmentContainer: false, fromContainer: containerHotbar, toContainer: lootContainer); ProcessContainerItemsOnDeathInPvP(isEquipmentContainer: false, fromContainer: containerInventory, toContainer: lootContainer); if (lootContainer.OccupiedSlotsCount <= 0) { // nothing dropped, destroy the just spawned loot container ServerWorld.DestroyObject((IWorldObject)lootContainer.Owner); return; } // set exact slots count ServerItems.SetSlotsCount( lootContainer, (byte)lootContainer.OccupiedSlotsCount); SharedLootDropNotifyHelper.ServerOnLootDropped(lootContainer); // please note - no need to notify player about the dropped loot, it's automatically done by ClientDroppedItemsNotificationsManager }