How to teleport a chest?

Hello

I’m looking for a way to create a Leomund chest spell.
So I would like to create a script teleporting this placeable chest to PC when he uses the summoning scroll, and teleporting the chest back to its “hidden limbo” location OnClosing it.

How to use the Jump command with a placeable?

Being new member, I apologies if this question has already been ask on forum (using a fast research I did not find any topic related- or I have to take more time to handle this forum)

Thank you all.

The chest in Limbo can be permanent, since the PC will never see it.

Use CreateObject() to create a new chest when summoned.

Copy the items from the permanent chest (if any).

On close, copy the items from the new chest to the permanent chest, then DestroyObject() to destroy the old chest.

Do you have sufficient scripting knowledge to do that?

1 Like

Prolerics solution is probably the best you can get.

Or in other words: It is not possible to jump or even to move a placeable.

Only to give the illusion of doing so - GetObjectVisualTransform(object, int).

TR

Which, in this particular case, doesn’t help because the illusion only works within the current area.

Incidentally, the Lexicon entry for CopyItem() is quite helpful in identifying the special cases that need to handled e.g. item variables, containers and plot items.

Looks like someone may have made this already - haven’t looked at it, though.

https://neverwintervault.org/project/nwn1/hakpak/leomunds-chest

Interesting, thank to lilac soul i think i may handle that.

What about
OnOpen launch a custom merchant
OnClose unsummon the chest
?

In that case I still have a problem to set the sell/buy to zero, a 1 gold piece remains when I edit a custom merchant)

OnOpen launch a custom merchant

You don’t need a chest to launch a merchant.

In that case I still have a problem to set the sell/buy to zero, a 1 gold piece remains when I edit a custom merchant)

for me, there seems not to be a workaround around this problem. The max buyprice to 1g is easiely set, but you can’t control the maximum sell price in the same way.

I see what you’re trying to do there - it’s the only inventory you can open remotely - but I don’t think you can work around the 1gp snag and other merchant biz.

The method I described works. Normally, it’s used to move inventories from creatures to containers, and vice-versa, which is why it has to go item-by-item. Not difficult to script.

If you’re looking for a simpler method in this special case, how about this?

  • CopyObject to create a copy of the chest at the PC’s location with bCopyLocalState=TRUE, then destroy the original chest
  • Let the PC open the chest and change the inventory
  • OnClose, copy the new chest to the old location before destroying it

I’ve verified that this works for a mixed inventory including gold, containers with contents, plot items, stolen items and item local variables.

There are ways to copy the inventory of the chest to another object and destroy the original. The trick is making sure everything copies over. Bags inside the chest with their own inventory need to have the bag copied and then each object inside copied to the new bag before moving on.
I have seen it done a few ways. Long ago, I started using a script from the Killer Death System called “_move_inv_inc” which handles this well (the function is called MoveEverything).

Are you aware of any glitches when CopyObject is used to copy a placeable and its inventory in one go?

This may be something ancient and long-since fixed, but I recall items inside other items (bags…) had issues.
This is from the lexicon: If you are iterating through a dead PC’s inventory and use CopyObject() on a container that has items within it, and copying to another placeable (a Corpse placeable for example) the items are duplicated. This occurs because the items belong both to the parent container and again to the child container. It may be possible to get around this unexpected behavior by marking each item already processed using SetLocalInt(), then seeing if an int value set exists on the item; if so do not copy the item (of course items in a copied object’s inventory will have to be iterated through manually).

So instead of copying the placeable at one go, you copy all the inventory to another object and destroy the original stuff.

Thanking you all for the time you spent to respond.
Pondering all of that.

=)

True, but a different case. Testing today (in EE), CopyObject on a placeable containing a bag of items results in a placeable containing an identical bag of items.

1 Like

Well, for now I begin to have some results:

I created 2 chests:

(a) PL_LEO_ETHERAL
PLaceable LEOmund chest staying in ETHERAL plane.
(according to my v3.5 Player’s Handbook^^)

(b) PL_LEO_SPAWNABLE
PLaceable LEOmund chest that will spawn next to PC.

(b) has OnOpen and OnClose scripts:

/*
 *  Script generated by LS Script Generator, v.TK.0
 *
 *  For download info, please visit:
 *  http://nwvault.ign.com/View.php?view=Other.Detail&id=1502
 */

// ONOPEN SCRIPT


void main()
{
    object oTarget;
    object oItem;

    // Get LEOMUND ETHERAL
    object oET = GetObjectByTag("PL_LEO_ETHERAL");

    // Relieve LEOMUND ETHERAL of its possessions into LEO SPAWNABLE
    oTarget = GetObjectByTag("PL_LEO_SPAWNABLE");
    oItem = GetFirstItemInInventory(oET);
    while ( oItem != OBJECT_INVALID )
    {
        AssignCommand(oTarget, ActionTakeItem(oItem, oET));
        oItem = GetNextItemInInventory(oET);
    }

}
/*
 *  Script generated by LS Script Generator, v.TK.0
 *
 *  For download info, please visit:
 *  http://nwvault.ign.com/View.php?view=Other.Detail&id=1502
 */
// ONCLOSE SCRIPT


void main()
{
    object oTarget;
    object oItem;

    // Get LEOMUND SPAWNABLE
    object oSP = GetObjectByTag("PL_LEO_SPAWNABLE");

    // Relieve LEO SPAWNABLE of its possessions into LEO ETHERAL
    oTarget = GetObjectByTag("PL_LEO_ETHERAL");
    oItem = GetFirstItemInInventory(oSP);
    while ( oItem != OBJECT_INVALID )
    {
        AssignCommand(oTarget, ActionTakeItem(oItem, oSP));
        oItem = GetNextItemInInventory(oSP);
    }

    {
    object oTarget;
    effect eVFX;

    // Get the creature who triggered this event.
    object oPC = GetLastClosedBy();

    // Destroy LEO SPAWNABLE + VFX

    eVFX = EffectVisualEffect(VFX_IMP_UNSUMMON);
    oTarget = GetObjectByTag("PL_LEO_SPAWNABLE");
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oTarget);
    DestroyObject(oTarget, 1.0);
    }

}

Containers seem to keep what they hold inside them.

Neat solution!

If you didn’t already, better check what happens if the chest contains a bag of items.