Inventory Stack Underflow

Trick Summary
The inventory stack underflow works by reducing the number of items in a stack in the inventory past zero in order that the stack count wraps around to a very large number.

Games It Works In
Baldur's Gate I - Yes

Baldur's Gate II - Yes

Icewind Dale I - Yes (without Heart Of Winter installed)

Icewind Dale II - Yes

Planescape Torment - ?

Method And Explanation
There are two variants of this trick. The first one works in games which don't pause the game while in the inventory and the second works in game which do pause the game while in the inventory. Baldur's Gate I and Icewind Dale I

Potions

Open the inventory and drink any potion (not the one you want to dupe). Then drink the potion you want to dupe and pick it up so that it floats. After a few seconds the stack count of the floating potion is reduced. Then quickly drop the floating potion in the inventory, drink it and pick it up again. The stack count will wrap around to 65535. You can also put the potion into the inventory of another party member instead of keeping it floating in the inventory, with the same effect.

Scrolls

Cast the scroll, quickly open the inventory and pick up the scroll while it's still being casted. Repeat this to produce the underflow.

Note: this only works sometimes in vanilla Baldur's Gate (without ToSC installed). This is because drinking potions from the inventory is broken and works only occasionally. Though because the drink potion is a bit slower than with TOSC installed you can dupe a potion without having performed an action the round before, saving 6 seconds.

Baldur's Gate II and Icewind Dale II

In Throne Of Bhaal, this can only be used on stackable non-consumables. To execute the trick, right-click on a potion in the inventory, select 'Drink Potion', then swap a gem into the inventory slot the potion was in. Return to the game and wait a round. The gem will be consumed, reducing the number in the stack to zero. Repeat this process to reduce it further, wrapping it around to 65535.

Wands that are not destroyed upon reaching 0 charges can be wrapped around to 65535 charges in this way. However potions, scrolls, missiles, and wands that are destroyed at zero charges will be used up by this trick.

Note that the technique of choosing 'Drink Potion' and then swapping items in the inventory is also used in the Use Any Item's Abilities glitch.

For Icewind Dale II make sure that the game is paused in the inventory. To do this either hit space before entering the inventory or use the button in the lower right of the UI while in the inventory.

Notable Speedrunning Applications

 * Duplicating gems near the start of Baldur's Gate II and selling them to immediately gain the 15000GP needed to pay Bodhi or Gaelan.
 * Duplicating potions and scrolls in any of the current Baldur's Gate and Icewind Dale runs.

Videos
thumb|425px|left|potion duping in BG thumb|425px|left|scroll duping in BG