Skip to content

Instantly share code, notes, and snippets.

@vhiperdev
Created June 18, 2018 19:35
Show Gist options
  • Save vhiperdev/c3debb0dae1fa6f2591fddacbe311747 to your computer and use it in GitHub Desktop.
Save vhiperdev/c3debb0dae1fa6f2591fddacbe311747 to your computer and use it in GitHub Desktop.
SpellRegulator + command .reload spell_regulator for (AzerothCore)
#Attention Modify this (commit) in your repository to add the module Spell_Regulator
#MODULE SPELL_REGULATOR FOR AZEROTHCORE 2018
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index bb7a89f..9fa3fad 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -52,6 +52,7 @@
#include "ArenaSpectator.h"
#include "DynamicVisibility.h"
#include "AccountMgr.h"
+#include "../../../modules/mod-spellregulator/src/SpellRegulator.h"
#ifdef ELUNA
#include "LuaEngine.h"
@@ -690,7 +691,10 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage
// Hook for OnDamage Event
sScriptMgr->OnDamage(attacker, victim, damage);
- if (victim->GetTypeId() == TYPEID_PLAYER && attacker != victim)
+ if ((damagetype == SPELL_DIRECT_DAMAGE || damagetype == DOT) && spellProto)
+ sSpellRegulator->Regulate(damage, spellProto->Id);
+
+ if (victim->GetTypeId() == TYPEID_PLAYER && attacker != victim)
{
// Signal to pets that their owner was attacked
Pet* pet = victim->ToPlayer()->GetPet();
@@ -5578,6 +5582,7 @@ void Unit::SendSpellNonMeleeReflectLog(SpellNonMeleeDamage* log, Unit* attacker)
void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log)
{
+ sSpellRegulator->Regulate(log->damage, log->SpellID);
WorldPacket data(SMSG_SPELLNONMELEEDAMAGELOG, (16+4+4+4+1+4+4+1+1+4+4+1)); // we guess size
data.append(log->target->GetPackGUID());
data.append(log->attacker->GetPackGUID());
@@ -5624,7 +5629,7 @@ void Unit::ProcDamageAndSpell(Unit* victim, uint32 procAttacker, uint32 procVict
void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo)
{
AuraEffect const* aura = pInfo->auraEff;
-
+ sSpellRegulator->Regulate(pInfo->damage, aura->GetId());
WorldPacket data(SMSG_PERIODICAURALOG, 30);
data.append(GetPackGUID());
data.appendPackGUID(aura->GetCasterGUID());
diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp
index 13fdf2c..6aae45a 100644
--- a/src/server/scripts/Commands/cs_reload.cpp
+++ b/src/server/scripts/Commands/cs_reload.cpp
@@ -29,6 +29,7 @@ EndScriptData */
#include "TicketMgr.h"
#include "WardenCheckMgr.h"
#include "WaypointManager.h"
+#include "../../../modules/mod-spellregulator/src/SpellRegulator.h"
class reload_commandscript : public CommandScript
{
@@ -137,6 +138,7 @@ public:
{ "spell_target_position", SEC_ADMINISTRATOR, true, &HandleReloadSpellTargetPositionCommand, "" },
{ "spell_threats", SEC_ADMINISTRATOR, true, &HandleReloadSpellThreatsCommand, "" },
{ "spell_group_stack_rules", SEC_ADMINISTRATOR, true, &HandleReloadSpellGroupStackRulesCommand, "" },
+ { "spell_regulator", SEC_ADMINISTRATOR, true, &HandleReloadSpellRegulator, "" },
{ "trinity_string", SEC_ADMINISTRATOR, true, &HandleReloadTrinityStringCommand, "" },
{ "warden_action", SEC_ADMINISTRATOR, true, &HandleReloadWardenactionCommand, "" },
{ "waypoint_scripts", SEC_ADMINISTRATOR, true, &HandleReloadWpScriptsCommand, "" },
@@ -185,6 +187,7 @@ public:
HandleReloadAutobroadcastCommand(handler, "");
HandleReloadBroadcastTextCommand(handler, "");
HandleReloadBattlegroundTemplate(handler, "");
+ HandleReloadSpellRegulator(handler, "");
return true;
}
@@ -904,6 +907,15 @@ public:
return true;
}
+ static bool HandleReloadSpellRegulator(ChatHandler* handler, char const* /*args*/)
+ {
+ #define sSpellRegulator SpellRegulator::instance()
+
+ sSpellRegulator->LoadFromDB();
+ handler->SendGlobalGMSysMessage("DB table `spell_regulator` reloaded.");
+ return true;
+ }
+
static bool HandleReloadSpellPetAurasCommand(ChatHandler* handler, const char* /*args*/)
{
sLog->outString("Re-Loading Spell pet auras...");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment