feat(Vehicle): Added keep engine running functionality (#1426)
This commit is contained in:
parent
2beb4d7f20
commit
5848599c60
@ -6,9 +6,9 @@
|
||||
#include "script_patches.hpp"
|
||||
#include "services/context_menu/context_menu_service.hpp"
|
||||
#include "services/orbital_drone/orbital_drone.hpp"
|
||||
#include "services/squad_spawner/squad_spawner.hpp"
|
||||
#include "services/tunables/tunables_service.hpp"
|
||||
#include "services/vehicle/vehicle_control_service.hpp"
|
||||
#include "services/squad_spawner/squad_spawner.hpp"
|
||||
#include "thread_pool.hpp"
|
||||
|
||||
|
||||
@ -203,7 +203,7 @@ namespace big
|
||||
while (true)
|
||||
{
|
||||
g_squad_spawner_service.tick();
|
||||
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
29
src/backend/looped/vehicle/keep_engine_running.cpp
Normal file
29
src/backend/looped/vehicle/keep_engine_running.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "backend/looped_command.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
class keep_engine_running : looped_command
|
||||
{
|
||||
using looped_command::looped_command;
|
||||
|
||||
virtual void on_tick() override
|
||||
{
|
||||
if (ENTITY::DOES_ENTITY_EXIST(self::veh) && !VEHICLE::GET_IS_VEHICLE_ENGINE_RUNNING(self::veh))
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_KEEP_ENGINE_ON_WHEN_ABANDONED(self::veh, true);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void on_disable() override
|
||||
{
|
||||
if (ENTITY::DOES_ENTITY_EXIST(self::veh) && VEHICLE::GET_IS_VEHICLE_ENGINE_RUNNING(self::veh))
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_KEEP_ENGINE_ON_WHEN_ABANDONED(self::veh, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
keep_engine_running g_keep_engine_running("keepengine", "Keep Engine Running", "Keeps the engine running when you exit the vehicle",
|
||||
g.vehicle.keep_engine_running);
|
||||
}
|
@ -641,6 +641,7 @@ namespace big
|
||||
bool no_water_collision = false;
|
||||
bool disable_engine_auto_start = false;
|
||||
bool change_engine_state_immediately = false;
|
||||
bool keep_engine_running = false;
|
||||
bool vehinvisibility = false;
|
||||
bool localveh_visibility = false;
|
||||
bool localped_visibility = true;
|
||||
@ -649,7 +650,7 @@ namespace big
|
||||
bool unlimited_weapons = false;
|
||||
bool siren_mute = false;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(vehicle, speedo_meter, fly, rainbow_paint, speed_unit, god_mode, proof_bullet, proof_fire, proof_collision, proof_melee, proof_explosion, proof_steam, proof_water, proof_mask, auto_drive_destination, auto_drive_style, auto_drive_speed, auto_turn_signals, boost_behavior, drive_on_water, horn_boost, instant_brake, block_homing, seatbelt, turn_signals, vehicle_jump, keep_vehicle_repaired, no_water_collision, disable_engine_auto_start, change_engine_state_immediately, vehinvisibility, localveh_visibility, localped_visibility, keep_on_ground, no_collision, unlimited_weapons, siren_mute)
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(vehicle, speedo_meter, fly, rainbow_paint, speed_unit, god_mode, proof_bullet, proof_fire, proof_collision, proof_melee, proof_explosion, proof_steam, proof_water, proof_mask, auto_drive_destination, auto_drive_style, auto_drive_speed, auto_turn_signals, boost_behavior, drive_on_water, horn_boost, instant_brake, block_homing, seatbelt, turn_signals, vehicle_jump, keep_vehicle_repaired, no_water_collision, disable_engine_auto_start, change_engine_state_immediately, keep_engine_running, vehinvisibility, localveh_visibility, localped_visibility, keep_on_ground, no_collision, unlimited_weapons, siren_mute)
|
||||
} vehicle{};
|
||||
|
||||
struct weapons
|
||||
|
@ -48,7 +48,7 @@ namespace big::vehicle
|
||||
{
|
||||
Vector3 min, max, result;
|
||||
MISC::GET_MODEL_DIMENSIONS(hash, &min, &max);
|
||||
result = max - min;
|
||||
result = max - min;
|
||||
y_offset = result.y;
|
||||
}
|
||||
else if (!spawn_inside)
|
||||
@ -613,15 +613,15 @@ namespace big::vehicle
|
||||
|
||||
inline void max_vehicle_performance(Vehicle veh)
|
||||
{
|
||||
if(entity::take_control_of(veh))
|
||||
if (entity::take_control_of(veh))
|
||||
{
|
||||
VehicleModType perfomance_mods[] = {MOD_ENGINE, MOD_BRAKES, MOD_TRANSMISSION, MOD_SUSPENSION, MOD_ARMOR, MOD_NITROUS, MOD_TURBO};
|
||||
VEHICLE::SET_VEHICLE_MOD_KIT(veh, 0);
|
||||
|
||||
for(auto mod_slot : perfomance_mods)
|
||||
for (auto mod_slot : perfomance_mods)
|
||||
{
|
||||
if(mod_slot != MOD_NITROUS && mod_slot != MOD_TURBO)
|
||||
VEHICLE::SET_VEHICLE_MOD(veh, mod_slot, VEHICLE::GET_NUM_VEHICLE_MODS(veh, mod_slot) -1, true);
|
||||
if (mod_slot != MOD_NITROUS && mod_slot != MOD_TURBO)
|
||||
VEHICLE::SET_VEHICLE_MOD(veh, mod_slot, VEHICLE::GET_NUM_VEHICLE_MODS(veh, mod_slot) - 1, true);
|
||||
else
|
||||
VEHICLE::TOGGLE_VEHICLE_MOD(veh, mod_slot, true);
|
||||
}
|
||||
|
@ -52,6 +52,8 @@ namespace big
|
||||
ImGui::Checkbox("DISABLE_ENGINE_AUTO_START"_T.data(), &g.vehicle.disable_engine_auto_start);
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox("CHANGE_STATE_IMMEDIATELY"_T.data(), &g.vehicle.change_engine_state_immediately);
|
||||
ImGui::SameLine();
|
||||
components::command_checkbox<"keepengine">();
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
|
Reference in New Issue
Block a user