39#include <G3D/g3dmath.h>
112 return static_cast<float>(
M_PI);
114 return static_cast<float>(-
M_PI/2);
116 return static_cast<float>(
M_PI/2);
118 return static_cast<float>(-
M_PI/4);
120 return static_cast<float>(-3*
M_PI/4);
122 return static_cast<float>(3*
M_PI/4);
124 return static_cast<float>(
M_PI/4);
458 return Effect == effectName;
500 double value = bp ? *bp : basePoints;
503 Unit const* casterUnit =
nullptr;
505 casterUnit = caster->
ToUnit();
510 double valueVariance =
frand(-delta, delta);
511 value += double(basePoints) * valueVariance;
514 *variance = valueVariance;
525 if (casterUnit && basePointsPerLevel != 0.0)
535 value += level * basePointsPerLevel;
545 value += comboDamage * comboPoints;
551 return int32(round(value));
561 else if (caster && caster->
IsUnit())
579 uint32 effectiveItemLevel = itemLevel != -1 ?
uint32(itemLevel) : 1u;
611 if (value > 0.0f && value < 1.0f)
614 return int32(round(value));
627 int32 expansion = -2;
629 expansion = contentTuning->ExpansionID;
634 else if (caster && caster->
IsUnit())
640 return int32(round(value));
657 return multiplierPercent / 100.0f;
697 else if (radius == 0.0f)
702 if (
Unit const* casterUnit = caster->
ToUnit())
705 radius = std::min(radius, entry->
RadiusMax);
744 return effImplicitTargetMask;
1199 for (
size_t i = 0; i <
_effects.size(); ++i)
1230 Speed = _misc->Speed;
1291 Dispel = _categories->DispelType;
1294 DmgClass = _categories->DefenseType;
1362 Stances =
MAKE_PAIR64(_shapeshift->ShapeshiftMask[0], _shapeshift->ShapeshiftMask[1]);
1370 Width = _target->Width;
1397 for (
size_t i = 0; i <
_effects.size(); ++i)
1419 if (eff.IsEffect(effect))
1428 if (effect.IsAura(aura))
1437 if (effect.IsAreaAuraEffect())
1447 if (effect.IsEffect())
1449 switch (effect.Effect)
1472 if (effect.TargetA.GetTarget() == target || effect.TargetB.GetTarget() == target)
1517 uint32 skill = effect.MiscValue;
1532 uint32 skill = effect.MiscValue;
1550 for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
1551 if (_spell_idx->second->SkillLine == skillType)
1570 if (effect.IsEffect() && effect.IsTargetingArea())
1606 mask |= effect.GetProvidedTargetMask();
1705 if (!effect.IsEffect())
1719 switch (effect.TargetA.GetCheckType())
1919 return spellSpec1 == spellSpec2;
1972 bool actAsShifted =
false;
1979 TC_LOG_ERROR(
"spells",
"GetErrorAtShapeshiftedCast: unknown shapeshift {}", form);
2009 for (
uint32 areaId : areaGroupMembers)
2032 mountFlags = areaTable->GetMountFlags();
2045 if (!mapEntry || mapEntry->
IsRaid())
2052 if (!mapEntry || !mapEntry->
IsDungeon())
2065 if (saBounds.first != saBounds.second)
2067 for (SpellAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
2069 if (itr->second.IsFitToRequirements(player, zone_id, area_id))
2140 if (!effect.IsAura())
2143 switch (effect.ApplyAuraName)
2148 if (
uint32 mountType = spellShapeshiftForm->MountTypeID)
2155 uint32 mountType = effect.MiscValueB;
2157 mountType = mountEntry->MountTypeID;
2184 auto getCreatorOrSelf = [](
WorldObject const* obj)
2188 creator = obj->GetGUID();
2192 if (getCreatorOrSelf(caster) != getCreatorOrSelf(target))
2212 if (caster != unitTarget)
2219 if (targetCreature->hasLootRecipient() && !targetCreature->isTappedBy(caster->
ToPlayer()))
2225 if (!targetCreature)
2328 if (
Unit const* unitCaster = caster->
ToUnit())
2330 if (!unitCaster->IsVehicle() && !(unitCaster->GetCharmerOrOwner() == target))
2354 if (instance->GetCombatResurrectionCharges() == 0 && instance->IsEncounterInProgress())
2371 if (
Unit const* unitTarget = target->
ToUnit())
2388 if (unitTarget->IsOnVehicle(unitCaster))
2411 if (shapeShiftFromEntry && (shapeShiftFromEntry->
Flags & 1) == 0)
2425 && (vehicleSeat->
Flags & checkMask) != checkMask)
2478 if (effect.IsEffect() && effect.Mechanic)
2479 mask |=
UI64LIT(1) << effect.Mechanic;
2503 if ((effectMask & (1 << effect.EffectIndex)) && effect.Mechanic)
2504 mask |=
UI64LIT(1) << effect.Mechanic;
2531 return uint32(1 << type);
2648 if (!effect.IsAura())
2650 switch (effect.ApplyAuraName)
2678 switch (firstRankSpellInfo->
Id)
2718 if (
Id == 603 ||
Id == 980 ||
Id == 80240)
2784 if (
Id == 48266 ||
Id == 48263 ||
Id == 48265)
2793 switch (effect.ApplyAuraName)
2853 else if (
Id == 47481)
2856 else if (
Id == 66689)
2859 else if (
Id == 64155)
2862 else if (
Id == 51750)
2865 else if (
Id == 48179)
3024 if (
Id == 200108 ||
Id == 212638)
3223 auto diminishingLimitDurationCompute = [
this]() ->
int32
3310 std::unique_ptr<SpellEffectInfo::ImmunityInfo> workBuffer = std::make_unique<SpellEffectInfo::ImmunityInfo>();
3314 uint32 schoolImmunityMask = 0;
3315 uint32 applyHarmfulAuraImmunityMask = 0;
3316 uint64 mechanicImmunityMask = 0;
3317 uint32 dispelImmunityMask = 0;
3318 uint32 damageImmunityMask = 0;
3319 uint8 otherImmunityMask = 0;
3321 int32 miscVal = effect.MiscValue;
3325 switch (effect.ApplyAuraName)
3331 schoolImmunityMask |= creatureImmunities->School.to_ulong();
3332 dispelImmunityMask |= creatureImmunities->DispelType.to_ulong();
3333 mechanicImmunityMask |= creatureImmunities->Mechanic.to_ullong();
3334 otherImmunityMask |= creatureImmunities->Other.AsUnderlyingType();
3337 for (
AuraType aura : creatureImmunities->Aura)
3369 mechanicImmunityMask |=
UI64LIT(1) << miscVal;
3386 schoolImmunityMask |=
uint32(miscVal);
3391 applyHarmfulAuraImmunityMask |=
uint32(miscVal);
3396 damageImmunityMask |=
uint32(miscVal);
3401 dispelImmunityMask = 1u << miscVal;
3427 effect._immunityInfo = std::move(workBuffer);
3428 workBuffer = std::make_unique<SpellEffectInfo::ImmunityInfo>();
3478 if (maxTargetsEffectValueHolder)
3484 if (maxTargets != expectedValue)
3485 TC_LOG_ERROR(
"spells",
"SpellInfo::_LoadSqrtTargetLimit(maxTargets): Spell {} has different value in effect {} than expected, recheck target caps (expected {}, got {})",
3489 TC_LOG_ERROR(
"spells",
"SpellInfo::_LoadSqrtTargetLimit(maxTargets): Spell {} does not have effect {}",
Id,
AsUnderlyingType(*maxTargetsEffectValueHolder));
3492 if (numNonDiminishedTargetsEffectValueHolder)
3494 if (numNonDiminishedTargetsEffectValueHolder <
GetEffects().
size())
3498 if (numNonDiminishedTargets != expectedValue)
3499 TC_LOG_ERROR(
"spells",
"SpellInfo::_LoadSqrtTargetLimit(numNonDiminishedTargets): Spell {} has different value in effect {} than expected, recheck target caps (expected {}, got {})",
3500 Id,
AsUnderlyingType(*numNonDiminishedTargetsEffectValueHolder), numNonDiminishedTargets, expectedValue);
3503 TC_LOG_ERROR(
"spells",
"SpellInfo::_LoadSqrtTargetLimit(numNonDiminishedTargets): Spell {} does not have effect {}",
Id,
AsUnderlyingType(*numNonDiminishedTargetsEffectValueHolder));
3522 if (auraSpellInfo->
Id ==
Id)
3533 if (existingAuraCaster && existingAuraCaster->
IsFriendlyTo(target))
3547 if (mechanicImmunity & (
UI64LIT(1) << i))
3556 std::vector<Aura*> aurasToUpdateTargets;
3561 aurasToUpdateTargets.push_back(aura);
3567 for (
Aura* aura : aurasToUpdateTargets)
3568 aura->UpdateTargetMap(aura->GetCaster());
3576 if (dispelImmunity & (1 << i))
3585 if ((dispelMask & dispelImmunity) == dispelMask)
3625 if (!effectInfo.IsEffect())
3634 if ((auraSpellInfo->
SchoolMask & schoolImmunity) != 0)
3638 if ((mechanicImmunity & (
UI64LIT(1) << auraSpellInfo->
Mechanic)) != 0)
3642 if (auraSpellInfo->
Dispel == dispelImmunity)
3645 bool immuneToAllEffects =
true;
3648 if (!auraSpellEffectInfo.IsAura())
3652 if ((mechanicImmunity & (
UI64LIT(1) << auraSpellEffectInfo.Mechanic)) != 0)
3655 if (
AuraType auraName = auraSpellEffectInfo.ApplyAuraName)
3662 if ((auraSpellInfo->
GetSchoolMask() & applyHarmfulAuraImmunityMask) != 0)
3666 immuneToAllEffects =
false;
3669 if (immuneToAllEffects)
3685 if ((auraSpellInfo->
SchoolMask & schoolImmunity) != 0)
3689 if ((auraSpellInfo->
GetSchoolMask() & applyHarmfulAuraImmunityMask) != 0)
3695 if ((mechanicImmunity & (
UI64LIT(1) << auraSpellInfo->
Mechanic)) != 0)
3697 if ((mechanicImmunity & (
UI64LIT(1) << auraEffectInfo.
Mechanic)) != 0)