Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
2.3 kB
2
Indexable
Never
        const SpellInfo* spellInfo = GetSpellInfo();
        Unit* target = GetHitUnit();
        Unit* caster = GetCaster();
        if (!target || !caster) return;

        if (CheckResistances(caster, target, spellInfo)) {
            return;
        }

        SpellMissInfo missInfo = caster->SpellHitResult(target, spellInfo);
        if (missInfo != SPELL_MISS_NONE) {
            return;
        }

        uint32 spellId = spellInfo->Id;
        auto it = idSpellDataOPCM.find(spellId);
        if (it == idSpellDataOPCM.end()) {
            if (Player* playerCaster = caster->ToPlayer()) {
                playerCaster->GetSession()->SendNotification(HandlerNotFoundMessage, spellId);
            }
            return;
        }

        const SpellData& data = it->second;

        if (IsSpellBlocked(target, data.blockers)) {
            return;
        }
    
        uint16 currentSkill = caster->GetTypeId() == TYPEID_PLAYER ? static_cast<Player*>(caster)->GetSkillValue(SkillName) : MaxCharSkillLevel;

        if (data.aura1ID > 0) {
            if ((data.aura1Targeting == 0) || (data.aura1Targeting == 1 && target != caster) || (data.aura1Targeting == 2 && target == caster)) {
                if (currentSkill >= data.aura1MinSkill && currentSkill <= data.aura1MaxSkill) {
                    ApplyAuraIfChance(caster, target, data.aura1ID, data.aura1Chance, data.aura1Type);
                }
            }
        }
        if (data.aura2ID > 0) {
            if ((data.aura2Targeting == 0) || (data.aura2Targeting == 1 && target != caster) || (data.aura2Targeting == 2 && target == caster)) {
                if (currentSkill >= data.aura2MinSkill && currentSkill <= data.aura2MaxSkill) {
                    ApplyAuraIfChance(caster, target, data.aura2ID, data.aura2Chance, data.aura2Type);
                }
            }
        }
        if (data.aura3ID > 0) {
            if ((data.aura3Targeting == 0) || (data.aura3Targeting == 1 && target != caster) || (data.aura3Targeting == 2 && target == caster)) {
                if (currentSkill >= data.aura3MinSkill && currentSkill <= data.aura3MaxSkill) {
                    ApplyAuraIfChance(caster, target, data.aura3ID, data.aura3Chance, data.aura3Type);
                }
            }
        }
Leave a Comment