Skip to content

Add a hook to govern the application of effects in a similar manner to CanAbilityHitUnit #1575

@ReshiMael

Description

@ReshiMael

Goal: Provide widely applicable and easy to use tool to govern whether or not effects are allowed to be applied to a unit, providing a similar result to CanAbilityHitUnit, which directly governs what abilities are allowed to apply to a unit.

Something in the vein of: EffectShouldRedirect() as declared in X2Effect_Persistent.
Maybe something along the lines of adding the code as follows to ApplyEffect in X2Effect, and adding a function bool to X2Effect that enables this functionality:

simulated final function name X2Effect::ApplyEffect(/**/)
{
if (TargetStateObject != none)
{
if (TargetStateObject.IsImmuneToEffect(self, SourceStateObject, AbilityStateObject))
{
return 'AA_UnitIsImmune';
}
}
}

And in XGS_Unit
function bool IsImmuneToEffect(X2Effect Effect, XComGameState_Unit SourceUnit, XComGameState_Ability AbilityState)
{
local XComGameStateHistory History;
local XComGameState_Effect EffectState;

History = `XCOMHISTORY;

foreach AffectedByEffects(EffectRef)
{
    EffectState = XComGameState_Effect(History.GetGameStateForObjectID(EffectRef.ObjectID));
    if (EffectState.GetX2Effect().ProvidesImmunityToEffect(Effect, EffectState, SourceUnit, self, AbilityState))
    {
        return true;
    }
}

return false;

}

and in X2Effect_Persistent
function bool ProvidesImmunityToEffect(X2Effect Effect, XComGameState_Effect EffectState, XComGameState_Unit SourceUnit, XComGameState_Unit TargetUnit, XComGameState_Ability AbilityState) { return false; }

Thanks for the help with figuring out a better implementation for this, Merist o7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions