GetIndex() public static method

Returns the index of 'resource' in the seriest of resources for which it belongs.
public static GetIndex ( CraftResource resource ) : int
resource CraftResource
return int
示例#1
0
        public override void AddNameProperties(ObjectPropertyList list)
        {
            base.AddNameProperties(list);

            int index = CraftResources.GetIndex(Resource);

            if (index >= 1 && index <= 8)
            {
                return;
            }

            if (!CraftResources.IsStandard(Resource))
            {
                int num = CraftResources.GetLocalizationNumber(Resource);

                if (num > 0)
                {
                    list.Add(num);
                }
                else
                {
                    list.Add(CraftResources.GetName(Resource));
                }
            }
        }
        public override void AddNameProperty(ObjectPropertyList list)
        {
            int index = CraftResources.GetIndex(Resource);

            if (index >= 1 && index <= 8)
            {
                list.Add(1049019 + index);
            }
            else
            {
                list.Add(1045128);                   // runic smithy hammer
            }
        }
示例#3
0
        public override void OnDoubleClick(Mobile from)
        {
            if (from.FindItemOnLayer(Layer.OneHanded) is SmithHammer)
            {
                bool hasForge, hasAnvil;
                DefBlacksmithy.CheckAnvilAndForge(from, 4, out hasAnvil, out hasForge);

                if (hasForge && hasAnvil)
                {
                    CraftSubRes subRes = CustomCraftMenu.GetSubRes(DefBlacksmithy.CraftSystem, GetType(), null);
                    int         num    = CraftResources.GetIndex(m_Resource);

                    if (subRes == null || !CustomCraftMenu.ResourceInfoList.ContainsKey(subRes))
                    {
                        from.SendAsciiMessage("You can't use that.");
                        return;
                    }

                    if (from.Skills[DefBlacksmithy.CraftSystem.MainSkill].Base < subRes.RequiredSkill)
                    {
                        from.SendAsciiMessage("You cannot work this strange and unusual metal.");
                        return;
                    }

                    from.SendGump(new CraftGump(from, DefBlacksmithy.CraftSystem, (BaseTool)from.FindItemOnLayer(Layer.OneHanded), null, num));
                }
                else
                {
                    from.SendAsciiMessage("You need to be close to a forge and anvil.");
                }
            }
            else
            {
                from.SendAsciiMessage("You need to equip a smith's hammer.");
            }

            base.OnDoubleClick(from);
        }
示例#4
0
        protected override void OnTarget(Mobile from, object targeted)
        {
            bool hasForge, hasAnvil;

            DefBlacksmithy.CheckAnvilAndForge(from, 4, out hasAnvil, out hasForge);

            if (targeted is BaseIngot && m_Tool is BaseTool)
            {
                if (hasAnvil && hasForge)
                {
                    BaseTool    tool   = (BaseTool)m_Tool;
                    BaseIngot   ingot  = (BaseIngot)targeted;
                    CraftSubRes subRes = CustomCraftMenu.GetSubRes(DefBlacksmithy.CraftSystem, targeted.GetType(), null);
                    int         num    = CraftResources.GetIndex(ingot.Resource);

                    if (subRes == null || !CustomCraftMenu.ResourceInfoList.ContainsKey(subRes))
                    {
                        from.SendAsciiMessage("You can't use that.");
                        return;
                    }

                    if (from.Skills[DefBlacksmithy.CraftSystem.MainSkill].Base < subRes.RequiredSkill)
                    {
                        from.SendAsciiMessage("You cannot work this strange and unusual metal.");
                        return;
                    }

                    from.SendGump(new CraftGump(from, m_CraftSystem, tool, null, num));
                    //from.SendMenu( new CustomCraftMenu( from, DefBlacksmithy.CraftSystem, ( (BaseTool)m_Tool ), -1, targeted.GetType(), CustomCraftMenu.ResourceInfoList[subRes].ResourceIndex ) );
                }
                else
                {
                    from.SendAsciiMessage("You need to be close to a forge and anvil to smith.");
                }
            }
            else if (targeted is BaseIngot && !(m_Tool is BaseTool))
            {
                from.SendAsciiMessage("You need to use a smith's hammer on that.");
            }
            else
            {
                if (!hasAnvil)
                {
                    from.SendAsciiMessage("You need to be close to an anvil to repair.");
                    return;
                }

                int number;

                if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        number = 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            weapon.MaxHitPoints -= toWeaken;
                            weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            weapon.HitPoints = weapon.MaxHitPoints;
                        }
                        else
                        {
                            number = 1044280;                             // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        number = 1044277;
                    }
                    // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;
                    }
                    // That item has been repaired many times, and will break if repairs are attempted again.
                    else
                    {
                        if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;
                        }
                        else
                        {
                            number = 1044280;
                            // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }
                else if (targeted is Item)
                {
                    number = 1044277;                     // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }
                from.SendAsciiMessage(CliLoc.LocToString(number));
            }
        }