/* ================ idBrittleFracture::Think ================ */ void idBrittleFracture::Think( void ) { int i, startTime, endTime, droppedTime; shard_t *shard; bool atRest = true, fading = false; // remove overdue shards for( i = 0; i < shards.Num(); i++ ) { droppedTime = shards[i]->droppedTime; if( droppedTime != -1 ) { if( gameLocal.time - droppedTime > SHARD_ALIVE_TIME ) { RemoveShard( i ); i--; } fading = true; } } // remove the entity when nothing is visible if( !shards.Num() ) { PostEventMS( &EV_Remove, 0 ); return; } if( thinkFlags & TH_PHYSICS ) { startTime = gameLocal.previousTime; endTime = gameLocal.time; // run physics on shards for( i = 0; i < shards.Num(); i++ ) { shard = shards[i]; if( shard->droppedTime == -1 ) { continue; } shard->physicsObj.Evaluate( endTime - startTime, endTime ); if( !shard->physicsObj.IsAtRest() ) { atRest = false; } } if( atRest ) { BecomeInactive( TH_PHYSICS ); } else { BecomeActive( TH_PHYSICS ); } } if( !atRest || bounds.IsCleared() ) { bounds.Clear(); for( i = 0; i < shards.Num(); i++ ) { bounds.AddBounds( shards[i]->clipModel->GetAbsBounds() ); } } if( fading ) { BecomeActive( TH_UPDATEVISUALS | TH_THINK ); } else { BecomeInactive( TH_THINK ); } RunPhysics(); Present(); }
END_CLASS /* ================= hhProjectileCrawlerGrenade::Spawn ================= */ void hhProjectileCrawlerGrenade::Spawn() { modelScale.Init( gameLocal.time, 0, 1.0f, 1.0f ); modelProxy = NULL; InitCollisionInfo(); //doesn't matter for single player, only for network logic -rww modelProxyCopyDone = false; if( !gameLocal.isClient ) { SpawnModelProxy(); } BecomeActive( TH_TICKER ); if (gameLocal.isClient) { //rww - do this right away on the client //Get rid of our model. The modelProxy is our model now. SetModel( "" ); } //rww - allow events on client fl.clientEvents = true; }
//-------------------------------- // hhProxDoor::SetDoorState //-------------------------------- void hhProxDoor::SetDoorState( EProxState doorState ) { int i; //HUMANHEAD PCF mdl 04/27/06 - Don't allow locked doors to become active if ( doorLocked && doorState == PROXSTATE_Active ) { return; } switch( doorState ) { case PROXSTATE_Active: BecomeActive( TH_TICKER ); CancelEvents( &EV_PollForExit ); PostEventMS( &EV_PollForExit, 500 ); OpenPortal(); break; case PROXSTATE_GoingInactive: break; case PROXSTATE_Inactive: // Guarantee the door is closed for( i = 0; i < doorPieces.Num(); i++ ) { if (doorPieces[i].IsValid()) { doorPieces[ i ]->SetProximity( 0.0 ); } } ClosePortal(); CancelEvents( &EV_PollForExit ); BecomeInactive( TH_TICKER ); break; } proxState = doorState; }
void idWorldManager::Spawn( void ) { int i; for (i = 0; i < 3; i++) { idDict args; records[i].index = 0; records[i].playing = false; records[i].completed = false; args.Clear(); args.Set( "model", "models/monster_npc/tris.ase" ); args.SetInt( "solid", 0 ); args.Set("skin", "skins/npc/ghost2"); records[i].ghost = ( idMover * )gameLocal.SpawnEntityType( idMover::Type, &args ); records[i].ghost->Hide(); recordlines[i].lines.Clear(); } lastPosition = vec3_zero; lastAngle = 0; nextRecordtime = 0; recordStarttime = 0; index = 0; state = OFF; BecomeActive( TH_THINK ); }
/* ================ idSound::Spawn ================ */ void idSound::Spawn( void ) { spawnArgs.GetVector( "move", "0 0 0", shakeTranslate ); spawnArgs.GetAngles( "rotate", "0 0 0", shakeRotate ); spawnArgs.GetFloat( "random", "0", random ); spawnArgs.GetFloat( "wait", "0", wait ); if( ( wait > 0.0f ) && ( random >= wait ) ) { random = wait - 0.001; gameLocal.DWarning( "speaker '%s' at (%s) has random >= wait", name.c_str(), GetPhysics()->GetOrigin().ToString( 0 ) ); } soundVol = 0.0f; lastSoundVol = 0.0f; if( ( shakeRotate != ang_zero ) || ( shakeTranslate != vec3_zero ) ) { BecomeActive( TH_THINK ); } if( !refSound.waitfortrigger && ( wait > 0.0f ) ) { timerOn = true; PostEventSec( &EV_Speaker_Timer, wait + gameLocal.random.CRandomFloat() * random ); } else { timerOn = false; } }
/* ================ idExplodingBarrel::AddLight ================ */ void idExplodingBarrel::AddLight( const char *name, bool burn ) { if ( lightHandle >= 0 ){ gameRenderWorld->FreeLightDef( lightHandle ); } memset( &light, 0, sizeof ( light ) ); light.axis = mat3_identity; light.lightRadius.x = spawnArgs.GetFloat( "light_radius" ); light.lightRadius.y = light.lightRadius.z = light.lightRadius.x; light.origin = physicsObj.GetOrigin(); light.origin.z += 128; light.pointLight = true; // RAVEN BEGIN // dluetscher: added detail levels to render lights light.detailLevel = DEFAULT_LIGHT_DETAIL_LEVEL; // dluetscher: made sure that barrels are set to no shadows light.noShadows = true; // RAVEN END light.shader = declManager->FindMaterial( name ); light.shaderParms[ SHADERPARM_RED ] = 2.0f; light.shaderParms[ SHADERPARM_GREEN ] = 2.0f; light.shaderParms[ SHADERPARM_BLUE ] = 2.0f; light.shaderParms[ SHADERPARM_ALPHA ] = 2.0f; lightHandle = gameRenderWorld->AddLightDef( &light ); lightTime = gameLocal.time; BecomeActive( TH_THINK ); }
void rvVehicleSpline::Spawn ( void ) { physicsObj.SetSelf( this ); physicsObj.SetClipModel( new idClipModel(GetPhysics()->GetClipModel()), 1.0f ); physicsObj.SetContents( CONTENTS_SOLID ); physicsObj.SetClipMask( 0 ); physicsObj.SetLinearVelocity( GetPhysics()->GetLinearVelocity() ); physicsObj.SetLinearAcceleration( spawnArgs.GetFloat( "accel", "200" ) ); physicsObj.SetLinearDeceleration( spawnArgs.GetFloat( "decel", "200" ) ); viewAxis = idAngles( 0, spawnArgs.GetFloat( "angle" ) , 0 ).ToMat3(); physicsObj.SetAxis( GetPhysics()->GetAxis() * viewAxis ); physicsObj.SetOrigin( GetPhysics()->GetOrigin() ); SetPhysics( &physicsObj ); BecomeActive( TH_THINK ); accelWithStrafe = Sign( spawnArgs.GetFloat("accel_strafe") ); idealSpeed = spawnArgs.GetFloat( "speed", "200" ); PostEventMS( &EV_PostSpawn, 0 ); }
/* ================ rvVehicleAnimated::Spawn ================ */ void rvVehicleAnimated::Spawn( void ) { turnRate = spawnArgs.GetFloat ( "turnRate", "90" ); viewAngles = GetPhysics()->GetAxis ( ).ToAngles ( ); viewAxis = viewAngles.ToMat3(); // Initialize the physics object physicsObj.SetSelf( this ); physicsObj.SetClipModel( new idClipModel( GetPhysics()->GetClipModel() ), 1.0f ); physicsObj.SetContents( CONTENTS_BODY ); physicsObj.SetClipMask( MASK_PLAYERSOLID|CONTENTS_VEHICLECLIP ); physicsObj.SetMaxStepHeight( spawnArgs.GetFloat ( "stepheight", "14" ) ); // Start just a tad above the floor physicsObj.SetOrigin( GetPhysics()->GetOrigin() + idVec3( 0, 0, CM_CLIP_EPSILON ) ); physicsObj.SetMass( spawnArgs.GetFloat( "mass", "100" ) ); physicsObj.SetDelta( vec3_origin ); // Gravity idVec3 gravity = spawnArgs.GetVector( "gravityDir", "0 0 -1" ); gravity *= g_gravity.GetFloat ( ); physicsObj.SetGravity( gravity ); SetPhysics( &physicsObj ); animator.RemoveOriginOffset( true ); additionalDelta.Zero(); BecomeActive( TH_THINK ); }
/* ================ idTarget_FadeEntity::Event_Activate ================ */ void idTarget_FadeEntity::Event_Activate( idEntity *activator ) { idEntity *ent; int i; if( !targets.Num() ) { return; } // always allow during cinematics cinematic = true; BecomeActive( TH_THINK ); ent = this; for( i = 0; i < targets.Num(); i++ ) { ent = targets[ i ].GetEntity(); if( ent ) { ent->GetColor( fadeFrom ); break; } } fadeStart = gameLocal.time; fadeEnd = gameLocal.time + SEC2MS( spawnArgs.GetFloat( "fadetime" ) ); }
/* ================ idBrittleFracture::DropShard ================ */ void idBrittleFracture::DropShard( shard_t* shard, const idVec3& point, const idVec3& dir, const float impulse, const int time ) { int i, j, clipModelId; float dist, f; idVec3 dir2, origin; idMat3 axis; shard_t* neighbour; // don't display decals on dropped shards shard->decals.DeleteContents( true ); // remove neighbour pointers of neighbours pointing to this shard for( i = 0; i < shard->neighbours.Num(); i++ ) { neighbour = shard->neighbours[i]; for( j = 0; j < neighbour->neighbours.Num(); j++ ) { if( neighbour->neighbours[j] == shard ) { neighbour->neighbours.RemoveIndex( j ); break; } } } // remove neighbour pointers shard->neighbours.Clear(); // remove the clip model from the static physics object clipModelId = shard->clipModel->GetId(); physicsObj.SetClipModel( NULL, 1.0f, clipModelId, false ); origin = shard->clipModel->GetOrigin(); axis = shard->clipModel->GetAxis(); // set the dropped time for fading shard->droppedTime = time; dir2 = origin - point; dist = dir2.Normalize(); f = dist > maxShatterRadius ? 1.0f : idMath::Sqrt( idMath::Fabs( dist - minShatterRadius ) ) * ( 1.0f / idMath::Sqrt( idMath::Fabs( maxShatterRadius - minShatterRadius ) ) ); // setup the physics shard->physicsObj.SetSelf( this ); shard->physicsObj.SetClipModel( shard->clipModel, density ); shard->physicsObj.SetMass( shardMass ); shard->physicsObj.SetOrigin( origin ); shard->physicsObj.SetAxis( axis ); shard->physicsObj.SetBouncyness( bouncyness ); shard->physicsObj.SetFriction( 0.6f, 0.6f, friction ); shard->physicsObj.SetGravity( gameLocal.GetGravity() ); shard->physicsObj.SetContents( CONTENTS_RENDERMODEL ); shard->physicsObj.SetClipMask( MASK_SOLID | CONTENTS_MOVEABLECLIP ); shard->physicsObj.ApplyImpulse( 0, origin, impulse * linearVelocityScale * dir ); shard->physicsObj.SetAngularVelocity( dir.Cross( dir2 ) * ( f * angularVelocityScale ) ); shard->clipModel->SetId( clipModelId ); BecomeActive( TH_PHYSICS ); }
/* =============== tdmFuncShooter::Spawn =============== */ void tdmFuncShooter::Spawn() { _active = !spawnArgs.GetBool( "start_off" ); _lastFireTime = 0; _fireInterval = spawnArgs.GetInt( "fire_interval", "-1" ); _fireIntervalFuzzyness = spawnArgs.GetInt( "fire_interval_fuzzyness", "0" ); _startDelay = spawnArgs.GetInt( "start_delay", "0" ); idStr reqStimStr = spawnArgs.GetString( "required_stim" ); if( !reqStimStr.IsEmpty() ) { _requiredStim = CStimResponse::GetStimType( reqStimStr ); _requiredStimTimeOut = spawnArgs.GetInt( "required_stim_timeout", "5000" ); } _triggerRequired = spawnArgs.GetBool( "required_trigger" ); _triggerTimeOut = spawnArgs.GetInt( "required_trigger_timeout", "4000" ); _ammo = spawnArgs.GetInt( "ammo", "-1" ); _useAmmo = ( _ammo != -1 ); if( _active && _fireInterval > 0 ) { BecomeActive( TH_THINK ); setupNextFireTime(); _nextFireTime += _startDelay; // Set the end time if we have a positive lifetime int maxLifeTime = spawnArgs.GetInt( "max_lifetime", "-1" ); if( maxLifeTime > 0 ) { _endTime = gameLocal.time + SEC2MS( maxLifeTime ); } } // Always react to stims if a required stim is setup. if( _requiredStim != ST_DEFAULT ) { //DM_LOG(LC_STIM_RESPONSE, LT_INFO)LOGSTRING("tdmFuncShooter is requiring stim %d\r", _requiredStim); GetPhysics()->SetContents( GetPhysics()->GetContents() | CONTENTS_RESPONSE ); } }
/* ================ 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; } } }
/* ================ idSound::Spawn ================ */ void idSound::Spawn( void ) { spawnArgs.GetVector( "move", "0 0 0", shakeTranslate ); spawnArgs.GetAngles( "rotate", "0 0 0", shakeRotate ); spawnArgs.GetFloat( "random", "0", random ); spawnArgs.GetFloat( "wait", "0", wait ); if ( ( wait > 0.0f ) && ( random >= wait ) ) { random = wait - 0.001; gameLocal.Warning( "speaker '%s' at (%s) has random >= wait", name.c_str(), GetPhysics()->GetOrigin().ToString(0) ); } soundVol = 0.0f; lastSoundVol = 0.0f; if ( ( shakeRotate != ang_zero ) || ( shakeTranslate != vec3_zero ) ) { BecomeActive( TH_THINK ); } if ( !refSound.waitfortrigger && ( wait > 0.0f ) ) { timerOn = true; PostEventSec( &EV_Speaker_Timer, wait + gameLocal.random.CRandomFloat() * random ); } else { timerOn = false; } // add this speaker to the list of ambient music speakers affected by tdm_music_volume if ( spawnArgs.GetBool( "s_music" ) ) { gameLocal.musicSpeakers.Append( entityNumber ); } }
/* ================ idEntityFx::Event_Trigger ================ */ void idEntityFx::Event_Trigger( idEntity *activator ) { if ( g_skipFX.GetBool() ) { return; } float fxActionDelay; const char *fx; if ( gameLocal.time < nextTriggerTime ) { return; } if ( spawnArgs.GetString( "fx", "", &fx) ) { Setup( fx ); Start( gameLocal.time ); PostEventMS( &EV_Fx_KillFx, Duration() ); BecomeActive( TH_THINK ); } fxActionDelay = spawnArgs.GetFloat( "fxActionDelay" ); if ( fxActionDelay != 0.0f ) { nextTriggerTime = gameLocal.time + SEC2MS( fxActionDelay ); } else { // prevent multiple triggers on same frame nextTriggerTime = gameLocal.time + 1; } PostEventSec( &EV_Fx_Action, fxActionDelay, activator ); }
/* ============== idSpawner::Event_Activate ============== */ void idSpawner::Event_Activate( idEntity *activator ) { // "trigger_only" spawners will attempt to spawn when triggered if ( spawnArgs.GetBool( "trigger_only" ) ) { // Update next spawn time to follo CheckSpawn into thinking its time to spawn again nextSpawnTime = gameLocal.time; CheckSpawn(); return; } // If nextSpawnTime is zero then the spawner is currently deactivated if ( nextSpawnTime == 0 ) { // Start thinking BecomeActive( TH_THINK ); // Allow immediate spawn nextSpawnTime = gameLocal.time; // Spawn any ai targets and add them to the current count ActivateTargets( this ); } else { nextSpawnTime = 0; BecomeInactive( TH_THINK ); // Remove the spawner if need be if ( spawnArgs.GetBool( "remove", "1" ) ) { PostEventMS( &EV_Remove, 0 ); } } }
/* ================ idLight::Fade ================ */ void idLight::Fade( const idVec4 &to, float fadeTime ) { GetColor( fadeFrom ); fadeTo = to; fadeStart = gameLocal.time; fadeEnd = gameLocal.time + SEC2MS( fadeTime ); BecomeActive( TH_THINK ); }
/* ================ idTrigger_Touch::Event_Trigger ================ */ void idTrigger_Touch::Event_Trigger( idEntity *activator ) { if ( thinkFlags & TH_THINK ) { BecomeInactive( TH_THINK ); } else { BecomeActive( TH_THINK ); } }
END_CLASS /* ============== sdSnowEffect::Spawn ============== */ void sdSnowEffect::Spawn( void ) { renderEntity_t *re = GetRenderEntity(); re->numInsts = MAX_GROUPS; re->insts = new sdInstInfo[ re->numInsts ]; idVec3 zero; idMat3 I; zero.Zero(); I.Identity(); this->SetPosition( zero, I ); idBounds modelbb = re->hModel->Bounds(); idVec3 extents = (modelbb.GetMaxs() - modelbb.GetMins()) * 0.5f; idPlayer *p = gameLocal.GetLocalViewPlayer(); idVec3 const &v = p->GetViewPos(); for (int i=0; i<MAX_GROUPS; i++) { groups[i].time = -1.f; } BecomeActive( TH_THINK ); UpdateVisuals(); }
END_CLASS /* ================ idTarget_EndLevel::Event_Activate ================ */ void idTarget_EndLevel::Event_Activate( idEntity *activator ) { if ( thinkFlags & TH_THINK ) { BecomeInactive( TH_THINK ); } else { // always allow during cinematics cinematic = true; BecomeActive( TH_THINK ); } idPlayer* player; player = gameLocal.GetLocalPlayer(); player->SetInfluenceLevel( 2 ); player->endLevelTime = gameLocal.time; // sikk - End Level time player->doEndLevel = true; // sikk - End Level Flag if ( !player->scoreBoardOpen ) { player->ToggleScoreboard(); } StartSoundShader( declManager->FindSound( "music_endLevel" ), SND_CHANNEL_ANY, 0, false, NULL ); }
/* ================ idTarget_SetFov::Event_Activate ================ */ void idTarget_SetFov::Event_Activate( idEntity *activator ) { // always allow during cinematics cinematic = true; idPlayer *player = gameLocal.GetLocalPlayer(); fovSetting.Init( gameLocal.time, SEC2MS( spawnArgs.GetFloat( "time" ) ), player ? player->DefaultFov() : g_fov.GetFloat(), spawnArgs.GetFloat( "fov" ) ); BecomeActive( TH_THINK ); }
void hhAnimatedGui::FadeInGui() { float curScale = guiScale.GetCurrentValue(gameLocal.time); guiScale.Init(gameLocal.time, 500, curScale, AG_LARGE_SCALE); BecomeActive(TH_THINK); attachedConsole->SetDeformation(DEFORMTYPE_SCALE, curScale); attachedConsole->Show(); }
/* ================ 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; } } }
/* ================ idTrigger_Touch::Spawn ================ */ void idTrigger_Touch::Spawn( void ) { // get the clip model // RAVEN BEGIN // mwhitlock: Dynamic memory consolidation RV_PUSH_HEAP_MEM(this); // RAVEN END clipModel = new idClipModel( GetPhysics()->GetClipModel() ); // RAVEN BEGIN // mwhitlock: Dynamic memory consolidation RV_POP_HEAP(); // RAVEN END // remove the collision model from the physics object GetPhysics()->SetClipModel( NULL, 1.0f ); if ( spawnArgs.GetBool( "start_on" ) ) { BecomeActive( TH_THINK ); } filterTeam = -1; idStr filterTeamStr = spawnArgs.GetString( "filterTeam" ); if ( filterTeamStr.Size() ) { if ( !idStr::Icmp( "marine", filterTeamStr.c_str() ) ) { filterTeam = AITEAM_MARINE; } else if ( !idStr::Icmp( "strogg", filterTeamStr.c_str() ) ) { filterTeam = AITEAM_STROGG; } } }
/* ================ sdTeleporter::Spawn ================ */ void sdTeleporter::Spawn( void ) { BecomeActive( TH_THINK ); sdTeamManagerLocal& manager = sdTeamManager::GetInstance(); teamInfo.SetNum( manager.GetNumTeams() ); for ( int i = 0; i < manager.GetNumTeams(); i++ ) { sdTeamInfo& team = manager.GetTeamByIndex( i ); // default to enabled teamInfo[ i ].enabled = spawnArgs.GetBool( va( "%s_starts_enabled", team.GetLookupName() ), "1" ); } delay = spawnArgs.GetInt( "delay" ); exitVelocity = spawnArgs.GetVector( "velocity_exit", "100 0 0" ); deployReverse = spawnArgs.GetFloat( "deploy_reverse" ); deployLength = spawnArgs.GetFloat( "deploy_length" ); deployWidth = spawnArgs.GetFloat( "deploy_width" ); telefragDamage = DAMAGE_FOR_NAME( spawnArgs.GetString( "dmg_telefrag" ) ); // set up the physics const char* triggerModel = spawnArgs.GetString( "cm_trigger" ); staticPhysics.SetSelf( this ); staticPhysics.SetClipModel( new idClipModel( GetPhysics()->GetClipModel() ), 1.0f ); if ( triggerModel != NULL && *triggerModel ) { // the trigger for the physics staticPhysics.SetClipModel( new idClipModel( triggerModel ), 1.0f, 1 ); } staticPhysics.SetOrigin( GetPhysics()->GetOrigin() ); staticPhysics.SetAxis( GetPhysics()->GetAxis() ); SetPhysics( &staticPhysics ); }
/* =========== hhForceField::EnterTurningOnState =========== */ void hhForceField::EnterTurningOnState() { GetPhysics()->SetContents( cachedContents ); SetSkin( NULL ); StartSound( "snd_start", SND_CHANNEL_ANY ); Show(); BecomeActive( TH_TICKER ); }
/* ================ hhSpring::LinkSpringAll HUMANHEAD ================ */ void hhSpring::LinkSpringAll(idEntity *ent1, int bodyID1, idVec3 &offset1, idEntity *ent2, int bodyID2, idVec3 &offset2) { physics1 = ent1; physics2 = ent2; spring.SetPosition( physics1.GetEntity(), bodyID1, offset1, physics2.GetEntity(), bodyID2, offset2 ); BecomeActive(TH_THINK); }
/* ================ idMoveableItem::Spawn ================ */ void idMoveableItem::Spawn( void ) { idTraceModel trm; float density, friction, bouncyness, tsize; idStr clipModelName; idBounds bounds; // create a trigger for item pickup spawnArgs.GetFloat( "triggersize", "16.0", tsize ); trigger = new idClipModel( idTraceModel( idBounds( vec3_origin ).Expand( tsize ) ) ); trigger->Link( gameLocal.clip, this, 0, GetPhysics()->GetOrigin(), GetPhysics()->GetAxis() ); trigger->SetContents( CONTENTS_TRIGGER ); // check if a clip model is set spawnArgs.GetString( "clipmodel", "", clipModelName ); if ( !clipModelName[0] ) { clipModelName = spawnArgs.GetString( "model" ); // use the visual model } // load the trace model if ( !collisionModelManager->TrmFromModel( clipModelName, trm ) ) { gameLocal.Error( "idMoveableItem '%s': cannot load collision model %s", name.c_str(), clipModelName.c_str() ); return; } // if the model should be shrinked if ( spawnArgs.GetBool( "clipshrink" ) ) { trm.Shrink( CM_CLIP_EPSILON ); } // get rigid body properties spawnArgs.GetFloat( "density", "0.5", density ); density = idMath::ClampFloat( 0.001f, 1000.0f, density ); spawnArgs.GetFloat( "friction", "0.05", friction ); friction = idMath::ClampFloat( 0.0f, 1.0f, friction ); spawnArgs.GetFloat( "bouncyness", "0.6", bouncyness ); bouncyness = idMath::ClampFloat( 0.0f, 1.0f, bouncyness ); // setup the physics physicsObj.SetSelf( this ); physicsObj.SetClipModel( new idClipModel( trm ), density ); physicsObj.SetOrigin( GetPhysics()->GetOrigin() ); physicsObj.SetAxis( GetPhysics()->GetAxis() ); physicsObj.SetBouncyness( bouncyness ); physicsObj.SetFriction( 0.6f, 0.6f, friction ); physicsObj.SetGravity( gameLocal.GetGravity() ); physicsObj.SetContents( CONTENTS_RENDERMODEL ); physicsObj.SetClipMask( MASK_SOLID | CONTENTS_MOVEABLECLIP ); SetPhysics( &physicsObj ); smoke = NULL; smokeTime = 0; const char *smokeName = spawnArgs.GetString( "smoke_trail" ); if ( *smokeName != '\0' ) { smoke = static_cast<const idDeclParticle *>( declManager->FindType( DECL_PARTICLE, smokeName ) ); smokeTime = gameLocal.time; BecomeActive( TH_UPDATEPARTICLES ); } }
/* ================ idTrigger_Multi::Spawn "wait" : Seconds between triggerings, 0.5 default, -1 = one time only. "call" : Script function to call when triggered "random" wait variance, default is 0 Variable sized repeatable trigger. Must be targeted at one or more entities. so, the basic time between firing is a random time between (wait - random) and (wait + random) ================ */ void idTrigger_Multi::Spawn( void ) { spawnArgs.GetFloat( "wait", "0.5", wait ); spawnArgs.GetFloat( "random", "0", random ); spawnArgs.GetFloat( "delay", "0", delay ); spawnArgs.GetFloat( "random_delay", "0", random_delay ); if ( random && ( random >= wait ) && ( wait >= 0 ) ) { random = wait - 1; gameLocal.Warning( "idTrigger_Multi '%s' at (%s) has random >= wait", name.c_str(), GetPhysics()->GetOrigin().ToString(0) ); } if ( random_delay && ( random_delay >= delay ) && ( delay >= 0 ) ) { random_delay = delay - 1; gameLocal.Warning( "idTrigger_Multi '%s' at (%s) has random_delay >= delay", name.c_str(), GetPhysics()->GetOrigin().ToString(0) ); } spawnArgs.GetString( "requires", "", requires ); spawnArgs.GetInt( "removeItem", "0", removeItem ); spawnArgs.GetBool( "triggerFirst", "0", triggerFirst ); spawnArgs.GetBool( "triggerWithSelf", "0", triggerWithSelf ); spawnArgs.GetInt( "buyZone", "0", buyZoneTrigger); spawnArgs.GetInt( "controlZone", "0", controlZoneTrigger); if ( buyZoneTrigger == -1 ) gameLocal.Warning( "trigger_buyzone '%s' at (%s) has no buyZone key set!", name.c_str(), GetPhysics()->GetOrigin().ToString(0) ); if ( controlZoneTrigger == -1 ) gameLocal.Warning( "trigger_controlzone '%s' at (%s) has no controlZone key set!", name.c_str(), GetPhysics()->GetOrigin().ToString(0) ); if ( spawnArgs.GetBool( "onlyVehicle" ) ) { touchVehicle = true; } else if ( spawnArgs.GetBool( "anyTouch" ) ) { touchClient = true; touchOther = true; } else if ( spawnArgs.GetBool( "noTouch" ) ) { touchClient = false; touchOther = false; } else if ( spawnArgs.GetBool( "noClient" ) ) { touchClient = false; touchOther = true; } else { touchClient = true; touchOther = false; } nextTriggerTime = 0; if ( spawnArgs.GetBool( "flashlight_trigger" ) ) { GetPhysics()->SetContents( CONTENTS_FLASHLIGHT_TRIGGER ); } else if ( spawnArgs.GetBool( "projectile_trigger" ) ) { GetPhysics()->SetContents( CONTENTS_TRIGGER | CONTENTS_PROJECTILE ); } else { GetPhysics()->SetContents( CONTENTS_TRIGGER ); } BecomeActive( TH_THINK ); }
/* ================ idSecurityCamera::Spawn ================ */ void idSecurityCamera::Spawn( void ) { idStr str; sweepAngle = spawnArgs.GetFloat( "sweepAngle", "90" ); health = spawnArgs.GetInt( "health", "100" ); scanFov = spawnArgs.GetFloat( "scanFov", "90" ); scanDist = spawnArgs.GetFloat( "scanDist", "200" ); flipAxis = spawnArgs.GetBool( "flipAxis" ); modelAxis = spawnArgs.GetInt( "modelAxis" ); if ( modelAxis < 0 || modelAxis > 2 ) { modelAxis = 0; } spawnArgs.GetVector( "viewOffset", "0 0 0", viewOffset ); if ( spawnArgs.GetBool( "spotLight" ) ) { PostEventMS( &EV_SecurityCam_AddLight, 0 ); } negativeSweep = ( sweepAngle < 0 ) ? true : false; sweepAngle = abs( sweepAngle ); scanFovCos = cos( scanFov * idMath::PI / 360.0f ); angle = GetPhysics()->GetAxis().ToAngles().yaw; StartSweep(); SetAlertMode( SCANNING ); BecomeActive( TH_THINK ); if ( health ) { fl.takedamage = true; } pvsArea = gameLocal.pvs.GetPVSArea( GetPhysics()->GetOrigin() ); // if no target specified use ourself str = spawnArgs.GetString( "cameraTarget" ); if ( str.Length() == 0 ) { spawnArgs.Set( "cameraTarget", spawnArgs.GetString( "name" ) ); } // check if a clip model is set spawnArgs.GetString( "clipmodel", "", str ); if ( !str[0] ) { str = spawnArgs.GetString( "model" ); // use the visual model } if ( !collisionModelManager->TrmFromModel( str, trm ) ) { gameLocal.Error( "idSecurityCamera '%s': cannot load collision model %s", name.c_str(), str.c_str() ); return; } GetPhysics()->SetContents( CONTENTS_SOLID ); GetPhysics()->SetClipMask( MASK_SOLID | CONTENTS_BODY | CONTENTS_CORPSE | CONTENTS_MOVEABLECLIP ); // setup the physics UpdateChangeableSpawnArgs( NULL ); }
void idMoveable::SetIsPushed( bool isNowPushed, const idVec3 &pushDirection ) { isPushed = isNowPushed; this->pushDirection = pushDirection; lastPushOrigin = GetPhysics()->GetOrigin(); // Update our think flags to allow UpdateMoveables to be called. if( isPushed ) { BecomeActive( TH_THINK ); } }