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

[TF2] Custom kill icon support #974

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions src/game/client/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ void CHud::LevelInit( void )
group->bHidden = false;
group->m_pLockingElements.Purge();
}

RefreshHudTextures();
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -811,6 +813,14 @@ void CHud::RefreshHudTextures()

CUtlDict< CHudTexture *, int > textureList;

// loading custom kill icons, presumably packed into the map
LoadHudTextures( textureList, "scripts/map_textures", NULL );
int co = textureList.Count();
for ( int index = 0; index < co; index++ )
{
CHudTexture* tex = textureList[ index ];
AddSearchableHudIconToList( *tex );
}
// check to see if we have sprites for this res; if not, step down
LoadHudTextures( textureList, "scripts/hud_textures", NULL );
LoadHudTextures( textureList, "scripts/mod_textures", NULL );
Expand Down
3 changes: 3 additions & 0 deletions src/game/server/pointhurt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ BEGIN_DATADESC( CPointHurt )
DEFINE_KEYFIELD( m_flDelay, FIELD_FLOAT, "DamageDelay" ),
DEFINE_KEYFIELD( m_bitsDamageType, FIELD_INTEGER, "DamageType" ),
DEFINE_KEYFIELD( m_strTarget, FIELD_STRING, "DamageTarget" ),
#ifdef TF_DLL
DEFINE_KEYFIELD( m_szKillIcon, FIELD_STRING, "KillIcon" ),
#endif // TF_DLL

// Function Pointers
DEFINE_FUNCTION( HurtThink ),
Expand Down
3 changes: 3 additions & 0 deletions src/game/server/pointhurt.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ class CPointHurt : public CPointEntity
float m_flDelay;
string_t m_strTarget;
EHANDLE m_pActivator;
#ifdef TF_DLL
string_t m_szKillIcon;
#endif // TF_DLL
};
12 changes: 12 additions & 0 deletions src/game/server/tf/func_croc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ LINK_ENTITY_TO_CLASS( func_croc, CFuncCroc );

BEGIN_DATADESC( CFuncCroc )
DEFINE_KEYFIELD( m_iszModel, FIELD_STRING, "croc_model" ),
DEFINE_KEYFIELD( m_iszKillIcon, FIELD_STRING, "killicon" ),
// Outputs
DEFINE_OUTPUT( m_OnEat, "OnEat" ),
DEFINE_OUTPUT( m_OnEatRed, "OnEatRed" ),
Expand Down Expand Up @@ -103,6 +104,7 @@ void CEntityCroc::Think( void )
CFuncCroc::CFuncCroc()
{
m_iszModel = NULL_STRING;
m_iszKillIcon = NULL_STRING;
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -208,4 +210,14 @@ const char *CFuncCroc::GetCrocModel( void )
}

return CROC_MODEL;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const char *CFuncCroc::GetKillIcon( void )
{
if ( m_iszKillIcon != NULL_STRING )
return ( STRING( m_iszKillIcon ) );
return "crocodile";
}
2 changes: 2 additions & 0 deletions src/game/server/tf/func_croc.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ class CFuncCroc : public CBaseTrigger
void FireOutputs( CTFPlayer *pTFPlayer );

const char *GetCrocModel( void );
const char *GetKillIcon( void );

private:

string_t m_iszModel;
string_t m_iszKillIcon;

COutputEvent m_OnEat;
COutputEvent m_OnEatRed;
Expand Down
3 changes: 3 additions & 0 deletions src/game/server/triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,9 @@ BEGIN_DATADESC( CTriggerHurt )
DEFINE_KEYFIELD( m_bitsDamageInflict, FIELD_INTEGER, "damagetype" ),
DEFINE_KEYFIELD( m_damageModel, FIELD_INTEGER, "damagemodel" ),
DEFINE_KEYFIELD( m_bNoDmgForce, FIELD_BOOLEAN, "nodmgforce" ),
#ifdef TF_DLL
DEFINE_KEYFIELD( m_szKillIcon, FIELD_STRING, "killicon" ),
#endif // TF_DLL

DEFINE_FIELD( m_flLastDmgTime, FIELD_TIME ),
DEFINE_FIELD( m_flDmgResetTime, FIELD_TIME ),
Expand Down
3 changes: 3 additions & 0 deletions src/game/server/triggers.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ class CTriggerHurt : public CTriggerHurtShim, public ITriggerHurtAutoList
int m_bitsDamageInflict; // DMG_ damage type that the door or tigger does
int m_damageModel;
bool m_bNoDmgForce; // Should damage from this trigger impart force on what it's hurting
#ifdef TF_DLL
string_t m_szKillIcon;
#endif // TF_DLL

enum
{
Expand Down
42 changes: 41 additions & 1 deletion src/game/shared/tf/tf_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
#include "tf_party.h"
#include "tf_autobalance.h"
#include "player_voice_listener.h"
#include "pointhurt.h"
#include "func_croc.h"
#endif

#include "tf_mann_vs_machine_stats.h"
Expand Down Expand Up @@ -12227,7 +12229,11 @@ const char *CTFGameRules::GetKillingWeaponName( const CTakeDamageInfo &info, CTF
}
else
{
killer_weapon_name = "crocodile";
CFuncCroc *pFuncCroc = dynamic_cast<CFuncCroc*>( pInflictor );
if ( pFuncCroc )
{
killer_weapon_name = pFuncCroc->GetKillIcon();
}
}
}
else if ( info.GetDamageCustom() == TF_DMG_CUSTOM_BOOTS_STOMP )
Expand Down Expand Up @@ -12389,6 +12395,28 @@ const char *CTFGameRules::GetKillingWeaponName( const CTakeDamageInfo &info, CTF
{
killer_weapon_name = "megaton";
}
else
{
CTriggerHurt *pTriggerHurt = dynamic_cast<CTriggerHurt*>( pInflictor );
if ( pTriggerHurt )
{
if ( pTriggerHurt->m_szKillIcon != NULL_STRING )
{
killer_weapon_name = STRING( pTriggerHurt->m_szKillIcon );
}
}
else
{
CPointHurt *pPointHurt = dynamic_cast<CPointHurt*>( pInflictor );
if ( pPointHurt )
{
if ( pPointHurt->m_szKillIcon != NULL_STRING )
{
killer_weapon_name = STRING( pPointHurt->m_szKillIcon );
}
}
}
}
}
else if ( pScorer && pInflictor && ( pInflictor == pScorer ) )
{
Expand Down Expand Up @@ -12477,6 +12505,18 @@ const char *CTFGameRules::GetKillingWeaponName( const CTakeDamageInfo &info, CTF
}
}
}
else
{
// point_hurt won't set damageCustom to TF_DMG_CUSTOM_TRIGGER_HURT if it can't pass through uber
CPointHurt *pPointHurt = dynamic_cast<CPointHurt*>( pInflictor );
if ( pPointHurt )
{
if ( pPointHurt->m_szKillIcon != NULL_STRING )
{
killer_weapon_name = STRING( pPointHurt->m_szKillIcon );
}
}
}
}
}
}
Expand Down