2021-02-05 02:38:56 +01:00
|
|
|
#include "features/custom_guns.hpp"
|
|
|
|
#include "features/notify.hpp"
|
2021-01-13 15:36:13 +01:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2021-01-14 22:18:49 +01:00
|
|
|
static Entity entity = 0;
|
2021-01-13 15:36:13 +01:00
|
|
|
static Vector3 location;
|
|
|
|
static Vector3 other;
|
2021-01-17 23:20:00 +01:00
|
|
|
static float dist;
|
2021-01-13 15:36:13 +01:00
|
|
|
|
|
|
|
static const int scroll = 2;
|
|
|
|
static const int controls[] = { 14, 15, 24 };
|
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
void custom_guns::gravity_gun()
|
2021-01-13 15:36:13 +01:00
|
|
|
{
|
2021-01-14 22:18:49 +01:00
|
|
|
bool bGravityGun = g_settings.options["custom_gun"]["type"] == 2;
|
|
|
|
double multiplier = g_settings.options["custom_gun"]["gravity_velocity_multiplier"];
|
2021-01-13 15:36:13 +01:00
|
|
|
|
2021-01-14 22:18:49 +01:00
|
|
|
if (bGravityGun)
|
2021-01-13 15:36:13 +01:00
|
|
|
{
|
2021-01-14 22:18:49 +01:00
|
|
|
Hash currWeapon;
|
2021-02-05 02:38:56 +01:00
|
|
|
WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id), &currWeapon, 1);
|
2021-01-14 22:18:49 +01:00
|
|
|
|
|
|
|
if (currWeapon != RAGE_JOAAT("weapon_pistol") && currWeapon != RAGE_JOAAT("weapon_pistol_mk2")) return;
|
|
|
|
|
2021-01-13 15:36:13 +01:00
|
|
|
// ZOOMED IN
|
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25))
|
|
|
|
{
|
2021-02-05 02:38:56 +01:00
|
|
|
PLAYER::DISABLE_PLAYER_FIRING(g_player.id, true);
|
2021-01-13 15:36:13 +01:00
|
|
|
for (int control : controls)
|
|
|
|
PAD::DISABLE_CONTROL_ACTION(0, control, true);
|
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
location = ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id), true);
|
2021-01-13 15:36:13 +01:00
|
|
|
|
|
|
|
// Attack RELEASED
|
2021-01-14 22:18:49 +01:00
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 24) && entity == 0)
|
2021-01-13 15:36:13 +01:00
|
|
|
{
|
2021-02-04 22:57:06 +01:00
|
|
|
if (func::raycast_entity(&entity))
|
2021-01-13 15:36:13 +01:00
|
|
|
{
|
2021-01-14 22:18:49 +01:00
|
|
|
if (ENTITY::IS_ENTITY_A_PED(entity) && PED::IS_PED_A_PLAYER(entity))
|
2021-01-13 15:36:13 +01:00
|
|
|
{
|
2021-01-13 16:55:49 +01:00
|
|
|
entity = 0;
|
2021-01-13 15:36:13 +01:00
|
|
|
|
2021-01-14 22:18:49 +01:00
|
|
|
notify::above_map("You can't move player entities!");
|
2021-01-13 15:36:13 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-14 22:18:49 +01:00
|
|
|
other = ENTITY::GET_ENTITY_COORDS(entity, true);
|
2021-02-04 22:57:06 +01:00
|
|
|
dist = (float)func::distance_between_vectors(location, other);
|
2021-01-14 22:18:49 +01:00
|
|
|
|
2021-02-03 16:38:00 +01:00
|
|
|
if (dist > 500)
|
2021-01-14 22:18:49 +01:00
|
|
|
{
|
|
|
|
entity = 0;
|
|
|
|
|
|
|
|
notify::above_map("Entity is too far.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-04 22:57:06 +01:00
|
|
|
func::take_control_of_entity(entity);
|
2021-01-13 15:36:13 +01:00
|
|
|
|
2021-02-03 21:34:46 +01:00
|
|
|
if (ENTITY::IS_ENTITY_A_PED(entity) && !PED::IS_PED_RAGDOLL(entity)) TASK::SET_HIGH_FALL_TASK(entity, 0, 0, 0);
|
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
notify::above_map("Selected entity at crosshair.");
|
2021-01-14 22:18:49 +01:00
|
|
|
}
|
2021-01-13 15:36:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-13 16:55:49 +01:00
|
|
|
entity = 0;
|
2021-01-13 15:36:13 +01:00
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
notify::above_map("No entity found.");
|
2021-01-13 15:36:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ENTITY::DOES_ENTITY_EXIST(entity))
|
|
|
|
{
|
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 14))
|
|
|
|
dist -= 5;
|
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 15))
|
|
|
|
dist += 5;
|
|
|
|
|
2021-02-04 22:57:06 +01:00
|
|
|
func::take_control_of_entity(entity);
|
2021-01-13 15:36:13 +01:00
|
|
|
|
|
|
|
ENTITY::SET_ENTITY_COLLISION(entity, false, false);
|
|
|
|
|
|
|
|
other = ENTITY::GET_ENTITY_COORDS(entity, true);
|
|
|
|
|
|
|
|
Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
2021-02-04 22:57:06 +01:00
|
|
|
float pitch = func::deg_to_rad(rot.x); // vertical
|
2021-01-13 15:36:13 +01:00
|
|
|
// float roll = rot.y;
|
2021-02-04 22:57:06 +01:00
|
|
|
float yaw = func::deg_to_rad(rot.z + 90); // horizontal
|
2021-01-13 15:36:13 +01:00
|
|
|
|
2021-01-15 02:38:38 +01:00
|
|
|
Vector3 velocity;
|
2021-01-13 15:36:13 +01:00
|
|
|
|
2021-01-15 02:38:38 +01: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-01-13 15:36:13 +01:00
|
|
|
|
2021-01-17 23:20:00 +01:00
|
|
|
ENTITY::SET_ENTITY_VELOCITY(entity, velocity.x * (float)multiplier, velocity.y * (float)multiplier, velocity.z * (float)multiplier);
|
2021-01-22 02:07:44 +01:00
|
|
|
ENTITY::SET_ENTITY_ALPHA(entity, 105, 0);
|
2021-01-13 15:36:13 +01:00
|
|
|
}
|
|
|
|
}
|
2021-01-14 22:18:49 +01:00
|
|
|
else if (entity != 0)
|
2021-01-13 15:36:13 +01:00
|
|
|
{
|
2021-02-04 22:57:06 +01:00
|
|
|
func::take_control_of_entity(entity);
|
2021-01-29 18:54:36 +01:00
|
|
|
|
2021-01-13 15:36:13 +01:00
|
|
|
ENTITY::SET_ENTITY_COLLISION(entity, true, true);
|
2021-01-22 02:07:44 +01:00
|
|
|
ENTITY::SET_ENTITY_ALPHA(entity, 255, 0);
|
2021-01-13 15:36:13 +01:00
|
|
|
|
2021-01-14 22:18:49 +01:00
|
|
|
entity = 0;
|
2021-01-13 15:36:13 +01:00
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
notify::above_map("Released entity.");
|
2021-01-13 15:36:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|