Time Spinner time pranks

mapledyne

Member
Has anyone come up with a good way to automate time pranks?

Representative code of what I'm doing now:
Code:
boolean time_prank(string player, string msg)
{
  if (!can_spin_time())
    false;
  string url = "choice.php?pwd&whichchoice=1198&option=1&pl="+url_encode(player)+"&th="+url_encode(msg);
  
  visit_url("inv_use.php?pwd=&which=3&whichitem=9104");
  visit_url("choice.php?pwd&whichchoice=1195&option=5");
  visit_url(url);
  return true;
}

can_spin_time() just looks for the spinner and checks available time remaining. It's been working pretty reliably both for manual checks and for future/past visits. (happy to send that code if helpful - I was just trying to keep things to a minimum for clarity).

My problem is that this code works great once, then a second run of it and KoL gets caught in the choice to time prank, go into the future, etc. If I open the relay browser, I'll be at that choice. Clicking out let's me successfully prank one more time, with the second one getting stuck. I can adventure (both via script and via relay browser) between the two runs and the results are the same - every other one stops at the choice page.

I'd love to see anyone else's solution to time pranking, if anyone has developed it.

Thanks!
 

mapledyne

Member
The problem could possibly be in can_spin_time(), so you should post that.

Here are the related functions that time_prank() calls:

Code:
boolean can_spin_time()
{
  if (item_amount($item[time-spinner]) == 0)
    return false;
  if (time_minutes() == 0)
    return false;
  return true;
}

Code:
int time_minutes()
{
  // hopefully mafia will track this as some point. Until then ...
  string time = visit_url("inv_use.php?pwd=&which=3&whichitem=9104");
  matcher minutematcher = create_matcher("You have (\\d+) minute[s]? left today", time);
  if(minutematcher.find())
  {
     return to_int(minutematcher.group(1));
  }
  return 0;
}

Thanks!
 

mapledyne

Member
I sorted the problem out. It wasn't "every other", though that's what my testing felt like. It failed instead if someone was already in their time stream (they'd already been pranked).

Solution was to check the return from visit_url(url) to see if they already had someone in line:

Code:
boolean time_prank(string player, string msg)
{
  if (!can_spin_time())
    false;
  string url = "choice.php?pwd&whichchoice=1198&option=1&pl="+url_encode(player)+"&th="+url_encode(msg);

  visit_url("inv_use.php?pwd=&which=3&whichitem=9104");
  visit_url("choice.php?pwd&whichchoice=1195&option=5");
  string ret = visit_url(url);
  string oops = "someone else hiding in their timestream already";

  if (contains_text(ret, oops))
  {
    print("Someone beat you to it.");
    visit_url("choice.php?pwd&whichchoice=1198&option=2");
    return false;
  }
  return true;
}
 
Top