Crash during battle when manipulating stats

If your game crashes, please copy and paste the full error message below, or post a screenshot of it.
Unfortunately I play on mobile so no screen shot. I’ll try and accurately type the message and stack trace:

action number 1
of Step Event0
for object obj_battlecontroller:

Cannot apply sqrt to negative number.
at gml_Script_diminishing_returns (line 9) - var trinum = (sqrt(8 * mult + 1) - 1) / 2;

stack frame is gml_Script_diminishing_returns (line 9)
called from - gml_Script_bc_EventGainDefense (line 33) - o.amount = diminishing_returns(o.amount, bit_mult(crit_defense(o.creature), .3))
called from - gml_Script_bc_OnProvoke (line 253) - scr_AddEventToStack(1, bc_EventGainDefense(crit, tgts[i], thylacine_round(bit_mult(crit_defense(tgts[i]), .3)), wait, “(Congregation)”))
called from - gml_Script_bc_CreatureProvoke (line33) - bc_OnProvoke(creature)
called from - gml_script_bc_ArtificialIntelligence (line 406) - bc_CreatureProvoke(crit, 1)
called from - gml_script_bc_Turn (line 5) - bc_ArtificialIntelligence(creature, global.enemies, global.crits)
called from - gml_Object_obj_battlecontroller_StepNormalEvent_1 (line 119) - bc_Turn(global.creatureList[1])

Please describe in as much detail as possible how to reproduce the bug or crash.
I’m not sure if this was the exact circumstances (just because the stack makes it look like it was the enemy going) but I’ve been seeing the top level message a lot. I’m running a combination of bastions, crypts, and doom spectres and I’ve been seeing this or similar crashes a lot when either increasing my stats or decreasing the enemies (it’s hard to tell which because the crash always happens while I’m holding down A and not paying attention).

What operating system are you playing the game on? Windows, Mac OS, Android, iOS, or Playstation?
If it’s Playstation, please also state your region (NA or EU). If it’s a mobile device, please state the device’s model/brand (such as Nexus 5 or Samsung Galaxy Tab 4).

I’m playing on an Android Nexus 5.

What game version are you playing? You can find the version number on the title screen in the lower left corner.



Screenshot on a mobile device is usually volume up or down and power button at the same time. Depends on the phone. For iPod or iPhone it is home and power button.

I’m pretty sure this one is already fixed or being fixed, and the patch simply isn’t out yet. It’s really just a missing sanity check in the diminishing returns formula, easily fixed.