diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 749b6db0..73325f8f 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -2243,7 +2243,7 @@ bool Entity::MsgRequestServerObjectInfo(GameMessages::GameMsg& msg) { } HandleMsg(info); - auto* targetForReport = Game::entityManager->GetEntity(requestInfo.targetForReport); - if (targetForReport) GameMessages::SendUIMessageServerToSingleClient("ToggleObjectDebugger", response, targetForReport->GetSystemAddress()); + auto* client = Game::entityManager->GetEntity(requestInfo.clientId); + if (client) GameMessages::SendUIMessageServerToSingleClient("ToggleObjectDebugger", response, client->GetSystemAddress()); return true; } diff --git a/dGame/dComponents/Component.h b/dGame/dComponents/Component.h index 9379cb15..9772ac49 100644 --- a/dGame/dComponents/Component.h +++ b/dGame/dComponents/Component.h @@ -56,10 +56,16 @@ public: protected: - void RegisterMsg(const MessageType::Game msgId, auto* self, const auto handler) { + inline void RegisterMsg(const MessageType::Game msgId, auto* self, const auto handler) { m_Parent->RegisterMsg(msgId, std::bind(handler, self, std::placeholders::_1)); } + template + inline void RegisterMsg(auto* self, const auto handler) { + T msg; + RegisterMsg(msg.msgId, self, handler); + } + /** * The entity that owns this component */ diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 29f14d3b..d1356b48 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -21,6 +21,7 @@ #include "BuffComponent.h" #include "SkillComponent.h" #include "Item.h" +#include "Amf3.h" #include #include @@ -42,6 +43,7 @@ Implementation DestroyableComponent::IsEnemyImplentation; Implementation DestroyableComponent::IsFriendImplentation; DestroyableComponent::DestroyableComponent(Entity* parent) : Component(parent) { + using namespace GameMessages; m_iArmor = 0; m_fMaxArmor = 0.0f; m_iImagination = 0; @@ -78,6 +80,8 @@ DestroyableComponent::DestroyableComponent(Entity* parent) : Component(parent) { m_DeathBehavior = -1; m_DamageCooldownTimer = 0.0f; + + RegisterMsg(this, &DestroyableComponent::OnGetObjectReportInfo); } DestroyableComponent::~DestroyableComponent() { @@ -1031,3 +1035,55 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source) { } } } + +bool DestroyableComponent::OnGetObjectReportInfo(GameMessages::GameMsg& msg) { + auto& reportInfo = static_cast(msg); + + auto& destroyableInfo = reportInfo.info->PushDebug("Destroyable"); + destroyableInfo.PushDebug("Health") = m_iHealth; + destroyableInfo.PushDebug("Max Health") = m_fMaxHealth; + destroyableInfo.PushDebug("Armor") = m_iArmor; + destroyableInfo.PushDebug("Max Armor") = m_fMaxArmor; + destroyableInfo.PushDebug("Imagination") = m_iImagination; + destroyableInfo.PushDebug("Max Imagination") = m_fMaxImagination; + destroyableInfo.PushDebug("Damage To Absorb") = m_DamageToAbsorb; + destroyableInfo.PushDebug("Is GM Immune") = m_IsGMImmune; + destroyableInfo.PushDebug("Is Shielded") = m_IsShielded; + destroyableInfo.PushDebug("Attacks To Block") = m_AttacksToBlock; + destroyableInfo.PushDebug("Damage Reduction") = m_DamageReduction; + auto& factions = destroyableInfo.PushDebug("Factions"); + for (const auto factionID : m_FactionIDs) { + factions.PushDebug(std::to_string(factionID)) = ""; + } + auto& enemyFactions = destroyableInfo.PushDebug("Enemy Factions"); + for (const auto enemyFactionID : m_EnemyFactionIDs) { + enemyFactions.PushDebug(std::to_string(enemyFactionID)) = ""; + } + destroyableInfo.PushDebug("Is Smashable") = m_IsSmashable; + destroyableInfo.PushDebug("Is Dead") = m_IsDead; + destroyableInfo.PushDebug("Is Smashed") = m_IsSmashed; + destroyableInfo.PushDebug("Is Module Assembly") = m_IsModuleAssembly; + destroyableInfo.PushDebug("Explode Factor") = m_ExplodeFactor; + destroyableInfo.PushDebug("Has Threats") = m_HasThreats; + destroyableInfo.PushDebug("Loot Matrix ID") = m_LootMatrixID; + destroyableInfo.PushDebug("Min Coins") = m_MinCoins; + destroyableInfo.PushDebug("Max Coins") = m_MaxCoins; + destroyableInfo.PushDebug("Killer ID") = std::to_string(m_KillerID); + + // "Scripts"; idk what to do about scripts yet + auto& immuneCounts = destroyableInfo.PushDebug("Immune Counts"); + immuneCounts.PushDebug("Basic Attack") = m_ImmuneToBasicAttackCount; + immuneCounts.PushDebug("Damage Over Time") = m_ImmuneToDamageOverTimeCount; + immuneCounts.PushDebug("Knockback") = m_ImmuneToKnockbackCount; + immuneCounts.PushDebug("Interrupt") = m_ImmuneToInterruptCount; + immuneCounts.PushDebug("Speed") = m_ImmuneToSpeedCount; + immuneCounts.PushDebug("Imagination Gain") = m_ImmuneToImaginationGainCount; + immuneCounts.PushDebug("Imagination Loss") = m_ImmuneToImaginationLossCount; + immuneCounts.PushDebug("Quickbuild Interrupt") = m_ImmuneToQuickbuildInterruptCount; + immuneCounts.PushDebug("Pull To Point") = m_ImmuneToPullToPointCount; + + destroyableInfo.PushDebug("Death Behavior") = m_DeathBehavior; + destroyableInfo.PushDebug("Damage Cooldown Timer") = m_DamageCooldownTimer; + + return true; +} diff --git a/dGame/dComponents/DestroyableComponent.h b/dGame/dComponents/DestroyableComponent.h index 8b3cd14c..a89b3eab 100644 --- a/dGame/dComponents/DestroyableComponent.h +++ b/dGame/dComponents/DestroyableComponent.h @@ -9,6 +9,10 @@ #include "eReplicaComponentType.h" #include "Implementation.h" +namespace GameMessages { + struct GetObjectReportInfo; +}; + namespace CppScripts { class Script; }; //! namespace CppScripts @@ -464,6 +468,8 @@ public: // handle hardcode mode drops void DoHardcoreModeDrops(const LWOOBJID source); + bool OnGetObjectReportInfo(GameMessages::GameMsg& msg); + static Implementation IsEnemyImplentation; static Implementation IsFriendImplentation; @@ -591,7 +597,7 @@ private: /** * The ID of the entity that smashed this entity, if any */ - LWOOBJID m_KillerID; + LWOOBJID m_KillerID{}; /** * The list of callbacks that will be called when this entity gets hit diff --git a/dGame/dUtilities/SlashCommands/DEVGMCommands.cpp b/dGame/dUtilities/SlashCommands/DEVGMCommands.cpp index 8b2ffe17..afbceaf3 100644 --- a/dGame/dUtilities/SlashCommands/DEVGMCommands.cpp +++ b/dGame/dUtilities/SlashCommands/DEVGMCommands.cpp @@ -1524,7 +1524,8 @@ namespace DEVGMCommands { GameMessages::RequestServerObjectInfo objectInfo; objectInfo.bVerbose = true; objectInfo.target = closest->GetObjectID(); - objectInfo.targetForReport = entity->GetObjectID(); + objectInfo.targetForReport = closest->GetObjectID(); + objectInfo.clientId = entity->GetObjectID(); closest->HandleMsg(objectInfo); Game::entityManager->SerializeEntity(closest);