libramBurn: Summon libram items to burn MP between battles, for profit!

fxer

Member
libramBurn: Summon libram items to burn MP between battles

[size=+1]libramBurn 3.01[/size]

In aftercore I seem to generate way more MP than I could possibly use on buffs, so why not summon valuable libram crap instead? I've been using a modified version of Bale's libram summoning script for some time but just got a hair up my ass decided to rewrite the whole shebang. Mainly I added support for Love Songs and BRICKOs and new code for "rotating" your summons between multiple librams and tallying your summons of each. I also import libramBurn into my rollover.ash script to burn MP from my nuns visits/free rests/Oscus' soda etc.

Between each battle if you don't have enough MP to summon you get the line:
Libram summon #26 when MP > 806.
Or if something is summoned it gives your tally for the day:
Libram Summons: [Casts: 65] [Profit: 575,626 meat] --- [Dice: 65]

Installation is pretty simple, download it to your /scripts directory and type in the gCLI:
set betweenBattleScript=libramBurn.ash
call libramBurn.ash (this initializes the variables, so you can adjust them before actually adventuring)
(requires zarqon's zlib)

Settings can be changed via the gCLI:
zlib libramburn_summonhearts = true/false
zlib libramburn_summonfavors = true/false
zlib libramburn_summonsongs = true/false
zlib libramburn_summonbrickos = true/false
zlib libramburn_summondice = true/false
zlib libramburn_summonresolutions = true/false
zlib libramburn_summontaffy = true/false
zlib libramburn_summoninhc = true/false (defaults to false, will not summon in HC/Ronin so you can micromanage your MP)
zlib libramburn_minmp = integer (amount of MP to save IN ADDITION to your autoRecoverMP setting in Mafia)

Using as an import: function libramBurn() will burn your mp, libramBurn_summary() will print out a status line

[size=-3]
Changelog:
2010.04.06 v0.92: Initial release.
2010.04.06 v0.93: Suggestions from Rinn including minor code cleanup, changing minmp to be in addition to mpAutoRecover setting in Mafia and remove abort() functions and change to warnings if you don't have any librams available/selected
2010.07.23 v0.94: Added option to enable/disable the script while in hc/ronin (suggested by Ancientofearth)
2010.08.17 v0.95: Fixed some logic errors with mp cost reducers (thanks to Fluxxdog and heeheehee)
2011.09.11 v0.96: added Gygaxian Libram
2011.11.04 v0.96.1: added libram_profit() function which return approx value of your summons (currently dice/divines only)
2011.11.08 v0.97: changed libram_profit() to calculate actual total profit from each libram item you have summoned today, vaya con dios estimates!
2011.11.08 v0.98: added Libram of Resolutions
2013.01.30 v2.00: Rewrote most of the script. Now utilizes looping over custom libram Records, removing a lot of duplicate code. Should speed up script, make it much easier to maintain, and contain less embarassing code...
2013.02.02 v2.01: Changed verbosity settings for 'Next Summon When' to 3, the zlib default for displaying messages. Most people never change this so were never seeing the 'Next Summon' message
2013.04.01 v2.02: Added Libram of Pulled Taffy
2014.10.13 v2.03: Summon Candy Hearts -> Summon Candy Heart
2016.06.07 v3.00: Rewrote script so new librams should be automatically handled as Mafia supports them
2020.03.21 v3.01: Remove un-needed int_to_string() mafia no longer supports anyway

[/size]
 

Attachments

  • libramBurn.ash
    10.5 KB · Views: 63
Last edited:

fxer

Member
I finally have a reason to try this script out, so far so good :) Thanks for writing it.

My pleasure Spiny. Also hopefully if anyone has troubles with the script they will message me in game, rather than delete my baby.

Just updated the script with a new small option. Previously I used "can_interact()" to disable the script if you were in HC/Ronin, now it is controlled by a boolean so you can choose whether you want the script on or off during HC/Ronin.
 

Spiny

Member
Looks like I'm going to HAVE to grab the update because between every fight I get the big red block telling me of the New Version. How come this doesn't show up only at the first instance that the script is called per session like UR?

Edit: I grabbed the latest version. When it runs, will it override the current settings set in my vars file with default settings or am I ok to continue my regular automation without manual intervention to re-adjust those settings?
 
Last edited:

fxer

Member
Edit: I grabbed the latest version. When it runs, will it override the current settings set in my vars file with default settings or am I ok to continue my regular automation without manual intervention to re-adjust those settings?

Your settings will stay the same, they are only initialized once the first time the script is ever run, a feature of zlib. Also the big red warning firing over and over I'm not sure about, the version info/updates are also handled by zlib so it would probably require a change on zarqon's end. Maybe I should ask him about it...
 

Spiny

Member
Ah ok, that makes sense. Bale's script probably has a customized version to ensure it only appears the first time the script is hit. Thanks :)
 

Bale

Minion
Bale's script probably has a customized version to ensure it only appears the first time the script is hit. Thanks :)

I like to do things my own way. :) If someone doesn't want to update, hitting him with the message twice after each battle seems cruel.
 

mredge73

Member
If you through in stickers, dry noodles, advanced cocktail items, and Reagents you would really have something that would work great in HC ascensions as well as Aftercore.
At low level you will probably not have the MP or meat for MP to summon these at breakfast but you can get them all very easily once you have a Max MP of 10+ and a pool table!

Now if a between battle script can burn this MP automatically...
Code:
if (have_skill($skill[Advanced Cocktailcrafting]))
    while (my_mp() >= mp_cost($skill[Advanced Cocktailcrafting]) && get_property("cocktailSummons").to_int()<3)
        use_skill ($skill[Advanced Cocktailcrafting]);

if (have_skill($skill[SuperHuman Cocktailcrafting]))
    while (my_mp() >= mp_cost($skill[Advanced Cocktailcrafting]) && get_property("cocktailSummons").to_int()<5)
        use_skill ($skill[Advanced Cocktailcrafting]);    

if (have_skill($skill[Pastamastery]))
    while (my_mp() >= mp_cost($skill[Pastamastery]) && get_property("noodleSummons").to_int()<3)
        use_skill ($skill[Pastamastery]);

if (have_skill($skill[Transcendental Noodlecraft]))
    while (my_mp() >= mp_cost($skill[Pastamastery]) && get_property("noodleSummons").to_int()<5)
        use_skill ($skill[Pastamastery]);    

if (have_skill($skill[Advanced Saucecrafting]))
    while (my_mp() >= mp_cost($skill[Advanced Saucecrafting]) && get_property("reagentSummons").to_int()<3)
        use_skill ($skill[Advanced Saucecrafting]);    
        
if (have_skill($skill[The Way of Sauce]))
    while (my_mp() >= mp_cost($skill[Advanced Saucecrafting]) && get_property("reagentSummons").to_int()<5)
        use_skill ($skill[Advanced Saucecrafting]);
 

Fluxxdog

Active member
Function fix

Got an odd uccerance that I thought was initially a problem with Bal's UR script, but came to realize (read as have pointed out) that it's not.
Code:
cast 7 Summon Party Favor
You acquire an item: divine champagne flute
You acquire an item: divine blowout
You acquire an item: divine noisemaker
You acquire an item: divine can of silly string
You acquire an item: divine can of silly string
You acquire an item: divine blowout
You acquire an item: divine noisemaker
 > Restoring MP! Currently at 162 of 162 HP, 21 of 297 MP, current meat: 37721 ... Target MP = 27.

use 1 carbonated water lily
You gain 63 Mana Points

cast 1 Summon Party Favor
You acquire an item: divine noisemaker
 > Summons today: Hearts(0) Favors(8) Songs(0) BRICKOs(0)
It's casting 8 times when I only have enough MP for 7 casts, causing mafia to force MP recovery when I have it disabled. I do have my MP threshhold set to 0 MP. Other than that, it works freaking beautifully.

And MrEdge, if you want a script for conjuring between battles, take a look at this one attached. Note some of the functions are custom designed, but you should get the idea what they do.

Edit: I did find a couple snags which might explain why I'll see this at the start of the day. In the function max_libram_summon():
PHP:
int max_libram_summon() {
	int y;
	int mptotal = next_summon_mp() - numeric_modifier("Mana Cost"); // cost of the next libram summon, adjusting for MP reduction items/days
This should read:
Code:
int mptotal = max(1,next_summon_mp() - numeric_modifier("Mana Cost"));
...or it can return a negative value. An MP cost modifier of -3 on your first summon for the day will equal -2, an impossible cost. The max() function will prevent that.
PHP:
	if(my_mp() - mptotal > 0) {
		int x = get_property("libramSummons").to_int(); //(square_root(8 * mptotal -7)+1) /2; // which number summon you are on today
		y = x; // which number summon can you get up to with your current mp
		while (my_mp() - (mptotal+vars["libramburn_minmp"].to_int()) > 0) {
			y = y +1;
			mptotal = mptotal + y * (y - 1) /2 +1;
Here as well a max() function is needed as well as accounting for MP cost modifiers.
Code:
mptotal = mptotal + max(1, (y * (y - 1) /2 +1) - numeric_modifier("Mana Cost")) ;
This will account for modifiers as well as not saying it costs less than 1 MP.

I've made changes to the function in my own personal copy. Other than that, the script works beautifully.
PHP:
int max_libram_summon() {
	int y;
	int mptotal = max(1,next_summon_mp() - numeric_modifier("Mana Cost")); // cost of the next libram summon, adjusting for MP reduction items/days
	if(my_mp() - (mptotal+vars["libramburn_minmp"].to_int()) > 0) {
		int x = get_property("libramSummons").to_int(); //(square_root(8 * mptotal -7)+1) /2; // which number summon you are on today
		y = x; // which number summon can you get up to with your current mp
		while (my_mp() - (mptotal+vars["libramburn_minmp"].to_int()) > 0) {
			y = y +1;
			mptotal = mptotal + max(1, (y * (y - 1) /2 +1) - numeric_modifier("Mana Cost")) ; 
		}
		y = y - (x + 1);
	}
	return y;
}
Hope this helps!

Edit 2: Just found a logic flaw that was causing the over casting.
PHP:
		while (my_mp() - (mptotal+vars["libramburn_minmp"].to_int()) > 0) {
			y = y +1;
			mptotal = mptotal + max(1, (y * (y - 1) /2 +1) - numeric_modifier("Mana Cost")) ;
		}
		y = y - x;
mptotal will keep calculating until it is too much. Then, the number of casts (which is 1 higher than it should be) is returned. A simple change to the end:
Code:
y = y - (x+1);
...will return the right number of casts.

Also, noted this:
PHP:
	if(my_mp() - mptotal > 0) {
...should actually read as this:
Code:
	if(my_mp() - (mptotal+vars["libramburn_minmp"].to_int()) > 0) {
I've changed the function above to reflect these changes.
 

Attachments

  • conjuregoodies.ash
    2.6 KB · Views: 90
Last edited:

fxer

Member
Thanks for all that work Fluxxdog, by adjusting my mp cost reducing gear and libramburn_minmp settings I was able to replicate everything you noticed. I ended up rewriting the logic a bit more as I still noticed errors related to "numeric_modifier("Mana Cost")" not being inside an abs(). Also by changing the summon counting code to "y = y - (x+1);" there was still a problem when mptotal + minmp exactly equaled my_mp(). I worked the checking for that into the while loop itself.

I'm hoping all the special cases are taken care of now, I tested all the different mp reducing and summon limit combos I could think of and none failed. I didn't increment the script version yet because zlib throws repeated update available messages which are annoying as hell :p The updated script is uploaded though, so let me know if you (or anyone) gets it to fail now!
 

heeheehee

Developer
Staff member
I'd suggest not having numeric_modifier("Mana Cost") inside an abs() -- in the case of stuff like Radiating Black Body (I think that's the one?), some things give +MP Cost (edge case: net MP cost modifier is positive, in which case it'll be seen as beneficial instead of detrimental). Instead, just multiply by -1.

Also, I'd suggest using mana_cost_modifier() instead -- it accounts for both numeric_modifier("Stackable Mana Cost") and numeric_modifier("Mana Cost").
 

fxer

Member
Both good calls heeheehee, thanks and updated the script accordingly. Don't remember mana_cost_modifier() existing last year when I wrote the script for myself, that is handy.
 

Theraze

Active member
Time to update the version header on the thread? :)

Edit: Thread, and inside the script itself... both still claim 0.94, which isn't going to alert people who aren't reading this thread.
 

fxer

Member
Holding off on the version increment for a day to see if fluxxdog or anyone else still has problems after these changes, only want to make zlib go insane with update notices once :)
 

Fluxxdog

Active member
Both good calls heeheehee, thanks and updated the script accordingly. Don't remember mana_cost_modifier() existing last year when I wrote the script for myself, that is handy.
I was wondering why you weren't using it, and that explains it. I like it. Only thing I'd do different would be to use if(my_mp() > mptotal... but that's purely personal. Combined with the save_mana() function I have, it'll be vicious.

The way I usually use this script is I import it into a massive conjuring script and have it check if max_libram_summon() > 0 and then call summon_libram() if true. Brutal in HC where those divine blowouts help take down most of the bosses, and then automatically summon BRICKOs once the king is free.

Now if I could just get my hands on a tome other than Sugar I'd really be set ^^
 

oly0015

Member
I've been using something similar for awhile but thanks for doing the math to get the jump in mp cost, been just casting one at a time but this is more efficient.
 

Fluxxdog

Active member
Found a new snag. If your current MP is equal to the current cost, it will not summon and tell you it will when your MP is > the next cost -1.

In line 160:
PHP:
else if(next_summon_mp()+minmp < my_mp()){
This should read:
Code:
else if(next_summon_mp()+minmp <= my_mp()){
 

JohnAnon

New member
I like this script an all, but is there any way to get rid of this horrible wait time? It even does it twice, and I hate it.
 

slyz

Developer
Wait time? I don't think the script uses wait()... Is there anything printed in your gCLI during the 'wait time'?
 
Top