Information Request

drakono82

New member
Hi. I'm completely new to mafia scripting (but I'm a computer engineer, so I'm sure I can pick some of it up quickly.) I'm going on a 2-week vacation soon, and won't be logging on to KoL for that time. I figured if I could figure it out myself, or leverage existing scripts, I could still have my character make some use of this time. I'm looking for information or tips on how to do the following. (I'm not looking for anyone to write this for me, but if you know where pieces/similar scripts exist that I could use to make my script, I'd very much appreciate it.)

1. Start mafia daily on my home computer, and have it start its work on its own.

This looks to be easily achievable with Scheduled Tasks in Windows, auto-login on mafia, and an On Login script in the breakfast section.

2. Have mafia log out (and preferably close) after completing its work.

I'm not sure how to accomplish this. Scheduled Tasks has an option to end a task after a period, but it isn't doing anything as far as I can tell.

3. Consume

I can just buy all the consumables ahead of time to avoid mall scripting. I assume if the menu is planned out, it's pretty easy to throw into any script?

4. Bounty hunt

I've found bounty.ash here. Do I need anything more than that one file? I was planning on testing it out tomorrow.

5. Level up

I imagine this is pretty easy, too, since I'd just do Spookyraven leveling. (I'll likely be a Sauceror.)

Bonus:
Yellow-ray twice a day for duct tape. I don't know how hard this will be. It would require overriding mafia's auto-adventuring. Any tips?

That's about it. My main goal is to level (for the trophy and a basement run), but I wouldn't want to miss those bounties, either. So, any tips? Threads where folks have already done something like this? Or even a beginner's guide to .ash scripting, or functions already existing in mafia?

(I plan to closet my meat and shinies that I won't need for these tasks, just in case. Any tips along this line? Other precautionary measures?)

Thank in advance.
 

Grotfang

Developer
Okay. Firstly, task scheduler is definitely the way to go. Secondly, you can call a script straight from command line, so that can be included in the scheduler.

A scheduled task along the lines of:

Code:
javaw -jar KoLmafia-8155.jar login.txt

An example of login.txt:

Code:
login grotfang
call dailyRoutine.ash
exit

dailyRoutine.ash is everything you want to do that day. If you have multiple scripts to run, just do them in order.

Save login.txt in the same directory as the .jar file (and include a cd to that directory at the beginning of the task).
 

heeheehee

Developer
Staff member
Functions already existing in Mafia can be found via >help (for CLI commands) and >ashref (for ASH functions). You can add filters to the these CLI commands to filter out all ASH functions that contain the specified string.

A lot of this can be done with CLI -- heck, you wouldn't even have to buy up stuff in advance, as there's the acquire int item CLI command.

>logout should take care of logging out. Heh.

The bonus could be done by creating a counter script -- this would require ASH. I'm not too sure about the details, but I could look it up.

Erm, yeah. Ninja'd.
 

Grotfang

Developer
I should clarify. Including exit at the end of your .txt file will cause mafia to close. Logout will only logout. Both are acceptable. As for your script - I will leave advice on that for better equipped minds than mine :)
 

StDoodle

Minion
1. Start mafia daily on my home computer, and have it start its work on its own.

Looks like you know what to do here.

2. Have mafia log out (and preferably close) after completing its work.

I'm not sure how to accomplish this. Scheduled Tasks has an option to end a task after a period, but it isn't doing anything as far as I can tell.

Scheduled tasks should work using "shutdown.exe". The problem is, that won't actually shutdown by itself, it will just pop up the "are you sure" dialog or whatever, depending on windows flavour / etc. What you need to do is look up the command as it's used for your particular OS version, and pass the parameters that force it to shutdown immediately, regardless of what may be running. Using "shutdown.exe -s -t 00" works for some versions, but YMMV.

I can just buy all the consumables ahead of time to avoid mall scripting. I assume if the menu is planned out, it's pretty easy to throw into any script?

Yeah, if we're looking at a simple text-file (.txt) script, you can just use "buy [how many] [whatever you want]" & "use [same params]." Ash is a bit different, but look at the wiki (http://wiki.kolmafia.us/) or the repository on this forum.

[Other stuff, and...](I plan to closet my meat and shinies that I won't need for these tasks, just in case. Any tips along this line? Other precautionary measures?)

Meh, shouldn't be necessary. The big worry, IMO, is if something "borks" while you're away (a KoL-side change makes mafia stop working, you lose power halfway through what you're doing, etc.). Not much you can do about that short of setting up remote access to your machine, in which case... whole 'nother topic. ;)

I would HIGHLY recommend setting up whatever you want your script to do, and testing it at least once before you leave, of course. Good luck, and feel free to ask additional questions if you have any "how do I do [x]" sorts of queries.
 

drakono82

New member
Thanks for the rapid responses. The tips given leave have been very helpful. And yes, I plan to test everything out in advance.

I tried bounty.ash today with FirstThingsFirst and Best Between Battle Script Ever, but it didn't olfact or putty. I realized I hadn't modified the ccs midway through the bounty. After changing it to have it consult FTF, it still didn't olfact/putty for the second half of the bounty. Am I missing something, or did it not pick up on being on a bounty because I didn't have it doing that from the start?
 

mredge73

Member
You can look into EatDrink.ash for consuming.
I would also be running Bale's counter and recovery scripts.

Scheduled task program sucks for running .jar files so that is another reason to get Rinn's script. This script fixes 3 problems with boting: windows task manager has a .exe to run, mafia will stay up to date, and it will auto-login.

When calling bounty.ash from an ash script or auto adventuring I would make sure to catch the return value to prevent the script from aborting prematurely.
Code:
if(cli_execute("bounty.ash *"))    {}    

if(adventure(my_adventures(), $location[giant castle]))      {}
For swapping outfits I would use mafia's new maximizer but you can always go old school:
Code:
cli_execute( "maximize meat" );

outfit("hobo nickles");
For moods:
Code:
 cli_execute("mood items; mood execute");
And at the very end of your script make sure you add the line:
Code:
cli_execute("exit");
This will close mafia so you don't have to worry about using scheduled tasks to shutdown the program.


I have many functions in my function library that you may find useful as well.
 
Last edited:

zarqon

Well-known member
FTF will only olfact if mafia knows you're on a bounty hunt, and the bounty isn't a 40-turn bounty, and you have enough MP. If FTF was not olfacting a bounty monster, I suspect it would be because one of these conditions was not true.

FTF will also only putty bounty monsters if the number of required items is not larger than your putty_bounties_upto setting.
 

heeheehee

Developer
Staff member
I'd say to use cli_execute("logout"); (as opposed to "exit") in your login script, then have if(my_name() == user2) cli_execute("login user2"); directly afterwards. If my thinking is correct, your login script should trigger again right after this command.
 

Camber

Member
I'd say to use cli_execute("logout"); (as opposed to "exit") in your login script, then have if(my_name() == user2) cli_execute("login user2"); directly afterwards. If my thinking is correct, your login script should trigger again right after this command.

I think that should be: if(my_name() == user1)

And i think you don't need the logout command, as the login will log you out if you are already logged in.
 
Top