mirror of
https://github.com/araxiaonline/mod-mythic-plus.git
synced 2026-06-13 03:02:24 -04:00
Added in leveling for enemies
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "MpLogger.h"
|
||||
#include "MythicPlus.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Log.h"
|
||||
|
||||
class MythicPlus_AllCreatureScript : public AllCreatureScript
|
||||
{
|
||||
@@ -12,12 +13,39 @@ public:
|
||||
|
||||
}
|
||||
|
||||
// void Creature_SelectLevel(const CreatureTemplate* /*creatureTemplate*/, Creature* creature) override {
|
||||
void OnBeforeCreatureSelectLevel(const CreatureTemplate* /*creatureTemplate*/, Creature* creature, uint8& level) override {
|
||||
|
||||
LOG_DEBUG("OnBeforeCreatureSelectLevel({}, {}) for instance {}", creature->GetName(), level, creature->GetMap()->GetMapName());
|
||||
|
||||
Map* map = creature->GetMap();
|
||||
if (!sMythicPlus->IsMapEligible(map)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// bail if the creature is not eligible to be scaled
|
||||
if (!sMythicPlus->IsCreatureEligible(creature)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// }
|
||||
// if we have instance data set for this map use it otherwise bail
|
||||
MpInstanceData* instanceData = sMpDataStore->GetInstanceData(map->GetId(), map->GetInstanceId());
|
||||
if(!instanceData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (creature->IsDungeonBoss()) {
|
||||
level = instanceData->boss.avgLevel;
|
||||
} else {
|
||||
uint8 level = instanceData->creature.avgLevel;
|
||||
level = uint8(irand(level-1, level+1));
|
||||
}
|
||||
|
||||
MpLogger::debug("OnBeforeCreatureSelectLevel({}, {}) for instance {}",
|
||||
creature->GetName(),
|
||||
level,
|
||||
map->GetMapName()
|
||||
);
|
||||
}
|
||||
|
||||
// void OnCreatureAddWorld(Creature* creature) override
|
||||
// {
|
||||
|
||||
@@ -47,8 +47,6 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// look to see if the settings for this map instance have been created.
|
||||
|
||||
uint8 avgLevel = 0;
|
||||
MpInstanceData instanceData;
|
||||
switch(groupData->difficulty) {
|
||||
@@ -93,13 +91,15 @@ public:
|
||||
sMpDataStore->AddInstanceData(map->GetId(), map->GetInstanceId(), instanceData);
|
||||
}
|
||||
|
||||
void OnPlayerLeaveAll(Map* map, Player* player)
|
||||
// When an instance is destroyed remove the instance data from the data store
|
||||
virtual void OnDestroyInstance(MapInstanced* /*mapInstanced*/, Map* map)
|
||||
{
|
||||
MpLogger::debug("AllMapScript::OnPlayerLeaveAll(): {}", map->GetMapName());
|
||||
|
||||
if (!sMythicPlus->IsMapEligible(map)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MpLogger::debug("AllMapScript::OnDestroyInstance(): {}", map->GetMapName());
|
||||
sMpDataStore->RemoveInstanceData(map->GetId(), map->GetInstanceId());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Chat.h"
|
||||
#include "MpDataStore.h"
|
||||
#include "MythicPlus.h"
|
||||
#include "MpDataStore.h"
|
||||
#include "MpLogger.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
@@ -98,6 +99,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
handler->PSendSysMessage("Mythic+ difficulty set to: " + difficulty);
|
||||
MpLogger::debug("HandleSetMythic() Set difficulty player: {} {}", player->GetName(), difficulty);
|
||||
|
||||
return true;
|
||||
@@ -105,22 +108,23 @@ public:
|
||||
|
||||
static bool HandleMythic(ChatHandler* handler, const std::vector<std::string>& /*args*/)
|
||||
{
|
||||
return HandleSetDifficulty(handler, std::vector<std::string>{"mythic"});
|
||||
return HandleSetDifficulty(handler, {"mythic"});
|
||||
}
|
||||
|
||||
static bool HandleLegendary(ChatHandler* handler, const std::vector<std::string>& /*args*/)
|
||||
{
|
||||
return HandleSetDifficulty(handler, std::vector<std::string>{"legendary"});
|
||||
return HandleSetDifficulty(handler, {"legendary"});
|
||||
}
|
||||
|
||||
static bool HandleAscendant(ChatHandler* handler, const std::vector<std::string>& /*args*/)
|
||||
{
|
||||
return HandleSetDifficulty(handler, std::vector<std::string>{"ascendant"});
|
||||
return HandleSetDifficulty(handler, {"ascendant"});
|
||||
}
|
||||
|
||||
static bool HandleStatus(ChatHandler* handler)
|
||||
{
|
||||
MpLogger::debug("HandleStatus()");
|
||||
Player* player = handler->GetPlayer();
|
||||
|
||||
std::string status = Acore::StringFormat(
|
||||
"Mythic+ Status:\n"
|
||||
" Mythic+ Enabled: %s\n"
|
||||
@@ -130,6 +134,17 @@ public:
|
||||
sMythicPlus->EnableItemRewards ? "Yes" : "No",
|
||||
sMythicPlus->EnableDeathLimits ? "Yes" : "No");
|
||||
|
||||
if (player->GetGroup()) {
|
||||
auto groupData = sMpDataStore->GetGroupData(player->GetGroup()->GetGUID());
|
||||
if (groupData) {
|
||||
status += Acore::StringFormat(
|
||||
" Group Difficulty: %u\n"
|
||||
" Group Deaths: %u\n",
|
||||
groupData->difficulty,
|
||||
groupData->deaths);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
handler->PSendSysMessage(status);
|
||||
return true;
|
||||
|
||||
@@ -10,26 +10,26 @@ class MythicPlus_GroupScript : public GroupScript
|
||||
public:
|
||||
MythicPlus_GroupScript() : GroupScript("MythicPlus_GroupScript") { }
|
||||
|
||||
// void OnCreate(Group* group, Player* leader) override {
|
||||
// if (!group) {
|
||||
// return;
|
||||
// }
|
||||
void OnCreate(Group* group, Player* leader) override {
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if(!leader) {
|
||||
// return;
|
||||
// }
|
||||
if(!leader) {
|
||||
return;
|
||||
}
|
||||
|
||||
// // sMpDataStore->AddGroupData(group->GetGUID(), gd);
|
||||
// }
|
||||
// sMpDataStore->AddGroupData(group->GetGUID(), gd);
|
||||
}
|
||||
|
||||
// void OnDisband(Group* group) override {
|
||||
// if (!group) {
|
||||
// return;
|
||||
// }
|
||||
void OnDisband(Group* group) override {
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
|
||||
// // MpDataStore* mpds = MpDataStore::instance();
|
||||
// // mpds->RemoveGroupData(group->GetGUID());
|
||||
// }
|
||||
// MpDataStore* mpds = MpDataStore::instance();
|
||||
// mpds->RemoveGroupData(group->GetGUID());
|
||||
}
|
||||
};
|
||||
|
||||
void Add_MP_GroupScripts()
|
||||
|
||||
@@ -4,11 +4,17 @@
|
||||
#include "Player.h"
|
||||
|
||||
MpDataStore::MpDataStore() {
|
||||
// constructor
|
||||
_groupData = new std::map<ObjectGuid, MpGroupData>();
|
||||
_playerData = new std::map<ObjectGuid, MpPlayerData>();
|
||||
_instanceData = new std::map<std::pair<uint32, uint32>, MpInstanceData>();
|
||||
_instanceCreatureData = new std::map<ObjectGuid, MapCreatureData>();
|
||||
}
|
||||
|
||||
MpDataStore::~MpDataStore() {
|
||||
// destructor
|
||||
delete _groupData;
|
||||
delete _playerData;
|
||||
delete _instanceData;
|
||||
delete _instanceCreatureData;
|
||||
}
|
||||
|
||||
// Adds an entry for the group difficult to memory and updats database
|
||||
@@ -87,6 +93,16 @@ void MpDataStore::AddInstanceData(uint32 mapId, uint32 instanceId, MpInstanceDat
|
||||
_instanceData->insert({GetInstanceDataKey(mapId, instanceId), instanceSettings});
|
||||
}
|
||||
|
||||
MpInstanceData* MpDataStore::GetInstanceData(uint32 mapId, uint32 instanceId) {
|
||||
|
||||
if (!_instanceData->contains(GetInstanceDataKey(mapId, instanceId))) {
|
||||
MpLogger::debug("No instance data found for map {} instance {}", mapId, instanceId);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &_instanceData->at(GetInstanceDataKey(mapId, instanceId));
|
||||
}
|
||||
|
||||
void MpDataStore::RemoveInstanceData(uint32 mapId, uint32 instanceId) {
|
||||
_instanceData->erase(GetInstanceDataKey(mapId, instanceId));
|
||||
}
|
||||
|
||||
@@ -20,6 +20,12 @@ struct MpGroupData
|
||||
uint32 deaths;
|
||||
|
||||
std::vector<std::pair<uint32,uint32>> instanceDataKeys;
|
||||
|
||||
std::string ToString() const {
|
||||
return "MpGroupData: { group: " + std::to_string(group->GetGUID().GetCounter()) +
|
||||
", difficulty: " + std::to_string(difficulty) +
|
||||
", deaths: " + std::to_string(deaths) + " }";
|
||||
}
|
||||
};
|
||||
|
||||
struct MpPlayerData
|
||||
@@ -35,7 +41,7 @@ struct MpMultipliers
|
||||
float melee;
|
||||
float spell;
|
||||
float armor;
|
||||
uint avgLevel;
|
||||
uint8 avgLevel;
|
||||
|
||||
std::string ToString() const {
|
||||
return "MpMultipliers: { health: " + std::to_string(health) +
|
||||
@@ -103,11 +109,13 @@ public:
|
||||
}
|
||||
|
||||
const MpGroupData* GetGroupData(ObjectGuid guid) const {
|
||||
try {
|
||||
|
||||
if (_groupData->contains(guid)) {
|
||||
return &_groupData->at(guid);
|
||||
} catch (const std::out_of_range& oor) {
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
const MpGroupData* GetGroupData(Player *player) const {
|
||||
return GetGroupData(player->GetGroup()->GetGUID());
|
||||
@@ -122,6 +130,7 @@ public:
|
||||
void RemovePlayerData(ObjectGuid guid);
|
||||
|
||||
void AddInstanceData(uint32 mapId, uint32 instanceId, MpInstanceData );
|
||||
MpInstanceData* GetInstanceData(uint32 mapId, uint32 instanceId);
|
||||
void RemoveInstanceData(uint32 mapId, uint32 instanceId);
|
||||
|
||||
void AddInstanceCreatureData(ObjectGuid guid, MapCreatureData mcd);
|
||||
|
||||
@@ -23,3 +23,40 @@ bool MythicPlus::IsDungeonDisabled(uint32 dungeon)
|
||||
{
|
||||
return std::find(disabledDungeons.begin(), disabledDungeons.end(), dungeon) != disabledDungeons.end();
|
||||
}
|
||||
|
||||
bool MythicPlus::IsCreatureEligible(Creature* creature)
|
||||
{
|
||||
if (creature->IsDungeonBoss()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((creature->IsHunterPet() || creature->IsPet() || creature->IsSummon()) && creature->IsControlledByPlayer()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (creature->IsCritter() || creature->IsTotem() || creature->IsTrigger()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
# if defined(MOD_PRESENT_NPCBOTS)
|
||||
if (creature->IsNpcBot()) {
|
||||
return false;
|
||||
}
|
||||
# endif
|
||||
|
||||
// throw out NPCs
|
||||
if ((creature->IsVendor() ||
|
||||
creature->HasNpcFlag(UNIT_NPC_FLAG_GOSSIP) ||
|
||||
creature->HasNpcFlag(UNIT_NPC_FLAG_QUESTGIVER) ||
|
||||
creature->HasNpcFlag(UNIT_NPC_FLAG_TRAINER) ||
|
||||
creature->HasNpcFlag(UNIT_NPC_FLAG_TRAINER_PROFESSION) ||
|
||||
creature->HasNpcFlag(UNIT_NPC_FLAG_REPAIR) ||
|
||||
creature->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC) ||
|
||||
creature->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE)) &&
|
||||
(!creature->IsDungeonBoss())
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,10 +49,18 @@ public:
|
||||
uint32 legendaryItemOffset;
|
||||
uint32 ascendantItemOffset;
|
||||
|
||||
// Map is eligible for mythic+ scaling
|
||||
bool IsMapEligible(Map* map);
|
||||
|
||||
// Check is difficulty is enabled in the configuration
|
||||
bool IsDifficultyEnabled(std::string difficulty);
|
||||
|
||||
// if configuration has disabled the specific dungeon return false
|
||||
bool IsDungeonDisabled(uint32 dungeonId);
|
||||
|
||||
// The creature should be given Mythic+ scaling and powers check for pets, npcs, etc
|
||||
bool IsCreatureEligible(Creature* creature);
|
||||
|
||||
private:
|
||||
MythicPlus() { }
|
||||
~MythicPlus() { }
|
||||
|
||||
@@ -16,9 +16,9 @@ void Addmod_mythic_plusScripts()
|
||||
Add_MP_AllCreatureScripts();
|
||||
Add_MP_AllMapScripts();
|
||||
Add_MP_CommandScripts();
|
||||
Add_MP_GlobalScripts();
|
||||
Add_MP_GroupScripts();
|
||||
Add_MP_PlayerScripts();
|
||||
// Add_MP_GlobalScripts();
|
||||
// Add_MP_GroupScripts();
|
||||
// Add_MP_PlayerScripts();
|
||||
Add_MP_UnitScripts();
|
||||
Add_MP_WorldScripts();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
|
||||
void OnAfterConfigLoad(bool /*reload*/) override
|
||||
{
|
||||
// Global Settings
|
||||
// Global Settings
|
||||
sMythicPlus->Enabled = sConfigMgr->GetOption<bool>("MythicPlus.Enabled", 1);
|
||||
sMythicPlus->EnableItemRewards = sConfigMgr->GetOption<bool>("MythicPlus.EnableItemRewards", 1);
|
||||
sMythicPlus->EnableDeathLimits = sConfigMgr->GetOption<bool>("MythicPlus.EnableDeathLimits", 1);
|
||||
|
||||
Reference in New Issue
Block a user