void cheat_handle_freeze_vehicles ( struct vehicle_info *vehicle_info, struct actor_info *actor_info ) { traceLastFunc( "cheat_handle_freeze_vehicles()" ); static struct freeze_info *freeze; struct vehicle_info *info; float *pos; int i; if ( KEY_PRESSED(set.key_vehicles_freeze) ) { cheat_state->_generic.vehicles_freeze ^= 1; if ( !cheat_state->_generic.vehicles_freeze && freeze != NULL ) memset( freeze, 0, pool_vehicle->size * sizeof(struct freeze_info) ); } if ( vehicle_info != NULL ) pos = &vehicle_info->base.matrix[4 * 3]; else if ( actor_info != NULL ) pos = &actor_info->base.matrix[4 * 3]; else return; if ( freeze == NULL ) /* XXX free on exit */ { freeze = (struct freeze_info *)malloc( pool_vehicle->size * sizeof(struct freeze_info) ); if ( freeze == NULL ) return; memset( freeze, 0, pool_vehicle->size * sizeof(struct freeze_info) ); } if ( cheat_state->_generic.vehicles_freeze ) { for ( i = 0; i < pool_vehicle->size; i++ ) { if ( (info = vehicle_info_get(i, VEHICLE_ALIVE)) == NULL || info == vehicle_info ) { if ( info == vehicle_info && freeze[i].set ) cheat_vehicle_air_brake_set( 1 ); /* entered a frozen vehicle */ freeze[i].set = 0; continue; } if ( freeze[i].set ) { matrix_copy( freeze[i].matrix, info->base.matrix ); vect3_mult( info->speed, 0.0f, info->speed ); vect3_mult( info->spin, 0.0f, info->spin ); } if ( vehicle_contains_trailer(vehicle_info, info) ) { freeze[i].set = 0; continue; } if ( vect3_dist(pos, &info->base.matrix[4 * 3]) >= 80.0f ) { freeze[i].set = 0; continue; } if ( freeze[i].set ) { continue; } matrix_copy( info->base.matrix, freeze[i].matrix ); freeze[i].set = 1; } } }
void cheat_hook ( HWND wnd ) { traceLastFunc( "cheat_hook()" ); // get the time static uint64_t time_last; __time_current = __time_get(); g_timeDiff = TIME_TO_DOUBLE(time_get() - time_last); // for looping int i; // install keyhook keyhook_maybe_install( wnd ); // setup menu menu_maybe_init(); traceLastFunc( "cheat_hook()" ); /* initialize state */ if ( cheat_state == NULL ) { // set default cheat_state variables cheat_state = &__cheat_state; cheat_state->_generic.spoof_weapon = -1; cheat_state->_generic.money = set.money_enabled; cheat_state->_generic.weapon = set.weapon_enabled; cheat_state->_generic.vehicles_unlock = false; cheat_state->_generic.vehicles_warp_invert = true; cheat_state->actor.invulnerable = true; cheat_state->vehicle.invulnerable = true; cheat_state->vehicle.hp_tire_support = true; cheat_state->vehicle.hp_minimum_on = 1; cheat_state->vehicle.hp_regen_on = 1; cheat_state->actor.hp_regen_on = 1; cheat_state->vehicle.brkdance = 0; cheat_state->game_speed = 1.0f; cheat_state->vehicle.is_engine_on = 1; cheat_state->_generic.interior_patch_enabled = 0; // refreshes any cheat_state stuff set from the INI ini_load_setSettings(); /* install patches from the .ini file */ for ( i = 0; i < INI_PATCHES_MAX; i++ ) { if ( set.patch[i].name != NULL && set.patch[i].ini_auto ) patcher_install( &set.patch[i] ); } if ( g_dwSAMP_Addr != NULL ) { for ( i = 0; i < INI_SAMPPATCHES_MAX; i++ ) { if ( set.sampPatch[i].name != NULL && set.sampPatch[i].ini_auto ) patcher_install( &set.sampPatch[i] ); } } } /* end initialize state */ // set cheat state to "off" cheat_state->state = CHEAT_STATE_NONE; /* setup & refresh actor pool */ pool_actor = *(struct pool **)ACTOR_POOL_POINTER; if ( pool_actor == NULL || pool_actor->start == NULL || pool_actor->size <= 0 ) return; /* setup & refresh vehicle pool */ pool_vehicle = *(struct pool **)VEHICLE_POOL_POINTER; if ( pool_vehicle == NULL || pool_vehicle->start == NULL || pool_vehicle->size <= 0 ) return; ////////////////////////////////////////// // looks like we have pools so continue // struct actor_info *actor_info; struct vehicle_info *vehicle_info; actor_info = actor_info_get( ACTOR_SELF, ACTOR_ALIVE ); vehicle_info = vehicle_info_get( VEHICLE_SELF, 0 ); /* no vehicle, and no actor. exit. */ if ( vehicle_info == NULL && actor_info == NULL ) { if ( cheat_state->actor.air_brake || cheat_state->actor.stick || cheat_state->vehicle.air_brake || cheat_state->vehicle.stick ) { cheat_state->actor.air_brake = 0; cheat_vehicle_air_brake_set( 0 ); cheat_state->actor.stick = 0; cheat_state->vehicle.stick = 0; cheat_state_text( "Air brake / stick disabled" ); } } else { if ( vehicle_info == NULL ) { if ( cheat_state->vehicle.air_brake || cheat_state->vehicle.stick ) { cheat_vehicle_air_brake_set( 0 ); cheat_state->vehicle.stick = 0; cheat_state_text( "Air brake / stick disabled" ); } cheat_state->state = CHEAT_STATE_ACTOR; // reset infinite NOS toggle state if ( cheat_state->vehicle.infNOS_toggle_on ) { cheat_state->vehicle.infNOS_toggle_on = false; patcher_remove( &patch_vehicle_inf_NOS ); } } else { if ( cheat_state->actor.air_brake || cheat_state->actor.stick ) { cheat_state->actor.air_brake = 0; cheat_state->actor.stick = 0; cheat_state_text( "Air brake / stick disabled" ); } cheat_state->state = CHEAT_STATE_VEHICLE; } // post GTA initialization initizalization routines if ( m_InitStages == 0 ) { // setup CGame & friends pGameInterface = new CGameSA(); pPools = pGameInterface->GetPools(); //pGameInterface->Initialize(); // all this does so far is disable modshops and pay&sprays // this seems to fix SAMP's load hang bug //pGameInterface->StartGame(); // we have to add ourself to the pool first so that we are always the 1st ref // NEW --> use the global external: pPedSelf pPedSelf = pGameInterface->GetPools()->AddPed( (DWORD *)actor_info ); pPedSelfSA = pPedSelf->GetPedInterface(); // install all startup hooks cheat_hookers_installhooks(); // increment stage m_InitStages++; } else if ( m_InitStages == 1 ) { // load all the weapon models loadAllWeaponModels(); // get funky //pGameInterface->GetAudio()->PlayBeatTrack(2); // increment stage m_InitStages++; } } if ( cheat_state->state != CHEAT_STATE_NONE ) { // keep this updated, cos something is switching it now pPedSelf = pPools->GetPedFromRef( CPOOLS_PED_SELF_REF ); pPedSelfSA = pPedSelf->GetPedInterface(); } static bool chat_set_once = false; if ( !chat_set_once && set.d3dtext_chat ) { if ( g_Chat != NULL && g_Chat->iChatWindowMode ) { //Log("Disabling SA:MP chat text."); g_Chat->iChatWindowMode = 0; chat_set_once = true; } } // sets kill text to s0beit mode if enabled from INI static bool kill_set_once = false; if ( !kill_set_once && set.d3dtext_kill ) { if ( g_DeathList != NULL && g_DeathList->iEnabled ) { g_DeathList->iEnabled = 0; kill_set_once = true; } } // more random than random if ( rand() % 5000 == 0 ) srand( rand() + time_get() ); // OMGWTFBBQ?!? if ( cheat_panic() ) { cheat_state->state = CHEAT_STATE_NONE; goto out; } // menus are good menu_run(); // install volatile patches from the .ini file for ( i = 0; i < INI_PATCHES_MAX; i++ ) { if ( set.patch[i].name != NULL && set.patch[i].has_volatile && set.patch[i].installed ) patcher_install( &set.patch[i] ); } // generic stuff - these want to run even though we're dead cheat_handle_debug( wnd ); cheat_handle_misc(); cheat_handle_spoof_weapon(); cheat_handle_weapon(); gta_game_speed_set( cheat_state->game_speed ); cheat_main_display_debug_stuff(g_timeDiff); if ( cheat_state->state != CHEAT_STATE_NONE ) { // generic stuff cheat_handle_weapon_disable(); cheat_handle_money(); ////////////////////////////////////////////////////////////////// // this should be removed after reworking weapon cheat function // //if ( set.restore_weapons_after_death ) // * (uint8_t *)0x5E6320 = 0xC3; cheat_handle_unlock(); cheat_handle_checkpoint(); // do stuff :p if ( cheat_state->state == CHEAT_STATE_VEHICLE ) { cheat_main_vehicle( g_timeDiff ); } else if ( cheat_state->state == CHEAT_STATE_ACTOR ) { cheat_main_actor( g_timeDiff ); } if ( KEY_PRESSED(set.key_disable_Wall_Collisions) ) { cheat_state->_generic.nocols_walls_enabled ^= 1; if ( cheat_state->_generic.nocols_walls_enabled ) patcher_install( &patch_NoColsWalls ); else patcher_remove( &patch_NoColsWalls ); } for ( i = 0; i < INI_PATCHES_MAX; i++ ) { if ( set.patch[i].name != NULL && KEY_PRESSED(set.patch[i].ini_hotkey) ) { if ( set.patch[i].installed || set.patch[i].failed ) patcher_remove( &set.patch[i] ); else patcher_install( &set.patch[i] ); } } for ( i = 0; i < INI_SAMPPATCHES_MAX; i++ ) { if ( set.sampPatch[i].name != NULL && KEY_PRESSED(set.sampPatch[i].ini_hotkey) ) { if ( set.sampPatch[i].installed || set.sampPatch[i].failed ) patcher_remove( &set.sampPatch[i] ); else patcher_install( &set.sampPatch[i] ); } } if ( KEY_PRESSED(set.key_vehicle_jumper) ) { int iVehicleID = vehicle_find_nearest( VEHICLE_ALIVE + VEHICLE_NOTBURNING ); vehicleJumper( iVehicleID ); } if ( KEY_PRESSED(set.key_vehicle_occupied_jumper) ) { int iVehicleID = vehicle_find_nearest( VEHICLE_ALIVE + VEHICLE_NOTBURNING + VEHICLE_OCCUPIED ); vehicleJumper( iVehicleID ); } } // cheat_state->state != CHEAT_STATE_NONE // hack some SA:MP, shall we? if ( g_SAMP && g_renderSAMP_initSAMPstructs ) sampMainCheat(); out: ; if (gta_menu_active()) { keyhook_clear_states(); *(BYTE *)0xB7CB49 = 0; // game not paused even if we are in the menu. } else keyhook_run(); time_last = time_get(); }