XCOM Squadsight Aim Penalty Mod

From Nexus Mods Wiki
Jump to: navigation, search
XCOM Developer Shell Initial Screen

Overview

This article will provide all of the information used to develop the mod to apply Aim penalties to XCOM units using the Squadsight ability

Background

The structure of the game code, with the separation of the "native" C++ code (contained in the XcomGame.exe file) and the Unreal Engine code (contained in the *.upk files) influenced how this mod was created. The actual To-Hit calculations are in the native C++ code, and so are inaccessible with the UE Explorer tool.

Thus a workaround was created to apply and display the to-hit penalty.


Details about what the Mod does

The range penalty is based upon the following formula:

Penalty = Max(-25 + 5*Max(numXCOM, 5) - 1.1*(range - visualRange), 5)

The penalty is only applied if range is greater than visualRange.

More detailed information and example pictures can be found in the Details page.

Alternate Formulae

The default formula provides BOTH a penalty for long range and a penalty for not having enough XCOM units "spotting" the target.

Alternate formulations are possible.

  1. To apply a penalty only for long range, set the "5" before "Max" to "0"
    This will likely require changing the -25 constant aim penalty portion.
  2. To apply a penalty only for not having enough XCOM units "spotting", change the "1.1" to "0.0"

Formula Variations

File Changes

There were three categories of changes made. The first adjusts calculates the penalty and adjusts the to-hit roll. The second adjusts the detailed hit break down in the "Shot Info" window. The penalty calculation is duplicated here. The third and final category are several changes necessary in order to update the UI to display the correct to-hit probability to the user.

Roll For Hit Change

This change actually applies the to-hit penalty to the to-hit roll. The existing code applies 'adjustments' to the to-hit roll for the Easy and Normal difficulty modes. These adjustments are applied via the function AdjustToHit. This mod removes the Easy / Normal bonuses and penalties that the game applies and calculates and applies the aim penalty for shooting via Squadsight. Any changes made here to the to-hit roll are not automatically reflected in the to-hit number displayed through the UI.

Roll For Hit Hex Changes

Roll For Hit Development Notes

Shot Summary Change

The function GetShotSummary puts together all of the various bonus and penalty factors that apply to a hit roll. This function is called in preparation of displaying the large "Shot Summary" window. An example of this is shown at the top of the page.

Shot Summary Hex Changes

Shot Summary Development Notes

UI Changes

There are three separate changes that fall under this category

Shot Summary UI

The total to-hit chance displayed in the Shot Summary UI window is drawn directly from the game, rather than summing up the Shot Summary data structure bonuses and penalties. This change alters the function so that the updated to-hit total is read and displayed.

UI Shot Summary Hex Changes

UI Shot Summary Development Notes

Targeted Ability UI

The class XGAbility_Targeted has a function GetUIHitChance. This function is called to display the hit chance when the mouse is hovered over the small icons in the lower right of the screen. XGAbility_Targeted.GetUIHitChance was altered to retrieve the updated hit chance.

Targeted Ability UI Hex Changes

Targeted Ability UI Development Notes

Fire Action UI

The class XGAction_Fire also has a function named GetUIHitChance. This function is called to display the hit in the first small HUD info panel that appears when the "Fire" ability is activated. It also is used for the to-hit number displayed to the upper left of the reticle on the target. XGAction_Fire.GetUIHitChance was altered to retrieve the updated hit chance.

Fire Action UI Hex Changes

Fire Action UI Development Notes

Localization Changes

In order to display text in the Shot Summary window, the following line was changed in the XComGame.INT localization file:

m_strCheating="Squadsight Long Range"

References

Referred to by this article:

That refer to this article: