User:Praise/Increased Enchantment Duration Exploit
Under certain circumstances, some enchantments will have apparently infinite duration. The actual duration is 136.01 years, i.e. (2^32)-1 seconds.
Here I will explain what those circumstances and which enchantments those are.
Basic info
The exploit uses Air of Disenchantment (AoD) and Mark of Insecurity (MoI). The technique is often combined with Tranquility.
The order of the hexes does not matter. With Tranquility, you have to make sure to apply it first.
How do those skills actually work?
AoD takes the base enchantment duration and divides it by its value. Then, it rounds the value to whole seconds to the nearest integer with half to even.
MoI takes the base enchantment duration and multiplies it by its value's complement. Then, it rounds the value to whole seconds upwards, with a minimum reduction of 1 s.
Tranquility takes the base enchantment duration and multiplies it by its value's complement. Then, it rounds the value to whole seconds towards 1.
Analysis
I have collected a lot of observations while varying enchantment durations, Illusion Magic attribute levels, Deadly Arts attribute levels, Wilderness Survival attribute levels, and casting orders.
Given the behaviours of these 3 skills, there must be 3 more things at play for the exploit to exist and also to explain other non-exploit observations:
- Tranquility and AoD do their rounding in between the calculations
- When AoD & MoI are both active, AoD is calculated before MoI
- Enchantment duration numbers are stored in unsigned bytes
Knowing these behaviours, we can predict the most basic case of an enchantment duration going infinite:
- A 1 s enchantment is cast under AoD @5 Illusion Magic & MoI @0 Deadly Arts:
- AoD: 1 / 2.0 = 0.5 -> round to 0 s;
- MoI: 0 * (1-0.3) = 0 s again. But the result of MoI must be a minimum of 1 s reduction, so 0-1 = -1
Since the byte cannot be negative, it rolls over to its maximum value. Most probably, that maximum value is 2^32 subtract 1, if using a 32 bit register. In any case, the situation could be called an unsigned integer underflow.
Finally, we can see now that the role of Tranquility is to bring the duration down to 1 second, so that AoD+MoI can make it infinite.
Since Tranquility is maximum 60% @20 Wilderness Survival, the longest base duration that can be brought to 1 is 4 seconds:
4 x (1-0.6) = 1.6 -> rounds down to 1
5 x (1-0.6) = 2 -> already rounded.
[edit]
Further proof for point 1. in-between rounding, can also be seen for longer durations, for example:
7 seconds enchantment with AoD 190% and MoI 47%:
The expected duration without rounding is: (7 / 1.9) x (1-0.47) = 1.95 seconds.
The observed duration is 3 seconds:
7 / 1.9 = 3.68 -> AoD rounds to 4.
4 x (1-0.47) = 2.12 -> MoI rounds up: 3 seconds