2022-03-08 12:52:00 -05:00
|
|
|
#pragma once
|
2023-03-01 21:27:15 +00:00
|
|
|
#include "entity.hpp"
|
2022-03-08 12:52:00 -05:00
|
|
|
#include "natives.hpp"
|
2022-07-31 01:47:48 +08:00
|
|
|
#include "pointers.hpp"
|
2023-03-21 16:22:08 +08:00
|
|
|
#include "outfit.hpp"
|
2023-03-28 23:28:25 +02:00
|
|
|
#include "services/players/player_service.hpp"
|
2022-03-08 12:52:00 -05:00
|
|
|
|
|
|
|
namespace big::ped
|
|
|
|
{
|
2022-08-10 08:42:34 +08:00
|
|
|
inline bool change_player_model(const Hash hash)
|
|
|
|
{
|
|
|
|
for (uint8_t i = 0; !STREAMING::HAS_MODEL_LOADED(hash) && i < 100; i++)
|
|
|
|
{
|
|
|
|
STREAMING::REQUEST_MODEL(hash);
|
|
|
|
script::get_current()->yield();
|
|
|
|
}
|
|
|
|
if (!STREAMING::HAS_MODEL_LOADED(hash))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
PLAYER::SET_PLAYER_MODEL(self::id, hash);
|
2023-01-22 21:57:32 +00:00
|
|
|
self::ped = PLAYER::PLAYER_PED_ID();
|
2022-08-10 08:42:34 +08:00
|
|
|
script::get_current()->yield();
|
|
|
|
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hash);
|
2023-03-01 21:27:15 +00:00
|
|
|
for (int i = 0; i < 12; i++)
|
|
|
|
{
|
|
|
|
PED::SET_PED_COMPONENT_VARIATION(self::ped, i, PED::GET_PED_DRAWABLE_VARIATION(self::ped, i), PED::GET_PED_TEXTURE_VARIATION(self::ped, i), PED::GET_PED_PALETTE_VARIATION(self::ped, i));
|
2023-01-22 16:59:17 -05:00
|
|
|
}
|
2022-08-10 08:42:34 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool steal_outfit(const Ped target)
|
2022-03-08 12:52:00 -05:00
|
|
|
{
|
2022-05-23 06:38:45 +08:00
|
|
|
Ped ped = self::ped;
|
2023-03-01 21:27:15 +00:00
|
|
|
|
|
|
|
if (ENTITY::GET_ENTITY_MODEL(ped) != ENTITY::GET_ENTITY_MODEL(target))
|
|
|
|
{
|
2022-08-10 08:42:34 +08:00
|
|
|
return false;
|
2022-03-08 12:52:00 -05:00
|
|
|
}
|
2023-03-01 21:27:15 +00:00
|
|
|
for (int i = 0; i < 12; i++)
|
|
|
|
{
|
|
|
|
PED::SET_PED_COMPONENT_VARIATION(ped, i, PED::GET_PED_DRAWABLE_VARIATION(target, i), PED::GET_PED_TEXTURE_VARIATION(target, i), PED::GET_PED_PALETTE_VARIATION(target, i));
|
2022-03-08 12:52:00 -05:00
|
|
|
}
|
2022-08-10 08:42:34 +08:00
|
|
|
|
|
|
|
return true;
|
2022-03-08 12:52:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void steal_identity(const Ped target)
|
|
|
|
{
|
2023-03-01 21:27:15 +00:00
|
|
|
const int max_health = ENTITY::GET_ENTITY_MAX_HEALTH(self::ped);
|
2022-07-25 04:56:37 +08:00
|
|
|
const int current_health = ENTITY::GET_ENTITY_HEALTH(self::ped);
|
2023-03-01 21:27:15 +00:00
|
|
|
const int current_armor = PED::GET_PED_ARMOUR(self::ped);
|
2022-05-23 06:38:45 +08:00
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
PLAYER::SET_PLAYER_MODEL(self::id, ENTITY::GET_ENTITY_MODEL(target));
|
2022-07-25 04:56:37 +08:00
|
|
|
script::get_current()->yield();
|
|
|
|
PED::CLONE_PED_TO_TARGET(target, self::ped);
|
|
|
|
ENTITY::SET_ENTITY_MAX_HEALTH(self::ped, max_health);
|
|
|
|
ENTITY::SET_ENTITY_HEALTH(self::ped, current_health, 0);
|
|
|
|
PED::SET_PED_ARMOUR(self::ped, current_armor);
|
2022-03-08 12:52:00 -05:00
|
|
|
}
|
2022-07-31 01:47:48 +08:00
|
|
|
|
Feature Additions, GUI Tweaks, Fixes (#975)
* Added view nearby to view header, moved get_entities function to entities and refactored some code. Also implemented a sphere scale to the blackhole as it can get big
* added delete and kill nearby peds and updated ped header
* added some nearby ped looped commands, and some changes to extend the buttons
* add vehicle options to nearby
* add most ciritcal feature kill enemies
* changes to ignore peds based off of some of maybegreat's suggestions, same with ped_rain, removed loose comment. Updated vehicle.hpp, changed size of vehicle buttons and inlined kill enemies
* fixed a problem where the vehicle options crashed + added color
* updated colors and added on disable for ped_rush
* finished and added vehicle rain feature
* added aimbot and triggerbot, added templating to buttons
* update vehicle rain desc
* added vdistance check, player check, police check, enemy check. Added even more commenting... sue me. 3 toggles added for the checks and slider for dist. Will tweak more later
* switched to goto statements instead of continue, should be done now
* removed delete nearby vehicles
* there was no check in get_entities for our local vehicle
2023-02-25 13:33:16 -07:00
|
|
|
inline void kill_ped(const Ped ped)
|
|
|
|
{
|
|
|
|
if (entity::take_control_of(ped))
|
|
|
|
PED::APPLY_DAMAGE_TO_PED(ped, PED::GET_PED_MAX_HEALTH(ped) * 2, false, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void kill_ped_by_relation(Ped ped, int relation_id)
|
|
|
|
{
|
|
|
|
if (PED::GET_RELATIONSHIP_BETWEEN_PEDS(ped, PLAYER::PLAYER_PED_ID()) == relation_id)
|
|
|
|
kill_ped(ped);
|
|
|
|
}
|
|
|
|
|
2022-08-10 08:42:34 +08:00
|
|
|
inline Ped spawn(ePedType pedType, Hash hash, Hash clone, Vector3 location, float heading, bool is_networked = true)
|
2022-07-31 01:47:48 +08:00
|
|
|
{
|
|
|
|
for (uint8_t i = 0; !STREAMING::HAS_MODEL_LOADED(hash) && i < 100; i++)
|
|
|
|
{
|
|
|
|
STREAMING::REQUEST_MODEL(hash);
|
|
|
|
script::get_current()->yield();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!STREAMING::HAS_MODEL_LOADED(hash))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ped = PED::CREATE_PED(pedType, hash, location.x, location.y, location.z, heading, is_networked, false);
|
|
|
|
|
|
|
|
script::get_current()->yield();
|
|
|
|
|
2022-08-10 08:42:34 +08:00
|
|
|
if (clone)
|
|
|
|
{
|
|
|
|
PED::CLONE_PED_TO_TARGET(clone, ped);
|
|
|
|
}
|
|
|
|
|
2022-07-31 01:47:48 +08:00
|
|
|
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hash);
|
|
|
|
|
|
|
|
return ped;
|
|
|
|
}
|
2023-03-21 16:22:08 +08:00
|
|
|
|
|
|
|
inline void set_ped_random_component_variation(Ped ped)
|
|
|
|
{
|
|
|
|
auto range = [](int lower_bound, int upper_bound) -> int {
|
|
|
|
return std::rand() % (upper_bound - lower_bound + 1) + lower_bound;
|
|
|
|
};
|
|
|
|
outfit::components_t components;
|
|
|
|
for (auto& item : components.items)
|
|
|
|
{
|
|
|
|
int drawable_id = range(0, PED::GET_NUMBER_OF_PED_DRAWABLE_VARIATIONS(ped, item.id) - 1);
|
|
|
|
int texture_id = range(0, PED::GET_NUMBER_OF_PED_TEXTURE_VARIATIONS(ped, item.id, drawable_id) - 1);
|
|
|
|
PED::SET_PED_COMPONENT_VARIATION(ped, item.id, drawable_id, texture_id, PED::GET_PED_PALETTE_VARIATION(ped, item.id));
|
|
|
|
}
|
|
|
|
}
|
2023-03-28 23:28:25 +02:00
|
|
|
|
|
|
|
inline player_ptr get_player_from_ped(Ped ped)
|
|
|
|
{
|
|
|
|
for (auto& p : g_player_service->players())
|
|
|
|
{
|
|
|
|
if (p.second->get_ped())
|
|
|
|
{
|
|
|
|
if (p.second->get_ped() == g_pointers->m_handle_to_ptr(ped))
|
|
|
|
return p.second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool load_animation_dict (const char* dict)
|
|
|
|
{
|
|
|
|
if (STREAMING::HAS_ANIM_DICT_LOADED(dict))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
for (uint8_t i = 0; !STREAMING::HAS_ANIM_DICT_LOADED(dict) && i < 35; i++)
|
|
|
|
{
|
|
|
|
STREAMING::REQUEST_ANIM_DICT(dict);
|
|
|
|
script::get_current()->yield();
|
|
|
|
}
|
|
|
|
|
|
|
|
return STREAMING::HAS_ANIM_DICT_LOADED(dict);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void ped_play_animation(Ped ped, const std::string_view& animDict, const std::string_view& animName, float speed = 4.f, float speedMultiplier = -4.f, int duration = -1, int flag = 1, float playbackRate = 0, bool lockPos = false)
|
|
|
|
{
|
|
|
|
if (load_animation_dict(animDict.data()))
|
|
|
|
TASK::TASK_PLAY_ANIM(ped, animDict.data(), animName.data(), speed, speedMultiplier, duration, flag, playbackRate, lockPos, lockPos, lockPos);
|
|
|
|
}
|
|
|
|
|
2023-01-22 16:59:17 -05:00
|
|
|
}
|