Skip to content

Commit c34949b

Browse files
authored
Trigger an Event in XComUnitPawn.PlayHitEffects #825 (#826)
1 parent 55fb1fe commit c34949b

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

X2WOTCCommunityHighlander/Src/XComGame/Classes/XComUnitPawn.uc

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,67 @@ simulated function DamageTypeHitEffectContainer GetDamageTypeHitEffectContainer(
377377
return DamageEffectContainer;
378378
}
379379

380+
/// HL-Docs: feature:OverrideHitEffects; issue:825; tags:tactical
381+
/// Allows listeners to override the default behavior of XComUnitPawn.PlayHitEffects
382+
/// This is especially useful for preventing the hardcoded templar fx for
383+
/// eHit_Parry, eHit_Reflect and eHit_Deflect which play for any abilities that utilizing these hit results.
384+
/// If OverrideHitEffect is set to true the PlayHitEffects function will return early and the default behavior is ommited.
385+
///
386+
/// ```unrealscript
387+
/// EventID: OverrideHitEffects
388+
/// EventData: XComLWTuple {
389+
/// Data: [
390+
/// out bool OverrideHitEffect,
391+
/// inout float Damage,
392+
/// inout Actor InstigatedBy,
393+
/// inout vector HitLocation,
394+
/// inout name DamageTypeName,
395+
/// inout vector Momentum,
396+
/// inout bool bIsUnitRuptured,
397+
/// inout EAbilityHitResult HitResult,
398+
/// ]
399+
/// }
400+
/// EventSource: self (XComUnitPawn)
401+
/// NewGameState: no
402+
/// ```
403+
simulated private function bool TriggerOnOverrideHitEffects(
404+
float Damage,
405+
Actor InstigatedBy,
406+
vector HitLocation,
407+
name DamageTypeName,
408+
vector Momentum,
409+
bool bIsUnitRuptured,
410+
EAbilityHitResult HitResult
411+
)
412+
{
413+
local XComLWTuple Tuple;
414+
415+
Tuple = new class'XComLWTuple';
416+
Tuple.Id = 'OverrideHitEffects';
417+
Tuple.Data.Add(8);
418+
Tuple.Data[0].kind = XComLWTVBool;
419+
Tuple.Data[0].b = false; // Override default hit effects
420+
Tuple.Data[1].kind = XComLWTVFloat;
421+
Tuple.Data[1].f = Damage;
422+
Tuple.Data[2].kind = XComLWTVObject;
423+
Tuple.Data[2].o = InstigatedBy;
424+
Tuple.Data[3].kind = XComLWTVVector;
425+
Tuple.Data[3].v = HitLocation;
426+
Tuple.Data[4].kind = XComLWTVName;
427+
Tuple.Data[4].n = DamageTypeName;
428+
Tuple.Data[5].kind = XComLWTVVector;
429+
Tuple.Data[5].v = Momentum;
430+
Tuple.Data[6].kind = XComLWTVBool;
431+
Tuple.Data[6].b = bIsUnitRuptured;
432+
Tuple.Data[7].kind = XComLWTVInt;
433+
Tuple.Data[7].i = HitResult;
434+
435+
`XEVENTMGR.TriggerEvent('OverrideHitEffects', Tuple, self);
436+
437+
return Tuple.Data[0].b;
438+
}
439+
440+
380441
simulated function PlayHitEffects(float Damage, Actor InstigatedBy, vector HitLocation, name DamageTypeName, vector Momentum, bool bIsUnitRuptured, EAbilityHitResult HitResult= eHit_Success, optional TraceHitInfo ThisHitInfo )
381442
{
382443
local XComPawnHitEffect HitEffect;
@@ -386,6 +447,13 @@ simulated function PlayHitEffects(float Damage, Actor InstigatedBy, vector HitLo
386447
local DamageTypeHitEffectContainer DamageContainer;
387448
local XGUnit SourceUnit;
388449

450+
// Start Issue #825
451+
if (TriggerOnOverrideHitEffects(Damage, InstigatedBy, HitLocation, DamageTypeName, Momentum, bIsUnitRuptured, HitResult))
452+
{
453+
return;
454+
}
455+
// End Issue #825
456+
389457
// The HitNormal used to have noise applied, via "* 0.5 * VRand();", but S.Jameson requested
390458
// that it be removed, since he can add noise with finer control via the editor. mdomowicz 2015_07_06
391459
HitNormal = Normal(Momentum);

0 commit comments

Comments
 (0)