Skip to content

Bug in effect opcodes 111 and 122 when using timing mode 0

argent77argent77 Member Posts: 3,444
edited November 2014 in IWD:EE Bugs (v1.4.0)
This issue is very similar to one I've posted in the BG2:EE Bugs section some time ago.

When using opcode 111 (Create magical weapon) or 122 (Create inventory item) with timing mode 0, the duration of the created items is much shorter than specified.

I've looked into it a bit further and it appears as if the game is treating the lifespan of the created items as ticks (1/15th seconds) instead of full seconds. So if you're creating an item with a duration of 300 seconds, it actually lasts only 20 seconds. Since the duration is stored in a field of only two bytes size, the max. possible duration is limited to 65535 ticks = 4369 seconds.

Edit: It's even worse for opcode 122. It looks like the duration is internally multiplied by 15 to get the number of ticks, which is then truncated to a 16-bit value and divided by 15 before it is finally stored. This limits the max. possible duration to less than 4370 ticks or 291 seconds (because 4370*15 = 65550 which is greater than 65535).

Effect opcode 111 is used in the various shapeshifting spells for the druids to create their creature-specific weapons. The duration of the weapons is specified as 3600000 seconds, which causes an overflow and is actually stored as 61056 ticks (3600000 modulo 65536 = 61056) and results in a duration of 4070 seconds.

Effect opcode 122 is used in the level 6 druid spell "Fire Seeds", which effectively reduces the duration of the created seeds from 1 turn per level to 4 seconds per level.
Post edited by argent77 on
Sign In or Register to comment.