//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- void CWeapon_SLAM::StartSatchelDetonate() { if ( GetActivity() != ACT_SLAM_DETONATOR_IDLE && GetActivity() != ACT_SLAM_THROW_IDLE ) return; // ----------------------------------------- // Play detonate animation // ----------------------------------------- if (m_bNeedReload) { SendWeaponAnim(ACT_SLAM_DETONATOR_DETONATE); } else if (m_tSlamState == SLAM_SATCHEL_ATTACH) { SendWeaponAnim(ACT_SLAM_STICKWALL_DETONATE); } else if (m_tSlamState == SLAM_SATCHEL_THROW) { SendWeaponAnim(ACT_SLAM_THROW_DETONATE); } else { return; } SatchelDetonate(); // needs a higher delay on all of these, a minimum time really - to elimiate refires. m_flNextPrimaryAttack = m_flNextSecondaryAttack = SLAM_REFIRE_DELAY + gpGlobals->curtime + SequenceDuration(); }
//----------------------------------------------------------------------------- // Purpose: Allows the weapon to choose proper weapon idle animation //----------------------------------------------------------------------------- void CBaseHL2MPCombatWeapon::WeaponIdle( void ) { //See if we should idle high or low if ( WeaponShouldBeLowered() ) { // Move to lowered position if we're not there yet if ( GetActivity() != ACT_VM_IDLE_LOWERED && GetActivity() != ACT_VM_IDLE_TO_LOWERED && GetActivity() != ACT_TRANSITION ) { SendWeaponAnim( ACT_VM_IDLE_LOWERED ); } else if ( HasWeaponIdleTimeElapsed() ) { // Keep idling low SendWeaponAnim( ACT_VM_IDLE_LOWERED ); } } else { // See if we need to raise immediately if ( m_flRaiseTime < gpGlobals->curtime && GetActivity() == ACT_VM_IDLE_LOWERED ) { SendWeaponAnim( ACT_VM_IDLE ); } else if ( HasWeaponIdleTimeElapsed() ) { SendWeaponAnim( ACT_VM_IDLE ); } } }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- void CWeapon_SLAM::StartSatchelDetonate() { if ( GetActivity() != ACT_SLAM_DETONATOR_IDLE && GetActivity() != ACT_SLAM_THROW_IDLE ) return; // ----------------------------------------- // Play detonate animation // ----------------------------------------- if (m_bNeedReload) { SendWeaponAnim(ACT_SLAM_DETONATOR_DETONATE); } else if (m_tSlamState == SLAM_SATCHEL_ATTACH) { SendWeaponAnim(ACT_SLAM_STICKWALL_DETONATE); } else if (m_tSlamState == SLAM_SATCHEL_THROW) { SendWeaponAnim(ACT_SLAM_THROW_DETONATE); } else { return; } SatchelDetonate(); m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration(); m_flNextSecondaryAttack = gpGlobals->curtime + SequenceDuration(); }
//----------------------------------------------------------------------------- // Purpose: // Input: // Output: //----------------------------------------------------------------------------- float CASW_Ranger::MaxYawSpeed( void ) { if ( GetActivity() == ACT_STRAFE_LEFT || GetActivity() == ACT_STRAFE_RIGHT ) { return 0.1f; } return 32.0f;// * GetMovementSpeedModifier(); }
void CXenPLight :: Touch( CBaseEntity *pOther ) { if ( pOther->IsPlayer() ) { pev->dmgtime = gpGlobals->time + XEN_PLANT_HIDE_TIME; if ( GetActivity() == ACT_IDLE || GetActivity() == ACT_STAND ) { SetActivity( ACT_CROUCH ); } } }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ void CNPC_LightStalk::Touch( CBaseEntity *pOther ) { if ( pOther->IsPlayer() ) { m_flHideEndTime = gpGlobals->curtime + LIGHTSTALK_HIDE_TIME; if ( GetActivity() == ACT_IDLE || GetActivity() == ACT_STAND ) { SetActivity( ACT_CROUCH ); LightLower(); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CFastZombie::BuildScheduleTestBits( void ) { // Any schedule that makes us climb should break if we touch player if ( GetActivity() == ACT_CLIMB_UP || GetActivity() == ACT_CLIMB_DOWN ) { SetCustomInterruptCondition( COND_FASTZOMBIE_CLIMB_TOUCH ); } else { ClearCustomInterruptCondition( COND_FASTZOMBIE_CLIMB_TOUCH ); } }
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 ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CNPC_Assassin::PrescheduleThink( void ) { if ( GetActivity() == ACT_RUN || GetActivity() == ACT_WALK) { CPASAttenuationFilter filter( this ); static int iStep = 0; iStep = ! iStep; if (iStep) { EmitSound( filter, entindex(), "NPC_Assassin.Footstep" ); } } }
//----------------------------------------------------------------------------- // Purpose: // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CWeaponBuilder::ShouldShowControlPanels( void ) { if ( GetActivity() == ACT_VM_IDLE ) return true; return false; }
void CXenPLight :: Think( void ) { StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; switch( GetActivity() ) { case ACT_CROUCH: if ( m_fSequenceFinished ) { SetActivity( ACT_CROUCHIDLE ); LightOff(); } break; case ACT_CROUCHIDLE: if ( gpGlobals->time > pev->dmgtime ) { SetActivity( ACT_STAND ); LightOn(); } break; case ACT_STAND: if ( m_fSequenceFinished ) SetActivity( ACT_IDLE ); break; case ACT_IDLE: default: break; } }
ECode RestrictedSettingsFragment::OnDestroy() { AutoPtr<IActivity> activity; GetActivity((IActivity**)&activity); IContext::Probe(activity)->UnregisterReceiver(mScreenOffReceiver); return SettingsPreferenceFragment::OnDestroy(); }
float CNPC_Gargantua::MaxYawSpeed ( void ) { float ys = 60; switch ( GetActivity() ) { case ACT_IDLE: ys = 60; break; case ACT_TURN_LEFT: case ACT_TURN_RIGHT: ys = 180; break; case ACT_WALK: case ACT_RUN: ys = 60; break; default: ys = 60; break; } return ys; }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- float CNPC_Headcrab::MaxYawSpeed ( void ) { switch ( GetActivity() ) { case ACT_IDLE: return 30; break; case ACT_RUN: case ACT_WALK: return 20; break; case ACT_TURN_LEFT: case ACT_TURN_RIGHT: return 15; break; case ACT_RANGE_ATTACK1: return 30; break; default: return 30; break; } return BaseClass::MaxYawSpeed(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFCompoundBow::ItemPostFrame( void ) { BaseClass::ItemPostFrame(); if ( m_flChargeBeginTime != 0.0f ) { float flChargeTime = gpGlobals->curtime - m_flChargeBeginTime; if ( flChargeTime >= TF_BOW_CHARGE_TIRED_TIME ) { // Play flinching animation if it was charged for too long. if ( GetActivity() == ACT_ITEM2_VM_IDLE_2 ) { SendWeaponAnim( ACT_ITEM2_VM_CHARGE_IDLE_3 ); } else if ( IsViewModelSequenceFinished() ) { SendWeaponAnim( ACT_ITEM2_VM_IDLE_3 ); } } else if ( IsViewModelSequenceFinished() ) { SendWeaponAnim( ACT_ITEM2_VM_IDLE_2 ); } } }
//======================================================== // RunAI - overridden for bullsquid because there are things // that need to be checked every think. //======================================================== void CNPC_Bullsquid::RunAI ( void ) { // first, do base class stuff BaseClass::RunAI(); if ( m_nSkin != 0 ) { // close eye if it was open. m_nSkin = 0; } if ( random->RandomInt( 0,39 ) == 0 ) { m_nSkin = 1; } if ( GetEnemy() != NULL && GetActivity() == ACT_RUN ) { // chasing enemy. Sprint for last bit if ( (GetAbsOrigin() - GetEnemy()->GetAbsOrigin()).Length2D() < SQUID_SPRINT_DIST ) { m_flPlaybackRate = 1.25; } } }
void CBaseTurret::Deploy(void) { SetNextThink( gpGlobals->curtime + 0.1f ); StudioFrameAdvance( ); if ( GetActivity() != ACT_TURRET_OPEN ) { m_iOn = 1; SetActivity( (Activity)ACT_TURRET_OPEN ); EmitSound( "NPC_Turret.Deploy" ); m_OnDeploy.FireOutput(NULL, this); } if (m_fSequenceFinished) { Vector curmins, curmaxs; curmins = WorldAlignMins(); curmaxs = WorldAlignMaxs(); curmaxs.z = m_iDeployHeight; curmins.z = -m_iDeployHeight; SetCollisionBounds( curmins, curmaxs ); Relink(); SetActivity( (Activity)ACT_TURRET_OPEN_IDLE ); m_flPlaybackRate = 0; SetThink(&CBaseTurret::SearchThink); } m_flLastSight = gpGlobals->curtime + m_flMaxWait; }
//========================================================= // MaxYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= float CNPC_Houndeye::MaxYawSpeed ( void ) { int ys = 90; switch ( GetActivity() ) { case ACT_CROUCHIDLE://sleeping! ys = 0; break; case ACT_IDLE: ys = 60; break; case ACT_WALK: ys = 90; break; case ACT_RUN: ys = 90; break; case ACT_TURN_LEFT: case ACT_TURN_RIGHT: ys = 90; break; } return ys; }
//----------------------------------------------------------------------------- // Animation event handlers //----------------------------------------------------------------------------- void CWeaponKatana::HandleAnimEventMeleeHit( animevent_t *pEvent, CBaseCombatCharacter *pOperator ) { // Trace up or down based on where the enemy is... // But only if we're basically facing that direction Vector vecDirection; AngleVectors( GetAbsAngles(), &vecDirection ); Vector vecEnd; VectorMA( pOperator->Weapon_ShootPosition(), 50, vecDirection, vecEnd ); CBaseEntity *pHurt = pOperator->CheckTraceHullAttack( pOperator->Weapon_ShootPosition(), vecEnd, Vector(-16,-16,-16), Vector(36,36,36), GetDamageForActivity( GetActivity() ), DMG_CLUB, 0.75 ); // did I hit someone? if ( pHurt ) { // play sound WeaponSound( MELEE_HIT ); // Fake a trace impact, so the effects work out like a player's crowbaw trace_t traceHit; UTIL_TraceLine( pOperator->Weapon_ShootPosition(), pHurt->GetAbsOrigin(), MASK_SHOT_HULL, pOperator, COLLISION_GROUP_NONE, &traceHit ); ImpactEffect( traceHit ); } else { WeaponSound( MELEE_MISS ); } }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ void CNPC_Houndeye::PrescheduleThink ( void ) { BaseClass::PrescheduleThink(); // if the hound is mad and is running, make hunt noises. if ( m_NPCState == NPC_STATE_COMBAT && ( GetActivity() == ACT_RUN ) && random->RandomFloat( 0, 1 ) < 0.2 ) { WarnSound(); } // at random, initiate a blink if not already blinking or sleeping if ( !m_fDontBlink ) { /*//<<TEMP>>//<<TEMP>> if ( ( pev->skin == 0 ) && random->RandomInt(0,0x7F) == 0 ) {// start blinking! pev->skin = HOUNDEYE_EYE_FRAMES - 1; } else if ( pev->skin != 0 ) {// already blinking pev->skin--; } */ } }
/* * Arma 3 listas: * ncp = Non Created Precedencies * dcp = Drain Connected Precedencies * ndcp = Non Drain Connected Precedencies * Las mismas las arma con cada una de las actividades que preceden a tal actividad. */ void SetPrecedencesLists(graphADT g, lisInfADT list, listInfADT * ncp, listInfADT * dcp, listInfADT * ndcp, char ** precedencies) { int i = 0; activityADT act; actInfo * info; listActADT actList; while(precedencies[i]) { info = CopyActInfo(getActInfo(list, precedencies[i])); if((act = GetActivity(g, precedencies[i])) == NULL) insertInf(ncp, info); else { actList = GetStageStart(GetActivityOrig(g, precedencies[i])); while(!ListActIsEmpty(actList)) {Act act = ListHeader(actList); if(IsDrain(GetActivityDest(g, ListActHeadID(list)))) insertInf(dcp, info); else insertInf(ndcp, info); actList = ListTail(actList); } } i++; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CTFMinigun::SendWeaponAnim( int iActivity ) { #ifdef CLIENT_DLL // Client procedurally animates the barrel bone if ( iActivity == ACT_MP_ATTACK_STAND_PRIMARYFIRE || iActivity == ACT_MP_ATTACK_STAND_PREFIRE ) { m_flBarrelTargetVelocity = MAX_BARREL_SPIN_VELOCITY; } else if ( iActivity == ACT_MP_ATTACK_STAND_POSTFIRE ) { m_flBarrelTargetVelocity = 0; } #endif // When we start firing, play the startup firing anim first if ( iActivity == ACT_VM_PRIMARYATTACK ) { // If we're already playing the fire anim, let it continue. It loops. if ( GetActivity() == ACT_VM_PRIMARYATTACK ) return true; // Otherwise, play the start it return BaseClass::SendWeaponAnim( ACT_VM_PRIMARYATTACK ); } return BaseClass::SendWeaponAnim( iActivity ); }
float CASW_Harvester::MaxYawSpeed( void ) { if ( m_bElectroStunned.Get() ) return 0.1f; return 32.0f; switch ( GetActivity() ) { case ACT_IDLE: return 64.0f; break; case ACT_WALK: return 64.0f; break; default: case ACT_RUN: return 64.0f; break; } return 64.0f; }
//----------------------------------------------------------------------------- // Purpose: Allows the weapon to choose proper weapon idle animation //----------------------------------------------------------------------------- void CBaseHLCombatWeapon::WeaponIdle( void ) { CBasePlayer *pPlayer = ToBasePlayer(GetOwner()); if ( pPlayer ) { if ( pPlayer->m_bIsRunning || !pPlayer->GetGroundEntity() || pPlayer->m_bShouldLowerWeapon ) return; } //See if we should idle high or low if ( WeaponShouldBeLowered() ) { #if !defined( CLIENT_DLL ) CHL2_Player *pPlayer = dynamic_cast<CHL2_Player*>(GetOwner()); if( pPlayer ) { pPlayer->Weapon_Lower(); } #endif // Move to lowered position if we're not there yet if ( GetActivity() != ACT_VM_IDLE_LOWERED && GetActivity() != ACT_VM_IDLE_TO_LOWERED && GetActivity() != ACT_TRANSITION ) { SendWeaponAnim( ACT_VM_IDLE_LOWERED ); } else if ( HasWeaponIdleTimeElapsed() ) { // Keep idling low SendWeaponAnim( ACT_VM_IDLE_LOWERED ); } } else { // See if we need to raise immediately if ( m_flRaiseTime < gpGlobals->curtime && GetActivity() == ACT_VM_IDLE_LOWERED ) { SendWeaponAnim( ACT_VM_IDLE ); } else if ( HasWeaponIdleTimeElapsed() ) { SendWeaponAnim( ACT_VM_IDLE ); } } }
//----------------------------------------------------------------------------- // Purpose: // Output : const Vector //----------------------------------------------------------------------------- const Vector &CNPC_Assassin::GetViewOffset( void ) { static Vector eyeOffset; //FIXME: Use eye attachment? // If we're crouching, offset appropriately if ( ( GetActivity() == ACT_ASSASSIN_PERCH ) || ( GetActivity() == ACT_RANGE_ATTACK1 ) ) { eyeOffset = Vector( 0, 0, 24.0f ); } else { eyeOffset = BaseClass::GetViewOffset(); } return eyeOffset; }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ void CNPC_LightStalk::Think( void ) { StudioFrameAdvance(); SetNextThink( gpGlobals->curtime + 0.1f ); switch( GetActivity() ) { case ACT_CROUCH: if ( IsActivityFinished() ) { SetActivity( ACT_CROUCHIDLE ); } break; case ACT_CROUCHIDLE: if ( gpGlobals->curtime > m_flHideEndTime ) { SetActivity( ACT_STAND ); LightRise(); } break; case ACT_STAND: if ( IsActivityFinished() ) { SetActivity( ACT_IDLE ); } break; case ACT_IDLE: default: break; } if (m_nFadeDir && m_pGlow) { float flFadePercent = (gpGlobals->curtime - m_flStartFadeTime)/LIGHTSTALK_FADE_TIME; if (flFadePercent > 1) { m_nFadeDir = FADE_NONE; } else { if (m_nFadeDir == FADE_IN) { m_pGlow->SetBrightness(LIGHTSTALK_MAX_BRIGHT*flFadePercent); } else { //m_pGlow->SetBrightness(LIGHTSTALK_MAX_BRIGHT*(1-flFadePercent)); // Fade out immedately m_pGlow->SetBrightness(0); } } } }
void CXenTree :: Attack( void ) { if ( GetActivity() == ACT_IDLE ) { SetActivity( ACT_MELEE_ATTACK1 ); pev->framerate = RANDOM_FLOAT( 1.0, 1.4 ); EMIT_SOUND_ARRAY_DYN( CHAN_WEAPON, pAttackMissSounds ); } }
//--------------------------------------------------------- //--------------------------------------------------------- int CFastZombie::TranslateSchedule( int scheduleType ) { switch( scheduleType ) { case SCHED_RANGE_ATTACK1: { // Scream right now, cause in half a second, we're gonna jump!! if( !m_fHasScreamed ) { // Only play that over-the-top attack scream once per combat state. EmitSound( "NPC_FastZombie.Scream" ); m_fHasScreamed = true; } else { EmitSound( "NPC_FastZombie.RangeAttack" ); } return SCHED_FASTZOMBIE_RANGE_ATTACK1; } break; case SCHED_MELEE_ATTACK1: return SCHED_FASTZOMBIE_MELEE_ATTACK1; break; case SCHED_FASTZOMBIE_UNSTICK_JUMP: if ( GetActivity() == ACT_CLIMB_UP || GetActivity() == ACT_CLIMB_DOWN ) { return SCHED_FASTZOMBIE_CLIMBING_UNSTICK_JUMP; } else { return SCHED_FASTZOMBIE_UNSTICK_JUMP; } break; default: return BaseClass::TranslateSchedule( scheduleType ); break; } }
//------------------------------------------------------------------------------ // Purpose: // Input : // Output : //------------------------------------------------------------------------------ void CAI_ASW_MeleeBehavior::HullAttack( float flDistance, float flDamage, float flForce, CUtlSymbol &AttackHitSound, CUtlSymbol &AttackMissSound ) { Vector vecForceDir; CBaseEntity *pHurt = GetOuter()->CheckTraceHullAttack( flDistance, -Vector( 16.0f, 16.0f, 32.0f ), Vector( 16.0f, 16.0f, 32.0f ), flDamage, DMG_SLASH, flForce ); if ( pHurt ) { SetBehaviorParam( m_StatusParm, 1 ); // Play a random attack hit sound if ( AttackHitSound != UTL_INVAL_SYMBOL ) { GetOuter()->EmitSound( GetSymbolText( AttackHitSound ) ); } // change our sequence to one with the hit in it if ( !m_bSecondaryMelee && ( GetActivity() == ACT_MELEE_ATTACK1 ) ) { if ( GetOuter()->HaveSequenceForActivity( (Activity) ACT_MELEE_ATTACK1_HIT ) ) { SetActivity( (Activity) ACT_MELEE_ATTACK1_HIT ); } } else if ( m_bSecondaryMelee && ( GetActivity() == ACT_MELEE_ATTACK2 ) ) { if ( GetOuter()->HaveSequenceForActivity( (Activity) ACT_MELEE_ATTACK2_HIT ) ) { SetActivity( (Activity) ACT_MELEE_ATTACK2_HIT ); } } if ( m_bKnockdown && pHurt->Classify() == CLASS_ASW_MARINE ) { CASW_Marine *pMarine = static_cast<CASW_Marine*>( pHurt ); Vector vecImpulse = ( GetOuter()->BodyDirection2D() * m_flKnockdownSpeed ) + Vector( 0, 0, m_flKnockdownLift ); pMarine->Knockdown( GetOuter(), vecImpulse ); } } else { // Play a miss sound. GetOuter()->EmitSound( GetSymbolText( AttackMissSound ) ); SetBehaviorParam( m_StatusParm, 0 ); } }
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 ); } }