Can't get scrolls to work right on photocopied rampaging adding machine

Zitim

New member
I'm not sure whether this is a bug or something I did wrong, so I'm posting here first for advice.

My clan keeps a rampaging adding machine in our deluxe fax machine. Several years ago I wrote a script to collect the appropriate scrolls, receive a fax, fight the adding machine, and ultimately get a facsimile dictionary to pull during the next softcore ascension. This worked fine for a long time, but somewhere between versions 17.5 and 17.6 it started generating errors and failing, interrupting my ascension script. I've tried different approaches, with the same result: it uses the first scroll (or two if funkslinging) successfully and then complains it doesn't have the last scroll it just used. Here are some snippets of code, CCS, and output from some different variations:

code:
set_auto_attack(0);
use(1,$item[photocopied monster]);
run_combat();

CCS:
[ adding machine ]
item 30669 scroll,33398 scroll
item 64067 scroll,668 scroll
attack with weapon

Autoattack is disabled.
Using 1 photocopied monster
[1041] photocopied monster
Encounter: rampaging adding machine
Round 0: Zitim wins initiative!
Round 1: Zitim uses the 30669 scroll and uses the 33398 scroll!
You acquire an item: 64067 scroll
You don't have enough 33398 scroll
You're on your own, partner.
Click here to continue in the relay browser.

code:
set_auto_attack(0);
use(1,$item[photocopied monster]);
run_combat();

CCS:
[ adding machine ]
item 30669 scroll
item 33398 scroll
item 64067 scroll
item 668 scroll
attack with weapon

Autoattack is disabled.
Using 1 photocopied monster...
[1093] photocopied monster
Encounter: rampaging adding machine
Round 0: Zitim wins initiative!
Round 1: Zitim uses the 30669 scroll!
You don't have enough 30669 scroll
You're on your own, partner.
Click here to continue in the relay browser.

code:
set_auto_attack(0);
use(1,$item[photocopied monster]);
if (item_amount($item[30669 scroll]) > 0 && item_amount($item[33398 scroll]) > 0)
throw_items($item[30669 scroll],$item[33398 scroll]);
if (item_amount($item[668 scroll]) == 0 && item_amount($item[334 scroll]) >= 2)
throw_items($item[334 scroll],$item[334 scroll]);
if (item_amount($item[64067 scroll]) > 0 && item_amount($item[668 scroll]) > 0)
throw_items($item[64067 scroll],$item[668 scroll]);
run_combat();

Autoattack is disabled.
Using 1 photocopied monster...
[1087] photocopied monster
Encounter: rampaging adding machine
Round 0: Zitim wins initiative!
Round 1: Zitim uses the 30669 scroll and uses the 33398 scroll!
You acquire an item: 64067 scroll
You don't have enough 33398 scroll
You're on your own, partner.
Click here to continue in the relay browser.

I read recently that when you trigger a monster from something like a fax, you don't need to use run_combat(), but I tried removing it and got the same result. I only posted the most relevant code in the interest of space, but I can post more if it's of interest. I've looked back at this code and CCS plenty of times, and I can't see what's wrong with it. I'm running Windows 7, and this has been happening with both Oracle Java and now Eclipse Adoptium 17.0.1+12. Any ideas?
 
Have you tried with the most recent daily build since the point builds don't have all the most recent fixes and can be very old
 

Veracity

Developer
Staff member
I see code in FIghtRequest:

Code:
      // Adding machine should override custom combat scripts as well,
      // since it's conditions-driven.

      else if (monsterName.equals("rampaging adding machine")
          && !KoLConstants.activeEffects.contains(FightRequest.BIRDFORM)
          && !FightRequest.waitingForSpecial) {
        this.handleAddingMachine();
      }
It should "override CCS", eh? Hmm.

Code:
    int action = Preferences.getInteger("addingScrolls");
    // 0: show in browser
    // 1: create goal scrolls only
    // 2: create goal & 668
    // 3: create goal, 31337, 668

It could be as simple as this:

Code:
set_property( "addingScrolls", 1);
set_auto_attack(0);
use(1, $item[photocopied monster]);
run_combat();
 

Zitim

New member

txrangersxx:

Good question. Yes, I usually use a daily .jar build, and I regularly get the latest one. I cited those old point builds just as a rough indicator of when I started having the problem.

Veracity:

Thanks for the tip. I had no idea there was a property for that. Let me try it and see what happens.
 

ckb

Minion
Staff member
That seems like a thing from long days past. It would be nice to have an option that is "Let the user use their own ccs"
 

Zitim

New member
Hmm. Changing the "addingScrolls" property to 1 seems to introduce a different error. Here are the code and output. Note that I changed the property (from 2 (default?) to 1) and already acquired the relevant scrolls, before running the script this time, so that doesn't show up in the output.

Code:
import <generic.ash>;
int aa;
void main()
{
  set_property("addingScrolls",1);
  print("Getting scrolls....","blue");
  justn(1,$item[668 scroll]);  # custom routine in generic.ash to pull/buy as needed to have n items
  justn(1,$item[30669 scroll]);
  justn(1,$item[33398 scroll]);
  print("Getting fax....","blue");
  visit_url("clan_viplounge.php?action=faxmachine");
  visit_url("clan_viplounge.php?preaction=receivefax");
  print("Fighting rampaging adding machine....","blue");
  aa = get_auto_attack();
  set_auto_attack(0);
  use(1,$item[photocopied monster]);
  run_combat();
  set_auto_attack(aa);
}

Getting scrolls....
Getting fax....

Visiting Fax Machine in clan VIP lounge
You acquire an item: photocopied monster
You receive a photocopied rampaging adding machine from the fax machine.
Fighting rampaging adding machine....
Autoattack is disabled.
Using 1 photocopied monster...

[1422] photocopied monster
Encounter: rampaging adding machine
Round 0: Schlager wins initiative!
(addingmachine.ash, line 16)
Script execution aborted (java.lang.StackOverflowError): (addingmachine.ash, line 16)

At this point I'm in a fight, and I have to finish in the relay browser. I'm still baffled.
 

Veracity

Developer
Staff member
OK, I see. I tested by manually adventuring (no fax) until I got an adding machine and then doing run_combat() in the gCLI. I cannot reproduce the StackOverflowError - although I think that an issue with your CCS - but I understand how the scroll automation and the property work.

Executive Summary:

1) If you want to use the built-in automation, set goals (using the "conditions" command), set addingScrolls to 1, and run_combat() after you see the adding machine. Note that if it is still alive after it achieves your goal, the fight will fall into your CCS. Something like this:

Code:
set_property("addingScrolls",1);
cli_execute( "conditions clear" );
cli_execute( "conditions add 1 64735 scroll" );
set_auto_attack(0);
use(1,$item[photocopied monster]);
run_combat();

2) If you want to entirely depend on your CCS, clear goals and set addingScrolls to 1. run_combat() should fall right into your CCS. Like this:

Code:
set_property("addingScrolls",1);
cli_execute( "conditions clear" );
set_auto_attack(0);
use(1,$item[photocopied monster]);
run_combat();

You should be able to debug your CCS by manually adventuring until you see an adding machine and then typing the "script" button.

Additional comments:

1) The "addingScrolls" property is available in GUI: select the Valley of Rof L'm Fao, go to Choice Advs, and voila! There is a dropdown where you have these options:

show in browser
create goal scrolls only
create goal and 668
create goal, 31337, 668

Those correspond to 0, 1, 2, 3.

For some reason, the current default value for that property is -1?

Notice that they depend on the "goals" you have set. That's the box on the Adventure frame of the GUI, below the panel of adventuring zones. If you automate through the GUI, you check the checkbox, set the goal, select a zone and an adventure count, and click the begin button. It adventures until the goal is met. The built-in automation for the adding machine supports that: set the goal to be 64735 scroll, and when it meets the adding machine, it combines scrolls to get you one. Assuming it succeeds, the goal is cleared, and automation stops.

Using a script, you need to not only set the property as desired, but set a "goal". You can do that with the "conditions" command.

2) I experimented by manually adventuring in the relay browser and then typing run_combat() in the gCLI.

- With no goals set, addingScrolls = 1, and manual adventuring until I saw the adding machine, run_combat() fell into my CCS and just fought the adding machine. Check.

- To verify that, I set my CCS like this:

[ rampaging adding machine ]
consult consult.ash

And provided consult.ash:

Code:
void main(int initround, monster foe, string page)
{
    print( "initround = " + initround );
    print( "monster = " + foe );
    print( "page length = " + length( page ) );
    attack();
}

Manual adventuring until I see an adding machine:

Code:
> ashq run_combat()

initround = 1
monster = rampaging adding machine
page length = 15082
Round 1: Chondara attacks!
Round 2: rampaging adding machine takes 4891 damage.
Round 2: Chondara wins the fight!
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
After Battle: You gain 6 Muscleboundness
After Battle: You gain 12 Magicalness
After Battle: You gain 10 Sarcasm

Which is to say, it ran my CCS which defered to a consult script, which finishes the combat. Check.

3) In your case, with no goals and addingScrolls =1, it went to your CCS - and I assume it was something there which caused the infinite loop.
 

ckb

Minion
Staff member
1) The "addingScrolls" property is available in GUI: select the Valley of Rof L'm Fao, go to Choice Advs, and voila! There is a dropdown where you have these options:

show in browser
create goal scrolls only
create goal and 668
create goal, 31337, 668

Those correspond to 0, 1, 2, 3.

For some reason, the current default value for that property is -1?

Looking at FightRequest.java, "addingScrolls" gets used thusly:

Code:
  private void handleAddingMachine() {
    int action = Preferences.getInteger("addingScrolls");
    // 0: show in browser
    // 1: create goal scrolls only
    // 2: create goal & 668
    // 3: create goal, 31337, 668
    if (action == 0) {
      FightRequest.nextAction = "abort";
      return;
    } else if (FightRequest.desiredScroll != null) {
      this.createAddingScroll(FightRequest.desiredScroll);
    } else if (GoalManager.hasGoal(FightRequest.SCROLL_64735)) {
      this.createAddingScroll(FightRequest.SCROLL_64735);
    } else if (GoalManager.hasGoal(FightRequest.SCROLL_64067)) {
      this.createAddingScroll(FightRequest.SCROLL_64067);
    } else if (GoalManager.hasGoal(FightRequest.SCROLL_31337)) {
      this.createAddingScroll(FightRequest.SCROLL_31337);
    } else if (GoalManager.hasGoal(FightRequest.SCROLL_668)) {
      this.createAddingScroll(FightRequest.SCROLL_668);
    } else if (action >= 3) {
      this.createAddingScroll(FightRequest.SCROLL_31337);
    } else if (action >= 2) {
      this.createAddingScroll(FightRequest.SCROLL_668);
    }
  }

So in this case, -1 (or any negative number) seems to be treated the same as 1.

The default should probably be 0 or 1 to be more clear.
 

Zitim

New member
Voila! Thank you very much, Veracity! I tried your #1 above, with no special CCS, and it worked perfectly.

Since I hadn't noticed the built-in automation under Choice Advs, which seems to have had a default of 2 in my prefs file, I see that my original script was asking Mafia to automate without goals, and then it was getting further confused by my CCS or hard-coded actions. And in my last script above, I clearly had the same problem with a lack of goals. For some reason, I wrongly assumed they were part of the automation, when of course I should have supplied them as in any other context. Thank you for the clear, thorough explanation.
 
Top