NPC Locksmith Script 11/05/2011 09:50 PM CDT
I know most people use "third party" scripts written in a more agreeable language, but I wrote this one for stormfront because 1) It was difficult-to-impossible to script this with an SF script prior to the change, and 2) as a halfling, placing the boxes on the counter while overloaded is just really inconvenient due to weight limitations and the funny way the game allows you to carry coins in excess of your maximum weight allowance! So here it is for all you halflings like me that were looking for a quicker way to open boxes without a player locksmith around.

Forgive me, the script appears to work for my first couple of test runs but it is a little rough around the edges!

Limitations: Script will exit if it discovers an item that cannot be emptied, if the container you're emptying to is full, if you attempt to grab a box from someone else's disk, if you are too weighed down to grab from your own disk, or if you have insufficient silver to pay the locksmith. I will likely address some of these issues at some point, but it should work well enough under most circumstances. Just withdraw some silver to get you going and initiate the script by typing .unlock while at the locksmith counter. Please also note that I didn't write the script to allow you to set variables for your containers and it will only check for two containers and a disk (although it shouldn't be a problem if you have only one or have no disk). To make it work for you, just change the word "backpack" and the word "greatcloak" under the START1: and CONTAINER2: labels, respectively, to match whatever your container names are.



COUNTER SET 5
IF_5 GOTO START%c
IF_4 GOTO START%c
IF_3 GOTO START%c
IF_2 GOTO START%c
IF_1 GOTO START%c
GOTO INITIALIZE

INITIALIZE:
put .unlock strongbox box chest trunk coffer
exit

CHECKREP:
SHIFT
COUNTER SUBTRACT 1
GOTO START%c

START5:
START4:
START3:
START2:
START1:
MATCH BELL You remove
MATCH CONTAINER2 Get what?
put get %1 from my backpack
MATCHWAIT

CONTAINER2:
MATCH BELL You remove
MATCH DISK Get what?
put get %1 from my greatcloak
MATCHWAIT

DISK:
MATCH STOP Get yer own disk!
MATCH STOP unable to handle
MATCH BELL You remove
MATCH CHECKREP Get what?
put get %1 from disk
MATCHWAIT

BELL:
MATCH STOP don't have enough!
MATCH STOP ignores you.
MATCH OPEN Having paid,
put ring bell
put pay 7000
MATCHWAIT

OPEN:
put open my %1
put get coins from my %1
pause 1
GOTO CHECK1

CHECK1:
MATCH STOP can't quite
MATCH STOP nothing will fit
MATCH CHECK1 ...wait
MATCH TRASH everything falls in
MATCH TRASH nothing comes
put empty my %1 in my backpack
MATCHWAIT

TRASH:
MATCH TRASH ...wait
MATCH START%c feel pleased
put put my %1 in barrel
MATCHWAIT

STOP:
exit

LABELERROR:
exit


Reply
Re: NPC Locksmith Script 11/05/2011 11:32 PM CDT
Cleaned up some of the stops in the script. Haven't tested, but should work. Also, I lied about just replacing the container names at START1: and CONTAINER2:. You also need to replace them at CHECK1: and CHECK2:, as well as properly naming the trash receptacle at TRASH: (I used "barrel" because I'm in RR, but it's different in other towns). I may try to write in a way to set variables for these things so that the script doesn't require editing every time you change containers or cities, but the easiest way of doing it is kind of taken up by the way the script cycles through the various box types. I'll think about it!

Lot of effort for something probably nobody else will ever use, but hey, as long as I'm taking the time to write it I might as well share!

~Taverkin



COUNTER SET 5
IF_5 GOTO START%c
IF_4 GOTO START%c
IF_3 GOTO START%c
IF_2 GOTO START%c
IF_1 GOTO START%c
GOTO INITIALIZE

INITIALIZE:
put .unlock strongbox box chest trunk coffer
exit

CHECKREP:
SHIFT
COUNTER SUBTRACT 1
GOTO START%c

START5:
START4:
START3:
START2:
START1:
MATCH BELL You remove
MATCH CONTAINER2 Get what?
put get %1 from my backpack
MATCHWAIT

CONTAINER2:
MATCH BELL You remove
MATCH DISK Get what?
put get %1 from my greatcloak
MATCHWAIT

DISK:
MATCH BELL You remove
MATCH CHECKREP Get yer own disk!
MATCH CHECKREP unable to handle
MATCH CHECKREP Get what?
put get %1 from disk
MATCHWAIT

BELL:
MATCH STOP don't have enough!
MATCH OPEN ignores you.
MATCH OPEN Having paid,
put ring bell
put pay 7000
MATCHWAIT

OPEN:
put open my %1
put get coins from my %1
pause 1
GOTO CHECK1

CHECK1:
MATCH STOP can't quite
MATCH CHECK2 nothing will fit
MATCH CHECK1 ...wait
MATCH TRASH everything falls in
MATCH TRASH nothing comes
put empty my %1 in my backpack
MATCHWAIT

CHECK2:
MATCH STOP can't quite
MATCH STOP nothing will fit
MATCH CHECK2 ...wait
MATCH TRASH everything falls in
MATCH TRASH nothing comes
put empty my %1 in my greatcloak
MATCHWAIT

TRASH:
MATCH TRASH ...wait
MATCH TRASH could not find
MATCH START%c feel pleased
put put my %1 in barrel
MATCHWAIT

STOP:
exit

LABELERROR:
exit
Reply
Re: NPC Locksmith Script 11/05/2011 11:55 PM CDT
Okay, one more update for tonight! Added the ability to set variables for two containers and the trash receptacle. Untested, but should work fine...I think!

Explanation for how to use this for those who don't really get scripts. For instance, typing ".unlock - - - - - backpack greatcloak barrel" will set the variables for your primary container to "backpack", secondary container to "greatcloak", and the place where you're throwing your trash to "barrel". This way the script knows where everything goes. If you change containers or the place where you throw your trash you just redefine the variables, for example .unlock - - - - - purse cape trashcan. After that it will continue to use those variables until you change them again. You have to define these variables the first time you use the script or it won't work!

Apologies if any of this doesn't work. I just wrote these improvements and haven't tested them. Will probably update more later (as if anyone cares!). :)

~Taverkin

COUNTER SET 5
IF_8 GOTO SETVAR
IF_7 GOTO SETVAR
IF_6 GOTO SETVAR
IF_5 GOTO START%c
IF_4 GOTO START%c
IF_3 GOTO START%c
IF_2 GOTO START%c
IF_1 GOTO START%c
GOTO INITIALIZE

SETVAR:
DEBUG OFF
SETVARIABLE unlockcont1 %6
SETVARIABLE unlockcont2 %7
SETVARIABLE unlockrecep %8
ECHO
ECHO Your primary container has been set to %unlockcont1%.
ECHO
ECHO Your secondary container has been set to %unlockcont2%.
ECHO
ECHO Your trash receptacle has been set to %unlockrecep%.
exit

INITIALIZE:
put .unlock strongbox box chest trunk coffer
exit

CHECKREP:
SHIFT
COUNTER SUBTRACT 1
GOTO START%c

START5:
START4:
START3:
START2:
START1:
MATCH BELL You remove
MATCH CONTAINER2 Get what?
put get %1 from my %unlockcont1
MATCHWAIT

CONTAINER2:
MATCH BELL You remove
MATCH DISK Get what?
put get %1 from my %unlockcont2
MATCHWAIT

DISK:
MATCH BELL You remove
MATCH CHECKREP Get yer own disk!
MATCH CHECKREP unable to handle
MATCH CHECKREP Get what?
put get %1 from disk
MATCHWAIT

BELL:
MATCH STOP don't have enough!
MATCH OPEN ignores you.
MATCH OPEN Having paid,
put ring bell
put pay 7000
MATCHWAIT

OPEN:
put open my %1
put get coins from my %1
pause 1
GOTO CHECK1

CHECK1:
MATCH STOP can't quite
MATCH CHECK2 nothing will fit
MATCH CHECK1 ...wait
MATCH TRASH everything falls in
MATCH TRASH nothing comes
put empty my %1 in my %unlockcont1
MATCHWAIT

CHECK2:
MATCH STOP can't quite
MATCH STOP nothing will fit
MATCH CHECK2 ...wait
MATCH TRASH everything falls in
MATCH TRASH nothing comes
put empty my %1 in my %unlockcont2
MATCHWAIT

TRASH:
MATCH TRASH ...wait
MATCH TRASH could not find
MATCH START%c feel pleased
put put my %1 in %trashrecep
MATCHWAIT

STOP:
exit

LABELERROR:
exit
Reply
Re: NPC Locksmith Script 11/06/2011 09:26 PM CST
Fixed what I broke with my lazy late-night fixes! Seems to work fine now. Only major issue I anticipate is that it won't work in any town with a locksmith that doesn't use the bell to initiate lockpicking. Not planning on fixing that until I move on to another town, and I expect by then one of the third-party script writers will have gotten around to writing an updated NPC locksmith script.

Sorry for the multi-posts! But I guess nobody uses this folder anyway!

~Taverkin


COUNTER SET 5
IF_8 GOTO SETVAR
IF_7 GOTO SETVAR
IF_6 GOTO SETVAR
IF_5 GOTO START%c
IF_4 GOTO START%c
IF_3 GOTO START%c
IF_2 GOTO START%c
IF_1 GOTO START%c
GOTO INITIALIZE

SETVAR:
DEBUG OFF
SETVARIABLE unlockcont1 %6
SETVARIABLE unlockcont2 %7
SETVARIABLE unlockrecep %8
ECHO
ECHO Your primary container has been set to %unlockcont1%.
ECHO
ECHO Your secondary container has been set to %unlockcont2%.
ECHO
ECHO Your trash receptacle has been set to %unlockrecep%.
exit

INITIALIZE:
put .unlock strongbox box chest trunk coffer
exit

CHECKREP:
SHIFT
COUNTER SUBTRACT 1
GOTO START%c

START5:
START4:
START3:
START2:
START1:
MATCH BELL You remove
MATCH CONTAINER2 Get what?
put get %1 from my %unlockcont1
MATCHWAIT

CONTAINER2:
MATCH BELL You remove
MATCH DISK Get what?
put get %1 from my %unlockcont2
MATCHWAIT

DISK:
MATCH BELL You remove
MATCH CHECKREP Get yer own disk!
MATCH CHECKREP unable to handle
MATCH CHECKREP Get what?
put get %1 from disk
MATCHWAIT

BELL:
MATCH STOP don't have enough!
MATCH OPEN ignores you.
MATCH OPEN Having paid,
put ring bell
put pay 7000
MATCHWAIT

OPEN:
put open my %1
put get coins from my %1
pause 1
GOTO CHECK1

CHECK1:
MATCH STOP can't quite
MATCH STOP leaving the rest
MATCH CHECK2 nothing will fit
MATCH CHECK1 ...wait
MATCH TRASH everything falls in
MATCH TRASH nothing comes
put empty my %1 in my %unlockcont1
MATCHWAIT

CHECK2:
MATCH STOP can't quite
MATCH STOP nothing will fit
MATCH CHECK2 ...wait
MATCH TRASH everything falls in
MATCH TRASH nothing comes
put empty my %1 in my %unlockcont2
MATCHWAIT

TRASH:
MATCH TRASH ...wait
MATCH TRASH could not find
MATCH START%c feel pleased
put put my %1 in %unlockrecep
MATCHWAIT

STOP:
exit

LABELERROR:
exit
Reply
Re: NPC Locksmith Script 11/07/2011 03:01 PM CST


Thank you!
Reply
Re: NPC Locksmith Script 11/07/2011 04:36 PM CST
Gosh! I sure was hoping somebody else would actually want this script! The market for SF scripts is rather small these days!

Welcome!

~Taverkin
Reply