Page 1 of 1

Force-Respawning a Remote Container

PostPosted: Sun Aug 09, 2009 8:11 am
by Ross Thomas
Here's my situation:

I have a remote container that is activated via message box choice. I want to refill it anytime it's been used, such that it will always contain one each of its 69 items.

Each of those 69 items is scripted to remove itself if there is more than one in the container. These scripts work fine when the items are added to/removed from local containers and actor inventories. However, "onAdd" and "ondrop" scripts don't run on items added to persistent remote containers (see the CS Wiki article on http://cs.elderscrolls.com/constwiki/index.php/Script_Processing).

Here's what I've tried to make this scenario work:

Heartbeating the container, as described in the Script Processing article, using their example script and a half dozen variations of it. This seems to have no practical effect on whether onAdd or ondrop scripts run on the items placed in them - they still don't run at all. I have also tried using a quest script to ping the container by setting new variable values every frame, instead of the container itself changing the values - also to no avail.

Moving the container to the player temporarily - this kind of works, but has risks (Oblivion gates, etc). Sending the container back to its home cell in the first frame of gamemode would avoid that risk sufficiently, but wouldn't allow enough time for a full refill.

Adding the items to the container one-by-one with a script with no conditions - does refill the container, but leaves duplicates every time, because the onAdd block of the items' script doesn't run.

Adding the items to the container one-by-one with a script with GetItemCount conditions - the script quits after a dozen or so items. I've tried it as an activator script, a quest script, putting it directly in the messagebox script - just about every arrangement I can think of, still having the early stopping issue. I did double-check the script where it tends to stop to make sure I didn't flub it up, and it doesn't appear that I have.

I'm fried now. Any suggestions? Thank you.

Force-Respawning a Remote Container

PostPosted: Sun Aug 09, 2009 12:25 am
by IsAiah AkA figgy
Use a dummy actor with permanent 100 chameleon (set unconscous and restrained) for the container, or atleast as a middleman (the inventory can be swapped out quickly with removeallitems). This should put the scripts used for some part of the process within a higher demand mode. If you find that you still need to have the container processed within the player's current scene, just add a condition so that this movement can only happen when the player is in Tamriel. It's not perfect, but it might solve some of your problems.

Force-Respawning a Remote Container

PostPosted: Sun Aug 09, 2009 10:20 am
by Sophie Miller
Quite a mystery there?
For me, the game crashes if I have 10 or more additems in the container onactivate block. Works fine the first time, but crashes when activating the container a second time. Adding a few per frame did not help.

Anyway, what worked was refilling the container just before activating it: "MyContainer.RemoveAllItems" + n x "MyContainer.AddItem xxx 1" + "MyContainer.Activate player 1".

Force-Respawning a Remote Container

PostPosted: Sat Aug 08, 2009 7:43 pm
by Minako
This may be a dumb idea, but here goes: Set the container to respawn. Place the remote container in it's own special cell. When using a script to open the container, have it first reset the container's special cell. When a cell resets, so does the inventory of any respawning container within it so this should ensure that your container always has 1 of each item.

Force-Respawning a Remote Container

PostPosted: Sun Aug 09, 2009 6:05 am
by Iain Lamb
Use a dummy actor with permanent 100 chameleon (set unconscous and restrained) for the container, or atleast as a middleman (the inventory can be swapped out quickly with removeallitems). This should put the scripts used for some part of the process within a higher demand mode. If you find that you still need to have the container processed within the player's current scene, just add a condition so that this movement can only happen when the player is in Tamriel. It's not perfect, but it might solve some of your problems.


That's actually a really good idea. Using a dead rat didn't work (I tried that too, did I mention?), but a living actor has quite a lot more potential. I will do that if for some reason QQuix's suggestion doesn't work. Thank you!

Quite a mystery there?
For me, the game crashes if I have 10 or more additems in the container onactivate block. Works fine the first time, but crashes when activating the container a second time. Adding a few per frame did not help.

Anyway, what worked was refilling the container just before activating it: "MyContainer.RemoveAllItems" + n x "MyContainer.AddItem xxx 1" + "MyContainer.Activate player 1".


The container itself isn't scripted - I read the bit on the wiki about onActivate blocks running on containers and crashing, and it scared me right into not doing that. All of these goings on happen in a message box script trigged by an options menu token.

Refilling the container (without conditions) before activation in the message box script did work, but I didn't consider the simple idea of emptying it first to prevent duplicates. :facepalm: Told you I was fried! Thank you.

This may be a dumb idea, but here goes: Set the container to respawn. Place the remote container in it's own special cell. When using a script to open the container, have it first reset the container's special cell. When a cell resets, so does the inventory of any respawning container within it so this should ensure that your container always has 1 of each item.


Tried that too. The player never enters the cell, it's just a dummy/storage cell, and cell reset [seemingly] takes place on cell load, not before - which I learned trying to make this work. Anyway, thank you - this was very close to being on the list of things I hadn't tried.


Thanks very much guys, I appreciate the help. :mohawk:

Force-Respawning a Remote Container

PostPosted: Sat Aug 08, 2009 11:12 pm
by Tania Bunic
Addendum:

Just emptying the container a frame before all the items get re-added works beautifully. Thank you again! :wub: