SmartStasis -- a complex script for a simple CCS

Theraze

Active member
I've found that if KoL has me in combat, I can leave my computer logged in overnight and it actually doesn't need to log in again in the morning... the same session continues. Or at least, it appears to... when I was paying attention, didn't see another login happening in the gCLI when I fire up the relay browser.

I was hoping for it (aborting combat) to happen when I had a relay session, but it unfortunately only happened during automation. I kept switching between the two though and hoping. :) Does make sense why it's aborting stasis on HP change... would just be nice if it could abort that script instead of all combat automation, but... eh.
 

Winterbay

Active member
My fight! alias has a repeat-condition in it as well since I've had times where one run_combat() didn't do the trick for whatever reason.
 

Theraze

Active member
I used to have an "attack with weapon" after my consults for when macrofied combat gets aborted... but then I realized that if the automatic combat breaks, I really don't want to just blindly whack out there and hope it works.

I am rather confused though why with 2 consults in a row and an "attack with weapon", macro-aborting the first consult will skip the second and run the "attack with weapon" action. If I can replicate that tomorrow, would that be a mafia bug, or just a charming KoL feature? Not sure which to credit, so I didn't report it...
 

zarqon

Well-known member
If you want mafia to abort the script rather than automation when it encounters KoL combat macro errors, that would be a feature request.

Perhaps a better solution would be to only abort automation for KoL combat errors if they happen outside a consult script, allowing the consult script itself the option of handling the error. That would actually completely solve all of these issues, albeit in a fairly ugly way. SS could submit a limited-use action with a "repeat" and KoL would execute it until it ran out -- then print an error. Since mafia wouldn't abort, BB would rebuild options and combat would continue as though an actual smart availability check were built in. It's rather inelegant to use KoL errors effectively as repeat conditions, but it's arguably better for users as it allows automation to continue.

I may actually make this feature request if you don't.

Your second issue is simple enough -- when your abort happened mafia thought you were in round X, where X > 2. Having finished the consult script, it checked your CCS for which action was at round X and found "attack" -- your second consult script was at the position for round 2.
 

Theraze

Active member
Ah... that makes sense. Except(?) for that without the "attack with weapon" it still stays aborted... does that make sense? So with this:
[ default ]
consult SmartStasis.ash
consult SpamAttack.ash
attack with weapon
it would attack with weapon after SmartStasis aborts, and with this
[ default ]
consult SmartStasis.ash
consult SpamAttack.ash
it just aborts automation entirely.

With how mafia currently runs, I'd expect it to need something like:
[ default ]
consult SmartStasis.ash
consult SpamAttack.ash
attack with weapon
consult SpamAttack.ash
to make it properly consider macro automation aborting...

If you know what you'd like requested, that would probably be better. I'd rather not botch the wording in a way that makes the developers upset with the FReq. It just seems bizarre that mafia will skip further consult scripts but not explicit actions...
 

Winterbay

Active member
Well in the second case it ran line 1, bypassed line 2 due to whatever happened in script one, and then had nothing left to do so aborted.
 

Theraze

Active member
But why would the first CCS run line 3 and not line 2? Why would aborting one consult script make it abort another unrelated script? That's the part that's got me confused. :)
 

zarqon

Well-known member
CCS's aren't order of operations, they are actions linked to mafia's round number (which can differ from KoL's with "quick" actions and such). So it didn't abort the second script, it never called it at all. The first script is in Round 1, the second script is in Round 2. When the first script aborted, it was already past round 2.

It's your second CCS aborting entirely that's more mysterious, since mafia presumably would assume that consulting spamattack occupies all remaining rounds after round 1.
 

Gdunge

Member
, it would go into batfactors.txt ... Just put in the right familiar number, name, values...

Thanks for the tip Theraze!

I looked at the file and realized I didn't know enough to safely change it. For instance, how do I figure out the familiar number?

Then along comes Bale:

Probably not, but that's no reason not to use the starfish as an approximation until the real stats are know. That approximation will do a lot more good than not adding it to batfactors. I think I'll update batfactors with it right now! :)

Thanks Bale for doing my work for me!

Edit: I just checked it and it works - thanks again!
 
Last edited:

zarqon

Well-known member
I feel better -- this change is only a few months old, which is an eternity in KoLmafia development, but a very short time in my RL. Of course, for me this has been a very busy May. :)
 

Bale

Minion
Read this, for example.

Talk about an eternity in Mafia time. That was only 4 months ago, but a decent bit of what holatuwol said in that changelog has already become outdated. That was just a starting point. However it does convey the idea that there is no longer a line number to round correlation.
 

Veracity

Developer
Staff member
The actual "eternity" is that this happened when Jason finished macrofying CCS - over a year ago. I should have searched the SVN commit log; the message I pointed to was holatuwol coming back from a 2 year hiatus and discovering, himself, that things were Very Different. Bottom line is that the CCS really IS just a sequence of actions uncorrelated to rounds - and if it appears to be skipping an action, there is something wrong, somwhere.

Heck, considering that a consult script can consume multiple rounds and then return and the CCS picks up as soon as it returns, that shouldn't be a surprise...

Here is the Commit message for revision 8452:

r8452 | jasonharper | 2010-05-21 03:10:27 -0500 (Fri, 21 May 2010) | 35 lines

A CCS section can now contain many of the combat macro commands, which are
passed thru unchanged in a macrofied combat, or ignored completely if the
combat can't be macrofied: scrollwhendone, mark, goto, call, sub/endsub,
if/endif, and while/endwhile. There are two intentional omissions: "icon"
(which is meaningless in an on-the-fly macro) and "repeat" (which isn't safe
to use with mafia's combat actions, as they may expand to more than one macro
action). If you want an action to be repeated until the combat is over,
either put an explicit loop around it, or simply let it be the final command
in the CCS section in which case mafia will loop it for you.

An arbitrary macro command can be inserted in a CCS by enclosing it in double
quotes. This would be useful for newly-added commands (prior to explicit
mafia support being added), and also to override any mafia augmentation of
the command. For example, "pickpocket" (with the quotes) would
unconditionally attempt to steal an item, even if mafia thinks the monster
has no drops, or that all drops are guaranteed due to your item drop
modifier. (You might be planning to run away after a successful pickpocket,
perhaps.)

If you have a CCS section named [global prefix], its contents will be
macrofied prior to the section that matches the monster name or location (or
ignored in round-by-round combat). You can use it to define subroutines that
can be used from any CCS section. It would also be the ideal place to put a
"scrollwhendone" command if you want that globally enabled.

The CCS editor no longer inserts line numbers in each section, as they are no
longer very useful in the presence of macro loops, conditionals, and
subroutines that make the line number entirely unrelated to the round number.
Existing line numbers will disappear the first time you edit and save the
CCS. You can still manually type a number followed by a colon at the start
of a line, as a shortcut for replicating the previous line until the
specified line number is reached.

The CCS editor's "help" button now works in both view and edit modes.
 

Theraze

Active member
Going back to what's making my SmartStasis abort... I think this might be it:
You're fighting a writing desk
HP: 34, Atk: 53, Def: 52
Drops: disintegrating quill pen (15), inkwell (30), snifter of thoroughly aged brandy (30)
You conjure up a mass of sticky noodles to entangle your opponent.

Trofflesby floats behind your opponent, and begins to glow brightly. Starlight shines through your opponent, doing 28 damage, and pours into your body.
You gain 28 Mana Points.

Your opponent struggles against your entangling noodles, but to no avail.

You don't have or can't use skill #3004, macro aborted.
 

Theraze

Active member
Here's one on another character, but think it's the same thing...
Visit to Manor1: Haunted Library in progress...
[927] Haunted Library
Encounter: writing desk
Strategy: C:\Program Files (x86)\KoLMafia\ccs\default.ccs [default]
Round 0: Theraze wins initiative!
1 MP costs 5.0μ.
1 HP costs 1.4285715μ.
disintegrating quill pen (15.0 @ +25.0): 45μ * 18.75% = 8.4375
inkwell (30.0 @ +25.0): 349μ * 37.5% = 130.875
snifter of thoroughly aged brandy (30.0 @ +25.0): 34μ * 37.5% = 12.75
Value of stat gain: 105μ
Profit per round: ActionProfitDamageOtherbase; Star Starfish (0μ)40.84μ8.17 (0 μ/dmg)MP: 8.17
Building options...
Options built! (16 actions)
disintegrating quill pen (15.0 @ +25.0): 45μ * 18.75% = 8.4375
inkwell (30.0 @ +25.0): 349μ * 37.5% = 130.875
snifter of thoroughly aged brandy (30.0 @ +25.0): 34μ * 37.5% = 12.75
Value of stat gain: 105μ
Monster: Writing Desk, ATT: 54, DEF: 53, HP: 63, Value: 257.06
You will die in 47 rounds.
Your attack will kill the monster in 2 rounds.
Building custom actions...
Custom actions built! (0 actions)
Stasis action chosen: skill 3004
Top of the stasis loop.
Executing macro: scrollwhendone; sub batround; endsub; sub batsub1; skill 3004; call batround; endsub; call batsub1; repeat !hpbelow 69.0 && !mpbelow 133.0 && !pastround 27;
Round 1: Theraze executes a macro!
Round 1: Theraze casts ENTANGLING NOODLES!
Round 2: Tron floats behind your opponent, and begins to glow brightly. Starlight shines through your opponent, doing 31 damage, and pours into your body.
Round 2: writing desk takes 31 damage.
You gain 31 Mana Points
Building options...
Options built! (15 actions)
Stasis action chosen: skill 3009
This monster is not your huckleberry.
Stasis loop complete.
SmartStasis complete.
You're on your own, partner.
Because I'm using a star starfish, the loop that should end when I get below 133 mp doesn't...
 

Winterbay

Active member
Yep, that appears to indeed be the same problem. But the interesting thing is that it actually chooses a second stasis skill (3009) and then aborts anyway.
 
Top