Make guaranteed crit abilities display as having 100% crit chance #1339
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1298
The Problem
There are two main components to
X2AbilityToHitCalc_StandardAim
, theGetHitChance()
which is used both for hit chance preview in UI and in the second component,InternalRollForAbilityHit()
, which does the actual hit roll.The
bHitsAreCrits
bool flag is not processed inGetHitChance()
at all, only in the roll function, where it will replaceeHit_Success
hit result witheHit_Crit
. So outside the ability description, the player has no way of knowing that the ability will crit.Here's how it looks in-game:
Proposed Fix
Give the
bHitsAreCrits
the same treatment asbGuaranteedHit
:GetHitChance()
,super.AddModifier()
is called to add 100 to crit chance using the super function fromX2AbilityToHitCalc
class.AddModifier()
function itself inX2AbilityToHitCalc_StandardAim
is adjusted to disallow adding crit modifiers if thebHitsAreCrits
flag is set.As the result, the ability will have one and only one crit chance modifier that equals to 100, and all other crit chance modifiers, such as from flanking, will be ignored. So in-game UI for
bHitsAreCrits
abilities will always display exactly 100%.Here's how it looks:
Addressing Concerns
This change does not alter handling of
bHitsAreCrits
inInternalRollForAbilityHit()
, so nothing changes functionality-wise. Custom ToHitCalcs that overrideGetHitChance()
orAddModifier()
, at worst, will display incorrect crit chance, which they would already be doing in regards tobHitsAreCrits
abilities.Extended Information
Extended Information mod seems to correctly process the changed logic: