Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extends the SE component with various Papyrus additions. #42

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sky-void0
Copy link

Synopsis

bool AddItemsBulk(Form[] items, int[] count, bool remove = false)
Adds to -or removes from- the container, count instances of the passed forms in a single operation. Mass addition/removal of items can also be achieved by the native AddItems if given a formlist as argument, but this will quickly send OnItemAdded notifications to all listeners, which can overwhelm the VM resulting in stack dumps and massive slowdowns. This function avoids that undesired side effect, and offers the added benefits of not requiring formlists and allowing fine tuning of the added/removed amounts.

int container.GetItemCountCached(Form item, bool refresh = false)
Upon the first call, the contents of the container are cached and subsequent calls simply retrieve the cached value without looking up the container. Much faster than the native GetItemCount. Intended for use when successive calls are required and the container's contents are known not to change.

int[] GetItemsCount(Form[] items]
Due to the frametime sync call overhead, GetItemCountCached is unsuitable for processing large arrays of items. This wrapper uses GetItemCountCached internally to processes an entire array in a single call and -usually- frame.

float RestoreItemCharge(Weapon wepn, bool all = false)
While there are other charge functions, this one works directly on forms inside containers. It restores and returns the missing charge of the first pertinent entry in the extradata list. Or all of them if all is true.

float GetDisplayValue(form item) native
There's already a function that returns a form's base value, however the final value can vary widely from this amount depending on enchantments, temper status and other factors. This function returns the real display value, as shown on the UI.

int GetSkillRequirement(string actorvalue)
Returns the skill level needed to acquire this perk.

SkylineR390 added 4 commits April 12, 2024 16:58
…items.

If there are pre-existing items in the base container, the toal count depends on static count + countDelta instead of delta alone. Additionally, in this case the game deletes entry data only when countDelta == 0. These changes intend to mimic this behavior.
GetItemCountCached doesn't account for any sort of concurrency. Just two simoultaneous looped calls on different containers can result at best in a cascade of data clear/rebuilds, eliminating any advantage the function might have had. Since its benefits are marginal, due to its inherent call cost and the existence of GetItemsCount, I think it best to remove it externally rather than implement a better solution not using static data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant