OverrideEligibleTrainingCenterAbilities
Tracking Issue: #815
Tags: events
The OverrideEligibleTrainingCenterAbilities
event allows mods to make arbitrary changes
to the list of eligible Training Center abilities generated for each unit.
Typical use case would be making specific abilities eligible or inelegible based on arbitrary conditions, like soldier class weapon restrictions. This event does not trigger for soldiers that do not have a "true" XCOM row, like Faction Heroes that use custom RandomAbilityDecks instead.
Since sending an SoldierClassAbilityType
struct with the tuple is impossible,
the event tuple contains three parallel arrays: with ability template names,
their inventory slots and their utility categories for abilities assigned
to utility items.
When modifying these arrays it is absolutely critical that the arrays remain parallel,
or you will end up breaking the list.
To prevent that, it's highly recommended you take advantage of two helper functions:
RebuildSoldierClassAbilityTypeArray
and SplitSoldierClassAbilityTypeArray
.
For example:
static function EventListenerReturn OnOverrideEligibleTrainingCenterAbilities(Object EventData, Object EventSource, XComGameState NewGameState, Name EventID, Object CallbackObject)
{
local XComGameState_Unit UnitState;
local XComLWTuple Tuple;
local array<name> AbilityNames;
local array<int> ApplyToWeaponSlots;
local array<name> UtilityCats;
local array<SoldierClassAbilityType> EligibleAbilities;
Tuple = XComLWTuple(EventData);
UnitState = XComGameState_Unit(EventSource);
// Rebuild the EligibleAbilities array from the Tuple.
AbilityNames = Tuple.Data[0].an;
ApplyToWeaponSlots = Tuple.Data[1].ai;
UtilityCats = Tuple.Data[2].an;
EligibleAbilities = class'CHHelpers'.static.RebuildSoldierClassAbilityTypeArray(AbilityNames, ApplyToWeaponSlots, UtilityCats);
// Your code here: modify EligibleAbilities as you please.
// Split the modified EligibleAbilities into parallel arrays and pass it back to the Tuple.
// This function will automaticaly wipe the contents of the 'out' arrays.
class'CHHelpers'.static.SplitSoldierClassAbilityTypeArray(EligibleAbilities, AbilityNames, ApplyToWeaponSlots, UtilityCats);
Tuple.Data[0].an = AbilityNames;
Tuple.Data[1].ai = ApplyToWeaponSlots;
Tuple.Data[2].an = UtilityCats;
return ELR_NoInterrupt;
}
OverrideEligibleTrainingCenterAbilities event
Param | Value |
---|---|
EventID | OverrideEligibleTrainingCenterAbilities |
EventData | XComLWTuple |
EventSource | XComGameState_Unit |
NewGameState | yes |
Tuple contents
Index | Name | Type | Direction |
---|---|---|---|
0 | AbilityNames | array<name> | inout |
1 | ApplyToWeaponSlots | array<int> | inout |
2 | UtilityCats | array<name> | inout |