Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add checks in X2Action_ApplyWeaponDamageToUnit to prevent Damage/Crit…
Browse files Browse the repository at this point in the history
… voicelines playing when unit is killed. Added a delay to the SquadMemberDead voiceline in XGUnit so it doesn't overlap the death voicelines & other visualization.
BlackDog86 committed Dec 7, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
phi-gamma Philipp Gesang
1 parent 12e1fb5 commit a930944
Showing 2 changed files with 52 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -662,16 +662,22 @@ simulated state Executing
{
Unit.UnitSpeak('ArmorHit');
}
else if(m_iShielded > 0 || m_iDamage > 0)
{
// Start Issue #1398 - Don't play 'Taking Damage' voiceline if unit was killed or incapacitated
else if((m_iShielded > 0 || m_iDamage > 0) && !bGoingToDeathOrKnockback)
{
Unit.UnitSpeak('TakingDamage');
}
// End Issue #1398
}

simulated function ShowCritMessage(EWidgetColor SuccessfulAttackColor, EWidgetColor UnsuccessfulAttackColor)
{
Unit.UnitSpeak('CriticallyWounded');

// Start Issue #1398 - Don't play 'Critically Wounded' voiceline if unit was killed or incapacitated
If(!bGoingToDeathOrKnockback)
{
Unit.UnitSpeak('CriticallyWounded');
}
// End Issue #1398
if( m_iShredded > 0 )
{
ShowShreddedMessage(SuccessfulAttackColor);
@@ -713,10 +719,12 @@ simulated state Executing
{
Unit.UnitSpeak('ArmorHit');
}
else if(m_iShielded > 0 || m_iDamage > 0)
// Start Issue #1398 - Don't play 'Taking Damage' voiceline if unit was killed or incapacitated
else if((m_iShielded > 0 || m_iDamage > 0) && !bGoingToDeathOrKnockback)
{
Unit.UnitSpeak('TakingDamage');
}
// End Issue #1398
}

simulated function ShowHPDamageMessage(string UIMessage, optional string CritMessage, optional EWidgetColor DisplayColor = eColor_Bad)
45 changes: 39 additions & 6 deletions X2WOTCCommunityHighlander/Src/XComGame/Classes/XGUnit.uc
Original file line number Diff line number Diff line change
@@ -1380,7 +1380,6 @@ function UnitSpeak(Name nCharSpeech, bool bDeadUnitSound = false)
if ((!bDeadUnitSound && !IsAliveAndWell()) || m_kPawn == none)
return;


GameStateUnit = GetVisualizedGameState();
if (GameStateUnit.IsPanicked())
{
@@ -1442,7 +1441,6 @@ function UnitSpeak(Name nCharSpeech, bool bDeadUnitSound = false)
return;
}


// mark that we played this voice
if (nCharSpeech != 'TakingDamage' && nCharSpeech != 'TargetKilled' && nCharSpeech != 'TakingFire' && nCharSpeech != 'HiddenMovement' && nCharSpeech != 'HiddenMovementVox')
{
@@ -1815,10 +1813,17 @@ simulated function XGInventory GetInventory()

function OnDeath( class<DamageType> DamageType, XGUnit kDamageDealer )
{
// Start Issue #1398
/// HL-Docs: ref:Bugfixes; issue:1398
/// This fix adds additional checks to X2Action_ApplyWeaponDamageToUnit, to prevent 'Taking Damage' or
/// 'Critically Wounded' voicelines from playing alongside the 'Death scream' voiceline if a unit is killed.
/// Additionally, it adds a dynamic delay to the 'Squad Member Dead' voiceline which waits for the visualizer to
/// finish before playing it to prevent it overlapping with active unit death sounds.

local int i;
local XGUnit SurvivingUnit;
// local XGUnit SurvivingUnit;
local XGPlayer PlayerToNotify;
local bool kIsRobotic;
// local bool kIsRobotic;

UnitSpeak('DeathScream', true);

@@ -1857,12 +1862,40 @@ function OnDeath( class<DamageType> DamageType, XGUnit kDamageDealer )

//RAM - Constant Combat

SurvivingUnit = GetSquad().GetNextGoodMember();
kIsRobotic = IsRobotic();
// SurvivingUnit = GetSquad().GetNextGoodMember();
// kIsRobotic = IsRobotic();

// if (SurvivingUnit != none && !kIsRobotic && !IsAlien_CheckByCharType())
// SurvivingUnit.UnitSpeak( 'SquadMemberDead' );

// Issue #1398 - New function which adds a dynamic delay to the squad member death voiceline
WaitForVisualizerIdleThenPlaySquadMemberDead();
}

function WaitForVisualizerIdleThenPlaySquadMemberDead()
{
if( !class'XComGameStateVisualizationMgr'.static.VisualizerIdleAndUpToDateWithHistory() )
{
SetTimer(0.25f, false, 'WaitForVisualizerIdleThenPlaySquadMemberDead', self);
return;
}
SetTimer(1.0f, false, 'DelaySpeechSquadMemberDead', self);
}

function DelaySpeechSquadMemberDead()
{
local XGUnit SurvivingUnit;
local bool kIsRobotic;

kIsRobotic = IsRobotic();
SurvivingUnit = GetSquad().GetNextGoodMember();

if (SurvivingUnit != none && !kIsRobotic && !IsAlien_CheckByCharType())
{
SurvivingUnit.UnitSpeak( 'SquadMemberDead' );
}
}
// End Issue #1398

//-------------------------------------------------------------------------------------
//---------------------------------- DEBUGGING ----------------------------------------

0 comments on commit a930944

Please sign in to comment.