void CElementRPCs::SetElementPosition ( NetBitStreamInterface& bitStream ) { // Read out the entity id and the position ElementID ID; CVector vecPosition; unsigned char ucTimeContext; if ( bitStream.Read ( ID ) && bitStream.Read ( vecPosition.fX ) && bitStream.Read ( vecPosition.fY ) && bitStream.Read ( vecPosition.fZ ) && bitStream.Read ( ucTimeContext ) ) { // Grab the entity CClientEntity* pEntity = CElementIDs::GetElement ( ID ); if ( pEntity ) { // Update the sync context to the new one pEntity->SetSyncTimeContext ( ucTimeContext ); // If it's a player, use Teleport if ( pEntity->GetType () == CCLIENTPLAYER ) { unsigned char ucWarp = 1; bitStream.Read ( ucWarp ); CClientPlayer* pPlayer = static_cast < CClientPlayer* > ( pEntity ); if ( ucWarp ) { pPlayer->Teleport ( vecPosition ); pPlayer->ResetInterpolation (); } else { pPlayer->SetPosition ( vecPosition ); } // If local player, reset return position (so we can't warp back if connection fails) if ( pPlayer->IsLocalPlayer () ) { m_pClientGame->GetNetAPI ()->ResetReturnPosition (); } } else if ( pEntity->GetType () == CCLIENTVEHICLE ) { CClientVehicle* pVehicle = static_cast < CClientVehicle* > ( pEntity ); pVehicle->RemoveTargetPosition (); pVehicle->SetPosition ( vecPosition ); } else { // Set its position pEntity->SetPosition ( vecPosition ); } } } }
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 ); } } } }
void CFoo::Test ( const char* szString ) { CClientManager* pManager = g_pClientGame->GetManager (); CClientPlayer* pLocal = pManager->GetPlayerManager ()->GetLocalPlayer (); CClientVehicleManager* pVehicleManager = pManager->GetVehicleManager (); CVector vecLocal; pLocal->GetPosition ( vecLocal ); CClientCamera* pCamera = pManager->GetCamera (); // ChrML: Trying to reproduce mantis issue #2760 if ( stricmp ( szString, "2760" ) == 0 ) { vecLocal = CVector ( 0.0f, 0.0f, 5.0f ); for ( int i = 0; i < 20; i++ ) { vecLocal.fX += 5.0f; CClientPlayer* pPlayer = new CClientPlayer ( pManager, i + 50 ); pPlayer->SetDeadOnNetwork ( false ); pPlayer->SetModel ( 168 + i ); pPlayer->AttachTo ( NULL ); pPlayer->SetFrozen ( false ); pPlayer->RemoveAllWeapons (); pPlayer->Teleport ( vecLocal ); pPlayer->SetCameraRotation ( 0 ); pPlayer->ResetInterpolation (); pPlayer->SetMoveSpeed ( CVector () ); pPlayer->SetHealth ( 100.0f ); pPlayer->SetArmor ( 0 ); pPlayer->SetCurrentRotation ( 0 ); pPlayer->SetInterior ( 0 ); pPlayer->SetDimension ( 0 ); } pLocal->SetDeadOnNetwork ( false ); pLocal->SetModel ( 145 ); pLocal->AttachTo ( NULL ); pLocal->SetFrozen ( false ); pLocal->RemoveAllWeapons (); pLocal->Teleport ( vecLocal ); pLocal->SetCameraRotation ( 0 ); pLocal->ResetInterpolation (); pLocal->SetMoveSpeed ( CVector () ); pLocal->SetHealth ( 100.0f ); pLocal->SetArmor ( 0 ); pLocal->SetCurrentRotation ( 0 ); pLocal->SetInterior ( 0 ); pLocal->SetDimension ( 0 ); g_pClientGame->SetAllDimensions ( 0 ); // Reset return position so we can't warp back to where we were if local player g_pClientGame->GetNetAPI ()->ResetReturnPosition (); // Make sure the camera is normal pCamera->SetFocusToLocalPlayer (); pCamera->FadeIn ( 0.0f ); } // Player load crash else if ( stricmp ( szString, "2741" ) == 0 ) { bFoo_PlayerLimitCrash = true; } // else if ( strnicmp ( szString, "interp", 6 ) == 0 ) { if ( pVehicleManager->Count () > 0 ) { CClientVehicle* pVehicle = *pVehicleManager->IterBegin (); float fdelta = atof ( szString + 7 ); CVector vecT; pVehicle->GetPosition ( vecT ); vecT.fZ = fdelta; pVehicle->SetTargetPosition ( vecT, TICK_RATE ); g_pCore->ChatPrintf ( "Done %f", false, fdelta ); static_cast < CDeathmatchVehicle* > ( pVehicle )->SetIsSyncing ( false ); } } // else if ( strnicmp ( szString, "interr", 6 ) == 0 ) { if ( pVehicleManager->Count () > 0 ) { CClientVehicle* pVehicle = *pVehicleManager->IterBegin (); CVector vecT; pVehicle->GetRotationDegrees ( vecT ); vecT.fZ = atof ( szString + 7 ); pVehicle->SetTargetRotation ( vecT, TICK_RATE ); g_pCore->ChatPrintf ( "Done %f", false, atof ( szString + 7 ) ); static_cast < CDeathmatchVehicle* > ( pVehicle )->SetIsSyncing ( false ); } } else if ( stricmp ( szString, "choke" ) == 0 ) { g_pClientGame->GetLocalPlayer ()->SetChoking ( true ); } // else if ( strnicmp ( szString, "static", 6 ) == 0 ) { if ( pVehicleManager->Count () > 0 ) { CClientVehicle* pVehicle = *pVehicleManager->IterBegin (); pVehicle->GetGameVehicle ()->SetRemap ( atoi ( szString + 7 ) ); g_pCore->ChatPrintf ( "Set %i", false, atoi ( szString + 7 ) ); } } // else if ( strnicmp ( szString, "getmass", 7 ) == 0 ) { CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle (); if ( pVehicle ) { g_pCore->ChatPrintf ( "Mass == %f", false, pVehicle->GetGameVehicle ()->GetMass () ); } } else if ( strnicmp ( szString, "setmass", 7 ) == 0 ) { CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle (); if ( pVehicle ) { pVehicle->GetGameVehicle ()->SetMass ( atof ( szString + 8 ) ); g_pCore->ChatPrintf ( "Set mass to %f", false, pVehicle->GetGameVehicle ()->GetMass () ); } } // /* else if ( strnicmp ( szString, "setmm", 5 ) == 0 ) { CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle (); if ( pVehicle ) { float fVal = atof ( szString + 6); szString += 4; float* fMass = (float*) atoi ( szString + 6 ); *fMass = fVal; g_pCore->ChatPrintf ( "Set %X to %f", false, fMass, fVal ); } } */ /* else if ( stricmp ( szString, "getmm" ) == 0 ) { CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle (); if ( pVehicle ) { float* fMass = (float*) atoi ( szString ); g_pCore->ChatPrintf ( "Get %f", false, *fMass ); } } */ /* else if ( stricmp ( szString, "dump" ) == 0 ) { FILE* poo = fopen ( "vehs.txt", "w+" ); if ( poo ) { tHandlingData* pHandling = (tHandlingData*) 0xC2B9E0; unsigned int uiIndex = 0; for ( ; uiIndex < 219; uiIndex++ ) { fprintf ( poo, "\n\n\n\n####### VEHICLE ID %u #######\n", uiIndex ); fprintf ( poo, "fMass = %f\n", pHandling->fMass ); fprintf ( poo, "fUnknown1 = %f\n", pHandling->fUnknown1 ); fprintf ( poo, "fTurnMass = %f\n", pHandling->fTurnMass ); fprintf ( poo, "fDragCoeff = %f\n", pHandling->fDragCoeff ); fprintf ( poo, "vecCenterOfMass = %f, %f, %f\n", pHandling->vecCenterOfMass.fX, pHandling->vecCenterOfMass.fY, pHandling->vecCenterOfMass.fZ ); fprintf ( poo, "uiPercentSubmerged = %u\n", pHandling->uiPercentSubmerged ); fprintf ( poo, "fUnknown2 = %f\n", pHandling->fUnknown2 ); fprintf ( poo, "fTractionMultiplier = %f\n", pHandling->fTractionMultiplier ); fprintf ( poo, "Transmission.fUnknown [0] = %f\n", pHandling->Transmission.fUnknown [0] ); fprintf ( poo, "Transmission.fUnknown [1] = %f\n", pHandling->Transmission.fUnknown [1] ); fprintf ( poo, "Transmission.fUnknown [2] = %f\n", pHandling->Transmission.fUnknown [2] ); fprintf ( poo, "Transmission.fUnknown [3] = %f\n", pHandling->Transmission.fUnknown [3] ); fprintf ( poo, "Transmission.fUnknown [4] = %f\n", pHandling->Transmission.fUnknown [4] ); fprintf ( poo, "Transmission.fUnknown [5] = %f\n", pHandling->Transmission.fUnknown [5] ); fprintf ( poo, "Transmission.fUnknown [6] = %f\n", pHandling->Transmission.fUnknown [6] ); fprintf ( poo, "Transmission.fUnknown [7] = %f\n", pHandling->Transmission.fUnknown [7] ); fprintf ( poo, "Transmission.fUnknown [8] = %f\n", pHandling->Transmission.fUnknown [8] ); fprintf ( poo, "Transmission.fUnknown [9] = %f\n", pHandling->Transmission.fUnknown [9] ); fprintf ( poo, "Transmission.fUnknown [10] = %f\n", pHandling->Transmission.fUnknown [10] ); fprintf ( poo, "Transmission.fUnknown [11] = %f\n", pHandling->Transmission.fUnknown [11] ); fprintf ( poo, "Transmission.fUnknown [12] = %f\n", pHandling->Transmission.fUnknown [12] ); fprintf ( poo, "Transmission.fUnknown [13] = %f\n", pHandling->Transmission.fUnknown [13] ); fprintf ( poo, "Transmission.fUnknown [14] = %f\n", pHandling->Transmission.fUnknown [14] ); fprintf ( poo, "Transmission.fUnknown [15] = %f\n", pHandling->Transmission.fUnknown [15] ); fprintf ( poo, "Transmission.fUnknown [16] = %f\n", pHandling->Transmission.fUnknown [16] ); fprintf ( poo, "Transmission.fUnknown [17] = %f\n", pHandling->Transmission.fUnknown [17] ); fprintf ( poo, "Transmission.ucDriveType = %c\n", pHandling->Transmission.ucDriveType ); fprintf ( poo, "Transmission.ucEngineType = %c\n", pHandling->Transmission.ucEngineType ); fprintf ( poo, "Transmission.ucNumberOfGears = %u\n", pHandling->Transmission.ucNumberOfGears ); fprintf ( poo, "Transmission.ucUnknown = %u\n", pHandling->Transmission.ucUnknown ); fprintf ( poo, "Transmission.uiHandlingFlags = 0x%X\n", pHandling->Transmission.uiHandlingFlags ); fprintf ( poo, "Transmission.fEngineAccelleration = %f\n", pHandling->Transmission.fEngineAccelleration ); fprintf ( poo, "Transmission.fEngineInertia = %f\n", pHandling->Transmission.fEngineInertia ); fprintf ( poo, "Transmission.fMaxVelocity = %f\n", pHandling->Transmission.fMaxVelocity ); fprintf ( poo, "Transmission.fUnknown2 [0] = %f\n", pHandling->Transmission.fUnknown2 [0] ); fprintf ( poo, "Transmission.fUnknown2 [1] = %f\n", pHandling->Transmission.fUnknown2 [1] ); fprintf ( poo, "Transmission.fUnknown2 [2] = %f\n", pHandling->Transmission.fUnknown2 [2] ); fprintf ( poo, "fBrakeDecelleration = %f\n", pHandling->fBrakeDecelleration ); fprintf ( poo, "fBrakeBias = %f\n", pHandling->fBrakeBias ); fprintf ( poo, "bABS = %u\n", pHandling->bABS ); fprintf ( poo, "fSteeringLock = %f\n", pHandling->fSteeringLock ); fprintf ( poo, "fTractionLoss = %f\n", pHandling->fTractionLoss ); fprintf ( poo, "fTractionBias = %f\n", pHandling->fTractionBias ); fprintf ( poo, "fSuspensionForceLevel = %f\n", pHandling->fSuspensionForceLevel ); fprintf ( poo, "fSuspensionDamping = %f\n", pHandling->fSuspensionDamping ); fprintf ( poo, "fSuspensionHighSpdDamping = %f\n", pHandling->fSuspensionHighSpdDamping ); fprintf ( poo, "fSuspensionUpperLimit = %f\n", pHandling->fSuspensionUpperLimit ); fprintf ( poo, "fSuspensionLowerLimit = %f\n", pHandling->fSuspensionLowerLimit ); fprintf ( poo, "fSuspensionFrontRearBias = %f\n", pHandling->fSuspensionFrontRearBias ); fprintf ( poo, "fSuspensionAntidiveMultiplier = %f\n", pHandling->fSuspensionAntidiveMultiplier ); fprintf ( poo, "fCollisionDamageMultiplier = %f\n", pHandling->fCollisionDamageMultiplier ); fprintf ( poo, "uiModelFlags = %X\n", pHandling->uiModelFlags ); fprintf ( poo, "uiHandlingFlags = %X\n", pHandling->uiHandlingFlags ); fprintf ( poo, "fSeatOffsetDistance = %f\n", pHandling->fSeatOffsetDistance ); fprintf ( poo, "uiMonetary = %u\n", pHandling->uiMonetary ); fprintf ( poo, "ucHeadLight = 0x%X\n", pHandling->ucHeadLight ); fprintf ( poo, "ucTailLight = 0x%X\n", pHandling->ucTailLight ); fprintf ( poo, "ucAnimGroup = 0x%X\n", pHandling->ucAnimGroup ); fprintf ( poo, "ucUnused = 0x%X\n", pHandling->ucUnused ); fprintf ( poo, "iUnknown7 = %f, %X\n", pHandling->iUnknown7, pHandling->iUnknown7 ); pHandling += 1; } g_pCore->ChatPrintf ( "Dumped", false ); fclose ( poo ); } } */ else if ( strnicmp ( szString, "moveug", 6 ) == 0 ) { if ( pVehicleManager->Count () > 0 ) { CClientVehicle* pVehicle = *pVehicleManager->IterBegin (); /* CClientPed* pModel = pVehicle->GetOccupant ( 0 ); if ( !pModel ) { CClientPlayer* pPlayer = new CClientPlayer ( g_pClientGame->GetManager (), 50 ); pModel = pPlayer->LoadModel ( 0 ); pModel->WarpIntoVehicle ( pVehicle ); } */ pVehicle->RemoveTargetPosition (); pVehicle->RemoveTargetRotation (); CVector vecT; pVehicle->GetPosition ( vecT ); vecT.fZ = atof ( szString + 7 ); pVehicle->SetPosition ( vecT ); g_pCore->ChatPrintf ( "Done", false ); } } else if ( strnicmp ( szString, "nocol", 5 ) == 0 ) { if ( pVehicleManager->Count () > 0 ) { CClientVehicle* pVehicle = *pVehicleManager->IterBegin (); pVehicle->SetCollisionEnabled ( false ); g_pCore->ChatPrintf ( "Done", false ); } } else if ( stricmp ( szString, "resetdamage" ) == 0 ) { g_pClientGame->GetPlayerManager ()->GetLocalPlayer ()->GetGamePlayer ()->ResetLastDamage (); } else if ( strnicmp ( szString, "fuckveh", 7 ) == 0 ) { CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle (); if ( pVehicle ) { pVehicle->SetTargetPosition ( CVector ( 0, 0, 0 ), TICK_RATE ); pVehicle->SetTargetRotation ( CVector ( 0, 0, 0 ), TICK_RATE ); g_pCore->ChatPrintf ( "Done", false ); } } else if ( stricmp ( szString, "ped" ) == 0 ) { CClientPed* pPed = new CClientPed ( g_pClientGame->GetManager (), INVALID_ELEMENT_ID, 9 ); vecLocal.fX += 5.0f; pPed->SetPosition ( vecLocal ); } else if ( strnicmp ( szString, "callit", 6 ) == 0 ) { FILE* pFile = fopen ( "C:/dump.txt", "w+" ); for ( int i = 0; i < 400; i++ ) { int iIndex = i; const char* szName = NULL; _asm { mov eax, 0x4D3A30 push iIndex call eax mov szName, eax add esp, 4 } fprintf ( pFile, "%i: %s\n", iIndex, szName ); } fclose ( pFile ); } else if ( strnicmp ( szString, "veh", 3 ) == 0 ) { int i = 600; FILE* p = fopen ( "C:/dump.txt", "w+" ); for ( int a = 0; a < 13; a++ ) { g_pGame->GetModelInfo ( i )->AddRef ( true ); CVehicle* pVehicle = g_pGame->GetPools ()->AddVehicle ( (eVehicleTypes)i ); DWORD* dw2 = (DWORD*)(((DWORD)pVehicle->GetVehicleInterface ()) + 0xE1 * 4 ); DWORD dw = *dw2; dw = dw + 4; dw = dw - 0xC2B9E0; dw = dw / 224; fprintf ( p, "Array [%u] = %u;\n", i, dw ); g_pGame->GetPools ()->RemoveVehicle ( pVehicle ); fflush ( p ); g_pGame->GetModelInfo ( i )->RemoveRef ( ); i++; } fclose ( p ); } else if ( strnicmp ( szString, "groups", 6 ) == 0 ) { FILE* pFile = fopen ( "C:/dump.txt", "w+" ); int i = 0; for ( ; i < 139; i++ ) { fprintf ( pFile, "==%s [%s] (%i)==\n", pGroups [i].szGroupName, pGroups [i].szSomething, i ); int i2 = 0; for ( ; i2 < pGroups [i].ulAnimCount; i2++ ) { const char* szAnimName = pGroups [i].pAnimNames [i2]; if ( szAnimName [0] ) { fprintf ( pFile, "''%i'': %s<br>\n", i2, szAnimName ); } } fprintf ( pFile, "\n" ); } fclose ( pFile ); } else if ( strnicmp ( szString, "getshot", 7 ) == 0 ) { if ( pLocal->GetGamePlayer ()->GetCanBeShotInVehicle () ) { g_pCore->ChatEcho ( "true" ); } else { g_pCore->ChatEcho ( "false" ); } } else if ( strnicmp ( szString, "gettest", 7 ) == 0 ) { if ( pLocal->GetGamePlayer ()->GetTestForShotInVehicle () ) { g_pCore->ChatEcho ( "true" ); } else { g_pCore->ChatEcho ( "false" ); } } else if ( strnicmp ( szString, "setshot", 7 ) == 0 ) { pLocal->GetGamePlayer ()->SetCanBeShotInVehicle ( true ); } else if ( strnicmp ( szString, "settest", 8 ) == 0 ) { pLocal->GetGamePlayer ()->SetTestForShotInVehicle ( true ); } else if ( stricmp ( szString, "applytest" ) == 0 ) { DWORD oldProt, oldProt2; VirtualProtect((LPVOID)0x5E8FFB,6,PAGE_EXECUTE_READWRITE,&oldProt); *(unsigned char*) (0x5E8FFB ) = 0x90; *(unsigned char*) (0x5E8FFC ) = 0x90; *(unsigned char*) (0x5E8FFD ) = 0x90; *(unsigned char*) (0x5E8FFE ) = 0x90; *(unsigned char*) (0x5E8FFF ) = 0x90; *(unsigned char*) (0x5E9000 ) = 0x90; VirtualProtect((LPVOID)0x5E8FFB,6,oldProt,&oldProt2); } }
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 ); g_pGame->GetAudioEngine ()->ReportBulletHit ( NULL, SURFACE_TYPE_WATER_SHALLOW, &vecCollision, 0.0f ); } #ifdef MARKER_DEBUG m_pMarker2->SetPosition ( vecTarget ); #endif m_pWeapon->DoBulletImpact ( m_pObject, pEntity, &vecOrigin, &vecTarget, pColPoint, 0 ); if ( !IsLocalEntity ( ) && m_pOwner ) { CClientPed * pPed = m_pOwner; CClientPed * pLocalPlayer = g_pClientGame->GetLocalPlayer(); if ( pPed->GetType () == CCLIENTPLAYER ) { // Restore compensated positions if ( !pPed->IsLocalPlayer () ) { CClientVehicle* pVehicle = pLocalPlayer->GetRealOccupiedVehicle (); if ( !pVehicle ) { pLocalPlayer->SetPosition ( vecWeaponFirePosition, false, false ); } else if ( pLocalPlayer->GetOccupiedVehicleSeat() == 0 ) { pVehicle->SetPosition ( vecWeaponFirePosition, false, false ); } } } } if ( !IsLocalEntity ( ) && GetOwner ( ) == g_pClientGame->GetLocalPlayer ( ) && bServerFire == false ) { g_pClientGame->GetNetAPI ( )->SendBulletSyncCustomWeaponFire ( this, vecOrigin, vecOriginalTarget ); } } #ifdef SHOTGUN_TEST else { //if ( pAttachedTo ) pAttachedTo->WorldIgnore ( true ); //if ( pAttachedTo ) pAttachedTo->WorldIgnore ( false ); // Fire instant hit is off by a few degrees FireShotgun ( m_pObject, vecOrigin, vecTarget, vecRotation ); } #endif if ( pColPoint ) pColPoint->Destroy (); }