mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-06 16:18:27 +00:00
New records and commands
This commit is contained in:
@@ -322,6 +322,18 @@ void Recorder::ActingDispatch(Entity* actor, const std::vector<Record*>& records
|
||||
}
|
||||
}
|
||||
|
||||
auto* cinematicRecord = dynamic_cast<CinematicRecord*>(record);
|
||||
|
||||
if (cinematicRecord) {
|
||||
if (variables != nullptr) {
|
||||
auto* playerEntity = Game::entityManager->GetEntity(variables->player);
|
||||
|
||||
if (playerEntity) {
|
||||
GameMessages::SendPlayCinematic(playerEntity->GetObjectID(), GeneralUtils::UTF8ToUTF16(cinematicRecord->cinematic), playerEntity->GetSystemAddress());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the record is a visibility record
|
||||
auto* visibilityRecord = dynamic_cast<VisibilityRecord*>(record);
|
||||
|
||||
@@ -518,6 +530,8 @@ void Cinema::Recording::Recorder::LoadRecords(tinyxml2::XMLElement* root, std::v
|
||||
record = new SpawnRecord();
|
||||
} else if (name == "MissionRecord") {
|
||||
record = new MissionRecord();
|
||||
} else if (name == "CinematicRecord") {
|
||||
record = new CinematicRecord();
|
||||
} else {
|
||||
LOG("Unknown record type: %s", name.c_str());
|
||||
continue;
|
||||
@@ -1468,4 +1482,26 @@ void Cinema::Recording::MissionRecord::Deserialize(tinyxml2::XMLElement* element
|
||||
m_Delay = element->DoubleAttribute("t");
|
||||
}
|
||||
|
||||
Cinema::Recording::CinematicRecord::CinematicRecord(const std::string& cinematic) {
|
||||
this->cinematic = cinematic;
|
||||
}
|
||||
|
||||
void Cinema::Recording::CinematicRecord::Act(Entity* actor) {
|
||||
}
|
||||
|
||||
void Cinema::Recording::CinematicRecord::Serialize(tinyxml2::XMLDocument& document, tinyxml2::XMLElement* parent) {
|
||||
auto* element = document.NewElement("CinematicRecord");
|
||||
|
||||
element->SetAttribute("cinematic", cinematic.c_str());
|
||||
|
||||
element->SetAttribute("t", m_Delay);
|
||||
|
||||
parent->InsertEndChild(element);
|
||||
}
|
||||
|
||||
void Cinema::Recording::CinematicRecord::Deserialize(tinyxml2::XMLElement* element) {
|
||||
cinematic = element->Attribute("cinematic");
|
||||
|
||||
m_Delay = element->DoubleAttribute("t");
|
||||
}
|
||||
|
||||
|
||||
@@ -454,4 +454,20 @@ public:
|
||||
void Deserialize(tinyxml2::XMLElement* element) override;
|
||||
};
|
||||
|
||||
class CinematicRecord : public Record
|
||||
{
|
||||
public:
|
||||
std::string cinematic;
|
||||
|
||||
CinematicRecord() = default;
|
||||
|
||||
CinematicRecord(const std::string& cinematic);
|
||||
|
||||
void Act(Entity* actor) override;
|
||||
|
||||
void Serialize(tinyxml2::XMLDocument& document, tinyxml2::XMLElement* parent) override;
|
||||
|
||||
void Deserialize(tinyxml2::XMLElement* element) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "InventoryComponent.h"
|
||||
#include "MovementAIComponent.h"
|
||||
#include "Recorder.h"
|
||||
#include "GhostComponent.h"
|
||||
|
||||
using namespace Cinema;
|
||||
|
||||
@@ -195,6 +196,22 @@ void Cinema::Scene::AutoLoadScenesForZone(LWOMAPID zone) {
|
||||
.requiredLevel = eGameMasterLevel::LEAD_MODERATOR
|
||||
});
|
||||
|
||||
SlashCommandHandler::RegisterCommand(Command{
|
||||
.help = "",
|
||||
.info = "",
|
||||
.aliases = { "cinematic" },
|
||||
.handle = CommandCinematic,
|
||||
.requiredLevel = eGameMasterLevel::LEAD_MODERATOR
|
||||
});
|
||||
|
||||
SlashCommandHandler::RegisterCommand(Command{
|
||||
.help = "",
|
||||
.info = "",
|
||||
.aliases = { "ghost" },
|
||||
.handle = CommandGhostReference,
|
||||
.requiredLevel = eGameMasterLevel::LEAD_MODERATOR
|
||||
});
|
||||
|
||||
const auto& scenesRoot = Game::config->GetValue("scenes_directory");
|
||||
|
||||
if (scenesRoot.empty()) {
|
||||
@@ -697,3 +714,29 @@ void Cinema::Scene::CommandCompanion(Entity* entity, const SystemAddress& sysAdd
|
||||
Cinema::Recording::CompanionRecord::SetCompanion(actor, follow);
|
||||
});
|
||||
}
|
||||
|
||||
void Cinema::Scene::CommandCinematic(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto splitArgs = GeneralUtils::SplitString(args, ' ');
|
||||
if (splitArgs.empty()) return;
|
||||
|
||||
const auto path = splitArgs[0];
|
||||
|
||||
GameMessages::SendPlayCinematic(entity->GetObjectID(), GeneralUtils::UTF8ToUTF16(path), sysAddr);
|
||||
}
|
||||
|
||||
void Cinema::Scene::CommandGhostReference(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
auto* ghostComponent = entity->GetComponent<GhostComponent>();
|
||||
|
||||
if (ghostComponent == nullptr) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Entity does not have a ghost component.");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& ref = ghostComponent->GetGhostReferencePoint();
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "<" << ref.x << ", " << ref.y << ", " << ref.z << ">";
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::UTF8ToUTF16(ss.str()));
|
||||
}
|
||||
|
||||
@@ -134,6 +134,8 @@ private:
|
||||
static void CommandSceneAct(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
static void CommandSceneSetup(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
static void CommandCompanion(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
static void CommandCinematic(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
static void CommandGhostReference(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
};
|
||||
|
||||
} // namespace Cinema
|
||||
|
||||
Reference in New Issue
Block a user