This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/BigBaseV2/src/features/looped/gravity_gun.cpp

115 lines
2.9 KiB
C++

#include "features.hpp"
namespace big
{
static Entity entity = 0;
static Vector3 location;
static Vector3 other;
static double dist;
static const int scroll = 2;
static const int controls[] = { 14, 15, 24 };
void features::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_playerId), &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_playerId, true);
for (int control : controls)
PAD::DISABLE_CONTROL_ACTION(0, control, true);
location = ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId), true);
// Attack RELEASED
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 24) && entity == 0)
{
if (functions::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 = functions::distance_between_vectors(location, other);
if (dist > 50)
{
entity = 0;
notify::above_map("Entity is too far.");
}
else
{
functions::take_control_of_entity(entity);
features::notify::above_map("Selected entity at crosshair.");
}
}
}
else
{
entity = 0;
features::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;
functions::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 = functions::deg_to_rad(rot.x); // vertical
// float roll = rot.y;
float yaw = functions::deg_to_rad(rot.z + 90); // horizontal
Vector3 zRot;
zRot.x = location.x + (dist * cos(pitch) * cos(yaw));
zRot.y = location.y + (dist * sin(yaw) * cos(pitch));
zRot.z = location.z + (dist * sin(pitch));
ENTITY::SET_ENTITY_VELOCITY(entity, (zRot.x - other.x) * multiplier, (zRot.y - other.y) * multiplier, (zRot.z - other.z) * multiplier);
}
}
else if (entity != 0)
{
ENTITY::SET_ENTITY_COLLISION(entity, true, true);
entity = 0;
features::notify::above_map("Released entity.");
}
}
}
float deg_to_rad(float deg)
{
double radian = (3.14159265359 / 180) * deg;
return (float)radian;
}
}