Events
Many of the Highlander's features utilize Event Hooks. Mods can subscribe to any event by name, and then
- Read some of the data passed with the event
- Perform actions in response to the event
- Send data back to the sender of the event
Especially the last option is something many Highlander hooks expect mods to do.
This is done with the XComLWTuple
class. It can contain arbitrary
tagged data, can be read and written to by mods. Consider it a polymorphic tuple that is
compatible with any event trigger/listener signature.
HL Event documentation
All Highlander-triggered events use a specification that looks like the following:
OverridePromotionUIClass event
Param | Value |
---|---|
EventID | OverridePromotionUIClass |
EventData | XComLWTuple |
EventSource | XComHQPresentationLayer |
NewGameState | none |
Tuple contents
Index | Name | Type | Direction |
---|---|---|---|
0 | PromotionScreenType | enum (CHLPromotionScreenType) | in |
1 | PromotionUIClass | class (class<UIArmory_Promotion>) | inout |
Listener template
static function EventListenerReturn OnOverridePromotionUIClass(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
{
local XComHQPresentationLayer Pres;
local XComLWTuple Tuple;
local CHLPromotionScreenType PromotionScreenType;
local class<UIArmory_Promotion> PromotionUIClass;
Pres = XComHQPresentationLayer(EventSource);
Tuple = XComLWTuple(EventData);
PromotionScreenType = CHLPromotionScreenType(Tuple.Data[0].i);
PromotionUIClass = class<UIArmory_Promotion>(Tuple.Data[1].o);
// Your code here
Tuple.Data[1].o = PromotionUIClass;
return ELR_NoInterrupt;
}
The "$event_name event" paragraph describes which values a listener receives. EventID
is the event name,
EventData
and EventSource
list the types of the objects passed along, and NewGameState
describes whether
there is a NewGameState
provided in the TriggerEvent
call.
If the EventData
is an XComLWTuple
, the "Tuple contents" paragraph lists the type and name of every variable passed using
the tuple, along with its direction:
- An
in
variable has a meaningful value when the event is triggered, and mods may read it, usually to inspect the default value the game has determined.- If a variable is not
in
, it may not be initialized when read from.
- If a variable is not
- An
out
variable will be read from by the game after all event listeners have been executed, usually with the expectation that a mod may have changed it to control some behaviors of the game.- If a variable is not
out
, assigning to it is a no-op.
- If a variable is not
- An
inout
variable has a meaningful default value and will be read from after the event listeners have been executed.
Note that exchanging data through an XComLWTuple
requires subscribing to the event with the ELD_Immediate
deferral.
The "Listener template" is a copy-pasteable function that you can copy into your own mod as a starting point for using the event.
Note: It is highly recommended that you use the CHEventListenerTemplate
to subscribe
to such events, as it is robust against history changes and allows you to provide the ELD_Immediate
deferral.
For this event, you would subscribe like this:
Template.RegisterInStrategy = true;
Template.AddCHEvent('OverridePromotionUIClass', OnOverridePromotionUIClass, ELD_Immediate, 50);
Event-relevant pages
The following is a list of all pages tagged "Events" due to their relevance to or use of the event system.
- #4 - CHEventListenerTemplate
- #93 - OverrideNumUpgradeSlots
- #106 - DynamicSoldierClassDisplay
- #110 - OnGetPCSImage
- #172 - OverrideHasHeavyWeapon
- #257 - OverrideUnitFocusUI
- #289 - ItemUpgraded
- #365 - Geoscape_ResInfoButtonVisible
- #365 - UIStrategyPolicy_ShowCovertActionsOnClose
- #368 - UIAvengerShortcuts_ShowCQResistanceOrders
- #391 - GetCovertActionEvents_Settings
- #393 - OverrideClipSize
- #400 - OverrideAbilityIconColor
- #408 - DynamicSoldierRankDisplay
- #420 - UpdateNavHelp
- #438 - CovertAction_PreventGiveRewards
- #448 - OverrideDisableReinforcementsFlare
- #490 - DrawDebugLabels
- #500 - OverrideEncounterZoneAnchorPoint
- #507 - OverridePatrolBehavior
- #534 - PsiProjectCompleted
- #561 - SitRepCheckAdditionalRequirements
- #562 - OnDistributeTacticalGameEndXp
- #562 - OverrideKillXp
- #562 - OverrideTotalNumKills
- #564 - AllowInteractHack
- #600 - OverridePromotionBlueprintTagPrefix
- #600 - OverridePromotionUIClass
- #624 - OverrideRespecSoldierProjectPoints
- #631 - OverrideShowPromoteIcon
- #633 - CanTechBeInspired
- #635 - OverrideMissionImage
- #650 - WillRecoveryTimeModifier
- #663 - UIResistanceReport_ShowCouncil
- #666 - ShouldCivilianRun
- #667 - OverrideNextRetaliationDisplay
- #676 - OnBestGearLoadoutApplied
- #694 - ItemAddedOrRemovedToSlot
- #711 - OverrideDarkEventCount
- #718 - OverridePatrolDestination
- #735 - OverrideHasAmmoPocket
- #735 - OverrideHasExtraUtilitySlot
- #735 - OverrideHasGrenadePocket
- #749 - OverrideAbilityIconColorImproved
- #752 - AllowOnCovertActionCompleteAnalytics
- #753 - PreDarkEventDeactivated
- #754 - XComLWTuple
- #774 - OverrideAllowStartingRegionLink
- #785 - PreCompleteStrategyFromTacticalTransfer
- #791 - AllowRulerOnMission
- #800 - PostInventoryLoadoutApplied
- #801 - FirstPromotionOverrideClass
- #807 - CovertAction_OverrideCostScalar
- #807 - CovertAction_OverrideRewardScalar
- #814 - ValidateGTSClassTraining
- #815 - OverrideEligibleTrainingCenterAbilities
- #825 - OverrideHitEffects
- #829 - OverrideProjectileInstance
- #837 - KismetGameStateMatinee
- #842 - OverrideHasInfiniteAmmo
- #844 - ShowItemInLockerList
- #864 - WorldRegionGetMeshScale
- #864 - WorldRegionGetStaticMesh
- #871 - HeadquartersUnitFired
- #875 - OverrideCanTakeFacilityMission
- #903 - OverrideDamageRemovesReserveActionPoints
- #921 - OverrideWeaponScale
- #932 - StrategyMap_NavHelpUpdated
- #986 - UIStrategyPolicy_MiscEvents
- #994 - AllowNoSquadSizeUpgradeAchievement
- #996 - OverrideReactionFireSlomo
- #1036 - OverrideEnemyFactionsAlertsOutsideVision
- #1094 - OverrideCanEquipImplant
- #1112 - GetLocalizedItemCategory
- #1116 - OverrideMetaHitEffect
- #1126 - OverrideInjuryClearingFatigueBehavior
- #1134 - OverrideStackedClassIcon
- #1150 - OverrideNegativeTraitRoll
- #1153 - FinalizePlayerStateForTacticalMusic
- #1218 - OverrideStrategyCostString
- #1303 - OverrideEligibleStartingRegion
- #1316 - PostUFOSetInterceptionTime
- #1354 - ShouldUnitPatrolUnderway