A request and possible challenge to the master scripters

Tom Sawyer

Member
Merry Crimbo everyone. I would like a script that buys wrapping paper, sticks 3 random items from my stash into it, then uses it. It then checks to make sure I am wearing a ring of teleporitis or under that effect, adventures once and the repeats.

It must not pull from the closet or clan stash as to be fair I really do not want to give away my UR's or other unique items.

As with anything else in the kingdom I can do this manually but spending 300 turns giving way Crimbo presents will take too much time that I do not have.

If you want payment for this I can slide a million meat your way :)
 

Crowther

Active member
Interesting. I was already starting to write a script, but hadn't decided how it should work. Since you have a plan, I followed that. Kolmafia doesn't support buying wrapping paper and doesn't recognize when it is used, so you'll need to buy a bunch manually before starting. Once that's supported, I believe my code will buy them for you as needed, but I was unable to test that.

I limited the value of gift items to under 10000 meat each based on mall prices, so it won't give gift items (ironic?). This can be easily changed.
 

Attachments

  • XiHide.ash
    2.4 KB · Views: 103

Crowther

Active member
I'm starting to get a number of thank you notes and I did 37 for testing. Oh, I just realized, mafia probably isn't subtracting the gifted items from inventory either, so eventually you might get an error when you run out of an item. Do an "inv refresh" and start again.
 

Tom Sawyer

Member
Crowther you are the man! I am too drunk to continue it seems but it seems you can hide stuff while drunk. I will give this a spin tomorrow and see how much 10 years worth of stash I can toss in 300 turns tomorrow :)
 

Crowther

Active member
I found another problem, with the gift function in the script. It doesn't handle sending gifts to players with spaces in their names.

Tom, you might also want to switch to giving some gifts to the undeserving. Just change "deserving" to "undeserving" near the end of the script.
 

Tom Sawyer

Member
Hmmm. Perhaps the use of drunkula's and the script looking for drunken stupor or mafia itself. Managed to hide about 30, I will try not drunk tomorrow :)
 
So the key piece of code for the actual gifting appears to be:
Code:
visit_url("choice.php?target="+target+"&recipient="+who+"&whichchoice=994&pwd&qty1="+qty1+"&itemid1="+item1.to_int()+"&qty2="+qty2+"&itemid2="+item2.to_int()+"&qty3="+qty3+"&itemid3="+item3.to_int()+"&whichhole="+hole+"&effort="+effort+"&note="+note+"&option=1"

...which I could adapt for some simple hard-coded after-adventure gifting. And I think I'd create an array of item ids to choose from if it wasn't just a single item, to really narrow things down. Or just choose from items that have over a specified number in inventory. And do both deserving and undeserving gifts for each visit (different items). And track locations so I only leave up to a certain number of gifts in any one place. And maybe log what was left where? And and and...

Cool, just what I needed for a head start, thanks. Weekend project time. I'll leave it to you generalists to create the ultimate gift script that just keeps giving.
 

Crowther

Active member
Yes, that is the "key", however the function gift() is a wrapper that provides error checking a number of other useful features. If you look at the bottom, the function main calls gift(). That's where I'd recommend you make your changes. Replace main with whatever magic you want and call gift() to hand out the gifts.
 

blech

New member
It would be quite useful if instead of picking from all items, it picked from a list you could set. Probably as an external text file?

Thanks for the script!
 

dueregar

New member
I hope Crowther has no objection to me posting this modification of his script, and if so I will remove it but I modified his script to give a gamma nog, a neutron lollipop, and a random choice of one of the cheap schematics. It will purchase each of the items up to a max price that you can set to protect against sudden mall swings as crimbo progresses. Its ugly as I haven't done any coding in years and decided this would be a good way to practice while I'm laid up on bed rest the next week or so. I'm open to any suggestions or ideas if anyone has some. I would prefer to only purchase the item if you don't have it already but mafia doesn't seem to be removing items from inventory when you hide them so that fails unless you force a session refresh after each gift hidden which seemed to wasteful. Besides I'm a hoarder and lots of leftovers from misfires kind of appeal to me anyway.
 

Attachments

  • Hide_schematic.ash
    3.8 KB · Views: 40

dueregar

New member
You need a newer version of mafia then.

Yeah, that was my first thought so I downloaded it but no dice. Currently seeing this behavior on v16.7 r15045 which is the newest available right now.

Edit: I just manually left a present and mafia doesn't remove the items from my inventory that way either so its not a problem with the script.
 
Last edited:

lostcalpolydude

Developer
Staff member
It took two weeks for anyone to say that the code for that isn't actually working, so that's why no one was doing anything to make it actually work.
 

dueregar

New member
Lol sorry bout that. I usually just download the pre made scripts the experts post and am always amazed at how you guys do all you do. This morning I decided to try and learn a little more about how things work and noticed it while trying to test the mods I made. I saw you posted it in the bug report section already so I'll leave it be. Next time I notice something strange I'll post it there.
 

Crowther

Active member
I hope Crowther has no objection to me posting this modification of his script
Of course not. My whole point in posting that script was to give someone a starting point to do something more.

I thought I checked to make sure KoLmafia was removing items from inventory. I guess I didn't check closely enough. Or maybe I forgot to test when the update came out.
 
Top