Help with Felonia Script

So, I've had this cli script that does Felonia for me in aftercore for quite some time, but I've recently been trying to make it more user friendly across a wider audience. But now I seem to be kinda stuck.

the 2nd part of the quest is to retrieve the elemental mushroom that Zapruder asks for, then, if you don't already have that familiar, you use the mushroom and finally equip the (new) familiar.

I think I've figured out how to figure out which one Zapruder is asking for, but then I run into trouble trying to that string into an appropriate $item and $familiar.

Code:
//felonia.ash
//completes mayor zapruder's quest in the muscle sign degrassi knoll

void main() {

get_next_goal	string
new_familiar_base	string
new_item	item	
new_familiar	familiar

if (!in_muscle_sign()) {
	print("you must be under a muscle moon sign to do Felonia");
	exit; }

if (in_muscle_sign()) {
	
	visit_url("knoll.php?place=mayor"); 				# start the quest
	if (item_amount($item[annoying pitchfork])==0) { 
		add_item_condition(1, $item[annoying pitchfork]);
		adventure(*, $location[bugbear pens]"); }
	
	get_next_goal = buffer ("knoll.php?place=mayor");	# determine which mushroom Zapruder wants
	if (contains_text(get_next_goal,"frozen mushroom"))	{
		retrieve_item(1,$item[frozen mushroom]);
		new_familiar_base = "frozen";	}
	if (contains_text(get_next_goal,"flaming mushroom"))	{ 
		retrieve_item(1,$item[flaming mushroom]);
		new_familiar_base = "flaming");	}
	if (contains_text(get_next_goal,"stinky mushroom"))	{
		retrieve_item(1,$item[stinky mushroom]);
		new_familiar_base = "stinky"	}
	
        new_item =$item[("pregnant "+new_familiar_base+" mushroom").to_item()]
	new_familiar=$familiar[(new_familiar_base+" gravy fairy").to_familiar()]
	
	visit_url("knoll.php?place=mayor");			# grow the fairy
	if !(have_familiar(new_familiar) use_item(1,new_item);
	use_familiar(new_familiar);
	
	cli_execute("conditions clear");			# get the required items
	add_item_condition(1, $item[inexplicably glowing rock]);
	add_item_condition(1, $item[spooky glove]);
	set_property("choiceAdventure5",2);
	adventure(*, $location[spooky gravy barrow]);

	equip($slot[acc3],$item[spooky glove]);		# finally kill felonia
	set_property("choiceAdventure5",1);
	cli_execute("conditions add 1 choiceadv");
	adventure(*, $location[spooky gravy barrow]);

	visit_url("knoll.php?place=mayor");	# gain the 6 mushroom fermenting solutions
	}
}

I'm not really in a position where I can test this right now, but obviously, the part i'm concerned about is where I create a new string and then do .to_item() and .to_familiar() on it. Is this going to work at all?

I don't know, maybe it will be easier to see if Zapruder gives you a pregnant mushroom when you return, then just equip any of the elemental fairies you might already have, cuz you don't have to use the same fairy that zapruder gives you. Ideas or suggestions?
 
Last edited:

slyz

Developer
PHP:
get_next_goal = buffer ("knoll.php?place=mayor");
is buffer() a user-defined function you didn't show here?

EDIT: no need for $item and $familiar on these lines, since you are using to_item() and to_familiar():
PHP:
new_item =$item[("pregnant "+new_familiar_base+" mushroom").to_item()]
new_familiar=$familiar[(new_familiar_base+" gravy fairy").to_familiar()]
Simply do:
PHP:
new_item = to_item( "pregnant " + new_familiar_base + " mushroom" );
new_familiar= to_familiar( new_familiar_base + " gravy fairy" );

EDIT2: other problems are:
  • Initialize variables by doing "string get_next_goal;" instead of "get_next_goal string".
  • If the script exits if you are not in a muscle sign, no need to check again.
  • "adventure(*, $location[bugbear pens]);" won't work, you need to do "adventure(my_adventures(), $location[bugbear pens]);".
  • If you want the script to be more user friendly, I would suggests adding more checks to everything that is done. For example, check if retrieve_item() worked before continuing, or look for specific text in the response of visit_url("knoll.php?place=mayor") at each stage, to make sure one part of the quest hasn't been done already.
  • At any time, you can do this in the gCLI: "verify felonia.ash" to check if something is wrong with what you have written so far.
 
Last edited:
is buffer() a user-defined function you didn't show here?

Umm, i thought buffer() was an ash function that captured all the text on the page... oh, I see what I've done...I think...

The rest is VERY helpful, especially the verify bit!
 

slyz

Developer
visit_url() returns the HTML of the page. Simply do:
PHP:
get_next_goal = visit_url("knoll.php?place=mayor");
instead.
 
Yeah, that's what I had thought I had done. ;-)

Here's the current verified version. The only thing verify tells me I'm not sure about is at the end, it says "No functions in your current namespace", but if I add "main();" as the last line, I get "Function main() undefined".

Code:
//felonia.ash
//completes mayor zapruder's quest in the muscle sign degrassi knoll


void main() {
string get_next_goal;
string new_familiar_base;
item new_item;	
familiar new_familiar;

if (!in_muscle_sign()) {
	print("you must be under a muscle moon sign to do Felonia");
	exit; }

visit_url("knoll.php?place=mayor"); 				# start the quest
if (item_amount($item[annoying pitchfork])==0) { 
	add_item_condition(1, $item[annoying pitchfork]);
	adventure(my_adventures(), $location[bugbear pens]); }
	
get_next_goal = visit_url("knoll.php?place=mayor");	# determine which mushroom Zapruder wants
if (contains_text(get_next_goal,"frozen mushroom"))	{
	retrieve_item(1,$item[frozen mushroom]);
	new_familiar_base = "frozen";	}
if (contains_text(get_next_goal,"flaming mushroom"))	{ 
	retrieve_item(1,$item[flaming mushroom]);
	new_familiar_base = "flaming";	}
if (contains_text(get_next_goal,"stinky mushroom"))	{
	retrieve_item(1,$item[stinky mushroom]);
	new_familiar_base = "stinky";	}
new_item =to_item("pregnant "+new_familiar_base+" mushroom");
new_familiar=to_familiar(new_familiar_base+" gravy fairy");
	
visit_url("knoll.php?place=mayor");			# open spooky gravy barrow
if (!have_familiar(new_familiar)) use(1,new_item);
	
use_familiar(new_familiar);
	
cli_execute("conditions clear");			# get the required items
add_item_condition(1, $item[inexplicably glowing rock]);
add_item_condition(1, $item[spooky glove]);
set_property("choiceAdventure5",2);
adventure(my_adventures(), $location[spooky gravy barrow]);

equip($slot[acc3],$item[spooky glove]);		# finally kill felonia
set_property("choiceAdventure5",1);
cli_execute("conditions add 1 choiceadv");
adventure(my_adventures(), $location[spooky gravy barrow]);

visit_url("knoll.php?place=mayor");			# gain the 6 mushroom fermenting solutions
}

Now I have to figure out what error checking to do.. thanks for the help, slyz.

I suppose someone could retrieve the pitchfork, show it to Zapruder, then smash it or autosell it or something...

So.. retrieve() will first check your inventory, then your closet, then Hagnk's (if you're out of ronin), then the mall (also, if you're out of ronin)... I guess some printout about needing mall access or growing your own mushroom in the Fields would be in order there.

I'll work on that some and see how it goes.
 
OK, so the first section, I'm changing to this:
Code:
visit_url("knoll.php?place=mayor"); 				# start the quest
if (item_amount($item[annoying pitchfork])==0) {
	retrieve_item(1, $item[annoying pitchfork]); }
	else {
	add_item_condition(1, $item[annoying pitchfork]);
	adventure(my_adventures(), $location[bugbear pens]); }

That should try to find one in all your crap, and if you don't or can't, does the adventuring part.
Once you turn the pitchfork in, Zapruder asks repeatedly for the elemental mushroom.

So I'll add this after I parse that page the first time, which should capture if retrieve_item() failed and exit.

Code:
if (item_amount(to_item(new_familiar_base+" mushroom"))==0) {
	print("Looks like you need to grow a "+new_familiar_base+" mushroom to continue");
	exit; }

I'm thinking that should work now. Now, to pop a prism somewhere to try it out.
 
Last edited:

slyz

Developer
retrieve_item() also returns true if you already have a pitchfork, so you can skip the item_amount() check:
PHP:
if ( !retrieve_item(1, $item[annoying pitchfork]) ) {
	add_item_condition(1, $item[annoying pitchfork]);
	adventure(my_adventures(), $location[bugbear pens]); }

EDIT:
The only thing verify tells me I'm not sure about is at the end, it says "No functions in your current namespace"
This isn't an error. Mafia is just stating that there aren't any user-defined functions in your script.
 
OK, so this is what happened when I ran it...

I didn't have a flaming mushroom in storage and the preference set to NOT buy from the mall, so retrieve_item() failed. The cli did print "you need 1 more flaming mushroom to continue".

After buying the mushroom from the mall and rerunning the script. I acquired the pregnant flaming mushroom, but then instead of using it, it printed out my "looks like you need to grow"... except, it didn't do the string summing, so it just said "grow a mushroom to continue"...

yeah, crap, I've still got something wrong here. because the script stopped the first time thru, then I bought the flaming mushroom from the mall manually, it's not constructing the strings properly because there is no text matching from the 2nd visit. Hence, when it gets to the use_familiar() part, it's trying to use a basic "baby gravy fairy" instead of an elemental. Needs more error checking. ugh. I really do suck at this.

So, the text after you've summoned the mushroom familiar (received either a pregnant * mushroom or a piece of equipment) is "You must investigate the Spooky Gravy Barrow, Citizen, and stop the spooky gravy fairies from tormenting our bugbears!". At this point, you can equip any of the flaming, frozen, or stinky fairies that you may have. If you don't have any, you need to use the pregnant something mushroom you just received, then you will have one.

/me goes to work on this more.. and it will be at least a few more days before I can test it again. Stay tuned!

Maybe an easier way to handle this is to break each part of the quest into it's own function, and call the appropriate function based on contains_text...
 
Last edited:
OK, here is the current code. Still untested by me (once per run stuff is *hard*). But attached in case any one wants to give it a go.

Code:
//felonia.ash
//completes mayor zapruder's quest in the muscle sign degrassi knoll


item new_item;	
familiar new_familiar;
string zapruder = "knoll.php?place=mayor";
string quest_status;

void pitchfork(){
	if (!retrieve_item(1, $item[annoying pitchfork])) {
		add_item_condition(1, $item[annoying pitchfork]);
		adventure(my_adventures(), $location[bugbear pens]); }
	}

void mushroomfairy(string page){
	if (contains_text(page,"frozen mushroom"))	 set_property("Zapruder_shroom","frozen");
	if (contains_text(page,"flaming mushroom")) set_property("Zapruder_shroom","flaming");
	if (contains_text(page,"stinky mushroom"))	 set_property("Zapruder_shroom","stinky");

	new_item =to_item("pregnant "+get_property("Zapruder_shroom")+" mushroom");
	new_familiar=to_familiar(get_property("Zapruder_shroom")+" gravy fairy");

	if (!retrieve_item(1,to_item(get_property("Zapruder_shroom")+" mushroom"))) {
		print("Looks like you need to grow a "+get_property("Zapruder_shroom")+" mushroom to continue");	
		exit;}

	if (contains_text(visit_url(zapruder),to_string(new_item))) use(1,new_item);
	use_familiar(new_familiar); 
	}

void felonia(){
		
	cli_execute("conditions clear");			# get the required items
	add_item_condition(1, $item[inexplicably glowing rock]);
	add_item_condition(1, $item[spooky glove]);
	set_property("choiceAdventure5",2);
	adventure(my_adventures(), $location[spooky gravy barrow]);

	equip($slot[acc3],$item[spooky glove]);		# finally kill felonia
	set_property("choiceAdventure5",1);
	cli_execute("conditions add 1 choiceadv");
	adventure(my_adventures(), $location[spooky gravy barrow]);

	visit_url(zapruder);			# gain the 6 mushroom fermenting solutions
	}

void main(){
if (!in_muscle_sign()) {
	print("you must be under a muscle moon sign to do Felonia");
	exit; }


quest_status = visit_url(zapruder);
while (!contains_text(quest_status,"The Knoll is truly grateful.")) {
	if (contains_text(quest_status,"we train bugbears")) pitchfork();
	if (contains_text(quest_status,"bugbears' annoyance")) pitchfork();
	if (contains_text(quest_status,"mushroom")) mushroomfairy(quest_status);
	if (contains_text(quest_status,"Spooky Gravy Barrow")) felonia();}
print("Felonia Quest Complete!");
}
 

Attachments

  • felonia.ash
    2.2 KB · Views: 43
Last edited:

Theraze

Active member
Easiest thing to do is not include them inline, and if it is inline, delete the inline portion and only leave it as the attached file... that's when you get the pretty box below the post. :)
 

Theraze

Active member
When I ran it just now, I got this, as I found my pitchfork:
Conditions satisfied after 4 adventures.
You need 1 more (unknown item 0) to continue.
Looks like you need to grow a mushroom to continue
so... looks like the item bit isn't COMPLETELY sorted yet. :)

Edit: Ah... it needs to visit the mayor again to move on to the next step. :) Running the script again found out that it needs a flaming mushroom.
 
Last edited:
Ahhhhh. I think i've fixed it. I initialized quest_status, but never updated it inside the while loop, so it would only run one time thru.
 

Attachments

  • felonia.ash
    2.3 KB · Views: 54
OK, report on last nights live test. It completed the quest all the way thru from the beginning without stopping. Yippee!

However, looking at my log it pulled frozen mushrooms, visited Zapruder, equipped the frozen gravy fairy (which I already had), visited Zapruder again, then pulled flaming mushroom, acquired the flaming glowsticks, equipped the flaming gravy fairy, visited Zapruder two more times, then adventured.

???

Appropriate Log section:
Code:
Visiting Mayor Zapruder

pull: 4 annoying pitchfork

pull: 16 frozen mushroom

Visiting Mayor Zapruder

familiar Frozen Gravy Fairy (16 lbs)

equip familiar little box of fireworks

Visiting Mayor Zapruder

pull: 13 flaming mushroom

Visiting Mayor Zapruder
You acquire an item: flaming glowsticks

familiar Flaming Gravy Fairy (16 lbs)

Unequip Frozen Gravy Fairy

equip familiar little box of fireworks

Visiting Mayor Zapruder

Visiting Mayor Zapruder

[635] Spooky Gravy Barrow
Encounter: Finding Neverevereverland
You gain 5 Fortitude
You gain 5 Mysteriousness
You gain 5 Roguishness
You gain a Moxie point!
 

Theraze

Active member
I think the issue is with how it's running its quest check... I think an if/elseif sequence should work better. So this:
while (!contains_text(quest_status,"The Knoll is truly grateful.")) {
if (contains_text(quest_status,"we train bugbears")) pitchfork();
if (contains_text(quest_status,"bugbears' annoyance")) pitchfork();
if (contains_text(quest_status,"mushroom")) mushroomfairy(quest_status);
if (contains_text(quest_status,"Spooky Gravy Barrow")) felonia();
quest_status = visit_url(zapruder); }
should become this:
while (!contains_text(quest_status,"The Knoll is truly grateful.")) {
if (contains_text(quest_status,"we train bugbears")) pitchfork();
else if (contains_text(quest_status,"bugbears' annoyance")) pitchfork();
else if (contains_text(quest_status,"mushroom")) mushroomfairy(quest_status);
else if (contains_text(quest_status,"Spooky Gravy Barrow")) felonia();
quest_status = visit_url(zapruder); }

It still ran the mushroomfairy section for me before it initialized which it wanted... This should make it work properly.
 
We're almost there!

Contemplating the suggestion on my other project to check the historical price of an item, I've added better buy() functionality for the pitchfork and the quest shroom.

Sample:
Code:
void pitchfork(){
	if (!retrieve_item(1, $item[annoying pitchfork])) {
		if (can_interact() && historical_price($item[annoying pitchfork]) < 200 && my_meat()>200 )
			buy(1,$item[annoying pitchfork]);
		else {
			add_item_condition(1, $item[annoying pitchfork]);
			adventure(my_adventures(), $location[bugbear pens]); 
			}
		}
	}
 

Attachments

  • felonia.ash
    3 KB · Views: 49
Last edited:

Theraze

Active member
One more bug, this one in the mushroom detection. It currently has this:
PHP:
 quest_shroom = to_item(get_property("Zapruder_shroom"+" mushroom"));
however, the property name is Zapruder_shroom, not Zapruder_shroom mushroom, so...
PHP:
 quest_shroom = to_item(get_property("Zapruder_shroom")+" mushroom");
works much better. :D
 
ACK! Why, yes it does.

I'll get to run it again tomorrow sometime after rollover.

eta: I've run this a couple times flawlessly from start to finish. Thanks Theraze for your patience. :)
 

Attachments

  • felonia.ash
    3.1 KB · Views: 85
Last edited:

stannius

Member
Your script works great. Now you just need to put it into a thread in the "turn burning scripts" forum so people can find it. :)

If you want to optimize, add sonata and smooth, which I think help? Assuming the required noncombats are noncombats and not superlikelies.
 
Top