Enhanced Perk Tree mod - XCOMEU: 2012

From Nexus Mods Wiki
Jump to: navigation, search
XCOM Soldier Perk Selection Screen

Overview

The purpose of this mod is to expand and enhance the selection of "perks" (otherwise referred to in-game as "Abilities").

Enhancements provided as of version 0.9 of this mod include:

  1. Up to 3 perks per level may be designated as options
  2. Each class can have it's own tree -- shape and size are configurable
  3. Perks can be placed in a tree more than once
    A perk cannot be selected more than once, but a soldier can be given a "second chance" to select a perk
  4. Both the 'regular' and 'psi' trees are configurable
    The 'psi' tree is still limited to 3 ranks
  5. Psionic rank names are now displayed

Game Version Compatibility

V 0.90 (initial release) - Patch 4 ( Changelist: 356266 )

Known Issues

  • When applying the mod and opening an existing save game, all soldiers will be marked as having perks available at ranks 1, 2, 4, and 5, and perks UNAVAILABLE at ranks 3, 6, and 7
  • In rare circumstances, a newly acquired rank will have no valid perk selections, and will not auto-mark the next rank upon selecting a previous rank's perks. Backing out to the main soldier menu and re-entering the 'Abilities' menu will clear the issue

Programs and Tools

The following tools were used in the creation of this mod:

  • UE Explorer
  • HxD Hex Editor
  • JPEXS Flash Decompiler

Details

This mod has a significant number of changes made to the game. These fall into the following categories:

  1. Changed the perk tree sprite define 21 ability icon locations in the perk tree
  2. Changed actionscript and upk code to support larger perk tree
  3. Changed the PerkInTree perk selection functions to be able to return more than 12 perk choices
  4. Changed the perk availability requirements
  5. Support for future enhancements

Perk Tree Sprite change

Manual decompilation of the hex code in Command1.upk's embedded SWF file containing promotion UI inteface code was performed. An additional 9 ability icons were added to the 'normalTree' sprite, bringing the total to 21 -- three at each rank.

Actionscript and UPK changes

Changes here involved the following:

  1. Allowing display of more than 2 ability icons per rank
  2. Displaying the 'normalTree' sprite instead of the 'psiTree' sprite
    1. Displaying class icon in upper left of 'psi' tree
    2. Hiding class rank icon in 'psi' tree
    3. Setting/displaying the class rank string in the 'psi' tree

GetPerkInTree changes

The GetPerkInTree functions return a perk choice (for each class) based upon the 'branch' and 'option' parameters.

  • branch is equivalent to soldier rank
  • option is the option at a particular rank

The existing functions used a series of nested if/else conditionals. For ranks 1 and 6 they ignored the 'option' parameter and always returned a particular perk, relying on the calling function to suppress calls for higher options at those ranks.

These functions were re-written to support up to four perk options per branch, and up to 11 branches.

  • Branches 8-11 are currently unused, and are reserved for future enhancements.
  • Option 4 at each branch is currently unused, and is reserved for future functionality.

Perk Availability Requirements

The existing code used perks already chosen to determine whether a rank was 'promotable' (that is, could a new ability be chosen at that rank). This created the implicit requirement that each perk be placed in the ability tree once. It also created conflicts with mods that provide additional equipment options (and require perks to be assigned to activate the equipment).

Instead of using pre-existing perks to determine 'promotability', this mod explicitly store bit flags (in the m_iEnergy class variable) to indicate which ranks have been promoted. By default all flags are set to 0, indicating that the rank can be promoted once the soldier rank is high enough. Upon selecting a perk, the appropriate bit flag is marked to 1, preventing future selection of a perk at that same rank.

Re-selecting a perk already selected is disallowed.

Future Proofing

Interest was expressed in making perk trees more dynamic. To support this capability in the future, only past and the current rank's perk choices are displayed. Future choices are left blank until the current perk choice is made. This allows future mods to tap into this to dynamically adjust the perk choices available at a given rank by simply altering the functionality of the GetPerkInTree functions.

The default GetPerkInTree functions are static, depending only upon the branch/option values. However, if they were to read other state information, such as existing perks chosen, and alter the perk returned based upon this information, a dynamic perk tree can be created.

File Changes

This mod requires a substantial number of hex changes (23 in total as of version 0.9). These fall into three broad categories:

  1. Changes made to the actionscript, applied to Command1.upk (11 changes)
    Actionscript File Changes
  2. Changes made to the unreal promotion interface code, applied to XcomStrategyGame.upk (7 changes)
    UPK Interface File Changes
  3. Changes made to the GetPerkInTree functions, applied to XcomGame.upk (5 changes)
    GetPerkInTree File Changes

The Category:Enhanced Perk Tree Mod - XCOM:EU 2012 (bottom of the window) will display all the related file articles.

Selecting Perks

Selecting perks is accomplished by altering the GetPerkInTree functions, in a manner similar to the default game. The location of the hex values changed is different with this mod, however. Additionally, returning a value of ZERO from the GetPerkInTree function will result in a BLANK location for the ability icon. This will be unselectable, and is how mod-user customization of the size and shape of a class's perk tree is accomplished.

As of version 0.9, a rank can have 0, 1, 2, or 3 perk choices available. If zero perk choices are available, the rank will be left empty of icons and it will be automatically marked as 'promoted'.

Complete information on how to alter the perk options is on its page: Choosing Assigned Perks

See also the general topic Abilities Modding - XCOM:EU 2012.

Localization Changes

No localization change are required for this mod.


References

Referred to by this article:

That refer to this article: