If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I am currently going through batbrain and adding enters, tabs and {} where I feel is appropriate so that the code becomes legible (for me that is). As an example, the to_event()-function is 26 lines of code in the original version, but in mine it is 51 lines and oh so much more readable

Scripts maintained by me:AutobasementSmashlib
A small programmer joke:Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
The man came back with 6 bottles of milk.
Wife: Why did you buy 6 bottles of milk.
Man: Because they had eggs...

@Bale: That was a great explanation. (Although I think of get_action() as a simple map lookup -- there are no conversions happening in that function. But that's purely academic.) I would also avoid documenting macro(advevent,"0") -- the string there specifies (the) repeat condition(s) in BALLS. There is a single parameter version to simply perform an action once.

The functions in BatBrain are, naturally, still evolving. The focus until now has been making all combat information available and accurate. The focus henceforth will be making that information easily usable -- which I've been figuring out by working on the new SS. The various get_action() functions were just added yesterday. SmartStasis will soon be using these functions rather than adding raw data to the custom actions list.

Once the functions have stabilized, I'll throw BatBrain up on the ASH Wiki as a resource for combat scripters.

Scripts maintained by me:AutobasementSmashlib
A small programmer joke:Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
The man came back with 6 bottles of milk.
Wife: Why did you buy 6 bottles of milk.
Man: Because they had eggs...

That's zarqon who uses three spaces, not me. I was only copying his method.

I've got my own very simple consult script called FinalAttack.ash which I've been using to conclude a fight. (My version of spamattack.) I just modified it to use BatBrain. I'm not trying to be particularly optimal, I'm just trying to conclude a combat with any of my characters. (I sometimes edit it on the fly when I'm playing.) I am interested in zarqon's commentary about if I used BatBrain properly.

Scripts maintained by me:AutobasementSmashlib
A small programmer joke:Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
The man came back with 6 bottles of milk.
Wife: Why did you buy 6 bottles of milk.
Man: Because they had eggs...

So, new version of the script. Found some small errors of placing in the spell damage formulas. This version does not use batbrain at all due to unexpected results in some ways and so I've reverted that for now

Edit: It also fixes the 9,5 vs. 9.5 error. It does so by instead having 11 there

Scripts maintained by me:AutobasementSmashlib
A small programmer joke:Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
The man came back with 6 bottles of milk.
Wife: Why did you buy 6 bottles of milk.
Man: Because they had eggs...

You're mostly correct, but you don't need the max(1,dmg) -- that's already taken into account in dmg_dealt(). Also, your hit chance is already included in the attack event.

To be entirely correct, you need to access a couple important advevents in BatBrain -- baseround() and retal. The baseround() event includes things that happen every round, such as passive damage and your familiar's attacks (even from the CoT). The retal event happens whenever the monster hits you and includes things like Saucespheres and pointy accessories. Here's the "very correct" way:

The first one is actually more accurate, however, since if the monster has resistances the multiple sources of damage will all be reduced, yet they will still add up to more than one.

@Bale: well done; your example has convinced me to add the tweak you suggested right now. The alternative in your above example would be to add noodles to the queue and then spam the queue with dangeraction, then call macro(), which is slightly inelegant in that it ignores the capability of BALLS to spam actions on your behalf.

I'm also going to clear the queue in macro() after executing it, so you need not bother clearing it anymore.

As far as whether you're using BatBrain correctly, yes. However, you are making unnecessary checks. If get_action() returns an empty event, the skill is unavailable. Otherwise, the skill is available. This will do the same as you posted:

I suppose if my feature request is implemented that undisambiguates/ambiguates your various shadows, you could reach the last line when fighting your shadow, because there's a line to remove all options that don't restore HP when facing your shadow -- but presently last_monster() can never equal $monster[your shadow] so that's a future concern. And who would automate combat against your shadow anyway?

Scripts maintained by me:AutobasementSmashlib
A small programmer joke:Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
The man came back with 6 bottles of milk.
Wife: Why did you buy 6 bottles of milk.
Man: Because they had eggs...