PDA

View Full Version : Consult script hanging -- contain_text() not working on last round?



bazo0ka
09-13-2010, 08:38 AM
Using a consult script, I can't seem to detect the end of combat by using contain_text() function --


void main(int initround, monster foe, string url)
{
while (!contains_text(url, "You win the fight!"))
attack();

return;
}

The script can't find "You win the fight!" (or any other winning/losing messages for that matter) and it gets stuck in the loop at the end of combat. This looks like such a simple problem, but I'm not figuring out what's wrong. Anyone? I'm using r8612, and I'm calling the script from a simple one line CCS (the line being "consult testcombat.ash"). Thanks.

jasonharper
09-13-2010, 10:43 AM
You never assign a new value to 'url' (a horrible name for that parameter, by the way), therefore it cannot ever contain any text that it did not initially contain.

bazo0ka
09-13-2010, 10:53 AM
Ah, thank you. I understand now.

I agree about the parameter name. I just saw it used in the wiki example and others' scripts, so I figured they knew something I didn't.

slyz
09-13-2010, 06:07 PM
void main( int initround, monster foe, string page )
{
while( !contains_text( page, "You win the fight!" ) )
page = attack();

return;
}

This should work. I think.

xKiv
09-14-2010, 01:29 PM
I think you shoulodn't be looking for "You win the fight!" but for the comment that gets emmited in the HTML even in fights that don't display "You win the fight!".
I think it's "<!--WINWINWIN-->", as used in FightRequest.

mredge73
09-16-2010, 01:24 PM
from casual combat:



//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$
boolean combat_finished(string url) {
if(contains_text(url, "lose the fight!") || my_hp()==0)
abort("You Just Got Served");
if(
contains_text(url, "win the fight!")
|| contains_text(url, "run away, like a sissy little coward")
|| contains_text(url, "You stare blankly at the destruction around you, then realize ")
|| contains_text(url, "You stare open-mouthed at the carnage that used to be the hippy camp")
|| contains_text(url, "A winner is you!")
|| round >= 31
)
return true;
return false;
}

heeheehee
09-16-2010, 03:11 PM
I think xKiv's comment applies to haiku combats, which can happen at any time if the haiku katana is equipped.

Theraze
09-16-2010, 05:31 PM
Looks like a combination of containing "<!--WINWINWIN-->" and not containing "fight.php" would be the best, as the WINWINWIN means you won, and no more fight.php means you lost...