OverrideWeaponScale

Tracking Issue: #921

Tags: pawns, events

The OverrideWeaponScale event allows mods to rescale weapons for unit pawns.

This event is triggered from two places: 1) XComUnitPawn::EquipWeapon() is used by items in weapon slots, as well as for utility items that use the Display Multi Slot Items functionality. 2) XComUnitPawn::AttachItem() is used for utility items by default. In this case, the ItemState component of the Tuple will be none.

OverrideWeaponScale event

Param Value
EventID OverrideWeaponScale
EventData XComLWTuple
EventSource XComUnitPawn
NewGameState none

Tuple contents

Index Name Type Direction
0 bOverride bool out
1 fOverrideWeaponScale float inout
2 ItemState XComGameState_Item in

Listener template

static function EventListenerReturn OnOverrideWeaponScale(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
{
    local XComUnitPawn UnitPawn;
    local XComLWTuple Tuple;
    local bool bOverride;
    local float fOverrideWeaponScale;
    local XComGameState_Item ItemState;

    UnitPawn = XComUnitPawn(EventSource);
    Tuple = XComLWTuple(EventData);

    fOverrideWeaponScale = Tuple.Data[1].f;
    ItemState = XComGameState_Item(Tuple.Data[2].o);

    // Your code here

    Tuple.Data[0].b = bOverride;
    Tuple.Data[1].f = fOverrideWeaponScale;

    return ELR_NoInterrupt;
}

Source code references