Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
- index afa4b62..c67554c 100755
- --- a/src/server/game/Entities/Creature/Creature.cpp
- +++ b/src/server/game/Entities/Creature/Creature.cpp
- @@ -1181,6 +1181,7 @@ void Creature::SelectLevel(const CreatureTemplate* cinfo)
- SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, cinfo->attackpower * damagemod);
- + sScriptMgr->Creature_SelectLevel(cinfo, this);
- }
- float Creature::_GetHealthMod(int32 Rank)
- diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
- index 5118b58..723d504 100755
- --- a/src/server/game/Entities/Unit/Unit.cpp
- +++ b/src/server/game/Entities/Unit/Unit.cpp
- @@ -942,6 +942,9 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama
- SpellSchoolMask damageSchoolMask = SpellSchoolMask(damageInfo->schoolMask);
- uint32 crTypeMask = victim->GetCreatureTypeMask();
- + //Hook For CalculateSpellDamageTaken
- + sScriptMgr->CalculateSpellDamageTaken(damageInfo, damage, spellInfo, attackType, crit);
- +
- if (IsDamageReducedByArmor(damageSchoolMask, spellInfo))
- damage = CalcArmorReducedDamage(victim, damage, spellInfo, attackType);
- @@ -1120,6 +1123,9 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam
- damage = MeleeDamageBonusDone(damageInfo->target, damage, damageInfo->attackType);
- damage = damageInfo->target->MeleeDamageBonusTaken(this, damage, damageInfo->attackType);
- + //Hook For CalculateMeleeDamage
- + sScriptMgr->CalculateMeleeDamage(victim, damage, damageInfo, attackType);
- +
- // Calculate armor reduction
- if (IsDamageReducedByArmor((SpellSchoolMask)(damageInfo->damageSchoolMask)))
- {
- diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
- index fc56106..b69297b 100755
- --- a/src/server/game/Scripting/ScriptLoader.cpp
- +++ b/src/server/game/Scripting/ScriptLoader.cpp
- @@ -17,6 +17,9 @@
- #include "ScriptLoader.h"
- +//VAS.AutoBalance
- +void AddSC_VAS_AutoBalance();
- +
- //examples
- void AddSC_example_creature();
- void AddSC_example_escort();
- @@ -1265,6 +1268,7 @@ void AddCustomScripts()
- {
- #ifdef SCRIPTS
- /* This is where custom scripts should be added. */
- + AddSC_VAS_AutoBalance();
- #endif
- }
- diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
- index 47ce6c1..a128323 100755
- --- a/src/server/game/Scripting/ScriptMgr.cpp
- +++ b/src/server/game/Scripting/ScriptMgr.cpp
- @@ -271,10 +271,12 @@ void ScriptMgr::Unload()
- SCR_CLEAR(ServerScript);
- SCR_CLEAR(WorldScript);
- SCR_CLEAR(FormulaScript);
- + SCR_CLEAR(AllMapScript);
- SCR_CLEAR(WorldMapScript);
- SCR_CLEAR(InstanceMapScript);
- SCR_CLEAR(BattlegroundMapScript);
- SCR_CLEAR(ItemScript);
- + SCR_CLEAR(AllCreatureScript);
- SCR_CLEAR(CreatureScript);
- SCR_CLEAR(GameObjectScript);
- SCR_CLEAR(AreaTriggerScript);
- @@ -291,6 +293,7 @@ void ScriptMgr::Unload()
- SCR_CLEAR(PlayerScript);
- SCR_CLEAR(GuildScript);
- SCR_CLEAR(GroupScript);
- + SCR_CLEAR(UnitScript);
- #undef SCR_CLEAR
- }
- @@ -652,6 +655,8 @@ void ScriptMgr::OnUnloadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy)
- void ScriptMgr::OnPlayerEnterMap(Map* map, Player* player)
- {
- + FOREACH_SCRIPT(AllMapScript)->OnPlayerEnterAll(map, player);
- +
- ASSERT(map);
- ASSERT(player);
- @@ -670,6 +675,8 @@ void ScriptMgr::OnPlayerEnterMap(Map* map, Player* player)
- void ScriptMgr::OnPlayerLeaveMap(Map* map, Player* player)
- {
- + FOREACH_SCRIPT(AllMapScript)->OnPlayerLeaveAll(map, player);
- +
- ASSERT(map);
- ASSERT(player);
- @@ -863,12 +870,18 @@ GameObjectAI* ScriptMgr::GetGameObjectAI(GameObject* gameobject)
- void ScriptMgr::OnCreatureUpdate(Creature* creature, uint32 diff)
- {
- + FOREACH_SCRIPT(AllCreatureScript)->OnAllCreatureUpdate(creature, diff);
- ASSERT(creature);
- GET_SCRIPT(CreatureScript, creature->GetScriptId(), tmpscript);
- tmpscript->OnUpdate(creature, diff);
- }
- +void ScriptMgr::Creature_SelectLevel(const CreatureTemplate *cinfo, Creature* creature)
- +{
- + FOREACH_SCRIPT(AllCreatureScript)->Creature_SelectLevel(cinfo, creature);
- +}
- +
- bool ScriptMgr::OnGossipHello(Player* player, GameObject* go)
- {
- ASSERT(player);
- @@ -1186,6 +1199,23 @@ void ScriptMgr::OnShutdown()
- FOREACH_SCRIPT(WorldScript)->OnShutdown();
- }
- +void ScriptMgr::SetInitialWorldSettings()
- +{
- + FOREACH_SCRIPT(WorldScript)->SetInitialWorldSettings();
- +}
- +
- +float ScriptMgr::VAS_Script_Hooks()
- +{
- + float VAS_Script_Hook_Version = 1.03f;
- +
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, "----------------------------------------------------");
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, " Powered by {VAS} Script Hooks v%4.2f",VAS_Script_Hook_Version);
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, "----------------------------------------------------");
- +
- + return VAS_Script_Hook_Version;
- +}
- +
- +
- bool ScriptMgr::OnCriteriaCheck(AchievementCriteriaData const* data, Player* source, Unit* target)
- {
- ASSERT(source);
- @@ -1414,6 +1444,37 @@ void ScriptMgr::OnGroupDisband(Group* group)
- FOREACH_SCRIPT(GroupScript)->OnDisband(group);
- }
- +//Called From Unit::DealDamage
- +uint32 ScriptMgr::DealDamage(Unit* AttackerUnit, Unit *pVictim, uint32 damage, DamageEffectType damagetype)
- +{
- + FOR_SCRIPTS_RET(UnitScript, itr, end, damage)
- + damage = itr->second->DealDamage(AttackerUnit, pVictim, damage, damagetype);
- + return damage;
- +}
- +
- +uint32 ScriptMgr::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster, int32 damage)
- +{
- + FOR_SCRIPTS_RET(UnitScript, itr, end, damage)
- + damage = itr->second->HandlePeriodicDamageAurasTick(target, caster, damage);
- + return damage;
- +}
- +
- +void ScriptMgr::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType, bool crit)
- +{
- + FOREACH_SCRIPT(UnitScript)->CalculateSpellDamageTaken(damageInfo, damage, spellInfo, attackType, crit);
- +}
- +
- +void ScriptMgr::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType)
- +{
- + FOREACH_SCRIPT(UnitScript)->CalculateMeleeDamage(pVictim, damage, damageInfo, attackType);
- +}
- +
- +UnitScript::UnitScript(const char* name)
- +: ScriptObject(name)
- +{
- + ScriptRegistry<UnitScript>::AddScript(this);
- +}
- +
- SpellScriptLoader::SpellScriptLoader(const char* name)
- : ScriptObject(name)
- {
- @@ -1438,6 +1499,12 @@ FormulaScript::FormulaScript(const char* name)
- ScriptRegistry<FormulaScript>::AddScript(this);
- }
- +AllMapScript::AllMapScript(const char* name)
- + : ScriptObject(name)
- +{
- + ScriptRegistry<AllMapScript>::AddScript(this);
- +}
- +
- WorldMapScript::WorldMapScript(const char* name, uint32 mapId)
- : ScriptObject(name), MapScript<Map>(mapId)
- {
- @@ -1471,6 +1538,12 @@ ItemScript::ItemScript(const char* name)
- ScriptRegistry<ItemScript>::AddScript(this);
- }
- +AllCreatureScript::AllCreatureScript(const char* name)
- +: ScriptObject(name)
- +{
- + ScriptRegistry<AllCreatureScript>::AddScript(this);
- +}
- +
- CreatureScript::CreatureScript(const char* name)
- : ScriptObject(name)
- {
- @@ -1576,10 +1649,12 @@ template class ScriptRegistry<SpellScriptLoader>;
- template class ScriptRegistry<ServerScript>;
- template class ScriptRegistry<WorldScript>;
- template class ScriptRegistry<FormulaScript>;
- +template class ScriptRegistry<AllMapScript>;
- template class ScriptRegistry<WorldMapScript>;
- template class ScriptRegistry<InstanceMapScript>;
- template class ScriptRegistry<BattlegroundMapScript>;
- template class ScriptRegistry<ItemScript>;
- +template class ScriptRegistry<AllCreatureScript>;
- template class ScriptRegistry<CreatureScript>;
- template class ScriptRegistry<GameObjectScript>;
- template class ScriptRegistry<AreaTriggerScript>;
- @@ -1596,6 +1671,7 @@ template class ScriptRegistry<AchievementCriteriaScript>;
- template class ScriptRegistry<PlayerScript>;
- template class ScriptRegistry<GuildScript>;
- template class ScriptRegistry<GroupScript>;
- +template class ScriptRegistry<UnitScript>;
- // Undefine utility macros.
- #undef GET_SCRIPT_RET
- diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
- index 2701825..9b4fe2f 100755
- --- a/src/server/game/Scripting/ScriptMgr.h
- +++ b/src/server/game/Scripting/ScriptMgr.h
- @@ -190,6 +190,20 @@ template<class TObject> class UpdatableScript
- virtual void OnUpdate(TObject* /*obj*/, uint32 /*diff*/) { }
- };
- +class UnitScript : public ScriptObject
- +{
- + protected:
- +
- + UnitScript(const char* name);
- +
- + public:
- +
- + virtual uint32 DealDamage(Unit* AttackerUnit, Unit *pVictim, uint32 damage, DamageEffectType damagetype) { return damage;}
- + virtual uint32 HandlePeriodicDamageAurasTick(Unit* target, Unit* caster, int32 damage) { return damage; }
- + virtual void CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType, bool crit) { }
- + virtual void CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType) { }
- +};
- +
- class SpellScriptLoader : public ScriptObject
- {
- protected:
- @@ -272,6 +286,9 @@ class WorldScript : public ScriptObject
- // Called when the world is actually shut down.
- virtual void OnShutdown() { }
- +
- + // Called at End of SetInitialWorldSettings.
- + virtual void SetInitialWorldSettings() { }
- };
- class FormulaScript : public ScriptObject
- @@ -344,6 +361,21 @@ template<class TMap> class MapScript : public UpdatableScript<TMap>
- virtual void OnUpdate(TMap* /*map*/, uint32 /*diff*/) { }
- };
- +class AllMapScript : public ScriptObject
- +{
- + protected:
- +
- + AllMapScript(const char* name);
- +
- + public:
- +
- + // Called when a player enters any Map
- + virtual void OnPlayerEnterAll(Map* /*map*/, Player* /*player*/) { }
- +
- + // Called when a player leave any Map
- + virtual void OnPlayerLeaveAll(Map* /*map*/, Player* /*player*/) { }
- +};
- +
- class WorldMapScript : public ScriptObject, public MapScript<Map>
- {
- protected:
- @@ -436,6 +468,21 @@ class CreatureScript : public ScriptObject, public UpdatableScript<Creature>
- virtual CreatureAI* GetAI(Creature* /*creature*/) const { return NULL; }
- };
- +class AllCreatureScript : public ScriptObject
- +{
- + protected:
- +
- + AllCreatureScript(const char* name);
- +
- + public:
- +
- + // Called from End of Creature Update.
- + virtual void OnAllCreatureUpdate(Creature* /*creature*/, uint32 /*diff*/) { }
- +
- + // Called from End of Creature SelectLevel.
- + virtual void Creature_SelectLevel(const CreatureTemplate* /*cinfo*/, Creature* /*creature*/) { }
- +};
- +
- class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
- {
- protected:
- @@ -822,6 +869,13 @@ class ScriptMgr
- ScriptMgr();
- virtual ~ScriptMgr();
- + public: /* UnitScriptLoader */
- +
- + uint32 DealDamage(Unit* AttackerUnit, Unit *pVictim,uint32 damage,DamageEffectType damagetype);
- + uint32 HandlePeriodicDamageAurasTick(Unit* target, Unit* caster, int32 damage);
- + void CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType, bool crit);
- + void CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType);
- +
- public: /* Initialization */
- void Initialize();
- @@ -837,6 +891,10 @@ class ScriptMgr
- void Unload();
- + public: /* {VAS} Script Hooks */
- +
- + float VAS_Script_Hooks();
- +
- public: /* SpellScriptLoader */
- void CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector);
- @@ -863,6 +921,7 @@ class ScriptMgr
- void OnWorldUpdate(uint32 diff);
- void OnStartup();
- void OnShutdown();
- + void SetInitialWorldSettings();
- public: /* FormulaScript */
- @@ -874,6 +933,11 @@ class ScriptMgr
- void OnGainCalculation(uint32& gain, Player* player, Unit* unit);
- void OnGroupRateCalculation(float& rate, uint32 count, bool isRaid);
- + public: /* AllScript */
- +
- + void OnPlayerEnterMapAll(Map* map, Player* player);
- + void OnPlayerLeaveMapAll(Map* map, Player* player);
- +
- public: /* MapScript */
- void OnCreateMap(Map* map);
- @@ -895,6 +959,11 @@ class ScriptMgr
- bool OnItemUse(Player* player, Item* item, SpellCastTargets const& targets);
- bool OnItemExpire(Player* player, ItemTemplate const* proto);
- + public: /* AllCreatureScript */
- +
- + void OnAllCreatureUpdate(Creature* creature, uint32 diff);
- + void Creature_SelectLevel(const CreatureTemplate *cinfo, Creature* creature);
- +
- public: /* CreatureScript */
- bool OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Creature* target);
- diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
- index bca26bd..5788edb 100755
- --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
- +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
- @@ -6172,6 +6172,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
- // ignore non positive values (can be result apply spellmods to aura damage
- uint32 damage = std::max(GetAmount(), 0);
- + damage = sScriptMgr->HandlePeriodicDamageAurasTick(target, caster, damage);
- if (GetAuraType() == SPELL_AURA_PERIODIC_DAMAGE)
- {
- diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
- index ea74b6d..d0be8c0 100755
- --- a/src/server/game/World/World.cpp
- +++ b/src/server/game/World/World.cpp
- @@ -1201,6 +1201,21 @@ void World::LoadConfigSettings(bool reload)
- m_bool_configs[CONFIG_PDUMP_NO_PATHS] = ConfigMgr::GetBoolDefault("PlayerDump.DisallowPaths", true);
- m_bool_configs[CONFIG_PDUMP_NO_OVERWRITE] = ConfigMgr::GetBoolDefault("PlayerDump.DisallowOverwrite", true);
- + m_int_configs[VAS_VasDebug] = ConfigMgr::GetIntDefault ("VAS.AutoBalance.Debug", 1);
- + m_int_configs[VAS_AutoInstance] = ConfigMgr::GetIntDefault ("VAS.AutoBalance.AutoInstance", 1);
- + m_int_configs[VAS_PlayerChangeNotify] = ConfigMgr::GetIntDefault ("VAS.AutoBalance.PlayerChangeNotify", 1);
- +
- + m_float_configs[VAS_Config_xPlayer] = ConfigMgr::GetFloatDefault("VAS.AutoBalance.XPlayer", 1.0f);
- + m_float_configs[VAS_Min_D_Mod] = ConfigMgr::GetFloatDefault("Min.D.Mod", 0.10f);
- + m_float_configs[VAS_Min_HP_Mod] = ConfigMgr::GetFloatDefault("Min.HP.Mod", 0.20f);
- +
- + std::string VAS_AutoBalance_40_Name = ConfigMgr::GetStringDefault("VAS.AutoBalance.40.Name", "");
- + std::string VAS_AutoBalance_25_Name = ConfigMgr::GetStringDefault("VAS.AutoBalance.25.Name", "");
- + std::string VAS_AutoBalance_20_Name = ConfigMgr::GetStringDefault("VAS.AutoBalance.20.Name", "");
- + std::string VAS_AutoBalance_10_Name = ConfigMgr::GetStringDefault("VAS.AutoBalance.10.Name", "");
- + std::string VAS_AutoBalance_5_Name = ConfigMgr::GetStringDefault("VAS.AutoBalance.5.Name", "");
- + std::string VAS_AutoBalance_2_Name = ConfigMgr::GetStringDefault("VAS.AutoBalance.2.Name", "");
- +
- // call ScriptMgr if we're reloading the configuration
- m_bool_configs[CONFIG_WINTERGRASP_ENABLE] = ConfigMgr::GetBoolDefault("Wintergrasp.Enable", false);
- m_int_configs[CONFIG_WINTERGRASP_PLR_MAX] = ConfigMgr::GetIntDefault("Wintergrasp.PlayerMax", 100);
- @@ -1763,6 +1778,8 @@ void World::SetInitialWorldSettings()
- uint32 startupDuration = GetMSTimeDiffToNow(startupBegin);
- + sScriptMgr->SetInitialWorldSettings();
- +
- sLog->outInfo(LOG_FILTER_WORLDSERVER, "World initialized in %u minutes %u seconds", (startupDuration / 60000), ((startupDuration % 60000) / 1000));
- sLog->EnableDBAppenders();
- }
- diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
- index a6cdd47..3f0ce51 100755
- --- a/src/server/game/World/World.h
- +++ b/src/server/game/World/World.h
- @@ -181,6 +181,9 @@ enum WorldFloatConfigs
- CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS,
- CONFIG_THREAT_RADIUS,
- CONFIG_CHANCE_OF_GM_SURVEY,
- + VAS_Config_xPlayer,
- + VAS_Min_D_Mod,
- + VAS_Min_HP_Mod,
- FLOAT_CONFIG_VALUE_COUNT
- };
- @@ -319,6 +322,9 @@ enum WorldIntConfigs
- CONFIG_WARDEN_CLIENT_BAN_DURATION,
- CONFIG_WARDEN_NUM_MEM_CHECKS,
- CONFIG_WARDEN_NUM_OTHER_CHECKS,
- + VAS_VasDebug,
- + VAS_AutoInstance,
- + VAS_PlayerChangeNotify,
- CONFIG_WINTERGRASP_PLR_MAX,
- CONFIG_WINTERGRASP_PLR_MIN,
- CONFIG_WINTERGRASP_PLR_MIN_LVL,
- @@ -617,6 +623,14 @@ class World
- /// Get the path where data (dbc, maps) are stored on disk
- std::string GetDataPath() const { return m_dataPath; }
- + /// Return the Mob IDs to be Autobalanced
- + std::string GetVAS40() const { return VAS_AutoBalance_40_Name; }
- + std::string GetVAS25() const { return VAS_AutoBalance_25_Name; }
- + std::string GetVAS20() const { return VAS_AutoBalance_20_Name; }
- + std::string GetVAS10() const { return VAS_AutoBalance_10_Name; }
- + std::string GetVAS5() const { return VAS_AutoBalance_5_Name; }
- + std::string GetVAS2() const { return VAS_AutoBalance_2_Name; }
- +
- /// When server started?
- time_t const& GetStartTime() const { return m_startTime; }
- /// What time is it?
- @@ -779,6 +793,15 @@ class World
- private:
- static ACE_Atomic_Op<ACE_Thread_Mutex, bool> m_stopEvent;
- static uint8 m_ExitCode;
- +
- + std::string VAS_AutoBalance_40_Name;
- + std::string VAS_AutoBalance_25_Name;
- + std::string VAS_AutoBalance_20_Name;
- + std::string VAS_AutoBalance_10_Name;
- + std::string VAS_AutoBalance_5_Name;
- + std::string VAS_AutoBalance_2_Name;
- + std::string VAS_color;
- +
- uint32 m_ShutdownTimer;
- uint32 m_ShutdownMask;
- diff --git a/src/server/scripts/Custom/CMakeLists.txt b/src/server/scripts/Custom/CMakeLists.txt
- index 62abde2..7c59d51 100644
- --- a/src/server/scripts/Custom/CMakeLists.txt
- +++ b/src/server/scripts/Custom/CMakeLists.txt
- @@ -7,9 +7,9 @@
- # This program is distributed in the hope that it will be useful, but
- # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
- # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- -
- set(scripts_STAT_SRCS
- ${scripts_STAT_SRCS}
- + Custom/VAS_AutoBalance.cpp
- )
- message(" -> Prepared: Custom")
- diff --git a/src/server/scripts/Custom/VAS_AutoBalance.cpp b/src/server/scripts/Custom/VAS_AutoBalance.cpp
- new file mode 100644
- index 0000000..149101e
- --- /dev/null
- +++ b/src/server/scripts/Custom/VAS_AutoBalance.cpp
- @@ -0,0 +1,499 @@
- +/*
- + * Copyright (C) 2012 CVMagic <http://www.trinitycore.org/f/topic/6551-vas-autobalance/>
- + * Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
- + * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
- + * Copyright (C) 1985-2010 {VAS} KalCorp <http://vasserver.dyndns.org/>
- + *
- + * This program is free software; you can redistribute it and/or modify it
- + * under the terms of the GNU General Public License as published by the
- + * Free Software Foundation; either version 2 of the License, or (at your
- + * option) any later version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- + * more details.
- + *
- + * You should have received a copy of the GNU General Public License along
- + * with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +/*
- + * Script Name: AutoBalance
- + * Original Authors: KalCorp and Vaughner
- + * Maintainer(s): CVMagic
- + * Original Script Name: VAS.AutoBalance
- + * Description: This script is intended to scale based on number of players, instance mobs & world bosses' health, mana, and damage.
- + */
- +
- +
- +#include "ScriptPCH.h"
- +#include "Configuration/Config.h"
- +#include "MapManager.h"
- +#include "Map.h"
- +#include <vector>
- +
- +#define BOOL_TO_STRING(b) ((b)? "true":"false")
- +
- +struct AutoBalanceCreatureInfo
- +{
- + uint32 instancePlayerCount;
- + float DamageMultiplier;
- +};
- +
- +static std::map<uint32, AutoBalanceCreatureInfo> CreatureInfo; // A hook should be added to remove the mapped entry when the creature is dead or this should be added into the creature object
- +static std::map<int, int> forcedCreatureIds; // The map values correspond with the VAS.AutoBalance.XX.Name entries in the configuration file.
- +
- +int GetValidDebugLevel()
- +{
- + int debugLevel = sWorld->getIntConfig(VAS_VasDebug);
- +
- + if ((debugLevel < 0) || (debugLevel > 3))
- + {
- + return 1;
- + }
- + return debugLevel;
- +}
- +
- +void LoadForcedCreatureIdsFromString(std::string creatureIds, int forcedPlayerCount) // Used for reading the string from the configuration file to for those creatures who need to be scaled for XX number of players.
- +{
- + std::string delimitedValue;
- + std::stringstream creatureIdsStream;
- +
- + creatureIdsStream.str(creatureIds);
- + while (std::getline(creatureIdsStream, delimitedValue, ',')) // Process each Creature ID in the string, delimited by the comma - ","
- + {
- + int creatureId = atoi(delimitedValue.c_str());
- + if (creatureId >= 0)
- + {
- + forcedCreatureIds[creatureId] = forcedPlayerCount;
- + }
- + }
- +}
- +
- +int GetForcedCreatureId(int creatureId)
- +{
- + if(forcedCreatureIds.find(creatureId) == forcedCreatureIds.end()) // Don't want the forcedCreatureIds map to blowup to a massive empty array
- + {
- + return 0;
- + }
- + return forcedCreatureIds[creatureId];
- +}
- +
- +class VAS_AutoBalance_WorldScript : public WorldScript
- +{
- + public:
- + VAS_AutoBalance_WorldScript()
- + : WorldScript("VAS_AutoBalance_WorldScript")
- + {
- + }
- +
- + void OnConfigLoad(bool /*reload*/)
- + {
- + }
- +
- + void OnStartup()
- + {
- + }
- +
- + void SetInitialWorldSettings()
- + {
- + // Load from the VAS.AutoBalance.XX.Name entries in the Configuration File
- + forcedCreatureIds.clear();
- + LoadForcedCreatureIdsFromString(sWorld->GetVAS40(), 40);
- + LoadForcedCreatureIdsFromString(sWorld->GetVAS25(), 25);
- + LoadForcedCreatureIdsFromString(sWorld->GetVAS10(), 10);
- + LoadForcedCreatureIdsFromString(sWorld->GetVAS5(), 5);
- + LoadForcedCreatureIdsFromString(sWorld->GetVAS2(), 2);
- +
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, "----------------------------------------------------");
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, " Powered by {VAS} AutoBalance");
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, "----------------------------------------------------");
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, " xPlayer = %4.1f ", sWorld->getFloatConfig(VAS_Config_xPlayer));
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, " AutoInstance = %u ", sWorld->getIntConfig(VAS_AutoInstance));
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, " PlayerChangeNotify = %u ", sWorld->getIntConfig(VAS_PlayerChangeNotify));
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, " Min.D.Mod = %4.2f ", sWorld->getFloatConfig(VAS_Min_D_Mod));
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, " Min.HP.Mod = %4.2f ", sWorld->getFloatConfig(VAS_Min_HP_Mod));
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, " VasDebug = %u ", GetValidDebugLevel());
- + sLog->outInfo(LOG_FILTER_WORLDSERVER, "----------------------------------------------------\n");
- + }
- +
- +};
- +
- +class VAS_AutoBalance_PlayerScript : public PlayerScript
- +{
- + public:
- + VAS_AutoBalance_PlayerScript()
- + : PlayerScript("VAS_AutoBalance_PlayerScript")
- + {
- + }
- +
- + void OnLogin(Player *Player)
- + {
- +
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_PLAYER_LOADING, "### VAS_AutoBalance_PlayerScript - OnLogin Player=%s", Player->GetName());
- + }
- +};
- +
- +class VAS_AutoBalance_UnitScript : public UnitScript
- +{
- + public:
- + VAS_AutoBalance_UnitScript()
- + : UnitScript("VAS_AutoBalance_UnitScript")
- + {
- + }
- +
- + uint32 DealDamage(Unit* AttackerUnit, Unit *playerVictim, uint32 damage, DamageEffectType damagetype)
- + {
- + if (AttackerUnit->GetMap()->IsDungeon() && playerVictim->GetMap()->IsDungeon())
- + if (AttackerUnit->GetTypeId() != TYPEID_PLAYER)
- + {
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_TSCR, "### VAS_AutoBalance_UnitScript - VAS_Unit_DealDamage Attacker=%s Victim=%s Start Damage=%u",AttackerUnit->GetName(),playerVictim->GetName(),damage);
- + damage = VAS_Modifer_DealDamage(AttackerUnit,damage);
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_TSCR, "### VAS_AutoBalance_UnitScript - VAS_Unit_DealDamage Attacker=%s Victim=%s End Damage=%u",AttackerUnit->GetName(),playerVictim->GetName(),damage);
- + }
- + return damage;
- + }
- +
- + uint32 HandlePeriodicDamageAurasTick(Unit* target, Unit* caster, int32 damage)
- + {
- + if (caster->GetMap()->IsDungeon() && target->GetMap()->IsDungeon())
- + if (caster->GetTypeId() != TYPEID_PLAYER)
- + {
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_TSCR, "### VAS_AutoBalance_UnitScript - VAS_Unit_HandlePeriodicDamage Attacker=%s Victim=%s Start Damage=%u",caster->GetName(),target->GetName(),damage);
- +
- + if (!((caster->isHunterPet() || caster->isPet() || caster->isSummon()) && caster->IsControlledByPlayer()))
- + damage = (float)damage * (float)CreatureInfo[caster->GetGUID()].DamageMultiplier;
- +
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_TSCR, "### VAS_AutoBalance_UnitScript - VAS_Unit_HandlePeriodicDamage Attacker=%s Victim=%s End Damage=%u",caster->GetName(),target->GetName(),damage);
- + }
- + return damage;
- + }
- +
- + void CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType, bool crit)
- + {
- + if ((damageInfo->attacker->GetMap()->IsDungeon() && damageInfo->target->GetMap()->IsDungeon()) || ( damageInfo->attacker->GetMap()->IsBattleground() && damageInfo->target->GetMap()->IsBattleground()))
- + {
- + if (damageInfo->attacker->GetTypeId() != TYPEID_PLAYER)
- + {
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_TSCR, "### VAS_AutoBalance_UnitScript - CalculateSpellDamageTaken Attacker=%s Victim=%s Start Damage=%u",damageInfo->attacker->GetName(),damageInfo->target->GetName(),damageInfo->damage);
- +
- + if ((damageInfo->attacker->isHunterPet() || damageInfo->attacker->isPet() || damageInfo->attacker->isSummon()) && damageInfo->attacker->IsControlledByPlayer())
- + return;
- +
- + damageInfo->damage = (float)damageInfo->damage * (float)CreatureInfo[damageInfo->attacker->GetGUID()].DamageMultiplier;
- +
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_TSCR, "### VAS_AutoBalance_UnitScript - CalculateSpellDamageTaken Attacker=%s Victim=%s End Damage=%u",damageInfo->attacker->GetName(),damageInfo->target->GetName(),damageInfo->damage);
- + }
- + }
- + return;
- + }
- +
- + void CalculateMeleeDamage(Unit *playerVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType)
- + {
- + // Make sure the Attacker and the Victim are in the same location, in addition that the attacker is not player.
- + if (((damageInfo->attacker->GetMap()->IsDungeon() && damageInfo->target->GetMap()->IsDungeon()) || (damageInfo->attacker->GetMap()->IsBattleground() && damageInfo->target->GetMap()->IsBattleground())) && (damageInfo->attacker->GetTypeId() != TYPEID_PLAYER))
- + if (!((damageInfo->attacker->isHunterPet() || damageInfo->attacker->isPet() || damageInfo->attacker->isSummon()) && damageInfo->attacker->IsControlledByPlayer())) // Make sure that the attacker is not a Pet of some sort
- + {
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_TSCR, "### VAS_AutoBalance_UnitScript - CalculateMeleeDamage Attacker=%s Victim=%s Start Damage=%u",damageInfo->attacker->GetName(),damageInfo->target->GetName(),damageInfo->damage);
- +
- + damageInfo->damage = (float)damageInfo->damage * (float)CreatureInfo[damageInfo->attacker->GetGUID()].DamageMultiplier;
- +
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_TSCR, "### VAS_AutoBalance_UnitScript - CalculateMeleeDamage Attacker=%s Victim=%s End Damage=%u",damageInfo->attacker->GetName(),damageInfo->target->GetName(),damageInfo->damage);
- + }
- + return;
- + }
- +
- + uint32 VAS_Modifer_DealDamage(Unit* AttackerUnit,uint32 damage)
- + {
- + if ((AttackerUnit->isHunterPet() || AttackerUnit->isPet() || AttackerUnit->isSummon()) && AttackerUnit->IsControlledByPlayer())
- + return damage;
- +
- + float damageMultiplier = CreatureInfo[AttackerUnit->GetGUID()].DamageMultiplier;
- +
- + return damage * damageMultiplier;
- +
- + }
- +
- +};
- +
- +
- +class VAS_AutoBalance_AllMapScript : public AllMapScript
- +{
- + public:
- + VAS_AutoBalance_AllMapScript()
- + : AllMapScript("VAS_AutoBalance_AllMapScript")
- + {
- + }
- +
- + void OnPlayerEnterAll(Map* map, Player* player)
- + {
- + if (GetValidDebugLevel() >= 2)
- + {
- + sLog->outInfo(LOG_FILTER_TSCR, "----------------------------------------------------");
- + sLog->outInfo(LOG_FILTER_TSCR, "## VAS_AutoBalance_AllMapScript - OnPlayerEnterAll");
- + sLog->outInfo(LOG_FILTER_TSCR, "## For InsatanceID %u",map->GetInstanceId());
- + sLog->outInfo(LOG_FILTER_TSCR, "## IsDungeon= %u",map->GetEntry()->IsDungeon());
- + sLog->outInfo(LOG_FILTER_TSCR, "## For Map %u",player->GetMapId());
- + sLog->outInfo(LOG_FILTER_TSCR, "## PlayersInMap %u",map->GetPlayersCountExceptGMs());
- + sLog->outInfo(LOG_FILTER_TSCR, "## pDifficulty %u",uint32(player->GetDifficulty(player->GetMap()->IsHeroic())));
- + sLog->outInfo(LOG_FILTER_TSCR, "## pGetDungeonDifficulty %u",uint32(player->GetDungeonDifficulty()));
- + sLog->outInfo(LOG_FILTER_TSCR, "## pGetRaidDifficulty %u",uint32(player->GetRaidDifficulty()));
- + sLog->outInfo(LOG_FILTER_TSCR, "## maxPlayers %u",((InstanceMap*)sMapMgr->FindMap(player->GetMapId(), player->GetInstanceId()))->GetMaxPlayers());
- + sLog->outInfo(LOG_FILTER_TSCR, "## IsHeroic=%s IsRaid=%s IsRegularDifficulty=%s IsRaidOrHeroicDungeon=%s IsNonRaidDungeon=%s",BOOL_TO_STRING(player->GetMap()->IsHeroic()),BOOL_TO_STRING(player->GetMap()->IsRaid()),BOOL_TO_STRING(player->GetMap()->IsRegularDifficulty()),BOOL_TO_STRING(player->GetMap()->IsRaidOrHeroicDungeon()),BOOL_TO_STRING(player->GetMap()->IsNonRaidDungeon()));
- + sLog->outInfo(LOG_FILTER_TSCR, "----------------------------------------------------\n");
- + }
- +
- + if (sWorld->getIntConfig(VAS_PlayerChangeNotify) >= 1)
- + {
- + if ((map->GetEntry()->IsDungeon()) && !player->isGameMaster() )
- + {
- + Map::PlayerList const &playerList = map->GetPlayers();
- + if (!playerList.isEmpty())
- + {
- + for (Map::PlayerList::const_iterator playerIteration = playerList.begin(); playerIteration != playerList.end(); ++playerIteration)
- + {
- + if (Player* playerHandle = playerIteration->getSource())
- + {
- + ChatHandler chatHandle = ChatHandler(playerHandle);
- + chatHandle.PSendSysMessage("|cffFF0000 [AutoBalance]|r|cffFF8000 %s entered the Instance %s. Auto setting player count to %u |r",player->GetName(),map->GetMapName(),map->GetPlayersCountExceptGMs());
- + }
- + }
- + }
- + }
- + }
- + }
- +
- + void OnPlayerLeaveAll(Map* map, Player* player)
- + {
- +
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_TSCR, "#### VAS_AutoBalance_AllMapScript - OnPlayerLeaveAll map=%s player=%s", map->GetMapName(),player->GetName());
- +
- + int instancePlayerCount = map->GetPlayersCountExceptGMs() - 1;
- +
- + if (instancePlayerCount >=1)
- + {
- + if (GetValidDebugLevel() >= 2)
- + {
- + sLog->outInfo(LOG_FILTER_TSCR, "----------------------------------------------------");
- + sLog->outInfo(LOG_FILTER_TSCR, "## VAS_AutoBalance_AllMapScript - OnPlayerLeaveAll");
- + sLog->outInfo(LOG_FILTER_TSCR, "## For InsatanceID %u",map->GetInstanceId());
- + sLog->outInfo(LOG_FILTER_TSCR, "## IsDungeon= %u",map->GetEntry()->IsDungeon());
- + sLog->outInfo(LOG_FILTER_TSCR, "## For Map %u",player->GetMapId());
- + sLog->outInfo(LOG_FILTER_TSCR, "## PlayersInMap %u",instancePlayerCount);
- + sLog->outInfo(LOG_FILTER_TSCR, "----------------------------------------------------\n");
- + }
- +
- + if (sWorld->getIntConfig(VAS_PlayerChangeNotify) >= 1)
- + {
- + if ((map->GetEntry()->IsDungeon()) && !player->isGameMaster())
- + {
- + Map::PlayerList const &playerList = map->GetPlayers();
- + if (!playerList.isEmpty())
- + {
- + for (Map::PlayerList::const_iterator playerIteration = playerList.begin(); playerIteration != playerList.end(); ++playerIteration)
- + {
- + if (Player* playerHandle = playerIteration->getSource())
- + {
- + ChatHandler chatHandle = ChatHandler(playerHandle);
- + chatHandle.PSendSysMessage("|cffFF0000 [VAS-AutoBalance]|r|cffFF8000 %s left the Instance %s. Auto setting player count to %u |r",player->GetName(),map->GetMapName(),instancePlayerCount);
- + }
- + }
- + }
- + }
- + }
- + }
- + }
- +};
- +
- +class VAS_AutoBalance_WorldMapScript : public WorldMapScript
- +{
- + public:
- + VAS_AutoBalance_WorldMapScript()
- + : WorldMapScript("VAS_AutoBalance_WorldMapScript",0)
- + {
- + }
- +
- + void OnPlayerEnter(Map* map, Player* player)
- + {
- +
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_TSCR, "### VAS_AutoBalance_WorldMapScript - OnPlayerEnter Map=%s player=%s",map->GetMapName(),player->GetName());
- + }
- +
- + void OnPlayerLeave(Map* map, Player* player)
- + {
- +
- + if (GetValidDebugLevel() >= 3)
- + sLog->outInfo(LOG_FILTER_TSCR, "### VAS_AutoBalance_WorldMapScript - OnPlayerLeave Map=%s player=%s",map->GetMapName(),player->GetName());
- + }
- +};
- +
- +
- +class VAS_AutoBalance_AllCreatureScript : public AllCreatureScript
- +{
- + public:
- + VAS_AutoBalance_AllCreatureScript()
- + : AllCreatureScript("VAS_AutoBalance_AllCreatureScript")
- + {
- + }
- +
- +
- + void Creature_SelectLevel(const CreatureTemplate *creatureTemplate, Creature* creature)
- + {
- +
- + if (creature->GetMap()->IsDungeon())
- + {
- + ModifyCreatureAttributes(creature);
- + CreatureInfo[creature->GetGUID()].instancePlayerCount = creature->GetMap()->GetPlayersCountExceptGMs();
- + }
- + }
- +
- + void OnAllCreatureUpdate(Creature* creature, uint32 diff)
- + {
- + if(!(CreatureInfo[creature->GetGUID()].instancePlayerCount == creature->GetMap()->GetPlayersCountExceptGMs()))
- + {
- + if (creature->GetMap()->IsDungeon() || creature->GetMap()->IsBattleground())
- + ModifyCreatureAttributes(creature);
- + CreatureInfo[creature->GetGUID()].instancePlayerCount = creature->GetMap()->GetPlayersCountExceptGMs();
- + }
- + }
- +
- + void ModifyCreatureAttributes(Creature* creature)
- + {
- + if(((creature->isHunterPet() || creature->isPet() || creature->isSummon()) && creature->IsControlledByPlayer()) || sWorld->getIntConfig(VAS_AutoInstance) < 1 || creature->GetMap()->GetPlayersCountExceptGMs() <= 0)
- + {
- + return;
- + }
- +
- + CreatureTemplate const *creatureTemplate = creature->GetCreatureTemplate();
- + CreatureBaseStats const* creatureStats = sObjectMgr->GetCreatureBaseStats(creature->getLevel(), creatureTemplate->unit_class);
- +
- + float damageMultiplier = 1.0f;
- + float healthMultiplier = 1.0f;
- +
- + uint32 baseHealth = creatureStats->GenerateHealth(creatureTemplate);
- + uint32 baseMana = creatureStats->GenerateMana(creatureTemplate);
- + uint32 instancePlayerCount = creature->GetMap()->GetPlayersCountExceptGMs();
- + uint32 maxNumberOfPlayers = ((InstanceMap*)sMapMgr->FindMap(creature->GetMapId(), creature->GetInstanceId()))->GetMaxPlayers();
- + uint32 scaledHealth = 0;
- + uint32 scaledMana = 0;
- +
- + // VAS SOLO - By MobID
- + if(GetForcedCreatureId(creatureTemplate->Entry) > 0)
- + {
- + maxNumberOfPlayers = GetForcedCreatureId(creatureTemplate->Entry); // Force maxNumberOfPlayers to be changed to match the Configuration entry.
- + }
- +
- + // (tanh((X-2.2)/1.5) +1 )/2 // 5 Man formula X = Number of Players
- + // (tanh((X-5)/2) +1 )/2 // 10 Man Formula X = Number of Players
- + // (tanh((X-16.5)/6.5) +1 )/2 // 25 Man Formula X = Number of players
- + //
- + // Note: The 2.2, 5, and 16.5 are the number of players required to get 50% health.
- + // It's not required this be a whole number, you'd adjust this to raise or lower
- + // the hp modifier for per additional player in a non-whole group. These
- + // values will eventually be part of the configuration file once I finalize the mod.
- + //
- + // The 1.5, 2, and 6.5 modify the rate of percentage increase between
- + // number of players. Generally the closer to the value of 1 you have this
- + // the less gradual the rate will be. For example in a 5 man it would take 3
- + // total players to face a mob at full health.
- + //
- + // The +1 and /2 values raise the TanH function to a positive range and make
- + // sure the modifier never goes above the value or 1.0 or below 0.
- + //
- + // Lastly this formula has one side effect on full groups Bosses and mobs will
- + // never have full health, this can be tested against by making sure the number
- + // of players match the maxNumberOfPlayers variable.
- +
- + switch (maxNumberOfPlayers)
- + {
- + case 40:
- + healthMultiplier = (float)instancePlayerCount / (float)maxNumberOfPlayers; // 40 Man Instances oddly enough scale better with the old formula
- + break;
- + case 25:
- + healthMultiplier = (tanh((instancePlayerCount - 16.5f) / 1.5f) + 1.0f) / 2.0f;
- + break;
- + case 10:
- + healthMultiplier = (tanh((instancePlayerCount - 4.5f) / 1.5f) + 1.0f) / 2.0f;
- + break;
- + case 2:
- + healthMultiplier = (float)instancePlayerCount / (float)maxNumberOfPlayers; // Two Man Creatures are too easy if handled by the 5 man formula, this would only
- + break; // apply in the situation where it's specified in the configuration file.
- + default:
- + healthMultiplier = (tanh((instancePlayerCount - 2.2f) / 1.5f) + 1.0f) / 2.0f; // default to a 5 man group
- + }
- +
- + // VAS SOLO - Map 0,1 and 530 ( World Mobs ) // This may be where VAS_AutoBalance_CheckINIMaps might have come into play. None the less this is
- + if((creature->GetMapId() == 0 || creature->GetMapId() == 1 || creature->GetMapId() == 530) && (creature->isElite() || creature->isWorldBoss())) // specific to World Bosses and elites in those Maps, this is going to use the entry XPlayer in place of instancePlayerCount.
- + {
- + if(baseHealth > 800000){
- + healthMultiplier = (tanh((sWorld->getFloatConfig(VAS_Config_xPlayer) - 5.0f) / 1.5f) + 1.0f) / 2.0f;
- + }else{
- + healthMultiplier = (tanh((sWorld->getFloatConfig(VAS_Config_xPlayer) - 2.2f) / 1.5f) + 1.0f) / 2.0f; // Assuming a 5 man configuration, as World Bosses have been relatively retired since BC so unless the boss has some substantial baseHealth
- + }
- +
- + }
- +
- + // Ensure that the healthMultiplier is not lower than the configuration specified value. -- This may be Deprecated later.
- + if(healthMultiplier <= sWorld->getFloatConfig(VAS_Min_HP_Mod) )
- + {
- + healthMultiplier = sWorld->getFloatConfig(VAS_Min_HP_Mod);
- + }
- +
- + //Getting the list of Classes in this group - this will be used later on to determine what additional scaling will be required based on the ratio of tank/dps/healer
- + //GetPlayerClassList(creature, playerClassList); // Update playerClassList with the list of all the participating Classes
- +
- +
- + scaledHealth = uint32((baseHealth * healthMultiplier) + 1.0f);
- + // Now adjusting Mana, Mana is something that can be scaled linearly
- + scaledMana = ((baseMana/maxNumberOfPlayers) * instancePlayerCount);
- + // Now Adjusting Damage, this too is linear for now .... this will have to change I suspect.
- + damageMultiplier = (float)instancePlayerCount / (float)maxNumberOfPlayers;
- +
- + // Can not be less then Min_D_Mod
- + if(damageMultiplier <= sWorld->getFloatConfig(VAS_Min_D_Mod))
- + {
- + damageMultiplier = sWorld->getFloatConfig(VAS_Min_D_Mod);
- + }
- +
- + if((GetValidDebugLevel() >= 3))
- + {
- + sLog->outInfo(LOG_FILTER_TSCR, "## VAS-AutoBalance MobID=%u MapID=%u creatureName=%s GUID=%llu instancePlayerCount=%u", creatureTemplate->Entry, creature->GetMapId(), creatureTemplate->Name.c_str(), creature->GetGUID(), instancePlayerCount);
- + sLog->outInfo(LOG_FILTER_TSCR, "## VAS-AutoBalance MapDifficulty=%u Health=%u / %u healthMultiplier=%4.5f", creature->GetMap()->GetDifficulty(), scaledHealth, baseHealth, healthMultiplier);
- + sLog->outInfo(LOG_FILTER_TSCR, "## VAS-AutoBalance maxNumberOfPlayers=%u IsRaid=%s", maxNumberOfPlayers, BOOL_TO_STRING(creature->GetMap()->IsRaid()));
- + sLog->outInfo(LOG_FILTER_TSCR, "## VAS-AutoBalance Mana %u / %u", baseMana, scaledMana);
- + sLog->outInfo(LOG_FILTER_TSCR, "## VAS-AutoBalance damageMultiplier=%4.2f", damageMultiplier);
- + }
- +
- + creature->SetCreateHealth(scaledHealth);
- + creature->SetMaxHealth(scaledHealth);
- + creature->ResetPlayerDamageReq();
- + creature->SetCreateMana(scaledMana);
- + creature->SetMaxPower(POWER_MANA, scaledMana);
- + creature->SetPower(POWER_MANA, scaledMana);
- + creature->SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, (float)scaledHealth);
- + creature->SetModifierValue(UNIT_MOD_MANA, BASE_VALUE, (float)scaledMana);
- + CreatureInfo[creature->GetGUID()].DamageMultiplier = damageMultiplier;
- + }
- +};
- +
- +void AddSC_VAS_AutoBalance()
- +{
- + new VAS_AutoBalance_WorldScript;
- + new VAS_AutoBalance_PlayerScript;
- + new VAS_AutoBalance_UnitScript;
- + new VAS_AutoBalance_AllCreatureScript;
- + new VAS_AutoBalance_AllMapScript;
- + new VAS_AutoBalance_WorldMapScript;
- +}
- diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
- index ce65517..da08d75 100644
- --- a/src/server/worldserver/worldserver.conf.dist
- +++ b/src/server/worldserver/worldserver.conf.dist
- @@ -26,6 +26,7 @@
- # CONSOLE AND REMOTE ACCESS
- # CHARACTER DELETE OPTIONS
- # CUSTOM SERVER OPTIONS
- +# VAS AUTOBALANCE OPTIONS
- # LOGGING SYSTEM SETTINGS
- #
- ###################################################################################################
- @@ -2645,6 +2646,77 @@ PlayerDump.DisallowOverwrite = 1
- ###################################################################################################
- ###################################################################################################
- +# VAS AUTOBALANCE OPTIONS
- +#
- +# VAS.AutoBalance.XPlayer
- +# Set Server to level of solo mode.
- +# Set to 0 to Disable VAS-SOLO Mod.
- +# Example: VAS.AutoBalance.XPlayer = 1 will set everything for a 1 player game.
- +# Default: 1
- +
- +VAS.AutoBalance.XPlayer = 1
- +
- +#
- +# VAS.AutoBalance.AutoInstance
- +# Set instances to Auto chance XPlayer depending on players in it.
- +# Default: 1 (1 = ON, 0 = OFF)
- +
- +VAS.AutoBalance.AutoInstance = 1
- +
- +#
- +# VAS.AutoBalance.Debug
- +# 0 = None
- +# 1 = Errors Only
- +# 2 = Errors and Basic Information
- +# 3 = All VAS Info
- +# Default: 1
- +
- +VAS.AutoBalance.Debug = 1
- +
- +#
- +# VAS.AutoBalance.PlayerChangeNotify
- +# Set Auto Notifications to all players in Instance that player count has changed.
- +# Default: 1 (1 = ON, 0 = OFF)
- +
- +VAS.AutoBalance.PlayerChangeNotify = 1
- +
- +#
- +# VAS.AutoBalance.Color
- +# In Game Color for mod information in chat window.
- +# Default: cffFF8000 (Orange)
- +
- +VAS.AutoBalance.Color = cffFF8000
- +
- +#
- +# Min.HP.Mod
- +# Minimum Modifier setting for Health Modification
- +# Default: 0.20
- +
- +Min.HP.Mod = 0.20
- +
- +#
- +# Min.D.Mod
- +# Minimum Modifier setting for Damage Modification
- +# Default: 0.10
- +
- +Min.D.Mod = 0.10
- +
- +#
- +# VAS.AutoBalance.XX.Name
- +# Sets MobIDs for the group they belong to.
- +# All 5 Man Mobs should go in VAS.AutoBalance.5.Name
- +# All 10 Man Mobs should go in VAS.AutoBalance.10.Name etc.
- +
- +VAS.AutoBalance.40.Name = "11583,16441,30057,13020,15589,14435,18192,14889,14888,14887,14890,15302,15818,15742,15741,15740,18338"
- +VAS.AutoBalance.25.Name = "22997,21966,21965,21964,21806,21215,21845,19728,12397,17711,18256,18192,"
- +VAS.AutoBalance.10.Name = "15689,15550,16152,17521,17225,16028,29324,31099"
- +VAS.AutoBalance.5.Name = "15203,15204,15205,15305,6109,26801,30508,26799,30495,26803,30497,27859,27249"
- +VAS.AutoBalance.2.Name = "25549,24558,25574,24559,25556,25557,25578,24561,25555,24555,25541,24553,25550,24554,24552,25564,15931,29373"
- +
- +#
- +###################################################################################################
- +
- +###################################################################################################
- #
- # LOGGING SYSTEM SETTINGS
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement