Destroy Items when Placed in Placeable

Wanting to have a placeable, possibly an anvil that when players place items into the placeable’s inventory, the items are destroyed and the player is given gold in return. Would also be a nice touch if while the player is using the anvil an animation is played (hammering?).

Is this possible?

Sure is. Use the OnDisturbed or OnClosed event of the anvil, as you please.

AFAIK there’s currently no way to call the combat animations independently of actually attacking something, but you could play ANIMATION_LOOPING_GET_MID, or make the PC attack the anvil.

Building block for the OnDisturbed route:

    object oPC     = GetLastDisturbed();
    object oItem   = GetInventoryDisturbItem();
    int nEvent     = GetInventoryDisturbType();

    // An item has been added.
    if (nEvent == INVENTORY_DISTURB_TYPE_ADDED)
        {
        }

DestroyObject() is for destroying things. GiveGoldToCreature() is for giving gold to people. PlayAnimation() is for playing animations.

Using the OnClosed event is probably more sensible here, though, since the player might still want to change their mind. If the item automatically gets destroyed when it’s placed into the container, there’s no “confirm” button, so to speak.

1 Like

Thanks, got it working!

1 Like