Alternate Lockpick V 1.2 **4/25/07*

Got any custom JavaScript additions/tweaks you think other people would like to see? Post 'em here!
Post Reply
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Alternate Lockpick V 1.2 **4/25/07*

Post by stranf »

An alternate Lockpicking script that allows the GM to specifiy difficulty.

Due to my lack of coding experience, I was unable to figure out a way to customize the existing lockpicking script to satisfy the needs of my shard, so I decided to code my own. I feel that this script will allow GMs greater flexiblity with created locked objects, as well as give rogue and adventuring characters a greater incentive to gain lockpicking skill.

The "set up" portion tells how to use the script in the game and also gives some examples of what kind of success rates a lockpicker would have vs. certain locks. The code for changing the difficulty can be easily customized.


Version 1.02
-- Set the default pick rate to 35% success. After testing, 45% seemed to easy.

--Fixed a boolean bug that would let you pick anything, even if it was not type 8.

--added a better debugging system that can be "decommented" to balance the system.
Set up:

1. First an object is set to its locked object type. (8 for container, 13 for a door, 64 for a spawn container). Example: "'set type 8" and select the container.

2. In order to allow a lock to be pickable, the morex of the object must be set to 5. This allows the GM to create "unpickable" locks. Example: "'set morex 5" and select the container.

3. The diffaculty level is set by adjusting the morey. It is recommended to use a value between 1 and 1000. This value is used against the PCs lockpicking skill. (see formula below). Example: "'set morey 525" and select the container.

*-----------------------------------*

Formula

When a PC uses a lockpick on a lock, a "This lock is unpickable" is returned if the morex of the container is not set to 5.

If it is a pickable lock, the default success rate is 45% without skills and penalties. Skill divided by 10 is added to the success rate, while the difficulty of the lock (morey) is subtracted from the success rate. A random number between 1 and 100 is compared against the success rate. If it is greater, than the lock is picked.

If it is a failure there is a 40% chance the pick will break.

The "skillcheck" function is fired to check to increase the lockpicking skill regardless of sucess or failure.

Here is the mathematical formula:

If (Random 100) + (skills/10) - (morey/10) > (100-45), pick the lock.


Here is an example of success:

lockpick 100 Vs Morey 1000 lock == 45% pickrate
lockpick 50 vs Morey 1000 lock == 0% pickrate
lockpick 60 vs morey 1000 lock == 5% pickrate

lockpick 100 Vs Morey 500 lock == 95% pickrate
lockpick 75 Vs Morey 500 lock == 70% pickrate
lockpick 10 vs Morey 500 lock == 5% pickrate

lockpick 20 vs Morey 100 lock == 55% pickrate
Last edited by stranf on Wed Apr 25, 2007 3:56 pm, edited 2 times in total.
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Copy the following text into a new .js file in your Uox3/js/custom directory. Go to the jse_FileAssociations.scp and change line 4008 to read your new file.

Example: 4008=custom/lockpick.js


function onUseChecked( pUser, iUsed )
{
    var pSock = pUser.socket;  

    pSock.tempObj = iUsed;     
    pSock.CustomTarget( 0, "What lock do you wish to pick?" );
           
       
   
}
//      case 1:     // Container
//      case 12:    // Door
//      case 63:    // Spawn Container
           
//      case 8:     // Locked Container
//      case 13:    // Locked Door
//      case 64:    // Locked Spawn Container



//pick targeting
function onCallback0( pSock, myTarget )
{
    var pUser = pSock.currentChar;
    var lockpick = pSock.tempObj;
    pSock.tempObj = null;

   

    if( myTarget.type == 8 || myTarget.type ==13 || myTarget.type ==64)    // fire if container is locked
    {


            if(myTarget.morex == 5)         // check to see if it is a pickable lock
             {
               
          //pick function == Random ((1-100) + (skills - difficulty)) must be greater than difficulty
       
       


            var Check =RandomNumber( 0, 100 );   //edit random ## roll here.  (default 0-100)
            // NOTE  Remember skills and morey should be from 1-1000, so be sure to divide by 10 to get it into the proper number format (Ie 1-100)
            var Bonus = ((pUser.skills.lockpicking - myTarget.morey)/10);  // edit bonus here (default = skill - difficulty)  
            var BaseOpen = 35;           //55% chance of opening a lock with no bonuses or difficulty...use for a base value of difficulty
                         
                        var DC = 100-BaseOpen;    //Base difficulty check based on the BaseOpen variable
            //debug text for formula check         
                        var Debug = Check + Bonus;
   
// *remove these comments to show the debug text*
                //      pUser.SysMessage("Check" + Check);
    //      pUser.SysMessage("Bonus" + Bonus);
    //      pUser.SysMessage("DC" + DC);
                //        pUser.SysMessage(Debug + ">" + DC);          
           
            pUser.CheckSkill( 24, 0, 1000 );   //run dummy function for skill gain purposes only.
            //Formula calculation

            if ((Check + Bonus) > DC)   // Fire if check is greater than lock difficulty

            {
             myTarget.TextMessage("*With a slight click and a gentle turn, the lock slips open*");
             pSock.SoundEffect( 0x01FF, false );
             
            if (myTarget.type == 8)
              myTarget.type = 1;

            if (myTarget.type == 13)
              myTarget.type =12;

            if (myTarget.type == 64)
              myTarget.type == 63;

            }

            else   //perform failure check here.

            {
                var CheckBreak = RandomNumber(0, 100);  //edit random ## to see if key breaks.
                var DCBreak = 40;  //Edit this value.  Currently a 40% chance of a pick breaking.
               

                if (CheckBreak > DCBreak)
                    {
                    pUser.TextMessage("*A sudden harsh twist causes the pick to snap*");
                    pSock.SoundEffect( 0x01FF, false );
                   
                    if( lockpick.amount > 1 )
                            lockpick.amount = (lockpick.amount-1);
                        else
                            lockpick.Delete();

                   
                    }

                else
                    {

                    myTarget.TextMessage("*Despite your efforts, the lock remains secure*");
                   
                   
                    }

            }


       
                     

             }
            else
             {
                pUser.TextMessage( "*This lock is beyond your skill to pick*");
                return;
             }

     }

       //Break if target is not locked
        else
        {
         pUser.SysMessage( "That object is not locked");
         return;
        }          
           



}
Post Reply