Merge branch '4.3.4' into '4.3.4'

Spell system ports from 335

See merge request !43
This commit is contained in:
Aokromes committed 2017-05-28 18:26:31 +00:00
commit 36b4834ba3
85 files changed
+7549 -6158

No files matched your search

@@ -0,0 +1 @@
DELETE FROM `rbac_permissions` WHERE `id` = 698;
@@ -0,0 +1,6 @@
DELETE FROM `spell_linked_spell` WHERE `spell_trigger` IN (7744, 42292, 59752);
DELETE FROM `spell_script_names` WHERE `ScriptName` IN ('spell_pvp_trinket_wotf_shared_cd','spell_wotf_shared_cd','spell_pvp_trinket_shared_cd');
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(7744, 'spell_wotf_shared_cd'),
(42292, 'spell_pvp_trinket_shared_cd'),
(59752, 'spell_pvp_trinket_shared_cd');
@@ -0,0 +1,3 @@
DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_paralytic_poison';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(35201, 'spell_gen_paralytic_poison');
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,4 @@
DELETE FROM spell_script_names WHERE spell_id IN (45051, 53750);
INSERT INTO spell_script_names (spell_id, ScriptName) VALUES
(45051, 'spell_item_mad_alchemists_potion'),
(53750, 'spell_item_crazy_alchemists_potion');
@@ -0,0 +1,6 @@
UPDATE `spell_proc` SET `AttributesMask`=(`AttributesMask` & ~0x10) WHERE `SpellId` IN (32216, 56817);
DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_gen_proc_charge_drop_only';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(32216, 'spell_gen_proc_charge_drop_only'),
(56817, 'spell_gen_proc_charge_drop_only');
@@ -0,0 +1,6 @@
DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_blade_warding';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(64440, 'spell_gen_blade_warding');
-- no cooldown
UPDATE `spell_proc` SET `Cooldown`=0 WHERE `SpellId`=64440;
+17 -15
View File
@@ -326,33 +326,35 @@ TC_COMMON_API bool StringToBool(std::string const& str);
// simple class for not-modifyable list
template <typename T>
class HookList
class HookList final
{
typedef typename std::list<T>::iterator ListIterator;
private:
typename std::list<T> m_list;
typedef std::vector<T> ContainerType;
ContainerType _container;
public:
HookList<T> & operator+=(T t)
typedef typename ContainerType::iterator iterator;
HookList<T>& operator+=(T t)
{
m_list.push_back(t);
return *this;
}
HookList<T> & operator-=(T t)
{
m_list.remove(t);
_container.push_back(t);
return *this;
}
size_t size()
{
return m_list.size();
return _container.size();
}
ListIterator begin()
iterator begin()
{
return m_list.begin();
return _container.begin();
}
ListIterator end()
iterator end()
{
return m_list.end();
return _container.end();
}
};
+12 -12
View File
@@ -461,7 +461,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (IsUnit(*itr))
if (Vehicle* vehicle = (*itr)->ToUnit()->GetVehicleKit())
for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it)
if (Player* player = ObjectAccessor::FindPlayer(it->second.Passenger.Guid))
if (Player* player = ObjectAccessor::GetPlayer(*(*itr), it->second.Passenger.Guid))
player->AreaExploredOrEventHappens(e.action.quest.quest);
if (IsPlayer(*itr))
@@ -547,7 +547,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
case SMART_ACTION_INVOKER_CAST:
{
Unit* tempLastInvoker = GetLastInvoker();
Unit* tempLastInvoker = GetLastInvoker(unit);
if (!tempLastInvoker)
break;
@@ -805,7 +805,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
// Special handling for vehicles
if (Vehicle* vehicle = unit->GetVehicleKit())
for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it)
if (Player* player = ObjectAccessor::FindPlayer(it->second.Passenger.Guid))
if (Player* player = ObjectAccessor::GetPlayer(*unit, it->second.Passenger.Guid))
player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
break;
}
@@ -950,7 +950,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
else if (IsUnit(*itr)) // Special handling for vehicles
if (Vehicle* vehicle = (*itr)->ToUnit()->GetVehicleKit())
for (SeatMap::iterator seatItr = vehicle->Seats.begin(); seatItr != vehicle->Seats.end(); ++seatItr)
if (Player* player = ObjectAccessor::FindPlayer(seatItr->second.Passenger.Guid))
if (Player* player = ObjectAccessor::GetPlayer(*(*itr), seatItr->second.Passenger.Guid))
player->KilledMonsterCredit(e.action.killedMonster.creature);
}
@@ -4082,14 +4082,14 @@ void SmartScript::SetScript9(SmartScriptHolder& e, uint32 entry)
}
}
Unit* SmartScript::GetLastInvoker()
Unit* SmartScript::GetLastInvoker(Unit* invoker)
{
WorldObject* lookupRoot = me;
if (!lookupRoot)
lookupRoot = go;
// Look for invoker only on map of base object... Prevents multithreaded crashes
if (WorldObject* baseObject = GetBaseObject())
return ObjectAccessor::GetUnit(*baseObject, mLastInvoker);
// used for area triggers invoker cast
else if (invoker)
return ObjectAccessor::GetUnit(*invoker, mLastInvoker);
if (lookupRoot)
return ObjectAccessor::GetUnit(*lookupRoot, mLastInvoker);
return ObjectAccessor::FindPlayer(mLastInvoker);
return nullptr;
}
@@ -235,7 +235,7 @@ class TC_GAME_API SmartScript
//TIMED_ACTIONLIST (script type 9 aka script9)
void SetScript9(SmartScriptHolder& e, uint32 entry);
Unit* GetLastInvoker();
Unit* GetLastInvoker(Unit* invoker = nullptr);
ObjectGuid mLastInvoker;
typedef std::unordered_map<uint32, uint32> CounterMap;
CounterMap mCounterList;
+3 -2
View File
@@ -44,7 +44,7 @@ float ThreatCalcHelper::calcThreat(Unit* hatedUnit, Unit* /*hatingUnit*/, float
return threat;
if (Player* modOwner = hatedUnit->GetSpellModOwner())
modOwner->ApplySpellMod(threatSpell->Id, SPELLMOD_THREAT, threat);
modOwner->ApplySpellMod<SPELLMOD_THREAT>(threatSpell->Id, threat);
}
return hatedUnit->ApplyTotalThreatModifier(threat, schoolMask);
@@ -422,7 +422,8 @@ void ThreatManager::doAddThreat(Unit* victim, float threat)
{
float redirectThreat = CalculatePct(threat, redirectThreadPct);
threat -= redirectThreat;
_addThreat(redirectTarget, redirectThreat);
if (ThreatCalcHelper::isValidProcess(redirectTarget, GetOwner()))
_addThreat(redirectTarget, redirectThreat);
}
}
+2 -2
View File
@@ -1346,7 +1346,7 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*
@param[in] guid Group guid
@param[in] dungeonId Dungeonid
*/
void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId)
void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId, Map const* currMap)
{
uint32 gDungeonId = GetDungeon(gguid);
if (gDungeonId != dungeonId)
@@ -1390,7 +1390,7 @@ void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId)
}
Player* player = ObjectAccessor::FindPlayer(guid);
if (!player)
if (!player || player->FindMap() != currMap)
{
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %s, Player: %s not found in world", gguid.ToString().c_str(), guid.ToString().c_str());
continue;
+2 -1
View File
@@ -28,6 +28,7 @@
class Group;
class Player;
class Quest;
class Map;
namespace lfg
{
@@ -309,7 +310,7 @@ class TC_GAME_API LFGMgr
// World.cpp
/// Finish the dungeon for the given group. All check are performed using internal lfg data
void FinishDungeon(ObjectGuid gguid, uint32 dungeonId);
void FinishDungeon(ObjectGuid gguid, uint32 dungeonId, Map const* currMap);
/// Loads rewards for random dungeons
void LoadRewards();
/// Loads dungeons from dbc and adds teleport coords
@@ -1873,7 +1873,7 @@ void Creature::LoadMechanicTemplateImmunity()
}
}
bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const
{
if (!spellInfo)
return false;
@@ -1883,7 +1883,7 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
{
if (!spellInfo->Effects[i].IsEffect())
continue;
if (!IsImmunedToSpellEffect(spellInfo, i))
if (!IsImmunedToSpellEffect(spellInfo, i, caster))
{
immunedToAllEffects = false;
break;
@@ -1892,15 +1892,15 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
if (immunedToAllEffects)
return true;
return Unit::IsImmunedToSpell(spellInfo);
return Unit::IsImmunedToSpell(spellInfo, caster);
}
bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const
{
if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && spellInfo->Effects[index].Effect == SPELL_EFFECT_HEAL)
return true;
return Unit::IsImmunedToSpellEffect(spellInfo, index);
return Unit::IsImmunedToSpellEffect(spellInfo, index, caster);
}
bool Creature::isElite() const
+2 -2
View File
@@ -497,8 +497,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
bool isCanTrainingAndResetTalentsOf(Player* player) const;
bool CanCreatureAttack(Unit const* victim, bool force = true) const;
void LoadMechanicTemplateImmunity();
bool IsImmunedToSpell(SpellInfo const* spellInfo) const override; // override Unit::IsImmunedToSpell
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override; // override Unit::IsImmunedToSpellEffect
bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const override;
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const override;
bool isElite() const;
bool isWorldBoss() const;
@@ -564,8 +564,8 @@ void GameObject::Update(uint32 diff)
if (Unit* owner = GetOwner())
{
// Hunter trap: Search units which are unfriendly to the trap's owner
Trinity::NearestUnfriendlyNoTotemUnitInObjectRangeCheck checker(this, owner, radius);
Trinity::UnitLastSearcher<Trinity::NearestUnfriendlyNoTotemUnitInObjectRangeCheck> searcher(this, target, checker);
Trinity::NearestAttackableNoTotemUnitInObjectRangeCheck checker(this, owner, radius);
Trinity::UnitLastSearcher<Trinity::NearestAttackableNoTotemUnitInObjectRangeCheck> searcher(this, target, checker);
VisitNearbyObject(radius, searcher);
}
else
@@ -1880,6 +1880,8 @@ void GameObject::CastSpell(Unit* target, uint32 spellId, TriggerCastFlags trigge
trigger->SetFaction(owner->GetFaction());
if (owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE))
trigger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
// copy pvp state flags from owner
trigger->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, owner->GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG));
// needed for GO casts for proper target validation checks
trigger->SetOwnerGUID(owner->GetGUID());
trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, owner->GetGUID());
+1 -1
View File
@@ -2012,7 +2012,7 @@ void WorldObject::AddObjectToRemoveList()
map->AddObjectToRemoveList(this);
}
TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= NULL*/, uint32 duration /*= 0*/, Unit* summoner /*= NULL*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/)
TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, Unit* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/)
{
uint32 mask = UNIT_MASK_SUMMON;
if (properties)
+97 -167
View File
@@ -943,12 +943,21 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
// Absorb, resist some environmental damage type
uint32 absorb = 0;
uint32 resist = 0;
if (type == DAMAGE_LAVA)
CalcAbsorbResist(this, SPELL_SCHOOL_MASK_FIRE, DIRECT_DAMAGE, damage, &absorb, &resist);
else if (type == DAMAGE_SLIME)
CalcAbsorbResist(this, SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, damage, &absorb, &resist);
damage -= absorb + resist;
switch (type)
{
case DAMAGE_LAVA:
case DAMAGE_SLIME:
{
DamageInfo dmgInfo(this, this, damage, nullptr, type == DAMAGE_LAVA ? SPELL_SCHOOL_MASK_FIRE : SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, BASE_ATTACK);
CalcAbsorbResist(dmgInfo);
absorb = dmgInfo.GetAbsorb();
resist = dmgInfo.GetResist();
damage = dmgInfo.GetDamage();
break;
}
default:
break;
}
DealDamageMods(this, damage, &absorb);
@@ -1211,18 +1220,6 @@ void Player::Update(uint32 p_time)
m_nextMailDelivereTime = 0;
}
// If this is set during update SetSpellModTakingSpell call is missing somewhere in the code
// Having this would prevent more aura charges to be dropped, so let's crash
//ASSERT (!m_spellModTakingSpell);
if (m_spellModTakingSpell)
{
//TC_LOG_FATAL("entities.player", "Player has m_pad %u during update!", m_pad);
//if (m_spellModTakingSpell)
TC_LOG_FATAL("spells", "Player::Update: Player '%s' (%s) has m_spellModTakingSpell (SpellID: %u) during update!",
GetName().c_str(), GetGUID().ToString().c_str(), m_spellModTakingSpell->m_spellInfo->Id);
m_spellModTakingSpell = nullptr;
}
// Update cinematic location, if 500ms have passed and we're doing a cinematic now.
_cinematicMgr->m_cinematicDiff += p_time;
if (_cinematicMgr->m_activeCinematicCameraId != 0 && GetMSTimeDiffToNow(_cinematicMgr->m_lastCinematicCheck) > CINEMATIC_UPDATEDIFF)
@@ -2177,6 +2174,9 @@ void Player::RemoveFromWorld()
UnsummonPetTemporaryIfAny();
ClearComboPoints();
ClearComboPointHolders();
ObjectGuid lootGuid = GetLootGUID();
if (!lootGuid.IsEmpty())
m_session->DoLootRelease(lootGuid);
sOutdoorPvPMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
sBattlefieldMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
}
@@ -2216,7 +2216,7 @@ void Player::SetObjectScale(float scale)
SendMovementSetCollisionHeight(scale * GetCollisionHeight(IsMounted()));
}
bool Player::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
bool Player::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const
{
// players are immune to taunt (the aura and the spell effect)
if (spellInfo->Effects[index].IsAura(SPELL_AURA_MOD_TAUNT))
@@ -2224,7 +2224,7 @@ bool Player::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) co
if (spellInfo->Effects[index].IsEffect(SPELL_EFFECT_ATTACK_ME))
return true;
return Unit::IsImmunedToSpellEffect(spellInfo, index);
return Unit::IsImmunedToSpellEffect(spellInfo, index, caster);
}
void Player::RegenerateAll()
@@ -8189,8 +8189,10 @@ void Player::UpdateEquipSpellsAtFormChange()
}
}
}
void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32 procVictim, uint32 procEx)
void Player::CastItemCombatSpell(DamageInfo const& damageInfo)
{
Unit* target = damageInfo.GetVictim();
if (!target || !target->IsAlive() || target == this)
return;
@@ -8198,7 +8200,9 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32
{
// If usable, try to cast item spell
if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
if (!item->IsBroken() && CanUseAttackType(attType))
{
if (!item->IsBroken() && CanUseAttackType(damageInfo.GetAttackType()))
{
if (ItemTemplate const* proto = item->GetTemplate())
{
// Additional check for weapons
@@ -8206,30 +8210,42 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32
{
// offhand item cannot proc from main hand hit etc
EquipmentSlots slot;
switch (attType)
switch (damageInfo.GetAttackType())
{
case BASE_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break;
case OFF_ATTACK: slot = EQUIPMENT_SLOT_OFFHAND; break;
case RANGED_ATTACK: slot = EQUIPMENT_SLOT_RANGED; break;
default: slot = EQUIPMENT_SLOT_END; break;
case BASE_ATTACK:
slot = EQUIPMENT_SLOT_MAINHAND;
break;
case OFF_ATTACK:
slot = EQUIPMENT_SLOT_OFFHAND;
break;
case RANGED_ATTACK:
slot = EQUIPMENT_SLOT_RANGED;
break;
default:
slot = EQUIPMENT_SLOT_END;
break;
}
if (slot != i)
continue;
// Check if item is useable (forms or disarm)
if (attType == BASE_ATTACK)
if (damageInfo.GetAttackType() == BASE_ATTACK)
if (!IsUseEquipedWeapon(true) && !IsInFeralForm())
continue;
}
CastItemCombatSpell(target, attType, procVictim, procEx, item, proto);
CastItemCombatSpell(damageInfo, item, proto);
}
}
}
}
}
void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item* item, ItemTemplate const* proto)
void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemTemplate const* proto)
{
// Can do effect if any damage done to target
if (procVictim & PROC_FLAG_TAKEN_DAMAGE)
//if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
// for done procs allow normal + critical + absorbs by default
bool canTrigger = (damageInfo.GetHitMask() & (PROC_HIT_NORMAL | PROC_HIT_CRITICAL | PROC_HIT_ABSORB)) != 0;
if (canTrigger)
{
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{
@@ -8259,14 +8275,14 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32
if (proto->SpellPPMRate)
{
uint32 WeaponSpeed = GetAttackTime(attType);
uint32 WeaponSpeed = GetAttackTime(damageInfo.GetAttackType());
chance = GetPPMProcChance(WeaponSpeed, proto->SpellPPMRate, spellInfo);
}
else if (chance > 100.0f)
chance = GetWeaponProcChance();
if (roll_chance_f(chance))
CastSpell(target, spellInfo->Id, true, item);
CastSpell(damageInfo.GetVictim(), spellInfo->Id, true, item);
}
}
@@ -8287,18 +8303,17 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32
continue;
SpellEnchantProcEntry const* entry = sSpellMgr->GetSpellEnchantProcEvent(enchant_id);
if (entry && entry->procEx)
{
// Check hit/crit/dodge/parry requirement
if ((entry->procEx & procEx) == 0)
if ((entry->procEx & damageInfo.GetHitMask()) == 0)
continue;
}
else
{
// Can do effect if any damage done to target
if (!(procVictim & PROC_FLAG_TAKEN_DAMAGE))
//if (!(damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE))
// for done procs allow normal + critical + absorbs by default
if (!canTrigger)
continue;
}
@@ -8311,7 +8326,6 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32
}
float chance = pEnchant->amount[s] != 0 ? float(pEnchant->amount[s]) : GetWeaponProcChance();
if (entry)
{
if (entry->PPMChance)
@@ -8321,7 +8335,7 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32
}
// Apply spell mods
ApplySpellMod(pEnchant->spellid[s], SPELLMOD_CHANCE_OF_SUCCESS, chance);
ApplySpellMod<SPELLMOD_CHANCE_OF_SUCCESS>(pEnchant->spellid[s], chance);
// Shiv has 100% chance to apply the poison
if (FindCurrentSpellBySpellId(5938) && e_slot == TEMP_ENCHANTMENT_SLOT)
@@ -8332,7 +8346,7 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32
if (spellInfo->IsPositive())
CastSpell(this, spellInfo, true, item);
else
CastSpell(target, spellInfo, true, item);
CastSpell(damageInfo.GetVictim(), spellInfo, true, item);
}
}
}
@@ -21229,8 +21243,8 @@ bool Player::IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod
if (!mod || !spellInfo)
return false;
// Mod out of charges
if (spell && mod->charges == -1 && spell->m_appliedMods.find(mod->ownerAura) == spell->m_appliedMods.end())
// First time this aura applies a mod to us and is out of charges
if (spell && mod->ownerAura->IsUsingCharges() && !mod->ownerAura->GetCharges() && !spell->m_appliedMods.count(mod->ownerAura))
return false;
// +duration to infinite duration spells making them limited
@@ -21253,7 +21267,7 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
size_t writePos = data.wpos();
data << uint32(modTypeCount);
data << uint8(mod->op);
for (int eff = 0; eff < 96; ++eff)
for (int32 eff = 0; eff < 96; ++eff)
{
if (eff != 0 && (eff % 32) == 0)
_mask[i++] = 0;
@@ -21262,9 +21276,11 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
if (mod->mask & _mask)
{
int32 val = 0;
for (SpellModList::iterator itr = m_spellMods[mod->op].begin(); itr != m_spellMods[mod->op].end(); ++itr)
if ((*itr)->type == mod->type && (*itr)->mask & _mask)
val += (*itr)->value;
for (SpellModifier* spellMod : m_spellMods[mod->op])
{
if (spellMod->type == mod->type && (spellMod->mask & _mask))
val += spellMod->value;
}
val += apply ? mod->value : -(mod->value);
data << uint8(eff);
@@ -21275,145 +21291,41 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
data.put<uint32>(writePos, modTypeCount);
SendDirectMessage(&data);
if (apply)
m_spellMods[mod->op].push_back(mod);
m_spellMods[mod->op].insert(mod);
else
{
m_spellMods[mod->op].remove(mod);
// mods bound to aura will be removed in AuraEffect::~AuraEffect
if (!mod->ownerAura)
delete mod;
}
m_spellMods[mod->op].erase(mod);
}
// Restore spellmods in case of failed cast
void Player::RestoreSpellMods(Spell* spell, uint32 ownerAuraId, Aura* aura)
bool Player::HasSpellModApplied(SpellModifier* mod, Spell* spell)
{
if (!spell || spell->m_appliedMods.empty())
return;
if (!spell)
return false;
std::list<Aura*> aurasQueue;
for (uint8 i=0; i<MAX_SPELLMOD; ++i)
{
for (SpellModList::iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end(); ++itr)
{
SpellModifier* mod = *itr;
// Spellmods without aura set cannot be charged
if (!mod->ownerAura || !mod->ownerAura->IsUsingCharges())
continue;
// Restore only specific owner aura mods
if (ownerAuraId && (ownerAuraId != mod->ownerAura->GetSpellInfo()->Id))
continue;
if (aura && mod->ownerAura != aura)
continue;
// Check if mod affected this spell
// First, check if the mod aura applied at least one spellmod to this spell
Spell::UsedSpellMods::iterator iterMod = spell->m_appliedMods.find(mod->ownerAura);
if (iterMod == spell->m_appliedMods.end())
continue;
// Second, check if the current mod is one of those applied by the mod aura
if (!(mod->mask & spell->m_spellInfo->SpellFamilyFlags))
continue;
// remove from list - This will be done after all mods have been gone through
// to ensure we iterate over all mods of an aura before removing said aura
// from applied mods (Else, an aura with two mods on the current spell would
// only see the first of its modifier restored)
aurasQueue.push_back(mod->ownerAura);
// add mod charges back to mod
if (mod->charges == -1)
mod->charges = 1;
else
mod->charges++;
// Do not set more spellmods than available
if (mod->ownerAura->GetCharges() < mod->charges)
mod->charges = mod->ownerAura->GetCharges();
// Skip this check for now - aura charges may change due to various reason
/// @todo track these changes correctly
//ASSERT (mod->ownerAura->GetCharges() <= mod->charges);
}
}
for (std::list<Aura*>::iterator itr = aurasQueue.begin(); itr != aurasQueue.end(); ++itr)
{
Spell::UsedSpellMods::iterator iterMod = spell->m_appliedMods.find(*itr);
if (iterMod != spell->m_appliedMods.end())
spell->m_appliedMods.erase(iterMod);
}
return spell->m_appliedMods.count(mod->ownerAura) != 0;
}
void Player::RestoreAllSpellMods(uint32 ownerAuraId, Aura* aura)
{
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
if (m_currentSpells[i])
RestoreSpellMods(m_currentSpells[i], ownerAuraId, aura);
}
void Player::RemoveSpellMods(Spell* spell)
void Player::ApplyModToSpell(SpellModifier* mod, Spell* spell)
{
if (!spell)
return;
if (spell->m_appliedMods.empty())
// don't do anything with no charges
if (mod->ownerAura->IsUsingCharges() && !mod->ownerAura->GetCharges())
return;
for (uint8 i=0; i<MAX_SPELLMOD; ++i)
{
for (SpellModList::const_iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end();)
{
SpellModifier* mod = *itr;
++itr;
// spellmods without aura set cannot be charged
if (!mod->ownerAura || !mod->ownerAura->IsUsingCharges())
continue;
// check if mod affected this spell
Spell::UsedSpellMods::iterator iterMod = spell->m_appliedMods.find(mod->ownerAura);
if (iterMod == spell->m_appliedMods.end())
continue;
// remove from list
spell->m_appliedMods.erase(iterMod);
if (mod->ownerAura->DropCharge(AURA_REMOVE_BY_EXPIRE))
itr = m_spellMods[i].begin();
}
}
}
void Player::DropModCharge(SpellModifier* mod, Spell* spell)
{
// don't handle spells with proc_event entry defined
// this is a temporary workaround, because all spellmods should be handled like that
if (sSpellMgr->GetSpellProcEvent(mod->spellId))
return;
if (spell && mod->ownerAura && mod->charges > 0)
{
if (--mod->charges == 0)
mod->charges = -1;
spell->m_appliedMods.insert(mod->ownerAura);
}
// register inside spell, proc system uses this to drop charges
spell->m_appliedMods.insert(mod->ownerAura);
}
void Player::SetSpellModTakingSpell(Spell* spell, bool apply)
{
if (!spell || (m_spellModTakingSpell && m_spellModTakingSpell != spell))
if (apply && m_spellModTakingSpell != nullptr)
return;
if (apply && spell->getState() == SPELL_STATE_FINISHED)
if (!apply && (!m_spellModTakingSpell || m_spellModTakingSpell != spell))
return;
m_spellModTakingSpell = apply ? spell : NULL;
m_spellModTakingSpell = apply ? spell : nullptr;
}
// send Proficiency
@@ -22447,7 +22359,12 @@ void Player::UpdatePotionCooldown(Spell* spell)
}
// from spell cases (m_lastPotionId set in Spell::SendSpellCooldown)
else
GetSpellHistory()->SendCooldownEvent(spell->m_spellInfo, m_lastPotionId, spell);
{
if (spell->IsIgnoringCooldowns())
return;
else
GetSpellHistory()->SendCooldownEvent(spell->m_spellInfo, m_lastPotionId, spell);
}
m_lastPotionId = 0;
}
@@ -23361,6 +23278,7 @@ void Player::ApplyEquipCooldown(Item* pItem)
if (pItem->GetTemplate()->Flags & ITEM_FLAG_NO_EQUIP_COOLDOWN)
return;
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{
_Spell const& spellData = pItem->GetTemplate()->Spells[i];
@@ -23369,6 +23287,18 @@ void Player::ApplyEquipCooldown(Item* pItem)
if (spellData.SpellId <= 0)
continue;
// apply proc cooldown to equip auras if we have any
if (spellData.SpellTrigger == ITEM_SPELLTRIGGER_ON_EQUIP)
{
SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(spellData.SpellId);
if (!procEntry)
continue;
if (Aura* itemAura = GetAura(spellData.SpellId, GetGUID(), pItem->GetGUID()))
itemAura->AddProcCooldown(now + procEntry->Cooldown);
continue;
}
// wrong triggering type (note: ITEM_SPELLTRIGGER_ON_NO_DELAY_USE not have cooldown)
if (spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
continue;
@@ -24391,7 +24321,7 @@ bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const
if (!player || IsAlive())
player = this;
if (player->GetMap()->IsDungeon())
if (pRewardSource->GetMap()->IsDungeon())
return true;
return pRewardSource->GetDistance(player) <= sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE);
+100 -37
View File
@@ -68,10 +68,10 @@ typedef std::deque<Mail*> PlayerMails;
#define PLAYER_EXPLORED_ZONES_SIZE 156
// Note: SPELLMOD_* values is aura types in fact
enum SpellModType
enum SpellModType : uint8
{
SPELLMOD_FLAT = 107, // SPELL_AURA_ADD_FLAT_MODIFIER
SPELLMOD_PCT = 108 // SPELL_AURA_ADD_PCT_MODIFIER
SPELLMOD_FLAT = SPELL_AURA_ADD_FLAT_MODIFIER,
SPELLMOD_PCT = SPELL_AURA_ADD_PCT_MODIFIER
};
// 2^n values, Player::m_isunderwater is a bitmask. These are Trinity internal values, they are never send to any client
@@ -156,10 +156,11 @@ enum TalentTree // talent tabs
// Spell modifier (used for modify other spells)
struct SpellModifier
{
SpellModifier(Aura* _ownerAura = nullptr) : op(SPELLMOD_DAMAGE), type(SPELLMOD_FLAT), charges(0), value(0), mask(), spellId(0), ownerAura(_ownerAura) { }
SpellModOp op : 8;
SpellModType type : 8;
int16 charges : 16;
SpellModifier(Aura* _ownerAura) : op(SPELLMOD_DAMAGE), type(SPELLMOD_FLAT), value(0), mask(), spellId(0), ownerAura(_ownerAura) { }
SpellModOp op;
SpellModType type;
int32 value;
flag96 mask;
uint32 spellId;
@@ -183,7 +184,7 @@ struct PlayerCurrency
typedef std::unordered_map<uint32, PlayerTalent*> PlayerTalentMap;
typedef std::unordered_map<uint32, PlayerSpell*> PlayerSpellMap;
typedef std::list<SpellModifier*> SpellModList;
typedef std::unordered_set<SpellModifier*> SpellModContainer;
typedef std::unordered_map<uint32, PlayerCurrency> PlayerCurrenciesMap;
/// Maximum number of CompactUnitFrames profiles
@@ -1242,7 +1243,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
static bool BuildEnumData(PreparedQueryResult result, ByteBuffer* dataBuffer, ByteBuffer* bitBuffer);
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override;
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const override;
void SetInWater(bool apply);
@@ -1842,13 +1843,11 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
PlayerSpellMap & GetSpellMap() { return m_spells; }
void AddSpellMod(SpellModifier* mod, bool apply);
bool IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell = nullptr);
template <class T>
void ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* spell = nullptr);
void RemoveSpellMods(Spell* spell);
void RestoreSpellMods(Spell* spell, uint32 ownerAuraId = 0, Aura* aura = nullptr);
void RestoreAllSpellMods(uint32 ownerAuraId = 0, Aura* aura = nullptr);
void DropModCharge(SpellModifier* mod, Spell* spell);
static bool IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell = nullptr);
template <SpellModOp op, class T>
void ApplySpellMod(uint32 spellId, T& basevalue, Spell* spell = nullptr) const;
static void ApplyModToSpell(SpellModifier* mod, Spell* spell);
static bool HasSpellModApplied(SpellModifier* mod, Spell* spell);
void SetSpellModTakingSpell(Spell* spell, bool apply);
void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns = false);
@@ -2198,9 +2197,9 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void ApplyItemEquipSpell(Item* item, bool apply, bool form_change = false);
void ApplyEquipSpell(SpellInfo const* spellInfo, Item* item, bool apply, bool form_change = false);
void UpdateEquipSpellsAtFormChange();
void CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32 procVictim, uint32 procEx);
void CastItemCombatSpell(DamageInfo const& damageInfo);
void CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemTemplate const* proto);
void CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8 cast_count, uint32 glyphIndex);
void CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item* item, ItemTemplate const* proto);
void SendEquipmentSetList();
void SetEquipmentSet(uint32 index, EquipmentSet eqset);
@@ -2722,7 +2721,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
uint32 m_baseHealthRegen;
int32 m_spellPenetrationItemMod;
SpellModList m_spellMods[MAX_SPELLMOD];
SpellModContainer m_spellMods[MAX_SPELLMOD];
EnchantDurationList m_enchantDuration;
ItemDurationList m_itemDuration;
@@ -2893,8 +2892,8 @@ TC_GAME_API void AddItemsSetItem(Player* player, Item* item);
TC_GAME_API void RemoveItemsSetItem(Player* player, ItemTemplate const* proto);
// "the bodies of template functions must be made available in a header file"
template <class T>
void Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* spell /*= nullptr*/)
template <SpellModOp op, class T>
void Player::ApplySpellMod(uint32 spellId, T& basevalue, Spell* spell /*= nullptr*/) const
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
@@ -2906,33 +2905,97 @@ void Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* s
if (m_spellModTakingSpell)
spell = m_spellModTakingSpell;
for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr)
switch (op)
{
SpellModifier* mod = *itr;
// special case, if a mod makes spell instant, only consume that mod
case SPELLMOD_CASTING_TIME:
{
SpellModifier* modInstantSpell = nullptr;
for (SpellModifier* mod : m_spellMods[op])
{
if (!IsAffectedBySpellmod(spellInfo, mod, spell))
continue;
// Charges can be set only for mods with auras
if (!mod->ownerAura)
ASSERT(mod->charges == 0);
if (mod->type == SPELLMOD_PCT && basevalue < T(10000) && mod->value <= -100)
{
modInstantSpell = mod;
break;
}
}
if (modInstantSpell)
{
Player::ApplyModToSpell(modInstantSpell, spell);
basevalue = T(0);
return;
}
break;
}
// special case if two mods apply 100% critical chance, only consume one
case SPELLMOD_CRITICAL_CHANCE:
{
SpellModifier* modCritical = nullptr;
for (SpellModifier* mod : m_spellMods[op])
{
if (!IsAffectedBySpellmod(spellInfo, mod, spell))
continue;
if (mod->type == SPELLMOD_FLAT && mod->value >= 100)
{
modCritical = mod;
break;
}
}
if (modCritical)
{
Player::ApplyModToSpell(modCritical, spell);
basevalue = T(100);
return;
}
break;
}
default:
break;
}
for (SpellModifier* mod : m_spellMods[op])
{
if (!IsAffectedBySpellmod(spellInfo, mod, spell))
continue;
if (mod->type == SPELLMOD_FLAT)
totalflat += mod->value;
else if (mod->type == SPELLMOD_PCT)
switch (mod->type)
{
// skip percent mods for null basevalue (most important for spell mods with charges)
if (basevalue == T(0))
continue;
case SPELLMOD_FLAT:
totalflat += mod->value;
break;
case SPELLMOD_PCT:
{
// skip percent mods with null basevalue (most important for spell mods with charges)
if (basevalue == T(0))
continue;
// special case (skip > 10sec spell casts for instant cast setting)
if (mod->op == SPELLMOD_CASTING_TIME && basevalue >= T(10000) && mod->value <= -100)
continue;
// special case (skip > 10sec spell casts for instant cast setting)
if (op == SPELLMOD_CASTING_TIME && mod->value <= -100 && basevalue >= T(10000))
continue;
else if (!Player::HasSpellModApplied(mod, spell))
{
// special case for Surge of Light, don't apply critical chance reduction if other mods not applied (ie procs while casting another spell)
// (Surge of Light is the only PCT_MOD on critical chance)
if (op == SPELLMOD_CRITICAL_CHANCE)
continue;
// special case for Backdraft, dont' apply GCD reduction if cast time reduction wasn't applied (ie when Backlash is consumed first)
// (Backdraft is the only PCT_MOD on global cooldown)
else if (op == SPELLMOD_GLOBAL_COOLDOWN)
continue;
}
totalmul += CalculatePct(1.0f, mod->value);
totalmul += CalculatePct(1.0f, mod->value);
break;
}
}
DropModCharge(mod, spell);
Player::ApplyModToSpell(mod, spell);
}
basevalue = T(float(basevalue + totalflat) * totalmul);
}
+2 -2
View File
@@ -143,7 +143,7 @@ void Totem::UnSummon(uint32 msTime)
AddObjectToRemoveList();
}
bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const
{
/// @todo possibly all negative auras immune?
if (GetEntry() == 5925)
@@ -160,5 +160,5 @@ bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) con
break;
}
return Creature::IsImmunedToSpellEffect(spellInfo, index);
return Creature::IsImmunedToSpellEffect(spellInfo, index, caster);
}
+1 -1
View File
@@ -58,7 +58,7 @@ class TC_GAME_API Totem : public Minion
void UpdateAttackPowerAndDamage(bool /*ranged*/) override { }
void UpdateDamagePhysical(WeaponAttackType /*attType*/) override { }
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override;
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const override;
protected:
TotemType m_type;
+11 -2
View File
@@ -178,8 +178,17 @@ void Player::UpdateSpellDamageAndHealingBonus()
// Get healing bonus for all schools
SetStatInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, SpellBaseHealingBonusDone(SPELL_SCHOOL_MASK_ALL));
// Get damage bonus for all schools
for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i)));
Unit::AuraEffectList const& modDamageAuras = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE);
for (uint16 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
{
SetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, std::accumulate(modDamageAuras.begin(), modDamageAuras.end(), 0, [i](int32 negativeMod, AuraEffect const* aurEff)
{
if (aurEff->GetAmount() < 0 && aurEff->GetMiscValue() & (1 << i))
negativeMod += aurEff->GetAmount();
return negativeMod;
}));
SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i)) - GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i));
}
}
bool Player::UpdateAllStats()
File diff suppressed because it is too large. Load diff
+194 -183
View File
@@ -82,42 +82,42 @@ enum SpellAuraInterruptFlags
AURA_INTERRUPT_FLAG_NOT_VICTIM = (AURA_INTERRUPT_FLAG_HITBYSPELL | AURA_INTERRUPT_FLAG_TAKE_DAMAGE | AURA_INTERRUPT_FLAG_DIRECT_DAMAGE)
};
enum SpellModOp
enum SpellModOp : uint8
{
SPELLMOD_DAMAGE = 0,
SPELLMOD_DURATION = 1,
SPELLMOD_THREAT = 2,
SPELLMOD_EFFECT1 = 3,
SPELLMOD_CHARGES = 4,
SPELLMOD_RANGE = 5,
SPELLMOD_RADIUS = 6,
SPELLMOD_CRITICAL_CHANCE = 7,
SPELLMOD_ALL_EFFECTS = 8,
SPELLMOD_NOT_LOSE_CASTING_TIME = 9,
SPELLMOD_CASTING_TIME = 10,
SPELLMOD_COOLDOWN = 11,
SPELLMOD_EFFECT2 = 12,
SPELLMOD_IGNORE_ARMOR = 13,
SPELLMOD_COST = 14,
SPELLMOD_CRIT_DAMAGE_BONUS = 15,
SPELLMOD_RESIST_MISS_CHANCE = 16,
SPELLMOD_JUMP_TARGETS = 17,
SPELLMOD_CHANCE_OF_SUCCESS = 18,
SPELLMOD_ACTIVATION_TIME = 19,
SPELLMOD_DAMAGE_MULTIPLIER = 20,
SPELLMOD_GLOBAL_COOLDOWN = 21,
SPELLMOD_DOT = 22,
SPELLMOD_EFFECT3 = 23,
SPELLMOD_BONUS_MULTIPLIER = 24,
SPELLMOD_DAMAGE = 0,
SPELLMOD_DURATION = 1,
SPELLMOD_THREAT = 2,
SPELLMOD_EFFECT1 = 3,
SPELLMOD_CHARGES = 4,
SPELLMOD_RANGE = 5,
SPELLMOD_RADIUS = 6,
SPELLMOD_CRITICAL_CHANCE = 7,
SPELLMOD_ALL_EFFECTS = 8,
SPELLMOD_NOT_LOSE_CASTING_TIME = 9,
SPELLMOD_CASTING_TIME = 10,
SPELLMOD_COOLDOWN = 11,
SPELLMOD_EFFECT2 = 12,
SPELLMOD_IGNORE_ARMOR = 13,
SPELLMOD_COST = 14,
SPELLMOD_CRIT_DAMAGE_BONUS = 15,
SPELLMOD_RESIST_MISS_CHANCE = 16,
SPELLMOD_JUMP_TARGETS = 17,
SPELLMOD_CHANCE_OF_SUCCESS = 18,
SPELLMOD_ACTIVATION_TIME = 19,
SPELLMOD_DAMAGE_MULTIPLIER = 20,
SPELLMOD_GLOBAL_COOLDOWN = 21,
SPELLMOD_DOT = 22,
SPELLMOD_EFFECT3 = 23,
SPELLMOD_BONUS_MULTIPLIER = 24,
// spellmod 25
SPELLMOD_PROC_PER_MINUTE = 26,
SPELLMOD_VALUE_MULTIPLIER = 27,
SPELLMOD_RESIST_DISPEL_CHANCE = 28,
SPELLMOD_CRIT_DAMAGE_BONUS_2 = 29, //one not used spell
SPELLMOD_SPELL_COST_REFUND_ON_FAIL = 30
};
SPELLMOD_PROC_PER_MINUTE = 26,
SPELLMOD_VALUE_MULTIPLIER = 27,
SPELLMOD_RESIST_DISPEL_CHANCE = 28,
SPELLMOD_CRIT_DAMAGE_BONUS_2 = 29, //one not used spell
SPELLMOD_SPELL_COST_REFUND_ON_FAIL = 30,
#define MAX_SPELLMOD 32
MAX_SPELLMOD
};
enum SpellValueMod
{
@@ -450,13 +450,19 @@ enum TriggerCastFlags
TRIGGERED_IGNORE_SET_FACING = 0x00000200, //! Will not adjust facing to target (if any)
TRIGGERED_IGNORE_SHAPESHIFT = 0x00000400, //! Will ignore shapeshift checks
TRIGGERED_IGNORE_CASTER_AURASTATE = 0x00000800, //! Will ignore caster aura states including combat requirements and death state
TRIGGERED_DISALLOW_PROC_EVENTS = 0x00001000, //! Disallows proc events from triggered spell (default)
TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE = 0x00002000, //! Will ignore mounted/on vehicle restrictions
// reuse = 0x00004000,
// reuse = 0x00008000,
TRIGGERED_IGNORE_CASTER_AURAS = 0x00010000, //! Will ignore caster aura restrictions or requirements
TRIGGERED_DISALLOW_PROC_EVENTS = 0x00020000, //! Disallows proc events from triggered spell (default)
TRIGGERED_DONT_RESET_PERIODIC_TIMER = 0x00020000, //! Will allow periodic aura timers to keep ticking (instead of resetting)
TRIGGERED_DONT_REPORT_CAST_ERROR = 0x00040000, //! Will return SPELL_FAILED_DONT_REPORT in CheckCast functions
TRIGGERED_FULL_MASK = 0x0007FFFF, //! Used when doing CastSpell with triggered == true
// debug flags (used with .cast triggered commands)
TRIGGERED_IGNORE_EQUIPPED_ITEM_REQUIREMENT = 0x00080000, //! Will ignore equipped item requirements
TRIGGERED_IGNORE_TARGET_CHECK = 0x00100000, //! Will ignore most target checks (mostly DBC target checks)
TRIGGERED_FULL_MASK = 0xFFFFFFFF
TRIGGERED_FULL_DEBUG_MASK = 0xFFFFFFFF
};
enum UnitMods
@@ -832,17 +838,21 @@ enum UnitTypeMask
struct DiminishingReturn
{
DiminishingReturn(DiminishingGroup group, uint32 t, uint32 count)
: DRGroup(group), stack(0), hitTime(t), hitCount(count)
{ }
DiminishingReturn() : stack(0), hitTime(0), hitCount(DIMINISHING_LEVEL_1) { }
DiminishingGroup DRGroup:16;
uint16 stack:16;
void Clear()
{
stack = 0;
hitTime = 0;
hitCount = DIMINISHING_LEVEL_1;
}
uint16 stack;
uint32 hitTime;
uint32 hitCount;
};
enum MeleeHitOutcome
enum MeleeHitOutcome : uint8
{
MELEE_HIT_EVADE, MELEE_HIT_MISS, MELEE_HIT_DODGE, MELEE_HIT_BLOCK, MELEE_HIT_PARRY,
MELEE_HIT_GLANCING, MELEE_HIT_CRIT, MELEE_HIT_CRUSHING, MELEE_HIT_NORMAL
@@ -850,21 +860,18 @@ enum MeleeHitOutcome
class DispelInfo
{
public:
explicit DispelInfo(Unit* dispeller, uint32 dispellerSpellId, uint8 chargesRemoved) :
_dispellerUnit(dispeller), _dispellerSpell(dispellerSpellId), _chargesRemoved(chargesRemoved) { }
public:
explicit DispelInfo(Unit* dispeller, uint32 dispellerSpellId, uint8 chargesRemoved) :
_dispellerUnit(dispeller), _dispellerSpell(dispellerSpellId), _chargesRemoved(chargesRemoved) { }
Unit* GetDispeller() const { return _dispellerUnit; }
uint32 GetDispellerSpellId() const { return _dispellerSpell; }
uint8 GetRemovedCharges() const { return _chargesRemoved; }
void SetRemovedCharges(uint8 amount)
{
_chargesRemoved = amount;
}
private:
Unit* _dispellerUnit;
uint32 _dispellerSpell;
uint8 _chargesRemoved;
Unit* GetDispeller() const { return _dispellerUnit; }
uint32 GetDispellerSpellId() const { return _dispellerSpell; }
uint8 GetRemovedCharges() const { return _chargesRemoved; }
void SetRemovedCharges(uint8 amount) { _chargesRemoved = amount; }
private:
Unit* _dispellerUnit;
uint32 _dispellerSpell;
uint8 _chargesRemoved;
};
struct CleanDamage
@@ -880,103 +887,110 @@ struct CleanDamage
};
struct CalcDamageInfo;
struct SpellNonMeleeDamage;
class TC_GAME_API DamageInfo
{
private:
Unit* const m_attacker;
Unit* const m_victim;
uint32 m_damage;
SpellInfo const* const m_spellInfo;
SpellSchoolMask const m_schoolMask;
DamageEffectType const m_damageType;
WeaponAttackType m_attackType;
uint32 m_absorb;
uint32 m_resist;
uint32 m_block;
public:
explicit DamageInfo(Unit* _attacker, Unit* _victim, uint32 _damage, SpellInfo const* _spellInfo, SpellSchoolMask _schoolMask, DamageEffectType _damageType);
explicit DamageInfo(CalcDamageInfo& dmgInfo);
private:
Unit* const m_attacker;
Unit* const m_victim;
uint32 m_damage;
SpellInfo const* const m_spellInfo;
SpellSchoolMask const m_schoolMask;
DamageEffectType const m_damageType;
WeaponAttackType m_attackType;
uint32 m_absorb;
uint32 m_resist;
uint32 m_block;
uint32 m_hitMask;
public:
DamageInfo(Unit* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, DamageEffectType damageType, WeaponAttackType attackType);
explicit DamageInfo(CalcDamageInfo const& dmgInfo);
DamageInfo(SpellNonMeleeDamage const& spellNonMeleeDamage, DamageEffectType damageType, WeaponAttackType attackType, uint32 hitMask);
void ModifyDamage(int32 amount);
void AbsorbDamage(uint32 amount);
void ResistDamage(uint32 amount);
void BlockDamage(uint32 amount);
void ModifyDamage(int32 amount);
void AbsorbDamage(uint32 amount);
void ResistDamage(uint32 amount);
void BlockDamage(uint32 amount);
Unit* GetAttacker() const { return m_attacker; }
Unit* GetVictim() const { return m_victim; }
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
SpellSchoolMask GetSchoolMask() const { return m_schoolMask; }
DamageEffectType GetDamageType() const { return m_damageType; }
WeaponAttackType GetAttackType() const { return m_attackType; }
uint32 GetDamage() const { return m_damage; }
uint32 GetAbsorb() const { return m_absorb; }
uint32 GetResist() const { return m_resist; }
uint32 GetBlock() const { return m_block; }
Unit* GetAttacker() const { return m_attacker; }
Unit* GetVictim() const { return m_victim; }
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
SpellSchoolMask GetSchoolMask() const { return m_schoolMask; }
DamageEffectType GetDamageType() const { return m_damageType; }
WeaponAttackType GetAttackType() const { return m_attackType; }
uint32 GetDamage() const { return m_damage; }
uint32 GetAbsorb() const { return m_absorb; }
uint32 GetResist() const { return m_resist; }
uint32 GetBlock() const { return m_block; }
uint32 GetHitMask() const;
};
class HealInfo
class TC_GAME_API HealInfo
{
private:
Unit* const _healer;
Unit* const _target;
uint32 _heal;
uint32 _absorb;
SpellInfo const* const _spellInfo;
SpellSchoolMask const _schoolMask;
private:
Unit* const _healer;
Unit* const _target;
uint32 _heal;
uint32 _effectiveHeal;
uint32 _absorb;
SpellInfo const* const _spellInfo;
SpellSchoolMask const _schoolMask;
uint32 _hitMask;
public:
explicit HealInfo(Unit* healer, Unit* target, uint32 heal, SpellInfo const* spellInfo, SpellSchoolMask schoolMask)
: _healer(healer), _target(target), _heal(heal), _absorb(0), _spellInfo(spellInfo), _schoolMask(schoolMask) { }
public:
HealInfo(Unit* healer, Unit* target, uint32 heal, SpellInfo const* spellInfo, SpellSchoolMask schoolMask);
void AbsorbHeal(uint32 amount)
{
amount = std::min(amount, GetHeal());
_absorb += amount;
_heal -= amount;
}
void AbsorbHeal(uint32 amount);
void SetEffectiveHeal(uint32 amount) { _effectiveHeal = amount; }
Unit* GetHealer() const { return _healer; }
Unit* GetTarget() const { return _target; }
uint32 GetHeal() const { return _heal; }
uint32 GetAbsorb() const { return _absorb; }
SpellInfo const* GetSpellInfo() const { return _spellInfo; };
SpellSchoolMask GetSchoolMask() const { return _schoolMask; };
Unit* GetHealer() const { return _healer; }
Unit* GetTarget() const { return _target; }
uint32 GetHeal() const { return _heal; }
uint32 GetEffectiveHeal() const { return _effectiveHeal; }
uint32 GetAbsorb() const { return _absorb; }
SpellInfo const* GetSpellInfo() const { return _spellInfo; };
SpellSchoolMask GetSchoolMask() const { return _schoolMask; };
uint32 GetHitMask() const;
};
class TC_GAME_API ProcEventInfo
{
public:
ProcEventInfo(Unit* actor, Unit* actionTarget, Unit* procTarget, uint32 typeMask,
uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask,
Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo);
public:
ProcEventInfo(Unit* actor, Unit* actionTarget, Unit* procTarget, uint32 typeMask,
uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask,
Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo);
Unit* GetActor() { return _actor; }
Unit* GetActionTarget() const { return _actionTarget; }
Unit* GetProcTarget() const { return _procTarget; }
Unit* GetActor() { return _actor; }
Unit* GetActionTarget() const { return _actionTarget; }
Unit* GetProcTarget() const { return _procTarget; }
uint32 GetTypeMask() const { return _typeMask; }
uint32 GetSpellTypeMask() const { return _spellTypeMask; }
uint32 GetSpellPhaseMask() const { return _spellPhaseMask; }
uint32 GetHitMask() const { return _hitMask; }
uint32 GetTypeMask() const { return _typeMask; }
uint32 GetSpellTypeMask() const { return _spellTypeMask; }
uint32 GetSpellPhaseMask() const { return _spellPhaseMask; }
uint32 GetHitMask() const { return _hitMask; }
SpellInfo const* GetSpellInfo() const;
SpellSchoolMask GetSchoolMask() const;
SpellInfo const* GetSpellInfo() const;
SpellSchoolMask GetSchoolMask() const;
DamageInfo* GetDamageInfo() const { return _damageInfo; }
HealInfo* GetHealInfo() const { return _healInfo; }
DamageInfo* GetDamageInfo() const { return _damageInfo; }
HealInfo* GetHealInfo() const { return _healInfo; }
private:
Unit* const _actor;
Unit* const _actionTarget;
Unit* const _procTarget;
uint32 _typeMask;
uint32 _spellTypeMask;
uint32 _spellPhaseMask;
uint32 _hitMask;
Spell* _spell;
DamageInfo* _damageInfo;
HealInfo* _healInfo;
Spell const* GetProcSpell() const { return _spell; }
private:
Unit* const _actor;
Unit* const _actionTarget;
Unit* const _procTarget;
uint32 _typeMask;
uint32 _spellTypeMask;
uint32 _spellPhaseMask;
uint32 _hitMask;
Spell* _spell;
DamageInfo* _damageInfo;
HealInfo* _healInfo;
};
// Struct for use in Unit::CalculateMeleeDamage
@@ -996,7 +1010,6 @@ struct CalcDamageInfo
WeaponAttackType attackType; //
uint32 procAttacker;
uint32 procVictim;
uint32 procEx;
uint32 cleanDamage; // Used only for rage calculation
MeleeHitOutcome hitOutCome; /// @todo remove this field (need use TargetState)
};
@@ -1006,7 +1019,7 @@ struct TC_GAME_API SpellNonMeleeDamage
{
SpellNonMeleeDamage(Unit* _attacker, Unit* _target, uint32 _SpellID, uint32 _schoolMask)
: target(_target), attacker(_attacker), SpellID(_SpellID), damage(0), overkill(0), schoolMask(_schoolMask),
absorb(0), resist(0), physicalLog(false), unused(false), blocked(0), HitInfo(0), cleanDamage(0)
absorb(0), resist(0), physicalLog(false), unused(false), blocked(0), HitInfo(0), cleanDamage(0), fullBlock(false)
{ }
Unit *target;
@@ -1023,6 +1036,7 @@ struct TC_GAME_API SpellNonMeleeDamage
uint32 HitInfo;
// Used for help
uint32 cleanDamage;
bool fullBlock;
};
struct SpellPeriodicAuraLogInfo
@@ -1039,7 +1053,7 @@ struct SpellPeriodicAuraLogInfo
bool critical;
};
uint32 createProcExtendMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCondition);
uint32 createProcHitMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCondition);
struct RedirectThreatInfo
{
@@ -1264,8 +1278,6 @@ enum PlayerTotemType
#define ATTACK_DISPLAY_DELAY 200
#define MAX_PLAYER_STEALTH_DETECT_RANGE 30.0f // max distance for detection targets by player
struct SpellProcEventEntry; // used only privately
class TC_GAME_API Unit : public WorldObject
{
public:
@@ -1286,7 +1298,9 @@ class TC_GAME_API Unit : public WorldObject
typedef std::list<AuraEffect*> AuraEffectList;
typedef std::list<Aura*> AuraList;
typedef std::list<AuraApplication *> AuraApplicationList;
typedef std::list<DiminishingReturn> Diminishing;
typedef std::array<DiminishingReturn, DIMINISHING_MAX> Diminishing;
typedef std::vector<std::pair<uint8 /*procEffectMask*/, AuraApplication*>> AuraApplicationProcContainer;
typedef std::map<uint8, AuraApplication*> VisibleAuraMap;
@@ -1301,11 +1315,11 @@ class TC_GAME_API Unit : public WorldObject
void CleanupBeforeRemoveFromMap(bool finalCleanup);
void CleanupsBeforeDelete(bool finalCleanup = true) override; // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)
DiminishingLevels GetDiminishing(DiminishingGroup group);
void IncrDiminishing(DiminishingGroup group);
float ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration, Unit* caster, DiminishingLevels Level, int32 limitduration);
void ApplyDiminishingAura(DiminishingGroup group, bool apply);
void ClearDiminishings() { m_Diminishing.clear(); }
DiminishingLevels GetDiminishing(DiminishingGroup group);
void IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered);
bool ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel) const;
void ApplyDiminishingAura(DiminishingGroup group, bool apply);
void ClearDiminishings();
// target dependent range checks
float GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const;
@@ -1463,22 +1477,22 @@ class TC_GAME_API Unit : public WorldObject
void PlayOneShotAnimKitId(uint16 animKitId);
uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
void DealDamageMods(Unit* victim, uint32 &damage, uint32* absorb);
void DealDamageMods(Unit const* victim, uint32 &damage, uint32* absorb) const;
uint32 DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDamage = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* spellProto = NULL, bool durabilityLoss = true);
void Kill(Unit* victim, bool durabilityLoss = true);
void KillSelf(bool durabilityLoss = true) { Kill(this, durabilityLoss); }
int32 DealHeal(Unit* victim, uint32 addhealth);
void DealHeal(HealInfo& healInfo);
void ProcDamageAndSpell(Unit* victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellInfo const* procSpell = NULL, SpellInfo const* procAura = NULL);
void ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellInfo const* procSpell, uint32 damage, SpellInfo const* procAura = NULL);
void ProcSkillsAndAuras(Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget,
uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell,
DamageInfo* damageInfo, HealInfo* healInfo);
void GetProcAurasTriggeredOnEvent(AuraApplicationList& aurasTriggeringProc, AuraApplicationList* procAuras, ProcEventInfo eventInfo);
void GetProcAurasTriggeredOnEvent(AuraApplicationProcContainer& aurasTriggeringProc, AuraApplicationList* procAuras, ProcEventInfo& eventInfo);
void TriggerAurasProcOnEvent(CalcDamageInfo& damageInfo);
void TriggerAurasProcOnEvent(AuraApplicationList* myProcAuras, AuraApplicationList* targetProcAuras,
Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget,
void TriggerAurasProcOnEvent(Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget,
uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell,
DamageInfo* damageInfo, HealInfo* healInfo);
void TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, AuraApplicationList& procAuras);
void TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, AuraApplicationProcContainer& procAuras);
void HandleEmoteCommand(uint32 anim_id);
void AttackerStateUpdate (Unit* victim, WeaponAttackType attType = BASE_ATTACK, bool extra = false);
@@ -1575,23 +1589,23 @@ class TC_GAME_API Unit : public WorldObject
virtual void UpdateUnderwaterState(Map* m, float x, float y, float z);
bool isInAccessiblePlaceFor(Creature const* c) const;
void SendHealSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, uint32 OverHeal, uint32 Absorb, bool critical = false);
int32 HealBySpell(Unit* victim, SpellInfo const* spellInfo, uint32 addHealth, bool critical = false);
void SendHealSpellLog(HealInfo& healInfo, bool critical = false);
int32 HealBySpell(HealInfo& healInfo, bool critical = false);
void SendEnergizeSpellLog(Unit* victim, uint32 spellID, int32 damage, Powers powertype);
void EnergizeBySpell(Unit* victim, uint32 SpellID, int32 Damage, Powers powertype);
uint32 SpellNonMeleeDamageLog(Unit* victim, uint32 spellID, uint32 damage);
void CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastCustomSpell(Unit* victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim = NULL, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* victim = NULL, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(float x, float y, float z, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastCustomSpell(Unit* victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
Aura* AddAura(uint32 spellId, Unit* target);
Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target);
void SetAuraStack(uint32 spellId, Unit* target, uint32 stack);
@@ -1731,16 +1745,14 @@ class TC_GAME_API Unit : public WorldObject
bool InitTamedPet(Pet* pet, uint8 level, uint32 spell_id);
// aura apply/remove helpers - you should better not use these
Aura* _TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount = NULL, Item* castItem = NULL, ObjectGuid casterGUID = ObjectGuid::Empty);
Aura* _TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, ObjectGuid casterGUID = ObjectGuid::Empty, bool resetPeriodicTimer = true);
void _AddAura(UnitAura* aura, Unit* caster);
AuraApplication * _CreateAuraApplication(Aura* aura, uint8 effMask);
void _ApplyAuraEffect(Aura* aura, uint8 effIndex);
void _ApplyAura(AuraApplication * aurApp, uint8 effMask);
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode);
void _UnapplyAura(AuraApplication * aurApp, AuraRemoveMode removeMode);
void _RemoveNoStackAuraApplicationsDueToAura(Aura* aura);
void _RemoveNoStackAurasDueToAura(Aura* aura);
bool _IsNoStackAuraDueToAura(Aura* appliedAura, Aura* existingAura) const;
void _RegisterAuraEffect(AuraEffect* aurEff, bool apply);
// m_ownedAuras container management
@@ -1838,9 +1850,14 @@ class TC_GAME_API Unit : public WorldObject
int32 GetMaxPositiveAuraModifier(AuraType auratype) const;
int32 GetMaxNegativeAuraModifier(AuraType auratype) const;
int32 GetTotalAuraModifier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const;
float GetTotalAuraMultiplier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const;
int32 GetMaxPositiveAuraModifier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const;
int32 GetMaxNegativeAuraModifier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const;
int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const;
int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask, const AuraEffect* except = NULL) const;
int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask, AuraEffect const* except = nullptr) const;
int32 GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const;
@@ -2042,19 +2059,19 @@ class TC_GAME_API Unit : public WorldObject
uint32 GetRemainingPeriodicAmount(ObjectGuid caster, uint32 spellId, AuraType auraType, uint8 effectIndex = 0) const;
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply);
virtual bool IsImmunedToSpell(SpellInfo const* spellInfo) const; // redefined in Creature
virtual bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const; // redefined in Creature
uint32 GetSchoolImmunityMask() const;
uint32 GetMechanicImmunityMask() const;
bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const;
bool IsImmunedToDamage(SpellInfo const* spellInfo) const;
virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const; // redefined in Creature
virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const; // redefined in Creature
static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = NULL, uint8 effIndex = MAX_SPELL_EFFECTS);
uint32 CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = MAX_ATTACK);
uint32 CalcSpellResistance(Unit* victim, SpellSchoolMask schoolMask, SpellInfo const* spellInfo) const;
void CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, uint32 const damage, uint32* absorb, uint32* resist, SpellInfo const* spellInfo = NULL);
void CalcHealAbsorb(Unit* victim, SpellInfo const* spellInfo, uint32& healAmount, uint32& absorb);
void CalcAbsorbResist(DamageInfo& damageInfo);
void CalcHealAbsorb(HealInfo& healInfo) const;
void UpdateSpeed(UnitMoveType mtype);
float GetSpeed(UnitMoveType mtype) const;
@@ -2117,7 +2134,7 @@ class TC_GAME_API Unit : public WorldObject
void UpdateAuraForGroup(uint8 slot);
// proc trigger system
bool CanProc() const {return !m_procDeep;}
bool CanProc() const { return !m_procDeep; }
void SetCantProc(bool apply);
uint32 GetModelForForm(ShapeshiftForm form, uint32 spellId) const;
@@ -2283,16 +2300,8 @@ class TC_GAME_API Unit : public WorldObject
bool IsAlwaysDetectableFor(WorldObject const* seer) const override;
void DisableSpline();
private:
bool IsTriggeredAtSpellProcEvent(Unit* victim, Aura* aura, SpellInfo const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const*& spellProcEvent);
bool RollProcResult(Unit* victim, Aura* aura, WeaponAttackType attType, bool isVictim, SpellProcEventEntry const* spellProcEvent);
bool HandleAuraProcOnPowerAmount(Unit* victim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
bool HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
bool HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown, bool * handled);
bool HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
bool HandleOverrideClassScriptAuraProc(Unit* victim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 cooldown);
bool HandleAuraRaidProcFromChargeWithValue(AuraEffect* triggeredByAura);
bool HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura);
void UpdateSplineMovement(uint32 t_diff);
void UpdateSplinePosition();
@@ -2301,6 +2310,8 @@ class TC_GAME_API Unit : public WorldObject
float GetCombatRatingReduction(CombatRating cr) const;
uint32 GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const;
void ProcSkillsAndReactives(bool isVictim, Unit* procTarget, uint32 typeMask, uint32 hitMask, WeaponAttackType attType);
protected:
void SetFeared(bool apply);
void SetConfused(bool apply);
@@ -893,10 +893,11 @@ namespace Trinity
float i_range;
};
class NearestUnfriendlyNoTotemUnitInObjectRangeCheck
class NearestAttackableNoTotemUnitInObjectRangeCheck
{
public:
NearestUnfriendlyNoTotemUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) { }
NearestAttackableNoTotemUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) { }
bool operator()(Unit* u)
{
if (!u->IsAlive())
@@ -905,13 +906,13 @@ namespace Trinity
if (u->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET)
return false;
if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->IsTotem())
if (u->GetTypeId() == TYPEID_UNIT && u->ToCreature()->IsTotem())
return false;
if (!u->isTargetableForAttack(false))
return false;
if (!i_obj->IsWithinDistInMap(u, i_range) || i_funit->IsFriendlyTo(u))
if (!i_obj->IsWithinDistInMap(u, i_range) || !i_funit->_IsValidAttackTarget(u, nullptr, i_obj))
return false;
i_range = i_obj->GetDistance(*u);
+14 -22
View File
@@ -1028,21 +1028,18 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject)
Player* member = itr->GetSource();
if (!member || !member->GetSession())
continue;
if (i->AllowedForPlayer(member))
if (member->IsAtGroupRewardDistance(pLootedObject) && i->AllowedForPlayer(member))
{
if (member->IsAtGroupRewardDistance(pLootedObject))
{
r->totalPlayersRolling++;
r->totalPlayersRolling++;
if (member->GetPassOnGroupLoot())
{
r->playerVote[member->GetGUID()] = PASS;
r->totalPass++;
// can't broadcast the pass now. need to wait until all rolling players are known.
}
else
r->playerVote[member->GetGUID()] = NOT_EMITED_YET;
if (member->GetPassOnGroupLoot())
{
r->playerVote[member->GetGUID()] = PASS;
r->totalPass++;
// can't broadcast the pass now. need to wait until all rolling players are known.
}
else
r->playerVote[member->GetGUID()] = NOT_EMITED_YET;
}
}
@@ -1114,13 +1111,10 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject)
if (!member || !member->GetSession())
continue;
if (i->AllowedForPlayer(member))
if (member->IsAtGroupRewardDistance(pLootedObject) && i->AllowedForPlayer(member))
{
if (member->IsAtGroupRewardDistance(pLootedObject))
{
r->totalPlayersRolling++;
r->playerVote[member->GetGUID()] = NOT_EMITED_YET;
}
r->totalPlayersRolling++;
r->playerVote[member->GetGUID()] = NOT_EMITED_YET;
}
}
@@ -1175,8 +1169,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
if (!playerToRoll || !playerToRoll->GetSession())
continue;
bool allowedForPlayer = i->AllowedForPlayer(playerToRoll);
if (allowedForPlayer && playerToRoll->IsAtGroupRewardDistance(lootedObject))
if (playerToRoll->IsAtGroupRewardDistance(lootedObject) && i->AllowedForPlayer(playerToRoll))
{
r->totalPlayersRolling++;
if (playerToRoll->GetPassOnGroupLoot())
@@ -1251,8 +1244,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
if (!playerToRoll || !playerToRoll->GetSession())
continue;
bool allowedForPlayer = i->AllowedForPlayer(playerToRoll);
if (allowedForPlayer && playerToRoll->IsAtGroupRewardDistance(lootedObject))
if (playerToRoll->IsAtGroupRewardDistance(lootedObject) && i->AllowedForPlayer(playerToRoll))
{
r->totalPlayersRolling++;
r->playerVote[playerToRoll->GetGUID()] = NOT_EMITED_YET;
+2 -1
View File
@@ -445,7 +445,8 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData)
return;
}
Player* target = ObjectAccessor::FindPlayer(target_playerguid);
// player on other map
Player* target = ObjectAccessor::GetPlayer(*_player, target_playerguid);
if (!target)
{
_player->SendLootError(lootguid, LOOT_ERROR_PLAYER_NOT_FOUND);
+3 -3
View File
@@ -1065,7 +1065,7 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recvData)
TC_LOG_DEBUG("network", "WORLD: Received CMSG_INSPECT");
Player* player = ObjectAccessor::FindPlayer(guid);
Player* player = ObjectAccessor::GetPlayer(*_player, guid);
if (!player)
{
TC_LOG_DEBUG("network", "CMSG_INSPECT: No player found from %s", guid.ToString().c_str());
@@ -1122,7 +1122,7 @@ void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recvData)
recvData.ReadByteSeq(guid[6]);
recvData.ReadByteSeq(guid[2]);
recvData.ReadByteSeq(guid[3]);
Player* player = ObjectAccessor::FindPlayer(guid);
Player* player = ObjectAccessor::GetPlayer(*_player, guid);
if (!player)
{
TC_LOG_DEBUG("network", "CMSG_INSPECT_HONOR_STATS: No player found from %s", guid.ToString().c_str());
@@ -1567,7 +1567,7 @@ void WorldSession::HandleQueryInspectAchievements(WorldPacket& recvData)
recvData >> guid.ReadAsPacked();
TC_LOG_DEBUG("network", "CMSG_QUERY_INSPECT_ACHIEVEMENTS [%s] Inspected Player [%s]", _player->GetGUID().ToString().c_str(), guid.ToString().c_str());
Player* player = ObjectAccessor::FindPlayer(guid);
Player* player = ObjectAccessor::GetPlayer(*_player, guid);
if (!player)
return;
+1 -1
View File
@@ -711,7 +711,7 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket)
if (!_player->GetGuardianPet() && !_player->GetCharm())
return;
if (ObjectAccessor::FindPlayer(guid))
if (guid.IsPlayer())
return;
Creature* pet=ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
+4 -1
View File
@@ -142,7 +142,7 @@ void WorldSession::HandleEnterPlayerVehicle(WorldPacket& data)
ObjectGuid guid;
data >> guid;
if (Player* player = ObjectAccessor::FindPlayer(guid))
if (Player* player = ObjectAccessor::GetPlayer(*_player, guid))
{
if (!player->GetVehicleKit())
return;
@@ -150,6 +150,9 @@ void WorldSession::HandleEnterPlayerVehicle(WorldPacket& data)
return;
if (!player->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
return;
// Dont' allow players to enter player vehicle on arena
if (!_player->FindMap() || _player->FindMap()->IsBattleArena())
return;
_player->EnterVehicle(player);
}
+1 -1
View File
@@ -679,7 +679,7 @@ void InstanceScript::UpdateEncounterState(EncounterCreditType type, uint32 credi
if (Group* grp = player->GetGroup())
if (grp->isLFGGroup())
{
sLFGMgr->FinishDungeon(grp->GetGUID(), dungeonId);
sLFGMgr->FinishDungeon(grp->GetGUID(), dungeonId, instance);
return;
}
}
+5
View File
@@ -3447,6 +3447,11 @@ void BattlegroundMap::RemoveAllPlayers()
player->TeleportTo(player->GetBattlegroundEntryPoint());
}
Player* Map::GetPlayer(ObjectGuid const& guid)
{
return ObjectAccessor::GetPlayer(this, guid);
}
AreaTrigger* Map::GetAreaTrigger(ObjectGuid const& guid)
{
return _objectsStore.Find<AreaTrigger>(guid);
+3 -2
View File
@@ -446,8 +446,9 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
void UpdateIteratorBack(Player* player);
TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = NULL, uint32 duration = 0, Unit* summoner = NULL, uint32 spellId = 0, uint32 vehId = 0);
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = NULL);
TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, Unit* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0);
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
Player* GetPlayer(ObjectGuid const& guid);
AreaTrigger* GetAreaTrigger(ObjectGuid const& guid);
Corpse* GetCorpse(ObjectGuid const& guid);
Creature* GetCreature(ObjectGuid const& guid);
+3 -3
View File
@@ -296,7 +296,7 @@ void Map::ScriptsProcess()
switch (step.sourceGUID.GetHigh())
{
case HighGuid::Item: // as well as HighGuid::Container
if (Player* player = HashMapHolder<Player>::Find(step.ownerGUID))
if (Player* player = GetPlayer(step.ownerGUID))
source = player->GetItemByGuid(step.sourceGUID);
break;
case HighGuid::Unit:
@@ -307,7 +307,7 @@ void Map::ScriptsProcess()
source = GetPet(step.sourceGUID);
break;
case HighGuid::Player:
source = HashMapHolder<Player>::Find(step.sourceGUID);
source = GetPlayer(step.sourceGUID);
break;
case HighGuid::Transport:
case HighGuid::GameObject:
@@ -339,7 +339,7 @@ void Map::ScriptsProcess()
target = GetPet(step.targetGUID);
break;
case HighGuid::Player: // empty GUID case also
target = HashMapHolder<Player>::Find(step.targetGUID);
target = GetPlayer(step.targetGUID);
break;
case HighGuid::Transport:
case HighGuid::GameObject:
@@ -602,7 +602,7 @@ enum SpellAttr7
SPELL_ATTR7_UNK17 = 0x00020000, // 17 Only 27965 (Suicide) spell.
SPELL_ATTR7_HAS_CHARGE_EFFECT = 0x00040000, // 18 Only spells that have Charge among effects.
SPELL_ATTR7_ZONE_TELEPORT = 0x00080000, // 19 Teleports to specific zones.
SPELL_ATTR7_USABLE_IN_STUN_FEAR_CONFUSION = 0x00100000, // 20 Blink, Divine Shield, Ice Block
SPELL_ATTR7_UNK20 = 0x00100000, // 20 Blink, Divine Shield, Ice Block
SPELL_ATTR7_UNK21 = 0x00200000, // 21 Not set
SPELL_ATTR7_UNK22 = 0x00400000, // 22
SPELL_ATTR7_UNK23 = 0x00800000, // 23 Motivate, Mutilate, Shattering Throw
@@ -3644,7 +3644,7 @@ enum DiminishingReturnsType
};
// Diminishing Return Groups
enum DiminishingGroup
enum DiminishingGroup : uint16
{
DIMINISHING_NONE = 0,
DIMINISHING_BANISH = 1,
@@ -3666,7 +3666,9 @@ enum DiminishingGroup
DIMINISHING_SLEEP = 17,
DIMINISHING_TAUNT = 18,
DIMINISHING_LIMITONLY = 19,
DIMINISHING_DRAGONS_BREATH = 20
DIMINISHING_DRAGONS_BREATH = 20,
DIMINISHING_MAX
};
enum SummonCategory
+12 -9
View File
@@ -1204,12 +1204,11 @@ void ScriptMgr::FillSpellSummary()
}
}
template<typename T, typename F>
void CreateSpellOrAuraScripts(uint32 spellId, std::list<T*>& scriptVector, F&& extractor)
template<typename T, typename F, typename O>
void CreateSpellOrAuraScripts(uint32 spellId, std::vector<T*>& scriptVector, F&& extractor, O* objectInvoker)
{
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
for (auto itr = bounds.first; itr != bounds.second; ++itr)
{
// When the script is disabled continue with the next one
if (!itr->second.second)
@@ -1220,24 +1219,28 @@ void CreateSpellOrAuraScripts(uint32 spellId, std::list<T*>& scriptVector, F&& e
continue;
T* script = (*tmpscript.*extractor)();
if (!script)
continue;
script->_Init(&tmpscript->GetName(), spellId);
if (!script->_Load(objectInvoker))
{
delete script;
continue;
}
scriptVector.push_back(script);
}
}
void ScriptMgr::CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector)
void ScriptMgr::CreateSpellScripts(uint32 spellId, std::vector<SpellScript*>& scriptVector, Spell* invoker) const
{
CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetSpellScript);
CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetSpellScript, invoker);
}
void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list<AuraScript*>& scriptVector)
void ScriptMgr::CreateAuraScripts(uint32 spellId, std::vector<AuraScript*>& scriptVector, Aura* invoker) const
{
CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetAuraScript);
CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetAuraScript, invoker);
}
SpellScriptLoader* ScriptMgr::GetSpellScriptLoader(uint32 scriptId)
+3 -2
View File
@@ -29,6 +29,7 @@
class AccountMgr;
class AuctionHouseObject;
class Aura;
class AuraScript;
class Battleground;
class BattlegroundMap;
@@ -894,8 +895,8 @@ class TC_GAME_API ScriptMgr
public: /* SpellScriptLoader */
void CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector);
void CreateAuraScripts(uint32 spellId, std::list<AuraScript*>& scriptVector);
void CreateSpellScripts(uint32 spellId, std::vector<SpellScript*>& scriptVector, Spell* invoker) const;
void CreateAuraScripts(uint32 spellId, std::vector<AuraScript*>& scriptVector, Aura* invoker) const;
SpellScriptLoader* GetSpellScriptLoader(uint32 scriptId);
public: /* ServerScript */
+212 -53
View File
@@ -100,8 +100,8 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleAuraModSchoolImmunity, // 39 SPELL_AURA_SCHOOL_IMMUNITY
&AuraEffect::HandleAuraModDmgImmunity, // 40 SPELL_AURA_DAMAGE_IMMUNITY
&AuraEffect::HandleAuraModDispelImmunity, // 41 SPELL_AURA_DISPEL_IMMUNITY
&AuraEffect::HandleNoImmediateEffect, // 42 SPELL_AURA_PROC_TRIGGER_SPELL implemented in Unit::ProcDamageAndSpellFor and Unit::HandleProcTriggerSpell
&AuraEffect::HandleNoImmediateEffect, // 43 SPELL_AURA_PROC_TRIGGER_DAMAGE implemented in Unit::ProcDamageAndSpellFor
&AuraEffect::HandleNoImmediateEffect, // 42 SPELL_AURA_PROC_TRIGGER_SPELL implemented in AuraEffect::HandleProc
&AuraEffect::HandleNoImmediateEffect, // 43 SPELL_AURA_PROC_TRIGGER_DAMAGE implemented in AuraEffect::HandleProc
&AuraEffect::HandleAuraTrackCreatures, // 44 SPELL_AURA_TRACK_CREATURES
&AuraEffect::HandleAuraTrackResources, // 45 SPELL_AURA_TRACK_RESOURCES
&AuraEffect::HandleNULL, // 46 SPELL_AURA_46 (used in test spells 54054 and 54058, and spell 48050) (3.0.8a)
@@ -320,7 +320,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleUnused, //259 unused (4.3.4) old SPELL_AURA_MOD_HOT_PCT
&AuraEffect::HandleNoImmediateEffect, //260 SPELL_AURA_SCREEN_EFFECT (miscvalue = id in ScreenEffect.dbc) not required any code
&AuraEffect::HandlePhase, //261 SPELL_AURA_PHASE
&AuraEffect::HandleNoImmediateEffect, //262 SPELL_AURA_ABILITY_IGNORE_AURASTATE implemented in spell::cancast
&AuraEffect::HandleNoImmediateEffect, //262 SPELL_AURA_ABILITY_IGNORE_AURASTATE implemented in Spell::CheckCast
&AuraEffect::HandleAuraAllowOnlyAbility, //263 SPELL_AURA_ALLOW_ONLY_ABILITY player can use only abilities set in SpellClassMask
&AuraEffect::HandleUnused, //264 unused (3.2.0)
&AuraEffect::HandleUnused, //265 unused (4.3.4)
@@ -386,7 +386,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleUnused, //325 unused (4.3.4)
&AuraEffect::HandlePhaseGroup, //326 SPELL_AURA_PHASE_GROUP
&AuraEffect::HandleUnused, //327 unused (4.3.4)
&AuraEffect::HandleNoImmediateEffect, //328 SPELL_AURA_PROC_ON_POWER_AMOUNT implemented in Unit::HandleAuraProcOnPowerAmount
&AuraEffect::HandleNoImmediateEffect, //328 SPELL_AURA_PROC_ON_POWER_AMOUNT implemented in AuraEffect::HandleProc
&AuraEffect::HandleNULL, //329 SPELL_AURA_MOD_RUNE_REGEN_SPEED
&AuraEffect::HandleNoImmediateEffect, //330 SPELL_AURA_CAST_WHILE_WALKING
&AuraEffect::HandleAuraForceWeather, //331 SPELL_AURA_FORCE_WEATHER
@@ -629,14 +629,13 @@ void AuraEffect::CalculatePeriodic(Unit* caster, bool resetPeriodicTimer /*= tru
if (!m_isPeriodic)
return;
Player* modOwner = caster ? caster->GetSpellModOwner() : NULL;
Player* modOwner = caster ? caster->GetSpellModOwner() : nullptr;
// Apply casting time mods
if (m_amplitude)
{
// Apply periodic time mod
if (modOwner)
modOwner->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME, m_amplitude);
modOwner->ApplySpellMod<SPELLMOD_ACTIVATION_TIME>(GetId(), m_amplitude);
if (caster)
{
@@ -658,9 +657,9 @@ void AuraEffect::CalculatePeriodic(Unit* caster, bool resetPeriodicTimer /*= tru
else // aura just created or reapplied
{
m_tickNumber = 0;
// reset periodic timer on aura create or on reapply when aura isn't dot
// possibly we should not reset periodic timers only when aura is triggered by proc
// or maybe there's a spell attribute somewhere
// reset periodic timer on aura create or reapply
// we don't reset periodic timers when aura is triggered by proc
if (resetPeriodicTimer)
{
m_periodicTimer = 0;
@@ -685,7 +684,6 @@ void AuraEffect::CalculateSpellMod()
m_spellmod->type = SpellModType(uint32(GetAuraType())); // SpellModType value == spell aura types
m_spellmod->spellId = GetId();
m_spellmod->mask = GetSpellInfo()->Effects[GetEffIndex()].SpellClassMask;
m_spellmod->charges = GetBase()->GetCharges();
}
m_spellmod->value = GetAmount();
break;
@@ -1067,6 +1065,81 @@ void AuraEffect::PeriodicTick(AuraApplication * aurApp, Unit* caster) const
}
}
bool AuraEffect::CheckEffectProc(AuraApplication* aurApp, ProcEventInfo& eventInfo) const
{
bool result = GetBase()->CallScriptCheckEffectProcHandlers(this, aurApp, eventInfo);
if (!result)
return false;
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
switch (GetAuraType())
{
case SPELL_AURA_MOD_CONFUSE:
case SPELL_AURA_MOD_FEAR:
case SPELL_AURA_MOD_STUN:
case SPELL_AURA_MOD_ROOT:
case SPELL_AURA_TRANSFORM:
{
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
return false;
// Spell own damage at apply won't break CC
if (spellInfo && spellInfo == GetSpellInfo())
{
Aura* aura = GetBase();
// called from spellcast, should not have ticked yet
if (aura->GetDuration() == aura->GetMaxDuration())
return false;
}
break;
}
case SPELL_AURA_MECHANIC_IMMUNITY:
case SPELL_AURA_MOD_MECHANIC_RESISTANCE:
// compare mechanic
if (!spellInfo || static_cast<int32>(spellInfo->Mechanic) != GetMiscValue())
return false;
break;
case SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK:
// skip melee hits and instant cast spells
if (!spellInfo || !spellInfo->CalcCastTime())
return false;
break;
case SPELL_AURA_MOD_DAMAGE_FROM_CASTER:
// Compare casters
if (GetCasterGUID() != eventInfo.GetActor()->GetGUID())
return false;
break;
case SPELL_AURA_MOD_POWER_COST_SCHOOL:
case SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT:
// Skip melee hits and spells with wrong school or zero cost
if (!spellInfo || (!spellInfo->ManaCost && !spellInfo->ManaCostPercentage) || // Cost Check
!(spellInfo->GetSchoolMask() & GetMiscValue())) // School Check
return false;
break;
case SPELL_AURA_REFLECT_SPELLS_SCHOOL:
// Skip melee hits and spells with wrong school
if (!spellInfo || !(spellInfo->GetSchoolMask() & GetMiscValue()))
return false;
break;
case SPELL_AURA_PROC_TRIGGER_SPELL:
case SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE:
case SPELL_AURA_PROC_ON_POWER_AMOUNT:
{
// Don't proc extra attacks while already processing extra attack spell
uint32 triggerSpellId = GetSpellInfo()->Effects[GetEffIndex()].TriggerSpell;
if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId))
if (aurApp->GetTarget()->m_extraAttacks && triggeredSpellInfo->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
return false;
break;
}
default:
break;
}
return result;
}
void AuraEffect::HandleProc(AuraApplication* aurApp, ProcEventInfo& eventInfo)
{
bool prevented = GetBase()->CallScriptEffectProcHandlers(this, aurApp, eventInfo);
@@ -1075,6 +1148,16 @@ void AuraEffect::HandleProc(AuraApplication* aurApp, ProcEventInfo& eventInfo)
switch (GetAuraType())
{
// CC Auras which use their amount to drop
// Are there any more auras which need this?
case SPELL_AURA_MOD_CONFUSE:
case SPELL_AURA_MOD_FEAR:
case SPELL_AURA_MOD_STUN:
case SPELL_AURA_MOD_ROOT:
case SPELL_AURA_TRANSFORM:
HandleBreakableCCAuraProc(aurApp, eventInfo);
break;
case SPELL_AURA_DUMMY:
case SPELL_AURA_PROC_TRIGGER_SPELL:
HandleProcTriggerSpellAuraProc(aurApp, eventInfo);
break;
@@ -1090,6 +1173,9 @@ void AuraEffect::HandleProc(AuraApplication* aurApp, ProcEventInfo& eventInfo)
case SPELL_AURA_RAID_PROC_FROM_CHARGE_WITH_VALUE:
HandleRaidProcFromChargeWithValueAuraProc(aurApp, eventInfo);
break;
case SPELL_AURA_PROC_ON_POWER_AMOUNT:
HandleProcOnPowerAmountAuraProc(aurApp, eventInfo);
break;
default:
break;
}
@@ -3521,7 +3607,13 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const* aurApp, uint8
// save current health state
float healthPct = target->GetHealthPct();
bool alive = target->IsAlive();
bool zeroHealth = !target->IsAlive();
// players in corpse state may mean two different states:
/// 1. player just died but did not release (in this case health == 0)
/// 2. player is corpse running (ie ghost) (in this case health == 1)
if (target->getDeathState() == CORPSE)
zeroHealth = (target->GetHealth() == 0);
for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
{
@@ -3547,7 +3639,7 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const* aurApp, uint8
// recalculate current HP/MP after applying aura modifications (only for spells with SPELL_ATTR0_UNK4 0x00000010 flag)
// this check is total bullshit i think
if (GetMiscValueB() & 1 << STAT_STAMINA && (m_spellInfo->Attributes & SPELL_ATTR0_ABILITY))
target->SetHealth(std::max<uint32>(uint32(healthPct * target->GetMaxHealth() * 0.01f), (alive ? 1 : 0)));
target->SetHealth(std::max<uint32>(CalculatePct(target->GetMaxHealth(), healthPct), (zeroHealth ? 1 : 0)));
}
void AuraEffect::HandleAuraModResistenceOfStatPercent(AuraApplication const* aurApp, uint8 mode, bool /*apply*/) const
@@ -4097,7 +4189,6 @@ void AuraEffect::HandleModDamageDone(AuraApplication const* aurApp, uint8 mode,
target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(GetAmount()), apply);
target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(GetAmount()), apply);
}
else
// Magic damage modifiers implemented in Unit::SpellBaseDamageBonusDone
// This information for client side use only
@@ -4356,10 +4447,6 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
if (caster)
target->GetMotionMaster()->MoveFall();
break;
case 71563:
if (Aura* newAura = target->AddAura(71564, target))
newAura->SetStackAmount(newAura->GetSpellInfo()->StackAmount);
break;
}
}
// AT REMOVE
@@ -5147,8 +5234,10 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
if (caster)
{
int32 heal = caster->CountPctFromMaxHealth(10);
caster->HealBySpell(target, auraSpellInfo, heal);
HealInfo healInfo(caster, target, heal, auraSpellInfo, auraSpellInfo->GetSchoolMask());
caster->HealBySpell(healInfo);
/// @todo: should proc other auras?
if (int32 mana = caster->GetMaxPower(POWER_MANA))
{
mana /= 10;
@@ -5434,8 +5523,6 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
}
}
uint32 absorb = 0;
uint32 resist = 0;
CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
// AOE spells are not affected by the new periodic system.
@@ -5454,7 +5541,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
damage = std::max(int32(damage * GetDonePct()), 0);
if (Player* modOwner = caster->GetSpellModOwner())
modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_DOT, damage);
modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, damage);
damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount());
@@ -5503,12 +5590,14 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
damage = uint32(ceil(CalculatePct<float, float>(target->GetMaxHealth(), damage)));
if (!m_spellInfo->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
{
if (m_spellInfo->Effects[m_effIndex].IsTargetingArea() || isAreaAura)
{
damage = int32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask));
if (caster->GetTypeId() != TYPEID_PLAYER)
damage = int32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask));
}
}
bool crit = false;
@@ -5519,13 +5608,16 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
damage = caster->SpellCriticalDamageBonus(m_spellInfo, damage, target);
int32 dmg = damage;
if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
caster->ApplyResilience(target, &dmg);
damage = dmg;
caster->CalcAbsorbResist(target, GetSpellInfo()->GetSchoolMask(), DOT, damage, &absorb, &resist, GetSpellInfo());
DamageInfo damageInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask(), DOT, BASE_ATTACK);
caster->CalcAbsorbResist(damageInfo);
damage = damageInfo.GetDamage();
uint32 absorb = damageInfo.GetAbsorb();
uint32 resist = damageInfo.GetResist();
TC_LOG_DEBUG("spells.periodic", "PeriodicTick: %s attacked %s for %u dmg inflicted by %u absorb is %u",
GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId(), absorb);
@@ -5534,10 +5626,12 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
// Set trigger flag
uint32 procAttacker = PROC_FLAG_DONE_PERIODIC;
uint32 procVictim = PROC_FLAG_TAKEN_PERIODIC;
uint32 procEx = (crit ? PROC_EX_CRITICAL_HIT : PROC_EX_NORMAL_HIT) | PROC_EX_INTERNAL_DOT;
damage = (damage <= absorb+resist) ? 0 : (damage-absorb-resist);
uint32 hitMask = damageInfo.GetHitMask();
if (damage)
{
hitMask |= crit ? PROC_HIT_CRITICAL : PROC_HIT_NORMAL;
procVictim |= PROC_FLAG_TAKEN_DAMAGE;
}
int32 overkill = damage - target->GetHealth();
if (overkill < 0)
@@ -5546,9 +5640,9 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
SpellPeriodicAuraLogInfo pInfo(this, damage, overkill, absorb, resist, 0.0f, crit);
target->SendPeriodicAuraLog(&pInfo);
caster->ProcDamageAndSpell(target, procAttacker, procVictim, procEx, damage, BASE_ATTACK, GetSpellInfo());
caster->DealDamage(target, damage, &cleanDamage, DOT, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), true);
caster->ProcSkillsAndAuras(target, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_NONE, hitMask, nullptr, &damageInfo, nullptr);
}
void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) const
@@ -5566,8 +5660,6 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
caster->SpellHitResult(target, GetSpellInfo(), false) != SPELL_MISS_NONE)
return;
uint32 absorb = 0;
uint32 resist = 0;
CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
bool isAreaAura = m_spellInfo->Effects[m_effIndex].IsAreaAuraEffect() || m_spellInfo->Effects[m_effIndex].IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA);
@@ -5582,6 +5674,9 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
else
damage = std::max(int32(damage * GetDonePct()), 0);
if (Player* modOwner = caster->GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, damage);
damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount());
// Calculate armor mitigation
@@ -5593,12 +5688,14 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
}
if (!m_spellInfo->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
{
if (m_spellInfo->Effects[m_effIndex].IsTargetingArea() || isAreaAura)
{
damage = uint32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask));
if (caster->GetTypeId() != TYPEID_PLAYER)
damage = uint32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask));
}
}
bool crit = false;
@@ -5613,32 +5710,43 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
caster->ApplyResilience(target, &dmg);
damage = dmg;
caster->CalcAbsorbResist(target, GetSpellInfo()->GetSchoolMask(), DOT, damage, &absorb, &resist, m_spellInfo);
DamageInfo damageInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask(), DOT, BASE_ATTACK);
caster->CalcAbsorbResist(damageInfo);
uint32 absorb = damageInfo.GetAbsorb();
uint32 resist = damageInfo.GetResist();
TC_LOG_DEBUG("spells.periodic", "PeriodicTick: %s health leech of %s for %u dmg inflicted by %u abs is %u",
GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId(), absorb);
// SendSpellNonMeleeDamageLog expects non-absorbed/non-resisted damage
caster->SendSpellNonMeleeDamageLog(target, GetId(), damage, GetSpellInfo()->GetSchoolMask(), absorb, resist, false, 0, crit);
damage = damageInfo.GetDamage();
// Set trigger flag
uint32 procAttacker = PROC_FLAG_DONE_PERIODIC;
uint32 procVictim = PROC_FLAG_TAKEN_PERIODIC;
uint32 procEx = (crit ? PROC_EX_CRITICAL_HIT : PROC_EX_NORMAL_HIT) | PROC_EX_INTERNAL_DOT;
damage = (damage <= absorb+resist) ? 0 : (damage-absorb-resist);
uint32 hitMask = damageInfo.GetHitMask();
if (damage)
{
hitMask |= crit ? PROC_HIT_CRITICAL : PROC_HIT_NORMAL;
procVictim |= PROC_FLAG_TAKEN_DAMAGE;
if (caster->IsAlive())
caster->ProcDamageAndSpell(target, procAttacker, procVictim, procEx, damage, BASE_ATTACK, GetSpellInfo());
}
int32 new_damage = caster->DealDamage(target, damage, &cleanDamage, DOT, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), false);
if (caster->IsAlive())
{
caster->ProcSkillsAndAuras(target, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_NONE, hitMask, nullptr, &damageInfo, nullptr);
float gainMultiplier = GetSpellInfo()->Effects[GetEffIndex()].CalcValueMultiplier(caster);
uint32 heal = uint32(caster->SpellHealingBonusDone(caster, GetSpellInfo(), uint32(new_damage * gainMultiplier), DOT, GetBase()->GetStackAmount()));
heal = uint32(caster->SpellHealingBonusTaken(caster, GetSpellInfo(), heal, DOT, GetBase()->GetStackAmount()));
int32 gain = caster->HealBySpell(caster, GetSpellInfo(), heal);
caster->getHostileRefManager().threatAssist(caster, gain * 0.5f, GetSpellInfo());
HealInfo healInfo(caster, caster, heal, GetSpellInfo(), GetSpellInfo()->GetSchoolMask());
caster->HealBySpell(healInfo);
caster->getHostileRefManager().threatAssist(caster, healInfo.GetEffectiveHeal() * 0.5f, GetSpellInfo());
caster->ProcSkillsAndAuras(caster, PROC_FLAG_DONE_PERIODIC, PROC_FLAG_TAKEN_PERIODIC, PROC_SPELL_TYPE_HEAL, PROC_SPELL_PHASE_NONE, hitMask, nullptr, nullptr, &healInfo);
}
}
@@ -5667,7 +5775,9 @@ void AuraEffect::HandlePeriodicHealthFunnelAuraTick(Unit* target, Unit* caster)
damage = int32(damage * gainMultiplier);
caster->HealBySpell(target, GetSpellInfo(), damage);
HealInfo healInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask());
caster->HealBySpell(healInfo);
caster->ProcSkillsAndAuras(target, PROC_FLAG_DONE_PERIODIC, PROC_FLAG_TAKEN_PERIODIC, PROC_SPELL_TYPE_HEAL, PROC_SPELL_PHASE_NONE, PROC_HIT_NORMAL, nullptr, nullptr, &healInfo);
}
void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
@@ -5740,7 +5850,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
damage = std::max(int32(damage * GetDonePct()), 0);
if (Player* modOwner = caster->GetSpellModOwner())
modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_DOT, damage);
modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, damage);
damage = target->SpellHealingBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount());
}
@@ -5756,15 +5866,16 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
TC_LOG_DEBUG("spells.periodic", "PeriodicTick: %s heal of %s for %u health inflicted by %u",
GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId());
uint32 absorb = 0;
uint32 heal = damage;
caster->CalcHealAbsorb(target, GetSpellInfo(), heal, absorb);
int32 gain = caster->DealHeal(target, heal);
SpellPeriodicAuraLogInfo pInfo(this, heal, heal - gain, absorb, 0, 0.0f, crit);
HealInfo healInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask());
caster->CalcHealAbsorb(healInfo);
caster->DealHeal(healInfo);
SpellPeriodicAuraLogInfo pInfo(this, heal, heal - healInfo.GetEffectiveHeal(), healInfo.GetAbsorb(), 0, 0.0f, crit);
target->SendPeriodicAuraLog(&pInfo);
target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, GetSpellInfo());
target->getHostileRefManager().threatAssist(caster, float(healInfo.GetEffectiveHeal()) * 0.5f, GetSpellInfo());
bool haveCastItem = !GetBase()->GetCastItemGUID().IsEmpty();
@@ -5774,8 +5885,8 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
{
uint32 funnelDamage = GetSpellInfo()->ManaPerSecond; // damage is not affected by spell power
if ((int32)funnelDamage > gain && gain > 0)
funnelDamage = gain;
if (funnelDamage > healInfo.GetEffectiveHeal() && healInfo.GetEffectiveHeal())
funnelDamage = healInfo.GetEffectiveHeal();
uint32 funnelAbsorb = 0;
caster->DealDamageMods(caster, funnelDamage, &funnelAbsorb);
@@ -5791,10 +5902,10 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
uint32 procAttacker = PROC_FLAG_DONE_PERIODIC;
uint32 procVictim = PROC_FLAG_TAKEN_PERIODIC;
uint32 procEx = (crit ? PROC_EX_CRITICAL_HIT : PROC_EX_NORMAL_HIT) | PROC_EX_INTERNAL_HOT;
uint32 hitMask = crit ? PROC_HIT_CRITICAL : PROC_HIT_NORMAL;
// ignore item heals
if (!haveCastItem)
caster->ProcDamageAndSpell(target, procAttacker, procVictim, procEx, damage, BASE_ATTACK, GetSpellInfo());
caster->ProcSkillsAndAuras(target, procAttacker, procVictim, PROC_SPELL_TYPE_HEAL, PROC_SPELL_PHASE_NONE, hitMask, nullptr, nullptr, &healInfo);
}
void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) const
@@ -5965,13 +6076,28 @@ void AuraEffect::HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) con
// Set trigger flag
uint32 procAttacker = PROC_FLAG_DONE_PERIODIC;
uint32 procVictim = PROC_FLAG_TAKEN_PERIODIC;
uint32 procEx = createProcExtendMask(&damageInfo, SPELL_MISS_NONE) | PROC_EX_INTERNAL_DOT;
uint32 hitMask = createProcHitMask(&damageInfo, SPELL_MISS_NONE);
uint32 spellTypeMask = PROC_SPELL_TYPE_NO_DMG_HEAL;
if (damageInfo.damage)
{
procVictim |= PROC_FLAG_TAKEN_DAMAGE;
caster->ProcDamageAndSpell(damageInfo.target, procAttacker, procVictim, procEx, damageInfo.damage, BASE_ATTACK, spellProto);
spellTypeMask |= PROC_SPELL_TYPE_DAMAGE;
}
caster->DealSpellDamage(&damageInfo, true);
DamageInfo dotDamageInfo(damageInfo, DOT, BASE_ATTACK, hitMask);
caster->ProcSkillsAndAuras(target, procAttacker, procVictim, spellTypeMask, PROC_SPELL_PHASE_NONE, hitMask, nullptr, &dotDamageInfo, nullptr);
}
void AuraEffect::HandleBreakableCCAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo)
{
int32 const damageLeft = GetAmount() - static_cast<int32>(eventInfo.GetDamageInfo()->GetDamage());
if (damageLeft <= 0)
aurApp->GetTarget()->RemoveAura(aurApp);
else
SetAmount(damageLeft);
}
void AuraEffect::HandleProcTriggerSpellAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo)
@@ -5986,7 +6112,7 @@ void AuraEffect::HandleProcTriggerSpellAuraProc(AuraApplication* aurApp, ProcEve
triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, NULL, this);
}
else
TC_LOG_DEBUG("spells","AuraEffect::HandleProcTriggerSpellAuraProc: Could not trigger spell %u from aura %u proc, because the spell does not have an entry in Spell.dbc.", triggerSpellId, GetId());
TC_LOG_ERROR("spells","AuraEffect::HandleProcTriggerSpellAuraProc: Could not trigger spell %u from aura %u proc, because the spell does not have an entry in Spell.dbc.", triggerSpellId, GetId());
}
void AuraEffect::HandleProcTriggerSpellWithValueAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo)
@@ -6002,7 +6128,7 @@ void AuraEffect::HandleProcTriggerSpellWithValueAuraProc(AuraApplication* aurApp
triggerCaster->CastCustomSpell(triggerTarget, triggerSpellId, &basepoints0, NULL, NULL, true, NULL, this);
}
else
TC_LOG_DEBUG("spells","AuraEffect::HandleProcTriggerSpellWithValueAuraProc: Could not trigger spell %u from aura %u proc, because the spell does not have an entry in Spell.dbc.", triggerSpellId, GetId());
TC_LOG_ERROR("spells","AuraEffect::HandleProcTriggerSpellWithValueAuraProc: Could not trigger spell %u from aura %u proc, because the spell does not have an entry in Spell.dbc.", triggerSpellId, GetId());
}
void AuraEffect::HandleProcTriggerDamageAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo)
@@ -6012,6 +6138,12 @@ void AuraEffect::HandleProcTriggerDamageAuraProc(AuraApplication* aurApp, ProcEv
Unit* target = aurApp->GetTarget();
Unit* triggerTarget = eventInfo.GetProcTarget();
if (triggerTarget->HasUnitState(UNIT_STATE_ISOLATED) || triggerTarget->IsImmunedToDamage(GetSpellInfo()))
{
SendTickImmune(triggerTarget, target);
return;
}
SpellNonMeleeDamage damageInfo(target, triggerTarget, GetId(), GetSpellInfo()->SchoolMask);
uint32 damage = target->SpellDamageBonusDone(triggerTarget, GetSpellInfo(), GetAmount(), SPELL_DIRECT_DAMAGE);
damage = triggerTarget->SpellDamageBonusTaken(target, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE);
@@ -6111,6 +6243,33 @@ void AuraEffect::HandleRaidProcFromChargeWithValueAuraProc(AuraApplication* aurA
target->CastCustomSpell(target, triggerSpellId, &value, NULL, NULL, true, NULL, this, GetCasterGUID());
}
void AuraEffect::HandleProcOnPowerAmountAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo)
{
Unit* triggerCaster = aurApp->GetTarget();
Unit* triggerTarget = eventInfo.GetProcTarget();
int32 powerAmountRequired = GetAmount();
Powers powerRequired = Powers(GetMiscValue());
if (!powerRequired || !powerAmountRequired)
{
TC_LOG_ERROR("spells", "AuraEffect::HandleProcOnPowerAmountAuraProc: Spell %u have 0 powerAmountRequired in EffectAmount[%d] or 0 powerRequired in EffectMiscValue, not handled custom case?", GetId(), GetEffIndex());
return;
}
if (triggerCaster->GetPower(powerRequired) != powerAmountRequired)
return;
uint32 triggerSpellId = GetSpellInfo()->Effects[GetEffIndex()].TriggerSpell;
if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId))
{
TC_LOG_DEBUG("spells", "AuraEffect::HandleProcOnPowerAmountAuraProc: Triggering spell %u from aura %u proc", triggeredSpellInfo->Id, GetId());
triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, NULL, this);
}
else
TC_LOG_ERROR("spells", "AuraEffect::HandleProcOnPowerAmountAuraProc: Could not trigger spell %u from aura %u proc, because the spell does not have an entry in Spell.dbc.", triggerSpellId, GetId());
}
void AuraEffect::HandleAuraForceWeather(AuraApplication const* aurApp, uint8 mode, bool apply) const
{
if (!(mode & AURA_EFFECT_HANDLE_REAL))
@@ -29,8 +29,8 @@ typedef void(AuraEffect::*pAuraEffectHandler)(AuraApplication const* aurApp, uin
class TC_GAME_API AuraEffect
{
friend void Aura::_InitEffects(uint8 effMask, Unit* caster, int32 *baseAmount);
friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID);
friend void Aura::_InitEffects(uint8 effMask, Unit* caster, int32* baseAmount);
friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID, bool resetPeriodicTimer);
friend Aura::~Aura();
private:
~AuraEffect();
@@ -46,8 +46,6 @@ class TC_GAME_API AuraEffect
template <typename Container>
void GetApplicationList(Container& applicationContainer) const;
SpellModifier* GetSpellModifier() const { return m_spellmod; }
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
uint32 GetId() const { return m_spellInfo->Id; }
uint32 GetEffIndex() const { return m_effIndex; }
@@ -95,8 +93,9 @@ class TC_GAME_API AuraEffect
bool HasSpellClassMask() const { return m_spellInfo->Effects[m_effIndex].SpellClassMask; }
void SendTickImmune(Unit* target, Unit* caster) const;
void PeriodicTick(AuraApplication * aurApp, Unit* caster) const;
void PeriodicTick(AuraApplication* aurApp, Unit* caster) const;
bool CheckEffectProc(AuraApplication* aurApp, ProcEventInfo& eventInfo) const;
void HandleProc(AuraApplication* aurApp, ProcEventInfo& eventInfo);
void CleanupTriggeredSpells(Unit* target);
@@ -314,11 +313,13 @@ class TC_GAME_API AuraEffect
void HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) const;
// aura effect proc handlers
void HandleBreakableCCAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo);
void HandleProcTriggerSpellAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo);
void HandleProcTriggerSpellWithValueAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo);
void HandleProcTriggerDamageAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo);
void HandleRaidProcFromChargeAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo);
void HandleRaidProcFromChargeWithValueAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo);
void HandleProcOnPowerAmountAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo);
};
namespace Trinity
+234 -184
View File
@@ -230,7 +230,7 @@ void AuraApplication::ClientUpdate(bool remove)
_target->SendMessageToSet(&data, true);
}
uint8 Aura::BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 avalibleEffectMask, WorldObject* owner)
uint8 Aura::BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 availableEffectMask, WorldObject* owner)
{
ASSERT(spellProto);
ASSERT(owner);
@@ -239,26 +239,28 @@ uint8 Aura::BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 avalibleE
{
case TYPEID_UNIT:
case TYPEID_PLAYER:
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellProto->Effects[i].IsUnitOwnedAuraEffect())
effMask |= 1 << i;
}
break;
case TYPEID_DYNAMICOBJECT:
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellProto->Effects[i].Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA)
effMask |= 1 << i;
}
break;
default:
ABORT();
break;
}
return effMask & avalibleEffectMask;
return effMask & availableEffectMask;
}
Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/, bool* refresh /*= NULL*/)
Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/, bool* refresh /*= nullptr*/, bool resetPeriodicTimer /*= true*/)
{
ASSERT(spellproto);
ASSERT(owner);
@@ -266,25 +268,28 @@ Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMas
ASSERT(tryEffMask <= MAX_EFFECT_MASK);
if (refresh)
*refresh = false;
uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
if (!effMask)
return NULL;
if (Aura* foundAura = owner->ToUnit()->_TryStackingOrRefreshingExistingAura(spellproto, effMask, caster, baseAmount, castItem, casterGUID))
return nullptr;
if (Aura* foundAura = owner->ToUnit()->_TryStackingOrRefreshingExistingAura(spellproto, effMask, caster, baseAmount, castItem, casterGUID, resetPeriodicTimer))
{
// we've here aura, which script triggered removal after modding stack amount
// check the state here, so we won't create new Aura object
if (foundAura->IsRemoved())
return NULL;
return nullptr;
if (refresh)
*refresh = true;
return foundAura;
}
else
return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
}
Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/)
Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/)
{
ASSERT(spellproto);
ASSERT(owner);
@@ -292,7 +297,8 @@ Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject
ASSERT(tryEffMask <= MAX_EFFECT_MASK);
uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
if (!effMask)
return NULL;
return nullptr;
return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
}
@@ -319,9 +325,9 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne
if (!owner->IsInWorld() || ((Unit*)owner)->IsDuringRemoveFromWorld())
// owner not in world so don't allow to own not self cast single target auras
if (casterGUID != owner->GetGUID() && spellproto->IsSingleTarget())
return NULL;
return nullptr;
Aura* aura = NULL;
Aura* aura = nullptr;
switch (owner->GetTypeId())
{
case TYPEID_UNIT:
@@ -333,11 +339,12 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne
break;
default:
ABORT();
return NULL;
return nullptr;
}
// aura can be removed in Unit::_AddAura call
if (aura->IsRemoved())
return NULL;
return nullptr;
return aura;
}
@@ -346,7 +353,8 @@ m_spellInfo(spellproto), m_casterGuid(casterGUID ? casterGUID : caster->GetGUID(
m_castItemGuid(castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_applyTime(time(NULL)),
m_owner(owner), m_timeCla(0), m_updateTargetMapInterval(0),
m_casterLevel(caster ? caster->getLevel() : m_spellInfo->SpellLevel), m_procCharges(0), m_stackAmount(1),
m_isRemoved(false), m_isSingleTarget(false), m_isUsingCharges(false), m_dropEvent(nullptr)
m_isRemoved(false), m_isSingleTarget(false), m_isUsingCharges(false), m_dropEvent(nullptr),
m_procCooldown(std::chrono::steady_clock::time_point::min())
{
if (m_spellInfo->ManaPerSecond)
m_timeCla = 1 * IN_MILLISECONDS;
@@ -361,7 +369,7 @@ m_isRemoved(false), m_isSingleTarget(false), m_isUsingCharges(false), m_dropEven
AuraScript* Aura::GetScriptByName(std::string const& scriptName) const
{
for (std::list<AuraScript*>::const_iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
if ((*itr)->_GetScriptName()->compare(scriptName) == 0)
return *itr;
return NULL;
@@ -382,12 +390,10 @@ void Aura::_InitEffects(uint8 effMask, Unit* caster, int32 *baseAmount)
Aura::~Aura()
{
// unload scripts
while (!m_loadedScripts.empty())
for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
{
std::list<AuraScript*>::iterator itr = m_loadedScripts.begin();
(*itr)->_Unload();
delete (*itr);
m_loadedScripts.erase(itr);
}
// free effects memory
@@ -544,11 +550,11 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply)
// check target immunities
for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
{
if (itr->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex))
if (itr->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex, caster))
itr->second &= ~(1 << effIndex);
}
if (!itr->second
|| itr->first->IsImmunedToSpell(GetSpellInfo())
|| itr->first->IsImmunedToSpell(GetSpellInfo(), caster)
|| !CanBeAppliedOn(itr->first))
addUnit = false;
@@ -737,7 +743,7 @@ int32 Aura::CalcMaxDuration(Unit* caster) const
// IsPermanent() checks max duration (which we are supposed to calculate here)
if (maxDuration != -1 && modOwner)
modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, maxDuration);
modOwner->ApplySpellMod<SPELLMOD_DURATION>(GetId(), maxDuration);
return maxDuration;
}
@@ -747,7 +753,7 @@ void Aura::SetDuration(int32 duration, bool withMods)
if (withMods)
if (Unit* caster = GetCaster())
if (Player* modOwner = caster->GetSpellModOwner())
modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, duration);
modOwner->ApplySpellMod<SPELLMOD_DURATION>(GetId(), duration);
m_duration = duration;
SetNeedClientUpdateForTargets();
@@ -773,10 +779,9 @@ void Aura::RefreshDuration(bool withMods)
m_timeCla = 1 * IN_MILLISECONDS;
}
void Aura::RefreshTimers()
void Aura::RefreshTimers(bool resetPeriodicTimer)
{
m_maxDuration = CalcMaxDuration();
bool resetPeriodic = true;
if (m_spellInfo->HasAttribute(SPELL_ATTR8_DONT_RESET_PERIODIC_TIMER))
{
int32 minAmplitude = m_maxDuration;
@@ -789,15 +794,16 @@ void Aura::RefreshTimers()
if (GetDuration() <= minAmplitude)
{
m_maxDuration += GetDuration();
resetPeriodic = false;
resetPeriodicTimer = false;
}
}
RefreshDuration();
Unit* caster = GetCaster();
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (HasEffect(i))
GetEffect(i)->CalculatePeriodic(caster, resetPeriodic, false);
if (AuraEffect* aurEff = m_effects[i])
aurEff->CalculatePeriodic(caster, resetPeriodicTimer, false);
}
void Aura::SetCharges(uint8 charges)
@@ -818,7 +824,7 @@ uint8 Aura::CalcMaxCharges(Unit* caster) const
if (caster)
if (Player* modOwner = caster->GetSpellModOwner())
modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, maxProcCharges);
modOwner->ApplySpellMod<SPELLMOD_CHARGES>(GetId(), maxProcCharges);
return uint8(maxProcCharges);
}
@@ -894,7 +900,7 @@ void Aura::SetStackAmount(uint8 stackAmount)
SetNeedClientUpdateForTargets();
}
bool Aura::ModStackAmount(int32 num, AuraRemoveMode removeMode)
bool Aura::ModStackAmount(int32 num, AuraRemoveMode removeMode /*= AURA_REMOVE_BY_DEFAULT*/, bool resetPeriodicTimer /*= true*/)
{
int32 stackAmount = m_stackAmount + num;
@@ -921,30 +927,16 @@ bool Aura::ModStackAmount(int32 num, AuraRemoveMode removeMode)
if (refresh)
{
RefreshSpellMods();
RefreshTimers();
RefreshTimers(resetPeriodicTimer);
// reset charges
SetCharges(CalcMaxCharges());
// FIXME: not a best way to synchronize charges, but works
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (AuraEffect* aurEff = GetEffect(i))
if (aurEff->GetAuraType() == SPELL_AURA_ADD_FLAT_MODIFIER || aurEff->GetAuraType() == SPELL_AURA_ADD_PCT_MODIFIER)
if (SpellModifier* mod = aurEff->GetSpellModifier())
mod->charges = GetCharges();
}
SetNeedClientUpdateForTargets();
return false;
}
void Aura::RefreshSpellMods()
{
for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
if (Player* player = appIter->second->GetTarget()->ToPlayer())
player->RestoreAllSpellMods(0, this);
}
bool Aura::HasMoreThanOneEffectForType(AuraType auraType) const
{
uint32 count = 0;
@@ -979,8 +971,9 @@ bool Aura::CanBeSaved() const
if (IsPassive())
return false;
// Check if aura is single target, not only spell info
if (GetCasterGUID() != GetOwner()->GetGUID())
if (GetSpellInfo()->IsSingleTarget())
if (GetSpellInfo()->IsSingleTarget() || IsSingleTarget())
return false;
// Can't be saved - aura handler relies on calculated amount and changes it
@@ -995,6 +988,18 @@ bool Aura::CanBeSaved() const
if (HasEffectType(SPELL_AURA_CONTROL_VEHICLE))
return false;
// do not save bind sight auras
if (HasEffectType(SPELL_AURA_BIND_SIGHT))
return false;
// no charming auras (taking direct control)
if (HasEffectType(SPELL_AURA_MOD_POSSESS) || HasEffectType(SPELL_AURA_MOD_POSSESS_PET))
return false;
// no charming auras can be saved
if (HasEffectType(SPELL_AURA_MOD_CHARM) || HasEffectType(SPELL_AURA_AOE_CHARM))
return false;
// Incanter's Absorbtion - considering the minimal duration and problems with aura stacking
// we skip saving this aura
// Also for some reason other auras put as MultiSlot crash core on keeping them after restart,
@@ -1070,7 +1075,7 @@ int32 Aura::CalcDispelChance(Unit const* auraTarget, bool offensive) const
// Apply dispel mod from aura caster
if (Unit* caster = GetCaster())
if (Player* modOwner = caster->GetSpellModOwner())
modOwner->ApplySpellMod(GetId(), SPELLMOD_RESIST_DISPEL_CHANCE, resistChance);
modOwner->ApplySpellMod<SPELLMOD_RESIST_DISPEL_CHANCE>(GetId(), resistChance);
// Dispel resistance from target SPELL_AURA_MOD_DISPEL_RESIST
// Only affects offensive dispels
@@ -1090,14 +1095,16 @@ void Aura::SetLoadedState(int32 maxduration, int32 duration, int32 charges, uint
m_stackAmount = stackamount;
Unit* caster = GetCaster();
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (m_effects[i])
{
if (AuraEffect* aurEff = m_effects[i])
{
m_effects[i]->SetAmount(amount[i]);
m_effects[i]->SetCanBeRecalculated((recalculateMask & (1 << i)) != 0);
m_effects[i]->CalculatePeriodic(caster, false, true);
m_effects[i]->CalculateSpellMod();
m_effects[i]->RecalculateAmount(caster);
aurEff->SetAmount(amount[i]);
aurEff->SetCanBeRecalculated((recalculateMask & (1 << i)) != 0);
aurEff->CalculatePeriodic(caster, false, true);
aurEff->CalculateSpellMod();
aurEff->RecalculateAmount(caster);
}
}
}
bool Aura::HasEffectType(AuraType type) const
@@ -1127,7 +1134,7 @@ void Aura::HandleAllEffects(AuraApplication * aurApp, uint8 mode, bool apply)
m_effects[i]->HandleEffect(aurApp, mode, apply);
}
void Aura::GetApplicationList(std::list<AuraApplication*> & applicationList) const
void Aura::GetApplicationList(Unit::AuraApplicationList& applicationList) const
{
for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
{
@@ -1279,47 +1286,31 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
caster->CastSpell(target, 61634, true);
}
}
switch (GetId())
{
case 12536: // Clearcasting
case 12043: // Presence of Mind
// Arcane Potency
if (AuraEffect const* aurEff = caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_MAGE, 2120, 0))
{
uint32 spellId = 0;
switch (aurEff->GetId())
{
case 31571: spellId = 57529; break;
case 31572: spellId = 57531; break;
default:
TC_LOG_ERROR("spells", "Aura::HandleAuraSpecificMods: Unknown rank of Arcane Potency (%d) found", aurEff->GetId());
}
if (spellId)
caster->CastSpell(caster, spellId, true);
}
break;
default:
break;
}
break;
case SPELLFAMILY_PRIEST:
if (!caster)
break;
// Devouring Plague
if (GetSpellInfo()->SpellFamilyFlags[0] & 0x02000000 && GetEffect(0))
if (GetSpellInfo()->SpellFamilyFlags[0] & 0x02000000)
{
AuraEffect const* devouringPlague = GetEffect(EFFECT_0);
if (!devouringPlague)
break;
// Improved Devouring Plague
if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 3790, 0))
{
uint32 damage = caster->SpellDamageBonusDone(target, GetSpellInfo(), GetEffect(0)->GetAmount(), DOT);
damage *= caster->SpellDamagePctDone(target, GetSpellInfo(), SPELL_DIRECT_DAMAGE);
damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT);
int32 basepoints0 = aurEff->GetAmount() * GetEffect(0)->GetTotalTicks() * int32(damage) / 100;
int32 heal = int32(CalculatePct(basepoints0, 15));
int32 damage = (devouringPlague->GetAmount() + devouringPlague->GetBonusAmount()) * devouringPlague->GetDonePct();
if (Player* modOwner = caster->GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, damage);
caster->CastCustomSpell(target, 63675, &basepoints0, NULL, NULL, true, NULL, GetEffect(0));
caster->CastCustomSpell(caster, 75999, &heal, NULL, NULL, true, NULL, GetEffect(0));
damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT);
int32 basepoints0 = CalculatePct(devouringPlague->GetTotalTicks() * static_cast<int32>(damage), aurEff->GetAmount());
int32 heal = CalculatePct(basepoints0, 15);
caster->CastCustomSpell(63675, SPELLVALUE_BASE_POINT0, basepoints0, target, true, nullptr, devouringPlague);
caster->CastCustomSpell(75999, SPELLVALUE_BASE_POINT0, heal, (Unit*)nullptr, true, nullptr, devouringPlague);
}
}
// Power Word: Shield
@@ -1583,7 +1574,7 @@ bool Aura::CanStackWith(Aura const* existingAura) const
bool sameCaster = GetCasterGUID() == existingAura->GetCasterGUID();
// passive auras don't stack with another rank of the spell cast by same caster
if (IsPassive() && sameCaster && m_spellInfo->IsRankOf(existingSpellInfo))
if (IsPassive() && sameCaster && (m_spellInfo->IsDifferentRankOf(existingSpellInfo) || (m_spellInfo->Id == existingSpellInfo->Id && m_castItemGuid.IsEmpty())))
return false;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
@@ -1695,22 +1686,17 @@ bool Aura::CanStackWith(Aura const* existingAura) const
return true;
}
bool Aura::IsProcOnCooldown() const
bool Aura::IsProcOnCooldown(std::chrono::steady_clock::time_point now) const
{
/*if (m_procCooldown)
{
if (m_procCooldown > time(NULL))
return true;
}*/
return false;
return m_procCooldown > now;
}
void Aura::AddProcCooldown(Milliseconds /*msec*/)
void Aura::AddProcCooldown(std::chrono::steady_clock::time_point cooldownEnd)
{
//m_procCooldown = std::chrono::steady_clock::now() + msec;
m_procCooldown = cooldownEnd;
}
void Aura::PrepareProcToTrigger(AuraApplication* aurApp, ProcEventInfo& eventInfo)
void Aura::PrepareProcToTrigger(AuraApplication* aurApp, ProcEventInfo& eventInfo, std::chrono::steady_clock::time_point now)
{
bool prepare = CallScriptPrepareProcHandlers(aurApp, eventInfo);
if (!prepare)
@@ -1724,49 +1710,90 @@ void Aura::PrepareProcToTrigger(AuraApplication* aurApp, ProcEventInfo& eventInf
}
SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId());
ASSERT(procEntry);
// cooldowns should be added to the whole aura (see 51698 area aura)
AddProcCooldown(procEntry->Cooldown);
AddProcCooldown(now + procEntry->Cooldown);
}
bool Aura::IsProcTriggeredOnEvent(AuraApplication* aurApp, ProcEventInfo& eventInfo) const
uint8 Aura::GetProcEffectMask(AuraApplication* aurApp, ProcEventInfo& eventInfo, std::chrono::steady_clock::time_point now) const
{
SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId());
// only auras with spell proc entry can trigger proc
if (!procEntry)
return false;
return 0;
// check spell triggering us
if (Spell const* spell = eventInfo.GetProcSpell())
{
// Do not allow auras to proc from effect triggered from itself
if (spell->IsTriggeredByAura(m_spellInfo))
return 0;
// check if aura can proc when spell is triggered (exception for hunter auto shot & wands)
if (spell->IsTriggered() && !(procEntry->AttributesMask & PROC_ATTR_TRIGGERED_CAN_PROC) && !(eventInfo.GetTypeMask() & AUTO_ATTACK_PROC_FLAG_MASK))
if (!GetSpellInfo()->HasAttribute(SPELL_ATTR3_CAN_PROC_WITH_TRIGGERED))
return 0;
}
// check don't break stealth attr present
if (m_spellInfo->HasAura(SPELL_AURA_MOD_STEALTH))
{
if (SpellInfo const* spellInfo = eventInfo.GetSpellInfo())
if (spellInfo->HasAttribute(SPELL_ATTR0_CU_DONT_BREAK_STEALTH))
return 0;
}
// check if we have charges to proc with
if (IsUsingCharges() && !GetCharges())
return false;
if (IsUsingCharges())
{
if (!GetCharges())
return 0;
if (procEntry->AttributesMask & PROC_ATTR_REQ_SPELLMOD)
if (Spell const* spell = eventInfo.GetProcSpell())
if (!spell->m_appliedMods.count(const_cast<Aura*>(this)))
return 0;
}
// check proc cooldown
if (IsProcOnCooldown())
return false;
/// @todo
// something about triggered spells triggering, and add extra attack effect
if (IsProcOnCooldown(now))
return 0;
// do checks against db data
if (!sSpellMgr->CanSpellTriggerProcOnEvent(*procEntry, eventInfo))
return false;
if (!SpellMgr::CanSpellTriggerProcOnEvent(*procEntry, eventInfo))
return 0;
// do checks using conditions table
if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL_PROC, GetId(), eventInfo.GetActor(), eventInfo.GetActionTarget()))
return false;
return 0;
// AuraScript Hook
bool check = const_cast<Aura*>(this)->CallScriptCheckProcHandlers(aurApp, eventInfo);
if (!check)
return false;
return 0;
// At least one effect has to pass checks to proc aura
uint8 procEffectMask = aurApp->GetEffectMask();
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (procEffectMask & (1 << i))
if ((procEntry->AttributesMask & (PROC_ATTR_DISABLE_EFF_0 << i)) || !GetEffect(i)->CheckEffectProc(aurApp, eventInfo))
procEffectMask &= ~(1 << i);
if (!procEffectMask)
return 0;
/// @todo
// do allow additional requirements for procs
// this is needed because this is the last moment in which you can prevent aura charge drop on proc
// and possibly a way to prevent default checks (if there're going to be any)
// Aura added by spell can't trigger from self (prevent drop charges/do triggers)
// But except periodic and kill triggers (can triggered from self)
if (SpellInfo const* spellInfo = eventInfo.GetSpellInfo())
if (spellInfo->Id == GetId() && !(eventInfo.GetTypeMask() & (PROC_FLAG_TAKEN_PERIODIC | PROC_FLAG_KILL)))
return 0;
// Check if current equipment meets aura requirements
// do that only for passive spells
/// @todo this needs to be unified for all kinds of auras
@@ -1776,12 +1803,12 @@ bool Aura::IsProcTriggeredOnEvent(AuraApplication* aurApp, ProcEventInfo& eventI
if (GetSpellInfo()->EquippedItemClass == ITEM_CLASS_WEAPON)
{
if (target->ToPlayer()->IsInFeralForm())
return false;
return 0;
if (eventInfo.GetDamageInfo())
if (DamageInfo* damageInfo = eventInfo.GetDamageInfo())
{
WeaponAttackType attType = eventInfo.GetDamageInfo()->GetAttackType();
Item* item = NULL;
WeaponAttackType attType = damageInfo->GetAttackType();
Item* item = nullptr;
if (attType == BASE_ATTACK)
item = target->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
else if (attType == OFF_ATTACK)
@@ -1789,20 +1816,23 @@ bool Aura::IsProcTriggeredOnEvent(AuraApplication* aurApp, ProcEventInfo& eventI
else
item = target->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED);
if (!item || item->IsBroken() || item->GetTemplate()->Class != ITEM_CLASS_WEAPON || !((1<<item->GetTemplate()->SubClass) & GetSpellInfo()->EquippedItemSubClassMask))
return false;
if (!item || item->IsBroken() || item->GetTemplate()->Class != ITEM_CLASS_WEAPON || !((1 << item->GetTemplate()->SubClass) & GetSpellInfo()->EquippedItemSubClassMask))
return 0;
}
}
else if (GetSpellInfo()->EquippedItemClass == ITEM_CLASS_ARMOR)
{
// Check if player is wearing shield
Item* item = target->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
if (!item || item->IsBroken() || item->GetTemplate()->Class != ITEM_CLASS_ARMOR || !((1<<item->GetTemplate()->SubClass) & GetSpellInfo()->EquippedItemSubClassMask))
return false;
if (!item || item->IsBroken() || item->GetTemplate()->Class != ITEM_CLASS_ARMOR || !((1 << item->GetTemplate()->SubClass) & GetSpellInfo()->EquippedItemSubClassMask))
return 0;
}
}
return roll_chance_f(CalcProcChance(*procEntry, eventInfo));
if (roll_chance_f(CalcProcChance(*procEntry, eventInfo)))
return procEffectMask;
return 0;
}
float Aura::CalcProcChance(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo) const
@@ -1820,21 +1850,33 @@ float Aura::CalcProcChance(SpellProcEntry const& procEntry, ProcEventInfo& event
}
// apply chance modifer aura, applies also to ppm chance (see improved judgement of light spell)
if (Player* modOwner = caster->GetSpellModOwner())
modOwner->ApplySpellMod(GetId(), SPELLMOD_CHANCE_OF_SUCCESS, chance);
modOwner->ApplySpellMod<SPELLMOD_CHANCE_OF_SUCCESS>(GetId(), chance);
}
// proc chance is reduced by an additional 3.333% per level past 60
if ((procEntry.AttributesMask & PROC_ATTR_REDUCE_PROC_60) && eventInfo.GetActor()->getLevel() > 60)
chance = std::max(0.f, (1.f - ((eventInfo.GetActor()->getLevel() - 60) * 1.f / 30.f)) * chance);
return chance;
}
void Aura::TriggerProcOnEvent(AuraApplication* aurApp, ProcEventInfo& eventInfo)
void Aura::TriggerProcOnEvent(uint8 procEffectMask, AuraApplication* aurApp, ProcEventInfo& eventInfo)
{
CallScriptProcHandlers(aurApp, eventInfo);
bool prevented = CallScriptProcHandlers(aurApp, eventInfo);
if (!prevented)
{
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (!(procEffectMask & (1 << i)))
continue;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (aurApp->HasEffect(i))
// OnEffectProc / AfterEffectProc hooks handled in AuraEffect::HandleProc()
GetEffect(i)->HandleProc(aurApp, eventInfo);
if (aurApp->HasEffect(i))
GetEffect(i)->HandleProc(aurApp, eventInfo);
}
CallScriptAfterProcHandlers(aurApp, eventInfo);
CallScriptAfterProcHandlers(aurApp, eventInfo);
}
// Remove aura if we've used last charge to proc
if (IsUsingCharges() && !GetCharges())
@@ -1852,30 +1894,21 @@ void Aura::_DeleteRemovedApplications()
void Aura::LoadScripts()
{
sScriptMgr->CreateAuraScripts(m_spellInfo->Id, m_loadedScripts);
for (std::list<AuraScript*>::iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end();)
sScriptMgr->CreateAuraScripts(m_spellInfo->Id, m_loadedScripts, this);
for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
{
if (!(*itr)->_Load(this))
{
std::list<AuraScript*>::iterator bitr = itr;
++itr;
delete (*bitr);
m_loadedScripts.erase(bitr);
continue;
}
TC_LOG_DEBUG("spells", "Aura::LoadScripts: Script `%s` for aura `%u` is loaded now", (*itr)->_GetScriptName()->c_str(), m_spellInfo->Id);
(*itr)->Register();
++itr;
}
}
bool Aura::CallScriptCheckAreaTargetHandlers(Unit* target)
{
bool result = true;
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_AREA_TARGET);
std::list<AuraScript::CheckAreaTargetHandler>::iterator hookItrEnd = (*scritr)->DoCheckAreaTarget.end(), hookItr = (*scritr)->DoCheckAreaTarget.begin();
auto hookItrEnd = (*scritr)->DoCheckAreaTarget.end(), hookItr = (*scritr)->DoCheckAreaTarget.begin();
for (; hookItr != hookItrEnd; ++hookItr)
result &= hookItr->Call(*scritr, target);
@@ -1886,10 +1919,10 @@ bool Aura::CallScriptCheckAreaTargetHandlers(Unit* target)
void Aura::CallScriptDispel(DispelInfo* dispelInfo)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_DISPEL);
std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->OnDispel.end(), hookItr = (*scritr)->OnDispel.begin();
auto hookItrEnd = (*scritr)->OnDispel.end(), hookItr = (*scritr)->OnDispel.begin();
for (; hookItr != hookItrEnd; ++hookItr)
hookItr->Call(*scritr, dispelInfo);
@@ -1899,10 +1932,10 @@ void Aura::CallScriptDispel(DispelInfo* dispelInfo)
void Aura::CallScriptAfterDispel(DispelInfo* dispelInfo)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_DISPEL);
std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->AfterDispel.end(), hookItr = (*scritr)->AfterDispel.begin();
auto hookItrEnd = (*scritr)->AfterDispel.end(), hookItr = (*scritr)->AfterDispel.begin();
for (; hookItr != hookItrEnd; ++hookItr)
hookItr->Call(*scritr, dispelInfo);
@@ -1913,10 +1946,10 @@ void Aura::CallScriptAfterDispel(DispelInfo* dispelInfo)
bool Aura::CallScriptEffectApplyHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, AuraEffectHandleModes mode)
{
bool preventDefault = false;
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_APPLY, aurApp);
std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectApply.end(), effItr = (*scritr)->OnEffectApply.begin();
auto effEndItr = (*scritr)->OnEffectApply.end(), effItr = (*scritr)->OnEffectApply.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, mode);
@@ -1933,10 +1966,10 @@ bool Aura::CallScriptEffectApplyHandlers(AuraEffect const* aurEff, AuraApplicati
bool Aura::CallScriptEffectRemoveHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, AuraEffectHandleModes mode)
{
bool preventDefault = false;
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_REMOVE, aurApp);
std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectRemove.end(), effItr = (*scritr)->OnEffectRemove.begin();
auto effEndItr = (*scritr)->OnEffectRemove.end(), effItr = (*scritr)->OnEffectRemove.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, mode);
@@ -1951,10 +1984,10 @@ bool Aura::CallScriptEffectRemoveHandlers(AuraEffect const* aurEff, AuraApplicat
void Aura::CallScriptAfterEffectApplyHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, AuraEffectHandleModes mode)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY, aurApp);
std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectApply.end(), effItr = (*scritr)->AfterEffectApply.begin();
auto effEndItr = (*scritr)->AfterEffectApply.end(), effItr = (*scritr)->AfterEffectApply.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, mode);
@@ -1965,10 +1998,10 @@ void Aura::CallScriptAfterEffectApplyHandlers(AuraEffect const* aurEff, AuraAppl
void Aura::CallScriptAfterEffectRemoveHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, AuraEffectHandleModes mode)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE, aurApp);
std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectRemove.end(), effItr = (*scritr)->AfterEffectRemove.begin();
auto effEndItr = (*scritr)->AfterEffectRemove.end(), effItr = (*scritr)->AfterEffectRemove.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, mode);
@@ -1980,10 +2013,10 @@ void Aura::CallScriptAfterEffectRemoveHandlers(AuraEffect const* aurEff, AuraApp
bool Aura::CallScriptEffectPeriodicHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp)
{
bool preventDefault = false;
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PERIODIC, aurApp);
std::list<AuraScript::EffectPeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectPeriodic.end(), effItr = (*scritr)->OnEffectPeriodic.begin();
auto effEndItr = (*scritr)->OnEffectPeriodic.end(), effItr = (*scritr)->OnEffectPeriodic.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff);
@@ -1999,10 +2032,10 @@ bool Aura::CallScriptEffectPeriodicHandlers(AuraEffect const* aurEff, AuraApplic
void Aura::CallScriptEffectUpdatePeriodicHandlers(AuraEffect* aurEff)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC);
std::list<AuraScript::EffectUpdatePeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectUpdatePeriodic.end(), effItr = (*scritr)->OnEffectUpdatePeriodic.begin();
auto effEndItr = (*scritr)->OnEffectUpdatePeriodic.end(), effItr = (*scritr)->OnEffectUpdatePeriodic.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff);
@@ -2013,10 +2046,10 @@ void Aura::CallScriptEffectUpdatePeriodicHandlers(AuraEffect* aurEff)
void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, int32 & amount, bool & canBeRecalculated)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_AMOUNT);
std::list<AuraScript::EffectCalcAmountHandler>::iterator effEndItr = (*scritr)->DoEffectCalcAmount.end(), effItr = (*scritr)->DoEffectCalcAmount.begin();
auto effEndItr = (*scritr)->DoEffectCalcAmount.end(), effItr = (*scritr)->DoEffectCalcAmount.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, amount, canBeRecalculated);
@@ -2027,10 +2060,10 @@ void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, int32 &
void Aura::CallScriptEffectCalcPeriodicHandlers(AuraEffect const* aurEff, bool & isPeriodic, int32 & amplitude)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_PERIODIC);
std::list<AuraScript::EffectCalcPeriodicHandler>::iterator effEndItr = (*scritr)->DoEffectCalcPeriodic.end(), effItr = (*scritr)->DoEffectCalcPeriodic.begin();
auto effEndItr = (*scritr)->DoEffectCalcPeriodic.end(), effItr = (*scritr)->DoEffectCalcPeriodic.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, isPeriodic, amplitude);
@@ -2041,10 +2074,10 @@ void Aura::CallScriptEffectCalcPeriodicHandlers(AuraEffect const* aurEff, bool &
void Aura::CallScriptEffectCalcSpellModHandlers(AuraEffect const* aurEff, SpellModifier* & spellMod)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD);
std::list<AuraScript::EffectCalcSpellModHandler>::iterator effEndItr = (*scritr)->DoEffectCalcSpellMod.end(), effItr = (*scritr)->DoEffectCalcSpellMod.begin();
auto effEndItr = (*scritr)->DoEffectCalcSpellMod.end(), effItr = (*scritr)->DoEffectCalcSpellMod.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, spellMod);
@@ -2055,10 +2088,10 @@ void Aura::CallScriptEffectCalcSpellModHandlers(AuraEffect const* aurEff, SpellM
void Aura::CallScriptEffectAbsorbHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount, bool& defaultPrevented)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_ABSORB, aurApp);
std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->OnEffectAbsorb.end(), effItr = (*scritr)->OnEffectAbsorb.begin();
auto effEndItr = (*scritr)->OnEffectAbsorb.end(), effItr = (*scritr)->OnEffectAbsorb.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
@@ -2073,10 +2106,10 @@ void Aura::CallScriptEffectAbsorbHandlers(AuraEffect* aurEff, AuraApplication co
void Aura::CallScriptEffectAfterAbsorbHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB, aurApp);
std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->AfterEffectAbsorb.end(), effItr = (*scritr)->AfterEffectAbsorb.begin();
auto effEndItr = (*scritr)->AfterEffectAbsorb.end(), effItr = (*scritr)->AfterEffectAbsorb.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
@@ -2087,10 +2120,10 @@ void Aura::CallScriptEffectAfterAbsorbHandlers(AuraEffect* aurEff, AuraApplicati
void Aura::CallScriptEffectManaShieldHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount, bool & /*defaultPrevented*/)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_MANASHIELD, aurApp);
std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->OnEffectManaShield.end(), effItr = (*scritr)->OnEffectManaShield.begin();
auto effEndItr = (*scritr)->OnEffectManaShield.end(), effItr = (*scritr)->OnEffectManaShield.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
@@ -2101,10 +2134,10 @@ void Aura::CallScriptEffectManaShieldHandlers(AuraEffect* aurEff, AuraApplicatio
void Aura::CallScriptEffectAfterManaShieldHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD, aurApp);
std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->AfterEffectManaShield.end(), effItr = (*scritr)->AfterEffectManaShield.begin();
auto effEndItr = (*scritr)->AfterEffectManaShield.end(), effItr = (*scritr)->AfterEffectManaShield.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
@@ -2115,10 +2148,10 @@ void Aura::CallScriptEffectAfterManaShieldHandlers(AuraEffect* aurEff, AuraAppli
void Aura::CallScriptEffectSplitHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & splitAmount)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_SPLIT, aurApp);
std::list<AuraScript::EffectSplitHandler>::iterator effEndItr = (*scritr)->OnEffectSplit.end(), effItr = (*scritr)->OnEffectSplit.begin();
auto effEndItr = (*scritr)->OnEffectSplit.end(), effItr = (*scritr)->OnEffectSplit.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, dmgInfo, splitAmount);
@@ -2130,10 +2163,10 @@ void Aura::CallScriptEffectSplitHandlers(AuraEffect* aurEff, AuraApplication con
bool Aura::CallScriptCheckProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
bool result = true;
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_PROC, aurApp);
std::list<AuraScript::CheckProcHandler>::iterator hookItrEnd = (*scritr)->DoCheckProc.end(), hookItr = (*scritr)->DoCheckProc.begin();
auto hookItrEnd = (*scritr)->DoCheckProc.end(), hookItr = (*scritr)->DoCheckProc.begin();
for (; hookItr != hookItrEnd; ++hookItr)
result &= hookItr->Call(*scritr, eventInfo);
@@ -2146,10 +2179,10 @@ bool Aura::CallScriptCheckProcHandlers(AuraApplication const* aurApp, ProcEventI
bool Aura::CallScriptPrepareProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
bool prepare = true;
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PREPARE_PROC, aurApp);
std::list<AuraScript::AuraProcHandler>::iterator effEndItr = (*scritr)->DoPrepareProc.end(), effItr = (*scritr)->DoPrepareProc.begin();
auto effEndItr = (*scritr)->DoPrepareProc.end(), effItr = (*scritr)->DoPrepareProc.begin();
for (; effItr != effEndItr; ++effItr)
effItr->Call(*scritr, eventInfo);
@@ -2165,10 +2198,10 @@ bool Aura::CallScriptPrepareProcHandlers(AuraApplication const* aurApp, ProcEven
bool Aura::CallScriptProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
bool handled = false;
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PROC, aurApp);
std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->OnProc.end(), hookItr = (*scritr)->OnProc.begin();
auto hookItrEnd = (*scritr)->OnProc.end(), hookItr = (*scritr)->OnProc.begin();
for (; hookItr != hookItrEnd; ++hookItr)
hookItr->Call(*scritr, eventInfo);
@@ -2181,10 +2214,10 @@ bool Aura::CallScriptProcHandlers(AuraApplication const* aurApp, ProcEventInfo&
void Aura::CallScriptAfterProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_PROC, aurApp);
std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->AfterProc.end(), hookItr = (*scritr)->AfterProc.begin();
auto hookItrEnd = (*scritr)->AfterProc.end(), hookItr = (*scritr)->AfterProc.begin();
for (; hookItr != hookItrEnd; ++hookItr)
hookItr->Call(*scritr, eventInfo);
@@ -2192,13 +2225,30 @@ void Aura::CallScriptAfterProcHandlers(AuraApplication const* aurApp, ProcEventI
}
}
bool Aura::CallScriptCheckEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
bool result = true;
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC, aurApp);
auto hookItrEnd = (*scritr)->DoCheckEffectProc.end(), hookItr = (*scritr)->DoCheckEffectProc.begin();
for (; hookItr != hookItrEnd; ++hookItr)
if (hookItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
result &= hookItr->Call(*scritr, aurEff, eventInfo);
(*scritr)->_FinishScriptCall();
}
return result;
}
bool Aura::CallScriptEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
bool preventDefault = false;
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PROC, aurApp);
std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->OnEffectProc.end(), effItr = (*scritr)->OnEffectProc.begin();
auto effEndItr = (*scritr)->OnEffectProc.end(), effItr = (*scritr)->OnEffectProc.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, eventInfo);
@@ -2213,10 +2263,10 @@ bool Aura::CallScriptEffectProcHandlers(AuraEffect const* aurEff, AuraApplicatio
void Aura::CallScriptAfterEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC, aurApp);
std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->AfterEffectProc.end(), effItr = (*scritr)->AfterEffectProc.begin();
auto effEndItr = (*scritr)->AfterEffectProc.end(), effItr = (*scritr)->AfterEffectProc.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, eventInfo);
+17 -18
View File
@@ -84,13 +84,13 @@ class TC_GAME_API AuraApplication
class TC_GAME_API Aura
{
friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32 *baseAmount, Item* castItem, ObjectGuid casterGUID);
friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32 *baseAmount, Item* castItem, ObjectGuid casterGUID, bool resetPeriodicTimer);
public:
typedef std::map<ObjectGuid, AuraApplication*> ApplicationMap;
static uint8 BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 avalibleEffectMask, WorldObject* owner);
static Aura* TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount = NULL, Item* castItem = NULL, ObjectGuid casterGUID = ObjectGuid::Empty, bool* refresh = NULL);
static Aura* TryCreate(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount = NULL, Item* castItem = NULL, ObjectGuid casterGUID = ObjectGuid::Empty);
static uint8 BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 availableEffectMask, WorldObject* owner);
static Aura* TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, ObjectGuid casterGUID = ObjectGuid::Empty, bool* refresh = nullptr, bool resetPeriodicTimer = true);
static Aura* TryCreate(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, ObjectGuid casterGUID = ObjectGuid::Empty);
static Aura* Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID);
explicit Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, ObjectGuid casterGUID);
void _InitEffects(uint8 effMask, Unit* caster, int32 *baseAmount);
@@ -131,7 +131,7 @@ class TC_GAME_API Aura
int32 GetDuration() const { return m_duration; }
void SetDuration(int32 duration, bool withMods = false);
void RefreshDuration(bool withMods = false);
void RefreshTimers();
void RefreshTimers(bool resetPeriodicTimer);
bool IsExpired() const { return !GetDuration() && !m_dropEvent; }
bool IsPermanent() const { return GetMaxDuration() == -1; }
@@ -146,9 +146,7 @@ class TC_GAME_API Aura
uint8 GetStackAmount() const { return m_stackAmount; }
void SetStackAmount(uint8 num);
bool ModStackAmount(int32 num, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RefreshSpellMods();
bool ModStackAmount(int32 num, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT, bool resetPeriodicTimer = true);
uint8 GetCasterLevel() const { return m_casterLevel; }
@@ -199,18 +197,14 @@ class TC_GAME_API Aura
bool CheckAreaTarget(Unit* target);
bool CanStackWith(Aura const* existingAura) const;
// Proc system
// this subsystem is not yet in use - the core of it is functional, but still some research has to be done
// and some dependant problems fixed before it can replace old proc system (for example cooldown handling)
// currently proc system functionality is implemented in Unit::ProcDamageAndSpell
bool IsProcOnCooldown() const;
void AddProcCooldown(Milliseconds msec);
bool IsProcOnCooldown(std::chrono::steady_clock::time_point now) const;
void AddProcCooldown(std::chrono::steady_clock::time_point cooldownEnd);
bool IsUsingCharges() const { return m_isUsingCharges; }
void SetUsingCharges(bool val) { m_isUsingCharges = val; }
void PrepareProcToTrigger(AuraApplication* aurApp, ProcEventInfo& eventInfo);
bool IsProcTriggeredOnEvent(AuraApplication* aurApp, ProcEventInfo& eventInfo) const;
void PrepareProcToTrigger(AuraApplication* aurApp, ProcEventInfo& eventInfo, std::chrono::steady_clock::time_point now);
uint8 GetProcEffectMask(AuraApplication* aurApp, ProcEventInfo& eventInfo, std::chrono::steady_clock::time_point now) const;
float CalcProcChance(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo) const;
void TriggerProcOnEvent(AuraApplication* aurApp, ProcEventInfo& eventInfo);
void TriggerProcOnEvent(uint8 procEffectMask, AuraApplication* aurApp, ProcEventInfo& eventInfo);
// AuraScript
void LoadScripts();
@@ -233,6 +227,7 @@ class TC_GAME_API Aura
void CallScriptEffectSplitHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & splitAmount);
// Spell Proc Hooks
bool CallScriptCheckProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo);
bool CallScriptCheckEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo);
bool CallScriptPrepareProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo);
bool CallScriptProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo);
void CallScriptAfterProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo);
@@ -241,9 +236,11 @@ class TC_GAME_API Aura
AuraScript* GetScriptByName(std::string const& scriptName) const;
std::list<AuraScript*> m_loadedScripts;
std::vector<AuraScript*> m_loadedScripts;
private:
void _DeleteRemovedApplications();
protected:
SpellInfo const* const m_spellInfo;
ObjectGuid const m_casterGuid;
@@ -269,6 +266,8 @@ class TC_GAME_API Aura
ChargeDropEvent* m_dropEvent;
std::chrono::steady_clock::time_point m_procCooldown;
private:
Unit::AuraApplicationList m_removedApplications;
};
File diff suppressed because it is too large. Load diff
+19 -16
View File
@@ -362,7 +362,7 @@ class TC_GAME_API Spell
void EffectUpdatePlayerPhase(SpellEffIndex effIndex);
void EffectUpdateZoneAurasAndPhases(SpellEffIndex effIndex);
typedef std::set<Aura*> UsedSpellMods;
typedef std::unordered_set<Aura*> UsedSpellMods;
Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID = ObjectGuid::Empty, bool skipCheck = false);
~Spell();
@@ -424,13 +424,13 @@ class TC_GAME_API Spell
SpellCastResult CheckCasterAuras(uint32* param1) const;
SpellCastResult CheckArenaAndRatedBattlegroundCastRules() const;
bool CheckCasterHasNotImmunedAuraType(AuraType auraType, uint32* param1) const;
bool CheckCasterNotImmunedCharmAuras(uint32* param1) const;
bool CheckCasterNotImmunedStunAuras(uint32* param1) const;
bool CheckCasterNotImmunedSilenceAuras(uint32* param1) const;
bool CheckCasterNotImmunedPacifyAuras(uint32* param1) const;
bool CheckCasterNotImmunedFearAuras(uint32* param1) const;
bool CheckCasterNotImmunedDisorientAuras(uint32* param1) const;
bool CheckSpellCancelsAuraEffect(AuraType auraType, uint32* param1) const;
bool CheckSpellCancelsCharm(uint32* param1) const;
bool CheckSpellCancelsStun(uint32* param1) const;
bool CheckSpellCancelsSilence(uint32* param1) const;
bool CheckSpellCancelsPacify(uint32* param1) const;
bool CheckSpellCancelsFear(uint32* param1) const;
bool CheckSpellCancelsConfuse(uint32* param1) const;
int32 CalculateDamage(uint8 i, Unit const* target) const { return m_caster->CalculateSpellDamage(target, m_spellInfo, i, &m_spellValue->EffectBasePoints[i]); }
@@ -494,9 +494,12 @@ class TC_GAME_API Spell
void ReSetTimer() { m_timer = m_casttime > 0 ? m_casttime : 0; }
bool IsTriggered() const { return (_triggeredCastFlags & TRIGGERED_FULL_MASK) != 0; }
bool IsIgnoringCooldowns() const { return (_triggeredCastFlags & TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD) != 0; }
bool IsProcDisabled() const { return (_triggeredCastFlags & TRIGGERED_DISALLOW_PROC_EVENTS) != 0; }
bool IsChannelActive() const { return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0; }
bool IsAutoActionResetSpell() const;
bool IsTriggeredByAura(SpellInfo const* auraSpellInfo) const { return (auraSpellInfo == m_triggeredByAuraSpell); }
bool IsDeletable() const { return !m_referencedFromCurrentSpell && !m_executedCurrently; }
void SetReferencedFromCurrent(bool yes) { m_referencedFromCurrentSpell = yes; }
bool IsInterruptable() const { return !m_executedCurrently; }
@@ -523,6 +526,7 @@ class TC_GAME_API Spell
bool HasGlobalCooldown() const;
void TriggerGlobalCooldown();
void CancelGlobalCooldown();
void _cast(bool skipCheck = false);
void SendLoot(ObjectGuid guid, LootType loottype);
std::pair<float, float> GetMinMaxRange(bool strict) const;
@@ -580,10 +584,6 @@ class TC_GAME_API Spell
// used in effects handlers
Aura* m_spellAura;
// this is set in Spell Hit, but used in Apply Aura handler
DiminishingLevels m_diminishLevel;
DiminishingGroup m_diminishGroup;
// -------------------------------------------
GameObject* focusObject;
@@ -596,8 +596,8 @@ class TC_GAME_API Spell
// ******************************************
uint32 m_procAttacker; // Attacker trigger flags
uint32 m_procVictim; // Victim trigger flags
uint32 m_procEx;
void prepareDataForTriggerSystem(AuraEffect const* triggeredByAura);
uint32 m_hitMask;
void prepareDataForTriggerSystem();
// *****************************************
// Spell target subsystem
@@ -677,10 +677,13 @@ class TC_GAME_API Spell
void CallScriptObjectTargetSelectHandlers(WorldObject*& target, SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);
void CallScriptDestinationTargetSelectHandlers(SpellDestination& target, SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);
bool CheckScriptEffectImplicitTargets(uint32 effIndex, uint32 effIndexToCheck);
std::list<SpellScript*> m_loadedScripts;
std::vector<SpellScript*> m_loadedScripts;
struct HitTriggerSpell
{
HitTriggerSpell(SpellInfo const* spellInfo, SpellInfo const* auraSpellInfo, int32 procChance) :
triggeredSpell(spellInfo), triggeredByAura(auraSpellInfo), chance(procChance) { }
SpellInfo const* triggeredSpell;
SpellInfo const* triggeredByAura;
// uint8 triggeredByEffIdx This might be needed at a later stage - No need known for now
@@ -689,7 +692,7 @@ class TC_GAME_API Spell
bool CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* triggeredByAura = NULL) const;
void PrepareTriggersExecutedOnHit();
typedef std::list<HitTriggerSpell> HitTriggerSpellList;
typedef std::vector<HitTriggerSpell> HitTriggerSpellList;
HitTriggerSpellList m_hitTriggerSpells;
// effect helpers
+37 -75
View File
@@ -315,14 +315,18 @@ void Spell::EffectEnvironmentalDMG(SpellEffIndex /*effIndex*/)
if (!unitTarget || !unitTarget->IsAlive())
return;
uint32 absorb = 0;
uint32 resist = 0;
m_caster->CalcAbsorbResist(unitTarget, m_spellInfo->GetSchoolMask(), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist, m_spellInfo);
m_caster->SendSpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, damage, m_spellInfo->GetSchoolMask(), absorb, resist, false, 0, false);
// CalcAbsorbResist already in Player::EnvironmentalDamage
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
unitTarget->ToPlayer()->EnvironmentalDamage(DAMAGE_FIRE, damage);
else
{
DamageInfo damageInfo(m_caster, unitTarget, damage, m_spellInfo, m_spellInfo->GetSchoolMask(), SPELL_DIRECT_DAMAGE, BASE_ATTACK);
m_caster->CalcAbsorbResist(damageInfo);
uint32 absorb = damageInfo.GetAbsorb();
uint32 resist = damageInfo.GetResist();
m_caster->SendSpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, damage, m_spellInfo->GetSchoolMask(), absorb, resist, false, 0, false);
}
}
void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
@@ -1238,9 +1242,12 @@ void Spell::EffectHeal(SpellEffIndex /*effIndex*/)
return;
}
int32 tickheal = targetAura->GetAmount();
if (Unit* auraCaster = targetAura->GetCaster())
tickheal = auraCaster->SpellHealingBonusDone(unitTarget, targetAura->GetSpellInfo(), tickheal, DOT);
int32 tickheal = (targetAura->GetAmount() + targetAura->GetBonusAmount()) * targetAura->GetDonePct();
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_DOT>(targetAura->GetId(), tickheal);
unitTarget->SpellHealingBonusTaken(m_caster, targetAura->GetSpellInfo(), tickheal, DOT);
//int32 tickheal = targetAura->GetSpellInfo()->EffectBasePoints[idx] + 1;
//It is said that talent bonus should not be included
@@ -1336,7 +1343,8 @@ void Spell::EffectHealthLeech(SpellEffIndex effIndex)
healthGain = m_caster->SpellHealingBonusDone(m_caster, m_spellInfo, healthGain, HEAL);
healthGain = m_caster->SpellHealingBonusTaken(m_caster, m_spellInfo, healthGain, HEAL);
m_caster->HealBySpell(m_caster, m_spellInfo, uint32(healthGain));
HealInfo healInfo(m_caster, m_caster, healthGain, m_spellInfo, m_spellSchoolMask);
m_caster->HealBySpell(healInfo);
}
}
@@ -1627,52 +1635,6 @@ void Spell::EffectEnergize(SpellEffIndex effIndex)
return;
m_caster->EnergizeBySpell(unitTarget, m_spellInfo->Id, damage, power);
// Mad Alchemist's Potion
if (m_spellInfo->Id == 45051)
{
// find elixirs on target
bool guardianFound = false;
bool battleFound = false;
Unit::AuraApplicationMap& Auras = unitTarget->GetAppliedAuras();
for (Unit::AuraApplicationMap::iterator itr = Auras.begin(); itr != Auras.end(); ++itr)
{
uint32 spell_id = itr->second->GetBase()->GetId();
if (!guardianFound)
if (sSpellMgr->IsSpellMemberOfSpellGroup(spell_id, SPELL_GROUP_ELIXIR_GUARDIAN))
guardianFound = true;
if (!battleFound)
if (sSpellMgr->IsSpellMemberOfSpellGroup(spell_id, SPELL_GROUP_ELIXIR_BATTLE))
battleFound = true;
if (battleFound && guardianFound)
break;
}
// get all available elixirs by mask and spell level
std::set<uint32> avalibleElixirs;
if (!guardianFound)
sSpellMgr->GetSetOfSpellsInSpellGroup(SPELL_GROUP_ELIXIR_GUARDIAN, avalibleElixirs);
if (!battleFound)
sSpellMgr->GetSetOfSpellsInSpellGroup(SPELL_GROUP_ELIXIR_BATTLE, avalibleElixirs);
for (std::set<uint32>::iterator itr = avalibleElixirs.begin(); itr != avalibleElixirs.end();)
{
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(*itr);
if (spellInfo->SpellLevel < m_spellInfo->SpellLevel || spellInfo->SpellLevel > unitTarget->getLevel())
avalibleElixirs.erase(itr++);
else if (sSpellMgr->IsSpellMemberOfSpellGroup(*itr, SPELL_GROUP_ELIXIR_SHATTRATH))
avalibleElixirs.erase(itr++);
else if (sSpellMgr->IsSpellMemberOfSpellGroup(*itr, SPELL_GROUP_ELIXIR_UNSTABLE))
avalibleElixirs.erase(itr++);
else
++itr;
}
if (!avalibleElixirs.empty())
{
// cast random elixir on target
m_caster->CastSpell(unitTarget, Trinity::Containers::SelectRandomContainerElement(avalibleElixirs), true, m_CastItem);
}
}
}
void Spell::EffectEnergizePct(SpellEffIndex effIndex)
@@ -2029,7 +1991,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
int32 duration = m_spellInfo->GetDuration();
if (Player* modOwner = m_originalCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
modOwner->ApplySpellMod<SPELLMOD_DURATION>(m_spellInfo->Id, duration);
TempSummon* summon = NULL;
@@ -3062,7 +3024,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
// if (addPctMods) { percent mods are added in Unit::CalculateDamage } else { percent mods are added in Unit::MeleeDamageBonusDone }
// this distinction is neccessary to properly inform the client about his autoattack damage values from Script_UnitDamage
bool addPctMods = !m_spellInfo->HasAttribute(SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS) && (m_spellSchoolMask & SPELL_SCHOOL_MASK_NORMAL);
bool const addPctMods = !m_spellInfo->HasAttribute(SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS) && (m_spellSchoolMask & SPELL_SCHOOL_MASK_NORMAL);
if (addPctMods)
{
UnitMods unitMod;
@@ -5225,18 +5187,8 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex)
m_runesState = m_caster->ToPlayer()->GetRunesState();
uint32 count = damage;
if (count == 0) count = 1;
for (uint32 j = 0; j < MAX_RUNES && count > 0; ++j)
{
if (player->GetRuneCooldown(j) && player->GetCurrentRune(j) == RuneType(m_spellInfo->Effects[effIndex].MiscValue))
{
if (m_spellInfo->Id == 45529)
if (player->GetBaseRune(j) != RuneType(m_spellInfo->Effects[effIndex].MiscValueB))
continue;
player->SetRuneCooldown(j, 0);
--count;
}
}
if (count == 0)
count = 1;
// Blood Tap
if (m_spellInfo->Id == 45529 && count > 0)
@@ -5244,11 +5196,12 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex)
for (uint32 l = 0; l + 1 < MAX_RUNES && count > 0; ++l)
{
// Check if both runes are on cd as that is the only time when this needs to come into effect
if ((player->GetRuneCooldown(l) && player->GetBaseRune(l) == RuneType(m_spellInfo->Effects[effIndex].MiscValueB)) && (player->GetRuneCooldown(l+1) && player->GetBaseRune(l+1) == RuneType(m_spellInfo->Effects[effIndex].MiscValueB)))
if ((player->GetRuneCooldown(l) && player->GetBaseRune(l) == RUNE_BLOOD) && (player->GetRuneCooldown(l + 1) && player->GetBaseRune(l + 1) == RUNE_BLOOD))
{
// Should always update the rune with the lowest cd
if (l + 1 < MAX_RUNES && player->GetRuneCooldown(l) >= player->GetRuneCooldown(l+1))
l++;
if (l + 1 < MAX_RUNES && player->GetRuneCooldown(l) >= player->GetRuneCooldown(l + 1))
++l;
player->SetRuneCooldown(l, 0);
--count;
// is needed to push through to the client that the rune is active
@@ -5259,6 +5212,15 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex)
}
}
for (uint32 j = 0; j < MAX_RUNES && count > 0; ++j)
{
if (player->GetRuneCooldown(j) && player->GetCurrentRune(j) == RuneType(m_spellInfo->Effects[effIndex].MiscValue))
{
player->SetRuneCooldown(j, 0);
--count;
}
}
// Empower rune weapon
if (m_spellInfo->Id == 47568)
{
@@ -5268,7 +5230,7 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex)
for (uint32 i = 0; i < MAX_RUNES; ++i)
{
if (player->GetRuneCooldown(i) && (player->GetCurrentRune(i) == RUNE_FROST || player->GetCurrentRune(i) == RUNE_DEATH))
if (player->GetRuneCooldown(i) && (player->GetBaseRune(i) == RUNE_FROST))
player->SetRuneCooldown(i, 0);
}
}
@@ -5402,7 +5364,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const*
int32 duration = m_spellInfo->GetDuration();
if (Player* modOwner = m_originalCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
modOwner->ApplySpellMod<SPELLMOD_DURATION>(m_spellInfo->Id, duration);
//TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
Map* map = caster->GetMap();
+8 -5
View File
@@ -161,6 +161,9 @@ void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, Item const* item,
void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, uint32 itemID, Spell* spell /*= nullptr*/)
{
if (spell && spell->IsIgnoringCooldowns())
return;
if (Player* player = _owner->ToPlayer())
{
// potions start cooldown until exiting combat
@@ -174,7 +177,7 @@ void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, uint32 itemID, Sp
}
}
if (spellInfo->IsCooldownStartedOnEvent() || spellInfo->IsPassive() || (spell && spell->IsIgnoringCooldowns()))
if (spellInfo->IsCooldownStartedOnEvent() || spellInfo->IsPassive())
return;
StartCooldown(spellInfo, itemID, spell);
@@ -303,11 +306,11 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel
// Now we have cooldown data (if found any), time to apply mods
if (Player* modOwner = _owner->GetSpellModOwner())
{
if (cooldown > 0)
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, cooldown, spell);
if (cooldown >= 0)
modOwner->ApplySpellMod<SPELLMOD_COOLDOWN>(spellInfo->Id, cooldown, spell);
if (categoryCooldown > 0 && !spellInfo->HasAttribute(SPELL_ATTR6_IGNORE_CATEGORY_COOLDOWN_MODS))
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, categoryCooldown, spell);
if (categoryCooldown >= 0 && !spellInfo->HasAttribute(SPELL_ATTR6_IGNORE_CATEGORY_COOLDOWN_MODS))
modOwner->ApplySpellMod<SPELLMOD_COOLDOWN>(spellInfo->Id, categoryCooldown, spell);
}
if (_owner->HasAuraTypeWithAffectMask(SPELL_AURA_MOD_SPELL_COOLDOWN_BY_HASTE, spellInfo))
File diff suppressed because it is too large. Load diff
+258 -227
View File
@@ -313,259 +313,290 @@ struct TC_GAME_API ImmunityInfo
boost::container::flat_set<SpellEffects> SpellEffectImmune;
};
struct TC_GAME_API SpellDiminishInfo
{
DiminishingGroup DiminishGroup = DIMINISHING_NONE;
DiminishingReturnsType DiminishReturnType = DRTYPE_NONE;
DiminishingLevels DiminishMaxLevel = DIMINISHING_LEVEL_IMMUNE;
int32 DiminishDurationLimit = 0;
};
class TC_GAME_API SpellInfo
{
public:
uint32 Id;
SpellCategoryEntry const* CategoryEntry;
uint32 Dispel;
uint32 Mechanic;
uint32 Attributes;
uint32 AttributesEx;
uint32 AttributesEx2;
uint32 AttributesEx3;
uint32 AttributesEx4;
uint32 AttributesEx5;
uint32 AttributesEx6;
uint32 AttributesEx7;
uint32 AttributesEx8;
uint32 AttributesEx9;
uint32 AttributesEx10;
uint32 AttributesCu;
uint64 Stances;
uint64 StancesNot;
uint32 Targets;
uint32 TargetCreatureType;
uint32 RequiresSpellFocus;
uint32 FacingCasterFlags;
uint32 CasterAuraState;
uint32 TargetAuraState;
uint32 CasterAuraStateNot;
uint32 TargetAuraStateNot;
uint32 CasterAuraSpell;
uint32 TargetAuraSpell;
uint32 ExcludeCasterAuraSpell;
uint32 ExcludeTargetAuraSpell;
SpellCastTimesEntry const* CastTimeEntry;
uint32 RecoveryTime;
uint32 CategoryRecoveryTime;
uint32 StartRecoveryCategory;
uint32 StartRecoveryTime;
uint32 InterruptFlags;
uint32 AuraInterruptFlags;
uint32 ChannelInterruptFlags;
uint32 ProcFlags;
uint32 ProcChance;
uint32 ProcCharges;
uint32 MaxLevel;
uint32 BaseLevel;
uint32 SpellLevel;
SpellDurationEntry const* DurationEntry;
uint32 PowerType;
uint32 ManaCost;
uint32 ManaCostPerlevel;
uint32 ManaPerSecond;
uint32 ManaCostPercentage;
uint32 RuneCostID;
SpellRangeEntry const* RangeEntry;
float Speed;
uint32 StackAmount;
uint32 Totem[2];
int32 Reagent[MAX_SPELL_REAGENTS];
uint32 ReagentCount[MAX_SPELL_REAGENTS];
int32 EquippedItemClass;
int32 EquippedItemSubClassMask;
int32 EquippedItemInventoryTypeMask;
uint32 TotemCategory[2];
uint32 SpellVisual[2];
uint32 SpellIconID;
uint32 ActiveIconID;
char* SpellName;
char* Rank;
uint32 MaxTargetLevel;
uint32 MaxAffectedTargets;
uint32 SpellFamilyName;
flag96 SpellFamilyFlags;
uint32 DmgClass;
uint32 PreventionType;
int32 AreaGroupId;
uint32 SchoolMask;
uint32 SpellDifficultyId;
uint32 SpellScalingId;
uint32 SpellAuraOptionsId;
uint32 SpellAuraRestrictionsId;
uint32 SpellCastingRequirementsId;
uint32 SpellCategoriesId;
uint32 SpellClassOptionsId;
uint32 SpellCooldownsId;
uint32 SpellEquippedItemsId;
uint32 SpellInterruptsId;
uint32 SpellLevelsId;
uint32 SpellPowerId;
uint32 SpellReagentsId;
uint32 SpellShapeshiftId;
uint32 SpellTargetRestrictionsId;
uint32 SpellTotemsId;
// SpellScalingEntry
int32 CastTimeMin;
int32 CastTimeMax;
int32 CastTimeMaxLevel;
int32 ScalingClass;
float CoefBase;
int32 CoefLevelBase;
SpellEffectInfo Effects[MAX_SPELL_EFFECTS];
uint32 ExplicitTargetMask;
SpellChainNode const* ChainEntry;
friend class SpellMgr;
// struct access functions
SpellTargetRestrictionsEntry const* GetSpellTargetRestrictions() const;
SpellAuraOptionsEntry const* GetSpellAuraOptions() const;
SpellAuraRestrictionsEntry const* GetSpellAuraRestrictions() const;
SpellCastingRequirementsEntry const* GetSpellCastingRequirements() const;
SpellCategoriesEntry const* GetSpellCategories() const;
SpellClassOptionsEntry const* GetSpellClassOptions() const;
SpellCooldownsEntry const* GetSpellCooldowns() const;
SpellEquippedItemsEntry const* GetSpellEquippedItems() const;
SpellInterruptsEntry const* GetSpellInterrupts() const;
SpellLevelsEntry const* GetSpellLevels() const;
SpellPowerEntry const* GetSpellPower() const;
SpellReagentsEntry const* GetSpellReagents() const;
SpellScalingEntry const* GetSpellScaling() const;
SpellShapeshiftEntry const* GetSpellShapeshift() const;
SpellTotemsEntry const* GetSpellTotems() const;
public:
uint32 Id;
SpellCategoryEntry const* CategoryEntry;
uint32 Dispel;
uint32 Mechanic;
uint32 Attributes;
uint32 AttributesEx;
uint32 AttributesEx2;
uint32 AttributesEx3;
uint32 AttributesEx4;
uint32 AttributesEx5;
uint32 AttributesEx6;
uint32 AttributesEx7;
uint32 AttributesEx8;
uint32 AttributesEx9;
uint32 AttributesEx10;
uint32 AttributesCu;
uint64 Stances;
uint64 StancesNot;
uint32 Targets;
uint32 TargetCreatureType;
uint32 RequiresSpellFocus;
uint32 FacingCasterFlags;
uint32 CasterAuraState;
uint32 TargetAuraState;
uint32 CasterAuraStateNot;
uint32 TargetAuraStateNot;
uint32 CasterAuraSpell;
uint32 TargetAuraSpell;
uint32 ExcludeCasterAuraSpell;
uint32 ExcludeTargetAuraSpell;
SpellCastTimesEntry const* CastTimeEntry;
uint32 RecoveryTime;
uint32 CategoryRecoveryTime;
uint32 StartRecoveryCategory;
uint32 StartRecoveryTime;
uint32 InterruptFlags;
uint32 AuraInterruptFlags;
uint32 ChannelInterruptFlags;
uint32 ProcFlags;
uint32 ProcChance;
uint32 ProcCharges;
uint32 MaxLevel;
uint32 BaseLevel;
uint32 SpellLevel;
SpellDurationEntry const* DurationEntry;
uint32 PowerType;
uint32 ManaCost;
uint32 ManaCostPerlevel;
uint32 ManaPerSecond;
uint32 ManaCostPercentage;
uint32 RuneCostID;
SpellRangeEntry const* RangeEntry;
float Speed;
uint32 StackAmount;
uint32 Totem[2];
int32 Reagent[MAX_SPELL_REAGENTS];
uint32 ReagentCount[MAX_SPELL_REAGENTS];
int32 EquippedItemClass;
int32 EquippedItemSubClassMask;
int32 EquippedItemInventoryTypeMask;
uint32 TotemCategory[2];
uint32 SpellVisual[2];
uint32 SpellIconID;
uint32 ActiveIconID;
char* SpellName;
char* Rank;
uint32 MaxTargetLevel;
uint32 MaxAffectedTargets;
uint32 SpellFamilyName;
flag96 SpellFamilyFlags;
uint32 DmgClass;
uint32 PreventionType;
int32 AreaGroupId;
uint32 SchoolMask;
uint32 SpellDifficultyId;
uint32 SpellScalingId;
uint32 SpellAuraOptionsId;
uint32 SpellAuraRestrictionsId;
uint32 SpellCastingRequirementsId;
uint32 SpellCategoriesId;
uint32 SpellClassOptionsId;
uint32 SpellCooldownsId;
uint32 SpellEquippedItemsId;
uint32 SpellInterruptsId;
uint32 SpellLevelsId;
uint32 SpellPowerId;
uint32 SpellReagentsId;
uint32 SpellShapeshiftId;
uint32 SpellTargetRestrictionsId;
uint32 SpellTotemsId;
// SpellScalingEntry
int32 CastTimeMin;
int32 CastTimeMax;
int32 CastTimeMaxLevel;
int32 ScalingClass;
float CoefBase;
int32 CoefLevelBase;
SpellEffectInfo Effects[MAX_SPELL_EFFECTS];
uint32 ExplicitTargetMask;
SpellChainNode const* ChainEntry;
SpellInfo(SpellEntry const* spellEntry, SpellEffectEntry const** effects);
~SpellInfo();
// struct access functions
SpellTargetRestrictionsEntry const* GetSpellTargetRestrictions() const;
SpellAuraOptionsEntry const* GetSpellAuraOptions() const;
SpellAuraRestrictionsEntry const* GetSpellAuraRestrictions() const;
SpellCastingRequirementsEntry const* GetSpellCastingRequirements() const;
SpellCategoriesEntry const* GetSpellCategories() const;
SpellClassOptionsEntry const* GetSpellClassOptions() const;
SpellCooldownsEntry const* GetSpellCooldowns() const;
SpellEquippedItemsEntry const* GetSpellEquippedItems() const;
SpellInterruptsEntry const* GetSpellInterrupts() const;
SpellLevelsEntry const* GetSpellLevels() const;
SpellPowerEntry const* GetSpellPower() const;
SpellReagentsEntry const* GetSpellReagents() const;
SpellScalingEntry const* GetSpellScaling() const;
SpellShapeshiftEntry const* GetSpellShapeshift() const;
SpellTotemsEntry const* GetSpellTotems() const;
uint32 GetCategory() const;
bool HasEffect(SpellEffects effect) const;
bool HasAura(AuraType aura) const;
bool HasAreaAuraEffect() const;
SpellInfo(SpellEntry const* spellEntry, SpellEffectEntry const** effects);
~SpellInfo();
inline bool HasAttribute(SpellAttr0 attribute) const { return !!(Attributes & attribute); }
inline bool HasAttribute(SpellAttr1 attribute) const { return !!(AttributesEx & attribute); }
inline bool HasAttribute(SpellAttr2 attribute) const { return !!(AttributesEx2 & attribute); }
inline bool HasAttribute(SpellAttr3 attribute) const { return !!(AttributesEx3 & attribute); }
inline bool HasAttribute(SpellAttr4 attribute) const { return !!(AttributesEx4 & attribute); }
inline bool HasAttribute(SpellAttr5 attribute) const { return !!(AttributesEx5 & attribute); }
inline bool HasAttribute(SpellAttr6 attribute) const { return !!(AttributesEx6 & attribute); }
inline bool HasAttribute(SpellAttr7 attribute) const { return !!(AttributesEx7 & attribute); }
inline bool HasAttribute(SpellAttr8 attribute) const { return !!(AttributesEx8 & attribute); }
inline bool HasAttribute(SpellAttr9 attribute) const { return !!(AttributesEx9 & attribute); }
inline bool HasAttribute(SpellAttr10 attribute) const { return !!(AttributesEx10 & attribute); }
inline bool HasAttribute(SpellCustomAttributes customAttribute) const { return !!(AttributesCu & customAttribute); }
uint32 GetCategory() const;
bool HasEffect(SpellEffects effect) const;
bool HasAura(AuraType aura) const;
bool HasAreaAuraEffect() const;
bool HasOnlyDamageEffects() const;
bool IsExplicitDiscovery() const;
bool IsLootCrafting() const;
bool IsQuestTame() const;
bool IsProfessionOrRiding() const;
bool IsProfession() const;
bool IsPrimaryProfession() const;
bool IsPrimaryProfessionFirstRank() const;
bool IsAbilityLearnedWithProfession() const;
bool IsAbilityOfSkillType(uint32 skillType) const;
inline bool HasAttribute(SpellAttr0 attribute) const { return !!(Attributes & attribute); }
inline bool HasAttribute(SpellAttr1 attribute) const { return !!(AttributesEx & attribute); }
inline bool HasAttribute(SpellAttr2 attribute) const { return !!(AttributesEx2 & attribute); }
inline bool HasAttribute(SpellAttr3 attribute) const { return !!(AttributesEx3 & attribute); }
inline bool HasAttribute(SpellAttr4 attribute) const { return !!(AttributesEx4 & attribute); }
inline bool HasAttribute(SpellAttr5 attribute) const { return !!(AttributesEx5 & attribute); }
inline bool HasAttribute(SpellAttr6 attribute) const { return !!(AttributesEx6 & attribute); }
inline bool HasAttribute(SpellAttr7 attribute) const { return !!(AttributesEx7 & attribute); }
inline bool HasAttribute(SpellAttr8 attribute) const { return !!(AttributesEx8 & attribute); }
inline bool HasAttribute(SpellAttr9 attribute) const { return !!(AttributesEx9 & attribute); }
inline bool HasAttribute(SpellAttr10 attribute) const { return !!(AttributesEx10 & attribute); }
inline bool HasAttribute(SpellCustomAttributes customAttribute) const { return !!(AttributesCu & customAttribute); }
bool IsAffectingArea() const;
bool IsTargetingArea() const;
bool NeedsExplicitUnitTarget() const;
bool NeedsToBeTriggeredByCaster(SpellInfo const* triggeringSpell) const;
bool IsExplicitDiscovery() const;
bool IsLootCrafting() const;
bool IsQuestTame() const;
bool IsProfessionOrRiding() const;
bool IsProfession() const;
bool IsPrimaryProfession() const;
bool IsPrimaryProfessionFirstRank() const;
bool IsAbilityLearnedWithProfession() const;
bool IsAbilityOfSkillType(uint32 skillType) const;
bool IsPassive() const;
bool IsRaidMarker() const;
bool IsAutocastable() const;
bool IsStackableWithRanks() const;
bool IsPassiveStackableWithRanks() const;
bool IsMultiSlotAura() const;
bool IsStackableOnOneSlotWithDifferentCasters() const;
bool IsCooldownStartedOnEvent() const;
bool IsDeathPersistent() const;
bool IsRequiringDeadTarget() const;
bool IsAllowingDeadTarget() const;
bool IsGroupBuff() const;
bool CanBeUsedInCombat() const;
bool IsPositive() const;
bool IsPositiveEffect(uint8 effIndex) const;
bool IsChanneled() const;
bool IsMoveAllowedChannel() const;
bool NeedsComboPoints() const;
bool IsNextMeleeSwingSpell() const;
bool IsBreakingStealth() const;
bool IsRangedWeaponSpell() const;
bool IsAutoRepeatRangedSpell() const;
bool HasInitialAggro() const;
bool IsAffectingArea() const;
bool IsTargetingArea() const;
bool NeedsExplicitUnitTarget() const;
bool NeedsToBeTriggeredByCaster(SpellInfo const* triggeringSpell) const;
bool IsAffected(uint32 familyName, flag96 const& familyFlags) const;
bool IsPassive() const;
bool IsRaidMarker() const;
bool IsAutocastable() const;
bool IsStackableWithRanks() const;
bool IsPassiveStackableWithRanks() const;
bool IsMultiSlotAura() const;
bool IsStackableOnOneSlotWithDifferentCasters() const;
bool IsCooldownStartedOnEvent() const;
bool IsDeathPersistent() const;
bool IsRequiringDeadTarget() const;
bool IsAllowingDeadTarget() const;
bool IsGroupBuff() const;
bool CanBeUsedInCombat() const;
bool IsPositive() const;
bool IsPositiveEffect(uint8 effIndex) const;
bool IsChanneled() const;
bool IsMoveAllowedChannel() const;
bool NeedsComboPoints() const;
bool IsNextMeleeSwingSpell() const;
bool IsBreakingStealth() const;
bool IsRangedWeaponSpell() const;
bool IsAutoRepeatRangedSpell() const;
bool HasInitialAggro() const;
bool IsAffectedBySpellMods() const;
bool IsAffectedBySpellMod(SpellModifier const* mod) const;
bool IsAffected(uint32 familyName, flag96 const& familyFlags) const;
bool CanPierceImmuneAura(SpellInfo const* auraSpellInfo) const;
bool CanDispelAura(SpellInfo const* auraSpellInfo) const;
bool IsAffectedBySpellMods() const;
bool IsAffectedBySpellMod(SpellModifier const* mod) const;
bool IsSingleTarget() const;
bool IsAuraExclusiveBySpecificWith(SpellInfo const* spellInfo) const;
bool IsAuraExclusiveBySpecificPerCasterWith(SpellInfo const* spellInfo) const;
bool CanPierceImmuneAura(SpellInfo const* auraSpellInfo) const;
bool CanDispelAura(SpellInfo const* auraSpellInfo) const;
SpellCastResult CheckShapeshift(uint32 form) const;
SpellCastResult CheckLocation(uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = NULL) const;
SpellCastResult CheckTarget(Unit const* caster, WorldObject const* target, bool implicit = true) const;
SpellCastResult CheckExplicitTarget(Unit const* caster, WorldObject const* target, Item const* itemTarget = NULL) const;
SpellCastResult CheckVehicle(Unit const* caster) const;
bool CheckTargetCreatureType(Unit const* target) const;
bool IsSingleTarget() const;
bool IsAuraExclusiveBySpecificWith(SpellInfo const* spellInfo) const;
bool IsAuraExclusiveBySpecificPerCasterWith(SpellInfo const* spellInfo) const;
SpellSchoolMask GetSchoolMask() const;
uint32 GetAllEffectsMechanicMask() const;
uint32 GetEffectMechanicMask(uint8 effIndex) const;
uint32 GetSpellMechanicMaskByEffectMask(uint32 effectMask) const;
Mechanics GetEffectMechanic(uint8 effIndex) const;
bool HasAnyEffectMechanic() const;
uint32 GetDispelMask() const;
static uint32 GetDispelMask(DispelType type);
uint32 GetExplicitTargetMask() const;
SpellCastResult CheckShapeshift(uint32 form) const;
SpellCastResult CheckLocation(uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = NULL) const;
SpellCastResult CheckTarget(Unit const* caster, WorldObject const* target, bool implicit = true) const;
SpellCastResult CheckExplicitTarget(Unit const* caster, WorldObject const* target, Item const* itemTarget = NULL) const;
SpellCastResult CheckVehicle(Unit const* caster) const;
bool CheckTargetCreatureType(Unit const* target) const;
AuraStateType GetAuraState() const;
SpellSpecificType GetSpellSpecific() const;
SpellSchoolMask GetSchoolMask() const;
uint32 GetAllEffectsMechanicMask() const;
uint32 GetEffectMechanicMask(uint8 effIndex) const;
uint32 GetSpellMechanicMaskByEffectMask(uint32 effectMask) const;
Mechanics GetEffectMechanic(uint8 effIndex) const;
bool HasAnyEffectMechanic() const;
uint32 GetDispelMask() const;
static uint32 GetDispelMask(DispelType type);
uint32 GetExplicitTargetMask() const;
float GetMinRange(bool positive = false) const;
float GetMaxRange(bool positive = false, Unit* caster = NULL, Spell* spell = NULL) const;
AuraStateType GetAuraState() const;
SpellSpecificType GetSpellSpecific() const;
int32 GetDuration() const;
int32 GetMaxDuration() const;
float GetMinRange(bool positive = false) const;
float GetMaxRange(bool positive = false, Unit* caster = nullptr, Spell* spell = nullptr) const;
uint32 GetMaxTicks() const;
int32 GetDuration() const;
int32 GetMaxDuration() const;
uint32 CalcCastTime(uint8 level = 0, Spell* spell = NULL) const;
uint32 GetRecoveryTime() const;
uint32 GetMaxTicks() const;
int32 CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const;
uint32 CalcCastTime(uint8 level = 0, Spell* spell = nullptr) const;
uint32 GetRecoveryTime() const;
bool IsRanked() const;
uint8 GetRank() const;
SpellInfo const* GetFirstRankSpell() const;
SpellInfo const* GetLastRankSpell() const;
SpellInfo const* GetNextRankSpell() const;
SpellInfo const* GetPrevRankSpell() const;
SpellInfo const* GetAuraRankForLevel(uint8 level) const;
bool IsRankOf(SpellInfo const* spellInfo) const;
bool IsDifferentRankOf(SpellInfo const* spellInfo) const;
bool IsHighRankOf(SpellInfo const* spellInfo) const;
int32 CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask, Spell* spell = nullptr) const;
// spell immunities
void ApplyAllSpellImmunitiesTo(Unit* target, uint8 effIndex, bool apply) const;
bool CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInfo) const;
bool CanSpellCastOverrideAuraEffect(SpellInfo const* auraSpellInfo, uint8 auraEffIndex) const;
bool IsRanked() const;
uint8 GetRank() const;
SpellInfo const* GetFirstRankSpell() const;
SpellInfo const* GetLastRankSpell() const;
SpellInfo const* GetNextRankSpell() const;
SpellInfo const* GetPrevRankSpell() const;
SpellInfo const* GetAuraRankForLevel(uint8 level) const;
bool IsRankOf(SpellInfo const* spellInfo) const;
bool IsDifferentRankOf(SpellInfo const* spellInfo) const;
bool IsHighRankOf(SpellInfo const* spellInfo) const;
// loading helpers
void _InitializeExplicitTargetMask();
bool _IsPositiveEffect(uint8 effIndex, bool deep) const;
bool _IsPositiveSpell() const;
static bool _IsPositiveTarget(uint32 targetA, uint32 targetB);
void _LoadImmunityInfo();
// spell diminishing returns
DiminishingGroup GetDiminishingReturnsGroupForSpell(bool triggered) const;
DiminishingReturnsType GetDiminishingReturnsGroupType(bool triggered) const;
DiminishingLevels GetDiminishingReturnsMaxLevel(bool triggered) const;
int32 GetDiminishingReturnsLimitDuration(bool triggered) const;
// unloading helpers
void _UnloadImplicitTargetConditionLists();
// spell immunities
void ApplyAllSpellImmunitiesTo(Unit* target, uint8 effIndex, bool apply) const;
bool CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInfo) const;
bool SpellCancelsAuraEffect(SpellInfo const* auraSpellInfo, uint8 auraEffIndex) const;
ImmunityInfo _immunityInfo[MAX_SPELL_EFFECTS];
uint32 GetAllowedMechanicMask() const;
private:
// loading helpers
void _InitializeExplicitTargetMask();
bool _IsPositiveEffect(uint8 effIndex, bool deep) const;
bool _IsPositiveSpell() const;
static bool _IsPositiveTarget(uint32 targetA, uint32 targetB);
void _LoadSpellSpecific();
void _LoadAuraState();
void _LoadSpellDiminishInfo();
void _LoadImmunityInfo();
// unloading helpers
void _UnloadImplicitTargetConditionLists();
SpellSpecificType _spellSpecific;
AuraStateType _auraState;
SpellDiminishInfo _diminishInfoNonTriggered;
SpellDiminishInfo _diminishInfoTriggered;
uint32 _allowedMechanicMask;
ImmunityInfo _immunityInfo[MAX_SPELL_EFFECTS];
};
#endif // _SPELLINFO_H
File diff suppressed because it is too large. Load diff
+37 -73
View File
@@ -36,6 +36,7 @@ class Player;
class Unit;
class ProcEventInfo;
struct SkillLineAbilityEntry;
enum AuraType;
// only used in code
enum SpellCategories
@@ -158,13 +159,13 @@ enum ProcFlags
| PROC_FLAG_DONE_SPELL_RANGED_DMG_CLASS | PROC_FLAG_TAKEN_SPELL_RANGED_DMG_CLASS,
SPELL_PROC_FLAG_MASK = PROC_FLAG_DONE_SPELL_MELEE_DMG_CLASS | PROC_FLAG_TAKEN_SPELL_MELEE_DMG_CLASS
| PROC_FLAG_DONE_RANGED_AUTO_ATTACK | PROC_FLAG_TAKEN_RANGED_AUTO_ATTACK
| PROC_FLAG_DONE_SPELL_RANGED_DMG_CLASS | PROC_FLAG_TAKEN_SPELL_RANGED_DMG_CLASS
| PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS | PROC_FLAG_TAKEN_SPELL_NONE_DMG_CLASS_POS
| PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_NEG | PROC_FLAG_TAKEN_SPELL_NONE_DMG_CLASS_NEG
| PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS | PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS
| PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG | PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG,
SPELL_CAST_PROC_FLAG_MASK = SPELL_PROC_FLAG_MASK | PROC_FLAG_DONE_TRAP_ACTIVATION | RANGED_PROC_FLAG_MASK,
| PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG | PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG
| PROC_FLAG_DONE_TRAP_ACTIVATION,
PERIODIC_PROC_FLAG_MASK = PROC_FLAG_DONE_PERIODIC | PROC_FLAG_TAKEN_PERIODIC,
@@ -172,7 +173,8 @@ enum ProcFlags
| PROC_FLAG_DONE_SPELL_MELEE_DMG_CLASS | PROC_FLAG_DONE_SPELL_RANGED_DMG_CLASS
| PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS | PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_NEG
| PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS | PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG
| PROC_FLAG_DONE_PERIODIC | PROC_FLAG_DONE_MAINHAND_ATTACK | PROC_FLAG_DONE_OFFHAND_ATTACK,
| PROC_FLAG_DONE_PERIODIC | PROC_FLAG_DONE_TRAP_ACTIVATION
| PROC_FLAG_DONE_MAINHAND_ATTACK | PROC_FLAG_DONE_OFFHAND_ATTACK,
TAKEN_HIT_PROC_FLAG_MASK = PROC_FLAG_TAKEN_MELEE_AUTO_ATTACK | PROC_FLAG_TAKEN_RANGED_AUTO_ATTACK
| PROC_FLAG_TAKEN_SPELL_MELEE_DMG_CLASS | PROC_FLAG_TAKEN_SPELL_RANGED_DMG_CLASS
@@ -192,43 +194,6 @@ enum ProcFlags
PROC_FLAG_DONE_SPELL_RANGED_DMG_CLASS | \
PROC_FLAG_TAKEN_SPELL_RANGED_DMG_CLASS)
enum ProcFlagsExLegacy
{
PROC_EX_NONE = 0x0000000, // If none can tigger on Hit/Crit only (passive spells MUST defined by SpellFamily flag)
PROC_EX_NORMAL_HIT = 0x0000001, // If set only from normal hit (only damage spells)
PROC_EX_CRITICAL_HIT = 0x0000002,
PROC_EX_MISS = 0x0000004,
PROC_EX_RESIST = 0x0000008,
PROC_EX_DODGE = 0x0000010,
PROC_EX_PARRY = 0x0000020,
PROC_EX_BLOCK = 0x0000040,
PROC_EX_EVADE = 0x0000080,
PROC_EX_IMMUNE = 0x0000100,
PROC_EX_DEFLECT = 0x0000200,
PROC_EX_ABSORB = 0x0000400,
PROC_EX_REFLECT = 0x0000800,
PROC_EX_INTERRUPT = 0x0001000, // Melee hit result can be Interrupt (not used)
PROC_EX_FULL_BLOCK = 0x0002000, // block al attack damage
PROC_EX_RESERVED2 = 0x0004000,
PROC_EX_NOT_ACTIVE_SPELL = 0x0008000, // Spell mustn't do damage/heal to proc
PROC_EX_EX_TRIGGER_ALWAYS = 0x0010000, // If set trigger always no matter of hit result
PROC_EX_EX_ONE_TIME_TRIGGER = 0x0020000, // If set trigger always but only one time (not implemented yet)
PROC_EX_ONLY_ACTIVE_SPELL = 0x0040000, // Spell has to do damage/heal to proc
// Flags for internal use - do not use these in db!
PROC_EX_INTERNAL_CANT_PROC = 0x0800000,
PROC_EX_INTERNAL_DOT = 0x1000000,
PROC_EX_INTERNAL_HOT = 0x2000000,
PROC_EX_INTERNAL_TRIGGERED = 0x4000000,
PROC_EX_INTERNAL_REQ_FAMILY = 0x8000000
};
#define AURA_SPELL_PROC_EX_MASK \
(PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT | PROC_EX_MISS | \
PROC_EX_RESIST | PROC_EX_DODGE | PROC_EX_PARRY | PROC_EX_BLOCK | \
PROC_EX_EVADE | PROC_EX_IMMUNE | PROC_EX_DEFLECT | \
PROC_EX_ABSORB | PROC_EX_REFLECT | PROC_EX_INTERRUPT)
enum ProcFlagsSpellType
{
PROC_SPELL_TYPE_NONE = 0x0000000,
@@ -269,22 +234,17 @@ enum ProcFlagsHit
enum ProcAttributes
{
PROC_ATTR_REQ_EXP_OR_HONOR = 0x0000010
};
PROC_ATTR_REQ_EXP_OR_HONOR = 0x0000001, // requires proc target to give exp or honor for aura proc
PROC_ATTR_TRIGGERED_CAN_PROC = 0x0000002, // aura can proc even with triggered spells
PROC_ATTR_REQ_MANA_COST = 0x0000004, // requires triggering spell to have a mana cost for aura proc
PROC_ATTR_REQ_SPELLMOD = 0x0000008, // requires triggering spell to be affected by proccing aura to drop charges
struct SpellProcEventEntry
{
uint32 schoolMask; // if nonzero - bit mask for matching proc condition based on spell candidate's school: Fire=2, Mask=1<<(2-1)=2
uint32 spellFamilyName; // if nonzero - for matching proc condition based on candidate spell's SpellFamilyNamer value
flag96 spellFamilyMask; // if nonzero - for matching proc condition based on candidate spell's SpellFamilyFlags (like auras 107 and 108 do)
uint32 procFlags; // bitmask for matching proc event
uint32 procEx; // proc Extend info (see ProcFlagsEx)
float ppmRate; // for melee (ranged?) damage spells - proc rate per minute. if zero, falls back to flat chance from Spell.dbc
float customChance; // Owerride chance (in most cases for debug only)
uint32 cooldown; // hidden cooldown used for some spell proc events, applied to _triggered_spell_
};
PROC_ATTR_DISABLE_EFF_0 = 0x0000010, // explicitly disables aura proc from effects, USE ONLY IF 100% SURE AURA SHOULDN'T PROC
PROC_ATTR_DISABLE_EFF_1 = 0x0000020, /// used to avoid a console error if the spell has invalid trigger spell and handled elsewhere
PROC_ATTR_DISABLE_EFF_2 = 0x0000040, /// or handling not needed
typedef std::unordered_map<uint32, SpellProcEventEntry> SpellProcEventMap;
PROC_ATTR_REDUCE_PROC_60 = 0x0000080 // aura should have a reduced chance to proc if level of proc Actor > 60
};
struct SpellProcEntry
{
@@ -333,14 +293,26 @@ enum SpellGroup
SPELL_GROUP_CORE_RANGE_MAX = 5
};
namespace std
{
template<>
struct hash<SpellGroup>
{
size_t operator()(SpellGroup const& group) const
{
return hash<uint32>()(uint32(group));
}
};
}
#define SPELL_GROUP_DB_RANGE_MIN 1000
// spell_id, group_id
typedef std::multimap<uint32, SpellGroup > SpellSpellGroupMap;
typedef std::unordered_multimap<uint32, SpellGroup> SpellSpellGroupMap;
typedef std::pair<SpellSpellGroupMap::const_iterator, SpellSpellGroupMap::const_iterator> SpellSpellGroupMapBounds;
// group_id, spell_id
typedef std::multimap<SpellGroup, int32> SpellGroupSpellMap;
typedef std::unordered_multimap<SpellGroup, int32> SpellGroupSpellMap;
typedef std::pair<SpellGroupSpellMap::const_iterator, SpellGroupSpellMap::const_iterator> SpellGroupSpellMapBounds;
enum SpellGroupStackRule
@@ -353,7 +325,9 @@ enum SpellGroupStackRule
SPELL_GROUP_STACK_RULE_MAX
};
typedef std::map<SpellGroup, SpellGroupStackRule> SpellGroupStackMap;
typedef std::unordered_map<SpellGroup, SpellGroupStackRule> SpellGroupStackMap;
typedef std::unordered_map<SpellGroup, std::unordered_set<uint32 /*auraName*/>> SameEffectStackMap;
struct SpellThreatEntry
{
@@ -594,13 +568,6 @@ inline bool IsProfessionOrRidingSkill(uint32 skill)
bool IsPartOfSkillLine(uint32 skillId, uint32 spellId);
// spell diminishing returns
TC_GAME_API DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto, bool triggered);
TC_GAME_API DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group);
TC_GAME_API DiminishingLevels GetDiminishingReturnsMaxLevel(DiminishingGroup group);
TC_GAME_API int32 GetDiminishingReturnsLimitDuration(DiminishingGroup group, SpellInfo const* spellproto);
TC_GAME_API bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group);
class TC_GAME_API SpellMgr
{
// Constructors
@@ -654,17 +621,13 @@ class TC_GAME_API SpellMgr
void GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set<uint32>& foundSpells, std::set<SpellGroup>& usedGroups) const;
// Spell Group Stack Rules table
bool AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, int32 amount, std::map<SpellGroup, int32>& groups) const;
bool AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, uint32 auraType, int32 amount, std::map<SpellGroup, int32>& groups) const;
SpellGroupStackRule CheckSpellGroupStackRules(SpellInfo const* spellInfo1, SpellInfo const* spellInfo2) const;
SpellGroupStackRule GetSpellGroupStackRule(SpellGroup groupid) const;
// Spell proc event table
SpellProcEventEntry const* GetSpellProcEvent(uint32 spellId) const;
bool IsSpellProcEventCanTriggeredBy(SpellInfo const* spellProto, SpellProcEventEntry const* spellProcEvent, uint32 EventProcFlag, SpellInfo const* procSpell, uint32 procFlags, uint32 procExtra, bool active) const;
// Spell proc table
SpellProcEntry const* GetSpellProcEntry(uint32 spellId) const;
bool CanSpellTriggerProcOnEvent(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo) const;
static bool CanSpellTriggerProcOnEvent(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo);
// Spell bonus data table
SpellBonusEntry const* GetSpellBonusData(uint32 spellId) const;
@@ -720,7 +683,6 @@ class TC_GAME_API SpellMgr
void LoadSpellTargetPositions();
void LoadSpellGroups();
void LoadSpellGroupStackRules();
void LoadSpellProcEvents();
void LoadSpellProcs();
void LoadSpellBonusess();
void LoadSpellThreats();
@@ -737,6 +699,8 @@ class TC_GAME_API SpellMgr
void UnloadSpellInfoImplicitTargetConditionLists();
void LoadSpellInfoCustomAttributes();
void LoadSpellInfoCorrections();
void LoadSpellInfoSpellSpecificAndAuraState();
void LoadSpellInfoDiminishing();
void LoadSpellInfoImmunities();
private:
@@ -750,7 +714,7 @@ class TC_GAME_API SpellMgr
SpellSpellGroupMap mSpellSpellGroup;
SpellGroupSpellMap mSpellGroupSpell;
SpellGroupStackMap mSpellGroupStack;
SpellProcEventMap mSpellProcEventMap;
SameEffectStackMap mSpellSameEffectStack;
SpellProcMap mSpellProcMap;
SpellBonusMap mSpellBonusMap;
SpellThreatMap mSpellThreatMap;
+47 -31
View File
@@ -316,35 +316,35 @@ void SpellScript::DestinationTargetSelectHandler::Call(SpellScript* spellScript,
bool SpellScript::_Validate(SpellInfo const* entry)
{
for (std::list<EffectHandler>::iterator itr = OnEffectLaunch.begin(); itr != OnEffectLaunch.end(); ++itr)
for (auto itr = OnEffectLaunch.begin(); itr != OnEffectLaunch.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectLaunch` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectHandler>::iterator itr = OnEffectLaunchTarget.begin(); itr != OnEffectLaunchTarget.end(); ++itr)
for (auto itr = OnEffectLaunchTarget.begin(); itr != OnEffectLaunchTarget.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectLaunchTarget` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectHandler>::iterator itr = OnEffectHit.begin(); itr != OnEffectHit.end(); ++itr)
for (auto itr = OnEffectHit.begin(); itr != OnEffectHit.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectHit` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectHandler>::iterator itr = OnEffectHitTarget.begin(); itr != OnEffectHitTarget.end(); ++itr)
for (auto itr = OnEffectHitTarget.begin(); itr != OnEffectHitTarget.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectHitTarget` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectHandler>::iterator itr = OnEffectSuccessfulDispel.begin(); itr != OnEffectSuccessfulDispel.end(); ++itr)
for (auto itr = OnEffectSuccessfulDispel.begin(); itr != OnEffectSuccessfulDispel.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectSuccessfulDispel` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<ObjectAreaTargetSelectHandler>::iterator itr = OnObjectAreaTargetSelect.begin(); itr != OnObjectAreaTargetSelect.end(); ++itr)
for (auto itr = OnObjectAreaTargetSelect.begin(); itr != OnObjectAreaTargetSelect.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnObjectAreaTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<ObjectTargetSelectHandler>::iterator itr = OnObjectTargetSelect.begin(); itr != OnObjectTargetSelect.end(); ++itr)
for (auto itr = OnObjectTargetSelect.begin(); itr != OnObjectTargetSelect.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnObjectTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<DestinationTargetSelectHandler>::iterator itr = OnDestinationTargetSelect.begin(); itr != OnDestinationTargetSelect.end(); ++itr)
for (auto itr = OnDestinationTargetSelect.begin(); itr != OnDestinationTargetSelect.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnDestinationTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
@@ -663,95 +663,99 @@ SpellValue const* SpellScript::GetSpellValue()
bool AuraScript::_Validate(SpellInfo const* entry)
{
for (std::list<CheckAreaTargetHandler>::iterator itr = DoCheckAreaTarget.begin(); itr != DoCheckAreaTarget.end(); ++itr)
for (auto itr = DoCheckAreaTarget.begin(); itr != DoCheckAreaTarget.end(); ++itr)
if (!entry->HasAreaAuraEffect() && !entry->HasEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA) && !entry->HasEffect(SPELL_EFFECT_APPLY_AURA))
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `DoCheckAreaTarget` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
for (std::list<AuraDispelHandler>::iterator itr = OnDispel.begin(); itr != OnDispel.end(); ++itr)
for (auto itr = OnDispel.begin(); itr != OnDispel.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `OnDispel` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
for (std::list<AuraDispelHandler>::iterator itr = AfterDispel.begin(); itr != AfterDispel.end(); ++itr)
for (auto itr = AfterDispel.begin(); itr != AfterDispel.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `AfterDispel` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
for (std::list<EffectApplyHandler>::iterator itr = OnEffectApply.begin(); itr != OnEffectApply.end(); ++itr)
for (auto itr = OnEffectApply.begin(); itr != OnEffectApply.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectApply` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectApplyHandler>::iterator itr = OnEffectRemove.begin(); itr != OnEffectRemove.end(); ++itr)
for (auto itr = OnEffectRemove.begin(); itr != OnEffectRemove.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectRemove` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectApplyHandler>::iterator itr = AfterEffectApply.begin(); itr != AfterEffectApply.end(); ++itr)
for (auto itr = AfterEffectApply.begin(); itr != AfterEffectApply.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectApply` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectApplyHandler>::iterator itr = AfterEffectRemove.begin(); itr != AfterEffectRemove.end(); ++itr)
for (auto itr = AfterEffectRemove.begin(); itr != AfterEffectRemove.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectRemove` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectPeriodicHandler>::iterator itr = OnEffectPeriodic.begin(); itr != OnEffectPeriodic.end(); ++itr)
for (auto itr = OnEffectPeriodic.begin(); itr != OnEffectPeriodic.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectPeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectUpdatePeriodicHandler>::iterator itr = OnEffectUpdatePeriodic.begin(); itr != OnEffectUpdatePeriodic.end(); ++itr)
for (auto itr = OnEffectUpdatePeriodic.begin(); itr != OnEffectUpdatePeriodic.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectUpdatePeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectCalcAmountHandler>::iterator itr = DoEffectCalcAmount.begin(); itr != DoEffectCalcAmount.end(); ++itr)
for (auto itr = DoEffectCalcAmount.begin(); itr != DoEffectCalcAmount.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcAmount` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectCalcPeriodicHandler>::iterator itr = DoEffectCalcPeriodic.begin(); itr != DoEffectCalcPeriodic.end(); ++itr)
for (auto itr = DoEffectCalcPeriodic.begin(); itr != DoEffectCalcPeriodic.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcPeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectCalcSpellModHandler>::iterator itr = DoEffectCalcSpellMod.begin(); itr != DoEffectCalcSpellMod.end(); ++itr)
for (auto itr = DoEffectCalcSpellMod.begin(); itr != DoEffectCalcSpellMod.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcSpellMod` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectAbsorbHandler>::iterator itr = OnEffectAbsorb.begin(); itr != OnEffectAbsorb.end(); ++itr)
for (auto itr = OnEffectAbsorb.begin(); itr != OnEffectAbsorb.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectAbsorb` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectAbsorbHandler>::iterator itr = AfterEffectAbsorb.begin(); itr != AfterEffectAbsorb.end(); ++itr)
for (auto itr = AfterEffectAbsorb.begin(); itr != AfterEffectAbsorb.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectAbsorb` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectManaShieldHandler>::iterator itr = OnEffectManaShield.begin(); itr != OnEffectManaShield.end(); ++itr)
for (auto itr = OnEffectManaShield.begin(); itr != OnEffectManaShield.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectManaShield` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectManaShieldHandler>::iterator itr = AfterEffectManaShield.begin(); itr != AfterEffectManaShield.end(); ++itr)
for (auto itr = AfterEffectManaShield.begin(); itr != AfterEffectManaShield.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectManaShield` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectSplitHandler>::iterator itr = OnEffectSplit.begin(); itr != OnEffectSplit.end(); ++itr)
for (auto itr = OnEffectSplit.begin(); itr != OnEffectSplit.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectSplit` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<CheckProcHandler>::iterator itr = DoCheckProc.begin(); itr != DoCheckProc.end(); ++itr)
for (auto itr = DoCheckProc.begin(); itr != DoCheckProc.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `DoCheckProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
for (std::list<AuraProcHandler>::iterator itr = DoPrepareProc.begin(); itr != DoPrepareProc.end(); ++itr)
for (auto itr = DoCheckEffectProc.begin(); itr != DoCheckEffectProc.end(); ++itr)
if (!itr->GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoCheckEffectProc` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
for (auto itr = DoPrepareProc.begin(); itr != DoPrepareProc.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `DoPrepareProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
for (std::list<AuraProcHandler>::iterator itr = OnProc.begin(); itr != OnProc.end(); ++itr)
for (auto itr = OnProc.begin(); itr != OnProc.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `OnProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
for (std::list<AuraProcHandler>::iterator itr = AfterProc.begin(); itr != AfterProc.end(); ++itr)
for (auto itr = AfterProc.begin(); itr != AfterProc.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `AfterProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
for (std::list<EffectProcHandler>::iterator itr = OnEffectProc.begin(); itr != OnEffectProc.end(); ++itr)
for (auto itr = OnEffectProc.begin(); itr != OnEffectProc.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectProc` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (std::list<EffectProcHandler>::iterator itr = AfterEffectProc.begin(); itr != AfterEffectProc.end(); ++itr)
for (auto itr = AfterEffectProc.begin(); itr != AfterEffectProc.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectProc` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
@@ -902,6 +906,17 @@ bool AuraScript::CheckProcHandler::Call(AuraScript* auraScript, ProcEventInfo& e
return (auraScript->*_HandlerScript)(eventInfo);
}
AuraScript::CheckEffectProcHandler::CheckEffectProcHandler(AuraCheckEffectProcFnType handlerScript, uint8 effIndex, uint16 effName)
: AuraScript::EffectBase(effIndex, effName)
{
_HandlerScript = handlerScript;
}
bool AuraScript::CheckEffectProcHandler::Call(AuraScript* auraScript, AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
return (auraScript->*_HandlerScript)(aurEff, eventInfo);
}
AuraScript::AuraProcHandler::AuraProcHandler(AuraProcFnType handlerScript)
{
_HandlerScript = handlerScript;
@@ -1163,6 +1178,7 @@ Unit* AuraScript::GetTarget() const
case AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD:
case AURA_SCRIPT_HOOK_EFFECT_SPLIT:
case AURA_SCRIPT_HOOK_CHECK_PROC:
case AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC:
case AURA_SCRIPT_HOOK_PREPARE_PROC:
case AURA_SCRIPT_HOOK_PROC:
case AURA_SCRIPT_HOOK_AFTER_PROC:
+20 -3
View File
@@ -63,9 +63,9 @@ class TC_GAME_API _SpellScript
public:
_SpellScript() : m_currentScriptState(SPELL_SCRIPT_STATE_NONE), m_scriptName(NULL), m_scriptSpellId(0) {}
virtual ~_SpellScript() { }
virtual void _Register();
virtual void _Unload();
virtual void _Init(std::string const* scriptname, uint32 spellId);
void _Register();
void _Unload();
void _Init(std::string const* scriptname, uint32 spellId);
std::string const* _GetScriptName() const;
protected:
@@ -470,6 +470,7 @@ enum AuraScriptHookType
AURA_SCRIPT_HOOK_AFTER_DISPEL,
// Spell Proc Hooks
AURA_SCRIPT_HOOK_CHECK_PROC,
AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC,
AURA_SCRIPT_HOOK_PREPARE_PROC,
AURA_SCRIPT_HOOK_PROC,
AURA_SCRIPT_HOOK_EFFECT_PROC,
@@ -501,6 +502,7 @@ class TC_GAME_API AuraScript : public _SpellScript
typedef void(CLASSNAME::*AuraEffectAbsorbFnType)(AuraEffect*, DamageInfo &, uint32 &); \
typedef void(CLASSNAME::*AuraEffectSplitFnType)(AuraEffect*, DamageInfo &, uint32 &); \
typedef bool(CLASSNAME::*AuraCheckProcFnType)(ProcEventInfo&); \
typedef bool(CLASSNAME::*AuraCheckEffectProcFnType)(AuraEffect const*, ProcEventInfo&); \
typedef void(CLASSNAME::*AuraProcFnType)(ProcEventInfo&); \
typedef void(CLASSNAME::*AuraEffectProcFnType)(AuraEffect const*, ProcEventInfo&); \
@@ -610,6 +612,14 @@ class TC_GAME_API AuraScript : public _SpellScript
private:
AuraCheckProcFnType _HandlerScript;
};
class TC_GAME_API CheckEffectProcHandler : public EffectBase
{
public:
CheckEffectProcHandler(AuraCheckEffectProcFnType handlerScript, uint8 effIndex, uint16 effName);
bool Call(AuraScript* auraScript, AuraEffect const* aurEff, ProcEventInfo& eventInfo);
private:
AuraCheckEffectProcFnType _HandlerScript;
};
class TC_GAME_API AuraProcHandler
{
public:
@@ -640,6 +650,7 @@ class TC_GAME_API AuraScript : public _SpellScript
class EffectManaShieldFunction : public AuraScript::EffectManaShieldHandler { public: EffectManaShieldFunction(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectManaShieldHandler((AuraScript::AuraEffectAbsorbFnType)_pEffectHandlerScript, _effIndex) { } }; \
class EffectSplitFunction : public AuraScript::EffectSplitHandler { public: EffectSplitFunction(AuraEffectSplitFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectSplitHandler((AuraScript::AuraEffectSplitFnType)_pEffectHandlerScript, _effIndex) { } }; \
class CheckProcHandlerFunction : public AuraScript::CheckProcHandler { public: CheckProcHandlerFunction(AuraCheckProcFnType handlerScript) : AuraScript::CheckProcHandler((AuraScript::AuraCheckProcFnType)handlerScript) { } }; \
class CheckEffectProcHandlerFunction : public AuraScript::CheckEffectProcHandler { public: CheckEffectProcHandlerFunction(AuraCheckEffectProcFnType handlerScript, uint8 effIndex, uint16 effName) : AuraScript::CheckEffectProcHandler((AuraScript::AuraCheckEffectProcFnType)handlerScript, effIndex, effName) { } }; \
class AuraProcHandlerFunction : public AuraScript::AuraProcHandler { public: AuraProcHandlerFunction(AuraProcFnType handlerScript) : AuraScript::AuraProcHandler((AuraScript::AuraProcFnType)handlerScript) { } }; \
class EffectProcHandlerFunction : public AuraScript::EffectProcHandler { public: EffectProcHandlerFunction(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName) : AuraScript::EffectProcHandler((AuraScript::AuraEffectProcFnType)effectHandlerScript, effIndex, effName) { } }
@@ -778,6 +789,12 @@ class TC_GAME_API AuraScript : public _SpellScript
HookList<CheckProcHandler> DoCheckProc;
#define AuraCheckProcFn(F) CheckProcHandlerFunction(&F)
// executed when aura effect checks if it can proc the aura
// example: DoCheckEffectProc += AuraCheckEffectProcFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
// where function is bool function (AuraEffect const* aurEff, ProcEventInfo& eventInfo);
HookList<CheckEffectProcHandler> DoCheckEffectProc;
#define AuraCheckEffectProcFn(F, I, N) CheckEffectProcHandlerFunction(&F, I, N)
// executed before aura procs (possibility to prevent charge drop/cooldown)
// example: DoPrepareProc += AuraProcFn(class::function);
// where function is: void function (ProcEventInfo& eventInfo);
+6 -3
View File
@@ -1512,6 +1512,9 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading SpellInfo custom attributes...");
sSpellMgr->LoadSpellInfoCustomAttributes();
TC_LOG_INFO("server.loading", "Loading SpellInfo diminishing infos...");
sSpellMgr->LoadSpellInfoDiminishing();
TC_LOG_INFO("server.loading", "Loading SpellInfo immunity infos...");
sSpellMgr->LoadSpellInfoImmunities();
@@ -1577,12 +1580,12 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading Spell Learn Skills...");
sSpellMgr->LoadSpellLearnSkills(); // must be after LoadSpellRanks
TC_LOG_INFO("server.loading", "Loading SpellInfo SpellSpecific and AuraState...");
sSpellMgr->LoadSpellInfoSpellSpecificAndAuraState(); // must be after LoadSpellRanks
TC_LOG_INFO("server.loading", "Loading Spell Learn Spells...");
sSpellMgr->LoadSpellLearnSpells();
TC_LOG_INFO("server.loading", "Loading Spell Proc Event conditions...");
sSpellMgr->LoadSpellProcEvents();
TC_LOG_INFO("server.loading", "Loading Spell Proc conditions and data...");
sSpellMgr->LoadSpellProcs();
+5 -10
View File
@@ -99,8 +99,7 @@ public:
return false;
}
bool triggered = (triggeredStr != NULL);
TriggerCastFlags triggered = (triggeredStr != NULL) ? TRIGGERED_FULL_DEBUG_MASK : TRIGGERED_NONE;
handler->GetSession()->GetPlayer()->CastSpell(target, spellId, triggered);
return true;
@@ -132,8 +131,7 @@ public:
return false;
}
bool triggered = (triggeredStr != NULL);
TriggerCastFlags triggered = (triggeredStr != NULL) ? TRIGGERED_FULL_DEBUG_MASK : TRIGGERED_NONE;
caster->CastSpell(handler->GetSession()->GetPlayer(), spellId, triggered);
return true;
@@ -167,8 +165,7 @@ public:
return false;
}
bool triggered = (triggeredStr != NULL);
TriggerCastFlags triggered = (triggeredStr != NULL) ? TRIGGERED_FULL_DEBUG_MASK : TRIGGERED_NONE;
float x, y, z;
handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, dist);
@@ -230,8 +227,7 @@ public:
return false;
}
bool triggered = (triggeredStr != NULL);
TriggerCastFlags triggered = (triggeredStr != NULL) ? TRIGGERED_FULL_DEBUG_MASK : TRIGGERED_NONE;
caster->CastSpell(caster->GetVictim(), spellId, triggered);
return true;
@@ -274,8 +270,7 @@ public:
return false;
}
bool triggered = (triggeredStr != NULL);
TriggerCastFlags triggered = (triggeredStr != NULL) ? TRIGGERED_FULL_DEBUG_MASK : TRIGGERED_NONE;
caster->CastSpell(x, y, z, spellId, triggered);
return true;
+24 -11
View File
@@ -2335,19 +2335,20 @@ public:
// melee damage by specific school
if (!spellStr)
{
uint32 absorb = 0;
uint32 resist = 0;
Player* attacker = handler->GetSession()->GetPlayer();
DamageInfo dmgInfo(attacker, target, damage, nullptr, schoolmask, SPELL_DIRECT_DAMAGE, BASE_ATTACK);
attacker->CalcAbsorbResist(dmgInfo);
handler->GetSession()->GetPlayer()->CalcAbsorbResist(target, schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist);
if (damage <= absorb + resist)
if (!dmgInfo.GetDamage())
return true;
damage -= absorb + resist;
damage = dmgInfo.GetDamage();
handler->GetSession()->GetPlayer()->DealDamageMods(target, damage, &absorb);
handler->GetSession()->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false);
handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0);
uint32 absorb = dmgInfo.GetAbsorb();
uint32 resist = dmgInfo.GetResist();
attacker->DealDamageMods(target, damage, &absorb);
attacker->DealDamage(target, damage, nullptr, DIRECT_DAMAGE, schoolmask, nullptr, false);
attacker->SendAttackStateUpdate(HITINFO_AFFECTS_VICTIM, target, 0, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0);
return true;
}
@@ -2355,10 +2356,22 @@ public:
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint32 spellid = handler->extractSpellIdFromLink((char*)args);
if (!spellid || !sSpellMgr->GetSpellInfo(spellid))
if (!spellid)
return false;
handler->GetSession()->GetPlayer()->SpellNonMeleeDamageLog(target, spellid, damage);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
if (!spellInfo)
return false;
Player* attacker = handler->GetSession()->GetPlayer();
SpellNonMeleeDamage dmgInfo(attacker, target, spellid, spellInfo->GetSchoolMask());
damage = attacker->SpellDamageBonusDone(target, spellInfo, damage, SPELL_DIRECT_DAMAGE);
damage = target->SpellDamageBonusTaken(attacker, spellInfo, damage, SPELL_DIRECT_DAMAGE);
attacker->CalculateSpellDamageTaken(&dmgInfo, damage, spellInfo);
attacker->DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb);
attacker->SendSpellNonMeleeDamageLog(&dmgInfo);
attacker->DealSpellDamage(&dmgInfo, true);
return true;
}
-10
View File
@@ -142,7 +142,6 @@ public:
{ "spell_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesSpellCommand, "" },
{ "spell_linked_spell", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LINKED_SPELL, true, &HandleReloadSpellLinkedSpellCommand, "" },
{ "spell_pet_auras", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PET_AURAS, true, &HandleReloadSpellPetAurasCommand, "" },
// { "spell_proc_event", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC_EVENT, true, &HandleReloadSpellProcEventCommand, "" },
{ "spell_proc", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC, true, &HandleReloadSpellProcsCommand, "" },
{ "spell_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_SCRIPTS, true, &HandleReloadSpellScriptsCommand, "" },
{ "spell_target_position", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_TARGET_POSITION, true, &HandleReloadSpellTargetPositionCommand, "" },
@@ -274,7 +273,6 @@ public:
HandleReloadSpellGroupsCommand(handler, "a");
HandleReloadSpellLearnSpellCommand(handler, "a");
HandleReloadSpellLinkedSpellCommand(handler, "a");
HandleReloadSpellProcEventCommand(handler, "a");
HandleReloadSpellProcsCommand(handler, "a");
HandleReloadSpellBonusesCommand(handler, "a");
HandleReloadSpellTargetPositionCommand(handler, "a");
@@ -809,14 +807,6 @@ public:
return true;
}
static bool HandleReloadSpellProcEventCommand(ChatHandler* handler, const char* /*args*/)
{
TC_LOG_INFO("misc", "Re-Loading Spell Proc Event conditions...");
sSpellMgr->LoadSpellProcEvents();
handler->SendGlobalGMSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded.");
return true;
}
static bool HandleReloadSpellProcsCommand(ChatHandler* handler, const char* /*args*/)
{
TC_LOG_INFO("misc", "Re-Loading Spell Proc conditions and data...");
@@ -202,7 +202,7 @@ public:
{
if (Group* group = players.begin()->GetSource()->GetGroup())
if (group->isLFGGroup())
sLFGMgr->FinishDungeon(group->GetGUID(), 287);
sLFGMgr->FinishDungeon(group->GetGUID(), 287, me->GetMap());
}
}
@@ -576,7 +576,7 @@ public:
{
if (Group* group = players.begin()->GetSource()->GetGroup())
if (group->isLFGGroup())
sLFGMgr->FinishDungeon(group->GetGUID(), 285);
sLFGMgr->FinishDungeon(group->GetGUID(), 285, me->GetMap());
}
}
@@ -178,7 +178,7 @@ class boss_apothecary_hummel : public CreatureScript
{
if (Group* group = players.begin()->GetSource()->GetGroup())
if (group->isLFGGroup())
sLFGMgr->FinishDungeon(group->GetGUID(), 288);
sLFGMgr->FinishDungeon(group->GetGUID(), 288, me->GetMap());
}
}
@@ -17,17 +17,19 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "hyjal.h"
#include "hyjal_trash.h"
enum Spells
{
SPELL_CARRION_SWARM = 31306,
SPELL_SLEEP = 31298,
SPELL_VAMPIRIC_AURA = 38196,
SPELL_INFERNO = 31299,
SPELL_IMMOLATION = 31303,
SPELL_INFERNO_EFFECT = 31302,
SPELL_CARRION_SWARM = 31306,
SPELL_SLEEP = 31298,
SPELL_VAMPIRIC_AURA = 38196,
SPELL_VAMPIRIC_AURA_HEAL = 31285,
SPELL_INFERNO = 31299,
SPELL_IMMOLATION = 31303,
SPELL_INFERNO_EFFECT = 31302
};
enum Texts
@@ -261,8 +263,48 @@ public:
};
class spell_anetheron_vampiric_aura : public SpellScriptLoader
{
public:
spell_anetheron_vampiric_aura() : SpellScriptLoader("spell_anetheron_vampiric_aura") { }
class spell_anetheron_vampiric_aura_AuraScript : public AuraScript
{
PrepareAuraScript(spell_anetheron_vampiric_aura_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_VAMPIRIC_AURA_HEAL))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
return;
int32 bp = damageInfo->GetDamage() * 3;
eventInfo.GetActor()->CastCustomSpell(SPELL_VAMPIRIC_AURA_HEAL, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetActor(), true, nullptr, aurEff);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(spell_anetheron_vampiric_aura_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_anetheron_vampiric_aura_AuraScript();
}
};
void AddSC_boss_anetheron()
{
new boss_anetheron();
new npc_towering_infernal();
new spell_anetheron_vampiric_aura();
}
@@ -406,7 +406,11 @@ class spell_devourer_of_souls_mirrored_soul_proc : public SpellScriptLoader
void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 damage = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), 45));
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
return;
int32 damage = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), 45);
GetTarget()->CastCustomSpell(SPELL_MIRRORED_SOUL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, GetCaster(), true);
}
@@ -1305,6 +1305,26 @@ class spell_taldaram_ball_of_inferno_flame : public SpellScriptLoader
{
return new spell_taldaram_ball_of_inferno_flame_SpellScript();
}
class spell_taldaram_ball_of_inferno_flame_AuraScript : public AuraScript
{
PrepareAuraScript(spell_taldaram_ball_of_inferno_flame_AuraScript);
void HandleStackDrop(ProcEventInfo& /*eventInfo*/)
{
ModStackAmount(-1);
}
void Register() override
{
OnProc += AuraProcFn(spell_taldaram_ball_of_inferno_flame_AuraScript::HandleStackDrop);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_taldaram_ball_of_inferno_flame_AuraScript();
}
};
// 72080 - Kinetic Bomb
@@ -730,8 +730,12 @@ class spell_blood_queen_essence_of_the_blood_queen : public SpellScriptLoader
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 heal = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
GetTarget()->CastCustomSpell(SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), TRIGGERED_FULL_MASK, NULL, aurEff);
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
return;
int32 heal = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
GetTarget()->CastCustomSpell(SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), TRIGGERED_FULL_MASK, nullptr, aurEff);
}
void Register() override
@@ -430,7 +430,7 @@ class boss_deathbringer_saurfang : public CreatureScript
case 72445:
case 72446:
if (me->GetPower(POWER_ENERGY) != me->GetMaxPower(POWER_ENERGY))
target->CastCustomSpell(SPELL_BLOOD_LINK_DUMMY, SPELLVALUE_BASE_POINT0, 1, me, true);
target->CastCustomSpell(SPELL_BLOOD_LINK_DUMMY, SPELLVALUE_BASE_POINT0, 1, (Unit*)nullptr, true);
break;
default:
break;
@@ -1134,8 +1134,7 @@ class spell_deathbringer_rune_of_blood : public SpellScriptLoader
void HandleScript(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex); // make this the default handler
if (GetCaster()->GetPower(POWER_ENERGY) != GetCaster()->GetMaxPower(POWER_ENERGY))
GetHitUnit()->CastCustomSpell(SPELL_BLOOD_LINK_DUMMY, SPELLVALUE_BASE_POINT0, 1, GetCaster(), true);
GetHitUnit()->CastCustomSpell(SPELL_BLOOD_LINK_DUMMY, SPELLVALUE_BASE_POINT0, 1, (Unit*)nullptr, true);
}
void Register() override
@@ -1150,6 +1149,41 @@ class spell_deathbringer_rune_of_blood : public SpellScriptLoader
}
};
// 72176 - Blood Beast's Blood Link
class spell_deathbringer_blood_beast_blood_link : public SpellScriptLoader
{
public:
spell_deathbringer_blood_beast_blood_link() : SpellScriptLoader("spell_deathbringer_blood_beast_blood_link") { }
class spell_deathbringer_blood_beast_blood_link_AuraScript : public AuraScript
{
PrepareAuraScript(spell_deathbringer_blood_beast_blood_link_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_BLOOD_LINK_DUMMY))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
eventInfo.GetProcTarget()->CastCustomSpell(SPELL_BLOOD_LINK_DUMMY, SPELLVALUE_BASE_POINT0, 3, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(spell_deathbringer_blood_beast_blood_link_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_deathbringer_blood_beast_blood_link_AuraScript();
}
};
class spell_deathbringer_blood_nova : public SpellScriptLoader
{
public:
@@ -1169,8 +1203,7 @@ class spell_deathbringer_blood_nova : public SpellScriptLoader
void HandleScript(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex); // make this the default handler
if (GetCaster()->GetPower(POWER_ENERGY) != GetCaster()->GetMaxPower(POWER_ENERGY))
GetHitUnit()->CastCustomSpell(SPELL_BLOOD_LINK_DUMMY, SPELLVALUE_BASE_POINT0, 2, GetCaster(), true);
GetHitUnit()->CastCustomSpell(SPELL_BLOOD_LINK_DUMMY, SPELLVALUE_BASE_POINT0, 2, (Unit*)nullptr, true);
}
void Register() override
@@ -1348,6 +1381,7 @@ void AddSC_boss_deathbringer_saurfang()
new spell_deathbringer_blood_link_aura();
new spell_deathbringer_blood_power();
new spell_deathbringer_rune_of_blood();
new spell_deathbringer_blood_beast_blood_link();
new spell_deathbringer_blood_nova();
new spell_deathbringer_blood_nova_targeting();
new spell_deathbringer_boiling_blood();
@@ -2459,6 +2459,33 @@ class spell_igb_teleport_players_on_victory : public SpellScriptLoader
}
};
// 71201 - Battle Experience - proc should never happen, handled in script
class spell_igb_battle_experience_check : public SpellScriptLoader
{
public:
spell_igb_battle_experience_check() : SpellScriptLoader("spell_igb_battle_experience_check") { }
class spell_igb_battle_experience_check_AuraScript : public AuraScript
{
PrepareAuraScript(spell_igb_battle_experience_check_AuraScript);
bool CheckProc(ProcEventInfo& /*eventInfo*/)
{
return false;
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_igb_battle_experience_check_AuraScript::CheckProc);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_igb_battle_experience_check_AuraScript();
}
};
class achievement_im_on_a_boat : public AchievementCriteriaScript
{
public:
@@ -2498,5 +2525,6 @@ void AddSC_boss_icecrown_gunship_battle()
new spell_igb_gunship_fall_teleport();
new spell_igb_check_for_players();
new spell_igb_teleport_players_on_victory();
new spell_igb_battle_experience_check();
new achievement_im_on_a_boat();
}
@@ -846,9 +846,23 @@ class spell_putricide_gaseous_bloat : public SpellScriptLoader
}
}
void HandleProc(ProcEventInfo& eventInfo)
{
uint32 stack = GetStackAmount();
Unit* caster = eventInfo.GetActor();
int32 const mod = caster->GetMap()->Is25ManRaid() ? 1500 : 1250;
int32 dmg = 0;
for (uint8 i = 1; i <= stack; ++i)
dmg += mod * i;
caster->CastCustomSpell(SPELL_EXPUNGED_GAS, SPELLVALUE_BASE_POINT0, dmg);
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_putricide_gaseous_bloat_AuraScript::HandleExtraEffect, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE);
OnProc += AuraProcFn(spell_putricide_gaseous_bloat_AuraScript::HandleProc);
}
};
@@ -1086,6 +1100,45 @@ class spell_putricide_ooze_eruption_searcher : public SpellScriptLoader
}
};
// 71770 - Ooze Spell Tank Protection
class spell_putricide_ooze_tank_protection : public SpellScriptLoader
{
public:
spell_putricide_ooze_tank_protection() : SpellScriptLoader("spell_putricide_ooze_tank_protection") { }
class spell_putricide_ooze_tank_protection_AuraScript : public AuraScript
{
PrepareAuraScript(spell_putricide_ooze_tank_protection_AuraScript);
bool Validate(SpellInfo const* spellInfo) override
{
if (!sSpellMgr->GetSpellInfo(spellInfo->Effects[EFFECT_0].TriggerSpell) ||
!sSpellMgr->GetSpellInfo(spellInfo->Effects[EFFECT_1].TriggerSpell))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* actionTarget = eventInfo.GetActionTarget();
actionTarget->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, true, nullptr, aurEff);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(spell_putricide_ooze_tank_protection_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
OnEffectProc += AuraEffectProcFn(spell_putricide_ooze_tank_protection_AuraScript::HandleProc, EFFECT_1, SPELL_AURA_PROC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_putricide_ooze_tank_protection_AuraScript();
}
};
class spell_putricide_choking_gas_bomb : public SpellScriptLoader
{
public:
@@ -1610,6 +1663,7 @@ void AddSC_boss_professor_putricide()
new spell_putricide_slime_puddle_aura();
new spell_putricide_unstable_experiment();
new spell_putricide_ooze_eruption_searcher();
new spell_putricide_ooze_tank_protection();
new spell_putricide_choking_gas_bomb();
new spell_putricide_unbound_plague();
new spell_putricide_eat_ooze();
@@ -1108,6 +1108,12 @@ class spell_sindragosa_s_fury : public SpellScriptLoader
if (!GetHitUnit()->IsAlive() || !_targetCount)
return;
if (GetHitUnit()->IsImmunedToDamage(GetSpellInfo()))
{
GetCaster()->SendSpellDamageImmune(GetHitUnit(), GetSpellInfo()->Id);
return;
}
float resistance = float(GetHitUnit()->GetResistance(SpellSchoolMask(GetSpellInfo()->SchoolMask)));
uint32 minResistFactor = uint32((resistance / (resistance + 510.0f)) * 10.0f) * 2;
uint32 randomResist = urand(0, (9 - minResistFactor) * 100) / 100 + minResistFactor;
@@ -3010,8 +3010,12 @@ class spell_the_lich_king_dark_hunger : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 heal = int32(eventInfo.GetDamageInfo()->GetDamage() / 2);
GetTarget()->CastCustomSpell(SPELL_DARK_HUNGER_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), true, NULL, aurEff);
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
return;
int32 heal = static_cast<int32>(damageInfo->GetDamage()) / 2;
GetTarget()->CastCustomSpell(SPELL_DARK_HUNGER_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -1192,7 +1192,8 @@ class npc_crok_scourgebane : public CreatureScript
}
else
{
me->DealHeal(me, me->CountPctFromMaxHealth(5));
// looks totally hacky to me
me->ModifyHealth(me->CountPctFromMaxHealth(5));
_events.ScheduleEvent(EVENT_HEALTH_CHECK, 1000);
}
break;
@@ -2031,11 +2031,7 @@ class spell_scion_of_eternity_arcane_barrage : public SpellScriptLoader
void TriggerDamageSpellFromPlayer()
{
if (Player* hitTarget = GetHitPlayer())
{
// There is some proc in this spell I have absolutely no idea of use, but just in case...
TriggerCastFlags triggerFlags = TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_DISALLOW_PROC_EVENTS);
hitTarget->CastSpell(hitTarget, SPELL_ARCANE_BARRAGE_DAMAGE, triggerFlags, NULL, NULL, GetCaster()->GetGUID());
}
hitTarget->CastSpell(hitTarget, SPELL_ARCANE_BARRAGE_DAMAGE, true, nullptr, nullptr, GetCaster()->GetGUID());
}
void Register() override
@@ -604,8 +604,11 @@ class spell_oculus_temporal_rift : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 amount = aurEff->GetAmount() + eventInfo.GetDamageInfo()->GetDamage();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
return;
int32 amount = aurEff->GetAmount() + damageInfo->GetDamage();
if (amount >= 15000)
{
if (Unit* caster = GetCaster())
@@ -1063,6 +1063,51 @@ class spell_xt002_submerged : public SpellScriptLoader
}
};
class spell_xt002_321_boombot_aura : public SpellScriptLoader
{
public:
spell_xt002_321_boombot_aura() : SpellScriptLoader("spell_xt002_321_boombot_aura") { }
class spell_xt002_321_boombot_aura_AuraScript : public AuraScript
{
PrepareAuraScript(spell_xt002_321_boombot_aura_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_ACHIEVEMENT_CREDIT_NERF_SCRAPBOTS))
return false;
return true;
}
bool CheckProc(ProcEventInfo& eventInfo)
{
if (eventInfo.GetActionTarget()->GetEntry() != NPC_XS013_SCRAPBOT)
return false;
return true;
}
void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
{
InstanceScript* instance = eventInfo.GetActor()->GetInstanceScript();
if (!instance)
return;
instance->DoCastSpellOnPlayers(SPELL_ACHIEVEMENT_CREDIT_NERF_SCRAPBOTS);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_xt002_321_boombot_aura_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_xt002_321_boombot_aura_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_xt002_321_boombot_aura_AuraScript();
}
};
class achievement_nerf_engineering : public AchievementCriteriaScript
{
public:
@@ -1122,6 +1167,7 @@ void AddSC_boss_xt002()
new spell_xt002_heart_overload_periodic();
new spell_xt002_tympanic_tantrum();
new spell_xt002_submerged();
new spell_xt002_321_boombot_aura();
new achievement_nerf_engineering();
new achievement_heartbreaker();
@@ -2750,8 +2750,13 @@ class spell_yogg_saron_grim_reprisal : public SpellScriptLoader // 63305
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
int32 damage = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), 60);
GetTarget()->CastCustomSpell(SPELL_GRIM_REPRISAL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, eventInfo.GetDamageInfo()->GetAttacker(), true, NULL, aurEff);
PreventDefaultAction();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
return;
int32 damage = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), 60);
GetTarget()->CastCustomSpell(SPELL_GRIM_REPRISAL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, damageInfo->GetAttacker(), true, nullptr, aurEff);
}
void Register() override
@@ -456,7 +456,11 @@ class spell_ingvar_woe_strike : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetHealInfo()->GetHeal() != 0;
HealInfo* healInfo = eventInfo.GetHealInfo();
if (!healInfo || !healInfo->GetHeal())
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
@@ -196,6 +196,57 @@ class spell_fixate : public SpellScriptLoader
}
};
enum SecondWind
{
SPELL_SECOND_WIND_TRIGGER = 42771
};
// 42770 - Second Wind
class spell_uk_second_wind : public SpellScriptLoader
{
public:
spell_uk_second_wind() : SpellScriptLoader("spell_uk_second_wind") { }
class spell_uk_second_wind_AuraScript : public AuraScript
{
PrepareAuraScript(spell_uk_second_wind_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_SECOND_WIND_TRIGGER))
return false;
return true;
}
bool CheckProc(ProcEventInfo& eventInfo)
{
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
if (!spellInfo)
return false;
return (spellInfo->GetAllEffectsMechanicMask() & ((1 << MECHANIC_ROOT) | (1 << MECHANIC_STUN))) != 0;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActionTarget();
caster->CastSpell(caster, SPELL_SECOND_WIND_TRIGGER, true, nullptr, aurEff);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_uk_second_wind_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_uk_second_wind_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_uk_second_wind_AuraScript();
}
};
enum EnslavedProtoDrake
{
TYPE_PROTODRAKE_AT = 28,
@@ -300,56 +351,11 @@ class npc_enslaved_proto_drake : public CreatureScript
}
};
class spell_uk_second_wind_proc : public SpellScriptLoader
{
public:
spell_uk_second_wind_proc() : SpellScriptLoader("spell_uk_second_wind_proc") { }
class spell_uk_second_wind_proc_AuraScript : public AuraScript
{
PrepareAuraScript(spell_uk_second_wind_proc_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_UK_SECOUND_WIND_TRIGGER))
return false;
return true;
}
bool CheckProc(ProcEventInfo& eventInfo)
{
if (eventInfo.GetProcTarget() == GetTarget())
return false;
if (!(eventInfo.GetDamageInfo() || eventInfo.GetDamageInfo()->GetSpellInfo()->GetAllEffectsMechanicMask() & ((1 << MECHANIC_ROOT) | (1 << MECHANIC_STUN))))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
PreventDefaultAction();
GetTarget()->CastCustomSpell(SPELL_UK_SECOUND_WIND_TRIGGER, SPELLVALUE_BASE_POINT0, 5, GetTarget(), true, NULL, aurEff);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_uk_second_wind_proc_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_uk_second_wind_proc_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_uk_second_wind_proc_AuraScript();
}
};
void AddSC_utgarde_keep()
{
new npc_dragonflayer_forge_master();
new npc_enslaved_proto_drake();
new spell_ticking_time_bomb();
new spell_fixate();
new spell_uk_second_wind_proc();
new spell_uk_second_wind();
}
@@ -0,0 +1,69 @@
/*
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.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/>.
*/
#include "ScriptMgr.h"
#include "SpellMgr.h"
#include "SpellScript.h"
#include "SpellAuraEffects.h"
enum Spells
{
SPELL_MARK_OF_MALICE_TRIGGERED = 33494
};
class spell_mark_of_malice : public SpellScriptLoader
{
public:
spell_mark_of_malice() : SpellScriptLoader("spell_mark_of_malice") { }
class spell_mark_of_malice_AuraScript : public AuraScript
{
PrepareAuraScript(spell_mark_of_malice_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_MARK_OF_MALICE_TRIGGERED))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
PreventDefaultAction();
// just drop charges
if (aurEff->GetBase()->GetCharges() > 1)
return;
GetTarget()->CastSpell(GetTarget(), SPELL_MARK_OF_MALICE_TRIGGERED, true, nullptr, aurEff);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(spell_mark_of_malice_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_mark_of_malice_AuraScript();
}
};
void AddSC_shadow_labyrinth()
{
new spell_mark_of_malice();
}
@@ -201,7 +201,7 @@ public:
{
if (Group* group = players.begin()->GetSource()->GetGroup())
if (group->isLFGGroup())
sLFGMgr->FinishDungeon(group->GetGUID(), 286);
sLFGMgr->FinishDungeon(group->GetGUID(), 286, me->GetMap());
}
_JustDied();
@@ -231,11 +231,7 @@ class boss_kelidan_the_breaker : public CreatureScript
Talk(SAY_NOVA);
if (SpellInfo const* nova = sSpellMgr->GetSpellInfo(SPELL_BURNING_NOVA))
{
if (Aura* aura = Aura::TryRefreshStackOrCreate(nova, MAX_EFFECT_MASK, me, me))
aura->ApplyForTargets();
}
me->AddAura(SPELL_BURNING_NOVA, me);
if (IsHeroic())
DoTeleportAll(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
@@ -34,16 +34,17 @@ enum Texts
enum Spells
{
SPELL_SHADOW_VOLLEY = 32963,
SPELL_CLEAVE = 31779,
SPELL_THUNDERCLAP = 36706,
SPELL_VOID_BOLT = 39329,
SPELL_MARK_OF_KAZZAK = 32960,
SPELL_MARK_OF_KAZZAK_DAMAGE = 32961,
SPELL_ENRAGE = 32964,
SPELL_CAPTURE_SOUL = 32966,
SPELL_TWISTED_REFLECTION = 21063,
SPELL_BERSERK = 32965,
SPELL_SHADOW_VOLLEY = 32963,
SPELL_CLEAVE = 31779,
SPELL_THUNDERCLAP = 36706,
SPELL_VOID_BOLT = 39329,
SPELL_MARK_OF_KAZZAK = 32960,
SPELL_MARK_OF_KAZZAK_DAMAGE = 32961,
SPELL_ENRAGE = 32964,
SPELL_CAPTURE_SOUL = 32966,
SPELL_TWISTED_REFLECTION = 21063,
SPELL_TWISTED_REFLECTION_HEAL = 21064,
SPELL_BERSERK = 32965,
};
enum Events
@@ -222,8 +223,47 @@ class spell_mark_of_kazzak : public SpellScriptLoader
}
};
class spell_twisted_reflection : public SpellScriptLoader
{
public:
spell_twisted_reflection() : SpellScriptLoader("spell_twisted_reflection") { }
class spell_twisted_reflection_AuraScript : public AuraScript
{
PrepareAuraScript(spell_twisted_reflection_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_TWISTED_REFLECTION_HEAL))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
return;
eventInfo.GetActionTarget()->CastSpell(eventInfo.GetActor(), SPELL_TWISTED_REFLECTION_HEAL, true, nullptr, aurEff);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(spell_twisted_reflection_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_twisted_reflection_AuraScript();
}
};
void AddSC_boss_doomlordkazzak()
{
new boss_doomlord_kazzak();
new spell_mark_of_kazzak();
new spell_twisted_reflection();
}
@@ -37,6 +37,7 @@ void AddSC_boss_ambassador_hellmaw();
void AddSC_boss_blackheart_the_inciter();
void AddSC_boss_grandmaster_vorpil();
void AddSC_boss_murmur();
void AddSC_shadow_labyrinth();
void AddSC_instance_shadow_labyrinth();
// Black Temple
@@ -159,6 +160,7 @@ void AddOutlandScripts()
AddSC_boss_blackheart_the_inciter();
AddSC_boss_grandmaster_vorpil();
AddSC_boss_murmur();
AddSC_shadow_labyrinth();
AddSC_instance_shadow_labyrinth();
// Black Temple
+146
View File
@@ -22,6 +22,8 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "SpellAuraEffects.h"
enum HunterSpells
{
@@ -35,6 +37,16 @@ enum HunterCreatures
NPC_HUNTER_VIPER = 19921
};
enum PetSpellsMisc
{
SPELL_PET_SILVERBACK_RANK_1 = 62800,
SPELL_PET_SILVERBACK_RANK_2 = 62801,
PET_ICON_ID_GROWL = 201,
PET_ICON_ID_CLAW = 262,
PET_ICON_ID_BITE = 1680,
PET_ICON_ID_SMACK = 473
};
class npc_pet_hunter_snake_trap : public CreatureScript
{
public:
@@ -139,7 +151,141 @@ class npc_pet_hunter_snake_trap : public CreatureScript
}
};
// -53178 - Guard Dog
class spell_pet_guard_dog : public SpellScriptLoader
{
public:
spell_pet_guard_dog() : SpellScriptLoader("spell_pet_guard_dog") { }
class spell_pet_guard_dog_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pet_guard_dog_AuraScript);
bool CheckProc(ProcEventInfo& eventInfo)
{
// Growl shares family flags with other spells
// filter by spellIcon instead
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
if (!spellInfo || spellInfo->SpellIconID != PET_ICON_ID_GROWL)
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
float addThreat = CalculatePct(ASSERT_NOTNULL(eventInfo.GetSpellInfo())->Effects[EFFECT_0].CalcValue(caster), aurEff->GetAmount());
eventInfo.GetProcTarget()->AddThreat(caster, addThreat);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_pet_guard_dog_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_pet_guard_dog_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_pet_guard_dog_AuraScript();
}
};
// -62764 - Silverback
class spell_pet_silverback : public SpellScriptLoader
{
public:
spell_pet_silverback() : SpellScriptLoader("spell_pet_silverback") { }
class spell_pet_silverback_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pet_silverback_AuraScript);
bool CheckProc(ProcEventInfo& eventInfo)
{
// Growl shares family flags with other spells
// filter by spellIcon instead
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
if (!spellInfo || spellInfo->SpellIconID != PET_ICON_ID_GROWL)
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
static uint32 const triggerSpell[2] = { SPELL_PET_SILVERBACK_RANK_1, SPELL_PET_SILVERBACK_RANK_2 };
PreventDefaultAction();
uint32 spellId = triggerSpell[GetSpellInfo()->GetRank() - 1];
eventInfo.GetActor()->CastSpell((Unit*)nullptr, spellId, true, nullptr, aurEff);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_pet_silverback_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_pet_silverback_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_pet_silverback_AuraScript();
}
};
// -61680 - Culling the Herd
class spell_pet_culling_the_herd : public SpellScriptLoader
{
public:
spell_pet_culling_the_herd() : SpellScriptLoader("spell_pet_culling_the_herd") { }
class spell_pet_culling_the_herd_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pet_culling_the_herd_AuraScript);
bool CheckProc(ProcEventInfo& eventInfo)
{
// Claw, Bite and Smack share FamilyFlags with other spells
// filter by spellIcon instead
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
if (!spellInfo)
return false;
switch (spellInfo->SpellIconID)
{
case PET_ICON_ID_CLAW:
case PET_ICON_ID_BITE:
case PET_ICON_ID_SMACK:
break;
default:
return false;
}
return true;
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_pet_culling_the_herd_AuraScript::CheckProc);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_pet_culling_the_herd_AuraScript();
}
};
void AddSC_hunter_pet_scripts()
{
new npc_pet_hunter_snake_trap();
new spell_pet_guard_dog();
new spell_pet_silverback();
new spell_pet_culling_the_herd();
}
+4 -6
View File
@@ -28,7 +28,7 @@
enum PriestSpells
{
SPELL_PRIEST_GLYPH_OF_SHADOWFIEND = 58228,
SPELL_PRIEST_GLYPH_OF_SHADOWFIEND_MANA = 58227,
SPELL_PRIEST_SHADOWFIEND_DEATH = 57989,
SPELL_PRIEST_LIGHTWELL_CHARGES = 59907
};
@@ -70,12 +70,10 @@ class npc_pet_pri_shadowfiend : public CreatureScript
{
npc_pet_pri_shadowfiendAI(Creature* creature) : PetAI(creature) { }
void JustDied(Unit* /*killer*/) override
void IsSummonedBy(Unit* summoner) override
{
if (me->IsSummon())
if (Unit* owner = me->ToTempSummon()->GetSummoner())
if (owner->HasAura(SPELL_PRIEST_GLYPH_OF_SHADOWFIEND))
owner->CastSpell(owner, SPELL_PRIEST_GLYPH_OF_SHADOWFIEND_MANA, true);
if (summoner->HasAura(SPELL_PRIEST_GLYPH_OF_SHADOWFIEND))
DoCastAOE(SPELL_PRIEST_SHADOWFIEND_DEATH);
}
};
+269 -49
View File
@@ -114,7 +114,8 @@ class spell_gen_adaptive_warding : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
if (eventInfo.GetDamageInfo()->GetSpellInfo()) // eventInfo.GetSpellInfo()
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetSpellInfo())
return false;
// find Mage Armor
@@ -157,7 +158,7 @@ class spell_gen_adaptive_warding : public SpellScriptLoader
default:
return;
}
GetTarget()->CastSpell(GetTarget(), spellId, true, NULL, aurEff);
GetTarget()->CastSpell(GetTarget(), spellId, true, nullptr, aurEff);
}
void Register() override
@@ -492,6 +493,109 @@ class spell_gen_bandage : public SpellScriptLoader
}
};
// Blood Reserve - 64568
enum BloodReserve
{
SPELL_GEN_BLOOD_RESERVE_AURA = 64568,
SPELL_GEN_BLOOD_RESERVE_HEAL = 64569
};
class spell_gen_blood_reserve : public SpellScriptLoader
{
public:
spell_gen_blood_reserve() : SpellScriptLoader("spell_gen_blood_reserve") { }
class spell_gen_blood_reserve_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_blood_reserve_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_GEN_BLOOD_RESERVE_HEAL))
return false;
return true;
}
bool CheckProc(ProcEventInfo& eventInfo)
{
if (DamageInfo* dmgInfo = eventInfo.GetDamageInfo())
if (Unit* caster = eventInfo.GetActionTarget())
if (caster->HealthBelowPctDamaged(35, dmgInfo->GetDamage()))
return true;
return false;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActionTarget();
caster->CastCustomSpell(SPELL_GEN_BLOOD_RESERVE_HEAL, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), caster, TRIGGERED_FULL_MASK, nullptr, aurEff);
caster->RemoveAura(SPELL_GEN_BLOOD_RESERVE_AURA);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_gen_blood_reserve_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_gen_blood_reserve_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_blood_reserve_AuraScript();
}
};
// Blade Warding - 64440
enum BladeWarding
{
SPELL_GEN_BLADE_WARDING_TRIGGERED = 64442
};
class spell_gen_blade_warding : public SpellScriptLoader
{
public:
spell_gen_blade_warding() : SpellScriptLoader("spell_gen_blade_warding") { }
class spell_gen_blade_warding_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_blade_warding_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_GEN_BLADE_WARDING_TRIGGERED });
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActionTarget();
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_GEN_BLADE_WARDING_TRIGGERED);
uint8 stacks = GetStackAmount();
int32 bp = 0;
for (uint8 i = 0; i < stacks; ++i)
bp += spellInfo->Effects[EFFECT_0].CalcValue(caster);
caster->CastCustomSpell(SPELL_GEN_BLADE_WARDING_TRIGGERED, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetActor(), TRIGGERED_FULL_MASK, nullptr, aurEff);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(spell_gen_blade_warding_AuraScript::HandleProc, EFFECT_1, SPELL_AURA_PROC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_blade_warding_AuraScript();
}
};
enum Bonked
{
SPELL_BONKED = 62991,
@@ -1419,51 +1523,6 @@ class spell_gen_ds_flush_knockback : public SpellScriptLoader
}
};
enum DummyTrigger
{
SPELL_PERSISTANT_SHIELD_TRIGGERED = 26470,
SPELL_PERSISTANT_SHIELD = 26467
};
class spell_gen_dummy_trigger : public SpellScriptLoader
{
public:
spell_gen_dummy_trigger() : SpellScriptLoader("spell_gen_dummy_trigger") { }
class spell_gen_dummy_trigger_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_dummy_trigger_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_PERSISTANT_SHIELD_TRIGGERED) ||
!sSpellMgr->GetSpellInfo(SPELL_PERSISTANT_SHIELD))
return false;
return true;
}
void HandleDummy(SpellEffIndex /* effIndex */)
{
int32 damage = GetEffectValue();
Unit* caster = GetCaster();
if (Unit* target = GetHitUnit())
if (SpellInfo const* triggeredByAuraSpell = GetTriggeringSpell())
if (triggeredByAuraSpell->Id == SPELL_PERSISTANT_SHIELD_TRIGGERED)
caster->CastCustomSpell(target, SPELL_PERSISTANT_SHIELD_TRIGGERED, &damage, NULL, NULL, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gen_dummy_trigger_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_gen_dummy_trigger_SpellScript();
}
};
class spell_gen_dungeon_credit : public SpellScriptLoader
{
public:
@@ -2194,7 +2253,8 @@ class spell_gen_obsidian_armor : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
if (eventInfo.GetDamageInfo()->GetSpellInfo()) // eventInfo.GetSpellInfo()
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetSpellInfo())
return false;
if (GetFirstSchoolInMask(eventInfo.GetSchoolMask()) == SPELL_SCHOOL_NORMAL)
@@ -2341,6 +2401,109 @@ class spell_gen_orc_disguise : public SpellScriptLoader
}
};
enum ParalyticPoison
{
SPELL_PARALYSIS = 35202
};
// 35201 - Paralytic Poison
class spell_gen_paralytic_poison : public SpellScriptLoader
{
public:
spell_gen_paralytic_poison() : SpellScriptLoader("spell_gen_paralytic_poison") { }
class spell_gen_paralytic_poison_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_paralytic_poison_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_PARALYSIS))
return false;
return true;
}
void HandleStun(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
return;
GetTarget()->CastSpell((Unit*)nullptr, SPELL_PARALYSIS, true, nullptr, aurEff);
}
void Register() override
{
AfterEffectRemove += AuraEffectRemoveFn(spell_gen_paralytic_poison_AuraScript::HandleStun, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_paralytic_poison_AuraScript();
}
};
class spell_gen_proc_below_pct_damaged : public SpellScriptLoader
{
public:
spell_gen_proc_below_pct_damaged(const char* name) : SpellScriptLoader(name) { }
class spell_gen_proc_below_pct_damaged_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_proc_below_pct_damaged_AuraScript);
bool CheckProc(ProcEventInfo& eventInfo)
{
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
return false;
int32 pct = GetSpellInfo()->Effects[EFFECT_0].CalcValue();
if (eventInfo.GetActionTarget()->HealthBelowPctDamaged(pct, damageInfo->GetDamage()))
return true;
return false;
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_gen_proc_below_pct_damaged_AuraScript::CheckProc);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_proc_below_pct_damaged_AuraScript();
}
};
class spell_gen_proc_charge_drop_only : public SpellScriptLoader
{
public:
spell_gen_proc_charge_drop_only() : SpellScriptLoader("spell_gen_proc_charge_drop_only") { }
class spell_gen_proc_charge_drop_only_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_proc_charge_drop_only_AuraScript);
void HandleChargeDrop(ProcEventInfo& /*eventInfo*/)
{
PreventDefaultAction();
}
void Register() override
{
OnProc += AuraProcFn(spell_gen_proc_charge_drop_only_AuraScript::HandleChargeDrop);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_proc_charge_drop_only_AuraScript();
}
};
enum ParachuteSpells
{
SPELL_PARACHUTE = 45472,
@@ -3279,6 +3442,53 @@ class spell_gen_upper_deck_create_foam_sword : public SpellScriptLoader
}
};
enum VampiricTouch
{
SPELL_VAMPIRIC_TOUCH_HEAL = 52724
};
// 52723 - Vampiric Touch
// 60501 - Vampiric Touch
class spell_gen_vampiric_touch : public SpellScriptLoader
{
public:
spell_gen_vampiric_touch() : SpellScriptLoader("spell_gen_vampiric_touch") { }
class spell_gen_vampiric_touch_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_vampiric_touch_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_VAMPIRIC_TOUCH_HEAL))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
return;
Unit* caster = eventInfo.GetActor();
int32 bp = damageInfo->GetDamage() / 2;
caster->CastCustomSpell(SPELL_VAMPIRIC_TOUCH_HEAL, SPELLVALUE_BASE_POINT0, bp, caster, true, nullptr, aurEff);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(spell_gen_vampiric_touch_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_vampiric_touch_AuraScript();
}
};
enum VehicleScaling
{
SPELL_GEAR_SCALING = 66668
@@ -4047,6 +4257,8 @@ void AddSC_generic_spell_scripts()
new spell_gen_aura_service_uniform();
new spell_gen_av_drekthar_presence();
new spell_gen_bandage();
new spell_gen_blood_reserve();
new spell_gen_blade_warding();
new spell_gen_bonked();
new spell_gen_break_shield("spell_gen_break_shield");
new spell_gen_break_shield("spell_gen_tournament_counterattack");
@@ -4067,7 +4279,6 @@ void AddSC_generic_spell_scripts()
new spell_gen_despawn_self();
new spell_gen_divine_storm_cd_reset();
new spell_gen_ds_flush_knockback();
new spell_gen_dummy_trigger();
new spell_gen_dungeon_credit();
new spell_gen_elune_candle();
new spell_gen_gadgetzan_transporter_backfire();
@@ -4092,6 +4303,14 @@ void AddSC_generic_spell_scripts()
new spell_gen_obsidian_armor();
new spell_gen_oracle_wolvar_reputation();
new spell_gen_orc_disguise();
new spell_gen_paralytic_poison();
new spell_gen_proc_below_pct_damaged("spell_item_soul_harvesters_charm");
new spell_gen_proc_below_pct_damaged("spell_item_commendation_of_kaelthas");
new spell_gen_proc_below_pct_damaged("spell_item_corpse_tongue_coin");
new spell_gen_proc_below_pct_damaged("spell_item_corpse_tongue_coin_heroic");
new spell_gen_proc_below_pct_damaged("spell_item_petrified_twilight_scale");
new spell_gen_proc_below_pct_damaged("spell_item_petrified_twilight_scale_heroic");
new spell_gen_proc_charge_drop_only();
new spell_gen_parachute();
new spell_gen_pet_summoned();
new spell_gen_profession_research();
@@ -4115,6 +4334,7 @@ void AddSC_generic_spell_scripts()
new spell_pvp_trinket_wotf_shared_cd<SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER_WOTF>("spell_wotf_shared_cd");
new spell_gen_turkey_marker();
new spell_gen_upper_deck_create_foam_sword();
new spell_gen_vampiric_touch();
new spell_gen_vehicle_scaling();
new spell_gen_vendor_bark_trigger();
new spell_gen_wg_water();
File diff suppressed because it is too large. Load diff
@@ -748,12 +748,14 @@ class spell_pri_pain_and_suffering_proc : public SpellScriptLoader
Unit* caster = GetCaster();
// Refresh Shadow Word: Pain on target
if (Unit* target = GetHitUnit())
{
if (AuraEffect* aur = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x8000, 0, 0, caster->GetGUID()))
{
aur->SetBonusAmount(caster->SpellDamageBonusDone(target, aur->GetSpellInfo(), 0, DOT));
aur->CalculatePeriodic(caster, false, false);
aur->GetBase()->RefreshDuration();
}
}
}
void Register() override
+3 -1
View File
@@ -544,6 +544,7 @@ class spell_warl_everlasting_affliction : public SpellScriptLoader
{
Unit* caster = GetCaster();
if (Unit* target = GetHitUnit())
{
// Refresh corruption on target
if (AuraEffect* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0x2, 0, 0, caster->GetGUID()))
{
@@ -551,6 +552,7 @@ class spell_warl_everlasting_affliction : public SpellScriptLoader
aurEff->CalculatePeriodic(caster, false, false);
aurEff->GetBase()->RefreshDuration(true);
}
}
}
void Register() override
@@ -781,7 +783,7 @@ class spell_warl_health_funnel : public SpellScriptLoader
uint32 damage = caster->CountPctFromMaxHealth(aurEff->GetBaseAmount());
if (Player* modOwner = caster->GetSpellModOwner())
modOwner->ApplySpellMod(GetId(), SPELLMOD_COST, damage);
modOwner->ApplySpellMod<SPELLMOD_COST>(GetId(), damage);
SpellNonMeleeDamage damageInfo(caster, caster, GetSpellInfo()->Id, GetSpellInfo()->SchoolMask);
damageInfo.damage = damage;