void CWorldRPCs::SetWeaponProperty(NetBitStreamInterface& bitStream) { unsigned char ucWeapon = 0; unsigned char ucProperty = 0; unsigned char ucWeaponSkill = 0; float fData = 0.0f; short sData = 0; if (bitStream.Read(ucWeapon) && bitStream.Read(ucProperty) && bitStream.Read(ucWeaponSkill)) { CWeaponStat* pWeaponInfo = g_pGame->GetWeaponStatManager()->GetWeaponStats(static_cast<eWeaponType>(ucWeapon), static_cast<eWeaponSkill>(ucWeaponSkill)); switch (ucProperty) { case WEAPON_WEAPON_RANGE: { bitStream.Read(fData); pWeaponInfo->SetWeaponRange(fData); break; } case WEAPON_TARGET_RANGE: { bitStream.Read(fData); pWeaponInfo->SetTargetRange(fData); break; } case WEAPON_ACCURACY: { bitStream.Read(fData); pWeaponInfo->SetAccuracy(fData); break; } case WEAPON_LIFE_SPAN: { bitStream.Read(fData); pWeaponInfo->SetLifeSpan(fData); break; } case WEAPON_FIRING_SPEED: { bitStream.Read(fData); pWeaponInfo->SetFiringSpeed(fData); break; } case WEAPON_MOVE_SPEED: { bitStream.Read(fData); pWeaponInfo->SetMoveSpeed(fData); break; } case WEAPON_ANIM_LOOP_START: { bitStream.Read(fData); pWeaponInfo->SetWeaponAnimLoopStart(fData); break; } case WEAPON_ANIM_LOOP_STOP: { bitStream.Read(fData); pWeaponInfo->SetWeaponAnimLoopStop(fData); break; } case WEAPON_ANIM_LOOP_RELEASE_BULLET_TIME: { bitStream.Read(fData); pWeaponInfo->SetWeaponAnimLoopFireTime(fData); break; } case WEAPON_ANIM2_LOOP_START: { bitStream.Read(fData); pWeaponInfo->SetWeaponAnim2LoopStart(fData); break; } case WEAPON_ANIM2_LOOP_STOP: { bitStream.Read(fData); pWeaponInfo->SetWeaponAnim2LoopStop(fData); break; } case WEAPON_ANIM2_LOOP_RELEASE_BULLET_TIME: { bitStream.Read(fData); pWeaponInfo->SetWeaponAnim2LoopFireTime(fData); break; } case WEAPON_ANIM_BREAKOUT_TIME: { bitStream.Read(fData); pWeaponInfo->SetWeaponAnimBreakoutTime(fData); break; } case WEAPON_DAMAGE: { bitStream.Read(sData); pWeaponInfo->SetDamagePerHit(sData); break; } case WEAPON_MAX_CLIP_AMMO: { bitStream.Read(sData); pWeaponInfo->SetMaximumClipAmmo(sData); break; } case WEAPON_FLAGS: { int iData = 0; if (bitStream.Version() < 0x57) { bitStream.Read(sData); iData = sData; } else bitStream.Read(iData); pWeaponInfo->ToggleFlagBits(iData); break; } case WEAPON_ANIM_GROUP: { bitStream.Read(sData); pWeaponInfo->SetAnimGroup(sData); break; } case WEAPON_FLAG_AIM_NO_AUTO: case WEAPON_FLAG_AIM_ARM: case WEAPON_FLAG_AIM_1ST_PERSON: case WEAPON_FLAG_AIM_FREE: case WEAPON_FLAG_MOVE_AND_AIM: case WEAPON_FLAG_MOVE_AND_SHOOT: case WEAPON_FLAG_TYPE_THROW: case WEAPON_FLAG_TYPE_HEAVY: case WEAPON_FLAG_TYPE_CONSTANT: case WEAPON_FLAG_TYPE_DUAL: case WEAPON_FLAG_ANIM_RELOAD: case WEAPON_FLAG_ANIM_CROUCH: case WEAPON_FLAG_ANIM_RELOAD_LOOP: case WEAPON_FLAG_ANIM_RELOAD_LONG: case WEAPON_FLAG_SHOT_SLOWS: case WEAPON_FLAG_SHOT_RAND_SPEED: case WEAPON_FLAG_SHOT_ANIM_ABRUPT: case WEAPON_FLAG_SHOT_EXPANDS: { bool bEnable; bitStream.ReadBit(bEnable); uint uiFlagBit = GetWeaponPropertyFlagBit((eWeaponProperty)ucProperty); if (bEnable) pWeaponInfo->SetFlagBits(uiFlagBit); else pWeaponInfo->ClearFlagBits(uiFlagBit); break; } } } }
bool CMapInfoPacket::Write ( NetBitStreamInterface& BitStream ) const { // Write the map weather BitStream.Write ( m_ucWeather ); BitStream.Write ( m_ucWeatherBlendingTo ); BitStream.Write ( m_ucBlendedWeatherHour ); BitStream.WriteBit ( m_bHasSkyGradient ); if ( m_bHasSkyGradient ) { BitStream.Write ( m_ucSkyGradientTR ); BitStream.Write ( m_ucSkyGradientTG ); BitStream.Write ( m_ucSkyGradientTB ); BitStream.Write ( m_ucSkyGradientBR ); BitStream.Write ( m_ucSkyGradientBG ); BitStream.Write ( m_ucSkyGradientBB ); } // Write heat haze BitStream.WriteBit ( m_bHasHeatHaze ); if ( m_bHasHeatHaze ) { SHeatHazeSync heatHaze ( m_HeatHazeSettings ); BitStream.Write ( &heatHaze ); } // Write the map hour BitStream.Write ( m_ucClockHour ); BitStream.Write ( m_ucClockMin ); BitStream.WriteCompressed ( m_ulMinuteDuration ); // Write the map flags SMapInfoFlagsSync flags; flags.data.bShowNametags = m_bShowNametags; flags.data.bShowRadar = m_bShowRadar; flags.data.bCloudsEnabled = m_bCloudsEnabled; BitStream.Write ( &flags ); // Write any other world conditions BitStream.Write ( m_fGravity ); if ( m_fGameSpeed == 1.0f ) BitStream.WriteBit ( true ); else { BitStream.WriteBit ( false ); BitStream.Write ( m_fGameSpeed ); } BitStream.Write ( m_fWaveHeight ); // Write world water level BitStream.Write ( m_WorldWaterLevelInfo.fSeaLevel ); BitStream.WriteBit ( m_WorldWaterLevelInfo.bNonSeaLevelSet ); if ( m_WorldWaterLevelInfo.bNonSeaLevelSet ) BitStream.Write ( m_WorldWaterLevelInfo.fNonSeaLevel ); BitStream.WriteCompressed ( m_usFPSLimit ); // Write the garage states for ( unsigned char i = 0 ; i < MAX_GARAGES ; i++ ) { const SGarageStates& garageStates = *m_pGarageStates; BitStream.WriteBit( garageStates[i] ); } // Write the fun bugs state SFunBugsStateSync funBugs; funBugs.data.bQuickReload = g_pGame->IsGlitchEnabled ( CGame::GLITCH_QUICKRELOAD ); funBugs.data.bFastFire = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTFIRE ); funBugs.data.bFastMove = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTMOVE ); funBugs.data.bCrouchBug = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CROUCHBUG ); funBugs.data.bCloseRangeDamage = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CLOSEDAMAGE ); funBugs.data2.bHitAnim = g_pGame->IsGlitchEnabled ( CGame::GLITCH_HITANIM ); funBugs.data3.bFastSprint = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTSPRINT ); BitStream.Write ( &funBugs ); BitStream.Write ( m_fJetpackMaxHeight ); BitStream.WriteBit ( m_bOverrideWaterColor ); if ( m_bOverrideWaterColor ) { BitStream.Write ( m_ucWaterRed ); BitStream.Write ( m_ucWaterGreen ); BitStream.Write ( m_ucWaterBlue ); BitStream.Write ( m_ucWaterAlpha ); } // Interior sounds BitStream.WriteBit ( m_bInteriorSoundsEnabled ); // Rain level BitStream.WriteBit ( m_bOverrideRainLevel ); if ( m_bOverrideRainLevel ) { BitStream.Write ( m_fRainLevel ); } // Moon size if ( BitStream.Version () >= 0x40 ) { BitStream.WriteBit ( m_bOverrideMoonSize ); if ( m_bOverrideMoonSize ) { BitStream.Write ( m_iMoonSize ); } } // Sun size BitStream.WriteBit ( m_bOverrideSunSize ); if ( m_bOverrideSunSize ) { BitStream.Write ( m_fSunSize ); } // Sun color BitStream.WriteBit ( m_bOverrideSunColor ); if ( m_bOverrideSunColor ) { BitStream.Write ( m_ucSunCoreR ); BitStream.Write ( m_ucSunCoreG ); BitStream.Write ( m_ucSunCoreB ); BitStream.Write ( m_ucSunCoronaR ); BitStream.Write ( m_ucSunCoronaG ); BitStream.Write ( m_ucSunCoronaB ); } // Wind velocity BitStream.WriteBit ( m_bOverrideWindVelocity ); if ( m_bOverrideWindVelocity ) { BitStream.Write ( m_fWindVelX ); BitStream.Write ( m_fWindVelY ); BitStream.Write ( m_fWindVelZ ); } // Far clip distance BitStream.WriteBit ( m_bOverrideFarClipDistance ); if ( m_bOverrideFarClipDistance ) { BitStream.Write ( m_fFarClip ); } // Fog distance BitStream.WriteBit ( m_bOverrideFogDistance ); if ( m_bOverrideFogDistance ) { BitStream.Write ( m_fFogDistance ); } BitStream.Write ( m_fAircraftMaxHeight ); if ( BitStream.Version () >= 0x3E ) BitStream.Write ( m_fAircraftMaxVelocity ); if ( BitStream.Version () >= 0x30 ) { for (int i = WEAPONTYPE_BRASSKNUCKLE; i < WEAPONTYPE_PISTOL; i++) { bool bEnabled; bEnabled = g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i ); BitStream.WriteBit ( bEnabled ); } } for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_EXTINGUISHER;i++) { sWeaponPropertySync WeaponProperty; CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i ); BitStream.WriteBit ( true ); WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType(); WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy(); WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed(); WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange(); WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange(); WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo(); WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit(); WeaponProperty.data.nFlags = pWeaponStat->GetFlags(); WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart(); WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop(); WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime(); WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart(); WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop(); WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime(); WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime(); BitStream.Write( &WeaponProperty ); if ( BitStream.Version () >= 0x30 ) { BitStream.WriteBit ( g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i ) ); } } for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_TEC9;i++) { sWeaponPropertySync WeaponProperty; BitStream.WriteBit ( true ); for (int j = 0; j <= 2;j++) { CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i, (eWeaponSkill)j ); WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType(); WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy(); WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed(); WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange(); WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange(); WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo(); WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit(); WeaponProperty.data.nFlags = pWeaponStat->GetFlags(); WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart(); WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop(); WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime(); WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart(); WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop(); WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime(); WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime(); BitStream.Write( &WeaponProperty ); } if ( BitStream.Version () >= 0x36 ) { BitStream.WriteBit ( g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i ) ); } } if ( BitStream.Version () >= 0x30 ) { for (int i = WEAPONTYPE_CAMERA; i <= WEAPONTYPE_PARACHUTE; i++) { bool bEnabled; bEnabled = g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i ); BitStream.WriteBit ( bEnabled ); } } multimap< unsigned short, CBuildingRemoval* >::const_iterator iter = g_pGame->GetBuildingRemovalManager ( )->IterBegin(); for (; iter != g_pGame->GetBuildingRemovalManager ( )->IterEnd();++iter) { CBuildingRemoval * pBuildingRemoval = (*iter).second; BitStream.WriteBit( true ); BitStream.Write( pBuildingRemoval->GetModel ( ) ); BitStream.Write( pBuildingRemoval->GetRadius ( ) ); BitStream.Write( pBuildingRemoval->GetPosition ( ).fX ); BitStream.Write( pBuildingRemoval->GetPosition ( ).fY ); BitStream.Write( pBuildingRemoval->GetPosition ( ).fZ ); if ( BitStream.Version() >= 0x039 ) { BitStream.Write ( pBuildingRemoval->GetInterior ( ) ); } } BitStream.WriteBit( false ); if ( BitStream.Version () >= 0x25 ) { bool bOcclusionsEnabled = g_pGame->GetOcclusionsEnabled (); BitStream.WriteBit( bOcclusionsEnabled ); } return true; }
void SwitchContext ( CPed* thePed ) { if ( thePed == NULL ) return; pContextSwitchedPed = thePed; // Are we not already in another context? if ( !bNotInLocalContext ) { // Grab the local ped and the local pad CPed* pLocalPlayerPed = pGameInterface->GetPools ()->GetPedFromRef ( (DWORD)1 ); // the player CPad* pLocalPad = pGameInterface->GetPad (); CPadSAInterface* pLocalPadInterface = ( (CPadSA*) pLocalPad )->GetInterface (); // We're not switching to local player if ( thePed != pLocalPlayerPed ) { // Store the local pad pLocalPad->Store (); // store a copy of the local pad internally // Grab the remote data storage for the player we're context switching to CPlayerPed* thePlayerPed = dynamic_cast < CPlayerPed* > ( thePed ); if ( thePlayerPed ) { CRemoteDataStorageSA * data = CRemoteDataSA::GetRemoteDataStorage ( thePlayerPed ); if ( data ) { // We want the player to be seen as in targeting mode if they are right clicking and with weapons CWeapon* pWeapon = thePed->GetWeapon(thePed->GetCurrentWeaponSlot()); eWeaponType currentWeapon = pWeapon->GetType(); CControllerState * cs = data->CurrentControllerState(); CWeaponStat * pWeaponStat = NULL; if ( currentWeapon >= WEAPONTYPE_PISTOL && currentWeapon <= WEAPONTYPE_TEC9 ) { float fValue = data->m_stats.StatTypesFloat [ pGameInterface->GetStats ()->GetSkillStatIndex ( currentWeapon ) ]; pWeaponStat = pGameInterface->GetWeaponStatManager ( )->GetWeaponStatsFromSkillLevel ( currentWeapon, fValue ); } else pWeaponStat = pGameInterface->GetWeaponStatManager ( )->GetWeaponStats ( currentWeapon ); if ( cs->RightShoulder1 != 0 && ( pWeaponStat && pWeaponStat->IsFlagSet ( WEAPONTYPE_FIRSTPERSON ) ) ) { b1stPersonWeaponModeHackInPlace = true; // make the CCamera::Using1stPersonWeaponMode function return true MemPutFast < BYTE > ( 0x50BFF0, 0xB0 ); MemPutFast < BYTE > ( 0x50BFF1, 0x01 ); MemPutFast < BYTE > ( 0x50BFF2, 0xC3 ); } // Change the local player's pad to the remote player's MemCpyFast ( pLocalPadInterface, &data->m_pad, sizeof ( CPadSAInterface ) ); // this is to fix the horn/siren pLocalPad->SetHornHistoryValue ( ( cs->ShockButtonL == 255 ) ); // disables the impatient actions on remote players (which cause desync) pLocalPad->SetLastTimeTouched ( pGameInterface->GetSystemTime () ); // this is to make movement work correctly fLocalPlayerCameraRotation = *(float *)VAR_CameraRotation; MemPutFast < float > ( VAR_CameraRotation, data->m_fCameraRotation ); // Change the gravity to the remote player's pGameInterface->SetGravity ( data->m_fGravity ); // Disable mouselook for remote players (so the mouse doesn't affect them) // Only disable mouselook if they're not holding a 1st-person weapon // And if they're not under-water bool bDisableMouseLook = true; if ( pWeapon ) { eWeaponType weaponType = pWeapon->GetType (); if ( pWeaponStat->IsFlagSet ( WEAPONTYPE_FIRSTPERSON ) ) { bDisableMouseLook = false; } } bMouseLookEnabled = *(bool *)0xB6EC2E; if ( bDisableMouseLook ) *(bool *)0xB6EC2E = false; // Disable the goggles bInfraredVisionEnabled = *(bool *)0xC402B9; MemPutFast < bool > ( 0xC402B9, false ); bNightVisionEnabled = *(bool *)0xC402B8; MemPutFast < bool > ( 0xC402B8, false ); // Remove the code making players cough on fire extinguisher and teargas MemSetFast ( (void*) 0x4C03F0, 0x90, 3 ); MemSetFast ( (void*) 0x4C03F8, 0x90, 7 ); // Prevent it calling ClearWeaponTarget for remote players MemPutFast < BYTE > ( 0x609C80, 0xC3 ); // Prevent rockets firing oddly //*(BYTE *)0x73811C = 0x90; //*(BYTE *)0x73811D = 0xE9; // This is so weapon clicks and similar don't play for us when done remotly MemPutFast < BYTE > ( 0x60F273, 0xEB ); MemPutFast < BYTE > ( 0x60F260, 0x90 ); MemPutFast < BYTE > ( 0x60F261, 0x90 ); // Prevent CCamera::SetNewPlayerWeaponMode being called MemPutFast < BYTE > ( 0x50BFB0, 0xC2 ); MemPutFast < BYTE > ( 0x50BFB1, 0x0C ); MemPutFast < BYTE > ( 0x50BFB2, 0x00 ); // Prevent it calling CCamera::ClearPlayerWeaponMode for remote players MemPutFast < BYTE > ( 0x50AB10, 0xC3 ); // Prevent it marking targets of remote players MemPutFast < BYTE > ( 0x742BF0, 0xC3 ); // this is to prevent shooting players following the local camera MemPutFast < BYTE > ( 0x687099, 0xEB ); // Prevent the game making remote player's weapons get switched by the local player's MemPutFast < BYTE > ( 0x60D850, 0xC2 ); MemPutFast < BYTE > ( 0x60D851, 0x04 ); MemPutFast < BYTE > ( 0x60D852, 0x00 ); // Change the local player's stats to the remote player's if ( data ) { MemCpyFast ( (void *)0xb79380, data->m_stats.StatTypesFloat, sizeof(float) * MAX_FLOAT_STATS ); MemCpyFast ( (void *)0xb79000, data->m_stats.StatTypesInt, sizeof(int) * MAX_INT_STATS ); MemCpyFast ( (void *)0xb78f10, data->m_stats.StatReactionValue, sizeof(float) * MAX_REACTION_STATS ); } /* // ChrML: Force as high stats as we can go before screwing up. Players can't have different // stats or guns don't work. We can't have dual guns either due to some screwups. // Dual gun screwup: Sync code needs update and the gun pointing up needs to. float* pfStats = (float*) 0xb79380; pfStats [ 69 ] = 500.0f; pfStats [ 70 ] = 999.0f; pfStats [ 71 ] = 999.0f; pfStats [ 72 ] = 999.0f; pfStats [ 73 ] = 500.0f; pfStats [ 74 ] = 999.0f; pfStats [ 75 ] = 500.0f; pfStats [ 76 ] = 999.0f; pfStats [ 77 ] = 999.0f; pfStats [ 78 ] = 999.0f; pfStats [ 79 ] = 999.0f; */ CPedSA* thePedSA = dynamic_cast < CPedSA* > ( thePed ); if ( thePedSA ) { CEntitySAInterface * ped = thePedSA->GetInterface(); MemPutFast < DWORD > ( 0xB7CD98, (DWORD)ped ); } // Remember that we're not in the local player's context any more (for switching back) bNotInLocalContext = true; // Call the pre-context switch handler we might have if ( m_pPreContextSwitchHandler ) { CPlayerPed* pPlayerPed = dynamic_cast < CPlayerPed* > ( thePed ); if ( pPlayerPed ) m_pPreContextSwitchHandler ( pPlayerPed ); } } } } else { // Set the local players gravity pGameInterface->SetGravity ( fLocalPlayerGravity ); if ( bCustomCameraRotation ) MemPutFast < float > ( VAR_CameraRotation, fLocalPlayerCameraRotation ); } } pGameInterface->OnPedContextChange ( thePed ); }
void CWorldRPCs::SetWeaponProperty ( NetBitStreamInterface& bitStream ) { unsigned char ucWeapon = 0; unsigned char ucProperty = 0; unsigned char ucWeaponSkill = 0; float fData = 0.0f; short sData = 0; if ( bitStream.Read ( ucWeapon ) && bitStream.Read ( ucProperty ) && bitStream.Read ( ucWeaponSkill ) ) { CWeaponStat* pWeaponInfo = g_pGame->GetWeaponStatManager()->GetWeaponStats( static_cast < eWeaponType > ( ucWeapon ), static_cast < eWeaponSkill > ( ucWeaponSkill ) ); CWeaponStat* pOriginalWeaponInfo = g_pGame->GetWeaponStatManager()->GetOriginalWeaponStats( static_cast < eWeaponType > ( ucWeapon ), static_cast < eWeaponSkill > ( ucWeaponSkill ) ); switch ( ucProperty ) { case WEAPON_WEAPON_RANGE: { bitStream.Read ( fData ); pWeaponInfo->SetWeaponRange ( fData ); break; } case WEAPON_TARGET_RANGE: { bitStream.Read ( fData ); pWeaponInfo->SetTargetRange ( fData ); break; } case WEAPON_ACCURACY: { bitStream.Read ( fData ); pWeaponInfo->SetAccuracy ( fData ); break; } case WEAPON_LIFE_SPAN: { bitStream.Read ( fData ); pWeaponInfo->SetLifeSpan ( fData ); break; } case WEAPON_FIRING_SPEED: { bitStream.Read ( fData ); pWeaponInfo->SetFiringSpeed ( fData ); break; } case WEAPON_MOVE_SPEED: { bitStream.Read ( fData ); pWeaponInfo->SetMoveSpeed ( fData ); break; } case WEAPON_ANIM_LOOP_START: { bitStream.Read ( fData ); pWeaponInfo->SetWeaponAnimLoopStart ( fData ); break; } case WEAPON_ANIM_LOOP_STOP: { bitStream.Read ( fData ); pWeaponInfo->SetWeaponAnimLoopStop ( fData ); break; } case WEAPON_ANIM_LOOP_RELEASE_BULLET_TIME: { bitStream.Read ( fData ); pWeaponInfo->SetWeaponAnimLoopFireTime ( fData ); break; } case WEAPON_ANIM2_LOOP_START: { bitStream.Read ( fData ); pWeaponInfo->SetWeaponAnim2LoopStart ( fData ); break; } case WEAPON_ANIM2_LOOP_STOP: { bitStream.Read ( fData ); pWeaponInfo->SetWeaponAnim2LoopStop ( fData ); break; } case WEAPON_ANIM2_LOOP_RELEASE_BULLET_TIME: { bitStream.Read ( fData ); pWeaponInfo->SetWeaponAnim2LoopFireTime ( fData ); break; } case WEAPON_ANIM_BREAKOUT_TIME: { bitStream.Read ( fData ); pWeaponInfo->SetWeaponAnimBreakoutTime ( fData ); break; } case WEAPON_DAMAGE: { bitStream.Read ( sData ); pWeaponInfo->SetDamagePerHit ( sData ); break; } case WEAPON_MAX_CLIP_AMMO: { bitStream.Read ( sData ); pWeaponInfo->SetMaximumClipAmmo ( sData ); break; } case WEAPON_FLAGS: { bitStream.Read ( sData ); if ( pWeaponInfo->IsFlagSet ( sData ) ) { if ( sData == 0x800 ) { // if it can support this anim group if ( ( ucWeapon >= WEAPONTYPE_PISTOL && ucWeapon <= WEAPONTYPE_SNIPERRIFLE ) || ucWeapon == WEAPONTYPE_MINIGUN ) { // Revert anim group to default pWeaponInfo->SetAnimGroup ( pOriginalWeaponInfo->GetAnimGroup ( ) ); } } pWeaponInfo->ClearFlag ( sData ); } else { if ( sData == 0x800 ) { // if it can support this anim group if ( ( ucWeapon >= WEAPONTYPE_PISTOL && ucWeapon <= WEAPONTYPE_SNIPERRIFLE ) || ucWeapon == WEAPONTYPE_MINIGUN ) { // sawn off shotgun anim group pWeaponInfo->SetAnimGroup ( 17 ); } } pWeaponInfo->SetFlag ( sData ); } break; } case WEAPON_ANIM_GROUP: { bitStream.Read ( sData ); pWeaponInfo->SetAnimGroup ( sData ); break; } } } }
bool CMapInfoPacket::Write ( NetBitStreamInterface& BitStream ) const { // Write the map weather BitStream.Write ( m_ucWeather ); BitStream.Write ( m_ucWeatherBlendingTo ); BitStream.Write ( m_ucBlendedWeatherHour ); BitStream.WriteBit ( m_bHasSkyGradient ); if ( m_bHasSkyGradient ) { BitStream.Write ( m_ucSkyGradientTR ); BitStream.Write ( m_ucSkyGradientTG ); BitStream.Write ( m_ucSkyGradientTB ); BitStream.Write ( m_ucSkyGradientBR ); BitStream.Write ( m_ucSkyGradientBG ); BitStream.Write ( m_ucSkyGradientBB ); } // Write heat haze BitStream.WriteBit ( m_bHasHeatHaze ); if ( m_bHasHeatHaze ) { SHeatHazeSync heatHaze ( m_HeatHazeSettings ); BitStream.Write ( &heatHaze ); } // Write the map hour BitStream.Write ( m_ucClockHour ); BitStream.Write ( m_ucClockMin ); BitStream.WriteCompressed ( m_ulMinuteDuration ); // Write the map flags SMapInfoFlagsSync flags; flags.data.bShowNametags = m_bShowNametags; flags.data.bShowRadar = m_bShowRadar; flags.data.bCloudsEnabled = m_bCloudsEnabled; BitStream.Write ( &flags ); // Write any other world conditions BitStream.Write ( m_fGravity ); if ( m_fGameSpeed == 1.0f ) BitStream.WriteBit ( true ); else { BitStream.WriteBit ( false ); BitStream.Write ( m_fGameSpeed ); } BitStream.Write ( m_fWaveHeight ); // Write world water level BitStream.Write ( m_WorldWaterLevelInfo.fSeaLevel ); BitStream.WriteBit ( m_WorldWaterLevelInfo.bNonSeaLevelSet ); if ( m_WorldWaterLevelInfo.bNonSeaLevelSet ) BitStream.Write ( m_WorldWaterLevelInfo.fNonSeaLevel ); BitStream.WriteCompressed ( m_usFPSLimit ); // Write the garage states for ( unsigned char i = 0 ; i < MAX_GARAGES ; i++ ) { BitStream.WriteBit( static_cast < unsigned char > ( m_pbGarageStates[i] ) ); } // Write the fun bugs state SFunBugsStateSync funBugs; funBugs.data.bQuickReload = g_pGame->IsGlitchEnabled ( CGame::GLITCH_QUICKRELOAD ); funBugs.data.bFastFire = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTFIRE ); funBugs.data.bFastMove = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTMOVE ); funBugs.data.bCrouchBug = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CROUCHBUG ); funBugs.data.bCloseRangeDamage = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CLOSEDAMAGE ); BitStream.Write ( &funBugs ); BitStream.Write ( m_fJetpackMaxHeight ); BitStream.WriteBit ( m_bOverrideWaterColor ); if ( m_bOverrideWaterColor ) { BitStream.Write ( m_ucWaterRed ); BitStream.Write ( m_ucWaterGreen ); BitStream.Write ( m_ucWaterBlue ); BitStream.Write ( m_ucWaterAlpha ); } // Interior sounds BitStream.WriteBit ( m_bInteriorSoundsEnabled ); // Rain level BitStream.WriteBit ( m_bOverrideRainLevel ); if ( m_bOverrideRainLevel ) { BitStream.Write ( m_fRainLevel ); } // Sun size BitStream.WriteBit ( m_bOverrideSunSize ); if ( m_bOverrideSunSize ) { BitStream.Write ( m_fSunSize ); } // Sun color BitStream.WriteBit ( m_bOverrideSunColor ); if ( m_bOverrideSunColor ) { BitStream.Write ( m_ucSunCoreR ); BitStream.Write ( m_ucSunCoreG ); BitStream.Write ( m_ucSunCoreB ); BitStream.Write ( m_ucSunCoronaR ); BitStream.Write ( m_ucSunCoronaG ); BitStream.Write ( m_ucSunCoronaB ); } // Wind velocity BitStream.WriteBit ( m_bOverrideWindVelocity ); if ( m_bOverrideWindVelocity ) { BitStream.Write ( m_fWindVelX ); BitStream.Write ( m_fWindVelY ); BitStream.Write ( m_fWindVelZ ); } // Far clip distance BitStream.WriteBit ( m_bOverrideFarClipDistance ); if ( m_bOverrideFarClipDistance ) { BitStream.Write ( m_fFarClip ); } // Fog distance BitStream.WriteBit ( m_bOverrideFogDistance ); if ( m_bOverrideFogDistance ) { BitStream.Write ( m_fFogDistance ); } BitStream.Write ( m_fAircraftMaxHeight ); for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_EXTINGUISHER;i++) { sWeaponPropertySync WeaponProperty; CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i ); BitStream.WriteBit ( true ); WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType(); WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy(); WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed(); WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange(); WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange(); WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo(); WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit(); WeaponProperty.data.nFlags = pWeaponStat->GetFlags(); WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart(); WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop(); WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime(); WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart(); WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop(); WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime(); WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime(); BitStream.Write( &WeaponProperty ); } for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_TEC9;i++) { sWeaponPropertySync WeaponProperty; BitStream.WriteBit ( true ); for (int j = 0; j <= 2;j++) { CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i, (eWeaponSkill)j ); WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType(); WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy(); WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed(); WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange(); WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange(); WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo(); WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit(); WeaponProperty.data.nFlags = pWeaponStat->GetFlags(); WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart(); WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop(); WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime(); WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart(); WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop(); WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime(); WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime(); BitStream.Write( &WeaponProperty ); } } return true; }
void CNametags::DrawFromAim() { unsigned long ulCurrentTime = CClientTime::GetTime(); // Got any players that are not local? if (m_pPlayerManager->Count() > 1) { // Grab the local player CClientPlayer* pLocalPlayer = m_pPlayerManager->GetLocalPlayer(); if (pLocalPlayer) { // Grab the current time and the camera unsigned long ulCurrentTime = CClientTime::GetTime(); CCamera* pCamera = g_pGame->GetCamera(); // Grab our controller state CControllerState State; g_pGame->GetPad()->GetCurrentControllerState(&State); // Grab our current weapon slot. Use screen center if melee or none CVector vecStart; CVector vecTarget; eWeaponSlot eSlot = pLocalPlayer->GetCurrentWeaponSlot(); if (eSlot == WEAPONSLOT_TYPE_UNARMED || eSlot == WEAPONSLOT_TYPE_MELEE || eSlot == WEAPONSLOT_TYPE_RIFLE || eSlot == WEAPONSLOT_TYPE_THROWN || eSlot == WEAPONSLOT_TYPE_SPECIAL || eSlot == WEAPONSLOT_TYPE_GIFT || eSlot == WEAPONSLOT_TYPE_PARACHUTE || eSlot == WEAPONSLOT_TYPE_DETONATOR) { // Grab the active cam CCamera* pCamera = g_pGame->GetCamera(); CCam* pActive = pCamera->GetCam(pCamera->GetActiveCam()); // Grab the camera matrix CMatrix matCamera; pCamera->GetMatrix(&matCamera); vecStart = matCamera.vPos; // Range float fRange; eWeaponType eWeapon = pLocalPlayer->GetCurrentWeaponType(); float fSkill = pLocalPlayer->GetStat(g_pGame->GetStats()->GetSkillStatIndex(eWeapon)); CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager()->GetWeaponStatsFromSkillLevel(eWeapon, fSkill); if (pWeaponStat) { fRange = pWeaponStat->GetTargetRange(); } else { fRange = MELEE_VISIBLE_RANGE; } // Find the target position CVector vecFront = *pActive->GetFront(); vecFront.Normalize(); vecTarget = *pActive->GetSource() + vecFront * fRange; } else { // Grab the weapon and keysync state. If it exists and he holds Target down CWeapon* pPlayerWeapon = pLocalPlayer->GetWeapon(); if (pPlayerWeapon && State.RightShoulder1) { // Grab the gun muzzle position eWeaponType eWeapon = pLocalPlayer->GetCurrentWeaponType(); float fSkill = pLocalPlayer->GetStat(g_pGame->GetStats()->GetSkillStatIndex(eWeapon)); CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager()->GetWeaponStatsFromSkillLevel(eWeapon, fSkill); CVector vecGunMuzzle = *pWeaponStat->GetFireOffset(); pLocalPlayer->GetTransformedBonePosition(BONE_RIGHTWRIST, vecGunMuzzle); // Grab the target point pCamera->Find3rdPersonCamTargetVector(AIM_VISIBLE_RANGE, &vecGunMuzzle, &vecStart, &vecTarget); } else { // Grab the active cam CCam* pActive = pCamera->GetCam(pCamera->GetActiveCam()); // Grab the camera matrix CMatrix matCamera; pCamera->GetMatrix(&matCamera); vecStart = matCamera.vPos; // Find the target position CVector vecFront = *pActive->GetFront(); vecFront.Normalize(); vecTarget = *pActive->GetSource() + vecFront * MELEE_VISIBLE_RANGE; } } // Ignore the local player for this pLocalPlayer->WorldIgnore(true); // Do the raycast CColPoint* pColPoint = NULL; CEntity* pEntity = NULL; SLineOfSightFlags flags; flags.bCheckBuildings = true; flags.bCheckVehicles = true; flags.bCheckPeds = true; flags.bCheckObjects = true; flags.bCheckDummies = true; flags.bSeeThroughStuff = true; flags.bIgnoreSomeObjectsForCamera = false; flags.bShootThroughStuff = true; g_pGame->GetWorld()->ProcessLineOfSight(&vecStart, &vecTarget, &pColPoint, &pEntity, flags); if (pColPoint) pColPoint->Destroy(); // Un-ignore the local player pLocalPlayer->WorldIgnore(false); // Did we find an entity? if (pEntity) { // Grab the CClientEntity belonging to this game_sa entity CClientEntity* pClientEntity = reinterpret_cast<CClientEntity*>(pEntity->GetStoredPointer()); if (pClientEntity) { // Is it a vehicle? Is it a ped? eClientEntityType EntityType = pClientEntity->GetType(); if (EntityType == CCLIENTVEHICLE) { CClientVehicle* pClientVehicle = static_cast<CClientVehicle*>(pClientEntity); // Set the current time as the last draw time for all players inside CClientPed* pPed; int i; for (i = 0; i < 8; i++) { // Grab this seat's occupant and set its last nametag show time to now pPed = pClientVehicle->GetOccupant(i); if (pPed && pPed->GetType() == CCLIENTPLAYER) { static_cast<CClientPlayer*>(pPed)->SetLastNametagShow(ulCurrentTime); } } } else if (EntityType == CCLIENTPLAYER) { // Grab the player this entity is CClientPlayer* pClientPlayer = static_cast<CClientPlayer*>(pClientEntity); if (pClientPlayer) { // Set now as the last time we had the cursor above him pClientPlayer->SetLastNametagShow(ulCurrentTime); } } } } // Grab the local player vehicle CClientVehicle* pLocalVehicle = pLocalPlayer->GetOccupiedVehicle(); // Draw the nametags we need to CClientPlayer* pPlayer; CClientStreamElement* pElement; list<CClientStreamElement*>::const_iterator iter = m_pPlayerStreamer->ActiveElementsBegin(); for (; iter != m_pPlayerStreamer->ActiveElementsEnd(); ++iter) { pElement = *iter; if (!pElement->IsStreamedIn()) continue; if (pElement->GetType() != CCLIENTPLAYER) continue; pPlayer = static_cast<CClientPlayer*>(pElement); if (pPlayer->IsLocalPlayer()) continue; // Is he in the same vehicle as the local player? if (pLocalVehicle && pPlayer->GetOccupiedVehicle() == pLocalVehicle) { pPlayer->SetLastNametagShow(ulCurrentTime); } // Can we show this player's nametag unsigned long ulLastNametagShow = pPlayer->GetLastNametagShow(); if (ulLastNametagShow != 0 && ulCurrentTime <= ulLastNametagShow + NAMETAG_END_FADE_TIME) { unsigned long ulLastNametagShow = pPlayer->GetLastNametagShow(); // Calculate the alpha modifier float fAlphaTimeModifier; if (ulCurrentTime < ulLastNametagShow + NAMETAG_BEGIN_FADE_TIME) { fAlphaTimeModifier = 1.0f; } else { fAlphaTimeModifier = 1.0f - (ulCurrentTime - ulLastNametagShow - NAMETAG_BEGIN_FADE_TIME) / 1000.0f; } // Calculate the alpha for the nametag unsigned char ucAlpha = static_cast<unsigned char>(180.0f * fAlphaTimeModifier); // Draw it DrawTagForPlayer(pPlayer, ucAlpha); } } } } }