Difference between revisions of "User:DavidJCobb/Stack dumping"

m
→‎Events that can trigger large numbers of suspended stacks: OnHit's concurrency has been experimentally verified. Item events' consecutive...ness... has not.
imported>DavidJCobb
imported>DavidJCobb
m (→‎Events that can trigger large numbers of suspended stacks: OnHit's concurrency has been experimentally verified. Item events' consecutive...ness... has not.)
Line 29: Line 29:
** Consider the case of an encounter between a player and five bandits, each of which takes four to seven hits to kill, and each of which has an OnHit event handler. Without an enchanted weapon, the player will generate 20 to 35 OnHit events to kill the bandits. If the player's weapon has two enchantments, she will generate 60 to 105 OnHit events. Meanwhile, the bandits will generate many OnHit events on the player (who can heal herself). The problem can quickly balloon out of control.
** Consider the case of an encounter between a player and five bandits, each of which takes four to seven hits to kill, and each of which has an OnHit event handler. Without an enchanted weapon, the player will generate 20 to 35 OnHit events to kill the bandits. If the player's weapon has two enchantments, she will generate 60 to 105 OnHit events. Meanwhile, the bandits will generate many OnHit events on the player (who can heal herself). The problem can quickly balloon out of control.
*** Incidentally, there's an area in Pinewatch where you can end up fighting five or six bandits all at once. It's also possible to obtain a sword with two enchantments very early in the game, courtesy of Meridia.
*** Incidentally, there's an area in Pinewatch where you can end up fighting five or six bandits all at once. It's also possible to obtain a sword with two enchantments very early in the game, courtesy of Meridia.
** OnHit can run concurrently with itself, so (ignoring outside influences) OnHit stacks should only be suspended if too many of them are generated too quickly.
* '''[[OnItemAdded - ObjectReference|OnItemAdded]] and [[OnItemRemoved - ObjectReference|OnItemRemoved]]''' can generate a large number of suspended stacks if no [[AddInventoryEventFilter - ObjectReference|inventory event filter]] is used. The player can transfer large masses of items (e.g. in their home), for example.
* '''[[OnItemAdded - ObjectReference|OnItemAdded]] and [[OnItemRemoved - ObjectReference|OnItemRemoved]]''' can generate a large number of suspended stacks if no [[AddInventoryEventFilter - ObjectReference|inventory event filter]] is used. The player can transfer large masses of items (e.g. in their home), for example.
** Even batch operations, like RemoveAllItems(), can cause stack dumping. One stack is generated for every type of item transferred, and inventory events can't run concurrently with themselves, so all but one of those stacks will be suspended the instant it is created.
** Even batch operations, like RemoveAllItems(), can cause stack dumping. One stack is generated for every type of item transferred, and inventory events can't run concurrently with themselves, so all but one of those stacks will be suspended the instant it is created.
*** Friendly reminder: built-in, Bethesda-authored content calls RemoveAllItems() on the player. Diplomatic Immunity, The Forsworn Conspiracy, The Mind of Madness, Restoration Ritual Spell, and Unbound all remove the player's inventory at some point.
*** Friendly reminder: built-in, Bethesda-authored content calls RemoveAllItems() on the player. Diplomatic Immunity, The Forsworn Conspiracy, The Mind of Madness, Restoration Ritual Spell, and Unbound all remove the player's inventory at some point.
** For OnItemAdded and OnItemRemoved, I list some additional methods for avoiding stack dumping [[Talk:OnItemAdded - ObjectReference#Facts about OnItemAdded|here]].
** For OnItemAdded and OnItemRemoved, I list some additional methods for avoiding stack dumping [[Talk:OnItemAdded - ObjectReference#Facts about OnItemAdded|here]].
** OnItemAdded and OnItemRemoved don't appear to be able to run concurrently with themselves, so their stacks will be suspended as a matter of course.


== Things to investigate ==
== Things to investigate ==
Anonymous user