feat(Backend/looped): Added gravity gun
This commit is contained in:
parent
cde49f624a
commit
9e41d2a60f
@ -12,5 +12,10 @@ namespace big
|
|||||||
{
|
{
|
||||||
looped::self_noclip();
|
looped::self_noclip();
|
||||||
}QUEUE_JOB_END_CLAUSE
|
}QUEUE_JOB_END_CLAUSE
|
||||||
|
|
||||||
|
QUEUE_JOB_BEGIN_CLAUSE()
|
||||||
|
{
|
||||||
|
looped::weapons_gravity_gun();
|
||||||
|
}QUEUE_JOB_END_CLAUSE
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,5 +6,7 @@ namespace big
|
|||||||
class looped {
|
class looped {
|
||||||
public:
|
public:
|
||||||
static void self_noclip();
|
static void self_noclip();
|
||||||
|
|
||||||
|
static void weapons_gravity_gun();
|
||||||
};
|
};
|
||||||
}
|
}
|
117
BigBaseV2/src/backend/looped/weapons/gravity_gun.cpp
Normal file
117
BigBaseV2/src/backend/looped/weapons/gravity_gun.cpp
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
#include "backend/looped/looped.hpp"
|
||||||
|
#include "core/globals.hpp"
|
||||||
|
#include "util/entity.hpp"
|
||||||
|
#include "util/math.hpp"
|
||||||
|
#include "util/notify.hpp"
|
||||||
|
|
||||||
|
namespace big
|
||||||
|
{
|
||||||
|
static Entity ent = 0;
|
||||||
|
static Vector3 location;
|
||||||
|
static Vector3 other;
|
||||||
|
static float dist;
|
||||||
|
|
||||||
|
static const int scroll = 0;
|
||||||
|
static const int controls[] = { 14, 15, 24 };
|
||||||
|
|
||||||
|
void looped::weapons_gravity_gun()
|
||||||
|
{
|
||||||
|
bool bGravityGun = g.weapons.custom_weapon == 0;
|
||||||
|
double multiplier = 3.0;
|
||||||
|
|
||||||
|
if (bGravityGun)
|
||||||
|
{
|
||||||
|
Hash currWeapon;
|
||||||
|
WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(PLAYER::PLAYER_PED_ID()), &currWeapon, 1);
|
||||||
|
|
||||||
|
// ZOOMED IN
|
||||||
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25))
|
||||||
|
{
|
||||||
|
PLAYER::DISABLE_PLAYER_FIRING(PLAYER::PLAYER_ID(), true);
|
||||||
|
for (int control : controls)
|
||||||
|
PAD::DISABLE_CONTROL_ACTION(0, control, true);
|
||||||
|
|
||||||
|
location = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
|
||||||
|
|
||||||
|
// Attack RELEASED
|
||||||
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 24) && ent == 0)
|
||||||
|
{
|
||||||
|
if (entity::raycast(&ent))
|
||||||
|
{
|
||||||
|
if (ENTITY::IS_ENTITY_A_PED(ent) && PED::IS_PED_A_PLAYER(ent))
|
||||||
|
{
|
||||||
|
ent = 0;
|
||||||
|
|
||||||
|
notify::above_map("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;
|
||||||
|
|
||||||
|
notify::above_map("Entity is too far.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entity::take_control_of(ent);
|
||||||
|
|
||||||
|
if (ENTITY::IS_ENTITY_A_PED(ent) && !PED::IS_PED_RAGDOLL(ent)) TASK::SET_HIGH_FALL_TASK(ent, 0, 0, 0);
|
||||||
|
|
||||||
|
notify::above_map("Selected entity at crosshair.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ent = 0;
|
||||||
|
|
||||||
|
notify::above_map("No entity found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ENTITY::DOES_ENTITY_EXIST(ent))
|
||||||
|
{
|
||||||
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 14))
|
||||||
|
dist -= 5;
|
||||||
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 15))
|
||||||
|
dist += 5;
|
||||||
|
|
||||||
|
entity::take_control_of(ent);
|
||||||
|
|
||||||
|
ENTITY::SET_ENTITY_COLLISION(ent, false, false);
|
||||||
|
|
||||||
|
other = ENTITY::GET_ENTITY_COORDS(ent, true);
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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(ent, velocity.x * (float)multiplier, velocity.y * (float)multiplier, velocity.z * (float)multiplier);
|
||||||
|
ENTITY::SET_ENTITY_ALPHA(ent, 105, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ent != 0)
|
||||||
|
{
|
||||||
|
entity::take_control_of(ent);
|
||||||
|
|
||||||
|
ENTITY::SET_ENTITY_COLLISION(ent, true, true);
|
||||||
|
ENTITY::SET_ENTITY_ALPHA(ent, 255, 0);
|
||||||
|
|
||||||
|
ent = 0;
|
||||||
|
|
||||||
|
notify::above_map("Released entity.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user