Feature - Implemented Normalize mood execution for the GUI and the Relay Browser

Bale

Minion
Original discussion HERE. I will summarize that discussion in this post.



There is a lack of consistency in the behavior of moods depending on the character's choice of adventuring in the relay browser or automatic adventuring in the GUI.

Moods fire before automatic adventuring or after relay adventuring.

In the GUI this is advantageous since it prepares the mood before your encounter. In the relay browser this does not ensure that the player has the correct buffs before adventuring, so it is clearly disadvantageous.

It tries to compensate for this flaw by always leaving 1 turn of buff, so that the next adventure is already buffed. Obviously this is a bit of a kludge. It is a good thing to keep at least 1 turn for stat boosting buffs like mojomelody, but other buffs merely consume MP, sometimes when you would rather see if you need the buff for another adventure before deciding to remove it from the mood.

There is one drawback to this: It would break some things if moods were run before the turn instead of after. For example, I have a script that runs unconditionally as part of my mood. In this moodScript...

PHP:
if(item_amount($item[evil eye]) > 0) use(item_amount($item[evil eye]), $item[evil eye]);

That automatically uses my evil eyes as I gain them. If that was run before my turn instead of afterwards it may often take me one more turn to complete the Nook, unless I manually use the last evil eye. I added it to my moodScript so that I don't have to manually do something mindless and repetitive.

If you want to run moods are run before manually adventuring, then betweenBattleScripts need to run after adventuring in the relay browser so that I can move my moodScript stuff to a betweenBattleScript and keep the functionality. Moods should run before all adventures regardless of relay or automatic and betweenBattleScripts should run after all adventures regardless of relay or automatic. That would solve things nicely.


To summarize this feature request, since it is a little complex and everything needs to work together.

  1. Make moods run consistently before adventures in both the GUI and relay browser.
  2. Fix betweenBattleScript to run after relay browser adventure as well as GUI.
  3. Change moods to automatically recast buffs that increase stats at 1 turn remaining and other buffs at 0 turns remaining.
 

Bale

Minion
Were we to change this, do we change it early after a release - to allow people to change their scripts and for us to work out the issues - or just before a new release - which will surprise people who, for whatever reason, don't use daily builds? I suspect the former.

Change it early after a release, like now-ish. That way the bugs get ironed out before a new release and scripters have a chance to update their scripts before the new point release. It improves the chance that everyone is on the same page.

We currently have:

relayMaintainsEffects - Run moods during manual adventuring
relayMaintainsHealth - Maintain health during manual adventuring
relayMaintainsMana - Maintain mana during manual adventuring

I assume those last two invoke Recover Scripts, as needed. Presumably, we add

relayRunsBetweenBattleScripts

... and the set of four settings control how scripts/moods/autorecovery works in the Relay Browser.

Sounds like a good idea.
 
Last edited:

Fluxxdog

Active member
  1. Make moods run consistently before adventures in both the GUI and relay browser.
  2. Fix betweenBattleScript to run after relay browser adventure as well as GUI.
Forgive me if I seem to be over simplifying this, but you're looking for a beforeBattleScript/Mood and an afterBattleScript/Mood, correct?
 

zarqon

Well-known member
It does seem like all of our problems could be solved if moods always ran before adventuring and we had a consistent way to add both pre- and post-adventure handling, separate from moods, which I prefer to use only for maintaining effects. Perhaps expand the betweenBattleScript into preBattleScript and postBattleScript, and give the option (relayRunsBattleScripts, already suggested by Veracity) of firing them during relay play? This would be more consistent than players needing to add one script to a mood and the other script to a preference.

I am following this thread's career with considerable interest.
 

Bale

Minion
Perhaps expand the betweenBattleScript into preBattleScript and postBattleScript,

In the interest of not breaking stuff, what would happen if someone is currently using the betweenBattleScript hook? Wouldn't that simply cease to exist under your schema?
 

zarqon

Well-known member
Transitional code has been used before. The user's betweenBattleScript could be copied to the preBattleScript (since that's when it presently fires), and then deleted. This means the only thing that would break is if someone were altering their betweenBattleScript setting on the fly in another script, which is 1) highly unlikely, and b) probably only done by users quite savvy enough to deal with the change easily.

"betweenBattleScript" has never been the best name for that property anyway, since it fires even before your first battle, so even though it's not a particularly big deal I'd be happy to see it changed to something more accurate.

I'm all for breaking suboptimal things to make them optimal, but I'm aware that others may not share this attitude. (I have not forgotten the complaints when I removed the entirely superfluous spaces_to_underscores() from ZLib.)
 

Fluxxdog

Active member
If betweenBattleScripts were run before and after adventuring, would that be an issue?
Yes. If a bBS hits the server at all, it's guaranteed to do it twice as much, once before and once after each adventure().
Code:
Running bBS: 12 server hits
adventure(1,$location[wherever]);
Running bBS: 12 server hits
Running bBS: 12 server hits
adventure(1,$location[wherever]);
Running bBS: 12 server hits...
I think they're looking to stream line it so it's more like:
Code:
Running preBS: 7 server hits
adventure(1,$location[wherever]);
Running postBS: 5 server hits
Running preBS: 7 server hits
adventure(1,$location[wherever]);
Running postBS: 5 server hits...
Heck, if something caused an abort during the combat, those last 5 server hits wouldn't even be needed.

Edit: Here's a side thought. What about functions that declares when it's before or after a battle? If adventure() pulls up the bBS, it can filter what it does whether it's before or after.
Code:
if(before_battle()){
     buff_up(); do_other_stuff();}
if(after_battle()){
     count_loot(); grab_beer();}
 
Last edited:

zarqon

Well-known member
Yes; probably a better option than adding new ASH functions would be adding a boolean parameter to the main() of betweenBattleScripts, specifying whether the script was being called before or after adventuring. Feels a bit hackish, but would work.
 

Theraze

Active member
The problem with an internal change inside the main and running the same script before/after battles is that, if the bBS does any server hits and it isn't updated to split out between before and after battle, you're still looking at doubling server hits for a LOT of people.

Changing it to be beforeBattleScript/afterBattleScript or preBattleScript/postBattleScript means that unless someone manually double-assigns it, they won't double-server-hit.
 

Stardock

Member
Anything happening with this? I do most of my adventuring in the relay browser and the mood fire before adventuring would be more desirable to me.

Also Bale, I don't 100% understand what you mean when you say this change might case issues in the nook with your evil eye function.

Right now it should do:
(adv1)->(mood execute after adv1)use evil eye->(adv2)

That should be the same as:
(adv1)->(mood execute before adv2)use evil eye->(adv2)

Right?
 

Stardock

Member
Also, just an additional point. If it's changed to execute before the adventure it would be really nice if my_location() was updated before the mood was executed.
 

Stardock

Member
I was unsure the flow on that. I know that it is for counter and betweenbattle, but I just wanted to make sure it went:
set my_location->mood execute
instead of
mood execute->set my_location
 

slyz

Developer
Also Bale, I don't 100% understand what you mean when you say this change might case issues in the nook with your evil eye function.

Right now it should do:
(adv1)->(mood execute after adv1)use evil eye->(adv2)

That should be the same as:
(adv1)->(mood execute before adv2)use evil eye->(adv2)

Right?
You missed that it's actually

(adv1)->(mood execute after adv1)use evil eye->(check if you need to spend another adventure)->(adv2)
 

Stardock

Member
Ah, so it would interfere with boss fight preparation?

Either way, I get it and after looking at the code I'm guessing that it isn't very trivial to implement this. The current mood executes when you lose an adventure because that's an easy condition to check for right? It's more difficult to determine in the relay browser when you intend to adventure than when you have adventured.
 

Veracity

Developer
Staff member
It's more difficult to determine in the relay browser when you intend to adventure than when you have adventured.
Actually, RelayRequest currently checks if you are "about to adventure" and, if so, waits for moods and recovery to finish before doing so. It could, presumably, kick off between battle actions at that time, rather than assuming they had already started and waiting for them. That would also allow me to fix Zaranthos's recent report that if clicks a basement button to start the next adventure BEFORE KoLmafia starts its recovery, it doesn't recover.
 

Stardock

Member
That would be cool, the mood thing still wouldn't be consistent but at least we'd have something firing before an adventure in the relay browser.
 
Top