/* ================ rvMonsterConvoyGround::Spawn ================ */ bool rvMonsterConvoyGround::CheckActions ( void ) { if ( isOpen ) { if ( move.fl.moving ) { /* || !CheckAction_RangedAttack( &actionBlasterAttack, -1 ) || enemy.range > actionBlasterAttack.maxRange || enemy.range < actionBlasterAttack.minRange || (!move.fl.moving && (gameLocal.GetTime()-move.startTime) > 3000 ) ) { */ StartSound( "snd_prepare", SND_CHANNEL_ANY, 0, 0, 0 ); PerformAction ( "Torso_Close", 4, true ); return true; } if ( PerformAction ( &actionBlasterAttack, (checkAction_t)&idAI::CheckAction_RangedAttack, &actionTimerRangedAttack ) ) { return true; } } else { // Open up if we have stopped and have an enemy if ( !move.fl.moving && physicsObj.HasGroundContacts ( ) && enemy.ent && legsAnim.IsIdle ( ) && CheckTactical ( AITACTICAL_RANGED ) ) { StartSound( "snd_prepare", SND_CHANNEL_ANY, 0, 0, 0 ); PerformAction ( "Torso_Open", 4, true ); return true; } } return idAI::CheckActions ( ); }
/* ================ hhWeaponAutoCannon::Event_SpawnRearGasFX ================ */ void hhWeaponAutoCannon::Event_SpawnRearGasFX() { if( !owner->CanShowWeaponViewmodel() || pm_thirdPerson.GetBool() ) return; hhFxInfo fxInfo; float fxHeatThreshold = hhMath::ClampFloat( 0.0f, 1.0f, dict->GetFloat("heatThreshold") ); if( fxHeatThreshold >= GetHeatLevel() ) { return; } //Checking if fx's are done yet. Only want to get in when fx's are done if( !rearGasFxL.IsValid() && !rearGasFxR.IsValid() ) { fxInfo.UseWeaponDepthHack( true ); fxInfo.RemoveWhenDone( true ); BroadcastFxInfoAlongBone( dict->RandomPrefix("fx_rearGas", gameLocal.random), dict->GetString("joint_rearGasFxL"), &fxInfo, &EV_Broadcast_AssignLeftRearFx, false ); BroadcastFxInfoAlongBone( dict->RandomPrefix("fx_rearGas", gameLocal.random), dict->GetString("joint_rearGasFxR"), &fxInfo, &EV_Broadcast_AssignRightRearFx, false ); if( GetHeatLevel() >= 1.0f ) StartSound( "snd_overheat", SND_CHANNEL_BODY, 0, false, NULL ); else StartSound( "snd_steam_vent", SND_CHANNEL_BODY, 0, false, NULL ); } }
void hhSlots::CheckVictory() { #define NUM_VICTORIES 16 static victory_t victoryTable[NUM_VICTORIES] = { { MASK_BARBARBAR, MASK_BARBARBAR, MASK_BARBARBAR, 10000}, { MASK_BARBAR, MASK_BARBAR, MASK_BARBAR, 1000}, { MASK_BAR, MASK_BAR, MASK_BAR, 500}, { MASK_ANYBAR, MASK_ANYBAR, MASK_ANYBAR, 100}, { MASK_MELON, MASK_MELON, MASK_MELON, 60}, { MASK_GRAPE, MASK_GRAPE, MASK_GRAPE, 50}, { MASK_APPLE, MASK_APPLE, MASK_APPLE, 40}, { MASK_LEMON, MASK_LEMON, MASK_LEMON, 30}, { MASK_ORANGE, MASK_ORANGE, MASK_ORANGE, 20}, { MASK_CHERRY, MASK_CHERRY, MASK_CHERRY, 10}, { MASK_CHERRY, MASK_CHERRY, MASK_ANY, 5}, { MASK_ANY, MASK_CHERRY, MASK_CHERRY, 5}, { MASK_CHERRY, MASK_ANY, MASK_CHERRY, 5}, { MASK_CHERRY, MASK_ANY, MASK_ANY, 2}, { MASK_ANY, MASK_CHERRY, MASK_ANY, 2}, { MASK_ANY, MASK_ANY, MASK_CHERRY, 2} }; PlayerCredits -= Bet; result = SLOTRESULT_LOSE; creditsWon = 0; for (int ix=0; ix<NUM_VICTORIES; ix++) { int fruitmask1 = MaskForFruit(reel1[ReelPos2Slot(reelPos1)]); int fruitmask2 = MaskForFruit(reel2[ReelPos2Slot(reelPos2)]); int fruitmask3 = MaskForFruit(reel3[ReelPos2Slot(reelPos3)]); if ((fruitmask1 & victoryTable[ix].f1) && (fruitmask2 & victoryTable[ix].f2) && (fruitmask3 & victoryTable[ix].f3) ) { result = SLOTRESULT_WIN; creditsWon = Bet * victoryTable[ix].payoff; PlayerCredits += creditsWon; PlayerCredits = idMath::ClampInt(0, 999999999, PlayerCredits); // Play victory sound if (victoryAmount && PlayerCredits >= victoryAmount) { StartSound( "snd_victory", SND_CHANNEL_ANY ); ActivateTargets( gameLocal.GetLocalPlayer() ); victoryAmount = 0; } else if (victoryTable[ix].payoff > 5) { StartSound( "snd_winbig", SND_CHANNEL_ANY ); } else { StartSound( "snd_win", SND_CHANNEL_ANY ); } break; } } PlayerBet = idMath::ClampInt(0, PlayerCredits, PlayerBet); }
/* ================ sdClientProjectile::Explode ================ */ void sdClientProjectile::Explode( const trace_t *collision, const char *sndExplode ) { const char *fxname; idVec3 normal, endpos; int removeTime; if ( spawnArgs.GetVector( "detonation_axis", "", normal ) ) { SetAxis( normal.ToMat3() ); } else { normal = collision ? collision->c.normal : idVec3( 0, 0, 1 ); } endpos = ( collision ) ? collision->endpos : GetOrigin(); removeTime = PROJECTILE_REMOVE_TIME; // play sound // StopSound( SND_CHANNEL_ANY ); StartSound( sndExplode, SND_CHANNEL_BODY ); StartSound( "snd_explode_med", SND_CHANNEL_BODY2 ); StartSound( "snd_explode_far", SND_CHANNEL_BODY3 ); Hide(); FreeLightDef(); SetOrigin( GetOrigin() + 8.0f * normal ); // change the model fxname = NULL; if ( g_testParticle.GetInteger() == TEST_PARTICLE_IMPACT ) { fxname = g_testParticleName.GetString(); } else { fxname = spawnArgs.GetString( "model_detonate" ); } ClientEntEvent_Remove( removeTime ); }
/* ================ idBrittleFracture::Shatter ================ */ void idBrittleFracture::Shatter( const idVec3 &point, const idVec3 &impulse, const int time ) { int i; idVec3 dir; shard_t *shard; float m; if ( gameLocal.isServer ) { idBitMsg msg; byte msgBuf[MAX_EVENT_PARAM_SIZE]; msg.Init( msgBuf, sizeof( msgBuf ) ); msg.BeginWriting(); msg.WriteFloat( point[0] ); msg.WriteFloat( point[1] ); msg.WriteFloat( point[2] ); msg.WriteFloat( impulse[0] ); msg.WriteFloat( impulse[1] ); msg.WriteFloat( impulse[2] ); ServerSendEvent( EVENT_SHATTER, &msg, true, -1 ); } if ( time > ( gameLocal.time - SHARD_ALIVE_TIME ) ) { if( m_bSoundDamped ) StartSound( "snd_shatter_damped", SND_CHANNEL_ANY, 0, false, NULL ); else StartSound( "snd_shatter", SND_CHANNEL_ANY, 0, false, NULL ); } if ( !IsBroken() ) { Break(); } if ( fxFracture.Length() ) { idEntityFx::StartFx( fxFracture, &point, &GetPhysics()->GetAxis(), this, true ); } dir = impulse; m = dir.Normalize(); for ( i = 0; i < shards.Num(); i++ ) { shard = shards[i]; if ( shard->droppedTime != -1 ) { continue; } if ( ( shard->clipModel->GetOrigin() - point ).LengthSqr() > Square( maxShatterRadius ) ) { continue; } DropShard( shard, point, dir, m, time ); } DropFloatingIslands( point, impulse, time ); }
END_CLASS_STATES /* ================ rvHealingStation::State_Healing ================ */ stateResult_t rvHealingStation::State_Healing ( const stateParms_t& parms ) { enum { STAGE_INIT, STAGE_WAIT, STAGE_DISPENSE, }; if ( entityToHeal.IsValid() ) { idPlayer* player = static_cast<idPlayer*>( entityToHeal.GetEntity( ) ); const int entityMaxHealth = player->inventory.maxHealth; if ( healthDispensed < maxHealth && // and we have health to dispense... entityToHeal->health < entityMaxHealth && // and the entity needs health. entityToHeal->health > 0 ) // and he's still alive. { switch ( parms.stage ) { case STAGE_INIT: soundStartTime = gameLocal.time; StartSound( "snd_start", SND_CHANNEL_ANY, 0, false, &soundLength ); return SRESULT_STAGE ( STAGE_WAIT ); case STAGE_WAIT: if ( gameLocal.time > soundStartTime + soundLength ) { soundStartTime = 0; soundLength = 0; return SRESULT_STAGE ( STAGE_DISPENSE ); } return SRESULT_WAIT; case STAGE_DISPENSE: if ( gameLocal.time > nextHealTime ) { // If it's time to heal... int healthGiven = Min( maxHealth - healthDispensed, Min( healAmount, entityMaxHealth - entityToHeal->health ) ); entityToHeal->health += healthGiven; healthDispensed += healthGiven; nextHealTime = gameLocal.time + healFrequency; } if ( !IsPlaying ( ) ) { StartSound( "snd_loop", SND_CHANNEL_ANY, 0, false, NULL ); } return SRESULT_WAIT; } } } StopSound ( SND_CHANNEL_ANY, 0 ); StartSound ( "snd_stop", SND_CHANNEL_ANY, 0, false, NULL ); return SRESULT_DONE; }
/* ================ rvWeaponGauntlet::State_Fire ================ */ stateResult_t rvWeaponGauntlet::State_Fire( const stateParms_t& parms ) { enum { STAGE_START, STAGE_START_WAIT, STAGE_LOOP, STAGE_LOOP_WAIT, STAGE_END, STAGE_END_WAIT }; switch ( parms.stage ) { case STAGE_START: PlayAnim( ANIMCHANNEL_ALL, "attack_start", parms.blendFrames ); StartBlade(); loopSound = LOOP_NONE; // #32 - no gauntlet spin up //return SRESULT_STAGE( STAGE_START_WAIT ); return SRESULT_STAGE( STAGE_LOOP ); case STAGE_START_WAIT: if ( !wsfl.attack ) { return SRESULT_STAGE( STAGE_END ); } if ( AnimDone( ANIMCHANNEL_ALL, parms.blendFrames ) ) { return SRESULT_STAGE( STAGE_LOOP ); } return SRESULT_WAIT; case STAGE_LOOP: PlayCycle( ANIMCHANNEL_ALL, "attack_loop", parms.blendFrames ); StartSound( "snd_spin_loop", SND_CHANNEL_WEAPON, 0, false, 0 ); return SRESULT_STAGE(STAGE_LOOP_WAIT); case STAGE_LOOP_WAIT: if ( !wsfl.attack || wsfl.lowerWeapon ) { return SRESULT_STAGE( STAGE_END ); } Attack(); return SRESULT_WAIT; case STAGE_END: PlayAnim( ANIMCHANNEL_ALL, "attack_end", parms.blendFrames ); StopBlade(); StartSound( "snd_spin_down", SND_CHANNEL_WEAPON, 0, false, 0 ); return SRESULT_STAGE( STAGE_END_WAIT ); case STAGE_END_WAIT: if ( wsfl.attack || AnimDone( ANIMCHANNEL_ALL, parms.blendFrames ) ) { PostState( "Idle", parms.blendFrames ); return SRESULT_DONE; } return SRESULT_WAIT; } return SRESULT_ERROR; }
void hhBlackJack::AssessScores() { if (PlayerScore > 21) { creditsWon = -Bet; resultIndex = BJRESULT_BUST; } else if (DealerScore > 21) { creditsWon = Bet; resultIndex = BJRESULT_WIN; } else if (PlayerScore == 21 && PlayerHand.Num() == 2) { // BlackJack creditsWon = Bet * 2; resultIndex = BJRESULT_BLACKJACK; } else if (PlayerScore <= 21 && PlayerHand.Num() == 5) { creditsWon = Bet * 5; resultIndex = BJRESULT_5CARD; } else if (DealerScore > PlayerScore) { creditsWon = -Bet; resultIndex = BJRESULT_LOSE; } else if (PlayerScore > DealerScore) { creditsWon = Bet; resultIndex = BJRESULT_WIN; } else { // Push creditsWon = 0; resultIndex = BJRESULT_PUSH; } PlayerCredits += creditsWon; PlayerCredits = idMath::ClampInt(0, 999999999, PlayerCredits); Bet = PlayerBet; // Play victory/failure sound if (victoryAmount && PlayerCredits >= victoryAmount) { StartSound( "snd_victory", SND_CHANNEL_ANY, 0, true, NULL ); ActivateTargets( gameLocal.GetLocalPlayer() ); victoryAmount = 0; } else if (creditsWon > 0) { StartSound( "snd_win", SND_CHANNEL_ANY, 0, true, NULL ); } else if (creditsWon < 0) { StartSound( "snd_lose", SND_CHANNEL_ANY, 0, true, NULL ); } }
/* ================= idMoveable::Collide ================= */ impactEffect_t idMoveable::Collide( const trace_t &collision, const idVec3 &velocity ) { float v, f; idVec3 dir; idEntity *ent; v = -( velocity * collision.c.normal ); if ( v > BOUNCE_SOUND_MIN_VELOCITY && gameLocal.time > nextSoundTime ) { f = v > BOUNCE_SOUND_MAX_VELOCITY ? 1.0f : idMath::Sqrt( v - BOUNCE_SOUND_MIN_VELOCITY ) * ( 1.0f / idMath::Sqrt( BOUNCE_SOUND_MAX_VELOCITY - BOUNCE_SOUND_MIN_VELOCITY ) ); if ( StartSound( "snd_bounce", SND_CHANNEL_ANY, 0, false, NULL ) ) { // don't set the volume unless there is a bounce sound as it overrides the entire channel // which causes footsteps on ai's to not honor their shader parms SetSoundVolume( f ); } nextSoundTime = gameLocal.time + 500; } if ( !gameLocal.isClient && canDamage && gameLocal.time > nextDamageTime ) { bool hasDamage = damage.Length() > 0; bool hasMonsterDamage = monsterDamage.Length() > 0; if ( hasDamage || hasMonsterDamage ) { ent = gameLocal.entities[ collision.c.entityNum ]; if ( ent && v > minDamageVelocity ) { f = v > maxDamageVelocity ? 1.0f : idMath::Sqrt( (v - minDamageVelocity) / (maxDamageVelocity - minDamageVelocity) ); dir = velocity; dir.Normalize(); //c4tnt: more precision if ( ent->IsType( idAI::Type ) && hasMonsterDamage ) { if ( attacker ) { ent->Damage( this, attacker, dir, monsterDamage, f, INVALID_JOINT ); } else { ent->Damage( this, GetPhysics()->GetClipModel()->GetOwner(), dir, monsterDamage, f, INVALID_JOINT ); } } else if ( hasDamage ) { // in multiplayer, scale damage wrt mass of object if ( gameLocal.isMultiplayer ) { f *= GetPhysics()->GetMass() * g_moveableDamageScale.GetFloat(); } if ( attacker ) { ent->Damage( this, attacker, dir, damage, f, INVALID_JOINT ); } else { ent->Damage( this, GetPhysics()->GetClipModel()->GetOwner(), dir, damage, f, INVALID_JOINT ); } } nextDamageTime = gameLocal.time + 1000; } } } if ( fxCollide.Length() && gameLocal.time > nextCollideFxTime ) { idEntityFx::StartFx( fxCollide, &collision.c.point, NULL, this, false ); nextCollideFxTime = gameLocal.time + 3500; } return IMP_BOUNCE; }
/* * make a sound like thunder * this function is called after each time BoltSound is called */ static void BoomSound() /*********************/ { short i; short low; short high; StopSound(); SetVoiceQueueSize( 1, 600 ); SetVoiceAccent( 1, 120, 50, S_STACCATO, 0 ); for( i=0; i < 1000; i++ ) { /* * create a random low-pitched sound */ high = rand() % 200 + 1; low = rand() % high + 1; SetVoiceSound( 1, MAKELONG( low, high ), 1 ); } StartSound(); WaitSoundState( S_QUEUEEMPTY ); /* wait for the sound to finish */ StopSound(); CloseSound(); } /* BoomSound */
/* ================ rvMonsterStroggHover::DoNamedAttack ================ */ void rvMonsterStroggHover::DoNamedAttack ( const char* attackName, jointHandle_t joint ) { if ( joint != INVALID_JOINT ) { StartSound ( va("snd_%s_fire",attackName), SND_CHANNEL_ANY, 0, false, NULL ); PlayEffect ( va("fx_%s_flash",attackName), joint ); Attack ( attackName, joint, GetEnemy() ); } }
void hhGibbable::Explode(idEntity *activator) { hhFxInfo fxInfo; Hide(); fl.takedamage = false; GetPhysics()->SetContents( 0 ); ActivateTargets( activator ); SetSkinByName(NULL); if ( spawnArgs.GetFloat( "respawn", "0" ) ) { PostEventSec( &EV_Respawn, spawnArgs.GetFloat( "respawn", "0" ) ); } else { PostEventMS( &EV_Remove, 200 ); // Remove after a small delay to allow sound commands to execute } StartSound( "snd_gib", SND_CHANNEL_ANY ); // Find thinnest axis in the bounds and use for fx normal idVec3 thinnest = vec3_origin; int axisIndex = DetermineThinnestAxis(); thinnest[axisIndex] = 1.0f; thinnest *= GetAxis(); fxInfo.RemoveWhenDone( true ); fxInfo.SetNormal(thinnest); // Spawn FX system for gib BroadcastFxInfo( spawnArgs.GetString("fx_gib"), GetOrigin(), GetAxis(), &fxInfo ); // Spawn gibs if (spawnArgs.FindKey("def_debrisspawner")) { hhUtils::SpawnDebrisMass(spawnArgs.GetString("def_debrisspawner"), this ); } }
void RotatingWorldModel::Load(HMESSAGEREAD hRead, uint32 dwLoadFlags) { if (!hRead) return; g_pLTServer->ReadFromMessageVector(hRead, &m_vVelocity); g_pLTServer->ReadFromMessageVector(hRead, &m_vSaveVelocity); g_pLTServer->ReadFromMessageVector(hRead, &m_vSign); g_pLTServer->ReadFromMessageVector(hRead, &m_vSpinUpTime); g_pLTServer->ReadFromMessageVector(hRead, &m_vSpinDownTime); g_pLTServer->ReadFromMessageVector(hRead, &m_vSpinTimeLeft); m_fLastTime = g_pLTServer->ReadFromMessageFloat(hRead); m_fStartTime = g_pLTServer->ReadFromMessageFloat(hRead); m_fPitch = g_pLTServer->ReadFromMessageFloat(hRead); m_fYaw = g_pLTServer->ReadFromMessageFloat(hRead); m_fRoll = g_pLTServer->ReadFromMessageFloat(hRead); m_fSoundRadius = g_pLTServer->ReadFromMessageFloat(hRead); m_eState = (RWMState) g_pLTServer->ReadFromMessageByte(hRead); m_bBoxPhysics = (LTBOOL) g_pLTServer->ReadFromMessageByte(hRead); m_hstrBusySound = g_pLTServer->ReadFromMessageHString(hRead); m_hstrSpinUpSound = g_pLTServer->ReadFromMessageHString(hRead); m_hstrSpinDownSound = g_pLTServer->ReadFromMessageHString(hRead); m_hShadowLightsString = g_pLTServer->ReadFromMessageHString(hRead); m_nShadowAxis = g_pLTServer->ReadFromMessageDWord(hRead); if (m_eState == RWM_NORMAL) { StartSound(m_hstrBusySound, LTTRUE); } }
END_CLASS void hhShuttleTransport::Spawn() { dockingBeam = NULL; dockedShuttle = NULL; shuttleCount = 0; bLocked = false; amountHealth = spawnArgs.GetInt("amounthealth"); amountPower = spawnArgs.GetInt("amountpower"); bCanExitLocked = spawnArgs.GetBool("canExitLocked"); bLockOnEntry = spawnArgs.GetBool("lockOnEntry"); bAllowFiring = spawnArgs.GetBool("allowFiring"); offsetNozzle = spawnArgs.GetVector("offset_nozzle1"); // offsetNozzle2 = spawnArgs.GetVector("offset_nozzle2"); offsetShuttlePoint = spawnArgs.GetVector("offset_shuttlepoint"); // dockingBeam = SpawnDockingBeam(offsetNozzle); dockingForce.SetRestoreFactor(spawnArgs.GetFloat("dockingforce")); dockingForce.SetTarget(GetOrigin() + offsetShuttlePoint * GetAxis()); // Fade in SetShaderParm(SHADERPARM_TIMEOFFSET, -MS2SEC(gameLocal.time)); // Growth start time SetShaderParm(5, 1.0f); // Growth direction (in) SetShaderParm(6, 1.0f); // Make Beam opaque StartSound("snd_fadein", SND_CHANNEL_ANY); }
//-------------------------------- // hhProxDoor::Event_Touch //-------------------------------- void hhProxDoor::Event_Touch( idEntity *other, trace_t *trace ) { if ( sndTrigger && trace->c.id == sndTrigger->GetId() ) { if (other && other->IsType(hhPlayer::Type) && IsLocked() && gameLocal.time > nextSndTriggerTime) { StartSound("snd_locked", SND_CHANNEL_ANY, 0, false, NULL ); nextSndTriggerTime = gameLocal.time + 10000; } return; } if( proxState == PROXSTATE_Active ) { return; } if ( !other ) { gameLocal.Warning("hhProxDoor: Event_Touch given NULL for other\n"); return; } float dist = ( other->GetOrigin() - GetOrigin() ).Length(); if (dist > movementDistance) { return; } if( !IsLocked() ) { SetDoorState( PROXSTATE_Active ); } }
/* ================= hhProjectileCrawlerGrenade::EnterDyingState ================= */ void hhProjectileCrawlerGrenade::EnterDyingState() { state = StateDying; modelScale.Init( gameLocal.GetTime(), inflateDuration, modelScale.GetCurrentValue(gameLocal.GetTime()), spawnArgs.GetFloat("inflateScale") ); StartSound( "snd_expand_screech", SND_CHANNEL_VOICE, 0, true, NULL ); ProcessEvent( &EV_ApplyExpandWound ); }
/* ================= hhProjectileCrawlerGrenade::Event_Collision_Bounce ================= */ void hhProjectileCrawlerGrenade::Event_Collision_Bounce( const trace_t* collision, const idVec3 &velocity ) { static const float minCollisionVelocity = 20.0f; static const float maxCollisionVelocity = 90.0f; StopSound( SND_CHANNEL_BODY, true ); // Velocity in normal direction float len = velocity * -collision->c.normal; if( collision->fraction < VECTOR_EPSILON || len < minCollisionVelocity ) { idThread::ReturnInt( 0 ); return; } StartSound( "snd_bounce", SND_CHANNEL_BODY, 0, true, NULL ); float volume = hhUtils::CalculateSoundVolume( len, minCollisionVelocity, maxCollisionVelocity ); HH_SetSoundVolume( volume, SND_CHANNEL_BODY ); BounceSplat( GetOrigin(), -collision->c.normal ); SIMDProcessor->Memcpy( &collisionInfo, collision, sizeof(trace_t) ); collisionInfo.fraction = 0.0f;//Sometimes fraction == 1.0f physicsObj.SetAngularVelocity( 0.5f*physicsObj.GetAngularVelocity() ); idThread::ReturnInt( 0 ); }
void playSound(unsigned int soundByte) { if (soundIndex >= soundLength && sound_on == 1) //Sound is not playing { soundIndex = 0; if (soundByte == 0) { BlockDestroyedSound(); } else if (soundByte == 1) { FireProjectileSound(); } else if (soundByte == 2) { BombDropSound(); } else if (soundByte == 3) { PhaserSound(); } else if (soundByte == 4) { PhotonSound(); } sound.duration.Enabled = 0; StartSound(frequencies[soundIndex], durations[soundIndex]); } }
/* ================ idExplodingBarrel::ExplodingEffects ================ */ void idExplodingBarrel::ExplodingEffects( void ) { const char *temp; StartSound( "snd_explode", SND_CHANNEL_ANY, 0, false, NULL ); temp = spawnArgs.GetString( "model_damage" ); if ( *temp != '\0' ) { SetModel( temp ); Show(); } temp = spawnArgs.GetString( "model_detonate" ); if ( *temp != '\0' ) { AddParticles( temp, false ); } temp = spawnArgs.GetString( "mtr_lightexplode" ); if ( *temp != '\0' ) { AddLight( temp, false ); } temp = spawnArgs.GetString( "mtr_burnmark" ); if ( *temp != '\0' ) { gameLocal.ProjectDecal( GetPhysics()->GetOrigin(), GetPhysics()->GetGravity(), 128.0f, true, 96.0f, temp ); } }
/* ================= idMoveable::Collide ================= */ bool idMoveable::Collide( const trace_t &collision, const idVec3 &velocity ) { float v, f; idVec3 dir; idEntity *ent; v = -( velocity * collision.c.normal ); if ( v > BOUNCE_SOUND_MIN_VELOCITY && gameLocal.time > nextSoundTime ) { f = v > BOUNCE_SOUND_MAX_VELOCITY ? 1.0f : idMath::Sqrt( v - BOUNCE_SOUND_MIN_VELOCITY ) * ( 1.0f / idMath::Sqrt( BOUNCE_SOUND_MAX_VELOCITY - BOUNCE_SOUND_MIN_VELOCITY ) ); if ( StartSound( "snd_bounce", SND_CHANNEL_ANY, 0, false, NULL ) ) { // don't set the volume unless there is a bounce sound as it overrides the entire channel // which causes footsteps on ai's to not honor their shader parms SetSoundVolume( f ); } nextSoundTime = gameLocal.time + 500; } if ( canDamage && damage.Length() && gameLocal.time > nextDamageTime ) { ent = gameLocal.entities[ collision.c.entityNum ]; if ( ent && v > minDamageVelocity ) { f = v > maxDamageVelocity ? 1.0f : idMath::Sqrt( v - minDamageVelocity ) * ( 1.0f / idMath::Sqrt( maxDamageVelocity - minDamageVelocity ) ); dir = velocity; dir.NormalizeFast(); ent->Damage( this, GetPhysics()->GetClipModel()->GetOwner(), dir, damage, f, INVALID_JOINT ); nextDamageTime = gameLocal.time + 1000; } } if ( fxCollide.Length() && gameLocal.time > nextCollideFxTime ) { idEntityFx::StartFx( fxCollide, &collision.c.point, NULL, this, false ); nextCollideFxTime = gameLocal.time + 3500; } return false; }
/* ================ idItem::ClientReceiveEvent ================ */ bool idItem::ClientReceiveEvent(int event, int time, const idBitMsg &msg) { switch (event) { case EVENT_PICKUP: { // play pickup sound StartSound("snd_acquire", SND_CHANNEL_ITEM, 0, false, NULL); // hide the model Hide(); // remove the highlight shell if (itemShellHandle != -1) { gameRenderWorld->FreeEntityDef(itemShellHandle); itemShellHandle = -1; } return true; } case EVENT_RESPAWN: { Event_Respawn(); return true; } case EVENT_RESPAWNFX: { Event_RespawnFx(); return true; } default: { return idEntity::ClientReceiveEvent(event, time, msg); } } return false; }
void hhShuttleForceField::ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &force ) { trace_t trace; idStr fxCollide = spawnArgs.GetString( "fx_collide" ); if ( fxCollide.Length() && gameLocal.time > nextCollideFxTime && point != GetOrigin()) { // Trace to find normal idVec3 dir = force; dir.NormalizeFast(); dir *= 200; idVec3 start = point-dir; idVec3 end = point+dir; memset(&trace, 0, sizeof(trace)); gameLocal.clip.TracePoint(trace, start, end, CONTENTS_SOLID, ent); if (trace.fraction < 1.0f) { // Spawn fx oriented to normal of collision hhFxInfo fxInfo; fxInfo.SetNormal( trace.c.normal ); BroadcastFxInfo( fxCollide, trace.c.point, mat3_identity, &fxInfo ); nextCollideFxTime = gameLocal.time + 200; StartSound( "snd_collide", SND_CHANNEL_ANY, 0, true, NULL ); ActivatePrefixed( "triggerCollide", this ); // bg: Feedback hook. } } }
LTBOOL CSteamFX::Update() { if (m_bWantRemove) return LTFALSE; // Debugging aid... if (s_cvarTweak.GetFloat() > 0) { TweakSystem(); } // Start/stop steam sound if necessary... if (m_hServerObject) { uint32 dwUserFlags; g_pLTClient->GetObjectUserFlags(m_hServerObject, &dwUserFlags); if (!(dwUserFlags & USRFLG_VISIBLE)) { if ((m_dwLastUserFlags & USRFLG_VISIBLE)) { StopSound(); } } else // visible { if (!(m_dwLastUserFlags & USRFLG_VISIBLE)) { StartSound(); } } m_dwLastUserFlags = dwUserFlags; // Make sure the sound is in the correct place (in case we are getting // keyframed)... if (m_hSound) { LTVector vPos; g_pLTClient->GetObjectPos(m_hServerObject, &vPos); g_pLTClient->SetSoundPosition(m_hSound, &vPos); } // Update the steam velocity based on our current rotation (again // for keyframing)... LTRotation rRot; g_pLTClient->GetObjectRotation(m_hServerObject, &rRot); LTVector vU, vR, vF; g_pLTClient->GetRotationVectors(&rRot, &vU, &vR, &vF); m_Steam.SetDriftVel(vF * (m_cs.fVel * 0.75f), vF * m_cs.fVel); } return m_Steam.Update(); }
/* =========== hhForceField::ApplyImpulse =========== */ void hhForceField::ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &force ) { if (!ent->IsType(idActor::Type)) { // Don't play sound for actor footsteps, landings. They play their own localized sounds for // the sake of very large forcefields. StartSound( "snd_impulse", SND_CHANNEL_ANY ); } EnterDamagedState(); // Apply the hit effect trace_t trace; idStr fxCollide = spawnArgs.GetString( "fx_collide" ); if ( fxCollide.Length() && gameLocal.time > nextCollideFxTime && point != GetOrigin()) { // Trace to find normal idVec3 dir = force; dir.NormalizeFast(); dir *= 200; idVec3 start = point-dir; idVec3 end = point+dir; memset(&trace, 0, sizeof(trace)); gameLocal.clip.TracePoint(trace, start, end, CONTENTS_FORCEFIELD, ent); if (trace.fraction < 1.0f) { // Spawn fx oriented to normal of collision hhFxInfo fxInfo; fxInfo.SetNormal( trace.c.normal ); BroadcastFxInfo( fxCollide, trace.c.point, mat3_identity, &fxInfo, 0, false ); //rww - changed to not broadcast nextCollideFxTime = gameLocal.time + 200; } } }
void RotatingWorldModel::SetNormalRotation() { m_eState = RWM_NORMAL; m_fLastTime = g_pLTServer->GetTime(); StartSound(m_hstrBusySound, LTTRUE); }
/* ================ idSecurityCamera::Event_Pause ================ */ void idSecurityCamera::Event_Pause( void ) { float sweepWait; sweepWait = spawnArgs.GetFloat( "sweepWait", "0.5" ); sweeping = false; StopSound( SND_CHANNEL_ANY, false ); StartSound( "snd_stop", SND_CHANNEL_BODY, 0, false, NULL ); PostEventSec( &EV_SecurityCam_ReverseSweep, sweepWait ); }
int CFrobLock::FrobLockStartSound(const char* soundName) { // Default implementation: Just play the sound on this entity. int length = 0; StartSound(soundName, SND_CHANNEL_ANY, 0, false, &length); return length; }
/* =========== hhForceField::EnterTurningOnState =========== */ void hhForceField::EnterTurningOnState() { GetPhysics()->SetContents( cachedContents ); SetSkin( NULL ); StartSound( "snd_start", SND_CHANNEL_ANY ); Show(); BecomeActive( TH_TICKER ); }
END_CLASS_STATES /* ================ rvMonsterConvoyGround::State_Fall ================ */ stateResult_t rvMonsterConvoyGround::State_Fall ( const stateParms_t& parms ) { enum { STAGE_INIT, // Initialize fall stage STAGE_WAITIMPACT, // Wait for the drop turret to hit the ground STAGE_IMPACT, // Handle drop turret impact, switch to combat state STAGE_WAITDONE, STAGE_DONE }; switch ( parms.stage ) { case STAGE_INIT: StopMove ( MOVE_STATUS_DONE ); StopAnimState ( ANIMCHANNEL_LEGS ); StopAnimState ( ANIMCHANNEL_TORSO ); StartSound ( "snd_falling", SND_CHANNEL_VOICE, 0, false, NULL ); PlayEffect ( "fx_droptrail", animator.GetJointHandle ( "origin" ), true ); DisableAnimState ( ANIMCHANNEL_LEGS ); PlayCycle ( ANIMCHANNEL_TORSO, "idle", 0 ); oldOrigin = physicsObj.GetOrigin ( ); return SRESULT_STAGE(STAGE_WAITIMPACT); case STAGE_WAITIMPACT: if ( physicsObj.HasGroundContacts ( ) ) { return SRESULT_STAGE(STAGE_IMPACT); } return SRESULT_WAIT; case STAGE_IMPACT: StopSound ( SND_CHANNEL_VOICE, false ); StopEffect ( "fx_droptrail" ); PlayEffect ( "fx_landing", GetPhysics()->GetOrigin(), (-GetPhysics()->GetGravityNormal()).ToMat3() ); if ( (physicsObj.GetOrigin ( ) - oldOrigin).LengthSqr() > Square(128.0f) ) { PlayAnim ( ANIMCHANNEL_TORSO, "land", 0 ); return SRESULT_STAGE ( STAGE_WAITDONE ); } return SRESULT_STAGE ( STAGE_DONE ); case STAGE_WAITDONE: if ( AnimDone ( ANIMCHANNEL_TORSO, 4 ) ) { return SRESULT_STAGE ( STAGE_DONE ); } return SRESULT_WAIT; case STAGE_DONE: onGround = true; SetAnimState ( ANIMCHANNEL_LEGS, "Legs_Idle" ); SetAnimState ( ANIMCHANNEL_TORSO, "Torso_Idle" ); return SRESULT_DONE; } return SRESULT_ERROR; }
/* ================ rvMonsterConvoyGround::State_Legs_Move ================ */ stateResult_t rvMonsterConvoyGround::State_Legs_Move ( const stateParms_t& parms ) { enum { STAGE_INIT, STAGE_MOVE }; switch ( parms.stage ) { case STAGE_INIT: move.fl.allowAnimMove = true; move.fl.allowPrevAnimMove = false; move.fl.running = true; move.currentDirection = MOVEDIR_FORWARD; // TODO: Looks like current anim rate never gets reset, so they do not correctly accelerate from a stop // unfortunately, adding this change (with a decent acceleration factor) caused them to do lots of // not-so-good looking short moves. // moveCurrentAnimRate = 0; oldOrigin = physicsObj.GetOrigin ( ); PlayCycle ( ANIMCHANNEL_LEGS, "run", 0 ); StartSound( "snd_move", SND_CHANNEL_BODY3, 0, false, NULL ); return SRESULT_STAGE ( STAGE_MOVE ); case STAGE_MOVE: // If not moving forward just go back to idle if ( !move.fl.moving || !CanMove() ) { StopSound( SND_CHANNEL_BODY3, 0 ); PostAnimState ( ANIMCHANNEL_LEGS, "Legs_Idle", 0 ); return SRESULT_DONE; } // If on the ground update the animation rate based on the normal of the ground plane if ( !ai_debugHelpers.GetBool ( ) && physicsObj.HasGroundContacts ( ) ) { float rate; idVec3 dir; dir = (physicsObj.GetOrigin ( ) - oldOrigin); if ( DistanceTo ( move.moveDest ) < move.walkRange ) { rate = moveAnimRateMin; } else if ( dir.Normalize ( ) > 0.0f ) { rate = idMath::ClampFloat ( -0.7f, 0.7f, physicsObj.GetGravityNormal ( ) * dir ) / 0.7f; rate = moveAnimRateMin + moveAnimRateRange * (1.0f + rate) / 2.0f; } else { rate = moveAnimRateMin + moveAnimRateRange * 0.5f; } moveCurrentAnimRate += ((rate - moveCurrentAnimRate) * moveAccelRate); animator.CurrentAnim ( ANIMCHANNEL_LEGS )->SetPlaybackRate ( gameLocal.time, moveCurrentAnimRate ); } oldOrigin = physicsObj.GetOrigin ( ); return SRESULT_WAIT; } return SRESULT_ERROR; }