2022-01-07 13:58:51 +01:00
|
|
|
#pragma once
|
|
|
|
#include "core/enums.hpp"
|
2022-01-18 02:06:28 +01:00
|
|
|
#include "globals.hpp"
|
2022-01-08 05:42:36 +01:00
|
|
|
#include "gta_util.hpp"
|
2022-01-07 13:58:51 +01:00
|
|
|
#include "misc.hpp"
|
2022-01-07 15:05:47 +01:00
|
|
|
#include "natives.hpp"
|
2022-01-18 02:06:28 +01:00
|
|
|
#include "notify.hpp"
|
2022-01-08 05:42:36 +01:00
|
|
|
#include "script.hpp"
|
|
|
|
#include "script_global.hpp"
|
|
|
|
#include "script_local.hpp"
|
2022-01-18 02:06:28 +01:00
|
|
|
#include "vehicle.hpp"
|
2022-01-07 13:58:51 +01:00
|
|
|
|
|
|
|
namespace big::mobile
|
|
|
|
{
|
2022-05-03 09:02:18 -04:00
|
|
|
inline auto player_global = script_global(2689224);
|
|
|
|
inline auto mechanic_global = script_global(2810701);
|
|
|
|
inline auto vehicle_global = script_global(1585853);
|
2022-01-07 15:05:47 +01:00
|
|
|
|
2022-01-08 05:42:36 +01:00
|
|
|
namespace util
|
|
|
|
{
|
|
|
|
int get_current_personal_vehicle(); // forward declare
|
|
|
|
inline void despawn_current_personal_vehicle()
|
|
|
|
{
|
|
|
|
misc::clear_bits(
|
|
|
|
vehicle_global.at(get_current_personal_vehicle(), 142).at(103).as<int*>(),
|
2022-01-11 19:09:25 +01:00
|
|
|
eVehicleFlags::TRIGGER_SPAWN_TOGGLE
|
2022-01-08 05:42:36 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int get_current_personal_vehicle()
|
|
|
|
{
|
|
|
|
return *script_global(2359296).at(0, 5559).at(675).at(2).as<int*>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-07 15:05:47 +01:00
|
|
|
namespace lester
|
2022-01-07 13:58:51 +01:00
|
|
|
{
|
2022-01-07 15:05:47 +01:00
|
|
|
inline void off_radar(bool toggle)
|
|
|
|
{
|
2022-05-04 19:16:40 +02:00
|
|
|
*player_global.at(PLAYER::GET_PLAYER_INDEX(), 451).at(207).as<int*>() = toggle;
|
2022-05-03 09:02:18 -04:00
|
|
|
*script_global(2703660).at(56).as<int*>() = NETWORK::GET_NETWORK_TIME() + 1;
|
2022-01-07 15:05:47 +01:00
|
|
|
}
|
|
|
|
}
|
2022-01-07 13:58:51 +01:00
|
|
|
|
2022-01-08 05:42:36 +01:00
|
|
|
namespace mors_mutual
|
|
|
|
{
|
2022-01-10 12:54:05 +01:00
|
|
|
inline bool fix_index(int veh_idx, bool spawn_veh = false)
|
|
|
|
{
|
|
|
|
bool can_be_fixed = misc::has_bits_set(
|
|
|
|
vehicle_global.at(veh_idx, 142).at(103).as<int*>(),
|
|
|
|
eVehicleFlags::DESTROYED | eVehicleFlags::HAS_INSURANCE
|
|
|
|
);
|
|
|
|
|
|
|
|
if (can_be_fixed)
|
|
|
|
{
|
|
|
|
misc::clear_bits(
|
|
|
|
vehicle_global.at(veh_idx, 142).at(103).as<int*>(),
|
|
|
|
eVehicleFlags::DESTROYED | eVehicleFlags::IMPOUNDED | eVehicleFlags::UNK2
|
|
|
|
);
|
|
|
|
|
|
|
|
if (spawn_veh)
|
|
|
|
{
|
|
|
|
misc::set_bits(
|
|
|
|
vehicle_global.at(veh_idx, 142).at(103).as<int*>(),
|
|
|
|
eVehicleFlags::TRIGGER_SPAWN_TOGGLE | eVehicleFlags::SPAWN_AT_MORS_MUTUAL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return can_be_fixed;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int fix_all()
|
|
|
|
{
|
|
|
|
int fixed_count = 0;
|
|
|
|
|
|
|
|
const int arr_size = *vehicle_global.as<int*>();
|
|
|
|
for (int i = 0; i < arr_size; i++)
|
2022-02-01 22:04:56 +01:00
|
|
|
if (fix_index(i, true))
|
2022-01-10 12:54:05 +01:00
|
|
|
fixed_count++;
|
|
|
|
|
|
|
|
return fixed_count;
|
|
|
|
}
|
2022-01-08 05:42:36 +01:00
|
|
|
}
|
2022-01-10 12:54:05 +01:00
|
|
|
|
2022-01-07 15:05:47 +01:00
|
|
|
namespace mechanic
|
|
|
|
{
|
2022-01-08 05:42:36 +01:00
|
|
|
inline void summon_vehicle_by_index(int veh_idx)
|
|
|
|
{
|
2022-01-18 02:06:28 +01:00
|
|
|
if (*mechanic_global.at(958).as<int*>() != -1)
|
2022-03-02 00:21:29 +01:00
|
|
|
return g_notification_service->push_warning("Vehicle", "Mechanic is not ready to deliver a vehicle right now.");
|
2022-01-18 02:06:28 +01:00
|
|
|
|
2022-01-22 00:06:43 +01:00
|
|
|
TASK::CLEAR_PED_TASKS_IMMEDIATELY(PLAYER::PLAYER_PED_ID());
|
|
|
|
|
2022-01-08 05:42:36 +01:00
|
|
|
// despawn current veh
|
|
|
|
util::despawn_current_personal_vehicle();
|
|
|
|
mors_mutual::fix_index(veh_idx);
|
2022-01-07 15:05:47 +01:00
|
|
|
|
2022-01-08 05:42:36 +01:00
|
|
|
script::get_current()->yield(100ms);
|
|
|
|
|
2022-01-26 17:27:55 +01:00
|
|
|
*mechanic_global.at(924).as<int*>() = 1; // disable vehicle node distance check
|
|
|
|
*mechanic_global.at(911).as<int*>() = 1; // tell freemode to spawn our vehicle
|
|
|
|
*mechanic_global.at(961).as<int*>() = 0; // required
|
2022-01-08 05:42:36 +01:00
|
|
|
*mechanic_global.at(958).as<int*>() = veh_idx;
|
|
|
|
|
|
|
|
script::get_current()->yield(100ms);
|
|
|
|
|
|
|
|
GtaThread* freemode_thread = gta_util::find_script_thread(RAGE_JOAAT("freemode"));
|
|
|
|
if (freemode_thread)
|
2022-05-03 18:00:09 +02:00
|
|
|
*script_local(freemode_thread, 18196).at(176).as<int*>() = 0; // spawn vehicle instantly
|
2022-01-18 02:06:28 +01:00
|
|
|
|
|
|
|
// blocking call till vehicle is delivered
|
|
|
|
notify::busy_spinner("Delivering vehicle...", mechanic_global.at(958).as<int*>(), -1);
|
|
|
|
|
2022-02-22 01:18:49 +01:00
|
|
|
if (g->vehicle.pv_teleport_into)
|
2022-05-07 18:27:59 -04:00
|
|
|
vehicle::bring(globals::get_personal_vehicle(), self::pos);
|
2022-01-08 05:42:36 +01:00
|
|
|
}
|
2022-01-07 15:05:47 +01:00
|
|
|
}
|
2022-01-07 13:58:51 +01:00
|
|
|
}
|