View Full Version : Rainbow Gravitation made easy
In hardcore it can be a pain in the bottom to use Rainbow Gravitation (unless you actually have 1 of every wad) because kolMafia does not support wad transmutation.
There I was with several extra Sleaze Wads, but no Spooky Wads. In order to create a Prismatic Wad, I'd need to transmute the extra Sleaze Wad -> Hot Wad -> Cold Wad -> Spooky Wad. That's three cooking operations that have to be done through the relay browser. Not to mention the trouble of figuring out which wads needed to be transformed.
Sure, I could have just spent 2 minutes and cooked up my wads, but if I spent 2-3 hours I could have it done automatically for me and never have to worry about the problem ever again. I figure that after using this script about 90 times I'll have made up the lost time. Then (being me), I ended up spending even more time to make it a little nicer. Okay, that seems like a bad use of time, but I did it anyway and I'll pass this script on to others so that they can help me with my time deficit.
This script will figure out exactly how many wads need to be transformed, it will tell you how many Twinkly Wads will be used up in the transformation and ask if you are willing to spend that many twinklies. If you agree, it will start cooking up new wads for you and cast Rainbow Gravitation.
If you don't need to transmute wads, then it will just cast Rainbow Gravitation, but it did save you the trouble of checking for yourself.
v1.1 Now if you have mall access and your preference is to automatically purchase from the mall, it will purchase any wads that you lack.
v1.2 Now it will tell you which elemental wads you lack.
v1.3 Fixed a bug with mall usage.
v1.4 In mallcore it will now cast Rainbow Gravitation as many times as possible.
v1.5 Takes advantage of the new craft() command for greater integration with mafia's cooking decisions.
v1.6 Improved return value checking necessitates a fix.
Muhandes
05-05-2009, 05:43 PM
Nice script, thanks.
May I suggest a tiny little enhancement. When asking if you are willing to spend the twinklies, also report what type you are missing. This would also make it somewhat useful for aftercore, since I don't know of a good way to find what I am missing from the CLI.
In aftercore, how about I just have it automatically purchase the required wads if you have the preference of purchasing automatically from the mall?
Would that be good?
That's what my rainbow gravitation.ash script does.
void cast_rainbow_gravitation()
{
print("Attempting to cast Rainbow Gravitation", "blue");
if (have_skill($skill[Rainbow Gravitation]))
{
if (can_interact())
{
if ( !in_hardcore() )
{
boolean restock( int nCount, item iItem)
{
int nAmount = available_amount( iItem );
if ( nAmount < nCount )
{
buy( ( nCount - nAmount ), iItem );
return true;
}
return false;
}
int nCurrentMeat = my_meat();
restock( 3, $item[twinkly wad] );
restock( 3, $item[cold wad] );
restock( 3, $item[stench wad] );
restock( 3, $item[hot wad] );
restock( 3, $item[sleaze wad] );
restock( 3, $item[spooky wad] );
print("Spent " + to_string(nCurrentMeat - my_meat()) + " meat restocking wads", "blue");
}
use_skill(3, $skill[Rainbow Gravitation]);
}
}
}
Yeah, that's what Rinn's rainbow gravitation does! Mine is mostly about automated wad transmutation, a somewhat different problem.
Though, just for the heck of it I've added automatic wad purchasing if you have mall access and told mafia to purchase from the mall. It'll still only make wads one at a time though.
nelix
06-14-2009, 05:41 PM
I have been using batass jackets to get my wads. I love this script (and any script helps me do things I normally forget to do).
Raven434
07-14-2009, 07:33 PM
I like the script.
Can I ask you to consider adding a "You don't have 'x' to successfully transmute" error message?
I was missing a spooky wad today and when I ran the script the error message I got was:
Without understanding the Way of the Sauce you cannot transmute wads.
When I figure out I only had 5 of the 6 wads needed, I made the spooky and it ran successfully.
Thanks!
Seem simple enough to add that so I took care of it for you. I can't test this properly at the moment though, so please let me know how it works. :D
Raven434
07-14-2009, 08:31 PM
> call scripts\Rainbow Gravitation.ash
You lack a sleaze wad.
You lack a spooky wad.
Without understanding the Way of the Sauce you cannot transmute wads.
You ROCK Bale. Works like a champ!
Thanks so much.
/hoists_a_beer
zarqon
08-14-2009, 08:43 AM
Love this script! Very handy.
I'm greatly saddened by the reports of people smashing all these perfectly collectable bat-ass leather jackets. :(
Bug: I haven't yet permed Way of Sauce, so I run this script primarily as a check after pulverizing during a run, and in aftercore. So I often end up buying wads in aftercore. The problem is, if the script needs to buy missing wads, it will buy them, then just sit there not doing anything, indefinitely:
Searching for "spooky wad"...
Purchasing spooky wad (1 @ 480)...
You acquire an item: spooky wad
Purchases complete.
Searching for "stench wad"...
Purchasing stench wad (1 @ 470)...
You acquire an item: stench wad
Purchases complete.
And that's it. It doesn't cause a CPU spike like an endless loop would, but nor does it finish running the script, so I'm a little confused as to what's going on. Aborting the script and then running it again will cast Gravitation as expected. Haven't had time to figure out the problem yet but wanted to report it since I knew you are so attentive.
Well, my hardcore character has Way and in softcore my breakfast script purchases 3 of each elemental wad and casts RG 3 times. As a result I've never noticed that bug.
I'm not 100% positive (the logic is surprisingly complicated for such a tiny script and it would take me a bit to completely understand it again), but I've got a strong hunch I know what the problem must be. I've updated the file in the first post.
Unfortunately I am not able to test this today. (My softcore character has already used up Rainbow Gravitation for the day.) So please test it for me and let me know if I've fixed the problem.
Rollover happened, so I was able to test the script on my multi.
Good news. The little fix I made to Rainbow Gravitation works perfectly!
Should I change it to use the skill all three times if you're in mallcore?
zarqon
08-15-2009, 05:47 AM
Excellent.
And yes, at present I would have to call it 6 times (once to buy wads and once to cast Gravitation, per cast). After grabbing your fix, down to 3. Would prefer 1.
On that note, would also like it to tell me how many of each needed wad I have before doing its thing.
Huh? Don't get what you mean. If it needs a wad it has ZERO, right? Or you mean you'd prefer that it not purchase the usually very cheap wads before you agree to have it gravitate the rainbow?
tOaDeR
08-31-2009, 05:42 PM
is there a way to turn off the mall purchases? i'd like to just transmute, since i've been farming the Battlefield.
Why would you want to do that?
An elemental wad usually costs less than the cost of another elemental wad AND a twinkly wad. Or at least, not very much more. Since you have mall access, shouldn't you use it to make your situation better?
Edit: If you really want to do that, I guess you could just change line 13
boolean mall = can_interact() && get_property("autoSatisfyWithMall").to_boolean();
change to:
boolean mall = false;
tOaDeR
09-02-2009, 01:32 AM
like i said, i'm farming the Battlefield. i'll have plenty of twinkly wads, at the very least. i have Pulverize and i'm a Sauceror right now, so i have Way(which i'll be perming after this run). it seems to me that would be the cheaper way to do it. i could be wrong, though. i often am about these things.
thanks for the code. i love your scripts.
Spiny
09-02-2009, 03:27 AM
like i said, i'm farming the Battlefield. i'll have plenty of twinkly wads, at the very least. i have Pulverize and i'm a Sauceror right now, so i have Way(which i'll be perming after this run). it seems to me that would be the cheaper way to do it. i could be wrong, though. i often am about these things.
thanks for the code. i love your scripts.
I don't have Rainbow's Gravitation skill so I haven't looked at this code all that much, but I've peeked.
It looks like, as is, if you have mall access, you buy what you need for wads that you don't have and then cast the skill.
If you don't have mall access, you then proceed into transmuting wads from wads you already have.
My thought on the process is as follows:
Twinkly wads are aplenty, but generally cost about 250 meat per in the mall.
Elemental wads vary in cost dramatically from about 400 to 980 per wad.
Transmutation costs 1 cooking turn. Let's say this cost is 500 meat for example purposes. If you have a chef-in-the-box, the turncost is converted to wear and tear/part replacement)
Transmutation chart:
hot+twinkly=cold
cold+twinkly=spooky
spooky+twinkly=stench
stench+twinkly=sleaze
sleaze+twinkly=hot
Let's say you have 3 cold, 3 spooky, 3 stench, 4 sleaze and 2 hot wads.
Cost to make that hot wad=
1 twinkly + 1 turn = 250+500=750 meat for 1 hot wad
The sleaze wad is not a cost as it is converted into the hot wad.
Now what if you had no extra sleaze wads and being a non-muscle class you can't malus things up. You do have an extra spooky wad though. So take a look at this:
You have 3 cold, 4 spooky, 3 stench, 3 sleaze, and 2 hot wads.
Cost to make the missing hot wad=
1 twinkly + 1 turn = stench +1 twinkly +1 turn=sleaze +1 twinkly +1 turn = hot =3 twinkly + 3 turns = 3(250)+3(500)=750+1500=2250 meat!
In short, transmuting for wads can add up costwise, but whether this matters to you or not is another matter ;)
-Spiny
Cheese Loaf
09-23-2009, 07:21 PM
Any way to set it to run 3 times? It's a whole 12 seconds taken off my life each day.
Seriously, I do love the script, but wouldn't mind a little pop up that asks how many wads to make. Perhaps that's more work to code than its worth, though.
It does pop-up a box to ask if you want to make wads, so I'm not sure exactly what you wanted in feedback.
As for running 3 times, that seems rather excessive for a script which is really optimized for hardcore. I figure for hardcore usage you'd want to run it three times separately, but if you want you could replace main() with this:
void main() {
if(can_gravity())
for i from 1 upto (3 - get_property("prismaticSummons").to_int())
gravitate();
}
That will make it run as many times as you have summons.
zarqon
09-24-2009, 05:47 AM
My ideal Gravitation script would try to Gravitate the maximum number of times (note: not always 3) in both HC and aftercore. Print current wad totals, which wads are needed, and how many would be transmuted/purchased, get user feedback if necessary, then do it all. (HC would be limited by current MP, aftercore would assume unlimited MP.) The quick fix above for a wadless aftercorer would quite inefficiently purchase 1 of each wad three separate times.
Of course, this is one of those things which is arguably not worth the effort, since the current script works fine. This is one of very few scripts I run unedited.
Now that I'm spending some time in aftercore for Crimbo, I modified the script to cast Gravitation the maximum number of times if you have mall access (and mafia is allowed to make free use of it). It's not a big deal, but it was annoying me to have to use the script three times instead of once.
New version uploaded.
Muhandes
12-18-2009, 08:46 AM
Blessed be you
Muhandes
01-04-2010, 06:38 AM
The version on the first page is still 1.3
Weird. I thought I changed it. It definitely is updated now.
Enjoy your new ability to create three Rainbow Wads with a single use of the script, if you're in aftercore.
Muhandes
01-04-2010, 01:38 PM
Thank you, it is updated now. And it works just as advertised.
One tiny note about the script name. I'm not sure a space inside a file name is such a good idea. For one, you can't use "call" from the CLI. The simple solution for me was to save it as Rainbow_Gravitation.
I see. I never do call from CLI so that problem is alien to me. Whenever I try to do that I get into trouble.
I've got a question about calling scripts from the CLI if you can answer it. If you've got a script that takes more than one parameter, how do you do that? Let's say that a script takes a string and a location, how can I pass that information in a CLI call?
Muhandes
01-05-2010, 03:55 PM
I use the CLI quite a bit, I guess I am the type that likes to type commands, rather than use menus.
As I don't use any script that accepts two parameters, I don't have any idea how that would work.
zarqon
01-05-2010, 04:02 PM
You can call scripts that have spaces. In fact, I usually call this script by simply typing "Rainbow Gravitation" in the CLI.
I don't think there is a way to pass multiple parameters from the CLI, which is why people have written things in to their main()s that parse multiple data points from a single string parameter. A way around it might involve requiring quotes around strings so that a separator character could be used between parameters, but I don't think the functionality gain would necessarily be worth the bloat/effort.
Updated this script to use the new craft() command for wad transmutation. (Update to recent build (http://builds.kolmafia.us/) is necessary to update the script.)
The advantage is that it will now detect if you want to use a chef in a box, and automatically repair your chef if it gets broken. Previously, you'd get screwed if your chef broke in the midst of wad transmutation.
ereinion
04-24-2010, 07:51 PM
Is there any way to make the script check if you've already used your daily casts of rainbow gravitation, and abort if you have? I tried looking around the forums and the mafia-wiki, but I can't seem to find anything dealing with this.
heeheehee
04-24-2010, 08:36 PM
The preference "prismaticSummons" should be what you're looking for. Combine that with get_property(), and use it as the condition of an if statement.
ereinion
04-24-2010, 08:55 PM
I see. Thanks for your help :-D
Is there any way to make the script check if you've already used your daily casts of rainbow gravitation, and abort if you have? I tried looking around the forums and the mafia-wiki, but I can't seem to find anything dealing with this.
The script already does that. Was this a bug report, or a strangely worded request for information?
ereinion
04-25-2010, 05:52 PM
It was a stangely worded request for information. If I'd read your script a bit more carefully, I wouldn't even have had to ask for it :)
billybobfred
11-01-2010, 08:45 PM
Is there a way to make this script and only this script automatically buy from the mall? I'll check and uncheck the preference every time if I have to, but if there's an easier way, I'd much prefer that.
Theraze
11-01-2010, 09:17 PM
Well, you could have the script save your autoSatisfyWithMall setting to an boolean, set it to true (if currently false), run its purchasing ways, and set it back (if different) when done. Only problem is that if the script fails with an error, your mall setting will remain true. If you aren't worried about cancelling it partially done, should be fine though.
Winterbay
11-01-2010, 10:47 PM
Is there a way to make this script and only this script automatically buy from the mall? I'll check and uncheck the preference every time if I have to, but if there's an easier way, I'd much prefer that.
Or you could use this alias:
alias rainbows => ash boolean mall = to_boolean(get_property("autoSatisfyWithMall")); if(!mall) { set_property("autoSatisfyWithMall","true"); } int [int] my_wads; my_wads[1] = item_amount($item[hot wad]); my_wads[2] = item_amount($item[cold wad]); my_wads[3] = item_amount($item[spooky wad]); my_wads[4] = item_amount($item[stench wad]); my_wads[5] = item_amount($item[sleaze wad]); foreach wad in my_wads { if(my_wads[wad] < 3) { cli_execute("buy " + (3 - my_wads[wad]) + " " + to_string(to_item(1450+wad))); } } cli_execute("cast 3 rainbow"); if(!mall) { set_property("autoSatisfyWithMall","false"); }
It changes the property autoSatisfyWithMall to true if it is false and then buys the missing amount of wads and casts rainbow gravitation 3 times followed by resetting the property if it was false to start with.
ETA: This does not take into account a) if you have the skill or b) if you are in ronin or hardcore so you need to keep track of those things yourself :)
Theraze
11-01-2010, 10:57 PM
Though that doesn't use the script at all... :)
Then how about:
alias rainbows => ashq import "Rainbow Gravitation.ash"; if(can_gravity()) {boolean usemall = to_boolean(get_property("autoSatisfyWithMall")); if(!usemall) set_property("autoSatisfyWithMall","true"); gravitate(); if(!usemall) set_property("autoSatisfyWithMall","false");}
Theraze
11-02-2010, 04:21 AM
Aww... and look, it even checks if it's possible. :p
Winterbay
11-02-2010, 07:05 AM
Though that doesn't use the script at all... :)
True :)
But since I don't either...
Raven434
11-02-2010, 05:47 PM
My permanently in hardcore multi sends much sake and sushi.
;)
redwulf25_ci
04-02-2012, 04:47 AM
Using r10873 I'm getting an odd message when I run this script.
WARNING: Missing return values in boolean functions will soon become an error (rainbow.ash, line 21)
Currently the script still runs correctly. Now, as far as I can tell line 21 is
}
So I'm not sure what return values it wants me to add. I do not recall making any changes to the base script but I'm including the entire script in case I've forgotten changing an argument or two that is causing the problems now. If it makes a difference I'm running the script by typing the script name into my CLI.
// Script: Rainbow Gravitation v 1.5
// Author: Bale
// This will create a prismatic wad by transmuting elemental wads, if it can be done in Hardcore.
script "Rainbow Gravitation.ash";
notify <Bale>;
item [item] to_make;
to_make [$item[cold wad]] = $item[hot wad];
to_make [$item[spooky wad]] = $item[cold wad];
to_make [$item[stench wad]] = $item[spooky wad];
to_make [$item[sleaze wad]] = $item[stench wad];
to_make [$item[hot wad]] = $item[sleaze wad];
boolean mall = can_interact() && get_property("autoSatisfyWithMall").to_boolean();
// Mafia doesn't have recipes for cooking wads so I need to use visit_url()
boolean cook_wad(item it) {
print("Cooking a twinkly wad with a "+ it+ ".");
//visit_url("craft.php?mode=cook&action=craft&a=1450&b="+ to_string(it.to_int())+ "&qty=1&master=Bake%21&pwd");
craft("cook", 1, $item[twinkly wad], it);
}
// Transform all wads necessary to cast the skill.
void transform_wads() {
item [item] transmute;
foreach key in to_make
transmute[to_make[key]] = key;
item choice;
foreach key in to_make
if(item_amount(key) < 1) {
choice = to_make[key];
while(item_amount(choice) < 2) {
choice = to_make[choice];
}
while(item_amount(key) < 1) {
// create(1, transmute[choice]);
cook_wad(choice);
choice = transmute[choice];
}
}
}
// Figure out the cost of transmutation, then cast Rainbow Gravitation
boolean gravitate() {
int [item] wads;
wads[$item[twinkly wad]] = item_amount($item[twinkly wad]);
wads[$item[hot wad]] = item_amount($item[hot wad]);
wads[$item[cold wad]] = item_amount($item[cold wad]);
wads[$item[spooky wad]] = item_amount($item[spooky wad]);
wads[$item[stench wad]] = item_amount($item[stench wad]);
wads[$item[sleaze wad]] = item_amount($item[sleaze wad]);
boolean doit = true;
// Do I have one of every wad? If so, then ask for confirmation if transformation is needed and cast.
boolean rainbow(){
foreach key in to_make
if(wads[key] < 1)
return false;
int twinkle_used = item_amount($item[twinkly wad]) - wads[$item[twinkly wad]];
if(twinkle_used > 0)
doit = user_confirm("Transmuting elemental wads would use up "+ twinkle_used+ " twinkly wads.\nGravitate the Rainbow?");
if(doit) {
transform_wads();
use_skill(1, $skill[Rainbow Gravitation]);
}
return true;
}
if(mall) {
int summonsLeft = 3 - get_property("prismaticSummons").to_int();
foreach key in wads
retrieve_item(summonsLeft, key);
use_skill(summonsLeft, $skill[rainbow gravitation]);
return true;
}
item change;
int steps;
foreach key in to_make
if(wads[key] < 1) {
change = to_make[key];
steps = 1;
while(wads[change] < 2) {
change = to_make[change];
steps = steps + 1;
}
wads[key] = wads[key] + 1;
wads[change] = wads[change] - 1;
wads[$item[twinkly wad]] = wads[$item[twinkly wad]] - steps;
if(wads[$item[twinkly wad]] < 1) {
print("There are insufficent twinkly wads to transmute that many elemental wads", "red");
return false;
}
if(rainbow())
return doit;
}
if(rainbow())
return doit;
return false;
}
// Can't transmute wads without Way of the Sauce
boolean need_way() {
boolean need = false;
foreach key in to_make
if(item_amount(key) < 1) {
print("You lack a "+ to_string(key)+ ".", "#FF7028");
need = true;
}
if(need && !have_skill($skill[The Way of Sauce]))
return true;
return false;
}
// First, do I have the pre-requisites to cast Rainbow Gravitation?
boolean can_gravity() {
int el_wad;
int el_wads(){
foreach key in to_make
el_wad = el_wad + item_amount(key);
return el_wad;
}
switch {
case !have_skill($skill[Rainbow Gravitation]):
print("You don't have the skill to gravitate a rainbow.", "red");
return false;
case get_property("prismaticSummons").to_int() > 2:
print("You've already made 3 Rainbow Wads today!", "red");
return false;
case mall:
return true;
case el_wads() < 5:
print("There are insufficient elemental wads. Make "+ to_string(5 - el_wad) + " more, then try again.", "red");
return false;
case item_amount($item[twinkly wad]) < 1:
print("You cannot use Rainbow Gravitation without a twinky wad.", "red");
return false;
case need_way():
print("Without understanding the Way of the Sauce you cannot transmute wads.", "red");
return false;
default:
return true;
}
}
void main() {
if(can_gravity())
gravitate();
}
Theraze
04-02-2012, 05:03 AM
The cook_wad function doesn't return either true or false, but it's officially a boolean return. Best thing is to just turn the craft line into:
return to_boolean(craft("cook", 1, $item[twinkly wad], it));
This is because of a fairly recent change to KoLmafia. I haven't been using this script lately since I can't use it in Boris so I hadn't noticed. It's easy to fix. I've done so and uploaded it to the first post. The problem was that a boolean function now needs to always return a boolean value.
Thanks for telling me about the problem. I appreciate it.
Powered by vBulletin® Version 4.1.12 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.