void CBasePlayer::SharedSpawn() { SetMoveType( MOVETYPE_WALK ); SetSolid( SOLID_BBOX ); AddSolidFlags( FSOLID_NOT_STANDABLE ); SetFriction( 1.0f ); pl.deadflag = false; m_lifeState = LIFE_ALIVE; m_iHealth = 100; m_takedamage = DAMAGE_YES; m_Local.m_bDrawViewmodel = true; m_Local.m_flStepSize = sv_stepsize.GetFloat(); m_Local.m_bAllowAutoMovement = true; m_nRenderFX = kRenderFxNone; m_flNextAttack = gpGlobals->curtime; m_flMaxspeed = 0.0f; MDLCACHE_CRITICAL_SECTION(); SetSequence( SelectWeightedSequence( ACT_IDLE ) ); if ( GetFlags() & FL_DUCKING ) SetCollisionBounds( VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX ); else SetCollisionBounds( VEC_HULL_MIN, VEC_HULL_MAX ); // dont let uninitialized value here hurt the player m_Local.m_flFallVelocity = 0; SetBloodColor( BLOOD_COLOR_RED ); }
void CBaseTurret::Deploy(void) { SetNextThink( gpGlobals->curtime + 0.1f ); StudioFrameAdvance( ); if ( m_Activity != 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(SearchThink); } m_flLastSight = gpGlobals->curtime + m_flMaxWait; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CASW_Ammo_Drop::Spawn( void ) { SetMoveType( MOVETYPE_NONE ); SetSolid( SOLID_BBOX ); SetCollisionGroup( ASW_COLLISION_GROUP_PASSABLE ); Precache(); SetModel(AMMO_DROP_MODEL); BaseClass::Spawn(); AddEFlags( EFL_NO_DISSOLVE | EFL_NO_MEGAPHYSCANNON_RAGDOLL | EFL_NO_PHYSCANNON_INTERACTION ); SetCollisionBounds( Vector(-26,-26,0), Vector(26,26,60)); m_takedamage = DAMAGE_NO; // check for attaching to elevators trace_t tr; UTIL_TraceLine( GetAbsOrigin() + Vector(0, 0, 2), GetAbsOrigin() - Vector(0, 0, 32), MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction < 1.0f && tr.m_pEnt && !tr.m_pEnt->IsWorld() && !tr.m_pEnt->IsNPC() ) { SetParent( tr.m_pEnt ); } m_iAmmoUnitsRemaining = DEFAULT_AMMO_DROP_UNITS; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool C_FuncPhysicsRespawnZone::Initialize( void ) { if ( InitializeAsClientEntity( STRING(GetModelName()), RENDER_GROUP_OPAQUE_ENTITY ) == false ) return false; SetSolid( SOLID_BSP ); AddSolidFlags( FSOLID_NOT_SOLID ); AddSolidFlags( FSOLID_TRIGGER ); SetMoveType( MOVETYPE_NONE ); const model_t *mod = GetModel(); if ( mod ) { Vector mins, maxs; modelinfo->GetModelBounds( mod, mins, maxs ); SetCollisionBounds( mins, maxs ); } Spawn(); AddEffects( EF_NODRAW ); UpdatePartitionListEntry(); CollisionProp()->UpdatePartition(); UpdateVisibility(); SetNextClientThink( gpGlobals->curtime + (cl_phys_props_respawnrate.GetFloat() * RandomFloat(1.0,1.1)) ); return true; }
//----------------------------------------------------------------------------- // Purpose: // Input : height - //----------------------------------------------------------------------------- void CNPC_CeilingTurret::SetHeight( float height ) { Vector forward, right, up; AngleVectors( GetLocalAngles(), &forward, &right, &up ); Vector mins = ( forward * -16.0f ) + ( right * -16.0f ); Vector maxs = ( forward * 16.0f ) + ( right * 16.0f ) + ( up * -height ); if ( mins.x > maxs.x ) { swap( mins.x, maxs.x ); } if ( mins.y > maxs.y ) { swap( mins.y, maxs.y ); } if ( mins.z > maxs.z ) { swap( mins.z, maxs.z ); } SetCollisionBounds( mins, maxs ); }
void CE_CBeam::RelinkBeam( void ) { // FIXME: Why doesn't this just define the absbox too? // It seems that we don't need to recompute the absbox // in CBaseEntity::SetObjectCollisionBox, in fact the absbox // computed there seems way too big Vector startPos = GetAbsStartPos(), endPos = GetAbsEndPos(); Vector vecAbsExtra1, vecAbsExtra2; bool bUseExtraPoints = false; // UNDONE: Should we do this to make the boxes smaller? //SetAbsOrigin( startPos ); Vector vecBeamMin, vecBeamMax; VectorMin( startPos, endPos, vecBeamMin ); VectorMax( startPos, endPos, vecBeamMax ); if ( bUseExtraPoints ) { VectorMin( vecBeamMin, vecAbsExtra1, vecBeamMin ); VectorMin( vecBeamMin, vecAbsExtra2, vecBeamMin ); VectorMax( vecBeamMax, vecAbsExtra1, vecBeamMax ); VectorMax( vecBeamMax, vecAbsExtra2, vecBeamMax ); } SetCollisionBounds( vecBeamMin - GetAbsOrigin(), vecBeamMax - GetAbsOrigin() ); }
void CRagdollProp::SetObjectCollisionBox( void ) { if ( m_allAsleep ) { Vector fullMins, fullMaxs; RagdollComputeExactBbox( m_ragdoll, GetAbsOrigin(), fullMins, fullMaxs ); SetCollisionBounds( fullMins - GetAbsOrigin(), fullMaxs - GetAbsOrigin() ); SetAbsMins( fullMins ); SetAbsMaxs( fullMaxs ); } else { SetCollisionBounds( m_savedESMins, m_savedESMaxs ); ComputeSurroundingBox(); } }
void CPlantedC4::Init( CCSPlayer *pevOwner, Vector vecStart, QAngle vecAngles ) { SetMoveType( MOVETYPE_NONE ); SetSolid( SOLID_NONE ); SetModel( PLANTED_C4_MODEL ); // Change this to c4 model SetCollisionBounds( Vector( 0, 0, 0 ), Vector( 8, 8, 8 ) ); SetAbsOrigin( vecStart ); SetAbsAngles( vecAngles ); SetOwnerEntity( pevOwner ); // Detonate in "time" seconds SetThink( &CPlantedC4::C4Think ); SetNextThink( gpGlobals->curtime + 0.1f ); m_flTimerLength = mp_c4timer.GetInt(); m_flC4Blow = gpGlobals->curtime + m_flTimerLength; m_flNextDefuse = 0; m_bStartDefuse = false; m_bBombTicking = true; SetFriction( 0.9 ); m_flDefuseLength = 0.0f; SpawnControlPanels(); }
void CBeam::OnDataChanged( DataUpdateType_t updateType ) { MarkMessageReceived(); // Make sure that the correct model is referenced for this entity SetModelPointer( modelinfo->GetModel( GetModelIndex() ) ); // Convert weapon world models to viewmodels if they're weapons being carried by the local player for (int i=0;i<MAX_BEAM_ENTS;i++) { C_BaseEntity *pEnt = m_hAttachEntity[i].Get(); if ( pEnt ) { C_BaseCombatWeapon *pWpn = dynamic_cast<C_BaseCombatWeapon *>(pEnt); if ( pWpn && pWpn->IsCarriedByLocalPlayer() ) { C_BasePlayer *player = ToBasePlayer( pWpn->GetOwner() ); C_BaseViewModel *pViewModel = player ? player->GetViewModel( 0 ) : NULL; if ( pViewModel ) { // Get the viewmodel and use it instead m_hAttachEntity.Set( i, pViewModel ); } } } } // Compute the bounds here... Vector mins, maxs; ComputeBounds( mins, maxs ); SetCollisionBounds( mins, maxs ); }
//----------------------------------------------------------------------------- // Purpose: Spawn function //----------------------------------------------------------------------------- void CWeaponSpawner::Spawn(void) { // Damn it. We need both item definition and weapon script data for spawners to work properly. CEconItemDefinition *pItemDef = GetItemSchema()->GetItemDefinition( m_nItemID ); if ( !pItemDef ) { Warning( "tf_weaponspawner has incorrect item ID %d.\n", m_nWeaponID ); UTIL_Remove( this ); return; } m_Item.SetItemDefIndex( m_nItemID ); // Only merc can use weapon spawners so it's safe use him for translation. m_pWeaponInfo = GetTFWeaponInfoForItem( m_nItemID, TF_CLASS_MERCENARY ); Assert( m_pWeaponInfo ); Precache(); SetModel( m_Item.GetWorldDisplayModel() ); BaseClass::Spawn(); // Ensures consistent trigger bounds for all weapons. (danielmm8888) SetSolid( SOLID_BBOX ); SetCollisionBounds( -Vector(22, 22, 15), Vector(22, 22, 15) ); AddEffects( EF_ITEM_BLINK ); }
void CHL2MP_Player::PostThink( void ) { BaseClass::PostThink(); if ( GetFlags() & FL_DUCKING ) { SetCollisionBounds( VEC_CROUCH_TRACE_MIN, VEC_CROUCH_TRACE_MAX ); } m_PlayerAnimState.Update(); // Store the eye angles pitch so the client can compute its animation state correctly. m_angEyeAngles = EyeAngles(); QAngle angles = GetLocalAngles(); angles[PITCH] = 0; SetLocalAngles( angles ); if (!IsDead()) { if (m_afButtonReleased & IN_KICK && m_flNextKickAttack < gpGlobals->curtime /* && m_flNextKickAttack < gpGlobals->curtime && !m_bIsKicking*/) { KickAttack(); m_bIsKicking = true; } } CBaseCombatWeapon *pWeapon = this->GetActiveWeapon(); if (pWeapon != NULL) { if (m_afButtonPressed & IN_IRONSIGHT) { pWeapon->EnableIronsights(); } else if (m_afButtonReleased & IN_IRONSIGHT) { pWeapon->DisableIronsights(); } } if (!IsDead()) { if (m_flNextKickAttack < gpGlobals->curtime) { m_bIsKicking = false; CBaseViewModel *vm = GetViewModel(1); if (vm) { int idealSequence = vm->SelectWeightedSequence(ACT_VM_IDLE); if (idealSequence >= 0) { vm->SendViewModelMatchingSequence(idealSequence); } } } } }
void CRagdollProp::CalcRagdollSize( void ) { Vector minbox, maxbox; ExtractBbox( GetSequence(), minbox, maxbox ); SetCollisionBounds( minbox, maxbox ); if ( m_ragdoll.list[0].pObject ) { Vector rootPos, rootWorldPos; m_ragdoll.list[0].pObject->GetPosition( &rootWorldPos, NULL ); WorldToEntitySpace( rootWorldPos, &rootPos ); // BUGBUG: This doesn't work because the sequence doesn't necessarily include // the extrema of pose space. // An algorithm that should work correctly is to store a radius in each bone // Then walk the skeleton away from the root to each leaf, accumulating distance to parent // The node or leaf with the largest radius + Sum(dist to parent) is the ragdoll's radius // Next rev of the model file format, I'll add bone radius and fix this. Vector dist; const Vector ¢er = EntitySpaceCenter(); int i; for ( i = 0; i < 3; i++ ) { if ( rootPos[i] > center[i] ) { dist[i] = rootPos[i] - EntitySpaceMins()[i]; } else { dist[i] = EntitySpaceMaxs()[i] - rootPos[i]; } } float radius = dist.Length(); Vector curmins( -radius, -radius, -radius ); Vector curmaxs( radius, radius, radius ); SetCollisionBounds( curmins, curmaxs ); } m_savedESMins = EntitySpaceMins(); m_savedESMaxs = EntitySpaceMaxs(); Relink(); }
//------------------------------------------------------------------------------ // Purpose : Initialize a gibs position and velocity // Input : // Output : //------------------------------------------------------------------------------ void CGib::InitGib( CBaseEntity *pVictim, float fMinVelocity, float fMaxVelocity ) { // ------------------------------------------------------------------------ // If have a pVictim spawn the gib somewhere in the pVictim's bounding volume // ------------------------------------------------------------------------ if ( pVictim ) { // Find a random position within the bounding box (add 1 to Z to get it out of the ground) Vector vecOrigin; pVictim->CollisionProp()->RandomPointInBounds( vec3_origin, Vector( 1, 1, 1 ), &vecOrigin ); vecOrigin.z += 1.0f; SetAbsOrigin( vecOrigin ); // make the gib fly away from the attack vector Vector vecNewVelocity = g_vecAttackDir * -1; // mix in some noise vecNewVelocity.x += random->RandomFloat ( -0.25, 0.25 ); vecNewVelocity.y += random->RandomFloat ( -0.25, 0.25 ); vecNewVelocity.z += random->RandomFloat ( -0.25, 0.25 ); vecNewVelocity *= random->RandomFloat ( fMaxVelocity, fMinVelocity ); QAngle vecNewAngularVelocity = GetLocalAngularVelocity(); vecNewAngularVelocity.x = random->RandomFloat ( 100, 200 ); vecNewAngularVelocity.y = random->RandomFloat ( 100, 300 ); SetLocalAngularVelocity( vecNewAngularVelocity ); // copy owner's blood color SetBloodColor( pVictim->BloodColor() ); AdjustVelocityBasedOnHealth( pVictim->m_iHealth, vecNewVelocity ); // Attempt to be physical if we can if ( VPhysicsInitNormal( SOLID_BBOX, 0, false ) ) { IPhysicsObject *pObj = VPhysicsGetObject(); if ( pObj != NULL ) { AngularImpulse angImpulse = RandomAngularImpulse( -500, 500 ); pObj->AddVelocity( &vecNewVelocity, &angImpulse ); } } else { SetSolid( SOLID_BBOX ); SetCollisionBounds( vec3_origin, vec3_origin ); SetAbsVelocity( vecNewVelocity ); } SetCollisionGroup( COLLISION_GROUP_DEBRIS ); } LimitVelocity(); }
//========================================================= // Retire - stop being active //========================================================= void CNPC_BaseTurret::Retire(void) { // make the turret level m_vecGoalAngles.x = 0; m_vecGoalAngles.y = m_flStartYaw; SetNextThink( gpGlobals->curtime + 0.1 ); StudioFrameAdvance( ); EyeOff( ); if (!MoveTurret()) { if (m_iSpin) { SpinDownCall(); } else if (GetSequence() != TURRET_ANIM_RETIRE) { SetTurretAnim(TURRET_ANIM_RETIRE); CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "Turret.Undeploy" ); m_OnDeactivate.FireOutput(this, this); } //else if (IsSequenceFinished()) else if( GetSequence() == TURRET_ANIM_RETIRE && GetCycle() <= 0.0 ) { m_iOn = 0; m_flLastSight = 0; //SetTurretAnim(TURRET_ANIM_NONE); Vector curmins, curmaxs; curmins = WorldAlignMins(); curmaxs = WorldAlignMaxs(); curmaxs.z = m_iRetractHeight; curmins.z = -m_iRetractHeight; SetCollisionBounds( curmins, curmaxs ); if (m_iAutoStart) { SetThink(&CNPC_BaseTurret::AutoSearchThink); SetNextThink( gpGlobals->curtime + 0.1 ); } else { SetThink( &CBaseEntity::SUB_DoNothing ); } } } else { SetTurretAnim(TURRET_ANIM_SPIN); } }
void CBaseTurret::Retire(void) { // make the turret level m_vecGoalAngles = GetAngles( ); SetNextThink( gpGlobals->curtime + 0.1f ); StudioFrameAdvance( ); EyeOff( ); if ( m_Activity != ACT_TURRET_CLOSE ) { SetActivity( (Activity)ACT_TURRET_OPEN_IDLE ); if (!MoveTurret()) { SetActivity( (Activity)ACT_TURRET_CLOSE ); EmitSound( "NPC_Turret.Retire" ); m_OnRetire.FireOutput(NULL, this); } } else if (m_fSequenceFinished) { m_iOn = 0; m_flLastSight = 0; SetActivity( (Activity)ACT_TURRET_CLOSED_IDLE ); Vector curmins, curmaxs; curmins = WorldAlignMins(); curmaxs = WorldAlignMaxs(); curmaxs.z = m_iRetractHeight; curmins.z = -m_iRetractHeight; SetCollisionBounds( curmins, curmaxs ); Relink(); if (m_iAutoStart) { SetThink(AutoSearchThink); SetNextThink( gpGlobals->curtime + .1 ); } else { SetThink(SUB_DoNothing); } } }
void CHL2MP_Player::PostThink( void ) { BaseClass::PostThink(); if ( GetFlags() & FL_DUCKING ) SetCollisionBounds( VEC_CROUCH_TRACE_MIN, VEC_CROUCH_TRACE_MAX ); QAngle angles = GetLocalAngles(); angles[PITCH] = 0; SetLocalAngles( angles ); // Store the eye angles pitch so the client can compute its animation state correctly. m_angEyeAngles = EyeAngles(); m_PlayerAnimState->Update( m_angEyeAngles[YAW], m_angEyeAngles[PITCH] ); }
//----------------------------------------------------------------------------- // Rebuilds the scaled bounds from the prescaled bounds after a model's scale has changed //----------------------------------------------------------------------------- void CCollisionProperty::RefreshScaledCollisionBounds( void ) { SetCollisionBounds( m_vecMinsPreScaled, m_vecMaxsPreScaled ); SurroundingBoundsType_t nSurroundType = static_cast< SurroundingBoundsType_t >( m_nSurroundType.Get() ); if ( nSurroundType == USE_SPECIFIED_BOUNDS ) { SetSurroundingBoundsType( nSurroundType, &(m_vecSpecifiedSurroundingMinsPreScaled.Get()), &(m_vecSpecifiedSurroundingMaxsPreScaled.Get()) ); } else { SetSurroundingBoundsType( nSurroundType ); } }
void CBeam::RelinkBeam( void ) { // FIXME: Why doesn't this just define the absbox too? // It seems that we don't need to recompute the absbox // in CBaseEntity::SetObjectCollisionBox, in fact the absbox // computed there seems way too big const Vector &startPos = GetAbsStartPos(), &endPos = GetAbsEndPos(); // UNDONE: Should we do this to make the boxes smaller? //SetAbsOrigin( startPos ); Vector vecBeamMin, vecBeamMax; VectorMin( startPos, endPos, vecBeamMin ); VectorMax( startPos, endPos, vecBeamMax ); SetCollisionBounds( vecBeamMin - GetAbsOrigin(), vecBeamMax - GetAbsOrigin() ); }
//------------------------------------------------------------------------------ // Spawn //------------------------------------------------------------------------------ void CQUAGrenadeHelicopter::Spawn( void ) { Precache(); // point sized, solid, bouncing SetCollisionGroup( COLLISION_GROUP_PROJECTILE ); SetModel( "models/combine_helicopter/helicopter_bomb01.mdl" ); SetSolid( SOLID_BBOX ); SetCollisionBounds( Vector( -12.5, -12.5, -12.5 ), Vector( 12.5, 12.5, 12.5 ) ); VPhysicsInitShadow( false, false ); SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM ); SetElasticity( 0.5f ); AddEffects( EF_NOSHADOW ); // We're always being dropped beneath the helicopter; need to not // be affected by the rotor wash AddEFlags( EFL_NO_ROTORWASH_PUSH ); // contact grenades arc lower SetGravity( UTIL_ScaleForGravity( 400 ) ); // use a lower gravity for grenades to make them easier to see QAngle angles; VectorAngles(GetAbsVelocity(), angles ); SetLocalAngles( angles ); SetThink( NULL ); // Tumble in air QAngle vecAngVel( random->RandomFloat ( -100, -500 ), 0, 0 ); SetLocalAngularVelocity( vecAngVel ); // Explode on contact SetTouch( &CQUAGrenadeHelicopter::ExplodeConcussion ); m_bActivated = false; m_pWarnSound = NULL; m_flDamage = 75.0; // Allow player to blow this puppy up in the air m_takedamage = DAMAGE_YES; g_pNotify->AddEntity( this, this ); }
//========================================================= // Deploy - go active //========================================================= void CNPC_BaseTurret::Deploy(void) { SetNextThink( gpGlobals->curtime + 0.1 ); StudioFrameAdvance( ); if (GetSequence() != TURRET_ANIM_DEPLOY) { m_iOn = 1; SetTurretAnim(TURRET_ANIM_DEPLOY); CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "Turret.Deploy" ); m_OnActivate.FireOutput(this, this); } if (IsSequenceFinished()) { Vector curmins, curmaxs; curmins = WorldAlignMins(); curmaxs = WorldAlignMaxs(); curmaxs.z = m_iDeployHeight; curmins.z = -m_iDeployHeight; SetCollisionBounds( curmins, curmaxs ); m_vecCurAngles.x = 0; QAngle angles = GetAbsAngles(); if (m_iOrientation == TURRET_ORIENTATION_CEILING) { m_vecCurAngles.y = UTIL_AngleMod( angles.y + 180 ); } else { m_vecCurAngles.y = UTIL_AngleMod( angles.y ); } SetTurretAnim(TURRET_ANIM_SPIN); m_flPlaybackRate = 0; SetThink(&CNPC_BaseTurret::SearchThink); } m_flLastSight = gpGlobals->curtime + m_flMaxWait; }
void CBeam::RelinkBeam( void ) { // FIXME: Why doesn't this just define the absbox too? // It seems that we don't need to recompute the absbox // in CBaseEntity::SetObjectCollisionBox, in fact the absbox // computed there seems way too big Vector startPos = GetAbsStartPos(), endPos = GetAbsEndPos(); Vector vecAbsExtra1, vecAbsExtra2; bool bUseExtraPoints = false; #ifdef PORTAL CBaseEntity *pStartEntity = GetStartEntityPtr(); CTraceFilterSkipClassname traceFilter( pStartEntity, "prop_energy_ball", COLLISION_GROUP_NONE ); ITraceFilter *pEntityBeamTraceFilter = NULL; if ( pStartEntity ) pEntityBeamTraceFilter = pStartEntity->GetBeamTraceFilter(); CTraceFilterChain traceFilterChain( &traceFilter, pEntityBeamTraceFilter ); bUseExtraPoints = UTIL_Portal_Trace_Beam( this, startPos, endPos, vecAbsExtra1, vecAbsExtra2, &traceFilterChain ); #endif // UNDONE: Should we do this to make the boxes smaller? //SetAbsOrigin( startPos ); Vector vecBeamMin, vecBeamMax; VectorMin( startPos, endPos, vecBeamMin ); VectorMax( startPos, endPos, vecBeamMax ); if ( bUseExtraPoints ) { VectorMin( vecBeamMin, vecAbsExtra1, vecBeamMin ); VectorMin( vecBeamMin, vecAbsExtra2, vecBeamMin ); VectorMax( vecBeamMax, vecAbsExtra1, vecBeamMax ); VectorMax( vecBeamMax, vecAbsExtra2, vecBeamMax ); } SetCollisionBounds( vecBeamMin - GetAbsOrigin(), vecBeamMax - GetAbsOrigin() ); }
//----------------------------------------------------------------------------- // Purpose: Adds to beam entity list //----------------------------------------------------------------------------- void CBeam::AddEntity( void ) { // If set to invisible, skip. Do this before resetting the entity pointer so it has // valid data to decide whether it's visible. if ( !ShouldDraw() ) { return; } //FIXME: If we're hooked up to an attachment point, then recompute our bounds every frame if ( m_hAttachEntity[0].Get() || m_hAttachEntity[1].Get() ) { // Compute the bounds here... Vector mins, maxs; ComputeBounds( mins, maxs ); SetCollisionBounds( mins, maxs ); } MoveToLastReceivedPosition(); }
//------------------------------------------------ // Spawn //------------------------------------------------ void CPropVehicleManhack::Spawn( void ) { Precache(); SetModel( "models/vehicles/vehicle_manhackcontroller.mdl" ); SetCollisionGroup( COLLISION_GROUP_VEHICLE ); BaseClass::Spawn(); SetSolid( SOLID_BBOX ); AddSolidFlags( FSOLID_NOT_SOLID ); SetCollisionBounds( Vector(-16,-16,0), Vector(16,16,72) ); SetMoveType( MOVETYPE_NONE ); //SetRenderMode(kRenderTransColor ); //SetRenderColorA(0); AddEffects( EF_NODRAW ); //VPhysicsInitShadow( true, false ); m_takedamage = DAMAGE_EVENTS_ONLY; m_hManhack = NULL; for (int i=0; i<NUMBER_OF_MAX_CONTROLLABLE_MANHACKS; i++) { m_hSetOfManhacks[i] = NULL; } m_hTarget = NULL; m_bDriverDucked = false; m_bHadDriver = false; m_fTimeToChangeManhack = 0; m_iHintTimesShown = 0; m_iHintNoSwapTimesShown = 0; m_iCurrentManhackIndex = -1; m_flLastWarningSound = 0; }
bool C_ASW_Snow_Volume::Initialize() { if ( InitializeAsClientEntity( NULL, false ) == false ) { return false; } Spawn(); const model_t *mod = GetModel(); if ( mod ) { Vector mins, maxs; modelinfo->GetModelBounds( mod, mins, maxs ); SetCollisionBounds( mins, maxs ); } SetBlocksLOS( false ); // this should be a small object SetNextClientThink( CLIENT_THINK_NEVER ); return true; }
bool CBoneFollower::Init( CBaseEntity *pOwner, const char *pModelName, solid_t &solid, const Vector &position, const QAngle &orientation ) { SetOwnerEntity( pOwner ); UTIL_SetModel( this, pModelName ); AddEffects( EF_NODRAW ); // invisible m_modelIndex = modelinfo->GetModelIndex( pModelName ); m_solidIndex = solid.index; SetAbsOrigin( position ); SetAbsAngles( orientation ); SetMoveType( MOVETYPE_PUSH ); SetSolid( SOLID_VPHYSICS ); SetCollisionGroup( pOwner->GetCollisionGroup() ); AddSolidFlags( FSOLID_CUSTOMRAYTEST | FSOLID_CUSTOMBOXTEST ); solid.params.pGameData = (void *)this; IPhysicsObject *pPhysics = VPhysicsInitShadow( false, false, &solid ); if ( !pPhysics ) return false; // we can't use the default model bounds because each entity is only one bone of the model // so compute the OBB of the physics model and use that. Vector mins, maxs; physcollision->CollideGetAABB( &mins, &maxs, pPhysics->GetCollide(), vec3_origin, vec3_angle ); SetCollisionBounds( mins, maxs ); pPhysics->SetCallbackFlags( pPhysics->GetCallbackFlags() | CALLBACK_GLOBAL_TOUCH ); pPhysics->EnableGravity( false ); // This is not a normal shadow controller that is trying to go to a space occupied by an entity in the game physics // This entity is not running PhysicsPusher(), so Vphysics is supposed to move it // This line of code informs vphysics of that fact if ( pOwner->IsNPC() ) { pPhysics->GetShadowController()->SetPhysicallyControlled( true ); } return true; }
void CSpriteTrail::Spawn( void ) { #ifdef CLIENT_DLL BaseClass::Spawn(); #else if ( GetModelName() != NULL_STRING ) { BaseClass::Spawn(); return; } SetModelName( m_iszSpriteName ); BaseClass::Spawn(); SetSolid( SOLID_NONE ); SetMoveType( MOVETYPE_NOCLIP ); SetCollisionBounds( vec3_origin, vec3_origin ); TurnOn(); #endif }
void CASW_Queen_Divers::Spawn() { BaseClass::Spawn(); Precache(); SetModel( ASW_QUEEN_DIVER_MODEL ); SetMoveType( MOVETYPE_NONE ); //SetSolid(SOLID_VPHYSICS); SetSolid( SOLID_BBOX ); SetCollisionGroup( COLLISION_GROUP_NONE ); m_takedamage = DAMAGE_YES; m_iHealth = 100; m_iMaxHealth = m_iHealth; int iIdleSeq = LookupSequence("idle"); SetSequence(iIdleSeq); AddEffects(EF_NOSHADOW); SetVisible(false); // stays hidden until we start a diver attack //VPhysicsInitStatic(); SetCollisionBounds( Vector(-32, -100, -5), Vector(32, 100, 72) ); SetThink( &CASW_Queen_Divers::AnimThink ); SetNextThink( gpGlobals->curtime + 0.1f); }
//----------------------------------------------------------------------------- // Purpose: Spawn function //----------------------------------------------------------------------------- void CWeaponSpawner::Spawn( void ) { CEconItemDefinition *pItemDef = GetItemSchema()->GetItemDefinition( m_nItemID ); if ( !pItemDef ) { Warning( "tf_weaponspawner has incorrect item ID %d. DELETED\n", m_nItemID ); UTIL_Remove( this ); return; } m_Item.SetItemDefIndex( m_nItemID ); Precache(); SetModel( m_Item.GetWorldDisplayModel() ); BaseClass::Spawn(); // Ensures consistent trigger bounds for all weapons. (danielmm8888) SetSolid( SOLID_BBOX ); SetCollisionBounds( -Vector( 22, 22, 15 ), Vector( 22, 22, 15 ) ); AddEffects( EF_ITEM_BLINK ); }
void CPlantedC4::Init( CCSPlayer *pevOwner, Vector vecStart, QAngle vecAngles ) { SetMoveType( MOVETYPE_NONE ); SetSolid( SOLID_BBOX ); SetModel( PLANTED_C4_MODEL ); // Change this to c4 model SetCollisionBounds( Vector( 0, 0, 0 ), Vector( 8, 8, 8 ) ); SetAbsOrigin( vecStart ); SetAbsAngles( vecAngles ); SetOwnerEntity( pevOwner ); // Detonate in "time" seconds SetThink( &CPlantedC4::C4Think ); //pGrenade->SetTouch( &CPlantedC4::C4Touch ); SetNextThink( gpGlobals->curtime + 0.1f ); m_flC4Blow = gpGlobals->curtime + c4timer.GetInt(); m_flNextFreqInterval = c4timer.GetInt() / 4; m_flNextFreq = gpGlobals->curtime; m_flNextBeep = gpGlobals->curtime + 0.5; m_iCurWave = 0; m_sBeepName = NULL; m_flNextBlink = gpGlobals->curtime + BLINK_INTERVAL; m_flNextDefuse = 0; m_bStartDefuse = false; m_bJustBlew = false; SetFriction( 0.9 ); Relink(); }
bool C_PhysPropClientside::Initialize() { if ( InitializeAsClientEntity( STRING(GetModelName()), RENDER_GROUP_OPAQUE_ENTITY ) == false ) { return false; } const model_t *mod = GetModel(); if ( mod ) { Vector mins, maxs; modelinfo->GetModelBounds( mod, mins, maxs ); SetCollisionBounds( mins, maxs ); } solid_t tmpSolid; // Create the object in the physics system if ( !PhysModelParseSolid( tmpSolid, this, GetModelIndex() ) ) { DevMsg("C_PhysPropClientside::Initialize: PhysModelParseSolid failed for entity %i.\n", GetModelIndex() ); return false; } else { m_pPhysicsObject = VPhysicsInitNormal( SOLID_VPHYSICS, 0, m_spawnflags & SF_PHYSPROP_START_ASLEEP, &tmpSolid ); if ( !m_pPhysicsObject ) { // failed to create a physics object DevMsg(" C_PhysPropClientside::Initialize: VPhysicsInitNormal() failed for %s.\n", STRING(GetModelName()) ); return false; } } // We want touch calls when we hit the world unsigned int flags = VPhysicsGetObject()->GetCallbackFlags(); VPhysicsGetObject()->SetCallbackFlags( flags | CALLBACK_GLOBAL_TOUCH_STATIC ); if ( m_spawnflags & SF_PHYSPROP_MOTIONDISABLED ) { m_pPhysicsObject->EnableMotion( false ); } Spawn(); // loads breakable & prop data if ( m_iPhysicsMode == PHYSICS_MULTIPLAYER_AUTODETECT ) { m_iPhysicsMode = GetAutoMultiplayerPhysicsMode( CollisionProp()->OBBSize(), m_pPhysicsObject->GetMass() ); } if ( m_spawnflags & SF_PHYSPROP_FORCE_SERVER_SIDE ) { // forced to be server-side by map maker return false; } if ( m_iPhysicsMode != PHYSICS_MULTIPLAYER_CLIENTSIDE ) { // spawn only clientside entities return false; } else { if ( engine->IsInEditMode() ) { // don't spawn in map edit mode return false; } } if ( m_fadeMinDist < 0 ) { // start fading out at 75% of r_propsmaxdist m_fadeMaxDist = r_propsmaxdist.GetFloat(); m_fadeMinDist = r_propsmaxdist.GetFloat() * 0.75f; } // player can push it away SetCollisionGroup( COLLISION_GROUP_PUSHAWAY ); UpdatePartitionListEntry(); CollisionProp()->UpdatePartition(); SetBlocksLOS( false ); // this should be a small object // Set up shadows; do it here so that objects can change shadowcasting state CreateShadow(); UpdateVisibility(); SetNextClientThink( CLIENT_THINK_NEVER ); return true; }