Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Assorted pet improvements #1402

Merged
merged 7 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dCommon/dEnums/ePetAbilityType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef __EPETABILITYTYPE__H__
#define __EPETABILITYTYPE__H__

jadebenn marked this conversation as resolved.
Show resolved Hide resolved
enum class ePetAbilityType : int32_t {
Invalid,
GoToObject,
JumpOnObject,
DigAtPosition
};

#endif //!__EPETABILITYTYPE__H__
4 changes: 4 additions & 0 deletions dDatabase/CDClientDatabase/CDClientDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
// Static Variables
static CppSQLite3DB* conn = new CppSQLite3DB();

// Status Variables
bool CDClientDatabase::isConnected = false;

//! Opens a connection with the CDClient
void CDClientDatabase::Connect(const std::string& filename) {
conn->open(filename.c_str());
isConnected = true;
}

//! Queries the CDClient
Expand Down
4 changes: 4 additions & 0 deletions dDatabase/CDClientDatabase/CDClientDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

//! The CDClient Database namespace
namespace CDClientDatabase {
/**
* Boolean defining the connection status of CDClient
*/
extern bool isConnected;
jadebenn marked this conversation as resolved.
Show resolved Hide resolved

//! Opens a connection with the CDClient
/*!
Expand Down
85 changes: 46 additions & 39 deletions dDatabase/CDClientDatabase/CDClientManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,43 +52,50 @@
#endif

CDClientManager::CDClientManager() {
CDActivityRewardsTable::Instance().LoadValuesFromDatabase();
CDActivitiesTable::Instance().LoadValuesFromDatabase();
CDCLIENT_DONT_CACHE_TABLE(CDAnimationsTable::Instance().LoadValuesFromDatabase());
CDBehaviorParameterTable::Instance().LoadValuesFromDatabase();
CDBehaviorTemplateTable::Instance().LoadValuesFromDatabase();
CDBrickIDTableTable::Instance().LoadValuesFromDatabase();
CDCLIENT_DONT_CACHE_TABLE(CDComponentsRegistryTable::Instance().LoadValuesFromDatabase());
CDCurrencyTableTable::Instance().LoadValuesFromDatabase();
CDDestructibleComponentTable::Instance().LoadValuesFromDatabase();
CDEmoteTableTable::Instance().LoadValuesFromDatabase();
CDFeatureGatingTable::Instance().LoadValuesFromDatabase();
CDInventoryComponentTable::Instance().LoadValuesFromDatabase();
CDCLIENT_DONT_CACHE_TABLE(CDItemComponentTable::Instance().LoadValuesFromDatabase());
CDItemSetSkillsTable::Instance().LoadValuesFromDatabase();
CDItemSetsTable::Instance().LoadValuesFromDatabase();
CDLevelProgressionLookupTable::Instance().LoadValuesFromDatabase();
CDCLIENT_DONT_CACHE_TABLE(CDLootMatrixTable::Instance().LoadValuesFromDatabase());
CDCLIENT_DONT_CACHE_TABLE(CDLootTableTable::Instance().LoadValuesFromDatabase());
CDMissionEmailTable::Instance().LoadValuesFromDatabase();
CDMissionNPCComponentTable::Instance().LoadValuesFromDatabase();
CDMissionTasksTable::Instance().LoadValuesFromDatabase();
CDMissionsTable::Instance().LoadValuesFromDatabase();
CDMovementAIComponentTable::Instance().LoadValuesFromDatabase();
CDObjectSkillsTable::Instance().LoadValuesFromDatabase();
CDCLIENT_DONT_CACHE_TABLE(CDObjectsTable::Instance().LoadValuesFromDatabase());
CDPhysicsComponentTable::Instance().LoadValuesFromDatabase();
CDPackageComponentTable::Instance().LoadValuesFromDatabase();
CDProximityMonitorComponentTable::Instance().LoadValuesFromDatabase();
CDPropertyEntranceComponentTable::Instance().LoadValuesFromDatabase();
CDPropertyTemplateTable::Instance().LoadValuesFromDatabase();
CDRailActivatorComponentTable::Instance().LoadValuesFromDatabase();
CDRarityTableTable::Instance().LoadValuesFromDatabase();
CDRebuildComponentTable::Instance().LoadValuesFromDatabase();
CDRewardCodesTable::Instance().LoadValuesFromDatabase();
CDRewardsTable::Instance().LoadValuesFromDatabase();
CDScriptComponentTable::Instance().LoadValuesFromDatabase();
CDSkillBehaviorTable::Instance().LoadValuesFromDatabase();
CDVendorComponentTable::Instance().LoadValuesFromDatabase();
CDZoneTableTable::Instance().LoadValuesFromDatabase();
if (CDClientDatabase::isConnected) {
CDActivityRewardsTable::Instance().LoadValuesFromDatabase();
CDActivitiesTable::Instance().LoadValuesFromDatabase();
CDCLIENT_DONT_CACHE_TABLE(CDAnimationsTable::Instance().LoadValuesFromDatabase());
CDBehaviorParameterTable::Instance().LoadValuesFromDatabase();
CDBehaviorTemplateTable::Instance().LoadValuesFromDatabase();
CDBrickIDTableTable::Instance().LoadValuesFromDatabase();
CDCLIENT_DONT_CACHE_TABLE(CDComponentsRegistryTable::Instance().LoadValuesFromDatabase());
CDCurrencyTableTable::Instance().LoadValuesFromDatabase();
CDDestructibleComponentTable::Instance().LoadValuesFromDatabase();
CDEmoteTableTable::Instance().LoadValuesFromDatabase();
CDFeatureGatingTable::Instance().LoadValuesFromDatabase();
CDInventoryComponentTable::Instance().LoadValuesFromDatabase();
CDCLIENT_DONT_CACHE_TABLE(CDItemComponentTable::Instance().LoadValuesFromDatabase());
CDItemSetSkillsTable::Instance().LoadValuesFromDatabase();
CDItemSetsTable::Instance().LoadValuesFromDatabase();
CDLevelProgressionLookupTable::Instance().LoadValuesFromDatabase();
CDCLIENT_DONT_CACHE_TABLE(CDLootMatrixTable::Instance().LoadValuesFromDatabase());
CDCLIENT_DONT_CACHE_TABLE(CDLootTableTable::Instance().LoadValuesFromDatabase());
CDMissionEmailTable::Instance().LoadValuesFromDatabase();
CDMissionNPCComponentTable::Instance().LoadValuesFromDatabase();
CDMissionTasksTable::Instance().LoadValuesFromDatabase();
CDMissionsTable::Instance().LoadValuesFromDatabase();
CDMovementAIComponentTable::Instance().LoadValuesFromDatabase();
CDObjectSkillsTable::Instance().LoadValuesFromDatabase();
CDCLIENT_DONT_CACHE_TABLE(CDObjectsTable::Instance().LoadValuesFromDatabase());
CDPhysicsComponentTable::Instance().LoadValuesFromDatabase();
CDPackageComponentTable::Instance().LoadValuesFromDatabase();
CDPetComponentTable::Instance().LoadValuesFromDatabase();
CDProximityMonitorComponentTable::Instance().LoadValuesFromDatabase();
CDPropertyEntranceComponentTable::Instance().LoadValuesFromDatabase();
CDPropertyTemplateTable::Instance().LoadValuesFromDatabase();
CDRailActivatorComponentTable::Instance().LoadValuesFromDatabase();
CDRarityTableTable::Instance().LoadValuesFromDatabase();
CDRebuildComponentTable::Instance().LoadValuesFromDatabase();
CDRewardCodesTable::Instance().LoadValuesFromDatabase();
CDRewardsTable::Instance().LoadValuesFromDatabase();
CDScriptComponentTable::Instance().LoadValuesFromDatabase();
CDSkillBehaviorTable::Instance().LoadValuesFromDatabase();
CDVendorComponentTable::Instance().LoadValuesFromDatabase();
CDZoneTableTable::Instance().LoadValuesFromDatabase();
} else {
LOG("Unable to connect to CDClientDatabase! Using default values instead!");

CDPetComponentTable::Instance().LoadValuesFromDefaults();
}
jadebenn marked this conversation as resolved.
Show resolved Hide resolved
}
3 changes: 3 additions & 0 deletions dDatabase/CDClientDatabase/CDClientManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*/
class CDClientManager : public Singleton<CDClientManager> {
public:
/**
* Constructor for CDClientManager
*/
jadebenn marked this conversation as resolved.
Show resolved Hide resolved
CDClientManager();

/**
Expand Down
63 changes: 63 additions & 0 deletions dDatabase/CDClientDatabase/CDClientTables/CDPetComponentTable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include "CDPetComponentTable.h"

namespace {
// Default entries for fallback
CDPetComponent defaultEntry {
.id = static_cast<unsigned int>(-1),
jadebenn marked this conversation as resolved.
Show resolved Hide resolved
UNUSED_DEFAULT(.minTameUpdateTime = 60.0f,)
UNUSED_DEFAULT(.maxTameUpdateTime = 300.0f,)
UNUSED_DEFAULT(.percentTameChance = 101.0f,)
UNUSED_DEFAULT(.tameability = 100.0f,)
UNUSED_DEFAULT(.elementType = 1,)
.walkSpeed = 2.5f,
.runSpeed = 5.0f,
.sprintSpeed = 10.0f,
UNUSED_DEFAULT(.idleTimeMin = 60.0f,)
UNUSED_DEFAULT(.idleTimeMax = 300.0f,)
UNUSED_DEFAULT(.petForm = 0,)
.imaginationDrainRate = 60.0f,
UNUSED_DEFAULT(.AudioMetaEventSet = "",)
UNUSED_DEFAULT(.buffIDs = "",)
};
}

void CDPetComponentTable::LoadValuesFromDatabase() {
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PetComponent");
while (!tableData.eof()) {
CDPetComponent entry;
entry.id = tableData.getIntField("id", defaultEntry.id);
UNUSED_COLUMN(entry.minTameUpdateTime = tableData.getFloatField("minTameUpdateTime", defaultEntry.minTameUpdateTime);)
UNUSED_COLUMN(entry.maxTameUpdateTime = tableData.getFloatField("maxTameUpdateTime", defaultEntry.maxTameUpdateTime);)
UNUSED_COLUMN(entry.percentTameChance = tableData.getFloatField("percentTameChance", defaultEntry.percentTameChance);)
UNUSED_COLUMN(entry.tameability = tableData.getFloatField("tamability", defaultEntry.tameability);) // Mispelled as "tamability" in CDClient
UNUSED_COLUMN(entry.elementType = tableData.getIntField("elementType", defaultEntry.elementType);)
entry.walkSpeed = tableData.getFloatField("walkSpeed", defaultEntry.walkSpeed);
entry.runSpeed = tableData.getFloatField("runSpeed", defaultEntry.runSpeed);
entry.sprintSpeed = tableData.getFloatField("sprintSpeed", defaultEntry.sprintSpeed);
UNUSED_COLUMN(entry.idleTimeMin = tableData.getFloatField("idleTimeMin", defaultEntry.idleTimeMin);)
UNUSED_COLUMN(entry.idleTimeMax = tableData.getFloatField("idleTimeMax", defaultEntry.idleTimeMax);)
UNUSED_COLUMN(entry.petForm = tableData.getIntField("petForm", 0);)
entry.imaginationDrainRate = tableData.getFloatField("imaginationDrainRate", defaultEntry.imaginationDrainRate);
UNUSED_COLUMN(entry.AudioMetaEventSet = tableData.getStringField("AudioMetaEventSet", defaultEntry.AudioMetaEventSet);)
UNUSED_COLUMN(entry.buffIDs = tableData.getStringField("buffIDs", defaultEntry.buffIDs);)

m_entries.insert(std::make_pair(entry.id, entry));
jadebenn marked this conversation as resolved.
Show resolved Hide resolved
tableData.nextRow();
}

tableData.finalize();

jadebenn marked this conversation as resolved.
Show resolved Hide resolved
}

void CDPetComponentTable::LoadValuesFromDefaults() {
m_entries.insert(std::make_pair(defaultEntry.id, defaultEntry));
jadebenn marked this conversation as resolved.
Show resolved Hide resolved
}

CDPetComponent& CDPetComponentTable::GetByID(unsigned int componentID) {
auto itr = m_entries.find(componentID);
if (itr == m_entries.end()) {
LOG("Unable to load pet component (ID %i) values from database! Using default values instead.", componentID);
EmosewaMC marked this conversation as resolved.
Show resolved Hide resolved
return defaultEntry;
}
return itr->second;
}
49 changes: 49 additions & 0 deletions dDatabase/CDClientDatabase/CDClientTables/CDPetComponentTable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once
#include "CDTable.h"
#include <string>

struct CDPetComponent {
unsigned int id;
UNUSED_COLUMN(float minTameUpdateTime;)
UNUSED_COLUMN(float maxTameUpdateTime;)
UNUSED_COLUMN(float percentTameChance;)
UNUSED_COLUMN(float tameability;) // Mispelled as "tamability" in CDClient
UNUSED_COLUMN(unsigned int elementType;)
float walkSpeed;
float runSpeed;
float sprintSpeed;
UNUSED_COLUMN(float idleTimeMin;)
UNUSED_COLUMN(float idleTimeMax;)
UNUSED_COLUMN(unsigned int petForm;)
float imaginationDrainRate;
UNUSED_COLUMN(std::string AudioMetaEventSet;)
UNUSED_COLUMN(std::string buffIDs;)
jadebenn marked this conversation as resolved.
Show resolved Hide resolved
};

class CDPetComponentTable : public CDTable<CDPetComponentTable> {
public:

/**
* Load values from the CD client database
*/
void LoadValuesFromDatabase();

/**
* Load the default values into memory instead of attempting to connect to the CD client database
*/
void LoadValuesFromDefaults();

/**
* @returns The name of the table
*/
static const std::string GetTableName() { return "PetComponent"; };
jadebenn marked this conversation as resolved.
Show resolved Hide resolved

/**
* Gets the pet component table corresponding to the pet component ID
* @returns A reference to the corresponding table, or the default if one could not be found
*/
CDPetComponent& GetByID(unsigned int componentID);

private:
std::map<unsigned int, CDPetComponent> m_entries;
jadebenn marked this conversation as resolved.
Show resolved Hide resolved
};
3 changes: 3 additions & 0 deletions dDatabase/CDClientDatabase/CDClientTables/CDTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
// Enable this to skip some unused columns in some tables
#define UNUSED_COLUMN(v)

// Use this to skip unused defaults for unused columns in some tables
#define UNUSED_DEFAULT(v, x)

#pragma warning (disable : 4244) //Disable double to float conversion warnings
#pragma warning (disable : 4715) //Disable "not all control paths return a value"

Expand Down
1 change: 1 addition & 0 deletions dDatabase/CDClientDatabase/CDClientTables/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set(DDATABASE_CDCLIENTDATABASE_CDCLIENTTABLES_SOURCES "CDActivitiesTable.cpp"
"CDMovementAIComponentTable.cpp"
"CDObjectSkillsTable.cpp"
"CDObjectsTable.cpp"
"CDPetComponentTable.cpp"
"CDPackageComponentTable.cpp"
"CDPhysicsComponentTable.cpp"
"CDPropertyEntranceComponentTable.cpp"
Expand Down
1 change: 0 additions & 1 deletion dGame/dComponents/BaseCombatAIComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
m_MovementAI = nullptr;
m_Disabled = false;
m_SkillEntries = {};
m_MovementAI = nullptr;
m_SoftTimer = 5.0f;

//Grab the aggro information from BaseCombatAI:
Expand Down
Loading
Loading