diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/game/server/episodic/npc_puppet.cpp | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/game/server/episodic/npc_puppet.cpp')
| -rw-r--r-- | mp/src/game/server/episodic/npc_puppet.cpp | 242 |
1 files changed, 121 insertions, 121 deletions
diff --git a/mp/src/game/server/episodic/npc_puppet.cpp b/mp/src/game/server/episodic/npc_puppet.cpp index ff0e9e85..8d4f3669 100644 --- a/mp/src/game/server/episodic/npc_puppet.cpp +++ b/mp/src/game/server/episodic/npc_puppet.cpp @@ -1,121 +1,121 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: NPC Puppet
-//
-//=============================================================================
-
-#include "cbase.h"
-#include "ai_basenpc.h"
-
-// Must be the last file included
-#include "memdbgon.h"
-
-class CNPC_Puppet : public CAI_BaseNPC
-{
- DECLARE_CLASS( CNPC_Puppet, CAI_BaseNPC );
-public:
-
- virtual void Spawn( void );
- virtual void Precache( void );
-
- void InputSetAnimationTarget( inputdata_t &inputdata );
-
-private:
-
- string_t m_sAnimTargetname;
- string_t m_sAnimAttachmentName;
-
- CNetworkVar( EHANDLE, m_hAnimationTarget ); // NPC that will drive what animation we're playing
- CNetworkVar( int, m_nTargetAttachment ); // Attachment point to match to on the target
-
- DECLARE_DATADESC();
- DECLARE_SERVERCLASS();
-};
-
-LINK_ENTITY_TO_CLASS( npc_puppet, CNPC_Puppet );
-
-BEGIN_DATADESC( CNPC_Puppet )
- DEFINE_KEYFIELD( m_sAnimTargetname, FIELD_STRING, "animationtarget" ),
- DEFINE_KEYFIELD( m_sAnimAttachmentName, FIELD_STRING, "attachmentname" ),
-
- DEFINE_FIELD( m_nTargetAttachment, FIELD_INTEGER ),
- DEFINE_FIELD( m_hAnimationTarget, FIELD_EHANDLE ),
- DEFINE_INPUTFUNC( FIELD_STRING, "SetAnimationTarget", InputSetAnimationTarget ),
-END_DATADESC()
-
-IMPLEMENT_SERVERCLASS_ST( CNPC_Puppet, DT_NPC_Puppet )
- SendPropEHandle( SENDINFO( m_hAnimationTarget ) ),
- SendPropInt( SENDINFO( m_nTargetAttachment) ),
-END_SEND_TABLE()
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-void CNPC_Puppet::Precache( void )
-{
- BaseClass::Precache();
- PrecacheModel( STRING( GetModelName() ) );
-}
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-void CNPC_Puppet::Spawn( void )
-{
- BaseClass::Spawn();
-
- Precache();
-
- SetModel( STRING( GetModelName() ) );
-
- NPCInit();
-
- SetHealth( 100 );
-
- // Find our animation target
- CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, m_sAnimTargetname );
- m_hAnimationTarget = pTarget;
- if ( pTarget )
- {
- CBaseAnimating *pAnimating = pTarget->GetBaseAnimating();
- if ( pAnimating )
- {
- m_nTargetAttachment = pAnimating->LookupAttachment( STRING( m_sAnimAttachmentName ) );
- }
- }
-
- // Always be scripted
- SetInAScript( true );
-}
-
-//-----------------------------------------------------------------------------
-// Purpose:
-// Input : &inputdata -
-//-----------------------------------------------------------------------------
-void CNPC_Puppet::InputSetAnimationTarget( inputdata_t &inputdata )
-{
- // Take the new name
- m_sAnimTargetname = MAKE_STRING( inputdata.value.String() );
-
- // Find our animation target
- CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, m_sAnimTargetname );
- if ( pTarget == NULL )
- {
- Warning("Failed to find animation target %s for npc_puppet (%s)\n", STRING( m_sAnimTargetname ), STRING( GetEntityName() ) );
- return;
- }
-
- m_hAnimationTarget = pTarget;
-
- CBaseAnimating *pAnimating = pTarget->GetBaseAnimating();
- if ( pAnimating )
- {
- // Cache off our target attachment
- m_nTargetAttachment = pAnimating->LookupAttachment( STRING( m_sAnimAttachmentName ) );
- }
-
- // Stuff us at the owner's core for visibility reasons
- SetParent( pTarget );
- SetLocalOrigin( vec3_origin );
- SetLocalAngles( vec3_angle );
-}
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: NPC Puppet +// +//============================================================================= + +#include "cbase.h" +#include "ai_basenpc.h" + +// Must be the last file included +#include "memdbgon.h" + +class CNPC_Puppet : public CAI_BaseNPC +{ + DECLARE_CLASS( CNPC_Puppet, CAI_BaseNPC ); +public: + + virtual void Spawn( void ); + virtual void Precache( void ); + + void InputSetAnimationTarget( inputdata_t &inputdata ); + +private: + + string_t m_sAnimTargetname; + string_t m_sAnimAttachmentName; + + CNetworkVar( EHANDLE, m_hAnimationTarget ); // NPC that will drive what animation we're playing + CNetworkVar( int, m_nTargetAttachment ); // Attachment point to match to on the target + + DECLARE_DATADESC(); + DECLARE_SERVERCLASS(); +}; + +LINK_ENTITY_TO_CLASS( npc_puppet, CNPC_Puppet ); + +BEGIN_DATADESC( CNPC_Puppet ) + DEFINE_KEYFIELD( m_sAnimTargetname, FIELD_STRING, "animationtarget" ), + DEFINE_KEYFIELD( m_sAnimAttachmentName, FIELD_STRING, "attachmentname" ), + + DEFINE_FIELD( m_nTargetAttachment, FIELD_INTEGER ), + DEFINE_FIELD( m_hAnimationTarget, FIELD_EHANDLE ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetAnimationTarget", InputSetAnimationTarget ), +END_DATADESC() + +IMPLEMENT_SERVERCLASS_ST( CNPC_Puppet, DT_NPC_Puppet ) + SendPropEHandle( SENDINFO( m_hAnimationTarget ) ), + SendPropInt( SENDINFO( m_nTargetAttachment) ), +END_SEND_TABLE() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CNPC_Puppet::Precache( void ) +{ + BaseClass::Precache(); + PrecacheModel( STRING( GetModelName() ) ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CNPC_Puppet::Spawn( void ) +{ + BaseClass::Spawn(); + + Precache(); + + SetModel( STRING( GetModelName() ) ); + + NPCInit(); + + SetHealth( 100 ); + + // Find our animation target + CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, m_sAnimTargetname ); + m_hAnimationTarget = pTarget; + if ( pTarget ) + { + CBaseAnimating *pAnimating = pTarget->GetBaseAnimating(); + if ( pAnimating ) + { + m_nTargetAttachment = pAnimating->LookupAttachment( STRING( m_sAnimAttachmentName ) ); + } + } + + // Always be scripted + SetInAScript( true ); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CNPC_Puppet::InputSetAnimationTarget( inputdata_t &inputdata ) +{ + // Take the new name + m_sAnimTargetname = MAKE_STRING( inputdata.value.String() ); + + // Find our animation target + CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, m_sAnimTargetname ); + if ( pTarget == NULL ) + { + Warning("Failed to find animation target %s for npc_puppet (%s)\n", STRING( m_sAnimTargetname ), STRING( GetEntityName() ) ); + return; + } + + m_hAnimationTarget = pTarget; + + CBaseAnimating *pAnimating = pTarget->GetBaseAnimating(); + if ( pAnimating ) + { + // Cache off our target attachment + m_nTargetAttachment = pAnimating->LookupAttachment( STRING( m_sAnimAttachmentName ) ); + } + + // Stuff us at the owner's core for visibility reasons + SetParent( pTarget ); + SetLocalOrigin( vec3_origin ); + SetLocalAngles( vec3_angle ); +} |