WWMGBP4LNJTFRB3CCVBGFRNZXCBG74A7LCAKUQEXZ52QGR7Q3ZLQC
if (UnitState != none && TargetState != none)
{
foreach UnitState.AffectedByEffects(EffectRef)
{
EffectState = XComGameState_Effect(History.GetGameStateForObjectID(EffectRef.ObjectID));
if (EffectState != none)
{
if (EffectState.GetX2Effect().ChangeHitResultForAttacker(UnitState, TargetState, kAbility, Result, ChangeResult))
{
`log("Effect" @ EffectState.GetX2Effect().FriendlyName @ "changing hit result for attacker:" @ ChangeResult,true,'XCom_HitRolls');
Result = ChangeResult;
// Issue #426: ChangeHitResultForX() code block moved to later in method.
/// HL-Docs: ref:Bugfixes; issue:426
/// Fix `X2AbilityToHitCalc_StandardAim` discarding unfavorable (for XCOM) changes to hit results from effects
// Due to how GetModifiedHitChanceForCurrentDifficulty() is implemented, it reverts attempts to change
// XCom Hits to Misses, or enemy misses to hits.
// The LW2 graze band issues are related to this phenomenon, since the graze band has the effect
// of changing some what "should" be enemy misses to hits (specifically graze result)
//ADDED THIS LINE!!!
if (default.ShowChances && default.ShowDiceRolls) PINotify.AddItem(UnitState.GetFullName()@"used an effect to change hit result to"@ ChangeResult);
}
}
}
foreach TargetState.AffectedByEffects(EffectRef)
{
EffectState = XComGameState_Effect(History.GetGameStateForObjectID(EffectRef.ObjectID));
if (EffectState != none)
{
if (EffectState.GetX2Effect().ChangeHitResultForTarget(EffectState, UnitState, TargetState, kAbility, bIsPrimaryTarget, Result, ChangeResult))
{
`log("Effect" @ EffectState.GetX2Effect().FriendlyName @ "changing hit result for target:" @ ChangeResult, true, 'XCom_HitRolls');
Result = ChangeResult;
//ADDED THIS LINE!!!
if (default.ShowChances && default.ShowDiceRolls) PINotify.AddItem(TargetState.GetFullName()@"has an effect that changes hit result to"@ ChangeResult);
}
}
}
}
// Start Issue #426: Block moved from earlier. Only code change is for lightning reflexes,
// because bRolledResultIsAMiss was used for both aim assist and reflexes
if (UnitState != none && TargetState != none)
{
foreach UnitState.AffectedByEffects(EffectRef)
{
EffectState = XComGameState_Effect(History.GetGameStateForObjectID(EffectRef.ObjectID));
if (EffectState != none)
{
if (EffectState.GetX2Effect().ChangeHitResultForAttacker(UnitState, TargetState, kAbility, Result, ChangeResult))
{
`log("Effect" @ EffectState.GetX2Effect().FriendlyName @ "changing hit result for attacker:" @ ChangeResult,true,'XCom_HitRolls');
Result = ChangeResult;
//ADDED THIS LINE!!!
if (default.ShowChances && default.ShowDiceRolls) PINotify.AddItem(UnitState.GetFullName()@"used an effect to change hit result to"@ ChangeResult);
}
}
}
foreach TargetState.AffectedByEffects(EffectRef)
{
EffectState = XComGameState_Effect(History.GetGameStateForObjectID(EffectRef.ObjectID));
if (EffectState != none)
{
if (EffectState.GetX2Effect().ChangeHitResultForTarget(EffectState, UnitState, TargetState, kAbility, bIsPrimaryTarget, Result, ChangeResult))
{
`log("Effect" @ EffectState.GetX2Effect().FriendlyName @ "changing hit result for target:" @ ChangeResult, true, 'XCom_HitRolls');
Result = ChangeResult;
/// HL-Docs: feature:GetHitChanceEvents; issue:1031; tags:tactical
/// WARNING! Triggering events in `X2AbilityToHitCalc::GetHitChance()` and other functions called by this function
/// may freeze (hard hang) the game under certain circumstances.
///
/// In our experiments, the game would hang when the player used a moving melee ability when an event was triggered
/// in `UITacticalHUD_AbilityContainer::ConfirmAbility()` right above the
/// `XComPresentationLayer(Owner.Owner).PopTargetingStates();` line or anywhere further down the script trace,
/// while another event was also triggered in `GetHitChance()` or anywhere further down the script trace.
///
/// The game hangs while executing UI code, but it is the event in the To Hit Calculation logic that induces it.
/// The speculation is that triggering events in `GetHitChance()` somehow corrupts the event manager, or it
/// could be a threading issue.
// Issue #237 start, let upgrades modify the crit chance of the breakdown
WeaponUpgrades = SourceWeapon.GetMyWeaponUpgradeTemplates();
for (i = 0; i < WeaponUpgrades.Length; ++i)
{
// Make sure we check to only use anything from the ini that we've specified doesn't use an Effect to modify crit chance
// Everything that does use an Effect, e.g. base game Laser Sights, get added in about 23 lines down from here
if (WeaponUpgrades[i].AddCritChanceModifierFn != None && default.CritUpgradesThatDontUseEffects.Find(WeaponUpgrades[i].DataName) != INDEX_NONE)
{
if (WeaponUpgrades[i].AddCritChanceModifierFn(WeaponUpgrades[i], iWeaponMod))
{
AddModifier(iWeaponMod, WeaponUpgrades[i].GetItemFriendlyName(), m_ShotBreakdown, eHit_Crit, bDebugLog);
}
}
}
// Issue #237 end