//----------------------------------------------------------------------------- // Purpose: Attach the player to the "Buff Station." //----------------------------------------------------------------------------- void CObjectBuffStation::AttachPlayer( CBaseTFPlayer *pPlayer ) { // Player shouldn't already be attached. Assert( !IsPlayerAttached( pPlayer ) ); // Check to see if the player is alive and on the correct team. if ( !pPlayer->IsAlive() || !pPlayer->InSameTeam( this ) ) return; // Check attachment availability. if ( m_nPlayerCount == BUFF_STATION_MAX_PLAYERS ) { // Unless the player is the owner he cannot connect. if ( pPlayer != GetOwner() ) return; // Kick a non-owning player off. DetachPlayerByIndex( BUFF_STATION_MAX_PLAYERS - 1 ); } // This will disconnect the player from other Buff Stations, and keep track of important player events. g_pNotify->ReportNamedEvent( pPlayer, "PlayerAttachedToGenerator" ); g_pNotify->AddEntity( this, pPlayer ); // Connect player. // Find the nearest empty slot int iNearest = BUFF_STATION_MAX_PLAYERS; float flNearestDist = 9999*9999; for ( int iPlayer = 0; iPlayer < BUFF_STATION_MAX_PLAYERS; iPlayer++ ) { if ( !m_hPlayers[iPlayer] ) { Vector vecPoint; QAngle angPoint; GetAttachment( m_aPlayerAttachInfo[iPlayer].m_iAttachPoint, vecPoint, angPoint ); float flDistance = ( vecPoint - pPlayer->GetAbsOrigin() ).LengthSqr(); if ( flDistance < flNearestDist ) { flNearestDist = flDistance; iNearest = iPlayer; } } } Assert( iNearest != BUFF_STATION_MAX_PLAYERS ); m_hPlayers.Set( iNearest, pPlayer ); m_aPlayerAttachInfo[iNearest].m_DamageModifier.SetModifier( obj_buff_station_damage_modifier.GetFloat() ); m_aPlayerAttachInfo[iNearest].m_hRope = CreateRope( pPlayer, m_aPlayerAttachInfo[iNearest].m_iAttachPoint ); m_nPlayerCount++; // Tell the player to constrain his movement. pPlayer->ActivateMovementConstraint( this, GetAbsOrigin(), obj_buff_station_range.GetFloat(), 75.0f, 0.15f ); // Update think. if ( GetNextThink(BUFF_STATION_BOOST_PLAYER_THINK_CONTEXT) > gpGlobals->curtime + BUFF_STATION_BOOST_PLAYER_THINK_INTERVAL ) SetNextThink( gpGlobals->curtime + BUFF_STATION_BOOST_PLAYER_THINK_INTERVAL, BUFF_STATION_BOOST_PLAYER_THINK_CONTEXT ); // Update network state. NetworkStateChanged(); }
//------------------------------------------------------------------------ bool CVehicleActionDeployRope::DeployRope() { IActorSystem* pActorSystem = gEnv->pGame->GetIGameFramework()->GetIActorSystem(); assert(pActorSystem); IActor* pActor = pActorSystem->GetActor(m_actorId); if (!pActor) return false; Vec3 upperPos = m_pRopeHelper->GetWorldTM().GetTranslation(); Vec3 lowerPos(upperPos.x, upperPos.y, upperPos.z - g_ropeLenght); m_ropeUpperId = CreateRope(m_pVehicle->GetEntity()->GetPhysics(), upperPos, upperPos); m_ropeLowerId = CreateRope(pActor->GetEntity()->GetPhysics(), upperPos, lowerPos); m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_AlwaysUpdate); return true; }
//---------------------------------------------------------------------------- void Rope::CreateScene () { mScene = new0 Node(); mTrnNode = new0 Node(); mScene->AttachChild(mTrnNode); mWireState = new0 WireState(); mRenderer->SetOverrideWireState(mWireState); CreateSprings(); CreateRope(); }
//---------------------------------------------------------------------------- void Rope::CreateScene () { m_spkScene = new Node(1); m_spkTrnNode = new Node(1); m_spkScene->AttachChild(m_spkTrnNode); m_spkWireframe = new WireframeState; m_spkScene->SetRenderState(m_spkWireframe); ZBufferState* pkZBuffer = new ZBufferState; pkZBuffer->Enabled() = true; pkZBuffer->Writeable() = true; pkZBuffer->Compare() = ZBufferState::CF_LEQUAL; m_spkScene->SetRenderState(pkZBuffer); CreateSprings(); CreateRope(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponGrapple::FireHook(void) { if (m_bMustReload) return; CBasePlayer *pOwner = ToBasePlayer(GetOwner()); if (pOwner == NULL) return; #ifndef CLIENT_DLL Vector vecAiming = pOwner->GetAutoaimVector(0); Vector vecSrc = pOwner->Weapon_ShootPosition(); QAngle angAiming; VectorAngles(vecAiming, angAiming); CGrappleHook *pHook = CGrappleHook::HookCreate(vecSrc, angAiming, this); if (pOwner->GetWaterLevel() == 3) { pHook->SetAbsVelocity(vecAiming * BOLT_WATER_VELOCITY); } else { pHook->SetAbsVelocity(vecAiming * BOLT_AIR_VELOCITY); } m_hHook = pHook; CreateRope(); #endif pOwner->ViewPunch(QAngle(-2, 0, 0)); WeaponSound(SINGLE); WeaponSound(SPECIAL2); SendWeaponAnim(ACT_VM_PRIMARYATTACK); m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + 0.75; DoLoadEffect(); SetChargerState(CHARGER_STATE_DISCHARGE); }
//----------------------------------------------------------------------------- // Purpose: Attach the object to the "Buff Station." //----------------------------------------------------------------------------- void CObjectBuffStation::AttachObject( CBaseObject *pObject, bool bPlacing ) { // Check to see if the object is already attached. if ( IsObjectAttached( pObject ) ) return; // Check to see if the object is on the correct team. if ( !pObject->InSameTeam( this ) ) return; // Check to see if the object is already being buffed by another station. if ( pObject->IsHookedAndBuffed() ) return; // Check attachment availability. if ( m_nObjectCount == BUFF_STATION_MAX_OBJECTS ) return; // Attach cable to object - get the attachment point. int nObjectAttachPoint = pObject->LookupAttachment( "boostpoint" ); if ( nObjectAttachPoint <= 0 ) nObjectAttachPoint = 1; // Connect object. m_hObjects.Set( m_nObjectCount, pObject ); m_aObjectAttachInfo[m_nObjectCount].m_DamageModifier.SetModifier( obj_buff_station_damage_modifier.GetFloat() ); m_aObjectAttachInfo[m_nObjectCount].m_hRope = CreateRope( pObject, m_aObjectAttachInfo[m_nObjectCount].m_iAttachPoint, nObjectAttachPoint ); m_nObjectCount += 1; // If we're placing, we're pretending to buff objects, but not really powering them pObject->SetBuffStation( this, bPlacing ); // Update think. if ( GetNextThink(BUFF_STATION_BOOST_OBJECT_THINK_CONTEXT) > gpGlobals->curtime + BUFF_STATION_BOOST_OBJECT_THINK_INTERVAL ) SetNextThink( gpGlobals->curtime + BUFF_STATION_BOOST_OBJECT_THINK_INTERVAL, BUFF_STATION_BOOST_OBJECT_THINK_CONTEXT ); // Update network state. NetworkStateChanged(); }
//---------------------------------------------------------------------------- void Castle::CreateScene () { mScene = new0 Node(); mTrnNode = new0 Node(); mScene->AttachChild(mTrnNode); mWireState = new0 WireState(); mRenderer->SetOverrideWireState(mWireState); CreateLights(); CreateEffects(); CreateTextures(); CreateSharedMeshes(); CreateWallTurret02(); CreateWallTurret01(); CreateWall02(); CreateWall01(); CreateQuadPatch01(); CreateMainGate01(); CreateMainGate(); CreateExterior(); CreateFrontHall(); CreateFrontRamp(); CreateDrawBridge(); CreateCylinder02(); CreateBridge(); CreateLargePort(); CreateSmallPort(1); CreateSmallPort(2); CreateRope(1); CreateRope(2); int i; for (i = 1; i <= 7; ++i) { CreateWoodShield(i); } for (i = 1; i <= 17; ++i) { CreateTorch(i); } for (i = 1; i <= 3; ++i) { CreateKeg(i); } for (i = 2; i <= 37; ++i) { CreateBarrel(i); } for (i = 1; i <= 48; ++i) { CreateDoorFrame(i); } for (i = 49; i <= 60; ++i) { CreateDoorFramePivotTrn(i); } CreateDoorFrame(61); CreateDoorFrameScalePivotTrn(62); CreateDoorFrameScalePivotTrn(63); for (i = 64; i <= 68; ++i) { CreateDoorFrame(i); } for (i = 69; i <= 78; ++i) { CreateDoorFramePivotTrn(i); } CreateDoorFrame(79); CreateDoorFrameScalePivotTrn(80); CreateDoorFrameScalePivotTrn(81); CreateDoorFramePivotTrn(82); CreateDoorFramePivotTrn(83); CreateDoorFramePivotTrn(73); CreateBunk(1); for (i = 4; i <= 20; ++i) { CreateBunk(i); } for (i = 1; i <= 36; ++i) { CreateBench(i); } for (i = 1; i <= 9; ++i) { CreateTable(i); } for (i = 1; i <= 4; ++i) { CreateBarrelRack(i); } for (i = 1; i <= 36; ++i) { CreateChest(i); } for (i = 1; i <= 3; ++i) { CreateCeilingLight(i); } for (i = 1; i <= 7; ++i) { CreateSquareTable(i); } for (i = 1; i <= 27; ++i) { CreateSimpleChair(i); } for (i = 1; i <= 42; ++i) { CreateMug(i); } for (i = 1; i <= 9; ++i) { CreateDoor(i); } CreateTerrain(); CreateSkyDome(); CreateWater(); CreateWater2(); }