Activity CNPCSimpleTalker::NPC_TranslateActivity( Activity eNewActivity ) { if ((eNewActivity == ACT_IDLE) && (GetExpresser()->IsSpeaking()) && (SelectWeightedSequence ( ACT_SIGNAL3 ) != ACTIVITY_NOT_AVAILABLE) ) { return ACT_SIGNAL3; } else if ((eNewActivity == ACT_SIGNAL3) && (SelectWeightedSequence ( ACT_SIGNAL3 ) == ACTIVITY_NOT_AVAILABLE) ) { return ACT_IDLE; } return BaseClass::NPC_TranslateActivity( eNewActivity ); }
//----------------------------------------------------------------------------- // Purpose: // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CBaseHL2MPCombatWeapon::Deploy( void ) { // If we should be lowered, deploy in the lowered position // We have to ask the player if the last time it checked, the weapon was lowered if ( GetOwner() && GetOwner()->IsPlayer() ) { CHL2MP_Player *pPlayer = assert_cast<CHL2MP_Player*>( GetOwner() ); if ( pPlayer->IsWeaponLowered() ) { if ( SelectWeightedSequence( ACT_VM_IDLE_LOWERED ) != ACTIVITY_NOT_AVAILABLE ) { if ( DefaultDeploy( (char*)GetViewModel(), (char*)GetWorldModel(), ACT_VM_IDLE_LOWERED, (char*)GetAnimPrefix() ) ) { m_bLowered = true; // Stomp the next attack time to fix the fact that the lower idles are long pPlayer->SetNextAttack( gpGlobals->curtime + 1.0 ); m_flNextPrimaryAttack = gpGlobals->curtime + 1.0; m_flNextSecondaryAttack = gpGlobals->curtime + 1.0; return true; } } } } m_bLowered = false; return BaseClass::Deploy(); }
void C_DHL_Player::ClientDeath( void ) { //This function should only be called for the local player, but just in case... if ( !IsLocalPlayer() ) return; //Fix ragdolls getting borked because of the stunt sequence if ( m_bProne ) { MDLCACHE_CRITICAL_SECTION(); ResetSequence( SelectWeightedSequence( ACT_DHL_PRONE_GENERIC ) ); } //Gotta go to first person for the ragdoll death cam if ( input->CAM_IsThirdPerson() ) { engine->ClientCmd( "firstperson \n"); m_bWantsThirdPerson = true; } if ( GetNightvisionEnabled() ) { EnableNightvision( false ); m_bWantsNV = true; } vieweffects->ClearAllFades(); //No screenfades after death }
AIMoveResult_t CAI_Motor::MoveJumpStop() { SetSmoothedVelocity( Vector(0,0,0) ); if (GetOuter()->GetActivity() == ACT_GLIDE) { float flTime = GetOuter()->GetGroundChangeTime(); GetOuter()->AddStepDiscontinuity( flTime, GetAbsOrigin(), GetAbsAngles() ); if ( SelectWeightedSequence( ACT_LAND ) == ACT_INVALID ) return AIMR_CHANGE_TYPE; SetActivity( ACT_LAND ); // FIXME: find out why the client doesn't interpolate immediatly after sequence change // GetOuter()->SetCycle( flTime - gpGlobals->curtime ); } if (GetOuter()->GetActivity() != ACT_LAND || GetOuter()->IsActivityFinished()) { return AIMR_CHANGE_TYPE; } SetMoveInterval( 0 ); SetGravity( 1.0f ); return AIMR_OK; }
//----------------------------------------------------------------------------- // Purpose: Looks up a sequence by sequence name first, then by activity name. // Input : label - The sequence name or activity name to look up. // Output : Returns the sequence index of the matching sequence, or ACT_INVALID. //----------------------------------------------------------------------------- int LookupSequence( CStudioHdr *pstudiohdr, const char *label ) { VPROF( "LookupSequence" ); if (! pstudiohdr) return 0; if (!pstudiohdr->SequencesAvailable()) return 0; // // Look up by sequence name. // for (int i = 0; i < pstudiohdr->GetNumSeq(); i++) { mstudioseqdesc_t &seqdesc = pstudiohdr->pSeqdesc( i ); if (stricmp( seqdesc.pszLabel(), label ) == 0) return i; } // // Not found, look up by activity name. // int nActivity = LookupActivity( pstudiohdr, label ); if (nActivity != ACT_INVALID ) { return SelectWeightedSequence( pstudiohdr, nActivity ); } return ACT_INVALID; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropAPC::Think( void ) { BaseClass::Think(); SetNextThink( gpGlobals->curtime ); if ( !m_bInitialHandbrake ) // after initial timer expires, set the handbrake { m_bInitialHandbrake = true; m_VehiclePhysics.SetHandbrake( true ); m_VehiclePhysics.Think(); } StudioFrameAdvance(); if ( IsSequenceFinished() ) { int iSequence = SelectWeightedSequence( ACT_IDLE ); if ( iSequence > ACTIVITY_NOT_AVAILABLE ) { SetCycle( 0 ); m_flAnimTime = gpGlobals->curtime; ResetSequence( iSequence ); ResetClientsideFrame(); } } if (m_debugOverlays & OVERLAY_NPC_KILL_BIT) { CTakeDamageInfo info( this, this, m_iHealth, DMG_BLAST ); info.SetDamagePosition( WorldSpaceCenter() ); info.SetDamageForce( Vector( 0, 0, 1 ) ); TakeDamage( info ); } }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ int CBaseAnimatingOverlay::AddGesture( Activity activity, bool autokill /*= true*/ ) { if ( IsPlayingGesture( activity ) ) { return FindGestureLayer( activity ); } MDLCACHE_CRITICAL_SECTION(); int seq = SelectWeightedSequence( activity ); if ( seq <= 0 ) { const char *actname = CAI_BaseNPC::GetActivityName( activity ); DevMsg( "CBaseAnimatingOverlay::AddGesture: model %s missing activity %s\n", STRING(GetModelName()), actname ); return -1; } int i = AddGestureSequence( seq, autokill ); Assert( i != -1 ); if ( i != -1 ) { m_AnimOverlay[ i ].m_nActivity = activity; } return i; }
void CBasePlayer::SharedSpawn() { SetMoveType( MOVETYPE_WALK ); SetSolid( SOLID_BBOX ); AddSolidFlags( FSOLID_NOT_STANDABLE ); SetFriction( 1.0f ); pl.deadflag = false; m_lifeState = LIFE_ALIVE; m_iHealth = 100; m_takedamage = DAMAGE_YES; m_Local.m_bDrawViewmodel = true; m_Local.m_flStepSize = sv_stepsize.GetFloat(); m_Local.m_bAllowAutoMovement = true; m_nRenderFX = kRenderFxNone; m_flNextAttack = gpGlobals->curtime; m_flMaxspeed = 0.0f; MDLCACHE_CRITICAL_SECTION(); SetSequence( SelectWeightedSequence( ACT_IDLE ) ); if ( GetFlags() & FL_DUCKING ) SetCollisionBounds( VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX ); else SetCollisionBounds( VEC_HULL_MIN, VEC_HULL_MAX ); // dont let uninitialized value here hurt the player m_Local.m_flFallVelocity = 0; SetBloodColor( BLOOD_COLOR_RED ); }
void CBasePlayerAnimState::ComputeMainSequence() { VPROF( "CBasePlayerAnimState::ComputeMainSequence" ); CBaseAnimatingOverlay *pPlayer = GetOuter(); // Have our class or the mod-specific class determine what the current activity is. Activity idealActivity = CalcMainActivity(); #ifdef CLIENT_DLL Activity oldActivity = m_eCurrentMainSequenceActivity; #endif // Store our current activity so the aim and fire layers know what to do. m_eCurrentMainSequenceActivity = idealActivity; // Export to our outer class.. int animDesired = SelectWeightedSequence( TranslateActivity(idealActivity) ); if ( !ShouldResetMainSequence( pPlayer->GetSequence(), animDesired ) ) return; if ( animDesired < 0 ) animDesired = 0; pPlayer->ResetSequence( animDesired ); #ifdef CLIENT_DLL if ( ShouldResetGroundSpeed( oldActivity, idealActivity ) ) { ResetGroundSpeed(); } #endif }
//----------------------------------------------------------------------------- // Purpose: // Input : flDot - // flDist - // Output : int CNPC_Assassin::RangeAttack1Conditions //----------------------------------------------------------------------------- int CNPC_Assassin::RangeAttack2Conditions ( float flDot, float flDist ) { if ( m_flNextLungeTime > gpGlobals->curtime ) return 0; float lungeRange = GetSequenceMoveDist( SelectWeightedSequence( (Activity) ACT_ASSASSIN_FLIP_FORWARD ) ); if ( flDist < lungeRange * 0.25f ) return COND_TOO_CLOSE_TO_ATTACK; if ( flDist > lungeRange * 1.5f ) return COND_TOO_FAR_TO_ATTACK; if ( flDot < 0.75f ) return COND_NOT_FACING_ATTACK; if ( GetEnemy() == NULL ) return 0; // Check for a clear path trace_t tr; UTIL_TraceHull( GetAbsOrigin(), GetEnemy()->GetAbsOrigin(), GetHullMins(), GetHullMaxs(), MASK_NPCSOLID, this, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction == 1.0f || tr.m_pEnt == GetEnemy() ) return COND_CAN_RANGE_ATTACK2; return 0; }
//----------------------------------------------------------------------------- // Purpose: // Output : //----------------------------------------------------------------------------- int CNPC_Headcrab::SelectSchedule( void ) { switch ( m_NPCState ) { case NPC_STATE_ALERT: { if (HasCondition( COND_LIGHT_DAMAGE ) || HasCondition( COND_HEAVY_DAMAGE )) { if ( fabs( GetMotor()->DeltaIdealYaw() ) < ( 1.0 - m_flFieldOfView) * 60 ) // roughly in the correct direction { return SCHED_TAKE_COVER_FROM_ORIGIN; } else if ( SelectWeightedSequence( ACT_SMALL_FLINCH ) != -1 ) { return SCHED_ALERT_SMALL_FLINCH; } } else if (HasCondition( COND_HEAR_DANGER ) || HasCondition( COND_HEAR_PLAYER ) || HasCondition( COND_HEAR_WORLD ) || HasCondition( COND_HEAR_COMBAT )) { return SCHED_ALERT_FACE; } else { return SCHED_PATROL_WALK; } break; } } // no special cases here, call the base class return BaseClass::SelectSchedule(); }
//----------------------------------------------------------------------------- // Purpose: Drops the weapon into a lowered pose // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CBaseHL2MPCombatWeapon::Lower( void ) { //Don't bother if we don't have the animation if ( SelectWeightedSequence( ACT_VM_IDLE_LOWERED ) == ACTIVITY_NOT_AVAILABLE ) return false; m_bLowered = true; return true; }
//----------------------------------------------------------------------------- // Purpose: Make the grub angry! //----------------------------------------------------------------------------- void CAntlionGrub::InputAgitate( inputdata_t &inputdata ) { SetSequence( SelectWeightedSequence( ACT_SMALL_FLINCH ) ); m_State = GRUB_STATE_AGITATED; m_flNextSquealSoundTime = gpGlobals->curtime; m_flFlinchTime = gpGlobals->curtime + inputdata.value.Float(); SetNextThink( gpGlobals->curtime ); }
void CActAnimating :: SetActivity( Activity act ) { int sequence = SelectWeightedSequence( act ); if ( sequence != ACTIVITY_NOT_AVAILABLE ) { ResetSequence( sequence ); m_Activity = act; m_flCycle = 0; } }
//----------------------------------------------------------------------------- // Purpose: Brings the weapon up to the ready position // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CBaseHL2MPCombatWeapon::Ready( void ) { //Don't bother if we don't have the animation if ( SelectWeightedSequence( ACT_VM_LOWERED_TO_IDLE ) == ACTIVITY_NOT_AVAILABLE ) return false; m_bLowered = false; m_flRaiseTime = gpGlobals->curtime + 0.5f; return true; }
void CAI_Motor::MoveClimbStart( const Vector &climbDest, const Vector &climbDir, float climbDist, float yaw ) { // @Note (toml 06-11-02): the following code is somewhat suspect. It // originated in CAI_BaseNPC::MoveClimb() from early June 2002 // At the very least, state should be restored to original, not // slammed. // // -----Original Message----- // From: Jay Stelly // Sent: Monday, June 10, 2002 3:57 PM // To: Tom Leonard // Subject: RE: // // yes. // // Also, there is some subtlety to using movetype. I think in // general we want to keep things in MOVETYPE_STEP because it // implies a bunch of things in the external game physics // simulator. There is a flag FL_FLY we use to // disable gravity on MOVETYPE_STEP characters. // // > -----Original Message----- // > From: Tom Leonard // > Sent: Monday, June 10, 2002 3:55 PM // > To: Jay Stelly // > Subject: // > // > Should I worry at all that the following highlighted bits of // > code are not reciprocal for all state, and furthermore, stomp // > other state? if ( fabsf( climbDir.z ) < .1 ) { SetActivity( GetNavigator()->GetMovementActivity() ); } else { SetActivity( (climbDir.z > -0.01 ) ? ACT_CLIMB_UP : ACT_CLIMB_DOWN ); } m_nDismountSequence = SelectWeightedSequence( ACT_CLIMB_DISMOUNT ); if (m_nDismountSequence != ACT_INVALID) { GetOuter()->GetSequenceLinearMotion( m_nDismountSequence, &m_vecDismount ); } else { m_vecDismount.Init(); } GetOuter()->AddFlag( FL_FLY ); // No gravity SetSolid( SOLID_BBOX ); SetGravity( 0.0 ); SetGroundEntity( NULL ); }
//----------------------------------------------------------------------------- // Purpose: // Input : activity - //----------------------------------------------------------------------------- void CRagdollProp::SetOverlaySequence( Activity activity ) { int seq = SelectWeightedSequence( activity ); if ( seq < 0 ) { m_nOverlaySequence = -1; } else { m_nOverlaySequence = seq; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAntlionGrub::FlinchThink( void ) { StudioFrameAdvance(); SetNextThink( gpGlobals->curtime + 0.1f ); // See if we're done if ( m_flFlinchTime < gpGlobals->curtime ) { SetSequence( SelectWeightedSequence( ACT_IDLE ) ); SetThink( &CAntlionGrub::IdleThink ); } }
void C_SkeletonPlayer::UpdateClientSideAnimation() { int curSeq = GetSequence(); Vector vel = GetLocalVelocity(); //EstimateAbsVelocity( vel ); int goalSeq = curSeq; if ( vel.LengthSqr() > 4 ) { QAngle velAng; VectorAngles( vel, velAng ); goalSeq = SelectWeightedSequence( ACT_RUN ); float speed = vel.Length2D(); float yaw = AngleNormalize( -(GetRenderAngles().y - velAng.y) ); float seqspeed = 150.0f; float rate = speed / seqspeed; SetPoseParameter( LookupPoseParameter( "move_x" ), cos( DEG2RAD( yaw ) ) * rate ); SetPoseParameter( LookupPoseParameter( "move_y" ), -sin( DEG2RAD( yaw ) ) * rate ); SetPlaybackRate( clamp( rate * 0.6f, 1, 1.5f ) ); } else goalSeq = SelectWeightedSequence( ACT_IDLE ); if ( curSeq != goalSeq ) { ResetSequence( goalSeq ); } //m_flAnimTime = gpGlobals->curtime; //StudioFrameAdvance(); if ( GetCycle() >= 1.0f ) SetCycle( GetCycle() - 1.0f ); }
// Purpose: Monitor the antlion's jump to play the proper landing sequence bool CASW_Alien_Jumper::CheckLanding( void ) { trace_t tr; Vector testPos; //Amount of time to predict forward const float timeStep = 0.1f; //Roughly looks one second into the future testPos = GetAbsOrigin() + ( GetAbsVelocity() * timeStep ); testPos[2] -= ( 0.5 * sv_gravity.GetFloat() * GetGravity() * timeStep * timeStep); if ( asw_debug_aliens.GetInt() == 2 ) { NDebugOverlay::Line( GetAbsOrigin(), testPos, 255, 0, 0, 0, 0.5f ); NDebugOverlay::Cross3D( m_vecSavedJump, -Vector(2,2,2), Vector(2,2,2), 0, 255, 0, true, 0.5f ); } // Look below AI_TraceHull( GetAbsOrigin(), testPos, NAI_Hull::Mins( GetHullType() ), NAI_Hull::Maxs( GetHullType() ), MASK_NPCSOLID, this, COLLISION_GROUP_NONE, &tr ); //See if we're about to contact, or have already contacted the ground if ( ( tr.fraction != 1.0f ) || ( GetFlags() & FL_ONGROUND ) ) { int sequence = SelectWeightedSequence( (Activity)ACT_ASW_ALIEN_LAND ); if ( GetSequence() != sequence ) { VacateStrategySlot(); SetIdealActivity( (Activity) ACT_ASW_ALIEN_LAND ); CreateDust( false ); EmitSound( "ASW_Drone.Land" ); // asw todo: make the alien attack here? //if ( GetEnemy() && GetEnemy()->IsPlayer() ) //{ //CBasePlayer *pPlayer = ToBasePlayer( GetEnemy() ); //if ( pPlayer && pPlayer->IsInAVehicle() == false ) //MeleeAttack( ANTLION_MELEE1_RANGE, sk_antlion_swipe_damage.GetFloat(), QAngle( 4.0f, 0.0f, 0.0f ), Vector( -250.0f, 1.0f, 1.0f ) ); //} SetAbsVelocity( GetAbsVelocity() * 0.33f ); return false; } return IsActivityFinished(); } return false; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponCGuard::DelayedFire( void ) { if ( m_flChargeTime >= gpGlobals->curtime ) return; if ( m_bFired ) return; m_bFired = true; // Only the player fires this way so we can cast CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( pPlayer == NULL ) return; // Abort here to handle burst and auto fire modes if ( (GetMaxClip1() != -1 && m_iClip1 == 0) || (GetMaxClip1() == -1 && !pPlayer->GetAmmoCount(m_iPrimaryAmmoType) ) ) return; // MUST call sound before removing a round from the clip of a CMachineGun WeaponSound(SINGLE); pPlayer->DoMuzzleFlash(); // To make the firing framerate independent, we may have to fire more than one bullet here on low-framerate systems, // especially if the weapon we're firing has a really fast rate of fire. if ( GetSequence() != SelectWeightedSequence( ACT_VM_PRIMARYATTACK ) ) { m_flNextPrimaryAttack = gpGlobals->curtime; } // Make sure we don't fire more than the amount in the clip, if this weapon uses clips if ( UsesClipsForAmmo1() ) { m_iClip1 = m_iClip1 - 1; } // Fire the bullets Vector vecSrc = pPlayer->Weapon_ShootPosition( ); Vector vecAiming = pPlayer->GetRadialAutoVector( NEW_AUTOAIM_RADIUS, NEW_AUTOAIM_DIST ); //Factor in the view kick AddViewKick(); Vector impactPoint = vecSrc + ( vecAiming * MAX_TRACE_LENGTH ); trace_t tr; UTIL_TraceHull( vecSrc, impactPoint, Vector( -2, -2, -2 ), Vector( 2, 2, 2 ), MASK_SHOT, pPlayer, COLLISION_GROUP_NONE, &tr ); CreateConcussiveBlast( tr.endpos, tr.plane.normal, this, 1.0 ); }
//----------------------------------------------------------------------------- // Purpose: // Input : act - //----------------------------------------------------------------------------- void CBaseObject::SetActivity( Activity act ) { // Hrm, it's not actually a studio model... if ( !GetModelPtr() ) return; int sequence = SelectWeightedSequence( act ); if ( sequence != ACTIVITY_NOT_AVAILABLE ) { m_Activity = act; SetObjectSequence( sequence ); } }
void C_BaseNetworkedRagdoll::OnDataChanged( DataUpdateType_t type ) { BaseClass::OnDataChanged( type ); if ( type == DATA_UPDATE_CREATED ) { SelectWeightedSequence( ACT_MP_RUN ); // m_vecForce is applied succesfully yet the ragdoll doesn't budge. // This may be of benefit however, as it means that it is likely to // settle where the player was actually killed. BecomeRagdollOnClient(); } }
void CBaseCombatWeapon::Operator_FrameUpdate( CBaseCombatCharacter *pOperator ) { StudioFrameAdvance( ); // animate if ( IsSequenceFinished() ) { if ( SequenceLoops() ) { // animation does loop, which means we're playing subtle idle. Might need to fidget. int iSequence = SelectWeightedSequence( GetActivity() ); if ( iSequence != ACTIVITY_NOT_AVAILABLE ) { ResetSequence( iSequence ); // Set to new anim (if it's there) } } #if 0 else { // animation that just ended doesn't loop! That means we just finished a fidget // and should return to our heaviest weighted idle (the subtle one) SelectHeaviestSequence( GetActivity() ); } #endif } CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner == NULL ) return; CBaseViewModel *vm = pOwner->GetViewModel( m_nViewModelIndex ); if ( vm == NULL ) return; // HACK: Player weapon and view model often use the same mdl, which results // in duplicate anim events. For now, let the view model handle the events // if they're the same, which is the preferred behavior in general. CStudioHdr *w_hdr = GetModelPtr(); CStudioHdr *v_hdr = vm->GetModelPtr(); if ( w_hdr->GetRenderHdr() != v_hdr->GetRenderHdr() ) { // Animation events are passed back to the weapon's owner/operator DispatchAnimEvents( pOperator ); } // Update and dispatch the viewmodel events if ( vm != NULL ) { vm->StudioFrameAdvance(); vm->DispatchAnimEvents( this ); } }
//--------------------------------------------------------- //--------------------------------------------------------- void CBounceBomb::Spawn() { Precache(); Wake( false ); SetModel("models/props_combine/combine_mine01.mdl"); SetSolid( SOLID_VPHYSICS ); m_hSprite.Set( NULL ); m_takedamage = DAMAGE_EVENTS_ONLY; // Find my feet! m_iHookN = LookupPoseParameter( "blendnorth" ); m_iHookE = LookupPoseParameter( "blendeast" ); m_iHookS = LookupPoseParameter( "blendsouth" ); m_iAllHooks = LookupPoseParameter( "blendstates" ); m_flHookPositions = 0; SetHealth( 100 ); m_bBounce = true; SetSequence( SelectWeightedSequence( ACT_IDLE ) ); OpenHooks( true ); m_bHeldByPhysgun = false; m_iFlipAttempts = 0; if( !GetParent() ) { // Create vphysics now if I'm not being carried. CreateVPhysics(); } m_flTimeGrabbed = FLT_MAX; if( m_bDisarmed ) { SetMineState( MINE_STATE_DORMANT ); } else { SetMineState( MINE_STATE_DEPLOY ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropJetski::Think(void) { BaseClass::Think(); // set handbrake after physics sim settles down if ( gpGlobals->curtime < m_flHandbrakeTime ) { SetNextThink( gpGlobals->curtime ); } else if ( !m_bInitialHandbrake ) // after initial timer expires, set the handbrake { m_bInitialHandbrake = true; m_VehiclePhysics.SetHandbrake( true ); m_VehiclePhysics.Think(); } // play enter animation if ( (m_bEnterAnimOn || m_bExitAnimOn) && !IsSequenceFinished() ) { StudioFrameAdvance(); } else if ( IsSequenceFinished() ) { if ( m_bExitAnimOn ) { CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); if ( pPlayer ) { pPlayer->LeaveVehicle(); // now that sequence is finished, leave car Vector vecEyes; QAngle vecEyeAng; GetAttachment( "vehicle_driver_eyes", vecEyes, vecEyeAng ); vecEyeAng.x = 0; vecEyeAng.z = 0; pPlayer->SnapEyeAngles( vecEyeAng ); } m_bExitAnimOn = false; } int iSequence = SelectWeightedSequence( ACT_IDLE ); if ( iSequence > ACTIVITY_NOT_AVAILABLE ) { SetCycle(0); m_flAnimTime = gpGlobals->curtime; ResetSequence( iSequence ); ResetClientsideFrame(); } } }
//----------------------------------------------------------------------------- // Purpose: // Input : &info - //----------------------------------------------------------------------------- int CAntlionGrub::OnTakeDamage( const CTakeDamageInfo &info ) { // Animate a flinch of pain if we're dying bool bSquashed = ( ( GetEffects() & EF_NODRAW ) != 0 ); if ( bSquashed == false ) { SetSequence( SelectWeightedSequence( ACT_SMALL_FLINCH ) ); m_flFlinchTime = gpGlobals->curtime + random->RandomFloat( 0.5f, 1.0f ); SetThink( &CAntlionGrub::FlinchThink ); SetNextThink( gpGlobals->curtime + 0.05f ); } return BaseClass::OnTakeDamage( info ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAntlionGrub::Spawn( void ) { Precache(); BaseClass::Spawn(); SetModel( ANTLIONGRUB_MODEL ); // FIXME: This is a big perf hit with the number of grubs we're using! - jdw CreateGlow(); SetSolid( SOLID_BBOX ); SetSolidFlags( FSOLID_TRIGGER ); SetMoveType( MOVETYPE_NONE ); SetCollisionGroup( COLLISION_GROUP_NONE ); AddEffects( EF_NOSHADOW ); CollisionProp()->UseTriggerBounds(true,1); SetTouch( &CAntlionGrub::GrubTouch ); SetHealth( 1 ); m_takedamage = DAMAGE_YES; // Stick to the nearest surface if ( HasSpawnFlags( SF_ANTLIONGRUB_NO_AUTO_PLACEMENT ) == false ) { AttachToSurface(); } // At this point, alter our bounds to make sure we're within them Vector vecMins, vecMaxs; RotateAABB( EntityToWorldTransform(), CollisionProp()->OBBMins(), CollisionProp()->OBBMaxs(), vecMins, vecMaxs ); UTIL_SetSize( this, vecMins, vecMaxs ); // Start our idle activity SetSequence( SelectWeightedSequence( ACT_IDLE ) ); SetCycle( random->RandomFloat( 0.0f, 1.0f ) ); ResetSequenceInfo(); m_State = GRUB_STATE_IDLE; // Reset m_flFlinchTime = 0.0f; m_flNextIdleSoundTime = gpGlobals->curtime + random->RandomFloat( 4.0f, 8.0f ); }
void CRagdollProp::InitRagdollAnimation() { m_flAnimTime = gpGlobals->curtime; m_flPlaybackRate = 0.0; m_flCycle = 0; // put into ACT_DIERAGDOLL if it exists, otherwise use sequence 0 int nSequence = SelectWeightedSequence( ACT_DIERAGDOLL ); if ( nSequence < 0 ) { ResetSequence( 0 ); } else { ResetSequence( nSequence ); } }
void CBaseCombatWeapon::Operator_FrameUpdate( CBaseCombatCharacter *pOperator ) { StudioFrameAdvance( ); // animate if ( IsSequenceFinished() ) { if ( SequenceLoops() ) { // animation does loop, which means we're playing subtle idle. Might need to fidget. int iSequence = SelectWeightedSequence( GetActivity() ); if ( iSequence != ACTIVITY_NOT_AVAILABLE ) { ResetSequence( iSequence ); // Set to new anim (if it's there) } } #if 0 else { // animation that just ended doesn't loop! That means we just finished a fidget // and should return to our heaviest weighted idle (the subtle one) SelectHeaviestSequence( GetActivity() ); } #endif } // Animation events are passed back to the weapon's owner/operator DispatchAnimEvents( pOperator ); // Update and dispatch the viewmodel events CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner == NULL ) return; CBaseViewModel *vm = pOwner->GetViewModel(); if ( vm != NULL ) { vm->StudioFrameAdvance(); vm->DispatchAnimEvents( this ); } }