mirror of
https://github.com/araxiaonline/mod-mythic-plus.git
synced 2026-06-13 03:02:24 -04:00
Added more database storage of stats, timers, death and workign on final boss detection.
This commit is contained in:
@@ -126,6 +126,9 @@ void MpDataStore::RemoveGroupData(Group *group) {
|
||||
void MpDataStore::AddPlayerData(ObjectGuid guid, MpPlayerData pd) {
|
||||
MpLogger::debug("AddPlayerData for player {}", guid.GetCounter());
|
||||
_playerData->emplace(guid, pd);
|
||||
|
||||
// get the player
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
}
|
||||
|
||||
void MpDataStore::UpdatePlayerData(ObjectGuid guid, MpPlayerData pd) {
|
||||
@@ -286,15 +289,78 @@ int32 MpDataStore::LoadScaleFactors() {
|
||||
return int32(_scaleFactors->size());
|
||||
}
|
||||
|
||||
// Writes current player data about their current instance run
|
||||
void MpDataStore::SavePlayerInstanceData(Player* player, MpPlayerData const* playerData)
|
||||
{
|
||||
// CharacterDatabase.Execute("REPLACE INTO mp_character_instance (character_guid, difficulty, deaths, map_id, instance_id, group_id) VALUES ({},{},{},{},{},{}) ",
|
||||
// player->GetGUID().GetCounter(),
|
||||
// playerData->difficulty,
|
||||
// playerData->deaths,
|
||||
// playerData->mapId,
|
||||
// playerData->instanceId,
|
||||
// playerData->groupId
|
||||
// );
|
||||
void MpDataStore::DBUpdatePlayerInstanceData(ObjectGuid playerGuid, MpDifficulty difficulty, uint32 mapId, uint32 instanceId, uint32 deaths) {
|
||||
if (!playerGuid) {
|
||||
MpLogger::error("DBAddPlayerData called with invalid playerData");
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterDatabase.Execute("REPLACE INTO mp_player_instance_data (guid, mapId, instanceId, deaths) VALUES ({},{},{},{},{}) ",
|
||||
playerGuid.GetCounter(),
|
||||
difficulty,
|
||||
mapId,
|
||||
instanceId,
|
||||
deaths
|
||||
);
|
||||
}
|
||||
|
||||
void MpDataStore::DBUpdatePlayerDeaths(ObjectGuid playerGuid, uint32 deaths) {
|
||||
if (!playerGuid) {
|
||||
MpLogger::error("DBUpdateDeaths called with invalid playerId");
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterDatabase.Execute("UPDATE mp_player_instance_data SET deaths = {} WHERE guid = {}",
|
||||
deaths,
|
||||
playerGuid.GetCounter()
|
||||
);
|
||||
}
|
||||
|
||||
void MpDataStore::DBUpdateGroupData(ObjectGuid groupGuid, MpDifficulty difficulty, uint32 mapId, uint32 instanceId, uint32 deaths) {
|
||||
if (!groupGuid) {
|
||||
MpLogger::error("DBUpdateGroupData called with invalid groupGuid");
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterDatabase.Execute("REPLACE INTO mp_group_data (guid, difficulty, mapId, instanceId, deaths) VALUES ({},{},{},{},{}) ",
|
||||
groupGuid.GetCounter(),
|
||||
difficulty,
|
||||
mapId,
|
||||
instanceId,
|
||||
deaths
|
||||
);
|
||||
}
|
||||
|
||||
void MpDataStore::DBRemovePlayerData(ObjectGuid playerGuid) {
|
||||
if (!playerGuid) {
|
||||
MpLogger::error("DBRemovePlayerData called with invalid playerGuid");
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterDatabase.Execute("DELETE FROM mp_player_instance_data WHERE guid = {} ", playerGuid.GetCounter());
|
||||
}
|
||||
|
||||
|
||||
void MpDataStore::DBUpdateGroupTimerDeaths(ObjectGuid groupGuid, uint32 mapId, uint32 instanceId, uint32 timer, uint32 deaths) {
|
||||
if (!groupGuid) {
|
||||
MpLogger::error("DBUpdateGroupTimerDeaths called with invalid groupGuid");
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterDatabase.Execute("REPLACE INTO mp_group_data (guid, mapId, instanceId, instanceTimer, deaths) VALUES ({},{},{},{},{}) ",
|
||||
groupGuid.GetCounter(),
|
||||
mapId,
|
||||
instanceId,
|
||||
timer,
|
||||
deaths
|
||||
);
|
||||
}
|
||||
|
||||
void MpDataStore::DBRemoveGroupData(ObjectGuid groupGuid) {
|
||||
if (!groupGuid) {
|
||||
MpLogger::error("DBRemoveGroupData called with invalid groupGuid");
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterDatabase.Execute("DELETE FROM mp_group_data WHERE guid = {} ", groupGuid.GetCounter());
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ struct MpPlayerData
|
||||
std::map<std::pair<uint32,uint32>,MpPlayerInstanceData> instanceData;
|
||||
|
||||
MpPlayerData(Player* p, MpDifficulty diff, uint32_t groupId)
|
||||
: player(p), difficulty(diff), groupId(groupId) {}
|
||||
: player(p), difficulty(diff), groupId(groupId) {
|
||||
}
|
||||
|
||||
void AddDeath(uint32 mapId, uint32 instanceId) {
|
||||
auto key = std::make_pair(mapId, instanceId);
|
||||
@@ -77,9 +78,11 @@ struct MpGroupData
|
||||
Group* group;
|
||||
MpDifficulty difficulty;
|
||||
std::vector<MpPlayerData*> players;
|
||||
MpDataStore* dataStore;
|
||||
|
||||
MpGroupData() : group(nullptr), difficulty(MpDifficulty{}) {
|
||||
players.reserve(5);
|
||||
dataStore = MpDataStore::instance();
|
||||
}
|
||||
|
||||
MpGroupData(Group* group, MpDifficulty difficulty)
|
||||
@@ -98,6 +101,8 @@ struct MpGroupData
|
||||
void ResetGroupDeaths(uint32 mapId, uint32 instanceId) {
|
||||
for (MpPlayerData* player : players) {
|
||||
player->ResetDeathCount(mapId, instanceId);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,6 +379,12 @@ public:
|
||||
int32 LoadScaleFactors();
|
||||
|
||||
// Database API calls
|
||||
void DBUpdatePlayerInstanceData(ObjectGuid playerGuid, MpDifficulty difficulty, uint32 mapId = 0, uint32 instanceId = 0, uint32 deaths = 0);
|
||||
void DBUpdatePlayerDeaths(ObjectGuid playerGuid, uint32 deaths);
|
||||
void DBRemovePlayerData(ObjectGuid playerGuid);
|
||||
void DBUpdateGroupData(ObjectGuid groupGuid, MpDifficulty difficulty, uint32 mapId, uint32 instanceId, uint32 deaths);
|
||||
void DBUpdateGroupTimerDeaths(ObjectGuid groupGuid, uint32 mapId, uint32 instanceId, uint32 timer, uint32 deaths);
|
||||
void DBRemoveGroupData(ObjectGuid groupGuid);
|
||||
void SavePlayerInstanceData(Player* player, MpPlayerData const* playerData);
|
||||
//SavePlayerDungeonStats(Group* group, MpGroupData const* groupData);
|
||||
|
||||
|
||||
@@ -476,6 +476,56 @@ int32 MythicPlus::ScaleHealSpell(SpellInfo const * spellInfo, uint32 heal, MpCre
|
||||
return int32(heal * scalingFactor * healMultiplier);
|
||||
}
|
||||
|
||||
static bool IsFinalBoss(Creature* creature) {
|
||||
CreatureTemplate const* cInfo = creature->GetCreatureTemplate();
|
||||
std::array<uint32, 48> finalBosses = {
|
||||
// --- WoW Classic ---
|
||||
11519, /* Bazzalan Ragefire */
|
||||
639, /* Edwin VanCleef Deadmines */
|
||||
3654, /* Mutanus the Devourer Wailing Caverns */
|
||||
4275, /* Archmage Arugal Shadowfang Keep */
|
||||
1716, /* Bazil Thredd Stockades */
|
||||
4829, /* Aku'mai blackfathom Deeps */
|
||||
7800, /* Mekgineer Thermaplugg Gnomeregan */
|
||||
4421, /* Charlga Razorflank Razorfen Kraul */
|
||||
4543, /* Bloodmage Thalnos Scarlet Monastery */
|
||||
3975, /* Herod Scarlet Monastery */
|
||||
3977, /* High Inquisitor Whitemane Scarlet Monastery */
|
||||
7350, /* Amnennar the Coldbringer Razorfen Downs */
|
||||
2748, /* Archaedas Uldaman */
|
||||
7267, /* Chief Ukorz Sandscalp Zul'Farrak */
|
||||
12201, /* Princess Theradras Maraudon */
|
||||
5709, /* Shade of Eranikus Sunken Temple */
|
||||
9019, /* Emperor Dagran Thaurissan Blackrock Depths */
|
||||
9568, /* Overlord Wyrmthalak Lower Blackrock Spire */
|
||||
10363, /* General Drakkisath Upper Blackrock Spire */
|
||||
11492, /* alzzin the Wildshaper Dire Maul */
|
||||
11496, /* Immol'thar Dire Maul */
|
||||
11501, /* King Gordok Dire Maul */
|
||||
1853, /* Darkmaster Gandling Scholomance */
|
||||
10812, /* Grand Crusader Dathrohan Stratholme */
|
||||
10440, /* Baron Rivendare Stratholme */
|
||||
|
||||
// --- The Burning Crusade ---
|
||||
18344, /* Nexus-Prince Shaffar - Mana-Tombs */
|
||||
17942, /* Quagmirran - The Slave Pens */
|
||||
17882, /* The Black Stalker - The Underbog */
|
||||
17991, /* Rokmar the Crackler - The Slave Pens (Heroic) */
|
||||
17977, /* Warp Splinter - The Botanica */
|
||||
17881, /* Aeonus - The Black Morass */
|
||||
18732, /* Grandmaster Vorpil - Shadow Labyrinth */
|
||||
19221, /* Nethermancer Sepethrea - The Mechanar */
|
||||
20885, /* Dalliah the Doomsayer - The Arcatraz */
|
||||
17975, /* High Botanist Freywinn - The Botanica */
|
||||
16808, /* Warchief Kargath Bladefist - The Shattered Halls */
|
||||
18473, /* Talon King Ikiss - Sethekk Halls */
|
||||
20912, /* Harbinger Skyriss - The Arcatraz */
|
||||
22930, /* Akama - Black Temple */
|
||||
|
||||
// --- Wrath of the Lich King ---
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Function is copied because was not accessible in core creature class
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
MpPlayerData const * playerData = sMpDataStore->GetPlayerData(player->GetGUID());
|
||||
if(playerData) {
|
||||
sMpDataStore->SavePlayerInstanceData(player, playerData);
|
||||
// sMpDataStore->SavePlayerInstanceData(player, playerData);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -88,7 +88,12 @@ public:
|
||||
.deaths = 0,
|
||||
});
|
||||
|
||||
sMpDataStore->SavePlayerInstanceData(player,playerData);
|
||||
sMpDataStore->DBUpdatePlayerInstanceData(player->GetGUID(), data->difficulty, map->GetId(), player->GetInstanceId(), 0);
|
||||
|
||||
if(group->GetLeaderGUID() == player->GetGUID()) {
|
||||
sMpDataStore->DBUpdateGroupData(group->GetGUID(), data->difficulty, map->GetId(), player->GetInstanceId(), 0);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user