Multi select for gravity gun (#690)
This commit is contained in:
parent
61f125901e
commit
bc9583b990
@ -6,81 +6,29 @@
|
|||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
static Entity ent = 0;
|
static std::vector<Entity> ents = { };
|
||||||
static Vector3 location;
|
static Vector3 location;
|
||||||
static Vector3 other;
|
static Vector3 other;
|
||||||
static float dist;
|
static float dist;
|
||||||
|
static constexpr double multiplier = 3.0;
|
||||||
|
|
||||||
static const int scroll = 0;
|
static const int scroll = 0;
|
||||||
|
|
||||||
void looped::weapons_gravity_gun()
|
void apply_velocity(Entity e)
|
||||||
{
|
{
|
||||||
bool is_gravity_gun_selected = g.weapons.custom_weapon == CustomWeapon::GRAVITY_GUN;
|
if (ENTITY::DOES_ENTITY_EXIST(e))
|
||||||
constexpr double multiplier = 3.0;
|
|
||||||
|
|
||||||
auto is_zoomed_in = is_gravity_gun_selected && PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM);
|
|
||||||
if (is_zoomed_in)
|
|
||||||
{
|
|
||||||
location = self::pos;
|
|
||||||
|
|
||||||
auto is_attack_released = PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK) && ent == 0;
|
|
||||||
if (is_attack_released)
|
|
||||||
{
|
|
||||||
if (entity::raycast(&ent))
|
|
||||||
{
|
|
||||||
if (ENTITY::IS_ENTITY_A_PED(ent) && PED::IS_PED_A_PLAYER(ent))
|
|
||||||
{
|
|
||||||
ent = 0;
|
|
||||||
|
|
||||||
g_notification_service->push_warning("Weapons", "You can't move player entities!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
other = ENTITY::GET_ENTITY_COORDS(ent, true);
|
|
||||||
dist = (float)math::distance_between_vectors(location, other);
|
|
||||||
|
|
||||||
if (dist > 500)
|
|
||||||
{
|
|
||||||
ent = 0;
|
|
||||||
|
|
||||||
g_notification_service->push_warning("Weapons", "Entity is too far.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
g_notification_service->push_warning("Weapons", "Selected entity at crosshair.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ent = 0;
|
|
||||||
|
|
||||||
g_notification_service->push_warning("Weapons", "No entity found.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ENTITY::DOES_ENTITY_EXIST(ent))
|
|
||||||
{
|
{
|
||||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT))
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT))
|
||||||
dist -= 5;
|
dist -= 5;
|
||||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV))
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV))
|
||||||
dist += 5;
|
dist += 5;
|
||||||
|
|
||||||
if (!entity::take_control_of(ent))
|
if (!entity::take_control_of(e))
|
||||||
{
|
return; // TODO: remove from vector
|
||||||
ent = 0;
|
|
||||||
|
|
||||||
return g_notification_service->push_warning("Weapons", "Failed to take control of entity.");
|
ENTITY::SET_ENTITY_COLLISION(e, false, false);
|
||||||
}
|
|
||||||
|
|
||||||
ENTITY::SET_ENTITY_COLLISION(ent, false, false);
|
other = ENTITY::GET_ENTITY_COORDS(e, true);
|
||||||
|
|
||||||
other = ENTITY::GET_ENTITY_COORDS(ent, true);
|
|
||||||
|
|
||||||
Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
||||||
float pitch = math::deg_to_rad(rot.x); // vertical
|
float pitch = math::deg_to_rad(rot.x); // vertical
|
||||||
@ -93,16 +41,85 @@ namespace big
|
|||||||
velocity.y = location.y + (dist * sin(yaw) * cos(pitch)) - other.y;
|
velocity.y = location.y + (dist * sin(yaw) * cos(pitch)) - other.y;
|
||||||
velocity.z = location.z + (dist * sin(pitch)) - other.z;
|
velocity.z = location.z + (dist * sin(pitch)) - other.z;
|
||||||
|
|
||||||
ENTITY::SET_ENTITY_VELOCITY(ent, velocity.x * (float)multiplier, velocity.y * (float)multiplier, velocity.z * (float)multiplier);
|
ENTITY::SET_ENTITY_VELOCITY(e, velocity.x * (float)multiplier, velocity.y * (float)multiplier, velocity.z * (float)multiplier);
|
||||||
ENTITY::SET_ENTITY_ALPHA(ent, 105, 0);
|
ENTITY::SET_ENTITY_ALPHA(e, 105, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ent != 0 && entity::take_control_of(ent))
|
|
||||||
{
|
|
||||||
ENTITY::SET_ENTITY_COLLISION(ent, true, true);
|
|
||||||
ENTITY::RESET_ENTITY_ALPHA(ent);
|
|
||||||
|
|
||||||
ent = 0;
|
void looped::weapons_gravity_gun()
|
||||||
|
{
|
||||||
|
bool is_gravity_gun_selected = g.weapons.custom_weapon == CustomWeapon::GRAVITY_GUN;
|
||||||
|
|
||||||
|
auto is_zoomed_in = is_gravity_gun_selected && PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM);
|
||||||
|
if (is_zoomed_in)
|
||||||
|
{
|
||||||
|
location = self::pos;
|
||||||
|
|
||||||
|
auto is_attack_just_pressed = PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK);
|
||||||
|
|
||||||
|
if (is_attack_just_pressed)
|
||||||
|
{
|
||||||
|
Entity ent_to_add;
|
||||||
|
|
||||||
|
if (entity::raycast(&ent_to_add))
|
||||||
|
{
|
||||||
|
if (ENTITY::IS_ENTITY_A_PED(ent_to_add) && PED::IS_PED_A_PLAYER(ent_to_add))
|
||||||
|
{
|
||||||
|
g_notification_service->push_warning("Weapons", "You can't move player entities!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
other = ENTITY::GET_ENTITY_COORDS(ent_to_add, true);
|
||||||
|
const int temp_dist = (float)math::distance_between_vectors(location, other);
|
||||||
|
|
||||||
|
if (ents.size() == 0)
|
||||||
|
{
|
||||||
|
dist = temp_dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (temp_dist > 500)
|
||||||
|
{
|
||||||
|
g_notification_service->push_warning("Weapons", "Entity is too far.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (entity::take_control_of(ent_to_add) && ENTITY::IS_ENTITY_A_PED(ent_to_add) && !PED::IS_PED_RAGDOLL(ent_to_add))
|
||||||
|
{
|
||||||
|
TASK::SET_HIGH_FALL_TASK(ent_to_add, 0, 0, 0);
|
||||||
|
|
||||||
|
g_notification_service->push_warning("Weapons", "Selected entity at crosshair.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ents.push_back(ent_to_add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ents.size() > 0)
|
||||||
|
{
|
||||||
|
for (const auto& e: ents)
|
||||||
|
{
|
||||||
|
apply_velocity(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ents.size() > 0)
|
||||||
|
{
|
||||||
|
for (const Entity& e: ents)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ents.clear();
|
||||||
|
|
||||||
g_notification_service->push("Weapons", "Released entity.");
|
g_notification_service->push("Weapons", "Released entity.");
|
||||||
}
|
}
|
||||||
|
@ -571,6 +571,12 @@ namespace big
|
|||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(ammo_special, toggle, type, explosion_tag)
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE(ammo_special, toggle, type, explosion_tag)
|
||||||
} ammo_special{};
|
} ammo_special{};
|
||||||
|
|
||||||
|
struct gravity_gun
|
||||||
|
{
|
||||||
|
bool launch_on_release = false;
|
||||||
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE(gravity_gun, launch_on_release)
|
||||||
|
} gravity_gun;
|
||||||
|
|
||||||
CustomWeapon custom_weapon = CustomWeapon::NONE;
|
CustomWeapon custom_weapon = CustomWeapon::NONE;
|
||||||
bool force_crosshairs = false;
|
bool force_crosshairs = false;
|
||||||
bool infinite_ammo = false;
|
bool infinite_ammo = false;
|
||||||
@ -584,7 +590,7 @@ namespace big
|
|||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(weapons,
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE(weapons,
|
||||||
ammo_special, custom_weapon, force_crosshairs, infinite_ammo, infinite_mag, increased_damage, no_recoil,
|
ammo_special, custom_weapon, force_crosshairs, infinite_ammo, infinite_mag, increased_damage, no_recoil,
|
||||||
no_spread, vehicle_gun_model, bypass_c4_limit, rapid_fire)
|
no_spread, vehicle_gun_model, bypass_c4_limit, rapid_fire, gravity_gun)
|
||||||
} weapons{};
|
} weapons{};
|
||||||
|
|
||||||
struct window
|
struct window
|
||||||
|
@ -135,6 +135,9 @@ namespace big
|
|||||||
|
|
||||||
switch (selected)
|
switch (selected)
|
||||||
{
|
{
|
||||||
|
case CustomWeapon::GRAVITY_GUN:
|
||||||
|
ImGui::Checkbox("Launch on release", &g.weapons.gravity_gun.launch_on_release);
|
||||||
|
break;
|
||||||
case CustomWeapon::VEHICLE_GUN:
|
case CustomWeapon::VEHICLE_GUN:
|
||||||
// this some ugly ass looking code
|
// this some ugly ass looking code
|
||||||
static char vehicle_gun[12];
|
static char vehicle_gun[12];
|
||||||
|
Reference in New Issue
Block a user