Summon Stickers and Snowcones

Baree

New member
First, let me share with you my script.
Code:
void tomeSummon(){
 if(in_hardcore())
 return;
 
 int stickCasts = random(4);
 boolean didCast;
 didCast = use_skill(stickCasts, $skill[Summon Stickers]);
 use_skill(3-stickCasts, $skill[Summon Snowcone]);
 
 if(didCast)
 print("Summoned: " + int_to_string(stickCasts) + " Stickers, " + int_to_string(3-stickCasts) + " Snowcones.");
 else
 print("Summon tome items failed.");
}

void main(){
 tomeSummon();
}
Though this is probably obvious the script selects a random integer between 0 and 3, casts summon stickers that many times, then casts summon snowcone 3-that number. After it has summoned (or not) it returns the results. Now, my problem is that the boolean returned by use_skill seems to return true even if no items were summoned. I am guessing this is probably the correct way for the returns from use_skill to function; however, is there a way to detect results so that I can have my script print the real results of the casting?
 

zarqon

Well-known member
Hey, great script, I like it. If I had more than one tome I would use this daily. Thanks for sharing.

Yeah, some of the ASH functions have unpredictable return values -- for example, adventure() returns false if it stops due to satisfied conditions, and use() often seems to return false when it successfully uses the item. I'm still trying to figure out what create() returns, since I've gotten false from both failed and successful creations!

As for detecting results, there are a couple methods, neither of them quick and easy.

The easiest but ugliest method:

1) Store the current inventory amount of all possible summoned items.
2) Perform your summoning.
3) Compare your current inventory against the stored values.

The more difficult, but much more graceful way:

1) Instead of using ASH's use_skill() command, perform the cast using visit_url() and store the result in a string.

Code:
string castpage = visit_url("whateverthecastingurlis.php?pwd&skill=whateverskillitis");

You'll have to figure out what the URL is on your own, or perhaps someone will be kind enough to supply that information. I'm not logged in so I can't figure it out at the moment.

2) Call extract_items() on the string to determine which items, if any, you got.

Code:
int[item] summonedstuff = extract_items(castpage);
print("You summoned "+count(summonedstuff)+" items.");

Hope that helps.
 

Baree

New member
Thanks for the info. I was hoping to avoid having to do a item lookup in this script so I only hit the item table when I'm actually creating the items (though, what do I know, maybe mafia implements these commands such that they use the local item cache information). I may have to mess with the url idea later when I've got a bit more time.
 

zarqon

Well-known member
Mafia does store your inventory locally. Checking your inventory using item_amount() will not hit the KoL server.
 
Top