Пример #1
0
bool CPropVehicleManhack::CanEnterVehicle( CBaseEntity *pEntity )
{
	// Prevent entering if the vehicle's being driven by an NPC
	if ( GetDriver() && GetDriver() != pEntity )
		return false;

	return true; 
}
Пример #2
0
//-----------------------------------------------------------------------------
// Purpose: Return true of the player's allowed to enter / exit the vehicle
//-----------------------------------------------------------------------------
bool CPropCrane::CanEnterVehicle( CBaseEntity *pEntity )
{
	// Prevent entering if the vehicle's being driven by an NPC
	if ( GetDriver() && GetDriver() != pEntity )
		return false;
	
	// Prevent entering if the vehicle's locked
	return ( !m_bLocked );
}
//-----------------------------------------------------------------------------
// Purpose: Return true of the player's allowed to enter / exit the vehicle
//-----------------------------------------------------------------------------
bool CPropVehicleChoreoGeneric::CanEnterVehicle( CBaseEntity *pEntity )
{
	// Prevent entering if the vehicle's being driven by an NPC
	if ( GetDriver() && GetDriver() != pEntity )
		return false;

	// Prevent entering if the vehicle's locked
	return !m_bLocked;
}
Пример #4
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPropVehicleManhack::Think(void)
{
	if ( GetDriver() )
	{
		if (GlobalEntity_GetState("manhacks_not_controllable") == GLOBAL_ON)
			ForcePlayerOut();

		BaseClass::Think();

		SetNextThink( gpGlobals->curtime );

		StudioFrameAdvance();

		if (m_hManhack == NULL || m_iManhackHealth <= 0 || m_iManhackDistance >= 100)
		{
			if (m_iManhackDistance >= 100)
			{
				CNPC_Manhack *pManhack = m_hManhack;

				if (pManhack)
				{
					pManhack->ComeBackToPlayer(m_hPlayer, 8.0f);
				}
			}

			/*if (!FindNextManhack())
			{
				SetLocator( NULL );
				ForcePlayerOut();
				DestroyAllManhacks();
				UTIL_Remove(this);
			}*/

			if (!FindNextManhack(true))
			{
				ForcePlayerOut();
			}
		} 
		else if ( m_hPlayer.Get() != NULL )
		{
			UpdateManhackView( m_hPlayer.Get() );	
			UpdateManhackDistance(this);
		}

		if (!GetDriver() && m_bHadDriver)
		{
			DevMsg("We have no driver, lets disappear");
			m_bHadDriver = false;
			//SetRenderMode(kRenderTransColor );
			//SetRenderColorA(0);
			AddEffects( EF_NODRAW );
			SetSolid(SOLID_NONE);
			AddSolidFlags( FSOLID_NOT_SOLID );
		}
	}
}
Пример #5
0
//TERO: We want to take damage normally since this is not really a vehicle but a fake body
//		We exit the vehicle so that it wouldn't look silly stiff man from the manhack point of view
int CPropVehicleManhack::OnTakeDamage( const CTakeDamageInfo &inputInfo )
{
	//Check to do damage to driver
	if ( GetDriver() )
	{
		GetDriver()->TakeDamage( inputInfo );
		ForcePlayerOut();
	}

	return 0;
}
Пример #6
0
//-----------------------------------------------------------------------------
// Purpose: Return true of the player's allowed to enter the vehicle
//-----------------------------------------------------------------------------
bool CPropVehicleDriveable::CanEnterVehicle( CBaseEntity *pEntity )
{
	// Prevent entering if the vehicle's being driven by an NPC
	if ( GetDriver() && GetDriver() != pEntity )
		return false;

	if ( IsOverturned() )
		return false;

	// Prevent entering if the vehicle's locked, or if it's moving too fast.
	return ( !m_bLocked && (m_nSpeed <= m_flMinimumSpeedToEnterExit) );
}
Пример #7
0
CClientPlayer * CClientVehicle::GetOccupant(BYTE byteSeatId)
{
	if(byteSeatId == 0)
		return GetDriver();

	return GetPassenger(byteSeatId - 1);
}
Пример #8
0
void GaussianBlurRender::Render(Engine& engine, IDirect3DSurface9* backBuffer, IDirect3DSurface9* dsSurface)
{
	if (!_shader || !GetRT() || !GetRT()->IsInit() || !_colorTex)
		throw int();

	_shader->Apply(engine);
	IDirect3DSurface9* targetSurf;
	GetRT()->GetTex()->GetSurfaceLevel(0, &targetSurf);
	GetDriver().GetDevice()->SetRenderTarget(0, targetSurf);
	engine.SetTexture(0, _colorTex->GetTex());

	//Horizontal
	_shader->curTechnique = GaussianBlurShader::ttHorizontal;
	engine.BeginDraw();
	DrawScreenQuad(engine);
	engine.EndDraw();

	//Vertical
	_shader->curTechnique = GaussianBlurShader::ttVertical;
	engine.BeginDraw();
	DrawScreenQuad(engine);
	engine.EndDraw();

	_shader->UnApply(engine);
	engine.SetTexture(0, 0);	
}
Пример #9
0
CPlayerEntity * CVehicleEntity::GetOccupant(BYTE byteSeatId)
{
	if(byteSeatId == 0)
		return GetDriver();

	return new CPlayerEntity(); //GetPassenger(byteSeatId - 1);
}
Пример #10
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPropVehicleDriveable::Think()
{
	BaseClass::Think();

	// Always think if we have any driver in us
	if ( GetDriver() )
	{
		SetNextThink( gpGlobals->curtime );
	}

	// If we have an NPC Driver, tell him to drive
	if ( m_hNPCDriver )
	{
		GetServerVehicle()->NPC_DriveVehicle();
	}

	// Keep thinking while we're waiting to turn off the keep upright
	if ( m_flTurnOffKeepUpright )
	{
		SetNextThink( gpGlobals->curtime );

		// Time up?
		if ( m_hKeepUpright && m_flTurnOffKeepUpright < gpGlobals->curtime && m_hKeepUpright )
		{
			variant_t emptyVariant;
			m_hKeepUpright->AcceptInput( "TurnOff", this, this, emptyVariant, USE_TOGGLE );
			m_flTurnOffKeepUpright = 0;

			UTIL_Remove( m_hKeepUpright );
		}
	}
}
Пример #11
0
CPlayerEntity * CVehicleEntity::GetOccupant(BYTE byteSeatId)
{
	if(byteSeatId == 0)
		return GetDriver();

	return nullptr;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPropVehicleViewController::InputForcePlayerOut( inputdata_t &inputdata )
{
	if ( !GetDriver() )
		return;

	GetServerVehicle()->HandlePassengerExit( m_hPlayer );
}
Пример #13
0
void CVehicleEntity::Interpolate()
{
	// Do we have a driver?
	if(GetDriver())
	{
		// Update our target position
		UpdateTargetPosition();

		// Update our target rotation
		UpdateTargetRotation();

		// Update our interior
		UpdateInterior(true);
	}
	else
	{
		// Update our interior
		UpdateInterior(false);

		// Remove our target position
		RemoveTargetPosition();

		// Remove our target rotation
		RemoveTargetRotation();
	}
}
Пример #14
0
void GetComPort(const string& dir, vector<basic_string<char> >& ports)
{
    // Get the driver the device is using
    string driver = GetDriver(dir);
    struct serial_struct serinfo;
    // Skip devices without a driver
    if (driver.size() > 0)
    {
        string devfile = string("/dev/") + basename(dir.c_str());
        // any driver will do eg. serial8250 pl2303 cdc_acm ftdi_sio, not just "serial"
        // Try to open the device
        int fd = open(devfile.c_str(), O_RDWR | O_NONBLOCK | O_NOCTTY);
        if (fd >= 0)
        {
            // Get serial_info
            if (ioctl(fd, TIOCGSERIAL, &serinfo) == 0)
            {
                // If device type is no PORT_UNKNOWN we accept the port
                if (serinfo.type != PORT_UNKNOWN)
                {
                    ports.push_back(devfile);
                }
            }
            close(fd);
        }
    }
}
void UUnitTestNetConnection::HandleClientPlayer(class APlayerController* PC, class UNetConnection* NetConnection)
{
	// Implement only essential parts of the original function, as we want to block most of it (triggers level change code)
	PC->Role = ROLE_AutonomousProxy;
	PC->NetConnection = NetConnection;

	PlayerController = PC;
	OwningActor = PC;

	// @todo #JohnBReview: This might cause undesirable behaviour, if - for example - HandleDisconnect gets called by
	//				RPC's, so may want to create a fake localplayer instead
	PC->Player = GEngine->GetFirstGamePlayer(NUTUtil::GetPrimaryWorld());

	// Sometimes, e.g. when executing in a commandlet, there is no available player, and one has to be created
	if (PC->Player == NULL)
	{
		// Do nothing, other than just create the raw object
		PC->Player = NewObject<ULocalPlayer>(GEngine, GEngine->LocalPlayerClass);
	}


	// Pass on notification
	UNetDriver* CurDriver = GetDriver();
	FNetworkNotifyHook* NotifyHook = (Driver != NULL ? (FNetworkNotifyHook*)CurDriver->Notify : NULL);

	if (NotifyHook != NULL)
	{
		NotifyHook->NotifyHandleClientPlayer(PC, NetConnection);
	}
}
Пример #16
0
bool UDemoNetConnection::ClientHasInitializedLevelFor(const UObject* TestObject) const
{
	// We save all currently streamed levels into the demo stream so we can force the demo playback client
	// to stay in sync with the recording server
	// This may need to be tweaked or re-evaluated when we start recording demos on the client
	return ( GetDriver()->DemoFrameNum > 2 || Super::ClientHasInitializedLevelFor( TestObject ) );
}
Пример #17
0
void unregister_cdrom(int drive)
{
	int device = GetDriver(drive);
	if (device >= 4)
		return;
	cd_drives[drive] = -1;
	numDrives--;
}
Пример #18
0
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool CPropAPC::ShouldAttractAutoAim( CBaseEntity *pAimingEnt )
{
	if( IsXbox() && pAimingEnt->IsPlayer() && GetDriver() )
	{
		return true;
	}

	return BaseClass::ShouldAttractAutoAim( pAimingEnt );
}
Пример #19
0
//-----------------------------------------------------------------------------
// Purpose: // The player takes damage if he hits something going fast enough
//-----------------------------------------------------------------------------
void CPropVehicleDriveable::VPhysicsCollision( int index, gamevcollisionevent_t *pEvent )
{
	// Don't care if we don't have a driver
	if ( !GetDriver() )
		return;

	// Make sure we don't keep hitting the same entity
	int otherIndex = !index;
	CBaseEntity *pHitEntity = pEvent->pEntities[otherIndex];
	if ( pEvent->deltaCollisionTime < 0.5 && (pHitEntity == this) )
		return;

	BaseClass::VPhysicsCollision( index, pEvent );

	// If we hit hard enough, damage the player
	// Don't take damage from ramming bad guys
	if ( pHitEntity->MyNPCPointer() )
		return;

	// Don't take damage from ramming ragdolls
	if ( pEvent->pObjects[otherIndex]->GetGameFlags() & FVPHYSICS_PART_OF_RAGDOLL )
		return;

	// Ignore func_breakables
	CBreakable *pBreakable = dynamic_cast<CBreakable *>(pHitEntity);
	if ( pBreakable )
	{
		// ROBIN: Do we want to only do this on func_breakables that are about to die?
		//if ( pBreakable->HasSpawnFlags( SF_PHYSICS_BREAK_IMMEDIATELY ) )
		return;
	}

	// Over our skill's minimum crash level?
	int damageType = 0;
	float flDamage = CalculatePhysicsImpactDamage( index, pEvent, gDefaultPlayerVehicleImpactDamageTable, 1.0, true, damageType );
	if ( flDamage > 0 )
	{
		Vector damagePos;
		pEvent->pInternalData->GetContactPoint( damagePos );
		Vector damageForce = pEvent->postVelocity[index] * pEvent->pObjects[index]->GetMass();
		CTakeDamageInfo info( this, GetDriver(), damageForce, damagePos, flDamage, damageType );
		GetDriver()->TakeDamage( info );
	}
}
Пример #20
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
int CASW_PropJeep::OnTakeDamage( const CTakeDamageInfo &inputInfo )
{
	//Do scaled up physics damage to the car
	CTakeDamageInfo info = inputInfo;
	info.ScaleDamage( 25 );
	
	// HACKHACK: Scale up grenades until we get a better explosion/pressure damage system
	if ( inputInfo.GetDamageType() & DMG_BLAST )
	{
		info.SetDamageForce( inputInfo.GetDamageForce() * 10 );
	}
	VPhysicsTakeDamage( info );

	// reset the damage
	info.SetDamage( inputInfo.GetDamage() );

	// small amounts of shock damage disrupt the car, but aren't transferred to the player
	if ( info.GetDamageType() == DMG_SHOCK )
	{
		if ( info.GetDamage() <= 10 )
		{
			// take 10% damage and make the engine stall
			info.ScaleDamage( 0.1 );
			m_throttleDisableTime = gpGlobals->curtime + 2;
		}
	}

	//Check to do damage to driver
	if ( GetDriver() )
	{
		//Take no damage from physics damages
		if ( info.GetDamageType() & DMG_CRUSH )
			return 0;

		// Take the damage (strip out the DMG_BLAST)
		info.SetDamageType( info.GetDamageType() & (~DMG_BLAST) );
		GetDriver()->TakeDamage( info );
	}

	return 0;
}
Пример #21
0
void UDemoNetConnection::LowLevelSend( void* Data, int32 Count )
{
	if ( Count == 0 )
	{
		UE_LOG( LogDemo, Warning, TEXT( "UDemoNetConnection::LowLevelSend: Ignoring empty packet." ) );
		return;
	}

	if ( Count > MAX_DEMO_READ_WRITE_BUFFER )
	{
		UE_LOG( LogDemo, Fatal, TEXT( "UDemoNetConnection::LowLevelSend: Count > MAX_DEMO_READ_WRITE_BUFFER." ) );
	}

	if ( !GetDriver()->ServerConnection && GetDriver()->FileAr )
	{
		// If we're outside of an official demo frame, we need to queue this up or it will throw off the stream
		if ( !GetDriver()->bIsRecordingDemoFrame )
		{
			FQueuedDemoPacket & B = *( new( QueuedDemoPackets )FQueuedDemoPacket );
			B.Data.AddUninitialized( Count );
			FMemory::Memcpy( B.Data.GetData(), Data, Count );
			return;
		}

		*GetDriver()->FileAr << Count;
		GetDriver()->FileAr->Serialize( Data, Count );
		
#if DEMO_CHECKSUMS == 1
		uint32 Checksum = FCrc::MemCrc32( Data, Count, 0 );
		*GetDriver()->FileAr << Checksum;
#endif
	}
}
Пример #22
0
void UDemoNetConnection::FlushNet( bool bIgnoreSimulation )
{
	// in playback, there is no data to send except
	// channel closing if an error occurs.
	if ( GetDriver()->ServerConnection != NULL )
	{
		InitSendBuffer();
	}
	else
	{
		Super::FlushNet( bIgnoreSimulation );
	}
}
Пример #23
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CASW_PropJeep::CheckWaterLevel( void )
{
	CBaseEntity *pEntity = GetDriver();
	if ( pEntity && pEntity->IsPlayer() )
	{
		CBasePlayer *pPlayer = static_cast<CBasePlayer*>( pEntity );
		
		Vector vecAttachPoint;
		QAngle vecAttachAngles;
		
		// Check eyes. (vehicle_driver_eyes point)
		int iAttachment = LookupAttachment( "vehicle_driver_eyes" );
		GetAttachment( iAttachment, vecAttachPoint, vecAttachAngles );

		// Add the jeep's Z view offset
		Vector vecUp;
		AngleVectors( vecAttachAngles, NULL, NULL, &vecUp );
		vecUp.z = clamp( vecUp.z, 0.0f, vecUp.z );
		vecAttachPoint.z += r_JeepViewZHeight.GetFloat() * vecUp.z;

		bool bEyes = ( UTIL_PointContents( vecAttachPoint, MASK_WATER ) & MASK_WATER ) ? true : false;
		if ( bEyes )
		{
			pPlayer->SetWaterLevel( WL_Eyes );
			return;
		}

		// Check waist.  (vehicle_engine point -- see parent function).
		if ( m_WaterData.m_bBodyInWater )
		{
			pPlayer->SetWaterLevel( WL_Waist );
			return;
		}

		// Check feet. (vehicle_feet_passenger0 point)
		iAttachment = LookupAttachment( "vehicle_feet_passenger0" );
		GetAttachment( iAttachment, vecAttachPoint, vecAttachAngles );
		bool bFeet = ( UTIL_PointContents( vecAttachPoint, MASK_WATER ) & MASK_WATER ) ? true : false;
		if ( bFeet )
		{
			pPlayer->SetWaterLevel( WL_Feet );
			return;
		}

		// Not in water.
		pPlayer->SetWaterLevel( WL_NotInWater );
	}
}
Пример #24
0
static int ReadSectors(int drive, Bit32u sector, Bit16u num, unsigned char *buf)
{
	unsigned char req_buf[24];
	unsigned save_ax = _AX;
	int error;
	Bit8u driver = GetDriver(drive);
	if (driver >= 4)
		return MSCDEX_ERROR_UNKNOWN_DRIVE;
	*CALC_PTR(req_buf, MSCD_READ_STARTSECTOR, u_long) = sector;
	*CALC_PTR(req_buf, MSCD_READ_ADRESSING, u_char) = 0;
	*CALC_PTR(req_buf, MSCD_READ_NUMSECTORS, u_short) = num;
	_AH = 2 | (driver << 6);
	cdrom_helper(req_buf, buf);
	error = _AL == 0 ? 0 : MSCDEX_ERROR_DRIVE_NOT_READY;
	_AX = save_ax;
	return error;
}
Пример #25
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPropVehicleManhack::ForcePlayerOut()
{
	if ( !GetDriver() )
		return;

	CBasePlayer *pPlayer = m_hPlayer;
	if ( !pPlayer )
		return;

	pPlayer->LeaveVehicle(GetAbsOrigin(), GetAbsAngles());

	//Lets make the "vehicle" invisible and not solid
	//SetRenderMode(kRenderTransColor );
	//SetRenderColorA(0);
	AddEffects( EF_NODRAW );
	SetSolid(SOLID_NONE);
	AddSolidFlags( FSOLID_NOT_SOLID );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPropVehicleChoreoGeneric::Think(void)
{
	SetNextThink( gpGlobals->curtime + 0.1 );

	if ( GetDriver() )
	{
		BaseClass::Think();
		
		// If the enter or exit animation has finished, tell the server vehicle
		if ( IsSequenceFinished() && (m_bExitAnimOn || m_bEnterAnimOn) )
		{
			GetServerVehicle()->HandleEntryExitFinish( m_bExitAnimOn, true );
		}
	}

	StudioFrameAdvance();
	DispatchAnimEvents( this );
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pPlayer - 
//-----------------------------------------------------------------------------
void CChoreoGenericServerVehicle::ItemPostFrame( CBasePlayer *player )
{
	Assert( player == GetDriver() );

	GetDrivableVehicle()->ItemPostFrame( player );

	if (( player->m_afButtonPressed & IN_USE ) || GetVehicle()->ShouldForceExit() )
	{
		GetVehicle()->ClearForcedExit();
		if ( GetDrivableVehicle()->CanExitVehicle(player) )
		{
			// Let the vehicle try to play the exit animation
			if ( !HandlePassengerExit( player ) && ( player != NULL ) )
			{
				player->PlayUseDenySound();
			}
		}
	}
}
Пример #28
0
void UDemoNetConnection::HandleClientPlayer( APlayerController* PC, UNetConnection* NetConnection )
{
	Super::HandleClientPlayer( PC, NetConnection );

	// Assume this is our special spectator controller
	GetDriver()->SpectatorController = PC;

	for ( FActorIterator It( Driver->World ); It; ++It)
	{
		if ( It->IsA( APlayerStart::StaticClass() ) )
		{
			PC->SetInitialLocationAndRotation( It->GetActorLocation(), It->GetActorRotation() );

			if ( PC->GetPawn() )
			{
				PC->GetPawn()->TeleportTo( It->GetActorLocation(), It->GetActorRotation(), false, true );
			}
			break;
		}
	}
}
Пример #29
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CASW_PropJeep::HandleWater( void )
{
	// Only check the wheels and engine in water if we have a driver (player).
	if ( !GetDriver() )
		return;

	// Check to see if we are in water.
	if ( CheckWater() )
	{
		for ( int iWheel = 0; iWheel < ASW_JEEP_WHEEL_COUNT; ++iWheel )
		{
			// Create an entry/exit splash!
			if ( m_WaterData.m_bWheelInWater[iWheel] != m_WaterData.m_bWheelWasInWater[iWheel] )
			{
				CreateSplash( m_WaterData.m_vecWheelContactPoints[iWheel] );
				CreateRipple( m_WaterData.m_vecWheelContactPoints[iWheel] );
			}
			
			// Create ripples.
			if ( m_WaterData.m_bWheelInWater[iWheel] && m_WaterData.m_bWheelWasInWater[iWheel] )
			{
				if ( m_WaterData.m_flNextRippleTime[iWheel] < gpGlobals->curtime )
				{
					// Stagger ripple times
					m_WaterData.m_flNextRippleTime[iWheel] = gpGlobals->curtime + RandomFloat( 0.1, 0.3 );
					CreateRipple( m_WaterData.m_vecWheelContactPoints[iWheel] );
				}
			}
		}
	}

	// Save of data from last think.
	for ( int iWheel = 0; iWheel < ASW_JEEP_WHEEL_COUNT; ++iWheel )
	{
		m_WaterData.m_bWheelWasInWater[iWheel] = m_WaterData.m_bWheelInWater[iWheel];
	}
}
Пример #30
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPropCrane::Think(void)
{
	SetNextThink( gpGlobals->curtime + 0.1 );

	if ( GetDriver() )
	{
		BaseClass::Think();
		
		if ( m_hNPCDriver )
		{
			GetServerVehicle()->NPC_DriveVehicle();
		}

		// play enter animation
		StudioFrameAdvance();

		// If the enter or exit animation has finished, tell the server vehicle
		if ( IsSequenceFinished() && (m_bExitAnimOn || m_bEnterAnimOn) )
		{
			if ( m_bEnterAnimOn )
			{
				// Finished entering, display the hint for using the crane
				UTIL_HudHintText( m_hPlayer, "#Valve_Hint_CraneKeys" );
			}
			
			GetServerVehicle()->HandleEntryExitFinish( m_bExitAnimOn, true );
		}
	}
	else
	{
		// Run the crane's movement
		RunCraneMovement( 0.1 );
	}

	// Update follower bones
	m_BoneFollowerManager.UpdateBoneFollowers(this);
}