mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-15 03:48:07 +00:00
Merge remote-tracking branch 'origin/main' into dCinema
This commit is contained in:
@@ -252,7 +252,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
if (chatCommand == "credits" || chatCommand == "info") {
|
||||
const auto& customText = chatCommand == "credits" ? VanityUtilities::ParseMarkdown((BinaryPathFinder::GetBinaryDir() / "vanity/CREDITS.md").string()) : VanityUtilities::ParseMarkdown((BinaryPathFinder::GetBinaryDir() / "vanity/INFO.md").string());
|
||||
const auto& customText = chatCommand == "credits" ? VanityUtilities::ParseMarkdown((BinaryPathFinder::GetBinaryDir() / "vanity/CREDITS.md").string()) : VanityUtilities::ParseMarkdown((BinaryPathFinder::GetBinaryDir() / "vanity/INFO.md").string());
|
||||
|
||||
{
|
||||
AMFArrayValue args;
|
||||
@@ -1666,6 +1666,24 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
return;
|
||||
}
|
||||
|
||||
//Testing basic attack immunity
|
||||
if (chatCommand == "attackimmune" && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
|
||||
int32_t state = false;
|
||||
|
||||
if (!GeneralUtils::TryParse(args[0], state)) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid state.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (destroyableComponent != nullptr) {
|
||||
destroyableComponent->SetIsImmune(state);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (chatCommand == "buff" && args.size() >= 2 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
auto* buffComponent = entity->GetComponent<BuffComponent>();
|
||||
|
||||
@@ -2019,7 +2037,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
if (chatCommand == "castskill" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
||||
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
||||
if (skillComponent){
|
||||
if (skillComponent) {
|
||||
uint32_t skillId;
|
||||
|
||||
if (!GeneralUtils::TryParse(args[0], skillId)) {
|
||||
@@ -2036,7 +2054,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
uint32_t skillId;
|
||||
int slot;
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
if (inventoryComponent){
|
||||
if (inventoryComponent) {
|
||||
if (!GeneralUtils::TryParse(args[0], slot)) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Error getting slot.");
|
||||
return;
|
||||
@@ -2045,7 +2063,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Error getting skill.");
|
||||
return;
|
||||
} else {
|
||||
if(inventoryComponent->SetSkill(slot, skillId)) ChatPackets::SendSystemMessage(sysAddr, u"Set skill to slot successfully");
|
||||
if (inventoryComponent->SetSkill(slot, skillId)) ChatPackets::SendSystemMessage(sysAddr, u"Set skill to slot successfully");
|
||||
else ChatPackets::SendSystemMessage(sysAddr, u"Set skill to slot failed");
|
||||
}
|
||||
}
|
||||
@@ -2054,7 +2072,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
if (chatCommand == "setfaction" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
if (destroyableComponent){
|
||||
if (destroyableComponent) {
|
||||
int32_t faction;
|
||||
|
||||
if (!GeneralUtils::TryParse(args[0], faction)) {
|
||||
@@ -2069,7 +2087,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
if (chatCommand == "addfaction" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
if (destroyableComponent){
|
||||
if (destroyableComponent) {
|
||||
int32_t faction;
|
||||
|
||||
if (!GeneralUtils::TryParse(args[0], faction)) {
|
||||
@@ -2084,7 +2102,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
if (chatCommand == "getfactions" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
if (destroyableComponent){
|
||||
if (destroyableComponent) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Friendly factions:");
|
||||
for (const auto entry : destroyableComponent->GetFactionIDs()) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, (GeneralUtils::to_u16string(entry)));
|
||||
|
@@ -15,6 +15,10 @@
|
||||
#include "Logger.h"
|
||||
#include "BinaryPathFinder.h"
|
||||
#include "EntityInfo.h"
|
||||
#include "Spawner.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "../dWorldServer/ObjectIDManager.h"
|
||||
#include "Level.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
@@ -29,6 +33,21 @@ void VanityUtilities::SpawnVanity() {
|
||||
|
||||
const uint32_t zoneID = Game::server->GetZoneID();
|
||||
|
||||
for (const auto& npc : m_NPCs) {
|
||||
if (npc.m_ID == LWOOBJID_EMPTY) continue;
|
||||
if (npc.m_LOT == 176){
|
||||
Game::zoneManager->RemoveSpawner(npc.m_ID);
|
||||
} else{
|
||||
auto* entity = Game::entityManager->GetEntity(npc.m_ID);
|
||||
if (!entity) continue;
|
||||
entity->Smash(LWOOBJID_EMPTY, eKillType::VIOLENT);
|
||||
}
|
||||
}
|
||||
|
||||
m_NPCs.clear();
|
||||
m_Parties.clear();
|
||||
m_PartyPhrases.clear();
|
||||
|
||||
ParseXML((BinaryPathFinder::GetBinaryDir() / "vanity/NPC.xml").string());
|
||||
|
||||
// Loop through all parties
|
||||
@@ -53,7 +72,7 @@ void VanityUtilities::SpawnVanity() {
|
||||
|
||||
// Loop through all locations
|
||||
for (const auto& location : party.m_Locations) {
|
||||
rate = GeneralUtils::GenerateRandomNumber<float>(0, 1);
|
||||
rate = GeneralUtils::GenerateRandomNumber<float>(0, 1);
|
||||
if (0.75f < rate) {
|
||||
continue;
|
||||
}
|
||||
@@ -66,10 +85,11 @@ void VanityUtilities::SpawnVanity() {
|
||||
}
|
||||
|
||||
auto& npc = npcList[npcIndex];
|
||||
|
||||
// Skip spawners
|
||||
if (npc.m_LOT == 176) continue;
|
||||
|
||||
taken.push_back(npcIndex);
|
||||
|
||||
// Spawn the NPC
|
||||
LOG("ldf size is %i", npc.ldf.size());
|
||||
if (npc.ldf.empty()) {
|
||||
npc.ldf = {
|
||||
@@ -79,13 +99,16 @@ void VanityUtilities::SpawnVanity() {
|
||||
}
|
||||
|
||||
// Spawn the NPC
|
||||
auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf);
|
||||
if (!npc.m_Phrases.empty()) {
|
||||
npcEntity->SetVar<std::vector<std::string>>(u"chats", m_PartyPhrases);
|
||||
SetupNPCTalk(npcEntity);
|
||||
if (npc.m_LOT == 176){
|
||||
npc.m_ID = SpawnSpawner(npc.m_LOT, location.m_Position, location.m_Rotation, npc.ldf);
|
||||
} else {
|
||||
auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf);
|
||||
if (!npc.m_Phrases.empty()) {
|
||||
npcEntity->SetVar<std::vector<std::string>>(u"chats", m_PartyPhrases);
|
||||
SetupNPCTalk(npcEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -111,27 +134,27 @@ void VanityUtilities::SpawnVanity() {
|
||||
new LDFData<std::u16string>(u"custom_script_client", u"scripts\\ai\\SPEC\\MISSION_MINIGAME_CLIENT.lua")
|
||||
};
|
||||
}
|
||||
if (npc.m_LOT == 176){
|
||||
npc.m_ID = SpawnSpawner(npc.m_LOT, location.m_Position, location.m_Rotation, npc.ldf);
|
||||
} else {
|
||||
// Spawn the NPC
|
||||
auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf);
|
||||
if (!npcEntity) continue;
|
||||
npc.m_ID = npcEntity->GetObjectID();
|
||||
if (!npc.m_Phrases.empty()){
|
||||
npcEntity->SetVar<std::vector<std::string>>(u"chats", npc.m_Phrases);
|
||||
|
||||
// Spawn the NPC
|
||||
auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf);
|
||||
if (!npc.m_Phrases.empty()){
|
||||
npcEntity->SetVar<std::vector<std::string>>(u"chats", npc.m_Phrases);
|
||||
auto* scriptComponent = npcEntity->GetComponent<ScriptComponent>();
|
||||
|
||||
SetupNPCTalk(npcEntity);
|
||||
}
|
||||
if (scriptComponent && !npc.m_Script.empty()) {
|
||||
scriptComponent->SetScript(npc.m_Script);
|
||||
scriptComponent->SetSerialized(false);
|
||||
|
||||
auto* scriptComponent = npcEntity->GetComponent<ScriptComponent>();
|
||||
|
||||
LOG_DEBUG("Script: %s", npc.m_Script.c_str());
|
||||
|
||||
if (scriptComponent && !npc.m_Script.empty()) {
|
||||
scriptComponent->SetScript(npc.m_Script);
|
||||
scriptComponent->SetSerialized(false);
|
||||
|
||||
LOG_DEBUG("Setting script to %s", npc.m_Script.c_str());
|
||||
|
||||
for (const auto& npc : npc.m_Flags) {
|
||||
npcEntity->SetVar<bool>(GeneralUtils::ASCIIToUTF16(npc.first), npc.second);
|
||||
for (const auto& npc : npc.m_Flags) {
|
||||
npcEntity->SetVar<bool>(GeneralUtils::ASCIIToUTF16(npc.first), npc.second);
|
||||
}
|
||||
}
|
||||
SetupNPCTalk(npcEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,8 +177,21 @@ void VanityUtilities::SpawnVanity() {
|
||||
}
|
||||
}
|
||||
|
||||
Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoint3& position,
|
||||
const NiQuaternion& rotation, const std::vector<LOT>& inventory, const std::vector<LDFBaseData*>& ldf) {
|
||||
LWOOBJID VanityUtilities::SpawnSpawner(LOT lot, const NiPoint3& position, const NiQuaternion& rotation, const std::vector<LDFBaseData*>& ldf){
|
||||
SceneObject obj;
|
||||
obj.lot = lot;
|
||||
// guratantee we have no collisions
|
||||
do {
|
||||
obj.id = ObjectIDManager::Instance()->GenerateObjectID();
|
||||
} while(Game::zoneManager->GetSpawner(obj.id));
|
||||
obj.position = position;
|
||||
obj.rotation = rotation;
|
||||
obj.settings = ldf;
|
||||
Level::MakeSpawner(obj);
|
||||
return obj.id;
|
||||
}
|
||||
|
||||
Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoint3& position, const NiQuaternion& rotation, const std::vector<LOT>& inventory, const std::vector<LDFBaseData*>& ldf) {
|
||||
EntityInfo info;
|
||||
info.lot = lot;
|
||||
info.pos = position;
|
||||
@@ -167,9 +203,6 @@ Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoin
|
||||
entity->SetVar(u"npcName", name);
|
||||
if (entity->GetVar<bool>(u"noGhosting")) entity->SetIsGhostingCandidate(false);
|
||||
|
||||
// Debug print
|
||||
LOG_DEBUG("Spawning NPC %s (%i) at %f, %f, %f", name.c_str(), lot, position.x, position.y, position.z);
|
||||
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
|
||||
if (inventoryComponent && !inventory.empty()) {
|
||||
@@ -184,15 +217,6 @@ Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoin
|
||||
destroyableComponent->SetHealth(0);
|
||||
}
|
||||
|
||||
auto* scriptComponent = entity->GetComponent<ScriptComponent>();
|
||||
|
||||
if (scriptComponent == nullptr)
|
||||
{
|
||||
entity->AddComponent<ScriptComponent>("", false);
|
||||
}
|
||||
|
||||
LOG_DEBUG("NPC has script component? %s", (entity->GetComponent<ScriptComponent>() != nullptr) ? "true" : "false");
|
||||
|
||||
Game::entityManager->ConstructEntity(entity);
|
||||
|
||||
return entity;
|
||||
|
@@ -13,6 +13,7 @@ struct VanityNPCLocation
|
||||
|
||||
struct VanityNPC
|
||||
{
|
||||
LWOOBJID m_ID = LWOOBJID_EMPTY;
|
||||
std::string m_Name;
|
||||
LOT m_LOT;
|
||||
std::vector<LOT> m_Equipment;
|
||||
@@ -44,6 +45,13 @@ public:
|
||||
const std::vector<LDFBaseData*>& ldf
|
||||
);
|
||||
|
||||
static LWOOBJID SpawnSpawner(
|
||||
LOT lot,
|
||||
const NiPoint3& position,
|
||||
const NiQuaternion& rotation,
|
||||
const std::vector<LDFBaseData*>& ldf
|
||||
);
|
||||
|
||||
static std::string ParseMarkdown(
|
||||
const std::string& file
|
||||
);
|
||||
|
Reference in New Issue
Block a user