If pickpocket succeeds...?

Aoi

New member
Hello; took a brief look around for this and didn't see it anywhere, so if I may ask...

Is there any way to implement something akin to: "if pickpocket is successful, then a, else, b" as a custom combat setting, or will this involve something a bit more complex?

Any kind of direction here would be muchly appreciated.
 

jasonharper

Developer
There are two problems with doing this:
1. There is no provision for any sort of conditional test in a CCS.
2. Mafia doesn't know (or care) whether a pickpocket was successful.

A consult script would be required to do this, it could look at the page text to recognize a successful pickpocket.
 

slyz

Developer
It would help if you told us what you want done, but one way would be to use Zarqon's First Things First consult script and modify it.

FTF will manage the first round of combat for you, pickpocketing if you are safe (and able to pickpocket) and if the monster drops at least one item. I attached a modified version here that will set the 'stolen' variable to true if you got something from pickpocketing.

You then have to import the modified FTF in a consult script that will use the 'stolen' variable to decide what to do next. I attached an example, PickPocket.ash, that only attacks either way. I used the main() in Zarqon's SmartStasis, which you might want to check out because of all the usefull things it can do.

All you need to do now is :
- get Zarqon's Zlib here : http://kolmafia.us/showthread.php?t=2072
- get the attached files, FirstThingsFirst_with_pickpocket.ash and PickPocket.ash
- modify PickPocket.ash to tell it to do whatever you need done in each case
- put all the .ash files in Mafia's script directory
- create a CCS like this :

Code:
[ default ]
1: consult PickPocket.ash
2: attack (or whatever you need to kill the monster after getting you needed done)

and voila !

Don't forget to thank Zarqon: you can send him lots of bats! (Or bat-related items)

Edit: this is untested
Edit2: if you are not familiar with ASH consult scripts, check out the wiki
 

Attachments

  • FirstThingsFirst_with_pickpocket.ash
    15.8 KB · Views: 59
  • PickPocket.ash
    887 bytes · Views: 51
Last edited:

Bale

Minion
Don't forget to thank Zarqon: you can send him lots of bats! (Or bat-related items)
I send him all my bat stuff at the end of every ascension. It's part of what my OCD inventory script does. ;) He earns them with all his scripting.
 

Aoi

New member
Mrrr. Thank you (and Zarqon)!

I'll take a brief moment to consider the files/scripts and report on how things turned out.

-----

I think something got broken in the process... I'm getting the error:
Unknown variable 'stolen' (FirstThingsFirst_with_pickpocket.ash, line 110)

I admit, programming isn't something in my area of expertise. ^^;;
 
Last edited:

slyz

Developer
Of course you had that problem: change line 34 of FirstThingsFirst_with_pickpocket.ash to:

Code:
boolean stolen = false;

I wrote 'stole' instead of 'stolen' there. I guess you had already figured it out though =)

That's my bad for whipping some code out without even *trying* to run it.
 

Aoi

New member
Hmm. I was pretty sure I DID try that, except it spit back another error, so I decided to check back. I need to stop running drinking so early; I'll report back after rollover...

-----

Aye, after making the change you suggested, I'm now getting another error...

Unknown variable 'stole' (PickPocket.ash, line 36)
Consult script 'PickPocket.ash' not found.

...I'm honestly not sure why it's not being being found when nothing else has changed, but I don't think it's relevant since it evidently CAN find it, since it reports an error in line 36...
 
Last edited:

Aoi

New member
So it's not pretty, but I finally managed to kludge something together that works:

boolean stolen = false;
string page;
page = steal();
if ( contains_text(page,"grab something")|| contains_text(page,"You manage to wrest") ) stolen = true;
if (stolen == true) #Command
if (stolen == false) #Command

Thanks for the assistance!
 

slyz

Developer
Sorry for posting something without checking it first (simply using the CLI 'verify' command would have been enough). I updated the files attached to my earlier post.

Now that you can execute different commands whether something is stolen or not, I'm still curious about what you had in mind =)
 

Tannenzaepfle

New member
Not necessarily even a runaway. For instance: Farming an item where the monster only drops one: if it doesn't drop, perform the +item disco combo.
 

zarqon

Well-known member
I think I may want to add this into FTF, for use by later consult scripts.

Question: does extract_items() work on the page when you pickpocket an item? It would be more useful as an item than a boolean.
 

zarqon

Well-known member
Turns out extract_items() does work on the pickpocket results. Nice! This will be in the next FTF update, which means if you want to take different actions depending on the success of pickpocketing, you can do this in your consult script:

1) import FTF,
2) call ftf() in main()
3) check the value of stolen, which is an item. If you didn't steal anything it will be $item[none]. If you stole something, it will be the item you stole.

I think this is cool.
 
Top