From 91fafca06494e58f83a46c90322c3fba615e15c3 Mon Sep 17 00:00:00 2001 From: Yimura Date: Wed, 19 May 2021 15:31:02 +0200 Subject: [PATCH] feat(Util): Added entity::cage_ped and entity::raycast --- BigBaseV2/src/util/entity.hpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/BigBaseV2/src/util/entity.hpp b/BigBaseV2/src/util/entity.hpp index 5d776744..f63bf2c2 100644 --- a/BigBaseV2/src/util/entity.hpp +++ b/BigBaseV2/src/util/entity.hpp @@ -1,9 +1,40 @@ #pragma once +#include "gta/joaat.hpp" #include "natives.hpp" #include "script.hpp" +#include "math.hpp" namespace big::entity { + 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); + } + + 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; + } + inline bool take_control_of(Entity ent) { if (NETWORK::NETWORK_HAS_CONTROL_OF_ENTITY(ent)) return true;