Skip to content

Commit 078a70b

Browse files
authored
Merge pull request #923 from ReactiveDrop/alterdeathmessage
AlterDeathMessage hook vscript function
2 parents beb0d60 + 33e7fc9 commit 078a70b

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

src/game/server/swarm/asw_gamerules_vscript.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ class CASW_Challenge_Thinker : public CLogicalEntity
13241324
g_pScriptVM->SetValue( hScope, "OnMissionStart", SCRIPT_VARIANT_NULL );
13251325
g_pScriptVM->SetValue( hScope, "OnGameplayStart", SCRIPT_VARIANT_NULL );
13261326
g_pScriptVM->SetValue( hScope, "OnReceivedTextMessage", SCRIPT_VARIANT_NULL );
1327+
g_pScriptVM->SetValue( hScope, "AlterDeathMessage", SCRIPT_VARIANT_NULL );
13271328

13281329
s_Thinkers.AddToTail( this );
13291330
}

src/game/server/swarm/asw_marine.cpp

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4358,6 +4358,44 @@ void CASW_Marine::Event_Killed( const CTakeDamageInfo &info )
43584358
if ( ASWDeathmatchMode() )
43594359
ASWDeathmatchMode()->OnMarineKilled( info, this );
43604360

4361+
m_bSlowHeal = false; // no healing if we're dead!
4362+
4363+
PrintDeathMessage( info );
4364+
}
4365+
4366+
void CASW_Marine::PrintDeathMessage( const CTakeDamageInfo &info )
4367+
{
4368+
CASW_Marine_Resource *pMR = GetMarineResource();
4369+
4370+
// print a custom death message if we have one
4371+
CAlienSwarm *pAlienSwarm = ASWGameRules();
4372+
if ( pAlienSwarm )
4373+
{
4374+
ScriptVariant_t args[7];
4375+
ScriptVariant_t retvalue;
4376+
4377+
args[0] = ToHScript( this );
4378+
args[1] = ToHScript( info.GetInflictor() );
4379+
args[2] = ToHScript( info.GetAttacker() );
4380+
args[3] = ToHScript( info.GetWeapon() );
4381+
args[4] = info.GetDamage();
4382+
args[5] = info.GetDamageType();
4383+
args[6] = info.GetAmmoName();
4384+
4385+
pAlienSwarm->RunScriptFunctionInListenerScopes( "AlterDeathMessage", &retvalue, NELEMS( args ), args );
4386+
4387+
if ( retvalue.m_type == FIELD_CSTRING )
4388+
{
4389+
char szName[256];
4390+
pMR->GetDisplayName( szName, sizeof( szName ) );
4391+
4392+
UTIL_ClientPrintAll( ASW_HUD_PRINTTALKANDCONSOLE, retvalue.m_pszString, szName );
4393+
4394+
return;
4395+
}
4396+
}
4397+
4398+
CBaseEntity *pAttacker = info.GetAttacker();
43614399
// print a message if marine was killed by another marine
43624400
if ( pAttacker && pAttacker->Classify() == CLASS_ASW_MARINE )
43634401
{
@@ -4411,8 +4449,6 @@ void CASW_Marine::Event_Killed( const CTakeDamageInfo &info )
44114449
UTIL_ClientPrintAll( ASW_HUD_PRINTTALKANDCONSOLE, "#asw_chat_died", szName );
44124450
}
44134451
}
4414-
4415-
m_bSlowHeal = false; // no healing if we're dead!
44164452
}
44174453

44184454
void CASW_Marine::AimGun()

src/game/server/swarm/asw_marine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ class CASW_Marine : public CASW_VPhysics_NPC, public IASWPlayerAnimStateHelpers,
635635
float m_flLastBurnSoundTime;
636636
float m_fNextPainSoundTime;
637637
virtual void Event_Killed( const CTakeDamageInfo &info );
638+
void PrintDeathMessage( const CTakeDamageInfo &info );
638639
bool CanBecomeRagdoll();
639640
virtual bool BecomeRagdollOnClient( const Vector &force );
640641
void Suicide();

0 commit comments

Comments
 (0)