Stacks produce an amount of gold equal to the size of the stack.
To use, copy & paste into a text-editor, save document with a .js file extension in your UOX3/JS/custom folder, and then assign it an unused ScriptID in jse_fileassociations.scp. Then use 'SETSCPTRIG # on containers in-game, or add the DFN-tag SCRIPT=# in the DFN sections for containers you want to function as trash-cans (replacing # with the ScriptID you assigned in jse_fileassociations.scp, of course).
// v1.2
// by Xuri (xuri@uox3.org)
// Last Updated: 26. November 2011
// Assign this script to any item to make said item act as a trash-can.
// As an added - optional - bonus, the script can be set to give out gold for every item disposed
// If enabled, the amount of gold defaults to the stack-size of the item, but can also be based on
// the weight of the item, or the sell-value of the item divided by two. Only one of the three options
// should be enabled at a time.
var enableGoldReward = false;
var baseGoldOnStackSize = true;
var baseGoldOnWeight = false;
var baseGoldOnSellValue = false;
function onDropItemOnItem( iDropped, pDropper, iDroppedOn )
{
//Safe-guard to stop trashcans from getting deleted if they're dropped into another container
if( iDropped.scripttrigger == 5100 )
return 1; // Use hard code, don't bounce item
//Grab some vital data before dropped item is deleted
iPickupSpot = pDropper.socket.pickupSpot;
iWeight = iDropped.weight;
iStackSize = iDropped.amount;
//Give feedback (and potentially gold) to player
if( enableGoldReward == true )
{
var goldAmount = 0;
if( baseGoldOnStackSize == true ) //If gold-reward is based on stack-size
goldAmount = iStackSize;
else if( baseGoldOnWeight == true ) //If gold-reward is based on item-weight
{
if( iDropped.weight != 0 )
goldAmount = ( Math.ceil( iDropped.weight / 100 )); //rounds up to nearest whole number
else
goldAmount = 1; //Default to 1 gold for items that have no weight defined
}
else if( baseGoldOnSellValue == true ) //If gold-reward is based on item sell-value
{
if( iDropped.sellvalue != 0 )
goldAmount = Math.ceil( iDropped.sellvalue / 2 );
}
// Now, spit out some gold for the player!
if( goldAmount > 0 )
{
var newGold = CreateDFNItem( pDropper.socket, pDropper, "0x0EED", goldAmount, "ITEM", true );
iDroppedOn.TextMessage( "The trashcan disposes of your unwanted junk and spits out "+goldAmount+" gold coins in return!", false, 0x7ef );
}
else
iDroppedOn.TextMessage( "The trashcan disposes of your worthless junk.", false, 0x7ef );
}
else
iDroppedOn.TextMessage( "The trashcan disposes of your unwanted junk.", false, 0x7ef );
iDropped.Delete();
// Subtract weight if item dropped was picked up from one of these spots:
// pickupspot 1 = ground, 3 = otherpack, 5 = bank
// In other cases it's handled by code when item gets deleted
if( iPickupSpot == 1 || iPickupSpot == 3 || iPickupSpot == 5 )
{
if( iWeight == 0 || iWeight == 25500 )
pDropper.weight = pDropper.weight - 25500;
else
pDropper.weight = pDropper.weight - iWeight;
}
return 2; // Don't use hard code, don't bounce item
}