2021-05-19 15:31:35 +02:00
|
|
|
#include "backend/looped/looped.hpp"
|
2021-05-19 16:05:21 +02:00
|
|
|
#include "core/enums.hpp"
|
2022-05-23 06:38:45 +08:00
|
|
|
#include "gta/enums.hpp"
|
2021-05-19 15:31:35 +02:00
|
|
|
#include "util/entity.hpp"
|
|
|
|
#include "util/math.hpp"
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2023-03-01 21:27:15 +00:00
|
|
|
static std::vector<Entity> ents = {};
|
2021-05-19 15:31:35 +02:00
|
|
|
static Vector3 location;
|
|
|
|
static Vector3 other;
|
|
|
|
static float dist;
|
2023-01-16 22:16:06 +01:00
|
|
|
static constexpr double multiplier = 3.0;
|
2021-05-19 15:31:35 +02:00
|
|
|
|
|
|
|
static const int scroll = 0;
|
|
|
|
|
2023-01-16 22:16:06 +01:00
|
|
|
void apply_velocity(Entity e)
|
|
|
|
{
|
|
|
|
if (ENTITY::DOES_ENTITY_EXIST(e))
|
|
|
|
{
|
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT))
|
|
|
|
dist -= 5;
|
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV))
|
|
|
|
dist += 5;
|
|
|
|
|
|
|
|
if (!entity::take_control_of(e))
|
2023-04-15 17:17:43 -04:00
|
|
|
return; // TODO: remove from vector
|
2023-01-16 22:16:06 +01:00
|
|
|
|
|
|
|
ENTITY::SET_ENTITY_COLLISION(e, false, false);
|
|
|
|
|
|
|
|
other = ENTITY::GET_ENTITY_COORDS(e, true);
|
|
|
|
|
|
|
|
Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
2023-04-15 17:17:43 -04:00
|
|
|
float pitch = math::deg_to_rad(rot.x); // vertical
|
2023-01-16 22:16:06 +01:00
|
|
|
// float roll = rot.y;
|
2023-04-15 17:17:43 -04:00
|
|
|
float yaw = math::deg_to_rad(rot.z + 90); // horizontal
|
2023-01-16 22:16:06 +01:00
|
|
|
|
|
|
|
Vector3 velocity;
|
|
|
|
|
|
|
|
velocity.x = location.x + (dist * cos(pitch) * cos(yaw)) - other.x;
|
|
|
|
velocity.y = location.y + (dist * sin(yaw) * cos(pitch)) - other.y;
|
|
|
|
velocity.z = location.z + (dist * sin(pitch)) - other.z;
|
|
|
|
|
|
|
|
ENTITY::SET_ENTITY_VELOCITY(e, velocity.x * (float)multiplier, velocity.y * (float)multiplier, velocity.z * (float)multiplier);
|
|
|
|
ENTITY::SET_ENTITY_ALPHA(e, 105, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 15:31:35 +02:00
|
|
|
void looped::weapons_gravity_gun()
|
|
|
|
{
|
2022-12-18 23:15:52 +01:00
|
|
|
bool is_gravity_gun_selected = g.weapons.custom_weapon == CustomWeapon::GRAVITY_GUN;
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2022-06-25 21:17:35 +02:00
|
|
|
auto is_zoomed_in = is_gravity_gun_selected && PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM);
|
2023-04-15 17:17:43 -04:00
|
|
|
if (is_zoomed_in && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
|
2021-05-19 15:31:35 +02:00
|
|
|
{
|
2022-05-23 06:38:45 +08:00
|
|
|
location = self::pos;
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2023-01-16 22:16:06 +01:00
|
|
|
auto is_attack_just_pressed = PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK);
|
|
|
|
|
|
|
|
if (is_attack_just_pressed)
|
2021-05-26 14:24:49 +02:00
|
|
|
{
|
2023-01-16 22:16:06 +01:00
|
|
|
Entity ent_to_add;
|
|
|
|
|
|
|
|
if (entity::raycast(&ent_to_add))
|
2021-05-19 15:31:35 +02:00
|
|
|
{
|
2023-01-16 22:16:06 +01:00
|
|
|
if (ENTITY::IS_ENTITY_A_PED(ent_to_add) && PED::IS_PED_A_PLAYER(ent_to_add))
|
2021-05-26 14:24:49 +02:00
|
|
|
{
|
2022-03-02 00:21:29 +01:00
|
|
|
g_notification_service->push_warning("Weapons", "You can't move player entities!");
|
2021-05-26 14:24:49 +02:00
|
|
|
}
|
|
|
|
else
|
2021-05-19 15:31:35 +02:00
|
|
|
{
|
2023-03-01 21:27:15 +00:00
|
|
|
other = ENTITY::GET_ENTITY_COORDS(ent_to_add, true);
|
2023-01-16 22:16:06 +01:00
|
|
|
const int temp_dist = (float)math::distance_between_vectors(location, other);
|
2021-05-26 14:24:49 +02:00
|
|
|
|
2023-01-16 22:16:06 +01:00
|
|
|
if (ents.size() == 0)
|
2021-05-19 15:31:35 +02:00
|
|
|
{
|
2023-01-16 22:16:06 +01:00
|
|
|
dist = temp_dist;
|
|
|
|
}
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2023-01-16 22:16:06 +01:00
|
|
|
if (temp_dist > 500)
|
|
|
|
{
|
2022-03-02 00:21:29 +01:00
|
|
|
g_notification_service->push_warning("Weapons", "Entity is too far.");
|
2021-05-19 15:31:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-16 22:16:06 +01:00
|
|
|
if (entity::take_control_of(ent_to_add) && ENTITY::IS_ENTITY_A_PED(ent_to_add) && !PED::IS_PED_RAGDOLL(ent_to_add))
|
2022-01-07 17:00:42 +01:00
|
|
|
{
|
2023-01-16 22:16:06 +01:00
|
|
|
TASK::SET_HIGH_FALL_TASK(ent_to_add, 0, 0, 0);
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2022-03-02 00:21:29 +01:00
|
|
|
g_notification_service->push_warning("Weapons", "Selected entity at crosshair.");
|
2022-01-07 17:00:42 +01:00
|
|
|
}
|
2023-03-01 21:27:15 +00:00
|
|
|
|
2023-01-16 22:16:06 +01:00
|
|
|
ents.push_back(ent_to_add);
|
2021-05-19 15:31:35 +02:00
|
|
|
}
|
|
|
|
}
|
2021-05-26 14:24:49 +02:00
|
|
|
}
|
|
|
|
}
|
2023-01-16 22:16:06 +01:00
|
|
|
if (ents.size() > 0)
|
2021-05-26 14:24:49 +02:00
|
|
|
{
|
2023-03-01 21:27:15 +00:00
|
|
|
for (const auto& e : ents)
|
2022-01-08 14:09:00 +01:00
|
|
|
{
|
2023-01-16 22:16:06 +01:00
|
|
|
apply_velocity(e);
|
2022-01-08 14:09:00 +01:00
|
|
|
}
|
2021-05-19 15:31:35 +02:00
|
|
|
}
|
2021-05-26 14:24:49 +02:00
|
|
|
}
|
2023-01-16 22:16:06 +01:00
|
|
|
else if (ents.size() > 0)
|
2021-05-26 14:24:49 +02:00
|
|
|
{
|
2023-03-01 21:27:15 +00:00
|
|
|
for (const Entity& e : ents)
|
2023-01-16 22:16:06 +01:00
|
|
|
{
|
|
|
|
if (entity::take_control_of(e))
|
|
|
|
{
|
|
|
|
if (g.weapons.gravity_gun.launch_on_release)
|
|
|
|
{
|
|
|
|
dist += 100;
|
|
|
|
apply_velocity(e);
|
|
|
|
}
|
|
|
|
ENTITY::SET_ENTITY_COLLISION(e, true, true);
|
|
|
|
ENTITY::RESET_ENTITY_ALPHA(e);
|
|
|
|
}
|
|
|
|
}
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2023-01-16 22:16:06 +01:00
|
|
|
ents.clear();
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2022-03-02 00:21:29 +01:00
|
|
|
g_notification_service->push("Weapons", "Released entity.");
|
2021-05-19 15:31:35 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-25 21:17:35 +02:00
|
|
|
}
|