2021-05-19 14:35:05 +02:00
|
|
|
#pragma once
|
2021-05-19 15:31:02 +02:00
|
|
|
#include "gta/joaat.hpp"
|
2021-05-19 14:35:05 +02:00
|
|
|
#include "natives.hpp"
|
|
|
|
#include "script.hpp"
|
2021-05-19 15:31:02 +02:00
|
|
|
#include "math.hpp"
|
2021-05-19 14:35:05 +02:00
|
|
|
|
|
|
|
namespace big::entity
|
|
|
|
{
|
2021-05-19 15:31:02 +02:00
|
|
|
inline void cage_ped(Ped ped)
|
|
|
|
{
|
|
|
|
Hash hash = RAGE_JOAAT("prop_gold_cont_01");
|
|
|
|
|
|
|
|
Vector3 location = ENTITY::GET_ENTITY_COORDS(ped, true);
|
|
|
|
OBJECT::CREATE_OBJECT(hash, location.x, location.y, location.z - 1.f, true, false, false);
|
|
|
|
}
|
|
|
|
|
2021-05-20 18:57:53 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-05-19 15:31:02 +02:00
|
|
|
inline bool raycast(Entity* ent)
|
|
|
|
{
|
|
|
|
BOOL hit;
|
|
|
|
Vector3 endCoords;
|
|
|
|
Vector3 surfaceNormal;
|
|
|
|
|
|
|
|
Vector3 camCoords = CAM::GET_GAMEPLAY_CAM_COORD();
|
|
|
|
Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
|
|
|
Vector3 dir = math::rotation_to_direction(rot);
|
|
|
|
Vector3 farCoords;
|
|
|
|
|
|
|
|
farCoords.x = camCoords.x + dir.x * 1000;
|
|
|
|
farCoords.y = camCoords.y + dir.y * 1000;
|
|
|
|
farCoords.z = camCoords.z + dir.z * 1000;
|
|
|
|
|
|
|
|
int ray = SHAPETEST::_START_SHAPE_TEST_RAY(camCoords.x, camCoords.y, camCoords.z, farCoords.x, farCoords.y, farCoords.z, -1, 0, 7);
|
|
|
|
SHAPETEST::GET_SHAPE_TEST_RESULT(ray, &hit, &endCoords, &surfaceNormal, ent);
|
|
|
|
|
|
|
|
return (bool)hit;
|
|
|
|
}
|
|
|
|
|
2021-05-19 14:35:05 +02:00
|
|
|
inline bool take_control_of(Entity ent)
|
|
|
|
{
|
|
|
|
if (NETWORK::NETWORK_HAS_CONTROL_OF_ENTITY(ent)) return true;
|
|
|
|
for (uint8_t i = 0; !NETWORK::NETWORK_HAS_CONTROL_OF_ENTITY(ent) && i < 5; i++)
|
|
|
|
{
|
|
|
|
|
|
|
|
NETWORK::NETWORK_REQUEST_CONTROL_OF_ENTITY(ent);
|
|
|
|
|
|
|
|
script::get_current()->yield();
|
|
|
|
}
|
|
|
|
if (!NETWORK::NETWORK_HAS_CONTROL_OF_ENTITY(ent)) return false;
|
|
|
|
|
|
|
|
int netHandle = NETWORK::NETWORK_GET_NETWORK_ID_FROM_ENTITY(ent);
|
|
|
|
NETWORK::SET_NETWORK_ID_CAN_MIGRATE(netHandle, true);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|