//////////////////////////////////////////////////// // // CMouseControl::ProcessMouseMove // // Process a windows mouse movement message and turn it into control // //////////////////////////////////////////////////// bool CMouseControl::ProcessMouseMove ( UINT uMsg, WPARAM wParam, LPARAM lParam ) { if ( uMsg != WM_MOUSEMOVE ) return false; if ( g_pCore->GetGame ()->GetSystemState () != 9 ) return false; // HACK: Grab our local player, and check his vehicle CPed* pPed = g_pCore->GetGame ()->GetPools ()->GetPedFromRef ( (DWORD)1 ); if ( !pPed ) return false; CVehicle* pVehicle = pPed->GetVehicle (); if ( !pVehicle ) return false; CModelInfo* pModelInfo = g_pCore->GetGame ()->GetModelInfo( pVehicle->GetModelIndex() ); bool bVar; CVARS_GET ( "fly_with_mouse", bVar ); if ( pModelInfo->IsPlane() || pModelInfo->IsHeli() && !bVar ) // Are we in a plane, but not have mouse flight enabled? return false; CVARS_GET ( "steer_with_mouse", bVar ); if ( !bVar ) // Are we in another type of vehicle, but not have mouse steering enabled? return false; // Let's calculate our mouse movement directions CVector2D resolution = g_pCore->GetGUI()->GetResolution(); int iX = LOWORD ( lParam ), iY = HIWORD ( lParam ); float fX = (iX - resolution.fX*0.5f)/resolution.fX; fX *= MOUSE_CONTROL_MULTIPLIER; float fMouseSensitivity = g_pCore->GetGame ( )->GetSettings()->GetMouseSensitivity (); fX *= fMouseSensitivity; m_usLeftStickX += fX*128; m_usLeftStickX = Clamp < const short > ( -128, m_usLeftStickX, 128 ); // Only process Y input if we're in a vehicle that requires it if ( pModelInfo->IsPlane() || pModelInfo->IsHeli() || pModelInfo->IsBike() || pModelInfo->IsBmx() || pModelInfo->IsQuadBike() ) { float fY = (resolution.fY*0.5f - iY)/resolution.fY; fY *= MOUSE_CONTROL_MULTIPLIER; fY *= fMouseSensitivity; CVARS_GET ( "invert_mouse", bVar ); fY = bVar ? -fY : fY; m_usLeftStickY += fY*128; m_usLeftStickY = Clamp < const short > ( -128, m_usLeftStickY, 128 ); } return true; }
int cheat_panic ( void ) { traceLastFunc( "cheat_panic()" ); static int pstate_map = 0, // m0d's map pstate_d3dtext_hud = 0, // hud bar pstate_actor_hp_nSP = 0, // "Extra actor invincibility" patch (invulnerable single player enemies) pstate_actor_hp_SP = 0, // "Extra actor invincibility2" patch (no problems in SP) pstate_vehicle_hp = 0, // vehicle hp patch pstate_generic_menu = 0, // m0d's menu pstate_infnos = 0, // infinite NOS pstate_ini[INI_PATCHES_MAX], pstate_dummy_aligner; // this should all be a structure, static = DOING IT WRONG int i; // sa-mp related static int pstate_chat = 0, // chat pstate_deathlist = 0; // deathlist if ( KEY_PRESSED(set.key_panic) ) { // toggle panic cheat_state->_generic.cheat_panic_enabled ^= 1; if ( cheat_state->_generic.cheat_panic_enabled ) { struct actor_info *actor_info = actor_info_get( ACTOR_SELF, ACTOR_ALIVE ); if ( actor_info ) { actor_info->flags &= ~ACTOR_FLAGS_INVULNERABLE; actor_info->weapon_slot = 0; } // remove infinite NOS pstate_infnos = cheat_state->vehicle.infNOS_toggle_on; cheat_state->vehicle.infNOS_toggle_on = false; patcher_remove( &patch_vehicle_inf_NOS ); if ( pPedSelf->GetVehicle() ) { CVehicle *pVehicleSelf = pPedSelf->GetVehicle(); CVehicle *pVehicleTemp = NULL; for ( pVehicleTemp = pVehicleSelf; pVehicleTemp != NULL; pVehicleTemp = pVehicleTemp->GetTowedVehicle() ) { pVehicleTemp->SetGravity( &CVector(0.0, 0.0, -1.0) ); pVehicleTemp->SetCanBeDamaged( true ); if ( !set.trailer_support ) break; } // remove inf NOS if ( pstate_infnos ) { pVehicleSelf->RemoveVehicleUpgrade( 1010 ); //pVehicleSelf->AddVehicleUpgrade( 1010 ); } // reset overrideLights, pstate not needed, will be reactivated on demand if ( set.enable_car_lights_at_day_time ) pVehicleSelf->SetOverrideLights( 0 ); } // hud bar, this should probably become a cheat_state pstate_d3dtext_hud = set.d3dtext_hud; set.d3dtext_hud = 0; // m0d's map pstate_map = cheat_state->_generic.map; cheat_state->_generic.map = 0; // m0d's menu pstate_generic_menu = cheat_state->_generic.menu; cheat_state->_generic.menu = 0; // remove "Extra actor invincibility" patch pstate_actor_hp_nSP = patch_actor_hp_extraInv.installed; patcher_remove( &patch_actor_hp_extraInv ); pstate_actor_hp_SP = patch_actor_hp.installed; patcher_remove( &patch_actor_hp ); // remove vehicle hp patch pstate_vehicle_hp = patch_vehicle_hp.installed; patcher_remove( &patch_vehicle_hp ); // just call with null vehicle info to disable cheat_handle_vehicle_fly( NULL, 0.0f ); for ( i = 0; i < INI_PATCHES_MAX; i++ ) { // added to not remove volatile patches if ( !set.patch[i].has_volatile ) { pstate_ini[i] = set.patch[i].installed; patcher_remove( &set.patch[i] ); } } // turn off kill & chat if ( g_DeathList != NULL ) { pstate_deathlist = g_DeathList->iEnabled; g_DeathList->iEnabled = 1; } if ( g_Chat != NULL ) { pstate_chat = g_Chat->iChatWindowMode; g_Chat->iChatWindowMode = 2; } } else { // restore infinite NOS if ( pstate_infnos ) { cheat_state->vehicle.infNOS_toggle_on = true; patcher_install( &patch_vehicle_inf_NOS ); } // vehicle stuff CPed *pPedSelf = pPools->GetPedFromRef( CPOOLS_PED_SELF_REF ); if ( pPedSelf->GetVehicle() ) { CVehicle *pVehicleSelf = pPedSelf->GetVehicle(); // restore inf NOS if ( pstate_infnos ) { pVehicleSelf->AddVehicleUpgrade( 1010 ); } } // restore "Extra actor invincibility" patch if ( pstate_actor_hp_nSP ) patcher_install( &patch_actor_hp_extraInv ); if ( pstate_actor_hp_SP ) patcher_install( &patch_actor_hp ); // restore vehicle hp patch if ( pstate_vehicle_hp ) patcher_install( &patch_vehicle_hp ); // restore some cheat_states set.d3dtext_hud = pstate_d3dtext_hud; cheat_state->_generic.map = pstate_map; cheat_state->_generic.menu = pstate_generic_menu; // restore patches for ( i = 0; i < INI_PATCHES_MAX; i++ ) { if ( pstate_ini[i] ) patcher_install( &set.patch[i] ); } // restore kill & chat if ( g_DeathList != NULL ) { g_DeathList->iEnabled = pstate_deathlist; } if ( g_Chat != NULL ) { g_Chat->iChatWindowMode = pstate_chat; } // clear cheat state text cheat_state_text( NULL ); } } return cheat_state->_generic.cheat_panic_enabled; }