I've been curious about this subject too - and especially if there's any trick to dealing with the always-annoying scenario of fighting a lone enemy thief who isn't intimidated enough by your party to retreat, but is impressed enough to not initiate an attack and just stands in stealth forever.
Pulled & sorted the text Boaster mentioned from the LOMSE disc thief.gs - it looks like this:
/scrolling_get_percent_thief_eq and all the rest take this same format with variations in the constants used to calculate v1 and v2. The constants are higher for when the detecting unit is a thief and higher still for when the thief has activated the detect thief skill.
I'm still pretty awful at interpreting the weird formatting of GS code, but what these appear to be doing are calculating a specific percentage to produce the variable called "percent". This variable is equal to the product of two factors, "v1" and "v2", rounded down to an integer. Since the constants are higher for thieves and when using the detection skill, the implication here is that percent represents the chance for a unit to successfully spot a thief - i.e. higher percent = worse stealth.
In the example above, v1 is equal to "level" multiplied by 50, divided by "stealth_ratio." v2 is equal to... 3 divided by the sum of "range" and 2? Not entirely sure of the order of operations here.
This scripting doesn't really establish how to determine the values of level, stealth_ratio, or range.
A greater level results in a much greater v1, so would infer that this is the level of the unit detecting the thief.
A greater stealth_ratio significantly reduces v1, so it doesn't make sense for this to be the thief's stealth noise factor alone since generally a lower stealth noise factor means better stealth. The stealth_ratio variable doesn't appear anywhere outside of thief.gs. Maybe this is a ratio of the detecting unit's noise factor to the thief's noise factor? So e.g. footmen (noise factor 10) detecting a faerie thief (noise factor 2) would result in a stealth_ratio of 5 - this at least follows logically as the thief having a lower factor than the detector creates a higher stealth_ratio and thus lower v1, while a thief having a greater factor relative to the detector's leads to a lower stealth_ratio and higher v1. But ultimately this is pure speculation unless the almighty Boaster has any extra insight
. I do wonder what this implies for what happens when a thief gets their noise factor to 0 via items.
I
think a greater range decreases v2, in which case the logical inference is that it represents the distance between the detecting unit and the stealthed thief in tiles.
So hypothetically say on the world map a party consisting of a single faerie thief with a stealth factor of 2 is trying to sneak past a party consisting of a single unit of level 4 footmen at a range of 3 tiles. If the assumptions above are correct, v1 = (4 * 50)/(10/2) = 200/5 = 40, and v2 = 3 /(3 + 2) = 0.6. Thus percent = 40 * 0.6 = 24. Presumably this suggests a 24% chance that the footmen detect the faerie on the attempt?
Boaster also referenced the "setarmystealthticksproc" data, which looks like this:
Once again my cluelessness at interpreting the code strikes but my guess is what's happening is...
"lvl" starts off as... the level of the unit detecting? The starting point here is unclear to me. We subtract 1 from lvl, which takes us from the world of LOMSE unit levels (typically starting at 1 and ending at 12 for a lord) to array references (starting at 0 and ending at 11). Then we constrain lvl to be between 0 and 11, which would handle level 0 animals and level 15 legendary creatures that could otherwise fall outside the range.
Finally, we pull a value from that array of numbers based on lvl - so for instance lvl 0 produces 150 and lvl 11 produces 40.
As to what the selected value represents... higher levels produce a lower value, so perhaps this is ticks between stealth checks? Implies a higher level unit can detect thieves in combat more rapidly than a lower level unit, in addition to having a higher chance at successful detection.EDIT For posterity - clarified by Boaster below and tested in-game, the setarmystealthticksproc function above determines the cooldown on which a thief can re-enter stealth after attacking something in combat. Higher level thieves can reenter stealth sooner. Based on the numbers above, a level 12 thief can re-stealth over 3 times faster than a level 1 thief (40 ticks vs 150 ticks).That said, all of the above is half-assed speculation based purely on this section of the script so please take with a ginormous grain of salt.