feat(CustomWeapons): Added Cage and Delete guns

This commit is contained in:
Yimura 2021-05-20 18:57:53 +02:00
parent ab28148e87
commit b63bf4b0e4
7 changed files with 115 additions and 0 deletions

View File

@ -21,6 +21,8 @@ namespace big
QUEUE_JOB_BEGIN_CLAUSE()
{
looped::weapons_cage_gun();
looped::weapons_delete_gun();
looped::weapons_gravity_gun();
looped::weapons_repair_gun();
}QUEUE_JOB_END_CLAUSE

View File

@ -8,9 +8,11 @@ namespace big
static void self_godmode();
static void self_noclip();
static void weapons_cage_gun();
static void weapons_gravity_gun();
static void weapons_repair_gun();
static void vehicle_speedo_meter();
static void weapons_delete_gun();
};
}

View File

@ -0,0 +1,38 @@
#include "backend/looped/looped.hpp"
#include "core/enums.hpp"
#include "util/entity.hpp"
#include "util/notify.hpp"
namespace big
{
static const int controls[] = { 14, 15, 24 };
void looped::weapons_cage_gun()
{
bool bCageGun = g.weapons.custom_weapon == CustomWeapon::CAGE_GUN;
if (bCageGun)
{
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);
if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, 24))
{
Entity entity;
if (entity::raycast(&entity))
{
if (ENTITY::IS_ENTITY_A_PED(entity))
{
entity::cage_ped(entity);
}
}
else notify::above_map("No entity found.");
}
}
}
}
}

View File

@ -0,0 +1,58 @@
#include "backend/looped/looped.hpp"
#include "core/enums.hpp"
#include "util/entity.hpp"
#include "util/math.hpp"
#include "util/notify.hpp"
namespace big
{
static const int controls[] = { 14, 15, 24 };
void looped::weapons_delete_gun()
{
bool bCageGun = g.weapons.custom_weapon == CustomWeapon::DELETE_GUN;
if (bCageGun)
{
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);
if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, 24))
{
Entity entity;
if (entity::raycast(&entity))
{
if (ENTITY::IS_ENTITY_A_PED(entity) && PED::IS_PED_A_PLAYER(entity))
{
notify::above_map("You can't delete player entities!");
}
else
{
Vector3 player = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
Vector3 entLoc = ENTITY::GET_ENTITY_COORDS(entity, true);
double dist = math::distance_between_vectors(player, entLoc);
if (dist > 500)
{
notify::above_map("Entity is too far.");
}
else
{
if (entity::take_control_of(entity))
{
entity::delete_entity(entity);
}
else notify::above_map("~r~Failed to take control of entity.");
}
}
}
else notify::above_map("No entity found.");
}
}
}
}
}

View File

@ -8,6 +8,8 @@ struct custom_weapon {
const custom_weapon custom_weapons[] = {
{ big::CustomWeapon::NONE, "No weapon" },
{ big::CustomWeapon::CAGE_GUN, "Cage Gun" },
{ big::CustomWeapon::DELETE_GUN, "Delete Gun" },
{ big::CustomWeapon::GRAVITY_GUN, "Gravity Gun" },
{ big::CustomWeapon::REPAIR_GUN, "Repair Gun" }
};

View File

@ -5,6 +5,8 @@ namespace big
enum class CustomWeapon
{
NONE,
CAGE_GUN,
DELETE_GUN,
GRAVITY_GUN,
REPAIR_GUN
};

View File

@ -14,6 +14,17 @@ namespace big::entity
OBJECT::CREATE_OBJECT(hash, location.x, location.y, location.z - 1.f, true, false, false);
}
inline void delete_entity(Entity ent)
{
ENTITY::DETACH_ENTITY(ent, 1, 1);
ENTITY::SET_ENTITY_VISIBLE(ent, false, false);
NETWORK::_NETWORK_SET_ENTITY_INVISIBLE_TO_NETWORK(ent, true);
ENTITY::SET_ENTITY_COORDS_NO_OFFSET(ent, 0, 0, 0, 0, 0, 0);
ENTITY::SET_ENTITY_AS_MISSION_ENTITY(ent, 1, 1);
ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&ent);
ENTITY::DELETE_ENTITY(&ent);
}
inline bool raycast(Entity* ent)
{
BOOL hit;