PostInventoryLoadoutApplied

Tracking Issue: #800

Tags: events

The PostInventoryLoadoutApplied event allows mods to make arbitrary changes to a Unit after they have been equipped with a Loadout by XComGameState_Unit::ApplyInventoryLoadout().

Normally this is done only once, shortly after the unit was created, but the ApplyInventoryLoadout() may call itself to also equip the Required Loadout on the unit. This means that if listeners intend to call UnitState.ApplyInventoryLoadout() themselves to equip a replacement loadout, they should use UnitState.HasLoadout() to check if the replacement loadout was already equipped by previously triggered listener.

Note that the LoadoutName and LoadoutItems components of the Tuple will be empty if ApplyInventoryLoadout() fails to find the loadout it was looking for.

PostInventoryLoadoutApplied event

Param Value
EventID PostInventoryLoadoutApplied
EventData XComLWTuple
EventSource XComGameState_Unit
NewGameState yes

Tuple contents

Index Name Type Direction
0 LoadoutName name in
1 LoadoutItems array<name> in

Listener template

static function EventListenerReturn OnPostInventoryLoadoutApplied(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
{
    local XComGameState_Unit UnitState;
    local XComLWTuple Tuple;
    local name LoadoutName;
    local array<name> LoadoutItems;

    UnitState = XComGameState_Unit(EventSource);
    Tuple = XComLWTuple(EventData);

    LoadoutName = Tuple.Data[0].n;
    LoadoutItems = Tuple.Data[1].an;

    // Your code here

    return ELR_NoInterrupt;
}

Refer to this feature for an event that triggers every time the unit is equipped with best available infinite weapons and armor.

PostSquaddieLoadoutApplied

The PostSquaddieLoadoutApplied event allows mods to make arbitrary changes to a Unit after they have been equipped with a Squaddie Loadout by XComGameState_Unit::ApplySquaddieLoadout().

Normally this function is called only when the unit is ranked up from a rookie to squaddie.

Note that the LoadoutName and LoadoutItems components of the Tuple will be empty if ApplySquaddieLoadout() fails to find the loadout it was looking for.

PostSquaddieLoadoutApplied event

Param Value
EventID PostSquaddieLoadoutApplied
EventData XComLWTuple
EventSource XComGameState_Unit
NewGameState yes

Tuple contents

Index Name Type Direction
0 LoadoutName name in
1 LoadoutItems array<name> in

Listener template

static function EventListenerReturn OnPostSquaddieLoadoutApplied(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
{
    local XComGameState_Unit UnitState;
    local XComLWTuple Tuple;
    local name LoadoutName;
    local array<name> LoadoutItems;

    UnitState = XComGameState_Unit(EventSource);
    Tuple = XComLWTuple(EventData);

    LoadoutName = Tuple.Data[0].n;
    LoadoutItems = Tuple.Data[1].an;

    // Your code here

    return ELR_NoInterrupt;
}

Source code references