XCOM Squadsight Aim Penalty Mod
This article will provide all of the information used to develop the mod to apply Aim penalties to XCOM units using the Squadsight ability
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.
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.
- 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.
- To apply a penalty only for not having enough XCOM units "spotting", change the "1.1" to "0.0"
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.
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.
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.
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.
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.
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"
Referred to by this article:
- Nexus forum post relating to this mod. Feedback and comments are welcome!
That refer to this article:
- All above XCOM_Squadsight_Aim_Penalty pages.