feat(Core/Spells): Implemented SPELLVALUE_AURA_DURATION. (#8690)

- Closes #8505
This commit is contained in:
UltraNix
2021-10-24 23:06:57 +02:00
committed by GitHub
parent 9c0894ab4a
commit 3cddfb84c1
3 changed files with 33 additions and 10 deletions

View File

@@ -125,10 +125,11 @@ enum SpellValueMod
SPELLVALUE_RADIUS_MOD,
SPELLVALUE_MAX_TARGETS,
SPELLVALUE_AURA_STACK,
SPELLVALUE_AURA_DURATION,
SPELLVALUE_FORCED_CRIT_RESULT
};
typedef std::pair<SpellValueMod, int32> CustomSpellValueMod;
typedef std::pair<SpellValueMod, int32> CustomSpellValueMod;
class CustomSpellValues : public std::vector<CustomSpellValueMod>
{
public:

View File

@@ -562,6 +562,7 @@ SpellValue::SpellValue(SpellInfo const* proto)
MaxAffectedTargets = proto->MaxAffectedTargets;
RadiusMod = 1.0f;
AuraStackAmount = 1;
AuraDuration = 0;
ForcedCritResult = false;
}
@@ -2966,7 +2967,16 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
if (m_originalCaster->HasAuraTypeWithAffectMask(SPELL_AURA_PERIODIC_HASTE, aurSpellInfo) || m_spellInfo->HasAttribute(SPELL_ATTR5_SPELL_HASTE_AFFECTS_PERIODIC))
duration = int32(duration * m_originalCaster->GetFloatValue(UNIT_MOD_CAST_SPEED));
if (duration != m_spellAura->GetMaxDuration())
if (m_spellValue->AuraDuration != 0)
{
if (m_spellAura->GetMaxDuration() != -1)
{
m_spellAura->SetMaxDuration(m_spellValue->AuraDuration);
}
m_spellAura->SetDuration(m_spellValue->AuraDuration);
}
else if (duration != m_spellAura->GetMaxDuration())
{
m_spellAura->SetMaxDuration(duration);
m_spellAura->SetDuration(duration);
@@ -3043,23 +3053,31 @@ void Spell::DoTriggersOnSpellHit(Unit* unit, uint8 effMask)
{
if (CanExecuteTriggersOnHit(effMask, i->triggeredByAura) && roll_chance_i(i->chance))
{
m_caster->CastSpell(unit, i->triggeredSpell, true);
LOG_DEBUG("spells.aura", "Spell %d triggered spell %d by SPELL_AURA_ADD_TARGET_TRIGGER aura", m_spellInfo->Id, i->triggeredSpell->Id);
// SPELL_AURA_ADD_TARGET_TRIGGER auras shouldn't trigger auras without duration
// set duration of current aura to the triggered spell
if (i->triggeredSpell->GetDuration() == -1)
{
// get duration from aura-only once
if (!_duration)
{
Aura* aur = unit->GetAura(m_spellInfo->Id, m_caster->GetGUID());
_duration = aur ? aur->GetDuration() : -1;
}
if (Aura* triggeredAur = unit->GetAura(i->triggeredSpell->Id, m_caster->GetGUID()))
{
// get duration from aura-only once
if (!_duration)
{
Aura* aur = unit->GetAura(m_spellInfo->Id, m_caster->GetGUID());
_duration = aur ? aur->GetDuration() : -1;
}
triggeredAur->SetDuration(_duration);
triggeredAur->SetDuration(std::max(triggeredAur->GetDuration(), _duration));
}
else
{
m_caster->CastCustomSpell(i->triggeredSpell->Id, SPELLVALUE_AURA_DURATION, _duration, unit, true);
}
}
else
{
m_caster->CastSpell(unit, i->triggeredSpell, true);
}
}
}
@@ -7916,6 +7934,9 @@ void Spell::SetSpellValue(SpellValueMod mod, int32 value)
case SPELLVALUE_AURA_STACK:
m_spellValue->AuraStackAmount = uint8(value);
break;
case SPELLVALUE_AURA_DURATION:
m_spellValue->AuraDuration = value;
break;
case SPELLVALUE_FORCED_CRIT_RESULT:
m_spellValue->ForcedCritResult = (bool)value;
break;

View File

@@ -214,6 +214,7 @@ struct SpellValue
uint32 MaxAffectedTargets;
float RadiusMod;
uint8 AuraStackAmount;
int32 AuraDuration;
bool ForcedCritResult;
};