//----------------------------------------------------------------------------- // tool recording //----------------------------------------------------------------------------- void C_BaseCombatWeapon::GetToolRecordingState( KeyValues *msg ) { if ( !ToolsEnabled() ) return; int nModelIndex = GetModelIndex(); int nWorldModelIndex = GetWorldModelIndex(); if ( nModelIndex != nWorldModelIndex ) { SetModelIndex( nWorldModelIndex ); } BaseClass::GetToolRecordingState( msg ); if ( m_iState == WEAPON_NOT_CARRIED ) { BaseEntityRecordingState_t *pBaseEntity = (BaseEntityRecordingState_t*)msg->GetPtr( "baseentity" ); pBaseEntity->m_nOwner = -1; } else { msg->SetInt( "worldmodel", 1 ); if ( m_iState == WEAPON_IS_ACTIVE ) { BaseEntityRecordingState_t *pBaseEntity = (BaseEntityRecordingState_t*)msg->GetPtr( "baseentity" ); pBaseEntity->m_bVisible = true; } } if ( nModelIndex != nWorldModelIndex ) { SetModelIndex( nModelIndex ); } }
// If the local player is visible (thirdperson mode, tf2 taunts, etc., then make sure that we are using the // w_ (world) model not the v_ (view) model or else the model can flicker, etc. // Otherwise, if we're not the local player, always use the world model void C_BaseCombatWeapon::EnsureCorrectRenderingModel() { C_BasePlayer *localplayer = C_BasePlayer::GetLocalPlayer(); if ( localplayer && localplayer == GetOwner() && !localplayer->ShouldDrawLocalPlayer() ) { return; } MDLCACHE_CRITICAL_SECTION(); // BRJ 10/14/02 // FIXME: Remove when Yahn's client-side prediction is done // It's a hacky workaround for the model indices fighting // (GetRenderBounds uses the model index, which is for the view model) SetModelIndex( GetWorldModelIndex() ); // Validate our current sequence just in case ( in theory the view and weapon models should have the same sequences for sequences that overlap at least ) CStudioHdr *pStudioHdr = GetModelPtr(); if ( pStudioHdr && GetSequence() >= pStudioHdr->GetNumSeq() ) { SetSequence( 0 ); } }
void C_PortalGhostRenderable::PerFrameUpdate( void ) { if( m_pGhostedRenderable ) { SetModelName( m_pGhostedRenderable->GetModelName() ); SetModelIndex( m_pGhostedRenderable->GetModelIndex() ); SetEffects( m_pGhostedRenderable->GetEffects() | EF_NOINTERP ); m_flAnimTime = m_pGhostedRenderable->m_flAnimTime; if( m_bSourceIsBaseAnimating ) { C_BaseAnimating *pSource = (C_BaseAnimating *)m_pGhostedRenderable; SetCycle( pSource->GetCycle() ); SetSequence( pSource->GetSequence() ); m_nBody = pSource->m_nBody; m_nSkin = pSource->m_nSkin; } } // Set position and angles relative to the object it's ghosting Vector ptNewOrigin = m_matGhostTransform * m_pGhostedRenderable->GetAbsOrigin(); QAngle qNewAngles = TransformAnglesToWorldSpace( m_pGhostedRenderable->GetAbsAngles(), m_matGhostTransform.As3x4() ); SetAbsOrigin( ptNewOrigin ); SetAbsAngles( qNewAngles ); AddEffects( EF_NOINTERP ); RemoveFromInterpolationList(); g_pClientLeafSystem->RenderableChanged( RenderHandle() ); }
void CTriggerVolume::Spawn( void ) { SetSolidType( SOLID_NOT ); SetMoveType( MOVETYPE_NONE ); SetModel( GetModelName() ); // set size and link into world SetModelName( iStringNull ); SetModelIndex( 0 ); }
/** * Constructor for CCivilianPedSA */ CCivilianPedSA::CCivilianPedSA( CCivilianPedSAInterface *ped, modelId_t modelID ) : CPedSA( ped ) { DEBUG_TRACE("CCivilianPedSA::CCivilianPedSA( CCivilianPedSAInterface *ped, unsigned short modelID )"); SetType( CIVILIAN_PED ); SetModelIndex( modelID ); BOOL_FLAG( GetInterface()->m_entityFlags, ENTITY_DISABLESTREAMING, true ); BOOL_FLAG( GetInterface()->m_entityFlags, ENTITY_NOSTREAM, true ); }
void CWeaponCycler::SecondaryAttack( void ) { float flFrameRate; int nSequence = (GetSequence() + 1) % 8; // BUG: Why do we set this here and then set to zero right after? SetModelIndex( m_iModel ); flFrameRate = 0.0; SetModelIndex( 0 ); if (flFrameRate == 0.0) { nSequence = 0; } SetSequence( nSequence ); SendWeaponAnim( nSequence ); m_flNextSecondaryAttack = gpGlobals->curtime + 0.3; }
void CWorld::Spawn( void ) { SetLocalOrigin( vec3_origin ); SetLocalAngles( vec3_angle ); // NOTE: SHOULD NEVER BE ANYTHING OTHER THAN 1!!! SetModelIndex( 1 ); // world model SetModelName( MAKE_STRING( modelinfo->GetModelName( GetModel() ) ) ); AddFlag( FL_WORLDBRUSH ); g_EventQueue.Init(); Precache( ); }
CObject::CObject(int iModelIndex, bool bCreate) { m_pRelatedDummy = NULL; if(bCreate) { SetModelIndex(iModelIndex); } else { SetModelIndexNoCreate(iModelIndex); } Init(); }
CObject::CObject(int modelIndex, bool create) { m_relatedDummy = NULL; if (create) { SetModelIndex(modelIndex); } else { SetModelIndexNoCreate(modelIndex); } Init(); }
//----------------------------------------------------------------------------- // Purpose: // Input : bnewentity - //----------------------------------------------------------------------------- void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged(updateType); CHandle< C_BaseCombatWeapon > handle = this; // If it's being carried by the *local* player, on the first update, // find the registered weapon for this ID C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); C_BaseCombatCharacter *pOwner = GetOwner(); // check if weapon is carried by local player bool bIsLocalPlayer = pPlayer && pPlayer == pOwner; if ( bIsLocalPlayer && ShouldDrawLocalPlayerViewModel() ) // TODO: figure out the purpose of the ShouldDrawLocalPlayer() test. { // If I was just picked up, or created & immediately carried, add myself to this client's list of weapons if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) ) { // Tell the HUD this weapon's been picked up if ( ShouldDrawPickup() ) { CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection(); if ( pHudSelection ) { pHudSelection->OnWeaponPickup( this ); } pPlayer->EmitSound( "Player.PickupWeapon" ); } } } else // weapon carried by other player or not at all { int overrideModelIndex = CalcOverrideModelIndex(); if( overrideModelIndex != -1 && overrideModelIndex != GetModelIndex() ) { SetModelIndex( overrideModelIndex ); } } if ( updateType == DATA_UPDATE_CREATED ) { UpdateVisibility(); } m_iOldState = m_iState; m_bJustRestored = false; }
void CWorld::Spawn( void ) { SetLocalOrigin( vec3_origin ); SetLocalAngles( vec3_angle ); // NOTE: SHOULD NEVER BE ANYTHING OTHER THAN 1!!! SetModelIndex( 1 ); // world model SetModelName( AllocPooledString( modelinfo->GetModelName( GetModel() ) ) ); AddFlag( FL_WORLDBRUSH ); g_EventQueue.Init(); Precache( ); GlobalEntity_Add( "is_console", STRING(gpGlobals->mapname), ( IsConsole() ) ? GLOBAL_ON : GLOBAL_OFF ); GlobalEntity_Add( "is_pc", STRING(gpGlobals->mapname), ( !IsConsole() ) ? GLOBAL_ON : GLOBAL_OFF ); }
//----------------------------------------------------------------------------- // Purpose: // Input : bnewentity - //----------------------------------------------------------------------------- void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged(updateType); CHandle< C_BaseCombatWeapon > handle = this; // If it's being carried by the *local* player, on the first update, // find the registered weapon for this ID C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); C_BaseCombatCharacter *pOwner = GetOwner(); // check if weapon is carried by local player bool bIsLocalPlayer = pPlayer && pPlayer == pOwner; if ( bIsLocalPlayer && !ShouldDrawLocalPlayer() ) { // If I was just picked up, or created & immediately carried, add myself to this client's list of weapons if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) ) { // Tell the HUD this weapon's been picked up if ( ShouldDrawPickup() ) { CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection(); if ( pHudSelection ) { pHudSelection->OnWeaponPickup( this ); } pPlayer->EmitSound( "Player.PickupWeapon" ); } } } else // weapon carried by other player or not at all { // BRJ 10/14/02 // FIXME: Remove when Yahn's client-side prediction is done // It's a hacky workaround for the model indices fighting // (GetRenderBounds uses the model index, which is for the view model) SetModelIndex( GetWorldModelIndex() ); } UpdateVisibility(); m_iOldState = m_iState; m_bJustRestored = false; }
void C_HL2MPRagdoll::CreateHL2MPRagdoll( void ) { // First, initialize all our data. If we have the player's entity on our client, // then we can make ourselves start out exactly where the player is. C_HL2MP_Player *pPlayer = dynamic_cast< C_HL2MP_Player* >( m_hPlayer.Get() ); if ( pPlayer && !pPlayer->IsDormant() ) { // move my current model instance to the ragdoll's so decals are preserved. pPlayer->SnatchModelInstance( this ); VarMapping_t *varMap = GetVarMapping(); // Copy all the interpolated vars from the player entity. // The entity uses the interpolated history to get bone velocity. bool bRemotePlayer = (pPlayer != C_BasePlayer::GetLocalPlayer()); if ( bRemotePlayer ) { Interp_Copy( pPlayer ); SetAbsAngles( pPlayer->GetRenderAngles() ); GetRotationInterpolator().Reset(); m_flAnimTime = pPlayer->m_flAnimTime; SetSequence( pPlayer->GetSequence() ); m_flPlaybackRate = pPlayer->GetPlaybackRate(); } else { // This is the local player, so set them in a default // pose and slam their velocity, angles and origin SetAbsOrigin( m_vecRagdollOrigin ); SetAbsAngles( pPlayer->GetRenderAngles() ); SetAbsVelocity( m_vecRagdollVelocity ); int iSeq = pPlayer->GetSequence(); if ( iSeq == -1 ) { Assert( false ); // missing walk_lower? iSeq = 0; } SetSequence( iSeq ); // walk_lower, basic pose SetCycle( 0.0 ); Interp_Reset( varMap ); } } else { // overwrite network origin so later interpolation will // use this position SetNetworkOrigin( m_vecRagdollOrigin ); SetAbsOrigin( m_vecRagdollOrigin ); SetAbsVelocity( m_vecRagdollVelocity ); Interp_Reset( GetVarMapping() ); } SetModelIndex( m_nModelIndex ); // Make us a ragdoll.. m_nRenderFX = kRenderFxRagdoll; matrix3x4_t boneDelta0[MAXSTUDIOBONES]; matrix3x4_t boneDelta1[MAXSTUDIOBONES]; matrix3x4_t currentBones[MAXSTUDIOBONES]; const float boneDt = 0.05f; if ( pPlayer && !pPlayer->IsDormant() ) { pPlayer->GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } else { GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt ); }
void C_CFRagdoll::CreateRagdoll() { // First, initialize all our data. If we have the player's entity on our client, // then we can make ourselves start out exactly where the player is. C_CFPlayer *pPlayer = dynamic_cast< C_CFPlayer* >( m_hPlayer.Get() ); if ( pPlayer && !pPlayer->IsDormant() ) { // move my current model instance to the ragdoll's so decals are preserved. pPlayer->SnatchModelInstance( this ); VarMapping_t *varMap = GetVarMapping(); // Copy all the interpolated vars from the player entity. // The entity uses the interpolated history to get bone velocity. bool bRemotePlayer = (pPlayer != C_BasePlayer::GetLocalPlayer()); if ( bRemotePlayer ) { Interp_Copy( pPlayer ); SetAbsAngles( pPlayer->GetRenderAngles() ); GetRotationInterpolator().Reset(); m_flAnimTime = pPlayer->m_flAnimTime; SetSequence( pPlayer->GetSequence() ); m_flPlaybackRate = pPlayer->GetPlaybackRate(); } else { // This is the local player, so set them in a default // pose and slam their velocity, angles and origin SetAbsOrigin( m_vecRagdollOrigin ); SetAbsAngles( pPlayer->GetRenderAngles() ); SetAbsVelocity( m_vecRagdollVelocity ); int iSeq = LookupSequence( "idle" ); if ( iSeq == -1 ) { Assert( false ); // missing walk_lower? iSeq = 0; } SetSequence( iSeq ); // walk_lower, basic pose SetCycle( 0.0 ); Interp_Reset( varMap ); } } else { // overwrite network origin so later interpolation will // use this position SetNetworkOrigin( m_vecRagdollOrigin ); SetAbsOrigin( m_vecRagdollOrigin ); SetAbsVelocity( m_vecRagdollVelocity ); Interp_Reset( GetVarMapping() ); } if (pPlayer) { SetModelIndex( m_nModelIndex ); m_nSkin = pPlayer->m_nSkin; SetBodygroup(1, pPlayer->m_bIsDecapitated); } // Turn it into a ragdoll. if ( cl_ragdoll_physics_enable.GetBool() ) { // Make us a ragdoll.. m_nRenderFX = kRenderFxRagdoll; matrix3x4_t boneDelta0[MAXSTUDIOBONES]; matrix3x4_t boneDelta1[MAXSTUDIOBONES]; matrix3x4_t currentBones[MAXSTUDIOBONES]; const float boneDt = 0.05f; // We have to make sure that we're initting this client ragdoll off of the same model. // GetRagdollInitBoneArrays uses the *player* Hdr, which may be a different model than // the ragdoll Hdr, if we try to create a ragdoll in the same frame that the player // changes their player model. CStudioHdr *pRagdollHdr = GetModelPtr(); CStudioHdr *pPlayerHdr = NULL; if ( pPlayer ) pPlayerHdr = pPlayer->GetModelPtr(); bool bChangedModel = false; if ( pRagdollHdr && pPlayerHdr ) { bChangedModel = pRagdollHdr->GetVirtualModel() != pPlayerHdr->GetVirtualModel(); Assert( !bChangedModel && "C_CFRagdoll::CreateRagdoll: Trying to create ragdoll with a different model than the player it's based on" ); } if ( pPlayer && !pPlayer->IsDormant() && !bChangedModel && pPlayerHdr ) { pPlayer->GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } else { GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt ); } SetNextClientThink( CLIENT_THINK_ALWAYS ); }
void C_SDKRagdoll::CreateRagdoll() { // First, initialize all our data. If we have the player's entity on our client, // then we can make ourselves start out exactly where the player is. C_SDKPlayer *pPlayer = dynamic_cast< C_SDKPlayer* >( m_hPlayer.Get() ); if ( pPlayer && !pPlayer->IsDormant() ) { // move my current model instance to the ragdoll's so decals are preserved. pPlayer->SnatchModelInstance( this ); VarMapping_t *varMap = GetVarMapping(); // Copy all the interpolated vars from the player entity. // The entity uses the interpolated history to get bone velocity. if ( !pPlayer->IsLocalPlayer() && pPlayer->IsInterpolationEnabled() ) { Interp_Copy( pPlayer ); SetAbsAngles( pPlayer->GetRenderAngles() ); GetRotationInterpolator().Reset(); m_flAnimTime = pPlayer->m_flAnimTime; SetSequence( pPlayer->GetSequence() ); m_flPlaybackRate = pPlayer->GetPlaybackRate(); } else { // This is the local player, so set them in a default // pose and slam their velocity, angles and origin SetAbsOrigin( m_vecRagdollOrigin ); SetAbsAngles( pPlayer->GetRenderAngles() ); SetAbsVelocity( m_vecRagdollVelocity ); int iSeq = LookupSequence( "RagdollSpawn" ); // hax, find a neutral standing pose if ( iSeq == -1 ) { Assert( false ); // missing look_idle? iSeq = 0; } SetSequence( iSeq ); // look_idle, basic pose SetCycle( 0.0 ); Interp_Reset( varMap ); } m_nBody = pPlayer->GetBody(); } else { // overwrite network origin so later interpolation will // use this position SetNetworkOrigin( m_vecRagdollOrigin ); SetAbsOrigin( m_vecRagdollOrigin ); SetAbsVelocity( m_vecRagdollVelocity ); Interp_Reset( GetVarMapping() ); } SetModelIndex( m_nModelIndex ); // Turn it into a ragdoll. if ( cl_ragdoll_physics_enable.GetInt() ) { // Make us a ragdoll.. m_nRenderFX = kRenderFxRagdoll; matrix3x4_t boneDelta0[MAXSTUDIOBONES]; matrix3x4_t boneDelta1[MAXSTUDIOBONES]; matrix3x4_t currentBones[MAXSTUDIOBONES]; const float boneDt = 0.05f; if ( pPlayer && pPlayer == C_BasePlayer::GetLocalPlayer() ) { pPlayer->GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } else { GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt ); } else { ClientLeafSystem()->SetRenderGroup( GetRenderHandle(), RENDER_GROUP_TRANSLUCENT_ENTITY ); } // Fade out the ragdoll in a while StartFadeOut( cl_ragdoll_fade_time.GetFloat() ); SetNextClientThink( gpGlobals->curtime + 5.0f ); }
void C_GENPCRagdoll::CreateRagdoll( void ) { // First, initialize all our data. If we have the player's entity on our client, // then we can make ourselves start out exactly where the player is. C_AI_BaseNPC *pNPC = dynamic_cast< C_AI_BaseNPC* >( m_hNPC.Get() ); // Cache away our skin before we start meddling (setting it later down) int skin = 0; if ( pNPC ) skin = pNPC->GetSkin(); if ( pNPC && !pNPC->IsDormant() ) { // move my current model instance to the ragdoll's so decals are preserved. pNPC->SnatchModelInstance( this ); // Copy all the interpolated vars from the player entity. // The entity uses the interpolated history to get bone velocity. Interp_Copy( pNPC ); SetAbsAngles( pNPC->GetRenderAngles() ); GetRotationInterpolator().Reset(); m_flAnimTime = pNPC->m_flAnimTime; SetSequence( pNPC->GetSequence() ); m_flPlaybackRate = pNPC->GetPlaybackRate(); } else { // overwrite network origin so later interpolation will // use this position SetNetworkOrigin( m_vecRagdollOrigin ); SetAbsOrigin( m_vecRagdollOrigin ); SetAbsVelocity( m_vecRagdollVelocity ); Interp_Reset( GetVarMapping() ); } SetModelIndex( m_nModelIndex ); // Make us a ragdoll.. m_nRenderFX = kRenderFxRagdoll; matrix3x4_t boneDelta0[MAXSTUDIOBONES]; matrix3x4_t boneDelta1[MAXSTUDIOBONES]; matrix3x4_t currentBones[MAXSTUDIOBONES]; const float boneDt = 0.05f; if ( pNPC && !pNPC->IsDormant() ) { pNPC->GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } else { GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } // Finally reset our skin m_nSkin = skin; InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CEnvLaser::Precache( void ) { SetModelIndex( PrecacheModel( STRING( GetModelName() ) ) ); if ( m_iszSpriteName != NULL_STRING ) PrecacheModel( STRING(m_iszSpriteName) ); }
void C_StriderRagdoll::CreateStriderRagdoll( void ) { // First, initialize all our data. If we have the player's entity on our client, // then we can make ourselves start out exactly where the player is. C_QUA_Strider *pStrider = dynamic_cast< C_QUA_Strider* >( m_hStrider.Get()); if ( pStrider) { // move my current model instance to the ragdoll's so decals are preserved. pStrider->SnatchModelInstance( this ); VarMapping_t *varMap = GetVarMapping(); // Copy all the interpolated vars from the player entity. // The entity uses the interpolated history to get bone velocity. /*bool bRemotePlayer = (pPlayer != C_BasePlayer::GetLocalPlayer()); if ( bRemotePlayer ) {*/ Interp_Copy( varMap, this, pStrider, pStrider->C_BaseAnimating::GetVarMapping() ); SetAbsAngles( pStrider->GetRenderAngles() ); GetRotationInterpolator().Reset(); m_flAnimTime = pStrider->m_flAnimTime; SetSequence( pStrider->GetSequence() ); m_flPlaybackRate = pStrider->GetPlaybackRate(); SetPoseParameter(LookupPoseParameter("body_height"),200.0f); /*} else {*/ // This is the local player, so set them in a default // pose and slam their velocity, angles and origin // SetAbsOrigin( m_vecRagdollOrigin ); // // SetAbsAngles( pPlayer->GetRenderAngles() ); // SetAbsVelocity( m_vecRagdollVelocity ); // int iSeq = pPlayer->GetSequence(); // if ( iSeq == -1 ) // { // Assert( false ); // missing walk_lower? // iSeq = 0; // } // // SetSequence( iSeq ); // walk_lower, basic pose // SetCycle( 0.0 ); // Interp_Reset( varMap ); //} } else { // overwrite network origin so later interpolation will // use this position SetNetworkOrigin( m_vecRagdollOrigin ); SetAbsOrigin( m_vecRagdollOrigin ); SetAbsVelocity( m_vecRagdollVelocity ); SetSequence(LookupSequence("idle01")); SetPoseParameter(LookupPoseParameter("body_height"),m_fAltura); Interp_Reset( GetVarMapping() ); } SetModelIndex( m_nModelIndex ); //engine->Con_NPrintf(27,"Le volvemos a poner de altura: %f",m_fAltura); SetPoseParameter(LookupPoseParameter("body_height"),200.0f); // Make us a ragdoll.. m_nRenderFX = kRenderFxRagdoll; BecomeRagdollOnClient( /*false*/ ); //FixMe No? xd }