本文整理汇总了C++中CClientVehicle类的典型用法代码示例。如果您正苦于以下问题:C++ CClientVehicle类的具体用法?C++ CClientVehicle怎么用?C++ CClientVehicle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CClientVehicle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void CElementRPCs::SetElementCollisionsEnabled ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
bool bEnable;
if ( bitStream.ReadBit ( bEnable ) )
{
switch ( pSource->GetType () )
{
case CCLIENTPED:
case CCLIENTPLAYER:
{
CClientPed* pPed = static_cast < CClientPed * > ( pSource );
pPed->SetUsesCollision ( bEnable );
break;
}
case CCLIENTVEHICLE:
{
CClientVehicle* pVehicle = static_cast < CClientVehicle * > ( pSource );
pVehicle->SetCollisionEnabled ( bEnable );
break;
}
case CCLIENTOBJECT:
{
CClientObject* pObject = static_cast < CClientObject * > ( pSource );
pObject->SetCollisionEnabled ( bEnable );
break;
}
}
}
}
示例2: while
void CUnoccupiedVehicleSync::Packet_UnoccupiedVehicleSync ( NetBitStreamInterface& BitStream )
{
// While we're not out of vehicles
while ( BitStream.GetNumberOfUnreadBits () >= 8 )
{
SUnoccupiedVehicleSync vehicle;
if ( BitStream.Read ( &vehicle ) )
{
CClientVehicle* pVehicle = m_pVehicleManager->Get ( vehicle.data.vehicleID );
if ( pVehicle && pVehicle->CanUpdateSync ( vehicle.data.ucTimeContext ) )
{
if ( vehicle.data.bSyncPosition ) pVehicle->SetTargetPosition ( vehicle.data.vecPosition, UNOCCUPIED_VEHICLE_SYNC_RATE, vehicle.data.bSyncVelocity, vehicle.data.vecVelocity.fZ );
if ( vehicle.data.bSyncRotation ) pVehicle->SetTargetRotation ( vehicle.data.vecRotation, UNOCCUPIED_VEHICLE_SYNC_RATE );
if ( vehicle.data.bSyncVelocity ) pVehicle->SetMoveSpeed ( vehicle.data.vecVelocity );
if ( vehicle.data.bSyncTurnVelocity ) pVehicle->SetTurnSpeed ( vehicle.data.vecTurnVelocity );
if ( vehicle.data.bSyncHealth ) pVehicle->SetHealth ( vehicle.data.fHealth );
pVehicle->SetEngineOn ( vehicle.data.bEngineOn );
if ( pVehicle->GetVehicleType() == CLIENTVEHICLE_TRAIN )
pVehicle->SetDerailed ( vehicle.data.bDerailed );
#ifdef MTA_DEBUG
pVehicle->m_pLastSyncer = NULL;
pVehicle->m_ulLastSyncTime = GetTickCount32 ();
pVehicle->m_szLastSyncType = "unoccupied";
#endif
}
}
else
break;
}
}
示例3: ReadLocalData
void CClientPacketRecorder::ReadLocalData(FILE* pFile)
{
// Grab the local player
CClientPlayer* pPlayer = m_pManager->GetPlayerManager()->GetLocalPlayer();
if (pPlayer)
{
// Grab the vehicle
CClientVehicle* pVehicle = pPlayer->GetOccupiedVehicle();
if (pVehicle)
{
// Temp vars
CMatrix matVehicle;
CVector vecMoveSpeed;
CVector vecTurnSpeed;
float fHealth;
// Read it out
fread(&matVehicle.vRight.fX, sizeof(float), 1, pFile);
fread(&matVehicle.vRight.fY, sizeof(float), 1, pFile);
fread(&matVehicle.vRight.fZ, sizeof(float), 1, pFile);
fread(&matVehicle.vFront.fX, sizeof(float), 1, pFile);
fread(&matVehicle.vFront.fY, sizeof(float), 1, pFile);
fread(&matVehicle.vFront.fZ, sizeof(float), 1, pFile);
fread(&matVehicle.vUp.fX, sizeof(float), 1, pFile);
fread(&matVehicle.vUp.fY, sizeof(float), 1, pFile);
fread(&matVehicle.vUp.fZ, sizeof(float), 1, pFile);
fread(&matVehicle.vPos.fX, sizeof(float), 1, pFile);
fread(&matVehicle.vPos.fY, sizeof(float), 1, pFile);
fread(&matVehicle.vPos.fZ, sizeof(float), 1, pFile);
fread(&vecMoveSpeed.fX, sizeof(float), 1, pFile);
fread(&vecMoveSpeed.fY, sizeof(float), 1, pFile);
fread(&vecMoveSpeed.fZ, sizeof(float), 1, pFile);
fread(&vecTurnSpeed.fX, sizeof(float), 1, pFile);
fread(&vecTurnSpeed.fY, sizeof(float), 1, pFile);
fread(&vecTurnSpeed.fZ, sizeof(float), 1, pFile);
fread(&fHealth, sizeof(float), 1, pFile);
CControllerState cs;
fread(&cs, sizeof(CControllerState), 1, pFile);
// Set the data
pVehicle->SetMatrix(matVehicle);
pVehicle->SetMoveSpeed(vecMoveSpeed);
pVehicle->SetTurnSpeed(vecTurnSpeed);
pVehicle->SetHealth(fHealth);
// Set the controller state
CControllerState csLast;
g_pGame->GetPad()->Disable(true);
g_pGame->GetPad()->GetCurrentControllerState(&csLast);
g_pGame->GetPad()->SetLastControllerState(&csLast);
g_pGame->GetPad()->SetCurrentControllerState(&cs);
}
}
}
示例4: memset
void CClientPlayerManager::DoPulse ( void )
{
unsigned long ulCurrentTime = CClientTime::GetTime ();
CClientPlayer * pPlayer = NULL;
vector < CClientPlayer* > ::const_iterator iter = m_Players.begin ();
for ( ; iter != m_Players.end (); ++iter )
{
pPlayer = *iter;
if ( !pPlayer->IsLocalPlayer () )
{
// Pulse voice data if voice is enabled
if ( g_pClientGame->GetVoiceRecorder()->IsEnabled() && pPlayer->GetVoice() )
pPlayer->GetVoice()->DoPulse();
// Flag him with connection error if its been too long since last puresync and force his position
unsigned long ulLastPuresyncTime = pPlayer->GetLastPuresyncTime ();
bool bHasConnectionTrouble = ( ulLastPuresyncTime != 0 && ulCurrentTime >= ulLastPuresyncTime + REMOTE_PLAYER_CONNECTION_TROUBLE_TIME );
if ( bHasConnectionTrouble && !g_pClientGame->IsDownloadingBigPacket () && !pPlayer->IsDeadOnNetwork () )
{
pPlayer->SetHasConnectionTrouble ( true );
// Reset his controller so he doesn't get stuck shooting or something
CControllerState State;
memset ( &State, 0, sizeof ( CControllerState ) );
pPlayer->SetControllerState ( State );
// Grab his vehicle if any and force the position to where he was last sync
CClientVehicle* pVehicle = pPlayer->GetOccupiedVehicle ();
if ( pVehicle )
{
// Is he driving the vehicle?
if ( pPlayer->GetOccupiedVehicleSeat () == 0 )
{
// Force his position to where he was last sync
pVehicle->SetPosition ( pPlayer->GetLastPuresyncPosition () );
pVehicle->SetMoveSpeed ( CVector ( 0, 0, 0 ) );
pVehicle->SetTurnSpeed ( CVector ( 0, 0, 0 ) );
pPlayer->ResetInterpolation ();
}
}
else
{
// Force his position to where he was last sync
pPlayer->SetPosition ( pPlayer->GetLastPuresyncPosition () );
pPlayer->ResetInterpolation ();
pPlayer->SetMoveSpeed ( CVector ( 0, 0, 0 ) );
pPlayer->ResetInterpolation ();
}
}
else
{
pPlayer->SetHasConnectionTrouble ( false );
}
}
}
}
示例5: SetPedOccupiedVehicle
int CLuaOOPDefs::SetPedOccupiedVehicle ( lua_State* luaVM )
{
// ped.vehicle = element vehicle
// ped.vehicle = nil
CClientPed* pPed;
CClientVehicle* pVehicle;
uint uiSeat = 0;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pPed );
argStream.ReadUserData ( pVehicle, NULL );
if ( pVehicle != NULL )
{
MinClientReqCheck ( argStream, MIN_CLIENT_REQ_WARPPEDINTOVEHICLE_CLIENTSIDE, "function is being called client side" );
if ( !argStream.HasErrors () )
{
if ( !pPed->IsLocalEntity () || !pVehicle->IsLocalEntity () )
argStream.SetCustomError ( "This client side function will only work with client created peds and vehicles" );
}
if ( !argStream.HasErrors () )
{
if ( CStaticFunctionDefinitions::WarpPedIntoVehicle ( pPed, pVehicle, uiSeat ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
}
else
{
if ( !argStream.HasErrors () )
{
if ( !pPed->IsLocalEntity () )
argStream.SetCustomError ( "This client side function will only work with client created peds" );
}
if ( !argStream.HasErrors () )
{
if ( CStaticFunctionDefinitions::RemovePedFromVehicle ( pPed ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
}
lua_pushboolean ( luaVM, false );
return 1;
}
示例6: DoPulse
void CClientVehicleManager::DoPulse ( void )
{
CClientVehicle * pVehicle = NULL;
// Loop through our streamed-in vehicles
vector < CClientVehicle * > cloneList = m_StreamedIn;
vector < CClientVehicle* > ::iterator iter = cloneList.begin ();
for ( ; iter != cloneList.end (); ++iter )
{
pVehicle = *iter;
// We should have a game vehicle here
assert ( pVehicle->GetGameVehicle () );
pVehicle->StreamedInPulse ();
}
}
示例7: DoPulse
void CClientPathNode::DoPulse(void)
{
list<CClientEntity*>::iterator iter = m_List.begin();
for (; iter != m_List.end(); iter++)
{
// TEST!
if ((*iter)->GetType() == CCLIENTVEHICLE)
{
CClientVehicle* pVehicle = static_cast<CClientVehicle*>(*iter);
CVector vecMoveSpeed;
pVehicle->GetMoveSpeed(vecMoveSpeed);
vecMoveSpeed.fZ = 0.0f;
pVehicle->SetMoveSpeed(vecMoveSpeed);
}
(*iter)->SetPosition(m_vecPosition);
}
}
示例8: IterBegin
void CClientVehicleManager::RestreamVehicles ( unsigned short usModel )
{
// Store the affected vehicles
CClientVehicle* pVehicle;
std::vector < CClientVehicle* > ::iterator iter = IterBegin ();
for ( ; iter != IterEnd (); iter++ )
{
pVehicle = *iter;
// Streamed in and same vehicle ID?
if ( pVehicle->IsStreamedIn () && pVehicle->GetModel () == usModel )
{
// Stream it out for a while until streamed decides to stream it
// back in eventually
pVehicle->StreamOutForABit ();
}
}
}
示例9:
CClientVehicle * CStreamer::GetVehicleFromGameVehicle(IVVehicle * pGameVehicle)
{
// Get the streamed in vehicles list
std::list <CStreamableEntity *> * m_streamedVehicles = &m_streamedElements[ENTITY_TYPE_VEHICLE];
// Loop through the streamed in vehicles list
for(std::list<CStreamableEntity *>::iterator iter = m_streamedVehicles->begin(); iter != m_streamedVehicles->end(); iter++)
{
// Get the vehicle pointer
CClientVehicle * pTestVehicle = reinterpret_cast<CClientVehicle *>(*iter);
// Is this the vehicle we are looking for?
if(pTestVehicle->GetGameVehicle()->GetVehicle() == pGameVehicle)
return pTestVehicle;
}
// No vehicle found
return NULL;
}
示例10: GetVehicleGravity
int CLuaOOPDefs::GetVehicleGravity ( lua_State* luaVM )
{
CClientVehicle* pVehicle = NULL;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pVehicle );
if ( !argStream.HasErrors () )
{
CVector vecGravity;
pVehicle->GetGravity ( vecGravity );
lua_pushvector ( luaVM, vecGravity );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例11: switch
void CClientWeapon::Fire ( void )
{
if ( !m_pWeapon || !m_pObject ) return;
switch ( m_Type )
{
case WEAPONTYPE_PISTOL:
case WEAPONTYPE_PISTOL_SILENCED:
case WEAPONTYPE_DESERT_EAGLE:
#ifdef SHOTGUN_TEST
case WEAPONTYPE_SHOTGUN:
case WEAPONTYPE_SAWNOFF_SHOTGUN:
case WEAPONTYPE_SPAS12_SHOTGUN:
#endif
case WEAPONTYPE_MICRO_UZI:
case WEAPONTYPE_MP5:
case WEAPONTYPE_AK47:
case WEAPONTYPE_M4:
case WEAPONTYPE_TEC9:
case WEAPONTYPE_COUNTRYRIFLE:
case WEAPONTYPE_SNIPERRIFLE:
case WEAPONTYPE_MINIGUN:
{
CVector vecOrigin, vecRotation;
GetPosition ( vecOrigin );
if ( m_pAttachedToEntity )
{
GetRotationRadians ( vecRotation );
}
else
{
GetRotationRadians ( vecRotation );
vecRotation = -vecRotation;
}
CVector vecTarget;
float fDistance = m_pWeaponInfo->GetWeaponRange ();
if ( m_targetType == TARGET_TYPE_ENTITY )
{
if ( m_pTarget )
{
if ( m_pTarget->GetType ( ) == CCLIENTPED || m_pTarget->GetType ( ) == CCLIENTPLAYER )
{
CClientPed * pPed = (CClientPed *) (CClientEntity *) m_pTarget;
pPed->GetBonePosition( m_targetBone, vecTarget );
}
else
{
if ( m_pTarget->GetType() == CCLIENTVEHICLE )
{
if ( m_itargetWheel <= MAX_WHEELS )
{
CClientVehicle * pTarget = (CClientVehicle*)(CClientEntity *)m_pTarget;
vecTarget = pTarget->GetGameVehicle()->GetWheelPosition ( (eWheels)m_itargetWheel );
}
else
m_pTarget->GetPosition( vecTarget );
}
else
m_pTarget->GetPosition( vecTarget );
}
if ( m_weaponConfig.bShootIfTargetOutOfRange == false && (vecOrigin - vecTarget).Length() >= fDistance )
{
return;
}
}
else
{
ResetWeaponTarget ( );
}
}
else if ( m_targetType == TARGET_TYPE_VECTOR )
{
vecTarget = m_vecTarget;
if ( m_weaponConfig.bShootIfTargetOutOfRange == false && (vecOrigin - vecTarget).Length() >= fDistance )
{
return;
}
}
else
{
CVector vecFireOffset = *m_pWeaponInfo->GetFireOffset ();
RotateVector ( vecFireOffset, vecRotation );
#ifndef SHOTGUN_TEST
vecOrigin += vecFireOffset;
#endif
CVector vecDirection ( 1, 0, 0 );
vecDirection *= fDistance;
RotateVector ( vecDirection, vecRotation );
vecTarget = vecOrigin + vecDirection;
}
// Save
short sDamage = m_pWeaponInfo->GetDamagePerHit ( );
float fAccuracy = m_pWeaponInfo->GetAccuracy ( );
float fTargetRange = m_pWeaponInfo->GetTargetRange ( );
//.........这里部分代码省略.........
示例12: switch
void CClientWeapon::Fire ( bool bServerFire )
{
if ( !m_pWeapon || !m_pObject || ( !IsLocalEntity ( ) && m_pOwner != g_pClientGame->GetLocalPlayer ( ) && bServerFire == false ) ) return;
switch ( m_Type )
{
case WEAPONTYPE_PISTOL:
case WEAPONTYPE_PISTOL_SILENCED:
case WEAPONTYPE_DESERT_EAGLE:
#ifdef SHOTGUN_TEST
case WEAPONTYPE_SHOTGUN:
case WEAPONTYPE_SAWNOFF_SHOTGUN:
case WEAPONTYPE_SPAS12_SHOTGUN:
#endif
case WEAPONTYPE_MICRO_UZI:
case WEAPONTYPE_MP5:
case WEAPONTYPE_AK47:
case WEAPONTYPE_M4:
case WEAPONTYPE_TEC9:
case WEAPONTYPE_COUNTRYRIFLE:
case WEAPONTYPE_SNIPERRIFLE:
case WEAPONTYPE_MINIGUN:
{
CMatrix matOrigin;
GetMatrix ( matOrigin );
CVector vecTarget;
float fDistance = m_pWeaponInfo->GetWeaponRange ();
if ( m_targetType == TARGET_TYPE_ENTITY )
{
if ( m_pTarget )
{
if ( m_pTarget->GetType ( ) == CCLIENTPED || m_pTarget->GetType ( ) == CCLIENTPLAYER )
{
CClientPed * pPed = (CClientPed *) (CClientEntity *) m_pTarget;
pPed->GetBonePosition( m_targetBone, vecTarget );
}
else
{
if ( m_pTarget->GetType() == CCLIENTVEHICLE )
{
if ( m_itargetWheel <= MAX_WHEELS )
{
CClientVehicle * pTarget = (CClientVehicle*)(CClientEntity *)m_pTarget;
vecTarget = pTarget->GetGameVehicle()->GetWheelPosition ( (eWheels)m_itargetWheel );
}
else
m_pTarget->GetPosition( vecTarget );
}
else
m_pTarget->GetPosition( vecTarget );
}
if ( m_weaponConfig.bShootIfTargetOutOfRange == false && (matOrigin.GetPosition() - vecTarget).Length() >= fDistance )
{
return;
}
}
else
{
ResetWeaponTarget ( );
}
}
else if ( m_targetType == TARGET_TYPE_VECTOR )
{
vecTarget = m_vecTarget;
if ( m_weaponConfig.bShootIfTargetOutOfRange == false && (matOrigin.GetPosition() - vecTarget).Length() >= fDistance )
{
return;
}
}
else
{
#ifndef SHOTGUN_TEST
CVector vecFireOffset = *m_pWeaponInfo->GetFireOffset ();
matOrigin = CMatrix( vecFireOffset, m_vecFireRotationNoTarget ) * matOrigin;
#endif
CVector vecDirection ( 1, 0, 0 );
vecDirection *= fDistance;
vecTarget = matOrigin.TransformVector( vecDirection );
}
// Save
short sDamage = m_pWeaponInfo->GetDamagePerHit ( );
float fAccuracy = m_pWeaponInfo->GetAccuracy ( );
float fTargetRange = m_pWeaponInfo->GetTargetRange ( );
float fRange = m_pWeaponInfo->GetWeaponRange ( );
// Set new
m_pWeaponInfo->SetDamagePerHit ( m_pWeaponStat->GetDamagePerHit ( ) );
m_pWeaponInfo->SetAccuracy ( m_pWeaponStat->GetAccuracy ( ) );
m_pWeaponInfo->SetTargetRange ( m_pWeaponStat->GetTargetRange ( ) );
m_pWeaponInfo->SetWeaponRange ( m_pWeaponStat->GetWeaponRange ( ) );
#ifdef SHOTGUN_TEST
CVector vecFireOffset = *m_pWeaponInfo->GetFireOffset ();
CMatrix matTemp = CMatrix( vecFireOffset ) * matOrigin;
#ifdef MARKER_DEBUG
// Process
m_pMarker->SetPosition ( matOrigin.GetPosition() );
//.........这里部分代码省略.........
示例13: ProcessVehicleList
///////////////////////////////////////////////////////////////
//
// CClientModelCacheManagerImpl::ProcessVehicleList
//
///////////////////////////////////////////////////////////////
void CClientModelCacheManagerImpl::ProcessVehicleList(std::map<ushort, float>& outNeedCacheList, const std::vector<CClientVehicle*>& vehicleList,
float fMaxStreamDistanceSq)
{
const ulong ulTimeNow = CClientTime::GetTime();
for (std::vector<CClientVehicle*>::const_iterator iter = vehicleList.begin(); iter != vehicleList.end(); ++iter)
{
CClientVehicle* pVehicle = *iter;
const ushort usModelId = pVehicle->GetModel();
if (usModelId < 400 || usModelId > 611)
continue;
// Check if currently within distance
{
// Check distance
CVector vecPosition;
pVehicle->GetPosition(vecPosition);
float fDistSq = (m_vecCameraPos - vecPosition).LengthSquared();
if (fDistSq < fMaxStreamDistanceSq)
{
// Add model to needed list
InsertIntoNeedCacheList(outNeedCacheList, usModelId, fDistSq);
AddProcessStat("p", true, PURESYNC_TYPE_NONE, usModelId, vecPosition, vecPosition);
continue;
}
}
CClientPlayer* pDriver = DynamicCast<CClientPlayer>(pVehicle->GetControllingPlayer());
if (!pDriver)
continue;
// Check if will be within distance soon
ePuresyncType syncType = pDriver->GetLastPuresyncType();
if (syncType == PURESYNC_TYPE_PURESYNC || syncType == PURESYNC_TYPE_LIGHTSYNC)
{
ulong ulSyncAge = ulTimeNow - pDriver->GetLastPuresyncTime();
if (ulSyncAge < 8000)
{
// Get velocity from somewhere
CVector vecVelocity;
if (syncType == PURESYNC_TYPE_LIGHTSYNC)
vecVelocity = pDriver->GetLightsyncCalcedVelocity();
else
{
pVehicle->GetMoveSpeed(vecVelocity);
vecVelocity *= m_fGameFps;
}
// Extrapolate position for 2 seconds time
float fSecondsToAdd = std::min(6000UL, ulSyncAge + 2000) * 0.001f;
CVector vecPosition;
pVehicle->GetPosition(vecPosition);
CVector vecNewPosition = vecPosition + vecVelocity * fSecondsToAdd;
// Check distance
float fDistSq = (m_vecCameraPos - vecNewPosition).LengthSquared();
if (fDistSq < fMaxStreamDistanceSq)
{
// Add model to needed list
InsertIntoNeedCacheList(outNeedCacheList, usModelId, fDistSq);
AddProcessStat("l", true, syncType, usModelId, vecPosition, vecNewPosition);
continue;
}
AddProcessStat("n", false, syncType, usModelId, vecPosition, vecNewPosition);
continue;
}
}
}
}
示例14: fopen
void CClientPacketRecorder::RecordLocalData(CClientPlayer* pLocalPlayer)
{
if (m_bRecording && m_szFilename)
{
// Open our file
FILE* pFile = fopen(m_szFilename, "ab+");
if (pFile)
{
// Write our timestamp
if (m_bFrameBased)
{
long lFrameStamp = m_lFrames - m_lRelative;
fwrite(&lFrameStamp, sizeof(long), 1, pFile);
}
else
{
long lTimeStamp = CClientTime::GetTime() - m_lRelative;
fwrite(&lTimeStamp, sizeof(long), 1, pFile);
}
// fwrite ( &ulTimeStamp, sizeof ( unsigned long ), 1, pFile );
// Write the packet ID
fputc(0xFE, pFile);
// Grab the vehicle
CClientVehicle* pVehicle = pLocalPlayer->GetOccupiedVehicle();
if (pVehicle)
{
// Read out the matrix, movespeed and turnspeed
CMatrix matVehicle;
CVector vecMoveSpeed;
CVector vecTurnSpeed;
pVehicle->GetMatrix(matVehicle);
pVehicle->GetMoveSpeed(vecMoveSpeed);
pVehicle->GetTurnSpeed(vecTurnSpeed);
float fHealth = pVehicle->GetHealth();
// Write it
fwrite(&matVehicle.vRight.fX, sizeof(float), 1, pFile);
fwrite(&matVehicle.vRight.fY, sizeof(float), 1, pFile);
fwrite(&matVehicle.vRight.fZ, sizeof(float), 1, pFile);
fwrite(&matVehicle.vFront.fX, sizeof(float), 1, pFile);
fwrite(&matVehicle.vFront.fY, sizeof(float), 1, pFile);
fwrite(&matVehicle.vFront.fZ, sizeof(float), 1, pFile);
fwrite(&matVehicle.vUp.fX, sizeof(float), 1, pFile);
fwrite(&matVehicle.vUp.fY, sizeof(float), 1, pFile);
fwrite(&matVehicle.vUp.fZ, sizeof(float), 1, pFile);
fwrite(&matVehicle.vPos.fX, sizeof(float), 1, pFile);
fwrite(&matVehicle.vPos.fY, sizeof(float), 1, pFile);
fwrite(&matVehicle.vPos.fZ, sizeof(float), 1, pFile);
fwrite(&vecMoveSpeed.fX, sizeof(float), 1, pFile);
fwrite(&vecMoveSpeed.fY, sizeof(float), 1, pFile);
fwrite(&vecMoveSpeed.fZ, sizeof(float), 1, pFile);
fwrite(&vecTurnSpeed.fX, sizeof(float), 1, pFile);
fwrite(&vecTurnSpeed.fY, sizeof(float), 1, pFile);
fwrite(&vecTurnSpeed.fZ, sizeof(float), 1, pFile);
fwrite(&fHealth, sizeof(float), 1, pFile);
// Write the controller state
CControllerState cs;
g_pGame->GetPad()->GetCurrentControllerState(&cs);
fwrite(&cs, sizeof(CControllerState), 1, pFile);
}
// Close the file
fclose(pFile);
}
}
}
示例15: GetAttachedTo
void CClientWeapon::FireInstantHit ( CVector vecOrigin, CVector vecTarget, bool bServerFire, bool bRemote )
#endif
{
CVector vecDirection = vecTarget - vecOrigin;
vecDirection.Normalize ();
CClientEntity * pAttachedTo = GetAttachedTo ();
CVector vecOriginalTarget = vecTarget;
CEntity * pColEntity = NULL;
CColPoint * pColPoint = NULL;
SLineOfSightBuildingResult pBuildingResult;
CEntitySAInterface * pEntity = NULL;
if ( m_Type != WEAPONTYPE_SHOTGUN )
{
CVector vecWeaponFirePosition;
if ( !IsLocalEntity ( ) && m_pOwner )
{
CClientPlayer * pPlayer = m_pOwner;
CClientPed * pLocalPlayer = g_pClientGame->GetLocalPlayer();
if ( pLocalPlayer && pPlayer )
{
CClientVehicle* pVehicle = pLocalPlayer->GetRealOccupiedVehicle ();
// Move both players to where they should be for shot compensation
if ( pPlayer && !pPlayer->IsLocalPlayer () )
{
if ( !pVehicle || pLocalPlayer->GetOccupiedVehicleSeat() == 0 )
{
// Warp back in time to where we were when this player shot (their latency)
// We don't account for interpolation here, +250ms seems to work better
// ** Changed ajustment to +125ms as the position of this clients player on the firers screen
// has been changed. See CClientPed::UpdateTargetPosition() **
CVector vecPosition;
unsigned short usLatency = ( pPlayer->GetLatency () + 125 );
g_pClientGame->GetNetAPI()->GetInterpolation ( vecPosition, usLatency );
// Move the entity back
if ( pVehicle )
{
pVehicle->GetPosition ( vecWeaponFirePosition );
pVehicle->SetPosition ( vecPosition, false, false );
}
else
{
pLocalPlayer->GetPosition ( vecWeaponFirePosition );
pLocalPlayer->SetPosition ( vecPosition, false, false );
}
}
}
}
}
//if ( pAttachedTo ) pAttachedTo->WorldIgnore ( true );
if ( m_pWeapon->ProcessLineOfSight ( &vecOrigin, &vecTarget, &pColPoint, &pColEntity, m_weaponConfig.flags, &pBuildingResult, m_Type, &pEntity ) )
{
vecTarget = pColPoint->GetPosition ();
}
// Don't continue without a valid colpoint
if ( !pColPoint )
return;
//if ( pAttachedTo ) pAttachedTo->WorldIgnore ( false );
// return if shoot if target is blocked is false and we aren't pointing at our target
if ( ( m_pTarget != NULL && m_pTarget->GetGameEntity ( ) != NULL && m_pTarget->GetGameEntity()->GetInterface ( ) != pEntity ) && m_weaponConfig.bShootIfTargetBlocked == false && bRemote == false )
{
if ( pColPoint )
pColPoint->Destroy ();
return;
}
// Execute our weapon fire event
CClientEntity * pClientEntity = m_pManager->FindEntitySafe ( pColEntity );
CLuaArguments Arguments;
if ( pClientEntity )
Arguments.PushElement ( pClientEntity ); // entity that got hit
else
Arguments.PushNil ( ); // Probably a building.
Arguments.PushNumber ( pColPoint->GetPosition ( ).fX ); // pos x
Arguments.PushNumber ( pColPoint->GetPosition ( ).fY ); // pos y
Arguments.PushNumber ( pColPoint->GetPosition ( ).fZ ); // pos z
Arguments.PushNumber ( pColPoint->GetNormal ( ).fX ); // Normal x
Arguments.PushNumber ( pColPoint->GetNormal ( ).fY ); // Normal y
Arguments.PushNumber ( pColPoint->GetNormal ( ).fZ ); // Normal z
Arguments.PushNumber ( pColPoint->GetSurfaceTypeB ( ) ); // Surface type "B"
Arguments.PushNumber ( pColPoint->GetLightingForTimeOfDay ( ) ); // Lighting
Arguments.PushNumber ( pColPoint->GetPieceTypeB ( ) ); // Piece
if ( !CallEvent ( "onClientWeaponFire", Arguments, true ) )
{
if ( pColPoint )
pColPoint->Destroy ();
return;
}
DoGunShells ( vecOrigin, vecDirection );
CVector vecCollision;
if ( g_pGame->GetWaterManager ()->TestLineAgainstWater ( vecOrigin, vecTarget, &vecCollision ) )
{
g_pGame->GetFx ()->TriggerBulletSplash ( vecCollision );
//.........这里部分代码省略.........