116 lines
3.1 KiB
C++
116 lines
3.1 KiB
C++
#include "features/custom_guns.hpp"
|
|
#include "features/notify.hpp"
|
|
|
|
namespace big
|
|
{
|
|
static Entity entity = 0;
|
|
static Vector3 location;
|
|
static Vector3 other;
|
|
static float dist;
|
|
|
|
static const int scroll = 2;
|
|
static const int controls[] = { 14, 15, 24 };
|
|
|
|
void custom_guns::gravity_gun()
|
|
{
|
|
bool bGravityGun = g_settings.options["custom_gun"]["type"] == 2;
|
|
double multiplier = g_settings.options["custom_gun"]["gravity_velocity_multiplier"];
|
|
|
|
if (bGravityGun)
|
|
{
|
|
Hash currWeapon;
|
|
WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id), &currWeapon, 1);
|
|
|
|
if (currWeapon != RAGE_JOAAT("weapon_pistol") && currWeapon != RAGE_JOAAT("weapon_pistol_mk2")) return;
|
|
|
|
// ZOOMED IN
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25))
|
|
{
|
|
PLAYER::DISABLE_PLAYER_FIRING(g_player.id, true);
|
|
for (int control : controls)
|
|
PAD::DISABLE_CONTROL_ACTION(0, control, true);
|
|
|
|
location = ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id), true);
|
|
|
|
// Attack RELEASED
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 24) && entity == 0)
|
|
{
|
|
if (func::raycast_entity(&entity))
|
|
{
|
|
if (ENTITY::IS_ENTITY_A_PED(entity) && PED::IS_PED_A_PLAYER(entity))
|
|
{
|
|
entity = 0;
|
|
|
|
notify::above_map("You can't move player entities!");
|
|
}
|
|
else
|
|
{
|
|
other = ENTITY::GET_ENTITY_COORDS(entity, true);
|
|
dist = (float)func::distance_between_vectors(location, other);
|
|
|
|
if (dist > 500)
|
|
{
|
|
entity = 0;
|
|
|
|
notify::above_map("Entity is too far.");
|
|
}
|
|
else
|
|
{
|
|
func::take_control_of_entity(entity);
|
|
|
|
if (ENTITY::IS_ENTITY_A_PED(entity) && !PED::IS_PED_RAGDOLL(entity)) TASK::SET_HIGH_FALL_TASK(entity, 0, 0, 0);
|
|
|
|
notify::above_map("Selected entity at crosshair.");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
entity = 0;
|
|
|
|
notify::above_map("No entity found.");
|
|
}
|
|
}
|
|
|
|
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;
|
|
|
|
func::take_control_of_entity(entity);
|
|
|
|
ENTITY::SET_ENTITY_COLLISION(entity, false, false);
|
|
|
|
other = ENTITY::GET_ENTITY_COORDS(entity, true);
|
|
|
|
Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
|
float pitch = func::deg_to_rad(rot.x); // vertical
|
|
// float roll = rot.y;
|
|
float yaw = func::deg_to_rad(rot.z + 90); // horizontal
|
|
|
|
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(entity, velocity.x * (float)multiplier, velocity.y * (float)multiplier, velocity.z * (float)multiplier);
|
|
ENTITY::SET_ENTITY_ALPHA(entity, 105, 0);
|
|
}
|
|
}
|
|
else if (entity != 0)
|
|
{
|
|
func::take_control_of_entity(entity);
|
|
|
|
ENTITY::SET_ENTITY_COLLISION(entity, true, true);
|
|
ENTITY::SET_ENTITY_ALPHA(entity, 255, 0);
|
|
|
|
entity = 0;
|
|
|
|
notify::above_map("Released entity.");
|
|
}
|
|
}
|
|
}
|
|
} |