Consult script hanging -- contain_text() not working on last round?

bazo0ka

New member
Using a consult script, I can't seem to detect the end of combat by using contain_text() function --

Code:
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

Developer
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

New member
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

Developer
PHP:
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

Active member
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

Member
from casual combat:

Code:
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
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

Developer
Staff member
I think xKiv's comment applies to haiku combats, which can happen at any time if the haiku katana is equipped.
 

Theraze

Active member
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...
 
Top