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
|
|
|
|
{
|
|
|
|
static Entity ent = 0;
|
|
|
|
static Vector3 location;
|
|
|
|
static Vector3 other;
|
|
|
|
static float dist;
|
|
|
|
|
|
|
|
static const int scroll = 0;
|
2022-05-23 06:38:45 +08:00
|
|
|
static const int controls[] = {
|
|
|
|
(int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT,
|
|
|
|
(int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV,
|
|
|
|
(int)ControllerInputs::INPUT_ATTACK
|
|
|
|
};
|
2021-05-19 15:31:35 +02:00
|
|
|
|
|
|
|
void looped::weapons_gravity_gun()
|
|
|
|
{
|
2022-02-22 01:18:49 +01:00
|
|
|
bool bGravityGun = g->weapons.custom_weapon == CustomWeapon::GRAVITY_GUN;
|
2021-05-19 15:31:35 +02:00
|
|
|
double multiplier = 3.0;
|
|
|
|
|
2021-05-26 14:24:49 +02:00
|
|
|
// ZOOMED IN
|
2022-05-23 06:38:45 +08:00
|
|
|
if (bGravityGun && PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
|
2021-05-19 15:31:35 +02:00
|
|
|
{
|
2022-05-23 06:38:45 +08:00
|
|
|
PLAYER::DISABLE_PLAYER_FIRING(self::id, true);
|
2021-05-26 14:24:49 +02:00
|
|
|
for (int control : controls)
|
|
|
|
PAD::DISABLE_CONTROL_ACTION(0, control, true);
|
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
|
|
|
|
2021-05-26 14:24:49 +02:00
|
|
|
// Attack RELEASED
|
2022-05-23 06:38:45 +08:00
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK) && ent == 0)
|
2021-05-26 14:24:49 +02:00
|
|
|
{
|
|
|
|
if (entity::raycast(&ent))
|
2021-05-19 15:31:35 +02:00
|
|
|
{
|
2021-05-26 14:24:49 +02:00
|
|
|
if (ENTITY::IS_ENTITY_A_PED(ent) && PED::IS_PED_A_PLAYER(ent))
|
|
|
|
{
|
|
|
|
ent = 0;
|
|
|
|
|
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
|
|
|
{
|
2021-05-26 14:24:49 +02:00
|
|
|
other = ENTITY::GET_ENTITY_COORDS(ent, true);
|
|
|
|
dist = (float)math::distance_between_vectors(location, other);
|
|
|
|
|
|
|
|
if (dist > 500)
|
2021-05-19 15:31:35 +02:00
|
|
|
{
|
|
|
|
ent = 0;
|
|
|
|
|
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
|
|
|
|
{
|
2022-01-07 17:00:42 +01:00
|
|
|
if (entity::take_control_of(ent) && ENTITY::IS_ENTITY_A_PED(ent) && !PED::IS_PED_RAGDOLL(ent))
|
|
|
|
{
|
|
|
|
TASK::SET_HIGH_FALL_TASK(ent, 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
|
|
|
}
|
2021-05-19 15:31:35 +02:00
|
|
|
}
|
|
|
|
}
|
2021-05-26 14:24:49 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ent = 0;
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2022-03-02 00:21:29 +01:00
|
|
|
g_notification_service->push_warning("Weapons", "No entity found.");
|
2021-05-19 15:31:35 +02:00
|
|
|
}
|
2021-05-26 14:24:49 +02:00
|
|
|
}
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2021-05-26 14:24:49 +02:00
|
|
|
if (ENTITY::DOES_ENTITY_EXIST(ent))
|
|
|
|
{
|
2022-05-23 06:38:45 +08:00
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT))
|
2021-05-26 14:24:49 +02:00
|
|
|
dist -= 5;
|
2022-05-23 06:38:45 +08:00
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV))
|
2021-05-26 14:24:49 +02:00
|
|
|
dist += 5;
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2022-01-08 14:09:00 +01:00
|
|
|
if (!entity::take_control_of(ent))
|
|
|
|
{
|
|
|
|
ent = 0;
|
|
|
|
|
2022-03-02 00:21:29 +01:00
|
|
|
return g_notification_service->push_warning("Weapons", "Failed to take control of entity.");
|
2022-01-08 14:09:00 +01:00
|
|
|
}
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2021-05-26 14:24:49 +02:00
|
|
|
ENTITY::SET_ENTITY_COLLISION(ent, false, false);
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2021-05-26 14:24:49 +02:00
|
|
|
other = ENTITY::GET_ENTITY_COORDS(ent, true);
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2021-05-26 14:24:49 +02:00
|
|
|
Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
|
|
|
float pitch = math::deg_to_rad(rot.x); // vertical
|
|
|
|
// float roll = rot.y;
|
|
|
|
float yaw = math::deg_to_rad(rot.z + 90); // horizontal
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2021-05-26 14:24:49 +02:00
|
|
|
Vector3 velocity;
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2021-05-26 14:24:49 +02:00
|
|
|
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;
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2021-05-26 14:24:49 +02:00
|
|
|
ENTITY::SET_ENTITY_VELOCITY(ent, velocity.x * (float)multiplier, velocity.y * (float)multiplier, velocity.z * (float)multiplier);
|
|
|
|
ENTITY::SET_ENTITY_ALPHA(ent, 105, 0);
|
2021-05-19 15:31:35 +02:00
|
|
|
}
|
2021-05-26 14:24:49 +02:00
|
|
|
}
|
|
|
|
else if (ent != 0 && entity::take_control_of(ent))
|
|
|
|
{
|
|
|
|
ENTITY::SET_ENTITY_COLLISION(ent, true, true);
|
|
|
|
ENTITY::RESET_ENTITY_ALPHA(ent);
|
2021-05-19 15:31:35 +02:00
|
|
|
|
2021-05-26 14:24:49 +02:00
|
|
|
ent = 0;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|