Revision as of 21:51, 19 January 2009 by Quetzilla (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

On the notes, were the actors in the same cell as the player?
--Haama 20:07, 19 January 2009 (UTC)

No, I added the test actors to a random house interior I had never been to and traveled there with coc. OnAdd blocks simply won't execute for items placed into NPC inventories when they initially spawn (or their inventory is regenerated via SetLevel or ResetInventory), or added as death items. It is most unfortunate behavior indeed. =(
I am going to play around more when I am home to see if I can use a gamemode script with a timer to add an item shortly after the actor spawns using AddItem (which will trigger the OnAdd block). My previous experiments with this showed that a gamemode block on an item script calling additem on its container would freeze the game, but it may be because the item I was adding also called RemoveMe in its OnAdd block. I hope to find a workaround for this.
--SnakeChomp 21:06, 19 January 2009 (UTC)
The GameMode script shouldn't freeze the game - try something simpler? I asked because in Oblivion (yeah, yeah - new computer should be up tomorrow so I can finally test these things myself) when you added an item to a remote container it would fire the script, so a GameMode block would run. However, the onAdd block wouldn't fire until the player entered the cell.
--Haama 21:38, 19 January 2009 (UTC)
I figured out why the game would freeze when I used a gamemode block. I added information about it to the RemoveMe page. There is a similar bug in Oblivion too.
--SnakeChomp 00:10, 20 January 2009 (UTC)
For the note that I added, about the Death Items, they were. I tried it with and without the player killing them, and it seems to be true for regular Death Items and for those added via perks like Contract Killer.
It's not all bad, you can use it to tell when the item is first removed from its container.
-- Cipscis 21:08, 19 January 2009 (UTC)
Sounds good, then. Confirmation is always a good thing :)
--Haama 21:38, 19 January 2009 (UTC)

Both of these notes stem from the same 'issue', which is really a matter of interpretation. OnAdd blocks are only run for items that are considered to be 'added' to the inventory. An actor's initial inventory items are never considered 'added' because they are what the character starts out with, e.g. the clothes on their back. When an actor is placed in the world, either in the GECK or via script, it's not that the actor is created and THEN the items are added to their inventory, but rather that the actor was placed into the world WITH their inventory, so the game never considers those items as changes which would trigger an OnAdd block.
It's the same idea behind why the game doesn't consider death items to be 'added' to the inventory, these are considered to be items that were *already* on the actor. For example, the ears and fingers for Lawbringer/Contract Killer are, from a realism standpoint, part of the body, it's just that when the actor is dead you can now take those body parts.
As scripters we might think that obvious way the above scenarious should work is that if an object is added to an inventory, no matter in what way, the object should trigger the OnAdd block, and the fact that it doesn't is confusing. However, I think from looking at in this perspective instead, the reason why they don't trigger is at least logical, if inconvenient.
--Quetzilla 02:51, 20 January 2009 (UTC)
Personal tools