[(BG2) Engine Bug] Attacks per round bonuses (0824) (ToBEx10)
This one's a bit difficult to describe, but it's a problem with how the engine handles opcode 1, attacks per round bonus. From the IESDP (emphasis mine):
#1 (0x001) Stat: Attacks Per Round Modifier [1]
Parameter #1: Key Modifier
Parameter #2: Type
Description:
Alters a characters Attacks per Round, by changing the Key by the modifier value specified by the 'Key Value' field, in the style specified by 'Type' field.
0 Cumulative Modifier -> Key = Key + 'Key Modifier' value
1 Flat Value Modifier -> Key = 'Key Modifier' value
2 Percentage Modifier -> Key = (Key * 'Key Modifier' value) / 100
3 Cumulative Modifier -> Same as 0
NB. When this opcode is stacked, the values of the Key Modifier are stacked, not the number of attacks.
The problem comes with effects stacking. Since it's the key value that's being added, a bunch of effects can push the value from 5 to 6 resulting in a drop from 5 attacks per round to 1/2 attack--exactly what happens with Melf's Minute Meteors gets crossed with Boon of Lathander. Melf's sets attacks to five (sets key=5) and then Boon gives a bonus of one attack per round (key+1), resulting in a Boon'd, MMM-wielding cleric-mage to throw a meteor every other round (key=6). We worked around this in BG2FP by disallowing casting MMM when under the influence of Boon or Offensive Spin, but it's a nonsensical hack edit: BG2FP worked around this by splitting the ApR bits of Boon/OS into a separate spells and blocking those spells when wielding MMM, which is wonky but functional.
My question is whether we can modify the opcode to behave more sensibly. In hindsight the key value would have been laid out linearly so that 1 = 0.5apr, 2 = 1apr, 3 = 1.5apr ... 10+ = 5apr and spells that added a full attack per round would just go key+2. It'd be trivial to adjust any BG/BG2 spells to use the new convention, however, this would break all sorts of mod stuff.
At the least would it be possible to prevent the key value from crossing over from 5 to 6?
#1 (0x001) Stat: Attacks Per Round Modifier [1]
Parameter #1: Key Modifier
Parameter #2: Type
Description:
Alters a characters Attacks per Round, by changing the Key by the modifier value specified by the 'Key Value' field, in the style specified by 'Type' field.
Key Attacks Per RoundKnown values for 'Type' are:
0 0
1 1
2 2
3 3
4 4
5 5
6 0.5
7 1.5
8 2.5
9 3.5
10 4.5
0 Cumulative Modifier -> Key = Key + 'Key Modifier' value
1 Flat Value Modifier -> Key = 'Key Modifier' value
2 Percentage Modifier -> Key = (Key * 'Key Modifier' value) / 100
3 Cumulative Modifier -> Same as 0
NB. When this opcode is stacked, the values of the Key Modifier are stacked, not the number of attacks.
The problem comes with effects stacking. Since it's the key value that's being added, a bunch of effects can push the value from 5 to 6 resulting in a drop from 5 attacks per round to 1/2 attack--exactly what happens with Melf's Minute Meteors gets crossed with Boon of Lathander. Melf's sets attacks to five (sets key=5) and then Boon gives a bonus of one attack per round (key+1), resulting in a Boon'd, MMM-wielding cleric-mage to throw a meteor every other round (key=6). We worked around this in BG2FP by disallowing casting MMM when under the influence of Boon or Offensive Spin, but it's a nonsensical hack edit: BG2FP worked around this by splitting the ApR bits of Boon/OS into a separate spells and blocking those spells when wielding MMM, which is wonky but functional.
My question is whether we can modify the opcode to behave more sensibly. In hindsight the key value would have been laid out linearly so that 1 = 0.5apr, 2 = 1apr, 3 = 1.5apr ... 10+ = 5apr and spells that added a full attack per round would just go key+2. It'd be trivial to adjust any BG/BG2 spells to use the new convention, however, this would break all sorts of mod stuff.
At the least would it be possible to prevent the key value from crossing over from 5 to 6?
Post edited by Bhryaen on
7
Comments
Additionally, items which subtract Attacks per Round have no effect.
When this opcode is stacked, the values of the Key Modifier are stacked, not the number of attacks.
And the key modifiers are :
Key Attacks Per Round
0 0
1 1
2 2
3 3
4 4
5 5
6 0.5
7 1.5
8 2.5
9 3.5
10 4.5
So, if a pj with 1 attack/round gain 1 attack/round, no matter, it will have 2 attacks/round
But if the same pj with 1 attack/round gain 1/2 attack/round, in fact in game he will have 7 attacks/round
Can you fix this please ?
When you try to set Attacks per Round with a Fighter to just 1 (say for example you have created an item that's uber good, but limits attacks to one per round) via an item, the Attacks per Round bonus via Level will factor in after the items.
So if you have a Level 7 Warrior that is wearing an item that sets Attacks per Round to 1, the Warrior will act 1.5 Attacks per Round with that item.
So the question is: how do we override the Attacks per Round via Level bonus with Fighters?
Level 7 Warrior
Item sets Attacks per Round to 1.
Actual Attacks per Round is 1½.
Perhaps we need additional item modifier flags that determine if it's before or after level modifications.
"(say for example you have created an item that's uber good, but limits attacks to one per round)"
As it stands I attack at the same speed (or maybe a bit faster) with boon on.
Have you already applied these fixes on your local build or are you on 0709?
I was able to replicate this in 0709, though I imported melfmet.itm (not in 0709) and scrla5.itm (MMM scroll) from a patched (but not Fixpacked) ToB install. Created a cleric of Lathander, dualed to mage, cast MMM (5 ApR) followed by Boon (0.5 ApR). The same happens if you first cast Boon (2 ApR) followed my MMM (0.5 ApR). These will be noted on the character record and you can verify them in game.
Thanks @deratiseur for the chart. :-)
The fixes from here don't actually fix the Attacks per round bonuses bug you describe here right? It just fixes the Boon of Lathander and MMM problem?
Apparently, the bug is with the Opcode behaviour itself so you need to test it with something else than MMM and Boon of Lathander.
If we are, ideally the key table would be laid out as
0 0
1 0.5
2 1
3 1.5
4 2
5 2.5
6 3
7 3.5
8 4
9 4.5
10+ 5
So an item that grants bonus ApR would need to increase the key by two instead of one, but that's something I can code fairly easily--just give me a heads up that it'll happen. We'll also have to add something in the BGEE modder's notes that the behavior has changed.
I'm just very curious
-Trent
Small problems being that all the items/effect need to be redone and characters now have a default number of attacks of 1/2. Not sure where to change that.