kuyondo wrote: ↑01 Aug 2018, 14:18
IMO, vanilla implementation is superior because it affects all ID, not just 1 instances of the ID.
It DOES NOT affect all objects.
It just spams barreltesting->getitemcount calls in hope that search by ID will find different objects during different calls. In this case "getitemcount" and "additem" actually can work work with different objects. Probably it is not intended behaviour.
I do not know how it works in vanilla, but OpenMW looks for first object with given ID, preferring active cells.
So you can call this script 1000 times, and it will find the first object with given ID in current cell 1000 times. Obviously, it will be the same item.
Unfortunately, vanilla script engine does not provide a reliable way to work with non-unique objects.
Probably you need to use MWSE in this case.
EDIT:
I specially tested vanilla game: tried to add a glass sword to non-unique quard and unique NPC:
Code: Select all
"hlaalu guard_outside"->additem "glass longsword" 1
heddvild->additem "glass longsword" 1
Result is a quite interesting: for guards it did not affect existing guards, but affects newly spawned ones.
If I select a guard in console, and run
only selected instance is affected.
For unique NPC result is opposite: it does not affect newly spawned instances, but affects existing reference.
Even if another instance of this NPC is added in game world (e.g. via script), NPC still is considered as unique and script works only with original instance.
Highly likely there are another quirks here.
For now, looks like console commands for objects (with ->) work in this way:
1. Check a count of existing instances of target object in game (take only instances from ESM/ESP files in acoount).
2. If there is only one instance, modify it and do not touch base record.
3. If there are many instances, modify base record, but do not touch existing instances.
Probably effect depends on console command.