BRICKOS summoning (hopefully I haven't butchered the ash language!)

Alex9009

New member
So, my starting goal was to create a script that summons BRICKOs until the mp cost of doing so exceeds my max mp.

Before tonight I had absolutely no experience with ash, so please bear with me.

I ran into a hangup: I want to use my KoLmafia mood for MP restoration, but I don't know how to do this in an .ash script.

Here's what I have so far:
Code:
I want to cast summon brickos until mp is insufficient for another cast,
then restore until my_mp() is > mp_cost(summon brickos) using Neverending soda, Nuns, MMJ, in that order.
Continue this until mp_cost(summon brickos) is > max_mp().

boolean cli_execute( outfit Max MP )

while ( int my_maxmp() >= int mp_cost(Summon BRICKOs) )
{ 
	if ( int my_mp() >= int mp_cost(Summon BRICKOs) 
	{ 
		use_skill(Summon BRICKOs) 
	}

	if (int my_mp() < mp_cost(Summon BRICKOs) )
	{ 
		## Here is where I want to restore MP according to my mood. 
                   How do I go about doing that in ash?

Hopefully I'm as close to a functional script as I think I am. Tips would be greeeaaaaatttlllllyy appreciated. If you responded with a fully functional script that did exactly what I want it to do, I'd even throw some meat at you. Because I'd be that appreciative. Ya.
 

Bale

Minion
Well, you did butcher the ash language. Here's a few tips:

PHP:
while ( my_maxmp() >= mp_cost($skill[Summon BRICKOs]) )

Notice how I didn't add "int" before the functions? It is being called, not defined. Also, note how I define the skill constant Summon BRICKOs. If you don't do that, mafia doesn't know if Summon BRICKOs is a skill, effect, string or whatnot.

Also, you forgot to end commands with semi-colons. Don't add semi-colons after if or while.

Finally, you need to put quotes around strings:
PHP:
cli_execute("outfit Max MP");
Note that I also put a semi-colon at the end of the line.
 
Last edited:

Bale

Minion
Here's a fully functional version.

PHP:
cli_execute("maximize MP"); 
// This will automatically search all your equipment and figure out which gear will best maximize MP.

while ( my_maxmp() >= mp_cost($skill[Summon BRICKOs]) )
{ 
	if ( my_mp() >= mp_cost($skill[Summon BRICKOs]) )
		use_skill(1, $skill[Summon BRICKOs]);
		
	if ( my_mp() < mp_cost($skill[Summon BRICKOs]) )
		restore_mp(0);

	if ( my_mp() < mp_cost($skill[Summon BRICKOs]) )
		exit; // If your mp restoration failed, it is good to have this escape
}
 
Last edited:

Alex9009

New member
Haha alright so I suck... But I do appreciate the functional script!

One weird thing happened though. Even though my max mp is 720, the script stopped summoning when the mp cost was 172.

It must have failed to recover mp and used that exit you coded.

But, it recovered using Oscus's neverending soda once and used the MMJ's I had on-hand already. It did not visit the nuns (even though that is checked in my mood) and it did not buy more MMJ's, even though I allow mafia to buy things when needed (via preferences).

Any idears?? I really appreciate your help

EDIT: Actually, it DID purchase those MMJ's. So it is capable of buying restorers... something else must be going on
 

Bale

Minion
I kinda expected that problem actually. The problem is that you wanted it to follow your mp restoration settings. That means it won't restore mp unless it is below the level you stated in your settings. You'd be better changing that line to restore_mp(ceil(my_maxmp() * to_float(get_property("mpAutoRecoveryTarget"))). That way it will always restore to the maximum you set, even if it is above the minimum.

PHP:
cli_execute("maximize MP"); 
// This will automatically search all your equipment and figure out which gear will best maximize MP.

while ( my_maxmp() >= mp_cost($skill[Summon BRICKOs]) )
{ 
	if ( my_mp() >= mp_cost($skill[Summon BRICKOs]) )
		use_skill(1, $skill[Summon BRICKOs]);
		
	if ( my_mp() < mp_cost($skill[Summon BRICKOs]) )
		restore_mp( ceil(my_maxmp() * to_float(get_property("mpAutoRecoveryTarget"))) );

	if ( my_mp() < mp_cost($skill[Summon BRICKOs]) )
		exit; // If your mp restoration failed, it is good to have this escape
}
 

Alex9009

New member
Excellent! It's workin' like a charm. For some reason it stopped when the skill cost 667mp and my max was 720... but that's like 2 more casts, very easy to live with.

It still won't use the freekin nuns... but i can just get massaged for those last couple casts manually.

This is exactly what I was after, thank you very much!
 

Bale

Minion
Probably it stopped because your Hp/Mp settings were set to restore up to 90% MP. If you changed that to 100%, then it would restore higher. Or would you prefer to have it always be 100%? You said about it obeying your settings for restoration so I didn't want to do differently. If you want to do that then...

PHP:
cli_execute("maximize MP"); 
// This will automatically search all your equipment and figure out which gear will best maximize MP.

while ( my_maxmp() >= mp_cost($skill[Summon BRICKOs]) )
{ 
	if ( my_mp() < mp_cost($skill[Summon BRICKOs]) )
		restore_mp( my_maxmp() );  // This will always restore your MP to maximum. Even if settings say otherwise.

	if ( my_mp() < mp_cost($skill[Summon BRICKOs]) )
		exit; // If your mp restoration failed, it is good to have this escape

	use_skill(1, $skill[Summon BRICKOs]);
}
I restructured the function a little to make it a bit tidier.
 
Last edited:

Bale

Minion
It still won't use the freekin nuns... but i can just get massaged for those last couple casts manually.
That's a mafia issue. I wrote a recovery script partially because of that very problem. Mafia will only use the nuns if you need 1000 Mp and have a max MP high enough to absorb them. To enable me to recover using the nuns the way I wanted, jason added the ability to make recovery a user definable feature. My recovery script did evolve into a lot more than that though: Universal Recovery. It will solve your recovery woes.

SIf you responded with a fully functional script that did exactly what I want it to do, I'd even throw some meat at you. Because I'd be that appreciative. Ya.
That would be nice.
 

Alex9009

New member
Incredible. What if I set it to something like this:

Code:
 restore_mp( mp_cost($skill[Summon BRICKOs]) )

Just to ensure no mp is wasted (cases like when i only need 3 mp to achieve max; using a restorer would waste mp)

I installed your recovery script and am eager to try this all again tomorrow.

I never expected my script (your script now? :p ) to be functional this quickly. Thanks again! Meat incoming!
 
Last edited:

Bale

Minion
The problem with that is when the casting cost is still low, it would restore far less than your max mp just to do a single cast. That would make restoration tedious. If you're good with that, then feel free.
 

Grotfang

Developer
A slight word of warning: I submitted a bug report a couple of days ago reporting incorrect tracking of libram MP. If mafia is doing the same thing for you, then you might find your script stops while you could still summon things.
 
Maybe you could manually command the nuns yourself?

Code:
cli_execute("maximize MP"); 
// This will automatically search all your equipment and figure out which gear will best maximize MP.

bool noMoreRestore = false;
while ( my_maxmp() >= mp_cost($skill[Summon BRICKOs]) )
{ 
    if ( my_mp() < mp_cost($skill[Summon BRICKOs]) )
        restore_mp( my_maxmp() );  // This will always restore your MP to maximum. Even if settings say otherwise.

    if ( my_mp() < mp_cost($skill[Summon BRICKOs]) )
        noMoreRestore=true;

    if (noMoreRestore == true)
    {
       ## Manually command nunnery.
        ## INSERT NUNNERY CODE HERE.
       noMoreRestore = false;
     }

    use_skill(1, $skill[Summon BRICKOs]);
}


I am at work, so don't know the exact commands, but you'd need to first check if you have any nun visits left, then command it to visit the nuns, using cli_execute if necessary.

It is not nearly as nice as Bale's solutions, but I suspect it would work without having to include scripts that have a lot more functionality than you might want to deal with.
 

lostcalpolydude

Developer
Staff member
It looks like use_skill(1, $skill[Summon BRICKOs]); will have mafia doing a whole bunch of single casts of brickos, when most times it could cast all that you have the MP for at once. I don't know if there's any way to say "as many casts as possible" with ash, but cli_execute("cast * bricko"); would speed the script up.
 

adeyke

Member
I just bought a BRICKO libram, so a script like this seems useful. However, I tweaked it a bit.

Outside the loop, I added this (stolen from SmartStasis, best when used with Universal Recovery):
Code:
if (get_property("_meatpermp") != "") {
    meatpermp = to_float(get_property("_meatpermp"));
} else {
    meatpermp = 8;                                          // seltzer base calc
    if (my_primestat() == $stat[mysticality] || (my_class() == $class[accordion thief] && my_level() > 8))
        meatpermp = 100.0 / (1.5 * to_float(my_level()) + 5); // mmj calc if available
}

And in the start of the loop, I added this:
Code:
    if ( meatpermp * mp_cost($skill[Summon BRICKOs]) > 3 * mall_price($item[BRICKO brick]) )
        exit;

The idea is that, if you're paying more for the MP than you'll get from the three bricks, it's not worth casting. (I'm ignoring the possibility of the less valuable eyes, since you'll probably have hit your daily limit by the time the skill gets expensive).

I also added this at the very start of the script:
Code:
buy(1, $item[glittery mascara]);
use(1, $item[glittery mascara]);

It's such a cheap way of further increasing your max MP, beyond equipment.
 

Bale

Minion
That's wonderful! As long as my recovery script is calculating meatpermp for you, it would be a shame not to use that number to figure out when to stop restoring. I love the idea!
 

RogerMexico

New member
My farmer's gear includes a pith helmet and Bag O' Tricks, so even using DB skills, I regenerate free mana as I farm. I was looking for a way to automate using the excess MP to summon Brickos. I'm not really a programmer, but with the tips here and the bits I picked up from trying to read slime.ash, I came up with:

PHP:
void main( int adv_to_use )
{

while ( adv_to_use > 0 )
{
	while ( my_mp() > mp_cost($skill[Summon BRICKOs])+12 )
	{ use_skill(1, $skill[Summon BRICKOs]);
	}
	adventure(1, $location[Giant's Castle]);
	adv_to_use = adv_to_use - 1;
}
}
I'm not sure if this is the best way to loop through a number of adventures specified at the CLI. And yeah, I know, I really should be checking adv_to_use against my_adventures(), and a whole bunch of other error checking probably. But this is simple and works.
The +12 is so I am always left with enough to cast Disco Nirvana.
 

slyz

Developer
In your case, you should use the cli version off use_skill, to take advantage of the * (and not have mafia cast 5 times 1 summon, instead casting once 5 summons):

Code:
void main( int adv_to_use )
{

     while ( adv_to_use > 0 )
     {
         if ( my_mp() > mp_cost($skill[Summon BRICKOs])+12 )
               cli_execute("cast * summon bricko)");
         
         adventure(1, $location[Giants Castle]);
         adv_to_use = adv_to_use - 1;
     }
}
 

heeheehee

Developer
Staff member
The only problem with the CLI-executable method is that it could possibly leave him with less than 12 MP (e.g. first summon of the day). Give me a few minutes to figure out a formula (and save server hits in the future).

Edit: Here we go:
Code:
void main( int adv_to_use ) {

	while ( adv_to_use > 0 ) {
		int c = to_int(get_property("libramSummons"));
		int i = 0;
		while(my_mp()-12>(i*(i+1)*(i+2)/6)-(i*(i-1)/2)-(c*(c+1)*(c+2)/6)-(c*(c-1)/2)) {
			i=i+1;
		}
		use_skill(i, $skill[Summon BRICKOs]); 
		adventure(1, $location[Giants Castle]);
		adv_to_use = adv_to_use - 1;
	}
}

That should work, hitting the server only once. I hope.
(Only took so long because I was wondering why it wasn't actually casting anything... realized I don't even have a libram. Silly me!)

Edit edit: Silly me forgot to subtract 12 from my_mp(). =D
 
Last edited:
Top