Since Bale made me this thread, and it contains lots of good discussion already, I decided to make this the official BatBrain thread. I think it's ready for release, so I'm calling this update 1.0. It has some really awesome new features.
BatBrain 1.0 updates!
- Smarter aborting of macros (don't use "match" for poisoned, etc.), and a generally more streamlined batround.
- Smarter insertion of batround into the macros. Subroutines including batround are still built-in for actions with repeat conditions.
- New wrapper function for player stats -- my_stat(string which). This is basically identical to the already existing monster_stat(string which), except for the player instead. Presently the only possible values are "hp" and "mp". All references to the ASH functions my_hp() and my_mp() have been replaced with this, and you should do the same if you're writing a script using BatBrain -- for reasons I will soon divulge.
Major changes to the enqueueing process:
- All versions of enqueue() now return a boolean and reject actions (don't enqueue them) if they are empty or if you lack the MP at that point. It returns true if the action was accepted and added to the queue. Now, if (enqueue(get_action("myaction"))), then myaction is available to your character and was added to the queue.
- All versions of macro() now clear the queue, after enqueueing any actions specified in parameters. It will clear the queue regardless of whether the action was actually enqueued.
And now for something truly amazing: Predictive Adjustment
I'm quite excited to announce this; the framework for it has been sitting there for a long time but I've finally made it work.
When an action is enqueued, the script environment is adjusted to a post-queue state. In other words, if you enqueue an action such as "attack", then check
monster_stat("hp"), it will return an adjusted value -- the monster's HP minus your expected damage. If you enqueue a second attack, it adjusts the value further. Checking
my_stat("hp") will also include adjustments for the monster's expected damage during those rounds. These adjustments also include retaliation damage, familiar actions, passive effects, etc. -- and significant meat gain/loss if you are predicted to kill the monster or die trying (
monster_value() and
beatenup, respectively). You can now easily build entire predictive combats in your script.
Since this is a new feature, there are definitely some special cases and formula variables which are not properly altered when adjusting for an enqueued action, but all the most important ones -- accessible in
monster_stat() and
my_stat() -- are handled. Additionally, since all the adjustments are kept in a gobal advevent variable called
adj, you can check the fields of that variable any time for your estimated progress in any of those areas.
For example, if your Volleyball has an ant pick equipped, that's an average of 5 meat per round and 4.4 cold damage. You're facing a Battlefield monster and you enqueue noodles, followed by a saucestorm, followed by a regular attack. That's three rounds -- so assuming no other factors at play, if you check adj.meat at that point, it will contain 15. If you check adj.mp, it will contain -13 (the cost of both skills). If you check adj.hp, it will contain 0, since Noodles is assumed to stun for 3 rounds. The $element[none] field of adj.dmg is used as the monster's HP adjustment, and it will contain -(your estimated saucestorm damage + your estimated attack damage + 26.4). That last number is 4.4 times 3, and doubled because Battlefield monsters are vulnerable to cold.
At last, a predictive solution to plinking:
PHP:
while (m_hit_chance() > 0.07) enqueue(get_action($skill[suckerpunch]));
Known Issues
- Predictive adjustment presently doesn't work for actions with repeat conditions -- it will treat them like single actions. I don't know if I'll ever try to make this work -- generally, if you know the repeat conditions, you generally know the situation post-macro, at which point if the combat isn't over your script can recalculate.
- Predictive adjustment also doesn't know about auto-funkifying yet. If you enqueue two consective item throws, the macro will automatically convert these to a single funkslinging toss -- but this happens at the time of macrofying, not at the time of enqueueing, so it predicts this like two rounds rather than one. This is an issue which will be fixed. Auto-funkifying will be moved into enqueueing -- but for now, it just means extra-conservative combat estimations; not too harmful.
Neat, eh? Have fun!