diff options
| author | Shauren <shauren.trinity@gmail.com> | 2023-10-22 18:39:59 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2023-10-22 18:39:59 +0200 |
| commit | dc9361fcc2eb16a59b52dfd8b0d47dfc1bf639be (patch) | |
| tree | b25b12a693f3e60f940be7a78df72b7ba47f4718 /src/server/game/Spells/Spell.cpp | |
| parent | b2393d6adeca9a54b6ff1fb62a87da48c068f010 (diff) | |
Core/Spells: Named and implemented most of SpellAttr8
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 157 |
1 files changed, 131 insertions, 26 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index c0bc954a8b2..fce17019d45 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -824,6 +824,22 @@ void Spell::SelectSpellTargets() } } + if (m_targets.HasDst()) + { + if (m_spellInfo->HasAttribute(SPELL_ATTR8_REQUIRES_LOCATION_TO_BE_ON_LIQUID_SURFACE)) + { + ZLiquidStatus status = m_caster->GetMap()->GetLiquidStatus(m_caster->GetPhaseShift(), + m_targets.GetDstPos()->GetPositionX(), m_targets.GetDstPos()->GetPositionY(), m_targets.GetDstPos()->GetPositionZ(), + map_liquidHeaderTypeFlags::AllLiquids); + if (!(status & (LIQUID_MAP_WATER_WALK | LIQUID_MAP_IN_WATER))) + { + SendCastResult(SPELL_FAILED_NO_LIQUID); + finish(SPELL_FAILED_NO_LIQUID); + return; + } + } + } + if (uint64 dstDelay = CalculateDelayMomentForDst(m_spellInfo->LaunchDelay)) m_delayMoment = dstDelay; } @@ -2740,7 +2756,7 @@ void Spell::TargetInfo::DoTargetSpellHit(Spell* spell, SpellEffectInfo const& sp if (unit->IsAlive() != IsAlive) return; - if (spell->getState() == SPELL_STATE_DELAYED && !spell->IsPositive() && (GameTime::GetGameTimeMS() - TimeDelay) <= unit->m_lastSanctuaryTime) + if (!spell->m_spellInfo->HasAttribute(SPELL_ATTR8_IGNORE_SANCTUARY) && spell->getState() == SPELL_STATE_DELAYED && !spell->IsPositive() && (GameTime::GetGameTimeMS() - TimeDelay) <= unit->m_lastSanctuaryTime) return; // No missinfo in that case if (_spellHitTarget) @@ -4672,6 +4688,9 @@ void Spell::SendSpellStart() if (HasPowerTypeCost(POWER_RUNES)) castFlags |= CAST_FLAG_NO_GCD; // not needed, but Blizzard sends it + if (m_spellInfo->HasAttribute(SPELL_ATTR8_HEAL_PREDICTION) && m_casttime && m_caster->IsUnit()) + castFlags |= CAST_FLAG_HEAL_PREDICTION; + WorldPackets::Spells::SpellStart packet; WorldPackets::Spells::SpellCastData& castData = packet.Cast; @@ -4737,13 +4756,8 @@ void Spell::SendSpellStart() castData.Immunities.Value = mechanicImmunityMask; } - /** @todo implement heal prediction packet data if (castFlags & CAST_FLAG_HEAL_PREDICTION) - { - castData.Predict.BeconGUID = ?? - castData.Predict.Points = 0; - castData.Predict.Type = 0; - }**/ + UpdateSpellHealPrediction(castData.Predict, false); m_caster->SendMessageToSet(packet.Write(), true); } @@ -4948,6 +4962,84 @@ int32 Spell::GetSpellCastDataAmmo() return ammoDisplayID; } +static std::pair<int32, SpellHealPredictionType> CalcPredictedHealing(SpellInfo const* spellInfo, Unit const* unitCaster, Unit* target, uint32 castItemEntry, int32 castItemLevel, Spell* spell, bool withPeriodic) +{ + int32 points = 0; + SpellHealPredictionType type = SPELL_HEAL_PREDICTION_TARGET; + for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) + { + switch (spellEffectInfo.Effect) + { + case SPELL_EFFECT_HEAL: + case SPELL_EFFECT_HEAL_PCT: + points += unitCaster->SpellHealingBonusDone(target, + spellInfo, spellEffectInfo.CalcValue(unitCaster, nullptr, target, nullptr, castItemEntry, castItemLevel), + DIRECT_DAMAGE, spellEffectInfo, 1, spell); + + if (target != unitCaster && (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_CASTER || spellEffectInfo.TargetB.GetTarget() == TARGET_UNIT_CASTER)) + type = SPELL_HEAL_PREDICTION_TARGET_AND_CASTER; // Binding Heal-like spells + else if (spellEffectInfo.TargetA.GetCheckType() == TARGET_CHECK_PARTY || spellEffectInfo.TargetB.GetCheckType() == TARGET_CHECK_PARTY) + type = SPELL_HEAL_PREDICTION_TARGET_PARTY; // Prayer of Healing (old party-wide targeting) + break; + default: + break; + } + + if (withPeriodic) + { + switch (spellEffectInfo.ApplyAuraName) + { + case SPELL_AURA_PERIODIC_HEAL: + case SPELL_AURA_OBS_MOD_HEALTH: + points += unitCaster->SpellHealingBonusDone(target, + spellInfo, spellEffectInfo.CalcValue(unitCaster, nullptr, target, nullptr, castItemEntry, castItemLevel), + DIRECT_DAMAGE, spellEffectInfo, 1, spell) * spellInfo->GetMaxTicks(); + break; + case SPELL_AURA_PERIODIC_TRIGGER_SPELL: + if (SpellInfo const* triggered = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, spellInfo->Difficulty)) + points += CalcPredictedHealing(triggered, unitCaster, target, castItemEntry, castItemLevel, nullptr, withPeriodic).first; + break; + default: + break; + } + } + } + + return { points, type }; +} + +void Spell::UpdateSpellHealPrediction(WorldPackets::Spells::SpellHealPrediction& healPrediction, bool withPeriodic) +{ + healPrediction.BeaconGUID = ObjectGuid::Empty; + healPrediction.Points = 0; + healPrediction.Type = SPELL_HEAL_PREDICTION_TARGET; + + Unit const* unitCaster = m_caster->ToUnit(); + + if (Unit* target = m_targets.GetUnitTarget()) + { + auto [points, type] = CalcPredictedHealing(m_spellInfo, unitCaster, target, m_castItemEntry, m_castItemLevel, this, withPeriodic); + healPrediction.Points = points; + healPrediction.Type = type; + } + + static constexpr uint32 beaconSpellId = 53651; + + if (healPrediction.Type == SPELL_HEAL_PREDICTION_TARGET && unitCaster->HasAura(beaconSpellId, unitCaster->GetGUID())) + { + auto beacon = std::find_if(unitCaster->GetSingleCastAuras().begin(), unitCaster->GetSingleCastAuras().end(), [](Aura const* aura) + { + return aura->GetSpellInfo()->GetEffects().size() > EFFECT_1 && aura->GetSpellInfo()->GetEffect(EFFECT_1).TriggerSpell == beaconSpellId; + }); + + if (beacon != unitCaster->GetSingleCastAuras().end()) + { + healPrediction.BeaconGUID = (*beacon)->GetOwner()->GetGUID(); + healPrediction.Type = SPELL_HEAL_PREDICTION_TARGET_AND_BEACON; + } + } +} + void Spell::SendSpellExecuteLog() { if (_executeLogEffects.empty()) @@ -5112,23 +5204,6 @@ void Spell::SendChannelStart(uint32 duration) if (!unitCaster) return; - WorldPackets::Spells::SpellChannelStart spellChannelStart; - spellChannelStart.CasterGUID = unitCaster->GetGUID(); - spellChannelStart.SpellID = m_spellInfo->Id; - spellChannelStart.Visual = m_SpellVisual; - spellChannelStart.ChannelDuration = duration; - unitCaster->SendMessageToSet(spellChannelStart.Write(), true); - - uint32 schoolImmunityMask = unitCaster->GetSchoolImmunityMask(); - uint32 mechanicImmunityMask = unitCaster->GetMechanicImmunityMask(); - - if (schoolImmunityMask || mechanicImmunityMask) - { - spellChannelStart.InterruptImmunities.emplace(); - spellChannelStart.InterruptImmunities->SchoolImmunities = schoolImmunityMask; - spellChannelStart.InterruptImmunities->Immunities = mechanicImmunityMask; - } - m_timer = duration; if (!m_targets.HasDst()) @@ -5176,6 +5251,33 @@ void Spell::SendChannelStart(uint32 duration) unitCaster->SetChannelSpellId(m_spellInfo->Id); unitCaster->SetChannelVisual(m_SpellVisual); + + WorldPackets::Spells::SpellChannelStart spellChannelStart; + spellChannelStart.CasterGUID = unitCaster->GetGUID(); + spellChannelStart.SpellID = m_spellInfo->Id; + spellChannelStart.Visual = m_SpellVisual; + spellChannelStart.ChannelDuration = duration; + + uint32 schoolImmunityMask = unitCaster->GetSchoolImmunityMask(); + uint32 mechanicImmunityMask = unitCaster->GetMechanicImmunityMask(); + + if (schoolImmunityMask || mechanicImmunityMask) + { + spellChannelStart.InterruptImmunities.emplace(); + spellChannelStart.InterruptImmunities->SchoolImmunities = schoolImmunityMask; + spellChannelStart.InterruptImmunities->Immunities = mechanicImmunityMask; + } + + if (m_spellInfo->HasAttribute(SPELL_ATTR8_HEAL_PREDICTION) && m_casttime && m_caster->IsUnit()) + { + WorldPackets::Spells::SpellTargetedHealPrediction& healPrediction = spellChannelStart.HealPrediction.emplace(); + if (unitCaster->m_unitData->ChannelObjects.size() == 1 && unitCaster->m_unitData->ChannelObjects[0].IsUnit()) + healPrediction.TargetGUID = unitCaster->m_unitData->ChannelObjects[0]; + + UpdateSpellHealPrediction(healPrediction.Predict, true); + } + + unitCaster->SendMessageToSet(spellChannelStart.Write(), true); } void Spell::SendResurrectRequest(Player* target) @@ -5594,6 +5696,9 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32 return SPELL_FAILED_CUSTOM_ERROR; } + if (m_spellInfo->HasAttribute(SPELL_ATTR8_ONLY_PLAYERS_CAN_CAST_THIS_SPELL) && !m_caster->IsPlayer()) + return SPELL_FAILED_CASTER_AURASTATE; + // Check global cooldown if (strict && !(_triggeredCastFlags & TRIGGERED_IGNORE_GCD) && HasGlobalCooldown()) return !m_spellInfo->HasAttribute(SPELL_ATTR0_COOLDOWN_ON_EVENT) ? SPELL_FAILED_NOT_READY : SPELL_FAILED_DONT_REPORT; @@ -6920,7 +7025,7 @@ SpellCastResult Spell::CheckArenaAndRatedBattlegroundCastRules() return isArena ? SPELL_FAILED_NOT_IN_ARENA : SPELL_FAILED_NOT_IN_RATED_BATTLEGROUND; if (isArena && m_spellInfo->HasAttribute(SPELL_ATTR9_NOT_USABLE_IN_ARENA)) - return SPELL_FAILED_NOT_IN_ARENA; + return SPELL_FAILED_NOT_IN_ARENA; // check cooldowns uint32 spellCooldown = m_spellInfo->GetRecoveryTime(); @@ -8075,7 +8180,7 @@ bool Spell::IsPositive() const bool Spell::IsNeedSendToClient() const { return m_SpellVisual.SpellXSpellVisualID || m_SpellVisual.ScriptVisualID || m_spellInfo->IsChanneled() || - (m_spellInfo->HasAttribute(SPELL_ATTR8_AURA_SEND_AMOUNT)) || m_spellInfo->HasHitDelay() || (!m_triggeredByAuraSpell && !IsTriggered()) || + (m_spellInfo->HasAttribute(SPELL_ATTR8_AURA_POINTS_ON_CLIENT)) || m_spellInfo->HasHitDelay() || (!m_triggeredByAuraSpell && !IsTriggered()) || m_spellInfo->HasAttribute(SPELL_ATTR7_ALWAYS_CAST_LOG); } |
