mirror of
https://github.com/araxiaonline/AzerothCore-Converted-Modules-to-latest-TrinityCore.git
synced 2026-06-13 01:22:21 -04:00
Initial Release
This commit is contained in:
@@ -86,99 +86,110 @@ to make up the non-deal party makeup.
|
||||
|
||||
namespace {
|
||||
|
||||
class solocraft_player_instance_handler : public PlayerScript {
|
||||
public:
|
||||
solocraft_player_instance_handler() : PlayerScript("solocraft_player_instance_handler") {
|
||||
TC_LOG_INFO("scripts.solocraft.player.instance", "[Solocraft] solocraft_player_instance_handler Loaded");
|
||||
}
|
||||
|
||||
void OnLogin(Player *player, bool firstLogin) override {
|
||||
if (firstLogin) {
|
||||
if (sConfigMgr->GetBoolDefault("Solocraft.Enable", true))
|
||||
{
|
||||
ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00SoloCraft |rmodule.");
|
||||
class solocraft_player_instance_handler : public PlayerScript {
|
||||
public:
|
||||
solocraft_player_instance_handler() : PlayerScript("solocraft_player_instance_handler") {
|
||||
TC_LOG_INFO("scripts.solocraft.player.instance", "[Solocraft] solocraft_player_instance_handler Loaded");
|
||||
}
|
||||
|
||||
void OnLogin(Player* player, bool firstLogin) override {
|
||||
if (firstLogin) {
|
||||
if (sConfigMgr->GetBoolDefault("Solocraft.Enable", true))
|
||||
{
|
||||
ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00SoloCraft |rmodule.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnMapChanged(Player *player) override {
|
||||
if (sConfigMgr->GetBoolDefault("Solocraft.Enable", true)) {
|
||||
Map *map = player->GetMap();
|
||||
int difficulty = CalculateDifficulty(map, player);
|
||||
int numInGroup = GetNumInGroup(player);
|
||||
ApplyBuffs(player, map, difficulty, numInGroup);
|
||||
}
|
||||
}
|
||||
private:
|
||||
std::map<ObjectGuid, int> _unitDifficulty;
|
||||
void OnMapChanged(Player* player) override {
|
||||
if (sConfigMgr->GetBoolDefault("Solocraft.Enable", true)) {
|
||||
Map* map = player->GetMap();
|
||||
int difficulty = CalculateDifficulty(map, player);
|
||||
int numInGroup = GetNumInGroup(player);
|
||||
ApplyBuffs(player, map, difficulty, numInGroup);
|
||||
}
|
||||
}
|
||||
private:
|
||||
// Get difficulty values from config
|
||||
const uint32 D5 = sConfigMgr->GetIntDefault("Solocraft.Dungeon", 5);
|
||||
const uint32 D10 = sConfigMgr->GetIntDefault("Solocraft.Heroic", 10);
|
||||
const uint32 D25 = sConfigMgr->GetIntDefault("Solocraft.Raid25", 25);
|
||||
const uint32 D40 = sConfigMgr->GetIntDefault("Solocraft.Raid40", 40);
|
||||
|
||||
int CalculateDifficulty(Map *map, Player *player) {
|
||||
int difficulty = 1;
|
||||
if (map) {
|
||||
if (map->Is25ManRaid()) {
|
||||
difficulty = 25;
|
||||
} else if (map->IsHeroic()) {
|
||||
difficulty = 10;
|
||||
} else if (map->IsRaid()) {
|
||||
difficulty = 40;
|
||||
} else if (map->IsDungeon()) {
|
||||
difficulty = 5;
|
||||
}
|
||||
}
|
||||
return difficulty;
|
||||
}
|
||||
std::map<ObjectGuid, int> _unitDifficulty;
|
||||
|
||||
int GetNumInGroup(Player *player) {
|
||||
int numInGroup = 1;
|
||||
Group *group = player->GetGroup();
|
||||
if (group) {
|
||||
Group::MemberSlotList const& groupMembers = group->GetMemberSlots();
|
||||
numInGroup = groupMembers.size();
|
||||
}
|
||||
return numInGroup;
|
||||
}
|
||||
int CalculateDifficulty(Map* map, Player* player) {
|
||||
int difficulty = 1;
|
||||
if (map) {
|
||||
if (map->Is25ManRaid()) {
|
||||
difficulty = 25;
|
||||
}
|
||||
else if (map->IsHeroic()) {
|
||||
difficulty = 10;
|
||||
}
|
||||
else if (map->IsRaid()) {
|
||||
difficulty = 40;
|
||||
}
|
||||
else if (map->IsDungeon()) {
|
||||
difficulty = 5;
|
||||
}
|
||||
}
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
void ApplyBuffs(Player *player, Map *map, int difficulty, int numInGroup) {
|
||||
ClearBuffs(player, map);
|
||||
if (difficulty > 1) {
|
||||
//InstanceMap *instanceMap = map->ToInstanceMap();
|
||||
//InstanceScript *instanceScript = instanceMap->GetInstanceScript();
|
||||
int GetNumInGroup(Player* player) {
|
||||
int numInGroup = 1;
|
||||
Group* group = player->GetGroup();
|
||||
if (group) {
|
||||
Group::MemberSlotList const& groupMembers = group->GetMemberSlots();
|
||||
numInGroup = groupMembers.size();
|
||||
}
|
||||
return numInGroup;
|
||||
}
|
||||
|
||||
ChatHandler(player->GetSession()).PSendSysMessage("Entered %s (difficulty = %d, numInGroup = %d)",
|
||||
map->GetMapName(), difficulty, numInGroup);
|
||||
void ApplyBuffs(Player* player, Map* map, int difficulty, int numInGroup) {
|
||||
ClearBuffs(player, map);
|
||||
if (difficulty > 1) {
|
||||
//InstanceMap *instanceMap = map->ToInstanceMap();
|
||||
//InstanceScript *instanceScript = instanceMap->GetInstanceScript();
|
||||
|
||||
_unitDifficulty[player->GetGUID()] = difficulty;
|
||||
for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) {
|
||||
player->ApplyStatPctModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(difficulty * 100));
|
||||
}
|
||||
player->SetFullHealth();
|
||||
if (player->GetPowerType() == POWER_MANA) {
|
||||
player->SetPower(POWER_MANA, player->GetMaxPower(POWER_MANA));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Announce to player
|
||||
std::ostringstream ss;
|
||||
ss << "|cffFF0000[SoloCraft] |cffFF8000" << player->GetName() << " entered %s - # of Players: %d - Difficulty Offset: %d.";
|
||||
ChatHandler(player->GetSession()).PSendSysMessage(ss.str().c_str(), map->GetMapName(), numInGroup, difficulty);
|
||||
|
||||
void ClearBuffs(Player *player, Map *map) {
|
||||
std::map<ObjectGuid, int>::iterator unitDifficultyIterator = _unitDifficulty.find(player->GetGUID());
|
||||
if (unitDifficultyIterator != _unitDifficulty.end()) {
|
||||
int difficulty = unitDifficultyIterator->second;
|
||||
_unitDifficulty.erase(unitDifficultyIterator);
|
||||
_unitDifficulty[player->GetGUID()] = difficulty;
|
||||
for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) {
|
||||
player->ApplyStatPctModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(difficulty * 100));
|
||||
}
|
||||
player->SetFullHealth();
|
||||
if (player->GetPowerType() == POWER_MANA) {
|
||||
player->SetPower(POWER_MANA, player->GetMaxPower(POWER_MANA));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inform the player
|
||||
std::ostringstream ss;
|
||||
ss << "|cffFF0000[SoloCraft] |cffFF8000" << player->GetName() << " exited to %s - Reverting Difficulty Offset: %d.";
|
||||
ChatHandler(player->GetSession()).PSendSysMessage(ss.str().c_str(), map->GetMapName(), difficulty);
|
||||
void ClearBuffs(Player* player, Map* map) {
|
||||
std::map<ObjectGuid, int>::iterator unitDifficultyIterator = _unitDifficulty.find(player->GetGUID());
|
||||
if (unitDifficultyIterator != _unitDifficulty.end()) {
|
||||
int difficulty = unitDifficultyIterator->second;
|
||||
_unitDifficulty.erase(unitDifficultyIterator);
|
||||
|
||||
for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) {
|
||||
player->ApplyStatPctModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(difficulty * 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
// Inform the player
|
||||
std::ostringstream ss;
|
||||
ss << "|cffFF0000[SoloCraft] |cffFF8000" << player->GetName() << " exited to %s - Reverting Difficulty Offset: %d.";
|
||||
ChatHandler(player->GetSession()).PSendSysMessage(ss.str().c_str(), map->GetMapName(), difficulty);
|
||||
|
||||
for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) {
|
||||
player->ApplyStatPctModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, 100.f / (1.f + float(difficulty * 100) / 100.f) - 100.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AddSC_solocraft() {
|
||||
new solocraft_player_instance_handler();
|
||||
new solocraft_player_instance_handler();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user