示例#1
0
    def remove_colliding_effects(self, aura):
        # Special case with SpellEffect mounting and mounting by aura
        if aura.spell_effect.aura_type == AuraTypes.SPELL_AURA_MOUNTED and \
                aura.target.unit_flags & UnitFlags.UNIT_MASK_MOUNTED and not \
                self.get_auras_by_type(AuraTypes.SPELL_AURA_MOUNTED):
            AuraEffectHandler.handle_mounted(
                aura, aura.target, remove=True)  # Remove mount effect
            # If a mount aura would be applied but we dismount the unit, don't apply the new mount aura.
            return False

        aura_spell_template = aura.source_spell.spell_entry

        new_aura_name = aura_spell_template.Name_enUS
        new_aura_rank = DbcDatabaseManager.SpellHolder.spell_get_rank_by_spell(
            aura_spell_template)

        aura_effect_index = aura.spell_effect.effect_index
        caster_guid = aura.caster.guid

        for applied_aura in list(self.active_auras.values()):
            applied_spell_entry = applied_aura.source_spell.spell_entry
            applied_aura_name = applied_spell_entry.Name_enUS
            applied_aura_rank = DbcDatabaseManager.SpellHolder.spell_get_rank_by_spell(
                applied_spell_entry)

            # TODO Same effects but different spells (exclusivity groups)?

            # Note: This method ignores the case of a weaker spell being applied, as that is handled in can_apply_aura.
            is_similar_and_weaker = applied_aura.spell_effect.effect_index == aura_effect_index and \
                applied_aura_name == new_aura_name and applied_aura_rank < new_aura_rank

            are_exclusive_by_source = ExtendedSpellData.AuraSourceRestrictions.are_colliding_auras(
                aura.spell_id,
                applied_aura.spell_id)  # Paladin seals, warlock curses

            # Source doesn't matter for unique auras.
            is_unique = applied_aura.source_spell.spell_entry.AttributesEx & SpellAttributesEx.SPELL_ATTR_EX_AURA_UNIQUE or not aura.harmful  # Buffs are unique.
            is_stacking = applied_aura.can_stack
            is_same_but_different_aura_index = aura.spell_id == applied_aura.spell_id and aura.spell_effect.effect_index != applied_aura.spell_effect.effect_index

            casters_are_same = applied_aura.caster.guid == caster_guid
            if is_similar_and_weaker and (is_unique or casters_are_same and not is_stacking) or \
                    are_exclusive_by_source and casters_are_same and not is_same_but_different_aura_index:
                self.remove_aura(applied_aura)
                continue

            if applied_aura.spell_effect.aura_type == AuraTypes.SPELL_AURA_MOD_SHAPESHIFT and \
                    aura.spell_effect.aura_type == AuraTypes.SPELL_AURA_MOD_SHAPESHIFT:
                self.remove_aura(
                    applied_aura)  # Player can only be in one shapeshift form.
                continue

        return True
示例#2
0
    def remove_colliding_effects(self, aura):
        # Special case with SpellEffect mounting and mounting by aura
        if aura.spell_effect.aura_type == AuraTypes.SPELL_AURA_MOUNTED and \
                aura.target.unit_flags & UnitFlags.UNIT_MASK_MOUNTED and not \
                self.get_auras_by_type(AuraTypes.SPELL_AURA_MOUNTED):
            AuraEffectHandler.handle_mounted(aura, True)  # Remove mount effect

        aura_spell_template = aura.source_spell.spell_entry
        aura_effect_index = aura.spell_effect.effect_index
        caster_guid = aura.caster.guid

        for applied_aura in list(self.active_auras.values()):
            if applied_aura.caster.guid != caster_guid or \
                    applied_aura.spell_effect.effect_index != aura_effect_index or \
                    applied_aura.source_spell.spell_entry != aura_spell_template:
                continue
            self.remove_aura(
                applied_aura)  # Remove identical auras the caster has applied
示例#3
0
    def remove_colliding_effects(self, aura):
        # Special case with SpellEffect mounting and mounting by aura
        if aura.spell_effect.aura_type == AuraTypes.SPELL_AURA_MOUNTED and \
                aura.target.unit_flags & UnitFlags.UNIT_MASK_MOUNTED and not \
                self.get_auras_by_type(AuraTypes.SPELL_AURA_MOUNTED):
            AuraEffectHandler.handle_mounted(
                aura, aura.target, remove=True)  # Remove mount effect

        aura_spell_template = aura.source_spell.spell_entry
        aura_effect_index = aura.spell_effect.effect_index
        caster_guid = aura.caster.guid

        for applied_aura in list(self.active_auras.values()):
            # TODO is_similar does not match different spell ranks
            is_similar = applied_aura.source_spell.spell_entry == aura_spell_template and \
                         applied_aura.spell_effect.effect_index == aura_effect_index  # Spell and effect are the same

            are_exclusive_by_source = ExtendedSpellData.AuraSourceRestrictions.are_colliding_auras(
                aura.spell_id,
                applied_aura.spell_id)  # Paladin seals, warlock curses

            # Source doesn't matter for unique auras
            is_unique = applied_aura.source_spell.spell_entry.AttributesEx & SpellAttributesEx.SPELL_ATTR_EX_AURA_UNIQUE or not aura.harmful  # Buffs are unique.
            is_stacking = applied_aura.can_stack

            casters_are_same = applied_aura.caster.guid == caster_guid
            if is_similar and (is_unique or casters_are_same and not is_stacking) or \
                    are_exclusive_by_source and casters_are_same:
                self.remove_aura(applied_aura)
                continue

            if applied_aura.spell_effect.aura_type == AuraTypes.SPELL_AURA_MOD_SHAPESHIFT and \
                    aura.spell_effect.aura_type == AuraTypes.SPELL_AURA_MOD_SHAPESHIFT:
                self.remove_aura(
                    applied_aura)  # Player can only be in one shapeshift form
                continue