BatBrain -- a central nervous system for consult scripts

zarqon

Well-known member
How does this stack with vulnerability to an element? Does the vulnerability take precedence or is the damage still reduced, and if so, is the damage reduced before or after the vulnerability doubles the damage?

EDIT: For that matter, how does it stack with monsters that already have atypical resistances?
 
Last edited:

Bale

Minion
Multiplication is commutative. If You do X damage to the monster, it takes double damage for elemental vulnerability and is protected by 25% damage reduction: X (0.25)(2) is the same as X(2)(0.25)

It will still take double damage and the order of operations is impossible to determine.
 
Last edited:

zarqon

Well-known member
Ah, been playing too much Pathfinder -- was thinking of resistance as functioning like DR. This can take monsters that already have high resistance up to immunity then? No further capping needed?

EDIT: Last question for now: does in-combat deleveling affect the monster's resistances due to +ML?
 
Last edited:

xKiv

Active member
Ah, been playing too much Pathfinder -- was thinking of resistance as functioning like DR. This can take monsters that already have high resistance up to immunity then? No further capping needed?

Why would other resistances matter? ML-based resistance simply cuts damage by 10.4% (at 26 ml) to 50% (at 125 ml), entirely independently of other resistances.
So a monster that had 75% resistance to damage, with 75 ml (cuts 30% damage) will have a total of (1-0.25*0.7=1-0.175=0.825) 82.5% resistance. It can only have 100% resistance if it already had 100% resistance even without ml.


What I am not sure of is, whether slime-hates-it based ml counts toward this. I think it doesn't.


Also, as far as stun and stagger resistance goes, I think it's this simple (ml levels may not be entirely correct):
if ml > 100, stuns don't work, at all
if ml > 150, staggers don't work either
(don't work means: the skill/item is still used, but monster attacks anyway)
 

Bale

Minion
Also, as far as stun and stagger resistance goes, I think it's this simple (ml levels may not be entirely correct):
if ml > 100, stuns don't work, at all
if ml > 150, staggers don't work either
(don't work means: the skill/item is still used, but monster attacks anyway)

It's not that simple. I believe that what you posted is correct, but between 50 and 100 there is a gradually increasing chance that stuns will fail.
 

zarqon

Well-known member
Ok, so you're all saying that it's multiplicative, but Bale's posted code is additive, which is why I keep asking questions about stacking.

So do I understand correctly that reduced damage due to +ML happens, then monster resistances/vulnerabilities, then soft/hard damage caps? If so, Bale's code is incorrect.

Consider a monster vulnerable to cold which has +50 ML (20% reduction). The posted (additive) code would change the cold resistance from -1 to -0.8, resulting in 180% of the original damage. If they are applied sequentially, however, first the ML-reduced damage is 80% of the original, which when doubled by the vulnerability would be 160%.

To apply them sequentially we need both multiplication and addition:

Code:
   if (numeric_modifier("Monster Level") > 25) {
      float ml_res = min(numeric_modifier("Monster Level") * .004, .5);
      foreach res,amt in mres
         mres[res] = ml_res + amt - (ml_res * amt);
   }

Based on the information posted so far I believe this is correct.

@lost: Thanks. So the place for this is not in act() but rather set_monster().
 

zarqon

Well-known member
Okay, I believe update r39 mostly catches me up in this thread.

  • As Crowther suggested, I added support for a "nospells" keyword in monster data. The golem and skeletons that previously used special code now simply use that keyword.
  • Also added the above code to account for +ML giving monsters variable resistance to all damage types. Thanks Bale for getting that started.
  • Finally, monsters with +ML over 100 are treated as having the "nomultistun" keyword, and monsters with +ML over 150 are treated as having the "nostun" keyword. I'll await further data on the 51-100 range.

Enjoy!
 

Crowther

Active member
I lost again to a "ninja snowman assassin". I hadn't realized before, but they are special. They also aren't in batfactors, so I die well before predicted. The wiki says, they are "nomiss", which is the biggest reason I died, and that's easy enough to add to batfactors, but they also do some special cold damage according the wiki. I've no idea if that formula is right or how to let BatBrain/WHAM know about it.
 

Bale

Minion
The formula is correct. Unfortunately BatBrain would need a code update to know it.

Guide calculates their attack damage that way and provides warning of the safe HP required at my current DA and cold resistance. As Avatar of Sneaky Pete I found that number very important because he doesn't have many HP. Since I did 20 Sneaky Pete ascensions, I can vouch for the accuracy.
 

Crowther

Active member
I think adding this:
Code:
      case $monster[ninja snowman assassin]:                                                                 
          spread res;
          res[m.attack_element] = (max(0,monster_stat("att")-my_stat("Moxie"))+110)*
              (1 - minmax((square_root(max(0,numeric_modifier("Damage Absorption"))/10) - 1)/10,0,0.9));
          return res;
to m_regular() will work, but I can't test it tonight.
As well as adding "nomiss" to batfactors.txt. Are we trying to keep that monsters section sorted? Or was that just a one time neatening?

EDIT: Oops, forgot about the ignoring some of your cold res part.
 
Last edited:

Bale

Minion
Sadly that is not sufficient to support the assassin. His attacks are cold elemental and the damage is reduced by your cold resistance as if it was 5 levels less.
 

Crowther

Active member
Sadly that is not sufficient to support the assassin. His attacks are cold elemental and the damage is reduced by your cold resistance as if it was 5 levels less.
Yeah, I realized that while trying to sleep last night. That's why I posted the code. I was hoping someone (you really) would find holes in it. Thanks. I should be able to test it today. I was thinking I'd have to fax and putty them, but I realized that my non-ascending multi has an infinite supply, so I've got plenty of chances to get it wrong.

EDIT: Drat. I see the problem is bigger than I thought. Mafia computes the resistance formula, not batbrain.
 
Last edited:

Crowther

Active member
Okay, I got it working, all except this:
Code:
      if (amt > 0) res += amt - min(pres[el]*max(amt,30),amt - 1.0);
I can't figure out why there's a "max(amt,30)" in there, but it makes my numbers come out slightly wrong.

Also, I don't like the idea of adding the elemental resistance formula to BatBrain. Having the same code two places is something that bothers me, because eventually one gets changed and the other doesn't. I added it anyway. Maybe handling the reduction in player cold resistance when fighting this monster should be in KoLmafia?

Still, it's a big improvement over not accounting for this special monster. I'm surprised this one slipped through the cracks for so long, here's my patch:
 

Attachments

  • assassin.patch
    1.7 KB · Views: 20

Crowther

Active member
To be clear. The line I quoted above is from BatBrain when it is applying player elemental resistance (pres) to the damage amount (amt).
 

Crowther

Active member
In my testing I had a base damage of 25. A resistance of 15 (after -5 from the assassin), so 83%. I saw 4 (25*(1-.83)) damage. That formula says I should have seen 1 damage. I did not test other data points.
 
Last edited:

Crowther

Active member
Here's my patch for handling turn-offs at the Fun-guy Mansion. There's still a couple that are likely wrong or unknown (what's spooky). It's a very long list. This worked very well for me. It efficiently handled fights up until very high levels (thousands of kills). I remember there being something off that became more apparent then. Maybe it was a skills not being used when it should because of KoL's spell vs not-spell "logic". It was a while ago. The problem was WHAM aborting unable to kill, when there was an option. Of course by that time, I was also finding monsters I couldn't figure out how to kill at all.

EDIT: My patch contains an ñ. I'm not sure if that's going to cause problems. I swear ever time non-ASCII characters show up, there is trouble.
 

Attachments

  • turn-offs.patch
    5.8 KB · Views: 27
Last edited:
Top