Talk:Trapping (category)

From Tales of Maj'Eyal
Jump to: navigation, search

Chance to unlock when disarming

Someone asked what the chance was of unlocking a new trap when disarming a trap. (In particular, the chance of unlocking the Poison Gas Trap when disarming a poison spore trap.) I read the relevant code, and it was quite complicated, so I wanted to document my findings here for posterity.

Here's how I think it works (not 100% sure, haven't tested it):

1) First, you have to successfully detect and then disarm the trap, e.g. by moving into its square or using the talent Disarm Trap, and then (either way) passing the check (a checkHitOld comparing your disarm power from Device Mastery to the trap's disarm power). checkHitOld is a logarithmic chance to hit, with a few parts to the formula. I haven't tried to figure that formula out yet.

2) Next, if you know Trap Mastery, and there is a trap that can be unlocked from disarming that trap, and you have not unlocked it yet, and you are within 1 range of the trap, then the game does another check to see if you should get the option to carefully dismantle the trap. This check is a checkHit with the attack being (your traps' detection power from Trap Mastery plus one-quarter of your disarm power from Device Mastery) and the defense being the trap's disarm power. checkHit is the normal formula that you might already know, used for accuracy vs. defense, or power vs. saves.
The game both checks that you pass the checkHit, and then it also requires that the chance of passing was at least 20%. This chance will be used again later on. It also requires you to pass the trap's unlock_talent_on_disarm.chance at this point, which is trap-specific. In the case of the poison spore trap teaching Poison Gas Trap, that chance is 25%. It also requires that you can't see any enemies.

3) If you pass all the requirements, then you get a message like this:
Disarming a trap:
As you begin disarming the trap, you think you may be able to learn how it works by carefully dismantling it. You estimate this will take up to X uninterrupted turns.
What do you want to do?
Your options are "Dismantle Carefully" or "Disarm Normally". If you press "Disarm Normally" it just stops (the trap stays disarmed). If you press "Dismantle Carefully", then you start dismantling the trap.

4) Dismantling the trap is like resting or digging, and it can be interrupted the same way. There's a max number of turns that you can spend trying to dismantle the trap. This is given by the formula math.ceil(diff_level*(1 + rng.float(1, 6*(1-chance/200)))), where diff_level is the Trap Mastery level required for the new trap being learnt (2 in the case of the Poison Gas Trap), and chance is the percentage checkHit chance from part (2).
e.g. If the chance was 90%, you would get from 4-9 turns at random. If the chance was 20%, you would get from 4-13 turns at random.

5) For the first diff_level turns, you don't make any progress. After that, you start making checks with a chance percentage to succeed. The number of successful checks is tracked, and if you get diff_level successes in a row, you successfully dismantle the trap and learn the new trap talent.
If you fail a check, the success count is reset to zero. You have a 10% chance to set off the trap at this point, which means you fail to dismantle it. Otherwise, you try again from zero successes.
This continues until you succeed, set off the trap, get interrupted, or run out of turns.
So for the poison spores trap, you would make no progress for 2 turns and then need to pass 2 rolls in a row.

Extra note: Moasseman said "iirc your detect/disarm power generally always eclipses the traps". If we assume that the checkHit chance is therefore 100%, then the overall chance of the process succeeding simplifies to the unlock_talent_on_disarm.chance (e.g. 25% in this case). --ScienceBall (talk) 01:08, 23 January 2023 (CET)