Modern castlefarming script

izchak

Member
EDIT: Updated!
EDIT: Updated again! (21 April 2007)
EDIT: Updated yet again! (5 November 2007)
EDIT: And again. Sheesh. (15 November 2007)

This is a script I put together, at the request of another player. It's tailored for a moxie class with superhuman cocktailcrafting, and advanced cocktailcrafting, but it will work without them.

Default consumption:
5 prussian cathouse, 3 fine wine OR
5 Rolls in the hay, 3 fine wine
1 milk of magnesium
3 knob sausage chow mein
15 twinkly wad

Toggles:

  • [li]DIYBooze. This is used to control whether you make your own superhuman drinks. Default: off.[/li]
    [li]KGE buff maintenance: Nasal spray & pet-buffing spray. Default: on.[/li]
    [li]Cantata of Confrontation, shrugging it off for ode where necessary. Default: on.[/li]
    [li]Parallelize Cantata requests: This is a new feature, to request cantata from multiple buffbots instead of just one. At the same time. Faster, but less efficient than waiting for a single buffbot. Default: on.[/li]
    [li]Pulverize toggle, to smash wolf masks and giant needles.This disables itself if you cant smash stuff. Default: on.[/li]
    [li]Hermit Looting. This gets clovers from the hermit, using 31337 scrolls as a source of worthless trinkets.Haxor the hermit first, please. Default: on.[/li]
    [li]useCollectorsFile, and closetCollectables. These are related, and described below. Default: off.[/li]
    [li]doBountyHunt. This does your daily bounty hunt for lucre. It tries to choose the highest level hunt it can.[/li]
    [li]conserveMilk. Set this to true to use one milk of magnesium every two days. Can cause issues with buff ordering, and accurate profit calculation.[/li]

As you can see, the toggles are many and numerous. They're all at the top of the script, and commented. You might want to change some of them about.

Last, but not least, here is what this script actually does:

  • [li]restock supplies (food, booze, spleenies, ingredients)[/li]
    [li]make your superhuman drinks, unless that has been toggled off[/li]
    [li]eat food[/li]
    [li]drink booze, using ode to booze[/li]
    [li]Complete todays bountyhunt for lucre, unless that's been disabled.[/li]
    [li]check buff levels. Basically, shrug off ode and get cantata, unless thats disabled. Also, KGE buffs, unless disabled.[/li]
    [li]switch to a custom farming outfit, called "Castlefarming"[/li]
    [li]spend all adventures at the giant castle[/li]
    [li]switch to a custom rollover outfit, called "Nightdress"[/li]
    [li]sell and smash the loot[/li]
    [li]get ode to booze, and drink a nightcap[/li]
    [li]use milk and eat food, if you're being conservative with your milk, and haven't eaten yet[/li]
    [li]calculate todays profits, including an average meat gain per adventure[/li]
    [li]NEW! Try to save a report of todays activity. Broken in certain versions of mafia.[/li]

If you have a plexiglass pith helmet as part of your farming outfit, it will attempt to use the generated mana to maintain your buffs, similar to what the new versions of mafia do with the mood maintenance thingy. It confuses me a little bit, so I haven't disabled this :)
I have tried to make this as customizable as possible, because I know everyone has a slightly different setup for farming. For instance, its trivial to change the food about, or the names of the custom outfits, etcetera, etcetera. This is also why I put in a bunch of toggles. All of the toggles are at the top of the script, and commented.
I did, however, make the assumption that you have liver of steel, not stomach of steel. It'd be trivial to switch that about, though, if desired.

I also assume that you have bought phat loot and polka in bulk, as I make no attempt to maintain those buff levels.
On the current TODO list is the following (I like lists):

  • [li]TPS drinks, and the preparation thereof.[/li]
    [li]Easier way to switch about between Liver and stomach of steel, and the quantities of food/booze for each[/li]
    [li]Spending excess Plexipith MP on candy heart summoning. Or any kind of candy heart action at all, in fact.[/li]

All of this stuff on my TODO list is kind of low priority, because I don't really need them. So, if you would find any of these future features useful, nag me! And I might even pay heed to your nagging, and update this script some more!

21 April update details:
(useCollectorsFile, and closetCollectables)
Basically, some of the castle farmed items are worth more to certain collectors, than you will get from autoselling them. This lets you define a list of collectors, with who pays what for what items. Then, when this script goes to sell your found loot, it won't sell stuff that can be sold to collectors. Make sense?
For instance, someone called 'thePlotHole' collects plot holes (surprise, surprise). He pays 175 meat per, which is better than the autosell. This guy is in the attached collectors.txt file, BTW.
It also figures out how much those items are worth, and what their potential value is, which it adds to the running potentialMeat total, used for the calculate_profit routine.
I have already found a few collectors, and have made a list with them. A basic collectors.txt file should be attached.
By default, this feature is turned off, because it detracts somewhat from the automated nature of this script, and the collectors could stop collecting, or something.
Related to this feature is the closetCollectables toggle. By default, this is turned on. Basically, this will closet all of the collectable items, so as not to include them when calculating tomorrows profits!
If useCollectorsFile is turned off, no closeting of collectable items will happen, by the way. If its turned off, you can pretend this new feature was never added, in fact!
I prefer to let the collectable items build up, and once a week or so, log in, and set up trade offers with the various collectors. By then, a decent quantity of items has built up.
Who says the closet is useless?
BTW: If you choose to use this feature, put the 'collectors.txt' file into either your scripts directory, or the data directory. I put it under data, but I think it'll work from either position.

5 November update:
I've added some automatic bountyhunting. It tries to pick the highest level bountyhunt available, and it checks to see if you can actually access the bountyhunt zone. If there's enough demand, I may optimize lucre farming a bit (IE: use combat modifiers where appropriate).
I've also added a 'food_fullness' integer. This is basically so that the script can automatically cope with feast of boris, or lesser filling foods (super salad, for instance).

15 November update:
Testudinata has changed her prices, the old price for Ode now gets a casting of madrigal, which kinda breaks getting ode from her. Script updated to reflect this change in price.


I have tested this new version, but not extensively. If anything is broken, please let me know, and I'll fixz0r it.
Also, if anyone has any feature requests, feel free to ask me! There are no guarantees I will implement XYZ feature request, but if its a good idea, there's a good chance I will.
 

Attachments

  • collectors.txt
    254 bytes · Views: 751
  • bountyhunting.ash
    11.6 KB · Views: 654
  • bounty.txt
    3.1 KB · Views: 581
  • izchak_castlefarm.ash
    27 KB · Views: 838
Re: Castlefarming, liver of steel, SHC

Nice job! Normally when I nose around in a script posted here I find ways to improve on speed and server hits. The only possible one is how you handle clovers, but that's trivial. Max of 5 extra not counting redirects.

I did see one thing though.

Code:
# yeah, yeah. making this a boolean returner is pretty pointless at the moment
# so? sue me!
# maybe one day this will be more complicated.
boolean eatFood() {
	# use milk of magnesium
	use(1, milk);
	# eat 3 meins
	eat(3, food);
	return true;
}

See ya in court ROFL How about making it have a more useful return?
Code:
boolean eatFood() {
	# use milk of magnesium
	//avoid eating unless we manage to use milk
        if(use(1, milk)) 
          {
	  # eat 3 meins
          //return the return value of the attempt to eat.
	  return eat(3, food);
          }
        //use of 1 milk failed if it got here so
        return false;
        //this also covers the missing return value error which is why I did not use else 
}
 

izchak

Member
Re: Castlefarming, liver of steel, SHC

Thanks, efilnikufecin, suggestion duly noted!
I incorporated that little change, and did a small amount of general cleanup. Selling and pulverizing is a little less server intensive now. Updated script attached.

Code:
# improved returning action here courtesy of efilnikufecin, from the mafia forums
boolean eatFood() {
	# use milk of magnesium
	if( use(1, milk) ) {
		# eat 3 meins
		return eat(3, food);
	}
	# if we get here, we failed to use the milk
	return false;
	
}
 

izchak

Member
Updated with some new features, including some action for the new "The butler did it" trophy.
Details are summarized in the first post. Expect future updates, when I get bored and work spiffy new features into it.
 

itamaram

Member
for int i = (initial value) upto (final value){
statement 1;
statement 2;
...
}

All bow to my superior spare time skills!
 
SkillCost(skill VarCost) probably came from my old ICY peak farming script, but it its deprecated and should be replaced with:
int mp_cost( skill sk)
Returns the amount of MP that it costs to use the specified skill. Passive skills return 0. MP reduction items are automatically included in this calculation.

int my_maxsober() {
if (have_skill($skill[liver of steel])) return 19;
return 14;
}

did you know about:
int inebriety_limit()
Returns the inebriety limit at which you must stop adventuring. You only need to subtract 1 to get your maximum inebriety to still adventure.
 

izchak

Member
[quote author=itamaram link=topic=801.msg3909#msg3909 date=1173522375]
for int i = (initial value) upto (final value){
statement 1;
statement 2;
...
}

All bow to my superior spare time skills!
[/quote]
Thanks, itamaram!
That quoted if statement didnt quite work, but I was able to track down some if statements that do work via your profile. For the record, this is the eventual if statement I ended up using, instead of the klunky while (count < 0) loop I had...
Code:
int split = maximumAdv / chunk;
for i from 0 upto split {
Turns out, you cant declare i to be an int there, its automatically an int!

[quote author=efilnikufecin link=topic=801.msg3910#msg3910 date=1173528736]
SkillCost(skill VarCost) probably came from my old ICY peak farming script, but it its deprecated and should be replaced with:
int mp_cost( skill sk)
Returns the amount of MP that it costs to use the specified skill. Passive skills return 0. MP reduction items are automatically included in this calculation.

did you know about:
int inebriety_limit()
Returns the inebriety limit at which you must stop adventuring. You only need to subtract 1 to get your maximum inebriety to still adventure.
[/quote]

Thanks, elfi!
I threw out that rather awkward but useful SkillCost routine, and used this probably-not-new-at-all-anymore mp_cost() function instead.
As for inebriety_limit(), no, I was not aware of it. I don't think I will actually use it for this script, as it would involve a little bit of rewriting, and it wouldn't necessarily make things any simpler than how they currently are.
I'll bear it in mind for future scripts, though!
 

Le Canard

New member
[quote author=izchak link=topic=801.msg3865#msg3865 date=1172944921]
Default consumption:
5 mons tiki, 3 shots of tomato schnapps OR
5 Rolls in the hay, 3 shots of tomato schnapps
[/quote]

don't you mean 4 mons tiki or 4 rolls in the hay? 5 would put you over the limit (5 drinks at 4 drunkeness each). i dont know if this was just a typo made in your post or not, but it would be worth double checking. i would look myself, but frankly, im new to the whole kolmafia/scripting thing, so i don't know how to look at the coding and whatnot of the actual script itself. :/.
 
[quote author=Le Canard link=topic=801.msg3931#msg3931 date=1173817657]


don't you mean 4 mons tiki or 4 rolls in the hay? 5 would put you over the limit (5 drinks at 4 drunkeness each). i dont know if this was just a typo made in your post or not, but it would be worth double checking. i would look myself, but frankly, im new to the whole kolmafia/scripting thing, so i don't know how to look at the coding and whatnot of the actual script itself. :/.
[/quote]

before adventuring 4 of either and 3 shots.
after adventuring 1 of either, the extra adventures will be added to the +40 at rollover.
 

hobo386

New member
Code:
boolean eatFood() {
	# use milk of magnesium
	if( use(1, milk) ) {
		# eat 3 meins
		return eat(3, food);
	}
	# if we get here, we failed to use the milk
	return false;
}

I have changed to

Code:
boolean eat_food() {
        #checks to see if you already have used a milk
        if (have_effect( $effect[Got Milk])>0){
		int quantity = 3;
		if (have_skill($skill[stomach of steel])) quantity = 4; 
		return eat(quantity, food);}
	# use milk of magnesium
	if( use(1, milk) ) {
		# eat 3 (or 4) meins
		int quantity = 3;
		if (have_skill($skill[stomach of steel])) quantity = 4; 
		return eat(quantity, food);
	}
	# if we get here, we failed to use the milk
	return false;
}

for my own personal use. If it is working as intended, it should stop me from drinking a milk of magnesium if I already have one used.
The code seems to work great though, except for when I tinker with it a bunch.
Also, just as a note, I use ram's face lager instead of schnapps. They are usually only 20 meat more expensive, and they seem to be worth it. I do realize that all food and booze is just a preference though.
 
[quote author=hobo386 link=topic=801.msg4022#msg4022 date=1175337201]
I have changed to

Code:
boolean eat_food() {
        #checks to see if you already have used a milk
        if (have_effect( $effect[Got Milk])>0){
		int quantity = 3;
		if (have_skill($skill[stomach of steel])) quantity = 4; 
		return eat(quantity, food);}
	# use milk of magnesium
	if( use(1, milk) ) {
		# eat 3 (or 4) meins
		int quantity = 3;
		if (have_skill($skill[stomach of steel])) quantity = 4; 
		return eat(quantity, food);
	}
	# if we get here, we failed to use the milk
	return false;
}

for my own personal use. If it is working as intended, it should stop me from drinking a milk of magnesium if I already have one used.
The code seems to work great though, except for when I tinker with it a bunch.
Also, just as a note, I use ram's face lager instead of schnapps. They are usually only 20 meat more expensive, and they seem to be worth it. I do realize that all food and booze is just a preference though.
[/quote]

When I am using 2 commands in a row more than 1 time in a script, I tend to write a separate
function. This proves helpful in readability when a script becomes huge because it can reduce the overall size of the script by 4 or more lines, and remove 1 or more if statements, and multiple control character pairs.

Code:
int food_quant()  {
       if (have_skill($skill[stomach of steel])) return 4;
       return 3;
}

boolean eat_food() {
        #checks to see if you already have used a milk and if so just eats
        if (have_effect( $effect[Got Milk])>0) return eat(food_quant() , food);
	# use milk of magnesium then eat
	if( use(1, milk) ) return eat(food_quant(), food);
	# if we get here, we failed to use the milk
	return false;
}

It makes the code easier to edit, and reduces the likelihood of me breaking something while editing.
 

hobo386

New member
Interesting, and thanks.

I'm kindof new to this scripting language, so even modifying a script to do a small task is actually a lot to me. If I ever make any more changes I deem potentially useful, I'll post them.
 

Le Canard

New member
pardon my noobishness, but how do you view the coding for the script?  i want to change some of the options and stuff on the script, but i dont know how to get to the coding in order to do so.

EDIT- i guess what i meant to say was, how do you get it to open in notepad or whatever in the first place so you can change stuff around.
 

izchak

Member
I've had more than one person ask me how to modify this script, so I'm going to post a brief walkthough of how to modify this script, for a few commonly adjusted items.
First, you can use any text editor to edit the script, notepad will do just fine.
The commonly adjusted variables are all at the top of the script, for the sake of convenience.
Here's the code you will more than likely want to modify.
Code:
# written by izchak (#557041)
# <GLOBALS>
# you can fiddle about with these if you want to change stuff about
item superCock = 	$item[mon tiki];
item garnish = 		$item[coconut shell];
item spirits = 		$item[bottle of rum];
item superSpirits = 	$item[bottle of Lieutenant Freeman];
item mixer = 		$item[lemon];
item superMixer = 	$item[kiwi];
# by default, this filler drink will be drunk thrice
item fillerDrink = 	$item[shot of tomato schnapps];
item food = 		$item[knob sausage chow mein];
item milk = 		$item[milk of magnesium];
string farmingGear = "Farming Armor";
string rolloverGear = "Rollover Duds";

# set this to false if you dont want to make your own booze
boolean DIYbooze = false;
# if DIYbooze is true, dont worry about this variable
# this determines what drink to drink instead of a supercock
item DBbooze = $item[roll in the hay];
Now, say you want to change the food to hot hi mein. This is the line you will want to change:
Code:
item food = 		$item[knob sausage chow mein];
and this is what you will want to change it TO.
Code:
item food = 		$item[hot hi mein];
Pretty simple, huh?

Now, say you want to drink fine wine, instead of tomato schnapps. Similar process. Change this:
Code:
item fillerDrink = 	$item[shot of tomato schnapps];
into this
Code:
item fillerDrink = 	$item[fine wine];

If you want to enable the making of superhuman drinks, you need to change this line:
Code:
boolean DIYbooze = false;
into this:
Code:
boolean DIYbooze = true;
NOTE: by default, this script will make mon tikis as the chosen superhuman drink. Also, if DIYBooze is set to true, it automatically overrides the item entry for DBDrink, so you dont need to change that variable. It will automatically make, and drink, the specified superhuman drink.

If you want to change the TYPE of superhuman drink about, its a similar process to changing the type of food, only there are more variables involved. Here are the lines you will need to change for that.
Code:
item superCock = 	$item[mon tiki];
item garnish = 		$item[coconut shell];
item spirits = 		$item[bottle of rum];
item superSpirits = 	$item[bottle of Lieutenant Freeman];
item mixer = 		$item[lemon];
item superMixer = 	$item[kiwi];

I hope that helps!
 

hobo386

New member
For some reason when I try this with 10.9 I get an error along the lines of "use the 'csend' command to request buffs.

Does anyone else experience this? If so or even if not, how would I fix it?
 

exdeath

Member
Change all message like this
Code:
cli_execute("send 7 meat to testudinata");
to
Code:
cli_execute("csend 7 meat to testudinata");
and it will work just fine again.
 

Le Canard

New member
apparently, i messed with it a bit TOO much. now, even if i have the right ingredients and stuff, i get the "failed to create cocktails" error. can someone help me figure out what i screwed up?
 

Attachments

  • izchak_castlefarm.ash
    26.4 KB · Views: 71

izchak

Member
Hi, Le Canard.

This was my mistake. I don't actually use DIYBooze, I drink DB drinks, so I didnt notice when I accidentally broke superhuman drinks.

This was the offending line:
Code:
print("trying to make some superhuman cocktails...");
if(my_primestat() == $stat[ moxie ]) {
	print("youre not a moxie class, and hence cannot use the still");
	return false;
}

And this is what it SHOULD have been
Code:
print("trying to make some superhuman cocktails...");
if(my_primestat() != $stat[ moxie ]) {
	print("youre not a moxie class, and hence cannot use the still");
	return false;
}

Whoops!
Note the NOT EQUALS there, it made all the difference. Now, if you aren't a moxie class, that little chunk should abort you properly...

I'm in the process of making some other updates to this script, so I'll post an updated version of the entire script soon. In the meantime, the attached file *should* work.

New, updated script!
Details!
Exclamation marks!!

I've been slowly working on this for a while now, so I might forget a new feature or two. Here is the summary:

  • [li]smarter milk use. This script should now use only half as much milk of magnesia. By eating at the end of the day half the time, you can gain the benefit of milk the next day, without needing to purchase it tomorrow![/li]
    [li]working superhuman drinks. I made a small mistake, which broke superhuman drink making. Whoops, fixed![/li]
    [li]working buff requests. Mafia now requires us to use csend when requesting philanthropic buffs. Fixed.[/li]
    [li]report saving. This tries to save a report of todays activity in a file, for evaluation purposes. This can be handy for figuring out your optimal outfit, or whatever. Sadly, this is broken with certain versions of mafia, but I've left it in anyway, since its a harmless break (it creates empty files when broken).[/li]
    [li]and finally, the big new feature, collectors.txt! This is fairly complex. Described below...[/li]
    [li]two collectables toggles: useCollectorsFile, and closetCollectables. Also described below...[/li]

Basically, some of the castle farmed items are worth more to certain collectors, than you will get from autoselling them. This lets you define a list of collectors, with who pays what for what items. Then, when this script makes to sell your found loot, it won't sell stuff that can be sold to collectors. Make sense?
It also figures out how much those items are worth, and what their potential value is, which it adds to the running potentialMeat total, used for the calculate_profit routine.
I have already found a few collectors, and have made a list with them. I'll attach that file to the main post.
By default, this feature is turned off, because it detracts somewhat from the automated nature of this script, and the collectors could stop collecting.
Related to this feature is the closetCollectables toggle. BY default, this is turned on. Basically, this will closet all of the collectable items, so as not to include them when calculating tomorrows profits!
I prefer to let the collectable items build up, and once a week or so, log in, and set up trade offers with the various collectors. By then, a decent quantity of items has built up.
Who says the closet is useless?

P.S. this post is kind of a duplicate of my updates to the main thread post, but redundant information isn't such a bad thing, is it?
 

Attachments

  • le_canard.izchak_castlefarm.ash
    26.4 KB · Views: 90

hobo386

New member
[quote author=izchak link=topic=801.msg4264#msg4264 date=1177163544]
I've been slowly working on this for a while now, so I might forget a new feature or two. Here is the summary:

  • [li]smarter milk use. This script should now use only half as much milk of magnesia. BY eating at the end of the day half the time, you can gain the benefit of milk the next day, without needing to purchase it tomorrow![/li]
    [li]report saving. This tries to save a report of todays activity in a file, for evaluation purposes. This can be handy for figuring out your optimal outfit, or whatever. Sadly, this is broken with certain versions of mafia, but I've left it in anyway, since its a harmless break (it creates empty files when broken).[/li]
    [li]and finally, the big new feature, collectors.txt! This is fairly complex. Described below...[/li]
[/quote]

Wow, now this script is actually smarter than me when I farm on my own. What next?
 
Top