Matt! More great thoughts.
1) I love the equipcheck() idea. Added that in, along with outfitcheck(). These will only swap gear if prep is true.
2) For boss zones, often the link to the boss area changes depending on whether the boss is defeated, so detecting whether the area is open and the boss remains undefeated should usually be doable in a single server hit.
3) Bat zones definitely need special handling for the use of sonars. I think the script ought to attempt to use enough sonars to reveal the desired zone, regardless of prep. If done right, the detection for that could be done in a single server hit. The question now becomes how to script that efficiently. For now, I added this after all three sonar-only bat zones, which I think is fairly nice:
Code:
if (!levelcheck(4)) return false;
string bathole = visit_url("bathole.php");
int sonarsneeded = to_int(!contains_text(bathole,"batratroom.gif")) +
to_int(!contains_text(bathole,"batbeanroom.gif")) + to_int(!contains_text(bathole,"batbossroom.gif"));
if (sonarsneeded > 0) {
use_upto(sonarsneeded,$item[sonar-in-a-biscuit],true);
bathole = visit_url("bathole.php");
}
return (contains_text(bathole,substring(to_url(where),0,index_of(to_url(where),"&"))));
Note that this will detect whether the Boss Bat has been defeated.
Also note that this uses a function from ZLib. Since this script also needed to use resist(), I simply made it require ZLib. Scripts that want to use both ZLib and CanAdv can now just import CanAdv.
4) That's a good thought, but the existing operators already work that way.
Consider this:
Code:
if (false && true) do something;
ASH, like many languages, handles these comparisons smartly. As soon as it sees the first false, it doesn't even evaluate the second condition, since the final result will be false no matter what the second condition evaluates to.
Likewise,
Code:
if (true || false) do something;
does not evaluate the second condition.
So,
Code:
return (levelcheck(7) && visit_url("cyrpt.php").contains_text("cyrpt6d.gif"));
will first perform the level check. If that returns false, then it will return false and not bother with the visit_url().
I asked about this long ago and was happy to discover that ASH behaves this way. I take advantage of it all the time in my scripts.
Now, if only use() had a useful return value...