Hobopolis chatbot script - New Problem (29th July)
Building on Alhifar's cagebot script, I tried to see if it was possible to create a chatbot for hobopolis. This was done mainly because my clan is looking to get into hobopolis runs soon and being in the UK I find it hard to be online when required.
Anyways, I managed to get the script to the point when on command it will go through the sewers and then use sufficient phials of the correct type to kill a pre-determined number of hobos. However, its behaviour with the tent is causing problems. Long story short, expected behaviour is for it to CLEESH to the tent on command ("tent") and then I want it to sit there (call the url but not actually do anything). On command ("play") it should enter the tent in the back and then sit there, and on command ("leave") it should leave the tent and then sit there, ready to go back to the tent on command.
What is actually happening is that first time through it got to the tent and then kept on calling the url until it got the play command, when it played correctly and then kept calling the url until getting the leave command, when it left. On subsequent "tent" commands it would CLEESH to the tent, and then would play and leave immediately. I'm not sure why it is doing this - maybe because looking so long at the code is stopping me from seeing obvious (or not so obvious) errors, but help would be much appreciated!
Verifying it in the gCLI produced no errors.
Building on Alhifar's cagebot script, I tried to see if it was possible to create a chatbot for hobopolis. This was done mainly because my clan is looking to get into hobopolis runs soon and being in the UK I find it hard to be online when required.
Anyways, I managed to get the script to the point when on command it will go through the sewers and then use sufficient phials of the correct type to kill a pre-determined number of hobos. However, its behaviour with the tent is causing problems. Long story short, expected behaviour is for it to CLEESH to the tent on command ("tent") and then I want it to sit there (call the url but not actually do anything). On command ("play") it should enter the tent in the back and then sit there, and on command ("leave") it should leave the tent and then sit there, ready to go back to the tent on command.
What is actually happening is that first time through it got to the tent and then kept on calling the url until it got the play command, when it played correctly and then kept calling the url until getting the leave command, when it left. On subsequent "tent" commands it would CLEESH to the tent, and then would play and leave immediately. I'm not sure why it is doing this - maybe because looking so long at the code is stopping me from seeing obvious (or not so obvious) errors, but help would be much appreciated!
Verifying it in the gCLI produced no errors.
Code:
string run_choice( string page_text )
{
matcher m_choice = create_matcher( "whichchoice value=(\\d+)" , page_text );
while( contains_text( page_text , "choice.php" ) )
{
m_choice.reset( page_text );
m_choice.find();
string choice_adv_num = m_choice.group( 1 );
string choice_adv_prop = "choiceAdventure" + choice_adv_num;
string choice_num = get_property( choice_adv_prop );
if( choice_num == "" ) abort( "Unsupported Choice Adventure!" );
string url = "choice.php?pwd&whichchoice=" + choice_adv_num + "&option=" + choice_num;
page_text = visit_url( url );
}
if( contains_text( page_text , "Combat" )) run_combat();
return page_text;
}
void main( string sender , string message )
{
buffer reply;
if( contains_text( visit_url( "clan_detailedroster.php" ) , sender ) )
{
buffer quote;
if( contains_text( message.to_lower_case() , "sewer" ) )
{
#Stuff I know works in the sewer and in hobopolis.
}
if( contains_text( message.to_lower_case() , "tent" ) )
{
cli_execute ( "ccs sewer" );
outfit( "tent" );
string page_text = visit_url( "adventure.php?snarfblat=167" );
int at_the_tent = 0;
while( !contains_text( page_text , "Attention -- A Tent!" ) && at_the_tent < 1 )
{
if( contains_text( page_text , "Combat" ) )
{
run_combat();
}
else if( contains_text( page_text , "Marketplace Entrance" ) )
{
page_text = run_choice( page_text );
}
#Things to heal me if needed and boost non-combats
if (at_the_tent < 1) {page_text = visit_url( "adventure.php?snarfblat=167" );}
}
if( contains_text( page_text , "Attention -- A Tent!" ) )
{
chat_reply( "at the tent");
at_the_tent = 1;
}
}
}
if( contains_text( message.to_lower_case() , "play" ) )
{
set_property( "choiceAdventure225" , "1" );
string page_text = visit_url( "adventure.php?snarfblat=167" );
if( contains_text( page_text , "Attention -- A Tent!" ) )
{
page_text = run_choice( page_text );
chat_reply( "playing" );
}
else
{
chat_reply( "not able to play" );
}
}
if( contains_text( message.to_lower_case() , "leave" ) )
{
set_property( "choiceAdventure226" , "2" );
string page_text = visit_url( "adventure.php?snarfblat=167" );
if( contains_text( page_text , "Here You Are, Up On Stage" ) )
{
page_text = run_choice( page_text );
chat_reply( "left" );
}
else
{
chat_reply( "can't leave!" );
}
}
}
Last edited: