Feature - Implemented Ash function to read the current set goals

Winterbay

Active member
I would like to propose (like apparently zarqon has done before, but I can't find it so it may be gone) an ash function that would return what your current goal is set to.
My suggestion would be a "string get_goals()" or similar that returns the same string that is shown in the adventure tab, i.e. a comma-delimited list of things.

This would, for example, make code like this not use up all your adventures if you happen to actually have the black market map already:
Code:
add_item_condition( 1 , $item[black market map] );
adventure(my_adventures(), $location[black forest]);

I am sure that zarqon's has_goal()-funciton would benefit muchly from it as well.
 

Bale

Minion
You make the case for this very poorly.

Code:
if(available_amount( $item[black market map] ) < 1) {
   add_item_condition( 1 , $item[black market map] );
   adventure(my_adventures(), $location[black forest]);
}

How would you benefit from checking your goals to improve that code?

At least suggest something where get_goals() would save you from needing to iterate over the full set of $items[] to check is_goal(). Or perhaps something involving more esoteric goals that is_goal() will not check such as "7 pirate insult" or "8 any paper strip".
 

slyz

Developer
I think he meant that, if "1 black market map" is already a goal when you do
PHP:
add_item_condition( 1 , $item[black market map] )
you end up with an impossible goal of "2 black market map".

In that example, using "goals clear" beforehand works, but I guess there are cases where that would not be a good solution.
 

Winterbay

Active member
Well, that is also a problem, but actually the case I presented was a very simplified version (due to time constraints). The problem showed up in BCC Ascend where the bumAdv()-function is used as a wrapper for adventure(). This function gets called with all kinds of arguments including goals to fulfil. The function sets those goals but have no way of seeing that we have a goal set, so if the goal is allready met, for whatever reason, the script will happily spend all your adventures searching for something that is already fulfilled.
Trying to adventure from the GUI with a already fulfilled goal will stop adventuring but not if you do it via set_goal + adventure.

I have worked out a solution that could work (see below), but it's a bit hackish and a get_goals() or similar funciton would be a lot more elegant. And also as you stated, is_goal() won't work for things that isn't items (which is the reason for the second part of the check in the code below).

Code:
cli_execute("goal clear");
string[int] split_goals = split_string(goals, ",");
boolean have_goal = false;
if (length(goals) > 0) {
	cli_execute("goal set "+goals);
	print("BCC: Setting goals of '"+goals+"'...", "lime");
	foreach i in split_goals {
		if(is_goal(to_item(split_goals[i])) || (length(split_goals[i]) > 0 && to_item(split_goals[i]) == $item[none]))
			have_goal = true;
	}
	if(!have_goal) {
		print("BCC: All goals have already been met, moving on.", "lime");
		return true;
	}
}
 
Top