feat: more destroyable debug info (#1912)

* feat: more destroyable info

* Change type and remove duplicate value
This commit is contained in:
David Markowitz
2025-10-16 12:15:02 -07:00
committed by GitHub
parent 4c9c773ec5
commit f3a5f60d81
4 changed files with 99 additions and 19 deletions

View File

@@ -424,6 +424,7 @@ void Entity::Initialize() {
comp->SetIsSmashable(destCompData[0].isSmashable);
comp->SetLootMatrixID(destCompData[0].LootMatrixIndex);
comp->SetCurrencyIndex(destCompData[0].CurrencyIndex);
Loot::CacheMatrix(destCompData[0].LootMatrixIndex);
// Now get currency information
@@ -2252,6 +2253,7 @@ bool Entity::MsgRequestServerObjectInfo(GameMessages::GameMsg& msg) {
response.Insert("objectID", std::to_string(m_ObjectID));
response.Insert("serverInfo", true);
GameMessages::GetObjectReportInfo info{};
info.clientID = requestInfo.clientId;
info.bVerbose = requestInfo.bVerbose;
info.info = response.InsertArray("data");
auto& objectInfo = info.info->PushDebug("Object Details");

View File

@@ -3,6 +3,9 @@
#include "Logger.h"
#include "Game.h"
#include "dConfig.h"
#include "CDLootMatrixTable.h"
#include "CDLootTableTable.h"
#include "CDRarityTableTable.h"
#include "Amf3.h"
#include "AmfSerialize.h"
@@ -1060,38 +1063,89 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source) {
bool DestroyableComponent::OnGetObjectReportInfo(GameMessages::GameMsg& msg) {
auto& reportInfo = static_cast<GameMessages::GetObjectReportInfo&>(msg);
auto& destroyableInfo = reportInfo.info->PushDebug("Destroyable");
destroyableInfo.PushDebug<AMFIntValue>("Health") = m_iHealth;
destroyableInfo.PushDebug<AMFDoubleValue>("Max Health") = m_fMaxHealth;
destroyableInfo.PushDebug<AMFIntValue>("Armor") = m_iArmor;
destroyableInfo.PushDebug<AMFDoubleValue>("Max Armor") = m_fMaxArmor;
destroyableInfo.PushDebug<AMFIntValue>("Imagination") = m_iImagination;
destroyableInfo.PushDebug<AMFDoubleValue>("Max Imagination") = m_fMaxImagination;
destroyableInfo.PushDebug<AMFIntValue>("Damage To Absorb") = m_DamageToAbsorb;
destroyableInfo.PushDebug<AMFIntValue>("DestructibleComponent DB Table Template ID") = m_ComponentID;
if (m_CurrencyIndex == -1) {
destroyableInfo.PushDebug<AMFBoolValue>("Has Loot Currency") = false;
} else {
destroyableInfo.PushDebug<AMFIntValue>("Loot Currency ID") = m_CurrencyIndex;
auto& detailedCoinInfo = destroyableInfo.PushDebug("Coin Info");
detailedCoinInfo.PushDebug<AMFIntValue>("Min Coins") = m_MinCoins;
detailedCoinInfo.PushDebug<AMFIntValue>("Max Coins") = m_MaxCoins;
}
if (m_LootMatrixID == -1 || m_LootMatrixID == 0) {
destroyableInfo.PushDebug<AMFBoolValue>("Has Loot Matrix") = false;
} else {
auto& lootInfo = destroyableInfo.PushDebug("Loot Info");
lootInfo.PushDebug<AMFIntValue>("Loot Matrix ID") = m_LootMatrixID;
auto* const componentsRegistryTable = CDClientManager::GetTable<CDComponentsRegistryTable>();
auto* const itemComponentTable = CDClientManager::GetTable<CDItemComponentTable>();
auto* const lootMatrixTable = CDClientManager::GetTable<CDLootMatrixTable>();
auto* const lootTableTable = CDClientManager::GetTable<CDLootTableTable>();
auto* const rarityTableTable = CDClientManager::GetTable<CDRarityTableTable>();
const auto& matrix = lootMatrixTable->GetMatrix(m_LootMatrixID);
for (const auto& entry : matrix) {
auto& thisEntry = lootInfo.PushDebug("Loot table Index - " + std::to_string(entry.LootTableIndex));
thisEntry.PushDebug<AMFDoubleValue>("Percent chance to drop") = entry.percent * 100.0f;
thisEntry.PushDebug<AMFDoubleValue>("Minimum amount to drop") = entry.minToDrop;
thisEntry.PushDebug<AMFDoubleValue>("Maximum amount to drop") = entry.maxToDrop;
const auto& lootTable = lootTableTable->GetTable(entry.LootTableIndex);
const auto& rarityTable = rarityTableTable->GetRarityTable(entry.RarityTableIndex);
auto& thisRarity = thisEntry.PushDebug("Rarity");
for (const auto& rarity : rarityTable) {
thisRarity.PushDebug<AMFDoubleValue>("Rarity " + std::to_string(rarity.rarity)) = rarity.randmax;
}
auto& thisItems = thisEntry.PushDebug("Drop(s) Info");
for (const auto& loot : lootTable) {
uint32_t itemComponentId = componentsRegistryTable->GetByIDAndType(loot.itemid, eReplicaComponentType::ITEM);
uint32_t rarity = itemComponentTable->GetItemComponentByID(itemComponentId).rarity;
auto title = "%[Objects_" + std::to_string(loot.itemid) + "_name] " + std::to_string(loot.itemid);
if (loot.MissionDrop) title += " - Mission Drop";
thisItems.PushDebug(title);
}
}
}
auto* const entity = Game::entityManager->GetEntity(reportInfo.clientID);
destroyableInfo.PushDebug<AMFBoolValue>("Is on your team") = entity ? IsFriend(entity) : false;
auto& stats = destroyableInfo.PushDebug("Statistics");
stats.PushDebug<AMFIntValue>("Health") = m_iHealth;
stats.PushDebug<AMFDoubleValue>("Maximum Health") = m_fMaxHealth;
stats.PushDebug<AMFIntValue>("Armor") = m_iArmor;
stats.PushDebug<AMFDoubleValue>("Maximum Armor") = m_fMaxArmor;
stats.PushDebug<AMFIntValue>("Imagination") = m_iImagination;
stats.PushDebug<AMFDoubleValue>("Maximum Imagination") = m_fMaxImagination;
stats.PushDebug<AMFIntValue>("Damage Absorption Points") = m_DamageToAbsorb;
destroyableInfo.PushDebug<AMFBoolValue>("Is GM Immune") = m_IsGMImmune;
destroyableInfo.PushDebug<AMFBoolValue>("Is Shielded") = m_IsShielded;
destroyableInfo.PushDebug<AMFIntValue>("Attacks To Block") = m_AttacksToBlock;
destroyableInfo.PushDebug<AMFIntValue>("Damage Reduction") = m_DamageReduction;
auto& factions = destroyableInfo.PushDebug("Factions");
size_t i = 0;
std::stringstream factionsStream;
for (const auto factionID : m_FactionIDs) {
factions.PushDebug<AMFStringValue>(std::to_string(i++) + " " + std::to_string(factionID)) = "";
factionsStream << factionID << " ";
}
auto& enemyFactions = destroyableInfo.PushDebug("Enemy Factions");
i = 0;
destroyableInfo.PushDebug<AMFStringValue>("Factions") = factionsStream.str();
factionsStream.str("");
for (const auto enemyFactionID : m_EnemyFactionIDs) {
enemyFactions.PushDebug<AMFStringValue>(std::to_string(i++) + " " + std::to_string(enemyFactionID)) = "";
factionsStream << enemyFactionID << " ";
}
destroyableInfo.PushDebug<AMFStringValue>("Enemy Factions") = factionsStream.str();
destroyableInfo.PushDebug<AMFBoolValue>("Is Smashable") = m_IsSmashable;
destroyableInfo.PushDebug<AMFBoolValue>("Is Dead") = m_IsDead;
destroyableInfo.PushDebug<AMFBoolValue>("Is Smashed") = m_IsSmashed;
destroyableInfo.PushDebug<AMFBoolValue>("Is Module Assembly") = m_IsModuleAssembly;
destroyableInfo.PushDebug<AMFDoubleValue>("Explode Factor") = m_ExplodeFactor;
destroyableInfo.PushDebug<AMFBoolValue>("Has Threats") = m_HasThreats;
destroyableInfo.PushDebug<AMFIntValue>("Loot Matrix ID") = m_LootMatrixID;
destroyableInfo.PushDebug<AMFIntValue>("Min Coins") = m_MinCoins;
destroyableInfo.PushDebug<AMFIntValue>("Max Coins") = m_MaxCoins;
destroyableInfo.PushDebug<AMFStringValue>("Killer ID") = std::to_string(m_KillerID);
// "Scripts"; idk what to do about scripts yet
@@ -1106,7 +1160,25 @@ bool DestroyableComponent::OnGetObjectReportInfo(GameMessages::GameMsg& msg) {
immuneCounts.PushDebug<AMFIntValue>("Quickbuild Interrupt") = m_ImmuneToQuickbuildInterruptCount;
immuneCounts.PushDebug<AMFIntValue>("Pull To Point") = m_ImmuneToPullToPointCount;
destroyableInfo.PushDebug<AMFIntValue>("Death Behavior") = m_DeathBehavior;
auto& deathInfo = destroyableInfo.PushDebug("Death Info");
deathInfo.PushDebug<AMFBoolValue>("Is Dead") = m_IsDead;
switch (m_DeathBehavior) {
case 0:
deathInfo.PushDebug<AMFStringValue>("Death Behavior") = "Fade";
break;
case 1:
deathInfo.PushDebug<AMFStringValue>("Death Behavior") = "Stay";
break;
case 2:
deathInfo.PushDebug<AMFStringValue>("Death Behavior") = "Immediate";
break;
case -1:
deathInfo.PushDebug<AMFStringValue>("Death Behavior") = "Invulnerable";
break;
default:
deathInfo.PushDebug<AMFStringValue>("Death Behavior") = "Other";
break;
}
destroyableInfo.PushDebug<AMFDoubleValue>("Damage Cooldown Timer") = m_DamageCooldownTimer;
return true;

View File

@@ -370,6 +370,8 @@ public:
*/
uint32_t GetLootMatrixID() const { return m_LootMatrixID; }
void SetCurrencyIndex(int32_t currencyIndex) { m_CurrencyIndex = currencyIndex; }
/**
* Returns the ID of the entity that killed this entity, if any
* @return the ID of the entity that killed this entity, if any
@@ -587,6 +589,9 @@ private:
*/
uint32_t m_LootMatrixID;
// The currency index to determine how much loot to drop
int32_t m_CurrencyIndex{ -1 };
/**
* The min amount of coins that will drop when this entity is smashed
*/

View File

@@ -793,6 +793,7 @@ namespace GameMessages {
AMFArrayValue* info{};
AMFArrayValue* subCategory{};
bool bVerbose{};
LWOOBJID clientID{};
GetObjectReportInfo() : GameMsg(MessageType::Game::GET_OBJECT_REPORT_INFO, eGameMasterLevel::DEVELOPER) {}
};