Ejemplo n.º 1
0
 /// <summary>
 /// Method used to add custom search criterias. Added Who List custom search criterias to the default ones.
 /// </summary>
 /// <param name="character">The <see cref="T:WCell.RealmServer.Entities.Character" /> to be checked against custom search criterias.</param>
 /// <returns>True if the character pass all custom search criterias. False otherwise.</returns>
 protected override bool IncludeCharacter(Character character)
 {
     return(base.IncludeCharacter(character) &&
            (Faction == FactionGroup.Invalid || character.Faction.Group == Faction) &&
            (string.IsNullOrEmpty(GuildName) && RaceMask.HasAnyFlag(character.RaceMask2) &&
             ClassMask.HasAnyFlag(character.ClassMask2)) &&
            ((Zones.Count <= 0 || Zones.Contains(character.Zone.Id)) &&
             (Names.Count <= 0 || Names.Contains(character.Name.ToLower()))));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns what went wrong (if anything) when the given unit tries to equip or use Items of this Template.
        /// </summary>
        public InventoryError CheckEquip(Character chr)
        {
            if (chr.GodMode)
            {
                return(InventoryError.OK);
            }
            if (chr.Level < RequiredLevel)
            {
                return(InventoryError.YOU_MUST_REACH_LEVEL_N);
            }
            if (RequiredClassMask != ClassMask.None && !RequiredClassMask.HasAnyFlag(chr.ClassMask))
            {
                return(InventoryError.YOU_CAN_NEVER_USE_THAT_ITEM);
            }
            if (RequiredRaceMask != ~RaceMask.AllRaces1 && !RequiredRaceMask.HasAnyFlag(chr.RaceMask))
            {
                return(InventoryError.YOU_CAN_NEVER_USE_THAT_ITEM2);
            }
            if (RequiredFaction != null)
            {
                if (chr.Faction != RequiredFaction)
                {
                    return(InventoryError.YOU_CAN_NEVER_USE_THAT_ITEM2);
                }
                if (RequiredFactionStanding != StandingLevel.Hated &&
                    chr.Reputations.GetStandingLevel(RequiredFaction.ReputationIndex) >=
                    RequiredFactionStanding)
                {
                    return(InventoryError.ITEM_REPUTATION_NOT_ENOUGH);
                }
            }

            if (RequiredSkill != null &&
                !chr.Skills.CheckSkill(RequiredSkill.Id, (int)RequiredSkillValue))
            {
                return(InventoryError.SKILL_ISNT_HIGH_ENOUGH);
            }
            if (RequiredProfession != null && !chr.Spells.Contains(RequiredProfessionId))
            {
                return(InventoryError.NO_REQUIRED_PROFICIENCY);
            }
            if (Set != null && Set.RequiredSkill != null &&
                !chr.Skills.CheckSkill(Set.RequiredSkill.Id, (int)Set.RequiredSkillValue))
            {
                return(InventoryError.SKILL_ISNT_HIGH_ENOUGH);
            }
            if (ItemProfession != SkillId.None && !chr.Skills.Contains(ItemProfession))
            {
                return(InventoryError.NO_REQUIRED_PROFICIENCY);
            }
            return(IsWeapon && !chr.MayCarry(InventorySlotMask)
        ? InventoryError.CANT_DO_WHILE_DISARMED
        : InventoryError.OK);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Whether this NPC can train the character in their specialty.
 /// </summary>
 /// <returns>True if able to train.</returns>
 public bool CanTrain(Character chr)
 {
     if (RequiredSpellId != SpellId.None && !chr.Spells.Contains(RequiredSpellId) ||
         RaceMask != ~RaceMask.AllRaces1 && !RaceMask.HasAnyFlag(chr.RaceMask))
     {
         return(false);
     }
     if (ClassMask != ClassMask.None)
     {
         return(ClassMask.HasAnyFlag(chr.ClassMask));
     }
     return(true);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Method used to add custom search criterias. Added Who List custom search criterias to the default ones.
        /// </summary>
        /// <param name="character">The <see cref="Character"/> to be checked against custom search criterias.</param>
        /// <returns>True if the character pass all custom search criterias. False otherwise.</returns>
        protected override bool IncludeCharacter(Character character)
        {
            if (!base.IncludeCharacter(character))
            {
                return(false);
            }

            if (Faction != FactionGroup.Invalid && character.Faction.Group != Faction)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(GuildName) /*&& character.Guild.Name != GuildName */)
            {
                return(false);
            }

            if (!RaceMask.HasAnyFlag(character.RaceMask2))
            {
                return(false);
            }

            if (!ClassMask.HasAnyFlag(character.ClassMask2))
            {
                return(false);
            }

            if (Zones.Count > 0 && !Zones.Contains(character.Zone.Id))
            {
                return(false);
            }

            if (Names.Count > 0 && !Names.Contains(character.Name.ToLower()))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Whether this NPC can train the character in their specialty.
 /// </summary>
 /// <returns>True if able to train.</returns>
 public bool CanTrain(Character chr)
 {
     return((RequiredSpellId == 0 || chr.Spells.Contains(RequiredSpellId)) &&
            (RaceMask == 0 || RaceMask.HasAnyFlag(chr.RaceMask)) &&
            (ClassMask == 0 || ClassMask.HasAnyFlag(chr.ClassMask)));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns what went wrong (if anything) when the given unit tries to equip or use Items of this Template.
        /// </summary>
        public InventoryError CheckEquip(Character chr)
        {
            if (chr.GodMode)
            {
                return(InventoryError.OK);
            }

            // level
            if (chr.Level < RequiredLevel)
            {
                return(InventoryError.YOU_MUST_REACH_LEVEL_N);
            }

            // class
            if (RequiredClassMask != 0 && !RequiredClassMask.HasAnyFlag(chr.ClassMask))
            {
                return(InventoryError.YOU_CAN_NEVER_USE_THAT_ITEM);
            }

            // race
            if (RequiredRaceMask != 0 && !RequiredRaceMask.HasAnyFlag(chr.RaceMask))
            {
                return(InventoryError.YOU_CAN_NEVER_USE_THAT_ITEM2);
            }

            // faction
            if (RequiredFaction != null)
            {
                if (chr.Faction != RequiredFaction)
                {
                    return(InventoryError.YOU_CAN_NEVER_USE_THAT_ITEM2);
                }

                if (RequiredFactionStanding != StandingLevel.Hated &&
                    chr.Reputations.GetStandingLevel(RequiredFaction.ReputationIndex) >= RequiredFactionStanding)
                {
                    return(InventoryError.ITEM_REPUTATION_NOT_ENOUGH);
                }
            }

            // skill
            if (RequiredSkill != null)
            {
                if (!chr.Skills.CheckSkill(RequiredSkill.Id, (int)RequiredSkillValue))
                {
                    return(InventoryError.SKILL_ISNT_HIGH_ENOUGH);
                }
            }

            // ability
            if (RequiredProfession != null)
            {
                if (!chr.Spells.Contains(RequiredProfessionId))
                {
                    return(InventoryError.NO_REQUIRED_PROFICIENCY);
                }
            }

            // set
            if (Set != null)
            {
                if (Set.RequiredSkill != null)
                {
                    if (!chr.Skills.CheckSkill(Set.RequiredSkill.Id, (int)Set.RequiredSkillValue))
                    {
                        return(InventoryError.SKILL_ISNT_HIGH_ENOUGH);
                    }
                }
            }

            // profession
            if (ItemProfession != SkillId.None)
            {
                if (!chr.Skills.Contains(ItemProfession))
                {
                    return(InventoryError.NO_REQUIRED_PROFICIENCY);
                }
            }

            // Disarmed
            if (IsWeapon && !chr.MayCarry(InventorySlotMask))
            {
                return(InventoryError.CANT_DO_WHILE_DISARMED);
            }

            // TODO: Add missing restrictions
            // if (template.RequiredLockpickSkill
            // if (template.RequiredPvPRank
            // if (RequiredArenaRanking

            return(InventoryError.OK);
        }