mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
fix(vehicle): fix repair not working after going in water (#2996)
This commit is contained in:
parent
3b42b3aac1
commit
e97c057ae4
@ -10,18 +10,42 @@ namespace big
|
||||
|
||||
virtual void on_tick() override
|
||||
{
|
||||
auto veh = self::veh;
|
||||
const auto veh = self::veh;
|
||||
if (!ENTITY::IS_ENTITY_A_VEHICLE(veh) || !entity::take_control_of(veh, 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (VEHICLE::GET_DOES_VEHICLE_HAVE_DAMAGE_DECALS(veh))
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
if (!g.vehicle.keep_vehicle_clean)
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_DIRT_LEVEL(veh, 0.f);
|
||||
}
|
||||
|
||||
// Rear window
|
||||
constexpr int rear_window_index = 7;
|
||||
if (!VEHICLE::IS_VEHICLE_WINDOW_INTACT(veh, rear_window_index))
|
||||
{
|
||||
VEHICLE::FIX_VEHICLE_WINDOW(veh, rear_window_index);
|
||||
}
|
||||
|
||||
g_pointers->m_gta.m_decal_manager_remove(g_pointers->m_gta.m_decal_manager, g_pointers->m_gta.m_handle_to_ptr(veh), -1, 0, 0x00'01'E0'00);
|
||||
|
||||
if (!g.vehicle.god_mode)
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_DEFORMATION_FIXED(veh);
|
||||
}
|
||||
|
||||
vehicle::repair_engine_from_water(veh);
|
||||
|
||||
const auto door_count = VEHICLE::GET_NUMBER_OF_VEHICLE_DOORS(veh);
|
||||
for (int i = 0; i < door_count; i++)
|
||||
{
|
||||
if (VEHICLE::IS_VEHICLE_DOOR_DAMAGED(veh, i))
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_FIXED(veh);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,32 +54,19 @@ namespace big
|
||||
if (VEHICLE::DOES_EXTRA_EXIST(veh, i) && VEHICLE::IS_VEHICLE_EXTRA_TURNED_ON(veh, i) && VEHICLE::IS_EXTRA_BROKEN_OFF(veh, i))
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_FIXED(veh);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (VEHICLE::IS_VEHICLE_BUMPER_BOUNCING(veh, TRUE) || VEHICLE::IS_VEHICLE_BUMPER_BOUNCING(veh, FALSE) || VEHICLE::GET_VEHICLE_NUM_OF_BROKEN_LOOSEN_PARTS(veh) > 0)
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_FIXED(veh);
|
||||
}
|
||||
|
||||
if (!VEHICLE::IS_VEHICLE_WINDOW_INTACT(veh, 7)) //Rear window
|
||||
VEHICLE::FIX_VEHICLE_WINDOW(veh, 7);
|
||||
|
||||
g_pointers->m_gta.m_decal_manager_remove(g_pointers->m_gta.m_decal_manager, g_pointers->m_gta.m_handle_to_ptr(veh), -1, 0, 0x0001E000);
|
||||
|
||||
if (!g.vehicle.god_mode)
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_DEFORMATION_FIXED(veh);
|
||||
}
|
||||
|
||||
if (!g.vehicle.keep_vehicle_clean)
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_DIRT_LEVEL(veh, 0.f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
keep_vehicle_repaired g_keep_vehicle_repaired("keepfixed", "KEEP_VEHICLE_FIXED", "KEEP_VEHICLE_FIXED_DESC",
|
||||
g.vehicle.keep_vehicle_repaired);
|
||||
keep_vehicle_repaired
|
||||
g_keep_vehicle_repaired("keepfixed", "KEEP_VEHICLE_FIXED", "KEEP_VEHICLE_FIXED_DESC", g.vehicle.keep_vehicle_repaired);
|
||||
}
|
||||
|
@ -137,6 +137,13 @@ namespace big::vehicle
|
||||
return true;
|
||||
}
|
||||
|
||||
void repair_engine_from_water(Vehicle veh)
|
||||
{
|
||||
auto cvehicle = (uint8_t*)g_pointers->m_gta.m_handle_to_ptr(veh);
|
||||
// fix vehicle being completly fucked after going into water.
|
||||
cvehicle[0xD8] &= ~(1 << 0);
|
||||
}
|
||||
|
||||
bool repair(Vehicle veh)
|
||||
{
|
||||
if (!ENTITY::IS_ENTITY_A_VEHICLE(veh) || !entity::take_control_of(veh, 0))
|
||||
@ -144,6 +151,8 @@ namespace big::vehicle
|
||||
return false;
|
||||
}
|
||||
|
||||
repair_engine_from_water(veh);
|
||||
|
||||
VEHICLE::SET_VEHICLE_FIXED(veh);
|
||||
VEHICLE::SET_VEHICLE_DIRT_LEVEL(veh, 0.f);
|
||||
|
||||
|
@ -25,6 +25,7 @@ namespace big::vehicle
|
||||
void bring(Vehicle veh, Vector3 location, bool put_in = true, int seatIdx = -1);
|
||||
Vehicle get_closest_to_location(Vector3 location, float range);
|
||||
bool set_plate(Vehicle veh, const char* plate);
|
||||
void repair_engine_from_water(Vehicle veh);
|
||||
bool repair(Vehicle veh);
|
||||
Vehicle spawn(Hash hash, Vector3 location, float heading, bool is_networked = true, bool script_veh = false);
|
||||
Vehicle clone_from_vehicle_data(std::map<int, int32_t>& data, Vector3 location, float heading);
|
||||
@ -37,7 +38,7 @@ namespace big::vehicle
|
||||
void set_engine_state(Vehicle current_vehicle, bool state, bool immediately, bool disable_auto_start);
|
||||
void downgrade(Vehicle vehicle);
|
||||
bool remote_control_vehicle(Vehicle veh);
|
||||
|
||||
|
||||
/*
|
||||
Set doorId to eDoorId::VEH_EXT_DOOR_INVALID_ID or simply -1 to apply to all vehicle doors.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user