What's in your login/logout scripts?

Bale

Minion
I'm curious what other people do in their login and logout scripts? Assuming that mafia's "breakfast" feature is not good enough for them, of course.

One thing that I use login/logout for is to account for different characters having different tomes and librams.

Then I want the libram available for manaburning during the run without having to spend all my mana on libram casting during breakfast. (The same option controls both behaviors.) To do that I set the breakfast option for libram casting during the login script (after breakfast has run) and then disable libram casting during the logout script.

I have my login script remove the sword behind inappropriate prepositions and my logout script maximize adventures if I am overdrunk. That way I don't get stuck saying weird things in chat. :)

Does anyone else have clever tricks like that to share? Here are my login and logout scripts:

LoginScript:
PHP:
void improve_spirits() {
	if(stills_available() < 1)
		return;
	item [item] upgrade;
	upgrade[$item[bottle of gin]] = $item[bottle of Calcutta Emerald];
	upgrade[$item[bottle of rum]] = $item[bottle of Lieutenant Freeman];
	upgrade[$item[bottle of tequila]] = $item[bottle of Jorge Sinsonte];
	upgrade[$item[bottle of vodka]] = $item[bottle of Definit];
	upgrade[$item[bottle of whiskey]] = $item[bottle of Domesticated Turkey];
	upgrade[$item[boxed wine]] = $item[boxed champagne];
	upgrade[$item[grapefruit]] = $item[tangerine];
	upgrade[$item[lemon]] = $item[kiwi];
	upgrade[$item[olive]] = $item[cocktail onion];
	upgrade[$item[orange]] = $item[kumquat];
	upgrade[$item[soda water]] = $item[tonic water];
	upgrade[$item[strawberry]] = $item[raspberry];
	upgrade[$item[bottle of sewage schnapps]] = $item[bottle of Ooze-O];
	upgrade[$item[bottle of sake]] = $item[bottle of Pete Sake];

	item best;
	int profit = 0;
	int test_profit;
	foreach key in upgrade {
		if(historical_age(upgrade[key])>1) mall_price(upgrade[key]);
		if(historical_age(key)>1) mall_price(key);
		test_profit = historical_price(upgrade[key]) - historical_price(key);
		if(test_profit > profit) {
			best = key;
			profit = test_profit;
		}
	}

	print("Creating " + stills_available()+ " " +upgrade[best]+ " to sell @ "+historical_price(upgrade[best]), "blue");
	retrieve_item(stills_available(), best);
	create(stills_available(), upgrade[best]);
	put_shop(historical_price(upgrade[best]), 0,  upgrade[best]);
	#cli_execute("mallsell * "+ upgrade[best]+ " @ "+ historical_price(upgrade[best]));
}

void gravitate() {
	int rainbowLeft;
	boolean noSummonsLeft() {
		rainbowLeft = 3 - get_property("prismaticSummons").to_int();
		return rainbowLeft < 1;
	}
	if(!have_skill($skill[Rainbow Gravitation]) || noSummonsLeft()) return;
	foreach key in $items[twinkly wad, hot wad, cold wad, spooky wad, stench wad, sleaze wad]
		retrieve_item(rainbowLeft, key);
	use_skill(rainbowLeft, $skill[rainbow gravitation]);
}

void cast_tome() {
	string tome = "";
	if(have_skill($skill[Summon Snowcones]))         tome = "Summon Snowcones";
	else if(have_skill($skill[Summon Sugar Sheets])) tome = "Summon Sugar Sheets";
	else if(have_skill($skill[Summon Stickers]))     tome = "Summon Stickers";
	if(tome != "") cli_execute("cast * "+tome);
}

string libram = "";
if(have_skill($skill[Summon Party Favor]))       libram = "Summon Party Favor";
else if(have_skill($skill[Summon BRICKOs]))      libram = "Summon BRICKOs";
else if(have_skill($skill[Summon Candy Hearts])) libram = "Summon Candy Hearts";
else if(have_skill($skill[Summon Love Song]))    libram = "Summon Love Song";

if(get_property("_loginScript") != "dayStarted") {
	if(can_interact()) {
		
		cli_execute("chips radium, ennui, wintergreen");
		improve_spirits();
		gravitate();
		cast_tome();
	
	}
	set_property("_loginScript", "dayStarted");
}

if(libram != "") {
	if(can_interact()) set_property("libramSkillsSoftcore", libram);
	else set_property("libramSkillsHardcore", libram);
}

if(have_equipped($item[sword behind inappropriate prepositions])) {
	print("Removing the pesky sword to save your prepositions.", "blue");
	equip($slot[weapon], $item[none]);
}

logout script:

PHP:
set_property("libramSkillsSoftcore", "none");
set_property("libramSkillsHardcore", "none");

if(my_inebriety() > inebriety_limit())
	cli_execute("maximize adv, switch disembodied hand");
 

Winterbay

Active member
Here are mine. They are most likely not everything they could be but they are a work in progress so :) (any comments are very welcome)

Login:
PHP:
import <bafh.ash>

if (my_name() == "molman")
{
	if(my_inebriety() <= inebriety_limit())
	{
		cli_execute("meat 100000");
		adv1(to_location("Giant's Castle"),-1,"");
		cli_execute("farm");
	}
	else
	{
		print("You are way too drunk to farm. Come back tomorrow.");
	}
}
else if(my_name() == "Winterbay")
{
	if(in_bad_moon() && in_hardcore())
	{
	}
	else
	{
		if(my_class() == to_class("Sauceror") && get_property("lastNemesisReset") == get_property("knownAscensions"))
		{
			if (user_confirm("Do you want to gather slimes?"))
			{
				string test;
				for i from 1 to 10
				{
					test = visit_url("volcanoisland.php?pwd&action=npc&subaction=getslime");
					if (contains_text(test,"Maybe tomorrow"))
					{
						print("You've already received your slimes for today, stopping");
						exit;
					}
				}
			}
		}
		if(user_confirm("Do you want to jump to BAfH?"))
		{
			int origin = origin_clan();
			goto_clan(90485);
			visit_vip("crimbotree get");
			visit_vip("glass");
			visit_vip("pool 3");
			visit_vip("pool 3");
			visit_vip("pool 3");
			visit_vip("ballpit");
			goto_clan(origin);
		}
	}
}

Logout:
PHP:
# Logout script for Molman and Winterbay

record itemprice
{
	item name;
	int price;
	boolean highest;
};

void buy_wine()
{
	itemprice[int] wines;
	int[int] high;
	high[0] = 0;
	high[1] = 0;
	high[2] = 0;
	for i from 1575 to 1586
	{
		wines[i-1574].highest = false;
		wines[i-1574].name = to_item(i);
		wines[i-1574].price = mall_price(to_item(i));
		high[1] = max(wines[i-1574].price,high[0]);

		if ( high[0] < high[1])
		{
			wines[i-1574].highest = true;
			high[0] = high[1];
			if ((high[2] != (i-1574)) && high[2] == 0)
			{
				high[2] = i-1574;
			}
			else if (high[2] != (i-1574))
			{
				wines[high[2]].highest = false;
				high[2] = i-1574;
			}
		}
	}
	foreach index in wines
	{
		if(wines[index].highest)
		{
			print("The most expensive drink is " + wines[index].name + " with a value of " + wines[index].price);
			print("Creating 1 " + wines[index].name);
			if(create(1,wines[index].name))
			{
				print("Putting drink in store");
				put_shop(0,0,wines[index].name);
			}
			else
			{
				print("That did not work as expected.");
				wait(5);
				//put_shop(0,0,wines[index].name);
			}
		}
	}
}

if(my_name() == "molman")
{
	if(item_amount(to_item("pumpkin"))>0)
		put_shop(0,0,to_item("pumpkin"));
	if(item_amount(to_item("\"DRINK ME\" potion"))>0)
		put_shop(0,0,to_item("\"DRINK ME\" potion"));
	while (stills_available() > 1) //Mix superdrinks
	{
		cli_execute("meat 1000");
		buy_wine();
	}
	cli_execute("undercut");
}
else if(my_name() == "winterbay")
{
	if (my_class() == to_class("Sauceror") && can_interact())
	{
		string test;
		int i = 1;
		while ((i < 11) && (my_adventures() > 0))
		{
			test = visit_url("volcanoisland.php?pwd&action=npc&subaction=getslime");
			i = i + 1;
			if (contains_text(test,"Maybe tomorrow"))
			{
				print("You've already received your slimes for today, stopping");
				i = 11;
			}
		}
	}
	cli_execute("maximize adv");
}
 
This is my login script and it runs basically until I log out. Have fun figuring it out.
PHP:
import <mutex.ash>
import <time.ash>

set_property("mainbot","Ominous Buffer");
set_property("selfname","TTang");
set_property("admin","Almighty Sapling");
int burnMinutes=20;
int logMinutes=2;
string botScript="chat.ash";

void earlyOut(){ 
 unlockMutex("_break");
 print_html("<b><font color=000000>Entering runlevel: </font><font color=FF0000>0</font></b>");
 set_property("chatbotScript","");
 cli_execute("maximize adv -tie");
 if(!(mutexFree("_abortNow")))cli_execute("exit");
 exit;
}

record ticket {
	boolean[int] numbers;
	int meganumber;
	int player;
	int ticketId;
};
record bookst {
 int cJackpot;
 int nJackpot;
 int clanCut;
 int myCut;
 ticket lastWeek;
};

int jackpots(){
 bookst[int] BOOKS;
 file_to_map("jbooks.txt",BOOKS,true);
 return BOOKS[1].cJackpot+BOOKS[1].nJackpot+BOOKS[1].myCut+BOOKS[1].clanCut;
}

void cashMeat(){
 cli_execute("cleanup");
 item needle=$item[giant needle];
 string smashBot="csend "+to_string(item_amount(needle))+" "+to_string(needle);
 foreach castle in $items[wolf mask, rave whistle, twinkly nugget]
 smashBot+=", "+to_string(item_amount(castle))+" "+to_string(castle);
 smashBot+=" to smashbot || wad";
 needle=$item[Warm Subject Gift Certificate];
 use(item_amount(needle),needle);
 cli_execute(smashBot);
 int meatGained=my_meat()-500000-jackpots();
 print("Meat Gained: "+to_string(meatGained),"green");
 int donated=meatGained*0.2;
 meatGained-=donated;
 int pdon=meatGained%2000;
 meatGained-=pdon;
 donated+=pdon;
 print("To Lotto: "+to_string(donated),"green");
 print("Kept: "+to_string(meatGained),"green"); 
 cli_execute("csend "+to_string(donated)+" meat to TTang || donate");
 int totalDMS;
 if (meatGained<0){
/*  totalDMS=min(floor((0-1)*meatGained/1000),closet_amount(to_item("dense meat stack")));
  if (totalDMS==0) return;
  take_closet(totalDMS,$item[dense meat stack]);
  autosell(totalDMS,$item[dense meat stack]);*/
 }else{
  totalDMS=floor(meatGained/2000);
  if (totalDMS==0) return;
  string exe="make "+to_string(totalDMS*2)+" dense meat stack";
  cli_execute(exe);
  //put_stash(totalDMS,$item[dense meat stack]);
  put_closet(totalDMS,$item[dense meat stack]);
 }
 if (my_meat()<300000) chat_private(get_property("admin"),"Low Funds");
}

void main(){
 print("Starting Bot","red");
 unlockMutex("_adventuring");
 lockMutex("_abortNow");
 string meatfarm_ccs = "default";
 string meatfarm_fam = "leprechaun";

 if (get_property("_breakfast")==""){
  string rumpus = visit_url("clan_rumpus.php");
  int camp_mp_gain;
  int camp_mp;
  int[item] campground = get_campground();
  if (campground[$item[Frobozz Real-Estate Company Instant House (TM)]] == 1) camp_mp = 40;
  else if (campground[$item[Newbiesport™ Tent]] == 1) camp_mp = 10;
  else if (campground[$item[Barskin Tent]] == 1) camp_mp = 20;
  else if (campground[$item[Cottage]] == 1) camp_mp = 30;
  else if (campground[$item[BRICKO pyramid]] == 1) camp_mp = 35;
  else if (campground[$item[Sandcastle]] == 1) camp_mp = 50;
  else if (campground[$item[House of Twigs and Spit]] == 1) camp_mp = 60;
  else if (campground[$item[Gingerbread House]] == 1) camp_mp = 70;
  else if (campground[$item[Hobo Fortress]] == 1) camp_mp = 85;
  camp_mp_gain = camp_mp;
  if (campground[$item[pagoda plans]] == 1) camp_mp_gain += camp_mp;
  if (stat_bonus_tomorrow() == $stat[mysticality]) camp_mp_gain += camp_mp;
  if (campground[$item[Beanbag chair]] == 1) camp_mp_gain += 30;
  set_property("campmp",camp_mp_gain);
  int rollmp = my_mp();
  set_property("rollmp",rollmp);
  if (contains_text(rumpus,"rump3_3")){
   visit_url("clan_rumpus.php?action=click&spot=3&furni=3");
   visit_url("clan_rumpus.php?action=click&spot=3&furni=3");
   visit_url("clan_rumpus.php?action=click&spot=3&furni=3");
  }
  if (contains_text(rumpus,"rump3_1")){
   visit_url("clan_rumpus.php?action=click&spot=3&furni=1");
   visit_url("clan_rumpus.php?action=click&spot=3&furni=1");
   visit_url("clan_rumpus.php?action=click&spot=3&furni=1");
  }
  if (contains_text(rumpus,"rump1_4")) visit_url("clan_rumpus.php?action=click&spot=1&furni=4");
  if (contains_text(rumpus,"rump4_2")) visit_url("clan_rumpus.php?action=click&spot=4&furni=2");
  if (contains_text(rumpus,"rump9_3")) visit_url("clan_rumpus.php?action=click&spot=9&furni=3");
  if (contains_text(rumpus,"rump4_1")) visit_url("clan_rumpus.php?action=click&spot=4&furni=1");
  if (contains_text(rumpus,"rump3_2")) visit_url("clan_rumpus.php?preaction=jukebox&whichsong=1");
  if (contains_text(rumpus,"rump9_2")){
   visit_url("clan_rumpus.php?preaction=buychips&whichbag=1");
   visit_url("clan_rumpus.php?preaction=buychips&whichbag=2");
   visit_url("clan_rumpus.php?preaction=buychips&whichbag=3");
  }
  if (contains_text(rumpus,"ballpit")) visit_url("clan_rumpus.php?action=click&spot=7");
  if (get_property("sidequestOrchardCompleted") != "none") visit_url("store.php?whichstore=h");
  if (get_property("sidequestArenaCompleted") != "none") visit_url("postwarisland.php?action=concert&pwd&option=2");
  retrieve_item(6,$item[supernova champagne]);
  drink(6,$item[supernova champagne]);
  retrieve_item(1,$item[can of swiller]);
  drink(1,$item[can of swiller]);  
  set_property("_breakfast", "1");
 }
 if (mutexFree("_break")){
  cli_execute("maximize mp");
  cli_execute("maximize mp regen max -tie");
  lockMutex("_break");
 }
 lockMutex("_forcedOut");
 lockMutex("_logoutNow");
 int lastCheck=0;
 if (get_property("chatbotScript")!=botScript){
  waitq(3);
  set_property("chatbotScript",botScript);
 }
 print("Initialization Complete","green");
 print("Bot Started","blue");
 if (get_property("_autod")==""){
  while (!(mutexFree("_logoutNow"))){
   if (minutesToRollover()<burnMinutes) unlockMutex("_logoutNow"); //requires time patch to reduce hits to server
   waitq(2);
   if (timeSeconds()-lastCheck>900){
    lastCheck=timeSeconds();
    cli_execute("call lottoh.ash");
   }
  }
  requestMutex("_adventuring");
  lockMutex("_logoutNow");
  if (mutexFree("_forcedOut")) earlyOut();
  cli_execute("maximize meat");
  cli_execute("familiar "+meatfarm_fam);
  print("Daily Adventuring","red");
  while (my_adventures() > 130){
   adventure(1,$location[giant's castle]);
   while((my_mp()+get_property("campmp"))>get_property("rollmp")) use_skill(1,$skill[empathy of the newt]);
  }
  cli_execute("maximize mp");
  cli_execute("maximize mp regen max -tie");
  print("Daily Adventuring Complete","green");
  print("Handling Funds","red");
  cashMeat();
  print("Balance Met","green");
  print("Bot Resumed","blue");
  unlockMutex("_adventuring");
  set_property("_autod","1");
 }
 while (!(mutexFree("_logoutNow"))){
  if ((minutesToRollover()<logMinutes)&&(mutexFree("_adventuring"))) unlockMutex("_logoutNow");
  waitq(2);
  if (timeSeconds()-lastCheck>3600){
   lastCheck=timeSeconds();
   cli_execute("call lottoh.ash");
  }
 }
 earlyOut();
}
Muahahaha.
 

StDoodle

Minion
Mine were written way back before I knew ash at all, and hence too embarrassing to post. ;) Basically, they just do my daily summoning on login & switch to Brimstone bludgeon & shield and maximize adventures on logout. Both check to make sure I'm aftercore and using my main, of course. But that's about it.
 

Fluxxdog

Active member
My "login" script is my bBS. I have a section dedicated specifically for breakfast however...
PHP:
if(!to_boolean(get_property("breakfastCompleted"))) {
    if(can_interact()) set_property("_startingMeat",my_meat());
    else set_property("_startingMeat",999999999);
    if(!in_aftercore()) cli_execute("call checklog");
    cli_execute("garden pick");
    if(!semirare_aware()) cli_execute("counters");
    cli_execute("breakfast");
    success_print("Ready for a brand new day!");}
This is twoards the end of my bBS and other stuff, like summoning ingredients, comes way before because I use hand-crafted casting scripts. In fact, the options I have enabled in preferences for breakfast are:
*enable auto-recovery *honor path restrictions (In-Ronin) *clan rumpus & VIP
*mushrooms *clovers *manual *once-a-day items
My logout script, I think appropriately named dessert.ash, doesn't get executed at logout. My bBS has a conditional set up so if I'm done adventuring for the day, it calls that script. This way, I can finish up, then stick around and chat:
PHP:
void sweettooth(){
cli_execute("call clutterclean.ash");
# cli_execute("call snapshot.ash"); //Thanks bcc!

if(possess_cheese()){
    gather_the_cheese();
    cli_execute("fold stinky cheese diaper");}
if(possess_item("Crown of Thrones"))
    cli_execute("enthrone grue");

if(get_property("sidequestNunsCompleted") == "fratboy"){
    cli_execute("maximize MP");
    while (prop_count("nunsVisits") < 3){
        cli_execute("nuns");
        summon_nom();}}

cli_execute("maximize 10000 adventures, MP");

if (can_interact() && didIlearn("Rainbow Gravitation")){
    string wad_order;
    foreach flavor in $elements[hot,cold,spooky,stench,sleaze]{
        if(have_item(flavor+" wad")<3 && have_item(flavor+" nuggets") >= 5){
            int ship_out=min(15-(have_item(flavor+" wad")*5),floor(have_item(flavor+" nuggets")/5)*5);
            wad_order+=ship_out+" "+flavor+" nuggets,";}}
    if(wad_order!="") cli_execute("kmail "+wad_order+" to wadbot || wads");}

if(can_interact() && my_name()!="oldguardmeat"){
    good_print("kmailing OGM "+floor((my_meat()-get_property("_startingMeat").to_int())/10)+" meat");
    kmail("oldguardmeat","",floor((my_meat()-get_property("_startingMeat").to_int())/10));}
print("Whew! I'm exhausted!","green");}
 

fronobulax

Developer
Staff member
Mine are pretty simple. For one character I pull items from the Display Case on login and return them on logout. This is because I use them in game but want them in the DC when JickenWings does their daily update. For one character I set and clear the property autoSatisfyWithStash because it is a global setting but screws up scripts for the character who cannot access the clan's stash. For all characters, I run a script that looks for their name on the leaderboards.
 

Bale

Minion
This is my login script and it runs basically until I log out. Have fun figuring it out.
Ick. And it is made even harder by the fact that I've never seen mutex.ash. What does your login script do anyway?

PHP:
int[item] campground = get_campground();
  if (campground[$item[Frobozz Real-Estate Company Instant House (TM)]] == 1) camp_mp = 40;
  else if (campground[$item[Newbiesport™ Tent]] == 1) camp_mp = 10;
  else if (campground[$item[Barskin Tent]] == 1) camp_mp = 20;
  else if (campground[$item[Cottage]] == 1) camp_mp = 30;
  else if (campground[$item[BRICKO pyramid]] == 1) camp_mp = 35;
  else if (campground[$item[Sandcastle]] == 1) camp_mp = 50;
  else if (campground[$item[House of Twigs and Spit]] == 1) camp_mp = 60;
  else if (campground[$item[Gingerbread House]] == 1) camp_mp = 70;
  else if (campground[$item[Hobo Fortress]] == 1) camp_mp = 85;
  camp_mp_gain = camp_mp;
  if (campground[$item[pagoda plans]] == 1) camp_mp_gain += camp_mp;
  if (stat_bonus_tomorrow() == $stat[mysticality]) camp_mp_gain += camp_mp;
  if (campground[$item[Beanbag chair]] == 1) camp_mp_gain += 30;

I think that what you really want is this single line:

PHP:
camp_mp_gain = numeric_modifier("Base Resting MP") * (numeric_modifier("Resting MP Percent")+100) / 100 + numeric_modifier("Bonus Resting MP");

Edit: I don't think that your old code will work anymore anyway. Dwellings were recently taken out of get_campground() and put into get_dwelling() so you need to fix that code.
 
Last edited:

mredge73

Member
Do you guys have any idea on how to turn on and off options in the breakfast panel via script?
I need some help on a workaround for a clan/cage bot, I would like to be able to run breakfast only if it is possible to run breakfast. Being stuck in the cage is very sensitive to Mafia.
If I try to do something that cannot be done due to cage restrictions like breakfast, Mafia will get upset and usually abort my script.
I need to write a breakfast script that can conditionally run Mafia's breakfast subroutines. It looks like there are some properties in the Global_prefs but I didn't think an ash script could modify these.
If this cannot be done, I will probably do a combination of all of the above scripts.
 

slyz

Developer
My login script:
  • doesn't do anything in-run
  • clanhops to my main clan in case I spend the night in a clan with +advs furniture - thanks Bale
  • removes the sword behind inappropriate prepositions
  • uses stills based on advice by PriceAdvisor (although these days it's obviously always ooze-o, maybe I could remove that part for the time being) - thanks Aqualectrix
  • makes prismatic wads - thanks Bale
  • closets reagents
  • use free mining - thanks That FN Ninja

My logout script:
  • checks the wand and zaps something if it has not been used today
  • uses Inigo casts to craft gatorskin umbrellas
  • makes prismatic wads
  • checks if the Nun's MP has been used, and summons BRICKOs with it if not.
  • puts on RO gear
  • malls a few items

On top of this, I use Bale's clanhop to switch to a clan with +adv furniture when loging out.
 

Attachments

  • MakePie.ash
    994 bytes · Views: 87
  • logout.ash
    7.6 KB · Views: 101
  • login.ash
    3.4 KB · Views: 140
Last edited:

morgad

Member
login (once a week):
update store budget
update BCC snapshot

login (once-a-day):
check for xmas pressie (and get it)
buy raffle tickets
get bounty

every login:
equip 'maximum item' outfit
print how many lucre I have

logout:
for every item in display case, add in all spares from inventionry
for each item in Mall Store, add all spares
equip 'maximum adventure' outfit
 

Attachments

  • logout.ash
    2.1 KB · Views: 57
  • login.ash
    3.2 KB · Views: 76
Ick. And it is made even harder by the fact that I've never seen mutex.ash. What does your login script do anyway?
mutex.ash is a very rudimentary mutex library. I have two scripts running simultaneously so I make sure they don't interfere with each other.
This is the login script for a chat-based buffbot.
I think that what you really want is this single line:
PHP:
camp_mp_gain = numeric_modifier("Base Resting MP") * (numeric_modifier("Resting MP Percent")+100) / 100 + numeric_modifier("Bonus Resting MP");
Edit: I don't think that your old code will work anymore anyway. Dwellings were recently taken out of get_campground() and put into get_dwelling() so you need to fix that code.
Thank you! To be honest, I didn't write this chunk of the breakfast code, I worked on this script with a fellow clannie (though I'm not sure he wrote it himself either), and I never got around to re-writing it. Good to know that the dwellings won't work anymore, he'll have to update that (he recently took over all the botting duties, so it's his problem now)
Thank you!
 

Sentrion

Member
Thank you! To be honest, I didn't write this chunk of the breakfast code, I worked on this script with a fellow clannie (though I'm not sure he wrote it himself either), and I never got around to re-writing it. Good to know that the dwellings won't work anymore, he'll have to update that (he recently took over all the botting duties, so it's his problem now)
That was all me - why do you think it's so inefficient? =D

My script (which makes use of Bale's lovely bafh.ash):

PHP:
string start_outfit = "Stat gains";

boolean in_ronin()
{
	if (!in_hardcore() && !can_interact())
		return true;
	else
		return false;
}

void rumpus()
{
	string rumpus = visit_url("clan_rumpus.php");
	print ("");
	print ("Visiting clan rumpus room.", "blue");
	if (contains_text(rumpus,"rump3_3"))
	{
		print ("");
		print ("Accessing Mr. Klaw Skill Crane Game.", "green");
		visit_url("clan_rumpus.php?action=click&spot=3&furni=3");
		visit_url("clan_rumpus.php?action=click&spot=3&furni=3");
		visit_url("clan_rumpus.php?action=click&spot=3&furni=3");
	}
	if (contains_text(rumpus,"rump3_1"))
	{
		print ("");
		print ("Using Soda Machine.", "green");
		visit_url("clan_rumpus.php?action=click&spot=3&furni=1");
		visit_url("clan_rumpus.php?action=click&spot=3&furni=1");
		visit_url("clan_rumpus.php?action=click&spot=3&furni=1");
	}
	if (contains_text(rumpus,"rump1_4") || contains_text(rumpus,"rump4_2") || contains_text(rumpus,"rump9_3"))
	{
		print ("");
		print ("Picking meat from plants.", "green");
		if (contains_text(rumpus,"rump1_4"))
			visit_url("clan_rumpus.php?action=click&spot=1&furni=4");
		if (contains_text(rumpus,"rump4_2"))
			visit_url("clan_rumpus.php?action=click&spot=4&furni=2");
		if (contains_text(rumpus,"rump9_3"))
			visit_url("clan_rumpus.php?action=click&spot=9&furni=3");
	}
	if (contains_text(rumpus,"rump9_2"))
	{
		print ("");
		print ("Getting chips.", "green");
		for i from 1 to 3
			visit_url("clan_rumpus.php?preaction=buychips&whichbag="+i);
	}
	return;
}

void vip()
{
	print ("");
	print ("Visiting VIP lounge.", "blue");
	print ("");
	print ("Accessing Deluxe Mr. Klaw Skill Crane Game.", "green");
	for i from 1 to 3
		visit_url("clan_viplounge.php?action=klaw");
	print ("");
	print ("Accessing A Looking Glass.", "green");
	visit_url("clan_viplounge.php?action=lookingglass");
	set_property("crimboTreeDays",to_int(get_property("crimboTreeDays"))-1);
	void getTree()
	{
		print ("");
		print ("Grabbing Crimbo Tree gift.", "green");
		cli_execute("clanhop bafh");
		visit_url("clan_viplounge.php?action=crimbotree");
		cli_execute("clanhop mesa");
	}
	if (get_property("crimboTreeDays") < 1)
	{
		if (user_confirm("Use Crimbo tree?"))
			getTree();
	}
	print("");
	return;
}

void other()
{
	print ("");
	print ("Finishing other breakfast functions.", "blue");
	if (get_property("sidequestOrchardCompleted") != "none")
	{
		print ("");
		print ("Visiting the Hippy Store.", "green");
		visit_url("store.php?whichstore=h");
	}
	foreach item in $items[Manual of Transmission,Manual of Dexterity,Manual of Labor]
	{
	if (item_amount(item) == 1)
	{
		print("");
		use(1,item);
	}
	}
	if (my_class() == $class[accordion thief])
	{
		visit_url ("volcanoisland.php?action=npc");
	if (item_amount($item[Fisherman's sack]) > 0)
		use(1,$item[Fisherman's sack]);
	}
	if (item_amount($item[Cheap toaster]) > 0)
		use(3,$item[Cheap toaster]);
	if (item_amount($item[Burrowgrub hive]) > 0)
		use(1,$item[Burrowgrub hive]);
	if (item_amount($item[Chester's bag of candy]) > 0)
		use(1,$item[Chester's bag of candy]);
	return;
}

void hardcore()
{
	vip();
	other();
	return;
}

void ronin()
{
	vip();
	other();
	return;
}

void aftercore()
{
	rumpus();
	vip();
	other();
//This uses daily skills with MP cost modifiers
	
	cli_execute("maximize -mana cost -tie");
	boolean dailyskills = true;
	if ((my_class() == $class[sauceror]) && (item_amount($item[Gravyskin Belt of the Sauceblob]) > 0))
		if (!use_skill(3, $skill["Advanced Saucecrafting"]))
			dailyskills = false;
	if ((!use_skill(5, $skill["Advanced Saucecrafting"])) || (!use_skill(5, $skill["Pastamastery"])) || (!use_skill(5, $skill["Advanced Cocktailcrafting"])) || (!use_skill(3, $skill["Summon Sugar Sheets"])))
		dailyskills = false;
	foreach i in $items[twinkly wad, hot wad, cold wad, stench wad, spooky wad, sleaze wad]
		buy(3,i);
	if (!use_skill(3,$skill["Rainbow Gravitation"]))
		dailyskills = false;
	if (!dailyskills)
		user_confirm("Unable to cast all daily skills.");
	for i from 1 to 5
		(!hermit(1, $item[Ten-leaf clover]));
	cli_execute("clanhop mesa");

//	outfit(start_outfit);
	return;
}

void main()
{
if (get_property("_breakfast") == "")
{
	if (can_interact())
		aftercore();
	else if (in_hardcore())
		hardcore();
	else if (in_ronin())
		ronin();
	print ("");
	set_property("_breakfast", "no");
	print ("");
	print ("Breakfast finished.", "blue");
	print ("Opening relay browser...", "green");
	cli_execute("relay");
}
else
{
	print("");
	print("Breakfast already done today.", "teal");
	print ("Opening relay browser...", "green");
	print("");
	cli_execute("relay");
}
}
 
Last edited:

Bale

Minion
Sentrion, most of what you list: Chester's bag, getting Fisherman's sack, cheap toasters, The Klaw, etc... That's all part of mafia's basic breakfast ability. Is there a reason to duplicate mafia's ability in the script instead of using breakfast?

Stuff his scripts do
Other stuff that his scripts do

Thanks guys, these were some of what I was hoping for. You suggested a few things that I ought to put into my scripts. :D

I'll have to add that free mining stuff, clanhopping and raffle ticket purchase stuff. Maybe some of the other things as well.
 

morgad

Member
a couple of random comments -

my ideas are a lot less buggy than the code that tries to implement them :)

If Mafia had seperate 'breakfast' (1st login after rollover) and 'login' scripts my code would be simpler

If I could invoke mafia with --no-display --run-script foo.ash it would get rid all the java errors when firing mafia up once a week from a cron job
(suspect I just neeed to re-direct errors to /dev/null instead)

and of course this morning I suffered from major ISP problems as well :-( (no net since 3AM, full service due to resume tommorrow)

Dave
 

zarqon

Well-known member
My login script doesn't do a lot -- mafia basically handles it all. A few things it does, most of which have already been mentioned:

  • Ensures that my battleAction is "custom combat script".
  • Puts on my "current" outfit.
  • Eats/drinks/uses any steel skill items.
  • For can_interact() characters, eats/drinks a standard menu, leaving room for estimated fortune cookie consumption. I have a provision for flagging character names as swimming, which makes the script eat/drink a seafaring menu.
  • Eats a fortune cookie if there is no active cookie counter.
  • Buys raffle tickets.
  • Opens the advent calendar for the day.
  • Gravitates the rainbow -- thanks Bale!
  • If (my_name() == "zarqon"), runs Registry.ash
  • If clear of restrictions, opens all gift packages.
  • Uses any scrolls of pasta summoning.
  • Admits any new clan member applicants.
  • Prints the author/time of the most recent clan forum post.
  • Whitelists, sends a message to, then boots any inactive members, so that they are not wasting clan resources for clan buffs.
  • Uses best_fam("items"), which also helps enforce 100% runs.

My logout script is a bit more involved, particularly given the first item:

  • Builds a list of skills you can cast on yourself (ignoring buffs you already have a LOT of and AT buffs that you don't already have), then makes optimum use of any free restores (PYEC, Nuns, unused Disco rests) to buff you to the maximum, leaving you at my_mp() - rollover MP. Will also maximize MP before using any free restores. Thus, absolutely no MP is wasted.
  • Uses any unused still upgrades for the day (again, thanks Bale).
  • Uses meat containers (warm subject certificates, coin purses, etc.), small boxes, penultimate chests, -5 large boxes, and all briefcases (but it holds one back if you don't yet have pirate fledges).
  • Gets any un-got buffs (friars, ball pit, pool table, cocktail demon, stabonic scroll).
  • Sends certain various items to various collectors.
  • Closets all stuffies so they don't clutter inventory.
  • Closets excess meat.
  • For can_interact(), drinks a nightcap.
  • If the character is the clan treasurer, adds any meat stacks to the DC and updates the Fund information.
  • Runs my display case manager script (which generates my Bat King progress table).

Not sure how much of that is useful to anyone, but I thought I would chip in.
 

fronobulax

Developer
Staff member
  • Prints the author/time of the most recent clan forum post.
  • Whitelists, sends a message to, then boots any inactive members, so that they are not wasting clan resources for clan buffs.
I'd add the first to my own scripts if you felt like posting the code.
I don't understand the mechanic that allows for inactive members to waste resources. Is that because your clan has a bot that automagically buffs everyone in the clan?

Thanks.
 

lostcalpolydude

Developer
Staff member
I don't understand the mechanic that allows for inactive members to waste resources. Is that because your clan has a bot that automagically buffs everyone in the clan?

Thanks.

There are things that can be used to give everyone outside of HC/ronin a buff, and you pay per person getting it. One of those things is an extra adventure for each person for 10k each. The workaround I've seen is a clan that only has a clan leader (in ronin) and a bunch of whitelists, so any buffs purchased only go to 1 person that wants it.
 

zarqon

Well-known member
Here are the relevant bits!

PHP:
string postplayer;

// returns now as a unix timestamp
int setnow() {
   string url = visit_url("charpane.php");
   url = substring(url,index_of(url,"rightnow = ")+11);
   return to_int(substring(url,0,index_of(url,";")));
}

// returns the timestamp of the latest clan post
int last_post() {
   int p,latest;
   string office = visit_url("clan_forums.php");
   string[int] chunks = split_string(office,"echodate\\(");
   if (count(chunks) < 2) return 0;
   for i from 1 to count(chunks)-1 {
      p = to_int(substring(chunks[i],0,index_of(chunks[i],",")));
      if (p > latest) {
         latest = p;
         chunks[i] = substring(chunks[i],index_of(chunks[i],"who="));
         postplayer = substring(chunks[i],index_of(chunks[i],">")+1,index_of(chunks[i],"</a>"));
      }
   }
   return latest;
}

// converts a number of seconds into a fairly decent human-readable string
string chunkit(int time) {
   int days = floor(time / (3600*24)); time = time - (days*3600*24);
   int hrs = floor(time / 3600); time = time - (hrs*3600);
   int mins = floor(time / 60);
   buffer res;
   if (days > 0) res.append(to_string(days) +" days ");
   if (hrs > 0) res.append(to_string(hrs) +" hours ");
   if (mins > 0) res.append(to_string(mins) +" minutes ");
   if (res.length() == 0) return "less than a minute";
   return res.to_string();
}

vprint("The last forum post was "+chunkit(setnow() - last_post())+" ago by "+postplayer+".",2);
 
Top