Bale
Minion
Hi. I've never posted here before, but as I understand the rules I need to provide some of the code I'm working with to support my question. I'm working on a recoveryScript. This is designed for hardcore or ronin -- an environment with limited resources and no access outside of inventory. It is also designed not to waste anything, so it will try to make most efficient use of limited resources. It will also try not to waste either hp or mp healing off items that give both, like Phonics downs or Ancient Magi-Wipes.
I'm pretty new to scripting for kolMafia. This is only my second script and I don't have any other examples of this type to borrow from, so please be gentle if I did something stupid. Anyway, here are my questions:
1. Is there some way to identify if the black market is open? All I could think of was to (contains_text(visit_url("woods.php"),"store.php?whichstore=l"), but it seems wasteful to have to hit the server every time I need the answer.
2. Can I check if the Doc Galaktik quest was completed without hitting the server? Is there a command for using Doc Galaktik's mp restorative or should I use a visit_url?
3. Is there some way to query mafia for the effectiveness of various restoratives since the method I'm using in my example seems terribly inefficient if there's a way built in.
Here's a snippet of the code I'm working on. There's more, but this is enough to give you the idea. It's still in an early phase. Note the ridiculously cumbersome map that I'm using to store restorative data. I hate that, but I can't think of a better method.
Reference: http://kolmafia.us/index.php/topic,1982.0.html
I'm pretty new to scripting for kolMafia. This is only my second script and I don't have any other examples of this type to borrow from, so please be gentle if I did something stupid. Anyway, here are my questions:
1. Is there some way to identify if the black market is open? All I could think of was to (contains_text(visit_url("woods.php"),"store.php?whichstore=l"), but it seems wasteful to have to hit the server every time I need the answer.
2. Can I check if the Doc Galaktik quest was completed without hitting the server? Is there a command for using Doc Galaktik's mp restorative or should I use a visit_url?
3. Is there some way to query mafia for the effectiveness of various restoratives since the method I'm using in my example seems terribly inefficient if there's a way built in.
Here's a snippet of the code I'm working on. There's more, but this is enough to give you the idea. It's still in an early phase. Note the ridiculously cumbersome map that I'm using to store restorative data. I hate that, but I can't think of a better method.
Code:
record restorative_info {
int minmp;
int maxmp;
int minhp;
int maxhp;
};
restorative_info [item] heal;
heal[ $item[plump juicy grub] ].minmp = 0;
heal[ $item[plump juicy grub] ].maxmp = 0;
heal[ $item[plump juicy grub] ].minhp = 999999999;
heal[ $item[plump juicy grub] ].maxhp = 999999999;
heal[ $item[Delicious shimmering moth] ].minmp = 30;
heal[ $item[Delicious shimmering moth] ].maxmp = 40;
heal[ $item[Delicious shimmering moth] ].minhp = 0;
heal[ $item[Delicious shimmering moth] ].maxhp = 0;
heal[ $item[Tonic water] ].minmp = 30;
heal[ $item[Tonic water] ].maxmp = 50;
heal[ $item[Tonic water] ].minhp = 0;
heal[ $item[Tonic water] ].maxhp = 0;
heal[ $item[magical mystery juice] ].minmp = floor(my_level() * 1.5 + 4);
heal[ $item[magical mystery juice] ].maxmp = floor(my_level() * 1.5 + 6);
heal[ $item[magical mystery juice] ].minhp = 0;
heal[ $item[magical mystery juice] ].maxhp = 0;
heal[ $item[Knob Goblin seltzer] ].minmp = 8;
heal[ $item[Knob Goblin seltzer] ].maxmp = 12;
heal[ $item[Knob Goblin seltzer] ].minhp = 0;
heal[ $item[Knob Goblin seltzer] ].maxhp = 0;
heal[ $item[black cherry soda] ].minmp = 8;
heal[ $item[black cherry soda] ].maxmp = 11;
heal[ $item[black cherry soda] ].minhp = 0;
heal[ $item[black cherry soda] ].maxhp = 0;
// This will tell me how many of a given restorative I need to restore a minimum quantity of mp without over-restoring hp.
int mp_quant(int minimum, item restorative){
int mp_needed = minimum - my_mp();
if mp_needed < 1
return 0;
float roughquantity = mp_needed / heal[restorative].maxmp;
int quantity = floor(roughquantity);
if (ceil(roughquantity) * heal[restorative].maxmp > my_maxmp())
if (heal[restorative].maxmp == 999999999)
return 1;
else
quantity = ceil (roughquantity)
while ( quantity * (heal[restorative].maxhp + heal[restorative].minhp) / 2 + my_hp() > my_maxhp() )
quantity = quantity - 1;
if quantity > item_amount(restorative)
quantity = item_amount(restorative);
return quantity;
}
// This will tell me how many of a given restorative I need to restore a minimum quantity of hp without over-restoring mp.
int hp_quant(int minimum, item restorative){
int hp_needed = minimum - my_hp();
if hp_needed < 1
return 0;
float roughquantity = hp_needed / heal[restorative].maxhp;
int quantity = floor(roughquantity);
if (ceil(roughquantity) * heal[restorative].maxhp > my_maxhp())
if (heal[restorative].maxhp == 999999999)
return 1;
else
quantity = ceil (roughquantity)
while ( quantity * (heal[restorative].maxmp + heal[restorative].minmp) / 2 + my_mp() > my_maxmp() )
quantity = quantity - 1;
if quantity > item_amount(restorative)
quantity = item_amount(restorative);
return quantity;
}
// This will chose the best restorative to purchase if I don't have enough in my inventory. I'll probably decide to use Doc Galaktics if it returns soda water.
item best_mp_purchase () {
if ( my_primestat() === $stat[ mysticality ] || ( my_class() === $class[ accordion thief ] && my_level() >= 9 ))
return $item[magical mystery juice];
if (have_outfit("knob goblin elite guard uniform") && item_amount("Cobb's Knob lab key") > 0)
return $item[knob seltzer];
if (my_level() >= 11)
return $item[black cherry soda];
return $item[soda water];
}
Reference: http://kolmafia.us/index.php/topic,1982.0.html