Clothing Bless Deed (v1.3)

Want to contribute to the Ultima Offline eXperiment? Submit your JS/DFN/Code fixes and/or other UOX3 improvements here!
Post Reply
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Clothing Bless Deed (v1.3)

Post by Xuri »

An example custom deed item making use of the script (I saved mine in misc_deeds.dfn, but it's advicable to create custom dfn-files with any custom stuff so it doesn't get overwritten by any UOX3 updates later):

Code: Select all

[clothingblessdeed]
{
GET=base_item
NAME=Clothing Bless Deed
ID=0x1F23
SCRIPT=6003
}
 
The actual Clothing Bless Deed-script:
// Clothing Bless Deed
// v1.3
// by Xuri (xuri@sensewave.com)
// Last Updated: 2. May 2006

// With a clothing bless deed, a player may bless/newbiefie any one piece of clothing in his/her backpack or paperdoll.
// The blessed clothing article will then stay with the character even upon death, and cannot be stolen.

// To use, save this script as js/custom/clothingBlessDeed.js, and add a new entry in jse_fileassociations.scp for it
// in the [SCRIPT_LIST] section of the file
// Example:
// 6000=custom/clothingBlessDeed.js
//
// Next, add a deed ingame using 'ADD 0x1f23, then do 'SETSCPTRIG 6000 on the deed.
// Alternatively, add a new deed-item to the item-dfns (with a unique header, like [ClothBlessDeed], and assign the script
// by adding a SCRIPT=6000 tag. Add the new item ingame using 'ADD ITEM ClothBlessDeed

//The following items may be blessed with a bless-deed:
var validClothingArray = new Array( "0x1515", "0x1516", "0x1517", "0x1518", "0x152e", "0x152f", "0x1530", "0x1531", "0x1537",
                            "0x1538", "0x1539", "0x153a", "0x153b", "0x153c", "0x153d", "0x153e", "0x153f", "0x1540",
                            "0x1544", "0x170b", "0x170c", "0x170d", "0x170e", "0x170f", "0x1710", "0x1711", "0x1712",
                            "0x1713", "0x1714", "0x1715", "0x1716", "0x1717", "0x1718", "0x1719", "0x171a", "0x171b",
                            "0x171c", "0x1efd", "0x1efe", "0x1eff", "0x1f00", "0x1f01", "0x1f02", "0x1f03", "0x1f04",
                            "0x1f7b", "0x1f7c", "0x1f9f", "0x1fa0", "0x1fa1", "0x1fa2", "0x1ffd", "0x1ffe", "0x2305",
                            "0x2306", "0x2307", "0x2308", "0x2309", "0x230a", "0x230b", "0x230c", "0x230d", "0x230e",
                            "0x230f", "0x2310", "0x25ea", "0x25eb", "0x25ec", "0x25ed", "0x25ee", "0x25ef", "0x25f2",
                            "0x25f3", "0x2649", "0x264a", "0x264d", "0x264e", "0x264f", "0x2650", "0x2651", "0x2652",
                            "0x2653", "0x2654", "0x2655", "0x2656", "0x265f", "0x2660", "0x2661", "0x2662", "0x2663",
                            "0x2664", "0x2665", "0x2666", "0x2667", "0x2668", "0x267b", "0x267c", "0x267d", "0x267e",
                            "0x267f", "0x2680", "0x2681", "0x2682", "0x2683", "0x2684", "0x268b", "0x268c", "0x269d",
                            "0x269e", "0x2782", "0x2783", "0x278f", "0x2794", "0x2796", "0x2797", "0x2798", "0x2799",
                            "0x279a", "0x279b", "0x279c", "0x27a0", "0x27a1", "0x27cd", "0x27ce", "0x27da", "0x27e1",
                            "0x27e2", "0x27e3", "0x27e4", "0x27e5", "0x27e6", "0x27e7", "0x27eb", "0x27ec", "0x2fb9",
                            "0x2fba", "0x2fbd", "0x2fbe", "0x2fc3", "0x2fc4", "0x2fca", "0x3173", "0x3174", "0x3175",
                            "0x3176", "0x3177", "0x3178", "0x3179", "0x317a", "0x3180" );

function onUseChecked( pUser, iUsed )
{
    var pSock = pUser.socket;
    var itemContainer = iUsed.container;
    if( itemContainer && itemContainer.serial == pUser.pack.serial )
    {
        pSock.tempObj = iUsed;
        pUser.CustomTarget( 0, "Select clothing article to bless:" );
    }
    else
        pUser.SysMessage( GetDictionaryEntry( 1763, pSock.Language )); //That item must be in your backpack before it can be used.
    return false;
}

function onCallback0( pSock, ourObj )
{  
    var pUser = pSock.currentChar;
    var iUsed = pSock.tempObj;
    if( iUsed.container && iUsed.container == pUser.pack )
    {
        if( !pSock.GetWord( 1 ) && ourObj.isItem )
        {
            if( ourObj.container && (( ourObj.container == pUser ) || ( ourObj.container == pUser.pack )))
            {
                for(var i = 0; i < validClothingArray.length; i++)
                {
                    if( ourObj.id == validClothingArray[i] )
                    {
                        if( ourObj.isNewbie == false )
                        {
                            ourObj.isNewbie = true;
                            pUser.SysMessage( "The targeted item (" + ourObj.name + ") has been blessed." );
                            iUsed.Delete();
                        }
                        else
                            pUser.SysMessage( "That item is already blessed." );
                        return;
                    }
                }          
            }
        }
        pSock.SysMessage( "You can only use this on clothes in your backpack or on your paperdoll." );
    }
    else
        pUser.SysMessage( "You are no longer carrying the clothing bless deed." );
}
Last edited by Xuri on Mon Dec 29, 2008 6:19 pm, edited 1 time in total.
-= Ho Eyo He Hum =-
karther77
UOX3 Newbie
Posts: 8
Joined: Wed Nov 08, 2006 5:19 am
Location: California
Has thanked: 0
Been thanked: 0
Contact:

Post by karther77 »

Could this same type of java be done to create a Item Bless Deed or other type.? This seems like it could be done since clothing sems to have the same array but for armor or items and codes. Can this be done?
Karther-Ranger of Yew
(NuFf SaId)
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

To extend it is as simple as adding more item IDs to the array, really. If you know the armour codes, just tack them on in the same sort of fashion.
dracuskaos
UOX3 Neophyte
Posts: 35
Joined: Sat Oct 25, 2008 3:54 am
Has thanked: 0
Been thanked: 0

Post by dracuskaos »

Can you make it global for all items in the game and have a global script that decrements the durability of what people are wearing on resurrection?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Hm. What exactly do you mean by "make it global"? You want the bless deeds to work on all items, or you want all items in your world to be "blessed" by default so they don't drop when someone is killed?

If it's the former, you can just remove the ID-check from the script. If it's the latter, you can create a global js script that runs for every new item that is created, and give it the scriptID 0 (zero) in jse_fileassociations.scp:

Code: Select all

function onCreate( objMade, objType )
{
	objMade.isNewbie = true;
}
The side-effect would be that all monster loot would be "blessed" as well, so the monsters won't actually drop any loot.
-= Ho Eyo He Hum =-
Post Reply