Custom teleport added euler angles and added persist outfit (#1743)

* Addressed #1694: Added Euler angles to telelocation JSON object.
* Added Persist Outfits to resolve #1669
This commit is contained in:
gir489
2023-07-18 04:16:26 -04:00
committed by GitHub
parent d1a8022eb7
commit 1d78388519
10 changed files with 294 additions and 90 deletions

View File

@ -77,8 +77,21 @@ namespace big
if (g_custom_teleport_service.get_saved_location_by_name(new_location_name))
g_notification_service->push_warning("Custom Teleport", std::format("Location with the name {} already exists", new_location_name));
else
g_custom_teleport_service.save_new_location(category,
{new_location_name, self::pos.x, self::pos.y, self::pos.z});
{
telelocation teleport_location;
Entity teleport_entity = self::ped;
if (self::veh != 0)
teleport_entity = self::veh;
auto coords = ENTITY::GET_ENTITY_COORDS(teleport_entity, TRUE);
teleport_location.name = new_location_name;
teleport_location.x = coords.x;
teleport_location.y = coords.y;
teleport_location.z = coords.z;
teleport_location.yaw = ENTITY::GET_ENTITY_HEADING(teleport_entity);
teleport_location.pitch = CAM::GET_GAMEPLAY_CAM_RELATIVE_PITCH();
teleport_location.roll = CAM::GET_GAMEPLAY_CAM_RELATIVE_HEADING();
g_custom_teleport_service.save_new_location(category, teleport_location);
}
});
ImGui::Separator();
@ -130,7 +143,7 @@ namespace big
if (ImGui::IsMouseDoubleClicked(0))
{
g_fiber_pool->queue_job([l] {
teleport::teleport_player_to_coords(g_player_service->get_self(), {l.x, l.y, l.z});
teleport::teleport_player_to_coords(g_player_service->get_self(), {l.x, l.y, l.z}, {l.yaw, l.pitch, l.roll});
});
}
}

View File

@ -3,6 +3,7 @@
#include "util/outfit.hpp"
#include "util/ped.hpp"
#include "views/view.hpp"
#include "services/outfit/outfit_service.hpp"
namespace big
{
@ -85,7 +86,18 @@ namespace big
if (drawable_id == -1)
PED::CLEAR_PED_PROP(self::ped, id, 1);
else
{
PED::SET_PED_PROP_INDEX(self::ped, id, drawable_id, texture_id, TRUE, 1);
if (id == 0)
{
//Prevent ped from taking helmet off.
PED::SET_PED_HELMET_PROP_INDEX(self::ped, drawable_id, 0);
PED::SET_PED_HELMET_TEXTURE_INDEX(self::ped, texture_id);
PED::SET_PED_CONFIG_FLAG(self::ped, 34, true);
if (!PED::IS_PED_ON_ANY_BIKE(self::ped))
PED::SET_PED_CONFIG_FLAG(self::ped, 36, true);
}
}
}
});
@ -173,36 +185,12 @@ namespace big
ImGui::SameLine();
components::button("OUTFIT_SAVE_CURRENT"_T, [] {
nlohmann::json j;
nlohmann::json j_components;
nlohmann::json j_props;
for (auto& item : components.items)
{
nlohmann::json tmp;
tmp["drawable_id"] = item.drawable_id;
tmp["texture_id"] = item.texture_id;
j_components[std::to_string(item.id)] = tmp;
}
for (auto& item : props.items)
{
nlohmann::json tmp;
tmp["drawable_id"] = item.drawable_id;
tmp["texture_id"] = item.texture_id;
j_props[std::to_string(item.id)] = tmp;
}
j["components"] = j_components;
j["props"] = j_props;
size_t index = 0;
std::string str = outfit_name;
while (saved_outfit_path.get_file(str + ".json").exists())
str = std::format("{}({})", outfit_name, ++index);
std::ofstream o(saved_outfit_path.get_file(str + ".json").get_path());
o << std::setw(4) << j << std::endl;
outfit_service::save_outfit(str + ".json");
});
ImGui::SameLine();
@ -213,28 +201,7 @@ namespace big
nlohmann::json j;
i >> j;
for (auto& item : j["components"].items())
{
std::stringstream ss(item.key());
int id = 0;
ss >> id;
int drawable_id = item.value()["drawable_id"];
int texture_id = item.value()["texture_id"];
PED::SET_PED_COMPONENT_VARIATION(self::ped, id, drawable_id, texture_id, PED::GET_PED_PALETTE_VARIATION(self::ped, id));
}
for (auto& item : j["props"].items())
{
std::stringstream ss(item.key());
int id = 0;
ss >> id;
int drawable_id = item.value()["drawable_id"];
int texture_id = item.value()["texture_id"];
if (drawable_id == -1)
PED::CLEAR_PED_PROP(self::ped, id, 1);
else
PED::SET_PED_PROP_INDEX(self::ped, id, drawable_id, texture_id, TRUE, 1);
}
outfit_service::apply_outfit(j, true);
}
});
ImGui::SameLine();
@ -255,5 +222,20 @@ namespace big
selected_index = i;
ImGui::EndListBox();
}
ImGui::SameLine();
ImGui::BeginGroup();
if (ImGui::Button("Set Persist Outfit"))
{
g.self.persist_outfit = saved_outfits[selected_index];
}
ImGui::SameLine();
if (ImGui::Button("Clear Persist Outfit"))
{
g.self.persist_outfit.clear();
}
ImGui::SameLine();
ImGui::Checkbox("Disable During Missions?", &g.self.persist_outfits_mis);
ImGui::Text(std::format("Current Persisted Outfit: {}", g.self.persist_outfit).c_str());
ImGui::EndGroup();
}
}