Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'OverrideMetaHitEffect' event #1117

Merged
merged 3 commits into from
Feb 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions X2WOTCCommunityHighlander/Src/XComGame/Classes/XComUnitPawn.uc
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,68 @@ simulated function PlayHitEffects(float Damage, Actor InstigatedBy, vector HitLo
}
}

/// HL-Docs: feature:OverrideMetaHitEffect; issue:1116; tags:tactical
/// Allows listeners to change the behavior of `XComUnitPawn::PlayMetaHitEffect()`.
/// Meta Hit Effects are intended to communicate the overall effect of the attack,
/// and include things like blood gushing out of the unit.
///
/// Listeners can set `OverrideMetaHitEffect` to `true`,
/// and then the default behavior will be omitted entirely,
/// and no meta hit effect will be played.
///
/// Alternatively, listeners can modify the parameters passed with the Tuple
/// to modify the default behavior.
///
/// ```event
/// EventID: OverrideMetaHitEffect,
/// EventData: [
/// inout bool OverrideMetaHitEffect,
/// inout vector HitLocation,
/// inout name DamageTypeName,
/// inout vector Momentum,
/// inout bool bIsUnitRuptured,
/// inout enum[EAbilityHitResult] HitResult,
/// ],
/// EventSource: XComUnitPawn (Pawn),
/// NewGameState: none
/// ```
simulated private function bool TriggerOnOverrideMetaHitEffect(
out vector HitLocation,
out name DamageTypeName,
out vector Momentum,
out int iUnitIsRuptured,
out EAbilityHitResult HitResult
)
{
local XComLWTuple Tuple;

Tuple = new class'XComLWTuple';
Tuple.Id = 'OverrideMetaHitEffect';
Tuple.Data.Add(6);
Tuple.Data[0].kind = XComLWTVBool;
Tuple.Data[0].b = false; // Override default hit effects
Tuple.Data[1].kind = XComLWTVVector;
Tuple.Data[1].v = HitLocation;
Tuple.Data[2].kind = XComLWTVName;
Tuple.Data[2].n = DamageTypeName;
Tuple.Data[3].kind = XComLWTVVector;
Tuple.Data[3].v = Momentum;
Tuple.Data[4].kind = XComLWTVBool;
Tuple.Data[4].b = iUnitIsRuptured != 0;
Tuple.Data[5].kind = XComLWTVInt;
Tuple.Data[5].i = HitResult;

`XEVENTMGR.TriggerEvent('OverrideMetaHitEffect', Tuple, self);

HitLocation = Tuple.Data[1].v;
DamageTypeName = Tuple.Data[2].n;
Momentum = Tuple.Data[3].v;
iUnitIsRuptured = Tuple.Data[4].b ? 1 : 0;
HitResult = EAbilityHitResult(Tuple.Data[5].i);

return Tuple.Data[0].b;
}

// The Meta Hit Effect is played once per shot (and NOT for every individual projectile), and
// is useful for showing an "overall" effect of the shot. mdomowicz 2015_04_30
simulated function PlayMetaHitEffect(vector HitLocation, name DamageTypeName, vector Momentum, bool bIsUnitRuptured, EAbilityHitResult HitResult= eHit_Success, optional TraceHitInfo ThisHitInfo )
Expand All @@ -519,6 +581,16 @@ simulated function PlayMetaHitEffect(vector HitLocation, name DamageTypeName, ve
local vector HitNormal;
local DamageTypeHitEffectContainer DamageContainer;
local XComPerkContentShared kPerkContent;
local int iUnitIsRuptured; // Variable for Issue #1116

// Start Issue #1116
iUnitIsRuptured = bIsUnitRuptured ? 1 : 0;
if (TriggerOnOverrideMetaHitEffect(HitLocation, DamageTypeName, Momentum, iUnitIsRuptured, HitResult))
{
return;
}
bIsUnitRuptured = iUnitIsRuptured > 0;
// End Issue #1116

// The HitNormal used to have noise applied, via "* 0.5 * VRand();", but S.Jameson requested
// that it be removed, since he can add noise with finer control via the editor. mdomowicz 2015_07_06
Expand Down