Ejemplo n.º 1
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.º 2
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.º 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)
 {
     return((RequiredSpellId == 0 || chr.Spells.Contains(RequiredSpellId)) &&
            (RaceMask == 0 || RaceMask.HasAnyFlag(chr.RaceMask)) &&
            (ClassMask == 0 || ClassMask.HasAnyFlag(chr.ClassMask)));
 }
Ejemplo n.º 4
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);
        }