/* ================ idEntityFx::ResetShaderParms ================ */ void idEntityFx::ResetShaderParms( void ) { if ( !fxEffect ) { return; } for( int i = 0; i < fxEffect->events.Num(); i++ ) { const idFXSingleAction& fxaction = fxEffect->events[i]; idFXLocalAction& laction = actions[i]; if ( laction.lightDefHandle != -1 && fxaction.sibling == -1 && fxaction.type != FX_ATTACHLIGHT ) { laction.renderLight.shaderParms[ SHADERPARM_RED ] = fxaction.lightColor.x; laction.renderLight.shaderParms[ SHADERPARM_GREEN ] = fxaction.lightColor.y; laction.renderLight.shaderParms[ SHADERPARM_BLUE ] = fxaction.lightColor.z; laction.renderLight.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.time ); } if ( laction.modelDefHandle != -1 && fxaction.sibling == -1 && fxaction.type != FX_ATTACHENTITY ) { laction.renderEntity.shaderParms[ SHADERPARM_RED ] = 1.0f; laction.renderEntity.shaderParms[ SHADERPARM_GREEN ] = 1.0f; laction.renderEntity.shaderParms[ SHADERPARM_BLUE ] = 1.0f; if( manualFadeIsOn ){ //no need to reset it if we are not fading - this would make the particle to change position instantly laction.renderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.time ); } laction.renderEntity.shaderParms[ SHADERPARM_PARTICLE_STOPTIME ] = 0; //make particles to appear } } }
/* ================ sdVehiclePosition::UpdateIK ================ */ void sdVehiclePosition::UpdateIK( void ) { if ( transport->GetInput().GetSteerAngle() > 0 ) { currentViewOffset += viewOffsetRate * MS2SEC( gameLocal.msec ); if ( currentViewOffset > 1.f ) { currentViewOffset = 1.f; } } else if ( transport->GetInput().GetSteerAngle() < 0 ) { currentViewOffset -= viewOffsetRate * MS2SEC( gameLocal.msec ); if ( currentViewOffset < -1.f ) { currentViewOffset = -1.f; } } else { currentViewOffset -= Min( idMath::Fabs( currentViewOffset ), viewOffsetRate * MS2SEC( gameLocal.msec ) ) * idMath::Sign( currentViewOffset ); } if ( !gameLocal.isClient ) { if ( minZfrac != -2.f && transport->GetPhysics()->GetAxis()[ 2 ].z < minZfrac ) { transport->GetPositionManager().EjectPlayer( *this, true ); } } currentViewOffsetAngles = ( idMath::Cos( DEG2RAD( ( currentViewOffset * 180 ) + 180 ) ) + 1 ) * 0.5f * idMath::Sign( currentViewOffset ) * maxViewOffset; for ( int i = 0; i < ikSystems.Num(); i++ ) { ikSystems[ i ]->Update(); } }
/* ================ sdDeliveryVehicle::Jotun_Think ================ */ void sdDeliveryVehicle::Jotun_Think( void ) { if ( deliveryMode == DMODE_NONE || gameLocal.IsPaused() ) { return; } if ( PathGetNumPoints() < 2 ) { return; } float time = MS2SEC( gameLocal.time - modeStartTime ); float frameTime = MS2SEC( gameLocal.msec ); float aheadPosition = ( time + leadTime ) * pathSpeed; // look ahead by a couple of seconds idVec3 aheadPoint; idVec3 aheadPointDir; PathGetPosition( aheadPosition, aheadPoint ); PathGetDirection( aheadPosition, aheadPointDir ); aheadPoint.z += JOTUN_FLY_HEIGHT; if ( deliveryMode == DMODE_DELIVER ) { bool levelOut = false; if ( aheadPosition > pathLength - 10000.0f ) { levelOut = true; } Jotun_DoMove( aheadPoint, aheadPointDir, endPoint, levelOut, false, pathSpeed ); } else if ( deliveryMode == DMODE_RETURN ) { Jotun_DoMove( aheadPoint, aheadPointDir, endPoint, false, true, pathSpeed ); } }
/* ================ rvClientEffect::Play ================ */ bool rvClientEffect::Play ( int _startTime, bool _loop, const idVec3& endOrigin ) { if ( !renderEffect.declEffect ) { return false; } // Initialize the render entity if ( bindMaster ) { renderEntity_t* renderEnt = bindMaster->GetRenderEntity ( ); assert( renderEnt ); // Copy suppress values from parent entity renderEffect.allowSurfaceInViewID = renderEnt->allowSurfaceInViewID; renderEffect.suppressSurfaceInViewID = renderEnt->suppressSurfaceInViewID; renderEffect.weaponDepthHackInViewID = renderEnt->weaponDepthHackInViewID; } renderEffect.shaderParms[SHADERPARM_RED] = 1.0f; renderEffect.shaderParms[SHADERPARM_GREEN] = 1.0f; renderEffect.shaderParms[SHADERPARM_BLUE] = 1.0f; renderEffect.shaderParms[SHADERPARM_ALPHA] = 1.0f; renderEffect.shaderParms[SHADERPARM_BRIGHTNESS] = 1.0f; renderEffect.shaderParms[SHADERPARM_TIMEOFFSET] = MS2SEC( gameLocal.time ); renderEffect.hasEndOrigin = ( endOrigin != vec3_origin ); renderEffect.endOrigin = endOrigin; renderEffect.loop = _loop; assert( effectDefHandle < 0 ); renderEffect.startTime = MS2SEC( _startTime ); return true; }
/* ================ idLight::BecomeBroken ================ */ void idLight::BecomeBroken( idEntity *activator ) { const char *damageDefName; fl.takedamage = false; if ( brokenModel.Length() ) { SetModel( brokenModel ); if ( !spawnArgs.GetBool( "nonsolid" ) ) { GetPhysics()->SetClipModel( new idClipModel( brokenModel.c_str() ), 1.0f ); GetPhysics()->SetContents( CONTENTS_SOLID ); } } else if ( spawnArgs.GetBool( "hideModelOnBreak" ) ) { SetModel( "" ); GetPhysics()->SetContents( 0 ); } if ( gameLocal.isServer ) { ServerSendEvent( EVENT_BECOMEBROKEN, NULL, true, -1 ); if ( spawnArgs.GetString( "def_damage", "", &damageDefName ) ) { idVec3 origin = renderEntity.origin + renderEntity.bounds.GetCenter() * renderEntity.axis; gameLocal.RadiusDamage( origin, activator, activator, this, this, damageDefName ); } } ActivateTargets( activator ); // offset the start time of the shader to sync it to the game time renderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.time ); renderLight.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.time ); // set the state parm renderEntity.shaderParms[ SHADERPARM_MODE ] = 1; renderLight.shaderParms[ SHADERPARM_MODE ] = 1; // if the light has a sound, either start the alternate (broken) sound, or stop the sound const char *parm = spawnArgs.GetString( "snd_broken" ); if ( refSound.shader || ( parm && *parm ) ) { StopSound( SND_CHANNEL_ANY, false ); const idSoundShader *alternate = refSound.shader ? refSound.shader->GetAltSound() : declManager->FindSound( parm ); if ( alternate ) { // start it with no diversity, so the leadin break sound plays refSound.referenceSound->StartSound( alternate, SND_CHANNEL_ANY, 0.0, 0 ); } } parm = spawnArgs.GetString( "mtr_broken" ); if ( parm && *parm ) { SetShader( parm ); } UpdateVisuals(); }
/* ================ sdDeliveryVehicle::Magog_Think ================ */ void sdDeliveryVehicle::Magog_Think() { int numPoints = PathGetNumPoints(); if ( numPoints < 2 ) { return; } if ( deliveryMode == DMODE_NONE || gameLocal.IsPaused() ) { return; } assert( gameLocal.msec != 0 ); float time = MS2SEC( gameLocal.time - modeStartTime ); float frameTime = MS2SEC( gameLocal.msec ); float position = time * pathSpeed; // look ahead by a couple of seconds float aheadPosition = position + leadTime * pathSpeed; idVec3 aheadPoint; idVec3 aheadPointDir; PathGetPosition( aheadPosition, aheadPoint ); PathGetDirection( aheadPosition, aheadPointDir ); bool approachingEnd = false; bool clampRoll = true; float yawScale = 1.0f; bool slowNearEnd = false; if ( deliveryMode == DMODE_DELIVER ) { slowNearEnd = true; if ( position > pathLength - 6000.0f ) { approachingEnd = true; clampRoll = false; // scale the max yaw yawScale = ( ( pathLength - position ) / 4096.0f ); yawScale = 5.0f - 5.0f * yawScale * yawScale * yawScale; yawScale = idMath::ClampFloat( 0.0f, 5.0f, yawScale ); } } else { aheadPoint.z += HOVER_HEIGHT_AIM; if ( position < 4096.0f ) { clampRoll = false; // scale the max yaw yawScale = ( 4096.0f - position ) / 4096.0f; yawScale = 5.0f - 5.0f * yawScale * yawScale * yawScale; yawScale = idMath::ClampFloat( 0.0f, 5.0f, yawScale ); } } Magog_DoMove( aheadPoint, aheadPointDir, endPoint, itemRotation, yawScale, approachingEnd, clampRoll, slowNearEnd, pathSpeed ); }
void hhDeathWraithEnergy::Ticker() { float theta; float radius; float z; if (!thePlayer.IsValid()) { return; } float alpha = (MS2SEC(gameLocal.time) - startTime) / duration; if (alpha < 1.0f) { if (thePlayer->DeathWalkStage2()) { SetOrigin( spline.GetValue(alpha) ); } else { radius = startRadius + alpha*(endRadius-startRadius); theta = startTheta + alpha*(endTheta-startTheta); z = startZ + alpha * (endZ - startZ); idVec3 locationRelativeToCenter = CylindricalToCartesian(radius, theta, z); idEntity *destEntity = thePlayer->GetDeathwalkEnergyDestination(); if (destEntity) { centerPosition = destEntity->GetOrigin(); } SetOrigin(centerPosition + locationRelativeToCenter); } } else if (!IsHidden()) { Hide(); StopSound(SND_CHANNEL_BODY); bool energyHealth = spawnArgs.GetBool("healthEnergy"); idEntity *dwProxy = thePlayer->GetDeathwalkEnergyDestination(); if (dwProxy) { // Spawn arrival effect StartSound("snd_arrival", SND_CHANNEL_ANY); dwProxy->SetShaderParm(SHADERPARM_TIMEOFFSET, -MS2SEC(gameLocal.time) ); dwProxy->SetShaderParm(SHADERPARM_MODE, energyHealth ? 2 : 1 ); } // Notify the player thePlayer->DeathWraithEnergyArived(energyHealth); PostEventMS(&EV_Remove, 5000); } hhPathEmitter::Ticker(); }
/* ================ idForce_Drag::Evaluate ================ */ void idForce_Drag::Evaluate( int time ) { float l1, l2, mass; idVec3 dragOrigin, dir1, dir2, velocity, centerOfMass; idMat3 inertiaTensor; idRotation rotation; idClipModel *clipModel; if ( !physics ) { return; } clipModel = physics->GetClipModel( id ); if ( clipModel != NULL && clipModel->IsTraceModel() ) { clipModel->GetMassProperties( 1.0f, mass, centerOfMass, inertiaTensor ); } else { centerOfMass.Zero(); } centerOfMass = physics->GetOrigin( id ) + centerOfMass * physics->GetAxis( id ); dragOrigin = physics->GetOrigin( id ) + p * physics->GetAxis( id ); dir1 = dragPosition - centerOfMass; dir2 = dragOrigin - centerOfMass; l1 = dir1.Normalize(); l2 = dir2.Normalize(); rotation.Set( centerOfMass, dir2.Cross( dir1 ), RAD2DEG( idMath::ACos( dir1 * dir2 ) ) ); physics->SetAngularVelocity( rotation.ToAngularVelocity() / MS2SEC( USERCMD_MSEC ), id ); velocity = physics->GetLinearVelocity( id ) * damping + dir1 * ( ( l1 - l2 ) * ( 1.0f - damping ) / MS2SEC( USERCMD_MSEC ) ); physics->SetLinearVelocity( velocity, id ); }
/* ================ sdEffect::Start ================ */ bool sdEffect::Start( int startTime ) { assert( !waitingToDie ); if ( effect.declEffect != NULL ) { if ( effectHandle == -1 ) { effect.shaderParms[SHADERPARM_TIMEOFFSET] = -MS2SEC( gameLocal.time ); effectHandle = gameRenderWorld->AddEffectDef( &effect, startTime ); effectStopped = false; } else if ( effectStopped ) { for ( int i = 0; i < waitingToDieList.Num(); i++ ) { if ( waitingToDieList[ i ].effectHandle == effectHandle ) { waitingToDieList.RemoveIndexFast( i ); break; } } waitingToDie = false; gameRenderWorld->RestartEffectDef( effectHandle ); effectStopped = false; } } if ( effectHandle != -1 ) { effectStopped = false; return true; } else { return false; } }
END_CLASS /* ================ idTarget_SetShaderTime::Event_Activate ================ */ void idTarget_SetShaderTime::Event_Activate( idEntity *activator ) { int i; idEntity *ent; float time; time = -MS2SEC( gameLocal.time ); for( i = 0; i < targets.Num(); i++ ) { ent = targets[ i ].GetEntity(); if( ent ) { ent->SetShaderParm( SHADERPARM_TIMEOFFSET, time ); if( ent->IsType( idLight::Type ) ) { static_cast<idLight *>( ent )->SetLightParm( SHADERPARM_TIMEOFFSET, time ); } } } }
/* ================ idExplodingBarrel::AddParticles ================ */ void idExplodingBarrel::AddParticles( const char *name, bool burn ) { if ( name && *name ) { if ( particleModelDefHandle >= 0 ){ gameRenderWorld->FreeEntityDef( particleModelDefHandle ); } memset( &particleRenderEntity, 0, sizeof ( particleRenderEntity ) ); const idDeclModelDef *modelDef = static_cast<const idDeclModelDef *>( declManager->FindType( DECL_MODELDEF, name ) ); if ( modelDef ) { particleRenderEntity.origin = physicsObj.GetAbsBounds().GetCenter(); particleRenderEntity.axis = mat3_identity; particleRenderEntity.hModel = modelDef->ModelHandle(); float rgb = ( burn ) ? 0.0f : 1.0f; particleRenderEntity.shaderParms[ SHADERPARM_RED ] = rgb; particleRenderEntity.shaderParms[ SHADERPARM_GREEN ] = rgb; particleRenderEntity.shaderParms[ SHADERPARM_BLUE ] = rgb; particleRenderEntity.shaderParms[ SHADERPARM_ALPHA ] = rgb; particleRenderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.realClientTime ); particleRenderEntity.shaderParms[ SHADERPARM_DIVERSITY ] = ( burn ) ? 1.0f : gameLocal.random.RandomInt( 90 ); particleRenderEntity.suppressSurfaceInViewID = -8; // sikk - Depth Render if ( !particleRenderEntity.hModel ) { particleRenderEntity.hModel = renderModelManager->FindModel( name ); } particleModelDefHandle = gameRenderWorld->AddEntityDef( &particleRenderEntity ); if ( burn ) { BecomeActive( TH_THINK ); } particleTime = gameLocal.realClientTime; } } }
/* ================ sdVehiclePosition::ClampAngle ================ */ bool sdVehiclePosition::ClampAngle( idAngles& newAngles, const idAngles& oldAngles, angleClamp_t clamp, int index, float epsilon ) { if ( clamp.flags.limitRate ) { float rate = clamp.rate[ 0 ] * MS2SEC( gameLocal.msec ); float diff = idMath::AngleDelta( newAngles[ index ], oldAngles[ index ] ); if( diff > rate ) { newAngles[ index ] = idMath::AngleNormalize180( oldAngles[ index ] + rate ); } else if ( diff < -rate ) { newAngles[ index ] = idMath::AngleNormalize180( oldAngles[ index ] - rate ); } } if ( clamp.flags.enabled ) { float mid = ( clamp.extents[ 0 ] + clamp.extents[ 1 ] ) * 0.5f; float range = ( clamp.extents[ 1 ] - clamp.extents[ 0 ] ) * 0.5f; float temp = idMath::AngleNormalize180( newAngles[ index ] - mid ); if ( temp < -range ) { temp = -range; } else if ( temp > range ) { temp = range; } newAngles[ index ] = temp + mid; } if ( epsilon <= 0.f ) { return newAngles[ index ] == oldAngles[ index ]; } return idMath::Fabs( newAngles[ index ] - oldAngles[ index ] ) < epsilon; }
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); }
/* ================ idEntityFx::SetupFade ================ */ void idEntityFx::SetupFade( void ) { int ieff; if ( !fxEffect ) { return; } for( ieff = 0; ieff < fxEffect->events.Num(); ieff++ ) { const idFXSingleAction& fxaction = fxEffect->events[ieff]; idFXLocalAction& laction = actions[ieff]; // turn on the waiting ones if ( laction.delay < 0 ) { laction.start = gameLocal.time; } // turn off the ones which are not endless else if( fxaction.duration != 0 ){ //duration = 0 means endless. Turn off -1 ones too! laction.start = -1; } //turn off particles if ( laction.modelDefHandle != -1 && fxaction.sibling == -1 && fxaction.type != FX_ATTACHENTITY ) { laction.renderEntity.shaderParms[ SHADERPARM_PARTICLE_STOPTIME ] = MS2SEC( gameLocal.time ); } } }
/* ================ idExplodingBarrel::AddParticles ================ */ void idExplodingBarrel::AddParticles( const char* name, bool burn ) { if( name && *name ) { int explicitTimeGroup = timeGroup; SetTimeState explicitTS( explicitTimeGroup ); if( particleModelDefHandle >= 0 ) { gameRenderWorld->FreeEntityDef( particleModelDefHandle ); } memset( &particleRenderEntity, 0, sizeof( particleRenderEntity ) ); idRenderModel* modelDef = renderModelManager->FindModel( name ); if( modelDef ) { particleRenderEntity.origin = physicsObj.GetAbsBounds().GetCenter(); particleRenderEntity.axis = mat3_identity; particleRenderEntity.hModel = modelDef; float rgb = ( burn ) ? 0.0f : 1.0f; particleRenderEntity.shaderParms[ SHADERPARM_RED ] = rgb; particleRenderEntity.shaderParms[ SHADERPARM_GREEN ] = rgb; particleRenderEntity.shaderParms[ SHADERPARM_BLUE ] = rgb; particleRenderEntity.shaderParms[ SHADERPARM_ALPHA ] = rgb; particleRenderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.realClientTime ); particleRenderEntity.shaderParms[ SHADERPARM_DIVERSITY ] = ( burn ) ? 1.0f : gameLocal.random.RandomInt( 90 ); particleRenderEntity.timeGroup = explicitTimeGroup; particleModelDefHandle = gameRenderWorld->AddEntityDef( &particleRenderEntity ); if( burn ) { BecomeActive( TH_THINK ); } particleTime = gameLocal.realClientTime; } } }
/* ================= idTestModel::TestModel_f Creates a static modelDef in front of the current position, which can then be moved around ================= */ void idTestModel::TestModel_f( const idCmdArgs &args ) { idVec3 offset; idStr name; idPlayer * player; const idDict * entityDef; idDict dict; player = gameLocal.GetLocalPlayer(); if ( !player || !gameLocal.CheatsOk() ) { return; } // delete the testModel if active if ( gameLocal.testmodel ) { delete gameLocal.testmodel; gameLocal.testmodel = NULL; } if ( args.Argc() < 2 ) { return; } name = args.Argv( 1 ); entityDef = gameLocal.FindEntityDefDict( name, false ); if ( entityDef ) { dict = *entityDef; } else { if ( declManager->FindType( DECL_MODELDEF, name, false ) ) { dict.Set( "model", name ); } else { // allow map models with underscore prefixes to be tested during development // without appending an ase if ( name[ 0 ] != '_' ) { name.DefaultFileExtension( ".ase" ); } if ( strstr( name, ".ma" ) || strstr( name, ".mb" ) ) { idModelExport exporter; exporter.ExportModel( name ); name.SetFileExtension( MD5_MESH_EXT ); } if ( !renderModelManager->CheckModel( name ) ) { gameLocal.Printf( "Can't register model\n" ); return; } dict.Set( "model", name ); } } offset = player->GetPhysics()->GetOrigin() + player->viewAngles.ToForward() * 100.0f; dict.Set( "origin", offset.ToString() ); dict.Set( "angle", va( "%f", player->viewAngles.yaw + 180.0f ) ); dict.Set( "def_head", g_testModelHead.GetString()); gameLocal.testmodel = ( idTestModel * )gameLocal.SpawnEntityType( idTestModel::Type, &dict ); gameLocal.testmodel->renderEntity.shaderParms[SHADERPARM_TIMEOFFSET] = -MS2SEC( gameLocal.time ); }
/* ================ sdPhysics_Linear::ApplyNetworkState ================ */ void sdPhysics_Linear::ApplyNetworkState( networkStateMode_t mode, const sdEntityStateNetworkData& newState ) { traceCollection.ForceNextUpdate(); if ( mode == NSM_BROADCAST ) { NET_GET_NEW( sdPhysicsLinearBroadcastData ); // update state current.atRest = newData.atRest; current.localOrigin = newData.localOrigin; current.linearExtrapolation.Init( MS2SEC( newData.startTime ), MS2SEC( newData.duration ), newData.startValue, newData.baseSpeed, newData.speed, newData.extrapolationType ); self->UpdateVisuals(); return; } }
/* ================ sdScriptedEntityHelper_Aimer::UpdateAngles ================ */ bool sdScriptedEntityHelper_Aimer::UpdateAngles( angleInfo_t& info, bool force ) { if ( idMath::Fabs( info.current - info.ideal ) > idMath::FLT_EPSILON ) { if ( info.clamp.filter > 0.f && !force ) { float angle = idMath::AngleNormalize180( info.ideal - info.current ); angle *= ( 1.f - info.clamp.filter ); info.ideal = info.current + angle; } if ( info.clamp.flags.limitRate && !force ) { float angle = idMath::AngleNormalize180( info.ideal - info.current ); float frac = idMath::Fabs( angle / 180.f ); float maxTurn = Lerp( info.clamp.rate[ 0 ], info.clamp.rate[ 1 ], frac ) * MS2SEC( gameLocal.msec ); if ( angle < -maxTurn ) { info.current -= maxTurn; } else if ( angle > maxTurn ) { info.current += maxTurn; } else { info.current = info.ideal; } } else { info.current = info.ideal; } } // Gordon: stop really small deltas updating sounds + animation, we need to cache the old value though to stop them accumulating float delta = idMath::Fabs( info.old - info.current ); bool changed = delta > 0.001f; if ( changed ) { info.old = info.current; } else { delta = 0.0f; } float changeVelocity = delta / MS2SEC( gameLocal.msec ); float soundValue = changeVelocity / 30.0f; if ( soundValue > 1.0f ) { soundValue = 1.0f; } if ( info.sound != NULL ) { info.sound->Update( soundValue ); } return changed; }
void hhShuttleTransport::Event_FadeOut() { // Fade out SetShaderParm(SHADERPARM_TIMEOFFSET, -MS2SEC(gameLocal.time)); // Growth start time SetShaderParm(5, -1.0f); // Growth direction (out) SetShaderParm(6, 0.0f); // Make Beam translucent StartSound("snd_fadeout", SND_CHANNEL_ANY); PostEventMS(&EV_Remove, 1000); }
void hhFuncEmitter::Hide() { idStaticEntity::Hide(); renderEntity.shaderParms[SHADERPARM_PARTICLE_STOPTIME] = MS2SEC( gameLocal.time ); particleStartTime = -1; BecomeInactive( TH_TICKER ); }
/* ===================== idTestModel::TestParticleStopTime_f ===================== */ void idTestModel::TestParticleStopTime_f( const idCmdArgs &args ) { if ( !gameLocal.testmodel ) { gameLocal.Printf( "No testModel active.\n" ); return; } gameLocal.testmodel->renderEntity.shaderParms[SHADERPARM_PARTICLE_STOPTIME] = MS2SEC( gameLocal.time ); gameLocal.testmodel->UpdateVisuals(); }
void hhFuncEmitter::Show() { idStaticEntity::Show(); renderEntity.shaderParms[SHADERPARM_PARTICLE_STOPTIME] = 0; renderEntity.shaderParms[SHADERPARM_TIMEOFFSET] = -MS2SEC( gameLocal.GetTime() ); particleStartTime = gameLocal.GetTime(); BecomeActive( TH_TICKER ); }
/* ================ idLight::On ================ */ void idLight::On( void ) { currentLevel = levels; // offset the start time of the shader to sync it to the game time renderLight.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.time ); if ( ( soundWasPlaying || refSound.waitfortrigger ) && refSound.shader ) { StartSoundShader( refSound.shader, SND_CHANNEL_ANY, 0, false, NULL ); soundWasPlaying = false; } SetLightLevel(); BecomeActive( TH_UPDATEVISUALS ); }
/* ================ idAF::ChangePose Change the articulated figure to match the current animation pose of the given entity and set the velocity relative to the previous pose. ================ */ void idAF::ChangePose( idEntity *ent, int time ) { int i; float invDelta; idAFBody *body; idVec3 origin, lastOrigin; idMat3 axis; idAnimator *animatorPtr; renderEntity_t *renderEntity; if( !IsLoaded() || !ent ) { return; } animatorPtr = ent->GetAnimator(); if( !animatorPtr ) { return; } renderEntity = ent->GetRenderEntity(); if( !renderEntity ) { return; } // if the animation is driven by the physics if( self->GetPhysics() == &physicsObj ) { return; } // if the pose was already updated this frame if( poseTime == time ) { return; } invDelta = 1.0f / MS2SEC( time - poseTime ); poseTime = time; for( i = 0; i < jointMods.Num(); i++ ) { body = physicsObj.GetBody( jointMods[i].bodyId ); animatorPtr->GetJointTransform( jointMods[i].jointHandle, time, origin, axis ); lastOrigin = body->GetWorldOrigin(); body->SetWorldOrigin( renderEntity->origin + ( origin + jointMods[i].jointBodyOrigin * axis ) * renderEntity->axis ); body->SetWorldAxis( jointMods[i].jointBodyAxis * axis * renderEntity->axis ); body->SetLinearVelocity( ( body->GetWorldOrigin() - lastOrigin ) * invDelta ); } physicsObj.UpdateClipModels(); }
/* ================ idSecurityCamera::Event_ContinueSweep ================ */ void idSecurityCamera::Event_ContinueSweep( void ) { float pct = ( stopSweeping - sweepStart ) / ( sweepEnd - sweepStart ); float f = gameLocal.time - ( sweepEnd - sweepStart ) * pct; int speed; sweepStart = f; speed = MS2SEC( SweepSpeed() ); sweepEnd = sweepStart + speed; PostEventMS( &EV_SecurityCam_Pause, speed * ( 1.0 - pct ) ); StartSound( "snd_moving", SND_CHANNEL_BODY, 0, false, NULL ); SetAlertMode( SCANNING ); sweeping = true; }
/* ============== idPlayerView::ClearEffects ============== */ void idPlayerView::ClearEffects() { lastDamageTime = MS2SEC( gameLocal.time - 99999 ); dvFinishTime = ( gameLocal.time - 99999 ); kickFinishTime = ( gameLocal.time - 99999 ); for ( int i = 0 ; i < MAX_SCREEN_BLOBS ; i++ ) { screenBlobs[i].finishTime = gameLocal.time; } fadeTime = 0; }
/* ================ idThread::Event_GetTime ================ */ void idThread::Event_GetTime() { ReturnFloat( MS2SEC( gameLocal.realClientTime ) ); /* Script always uses realClient time to determine scripty stuff. ( This Fixes Weapon Animation timing bugs ) if ( common->IsMultiplayer() ) { ReturnFloat( MS2SEC( gameLocal.GetServerGameTimeMs() ) ); } else { ReturnFloat( MS2SEC( gameLocal.realClientTime ) ); } */ }
END_CLASS /* ================ idTarget_SetGlobalShaderTime::Event_Activate ================ */ void idTarget_SetGlobalShaderTime::Event_Activate( idEntity *activator ) { int parm = spawnArgs.GetInt( "globalParm" ); float time = -MS2SEC( gameLocal.time ); if ( parm >= 0 && parm < MAX_GLOBAL_SHADER_PARMS ) { gameLocal.globalShaderParms[parm] = time; } }
/* ================ sdClientAnimated::Event_PlayAnimBlended ================ */ void sdClientAnimated::Event_PlayAnimBlended( animChannel_t channel, const char *animname, float blendTime ) { int anim = animator.GetAnim( animname ); if ( !anim ) { if( anim_showMissingAnims.GetBool() ) { gameLocal.Warning( "idAnimatedEntity::Event_PlayAnimBlended missing '%s' animation", animname ); } animator.Clear( channel, gameLocal.time, 0 ); sdProgram::ReturnFloat( 0 ); } else { animator.PlayAnim( channel, anim, gameLocal.time, SEC2MS( blendTime ) ); sdProgram::ReturnFloat( MS2SEC( animator.AnimLength( anim ) ) ); } }
/* ================ sdClientAnimated::Event_PlayCycle ================ */ void sdClientAnimated::Event_PlayCycle( animChannel_t channel, const char *animname ) { int anim = animator.GetAnim( animname ); if ( !anim ) { if( anim_showMissingAnims.GetBool() ) { gameLocal.Warning( "sdClientAnimated::Event_PlayCycle missing '%s' animation", animname ); } animator.Clear( channel, gameLocal.time, 0 ); sdProgram::ReturnFloat( 0.0f ); } else { animator.CycleAnim( channel, anim, gameLocal.time, 0 ); sdProgram::ReturnFloat( MS2SEC( animator.AnimLength( anim ) ) ); } }