OverrideProjectileInstance

Tracking Issue: #829

Tags: events

Allows listeners to override the parameters of SpawnAndConfigureNewProjectile. The feature also introduces support for subclasses of X2UnifiedProjectile as custom projectile archetypes. If bPreventProjectileSpawning is set to true the projectile instance will NOT be spawned.

If your subclass of X2UnifiedProjectile overrides any of the functions that handle Particle System Components, it's important to preserve changes implemented by Issue #720: ProjectilePerformanceDrain

OverrideProjectileInstance event

Param Value
EventID OverrideProjectileInstance
EventData XComLWTuple
EventSource XComGameStateContext_Ability
NewGameState none

Tuple contents

Index Name Type Direction
0 bPreventProjectileSpawning bool out
1 ProjectileTemplate Actor inout
2 InVolleyNotify AnimNotify_FireWeaponVolley inout
3 InSourceWeapon XComWeapon inout
4 CurrentFireAction X2Action_Fire inout
5 Unit XGUnitNativeBase in

Listener template

static function EventListenerReturn OnOverrideProjectileInstance(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
{
    local XComGameStateContext_Ability AbilityContext;
    local XComLWTuple Tuple;
    local bool bPreventProjectileSpawning;
    local Actor ProjectileTemplate;
    local AnimNotify_FireWeaponVolley InVolleyNotify;
    local XComWeapon InSourceWeapon;
    local X2Action_Fire CurrentFireAction;
    local XGUnitNativeBase Unit;

    AbilityContext = XComGameStateContext_Ability(EventSource);
    Tuple = XComLWTuple(EventData);

    ProjectileTemplate = Actor(Tuple.Data[1].o);
    InVolleyNotify = AnimNotify_FireWeaponVolley(Tuple.Data[2].o);
    InSourceWeapon = XComWeapon(Tuple.Data[3].o);
    CurrentFireAction = X2Action_Fire(Tuple.Data[4].o);
    Unit = XGUnitNativeBase(Tuple.Data[5].o);

    // Your code here

    Tuple.Data[0].b = bPreventProjectileSpawning;
    Tuple.Data[1].o = ProjectileTemplate;
    Tuple.Data[2].o = InVolleyNotify;
    Tuple.Data[3].o = InSourceWeapon;
    Tuple.Data[4].o = CurrentFireAction;

    return ELR_NoInterrupt;
}

Source code references